Skip to content

Add Azure Artifacts npm authentication refresh - #2339

Open
MackinnonBuck wants to merge 1 commit into
mainfrom
mackinnonbuck-add-sdk-npm-auth
Open

Add Azure Artifacts npm authentication refresh#2339
MackinnonBuck wants to merge 1 commit into
mainfrom
mackinnonbuck-add-sdk-npm-auth

Conversation

@MackinnonBuck

Copy link
Copy Markdown
Collaborator

Summary

  • add a guarded Azure Artifacts npm authentication refresh script for the repository's three nested npm packages
  • keep project configs scoped to @github while storing credentials at user level
  • document Microsoft contributor setup and cover platform commands, CLI gating, config output, and error propagation

Validation

  • npm test -- npm-auth-refresh.test.ts (15 passed)
  • npm run lint (passed with 3 existing warnings)
  • npm run typecheck
  • npx tsc --noEmit --strict --skipLibCheck --module NodeNext --moduleResolution NodeNext --target ES2022 --esModuleInterop test\npm-auth-refresh.test.ts
  • npx prettier --config .prettierrc.json --check test\npm-auth-refresh.test.ts ..\scripts\npm-auth-refresh.mjs ..\scripts\npm-auth-refresh.d.mts
  • node .\scripts\npm-auth-refresh.mjs --help

npm run format:check was also run; on this Windows checkout it reports existing CRLF formatting drift in 104 untouched Node files. All new auth files pass the targeted Prettier check above.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 14, 2026 22:46
@MackinnonBuck
MackinnonBuck requested a review from a team as a code owner August 14, 2026 22:46
Comment on lines +86 to +88
const result = spawnSync(invocation.command, invocation.args, {
stdio: "inherit",
});
@github-actions github-actions Bot mentioned this pull request Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds cross-platform Azure Artifacts npm authentication setup for Microsoft contributors.

Changes:

  • Adds guarded credential refresh and scoped .npmrc generation.
  • Adds comprehensive Vitest coverage.
  • Documents setup and ignores generated configurations.
Show a summary per file
File Description
scripts/npm-auth-refresh.mjs Implements configuration and authentication refresh.
scripts/npm-auth-refresh.d.mts Declares script types.
nodejs/test/npm-auth-refresh.test.ts Tests CLI and platform behavior.
nodejs/package.json Adds the refresh command.
CONTRIBUTING.md Documents contributor setup.
.gitignore Ignores generated .npmrc files.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 5/6 changed files
  • Comments generated: 2
  • Review effort level: Balanced

export function writeProjectNpmConfigs(npmrcPaths) {
const config = buildProjectNpmConfig();
for (const npmrcPath of npmrcPaths) {
writeFileSync(npmrcPath, config, "utf8");
},
{
command: "artifacts-npm-credprovider",
args: ["-c", npmrcPath],

@SteveSandersonMS SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 32writeProjectNpmConfigs unconditionally overwrites .npmrc files, erasing any pre-existing unrelated settings. Should either merge the @github:registry key into existing content or reject if the file exists and wasn't generated by this script.

Line 63 — Non-Windows path missing -f/--force flag for artifacts-npm-credprovider. Without it, the documented 'rerun after Azure 401/403' recovery step won't force a fresh token refresh on mac/Linux.

Line 88 — CodeQL alert: shell command built from process.env.ComSpec. Either hardcode the interpreter or validate/sanitize the env value.

@SteveSandersonMS SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of technical issues

export function writeProjectNpmConfigs(npmrcPaths) {
const config = buildProjectNpmConfig();
for (const npmrcPath of npmrcPaths) {
writeFileSync(npmrcPath, config, "utf8");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeProjectNpmConfigs unconditionally overwrites .npmrc files, erasing any pre-existing unrelated settings. Should either merge the @github:registry key into existing content or reject if the file exists and wasn't generated by this script.

},
{
command: "artifacts-npm-credprovider",
args: ["-c", npmrcPath],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-Windows path missing -f/--force flag for artifacts-npm-credprovider. Without it, the documented 'rerun after Azure 401/403' recovery step won't force a fresh token refresh on mac/Linux.

const invocation = getCommandInvocation(platform, command, args, commandInterpreter);
const result = spawnSync(invocation.command, invocation.args, {
stdio: "inherit",
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL alert: shell command built from process.env.ComSpec. Either hardcode the interpreter or validate/sanitize the env value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants