azure-artifacts-auth-check
v0.1.5
Published
Azure DevOps npm authentication preflight and setup CLI
Maintainers
Readme
azure-artifacts-auth-check
Cross-platform CLI for authenticating Azure DevOps Artifacts npm feeds.
- Windows: Wrapper for vsts-npm-auth that uses native Windows authentication and Credential Manager
- macOS/Linux: Manual PAT-based authentication with guided setup
The tool verifies stored credentials, handles authentication when required, writes the necessary entries to ~/.npmrc, and keeps the project .npmrc scoped registry settings up to date.
Installation
Use npx for one-off runs:
npx azure-artifacts-auth-checkOr install globally:
npm install -g azure-artifacts-auth-checkWindows users: On first run, the tool will automatically download and use vsts-npm-auth via npx (no manual installation needed).
Usage
Run the CLI inside your project directory (where azure-feed.config.json lives):
azure-artifacts-auth-checkTo enforce the check before every install, add a preinstall hook in your package.json:
{
"scripts": {
"preinstall": "azure-artifacts-auth-check --silent"
}
}Using --silent avoids noise during routine installs; the command only prints when credentials need attention.
Options
azure-artifacts-auth-check [options]
Options:
--config <path> Path to azure-feed.config.json (defaults to ./azure-feed.config.json)
--cwd <path> Project directory (defaults to current working directory)
--global-npmrc <path> Override path to global ~/.npmrc
--local-npmrc <path> Override path to project .npmrc
--use-pat Force PAT authentication (skip vsts-npm-auth on Windows)
--silent Suppress normal output (only prints when action is required)
--help Show usage informationWindows Users: By default, the tool uses vsts-npm-auth for native Windows authentication. If you prefer to use PAT-based authentication (like macOS/Linux), add the --use-pat flag:
azure-artifacts-auth-check --use-patConfiguration
Create an azure-feed.config.json file in your project root:
{
"feeds": [
{
"registryUrl": "https://contoso.pkgs.visualstudio.com/Apps/_packaging/Widgets/npm/registry/",
"scope": "@contoso"
}
]
}Each feed entry supports:
registryUrl(required) — Azure DevOps npm feed URL.scope(optional but recommended) — npm scope that maps to the feed.organization,project,feed(optional) — only needed when you want to override values derived from the URL.testPackage(optional) — package name the CLI should query instead of the synthetic probe.
How It Works
Common Steps (All Platforms)
- Locates
azure-feed.config.jsonand resolves the feed metadata. - Ensures scoped registry mappings exist in your project
.npmrc. - Checks
~/.npmrcfor stored credentials per feed. - Runs
npm viewagainst each feed to verify authentication.
A 404 during the probe is treated as success—only 401/403 errors trigger authentication.
Platform-Specific Authentication
Windows
When authentication is needed on Windows, the tool (by default):
- Writes registry URLs to
~/.npmrc(required by vsts-npm-auth) - Invokes
npx vsts-npm-auth -C ~/.npmrc - Prompts for Azure DevOps login using native Windows authentication
- Stores credentials securely in Windows Credential Manager
- Verifies all feeds are authenticated
Benefits: Native Windows SSO, automatic credential refresh, secure storage in Credential Manager.
Alternative: Use --use-pat to skip vsts-npm-auth and use PAT-based authentication instead (same flow as macOS/Linux).
macOS/Linux
When authentication is needed on macOS or Linux, the tool:
- Groups feeds by organization
- Prompts you to create a PAT via the Azure DevOps web UI
- Accepts your PAT via stdin
- Base64 encodes the token (no leading colon) and writes to
~/.npmrc - Verifies all feeds are authenticated
PAT Requirements
macOS/Linux: PAT authentication is required. Create a Personal Access Token (PAT) with Packaging → Read scope using the Azure DevOps web UI.
Windows: By default, PATs are not needed—the tool uses native Windows authentication via vsts-npm-auth. However, if you use the --use-pat flag, you'll need to create a PAT just like on macOS/Linux.
The CLI will guide you through the PAT creation process and base64 encode the token correctly (no leading colon) before writing to ~/.npmrc.
