From 4fcda3cc1c0fc648572599395ad4a2a3869da7a1 Mon Sep 17 00:00:00 2001 From: GARCIA Pierre-Luc Date: Thu, 21 Mar 2024 18:22:56 +0100 Subject: [PATCH 1/2] Added support for Azure DevOps Server --- index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/index.ts b/index.ts index b1e223d..373ec77 100644 --- a/index.ts +++ b/index.ts @@ -33,7 +33,8 @@ async function run( clientId = AZDEVOPS_AUTH_CLIENT_ID, tenantId = AZDEVOPS_AUTH_TENANT_ID, ciInfo: boolean | string, - projectBasePath?: string + projectBasePath?: string, + resourceId = AZDEVOPS_RESOURCE_ID ) { if (inCI(ciInfo)) { return; @@ -67,18 +68,18 @@ async function run( switch (exception.error) { case "invalid_grant": console.log(chalk.yellow("Refresh token is invalid or expired.")); - tokenSet = await startDeviceCodeFlow(client); + tokenSet = await startDeviceCodeFlow(client, resourceId); break; case "interaction_required": console.log(chalk.yellow("Interaction required.")); - tokenSet = await startDeviceCodeFlow(client); + tokenSet = await startDeviceCodeFlow(client, resourceId); break; default: throw exception; } } } else { - tokenSet = await startDeviceCodeFlow(client); + tokenSet = await startDeviceCodeFlow(client, resourceId); } // Update user npm config with tokens @@ -91,12 +92,12 @@ async function run( } } -async function startDeviceCodeFlow(client: Client) { +async function startDeviceCodeFlow(client: Client, resourceId: string) { console.log(chalk.green("Launching device code authentication...")); // Make sure to include 'offline_access' scope to receive refresh token. const handle = await client.deviceAuthorization({ - scope: `${AZDEVOPS_RESOURCE_ID}/.default offline_access` + scope: `${resourceId}/.default offline_access` }); console.log( From 489331ccfc1a596378dc1d9b80ca4bb0e54dedb6 Mon Sep 17 00:00:00 2001 From: pl-garcia <107400256+pl-garcia@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:05:25 +0100 Subject: [PATCH 2/2] Feature/ado on premises (#3) * Added support for Azure DevOps Server * Modified cli.ts --- cli.ts | 5 +++-- package.json | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cli.ts b/cli.ts index 7e59160..76cd0fa 100644 --- a/cli.ts +++ b/cli.ts @@ -7,8 +7,9 @@ const args = require("minimist")(process.argv.slice(2), { cid: "client_id", tid: "tenant_id", ci: "continuous_integration_variable", - pbp: "project_base_path" + pbp: "project_base_path", + resid: "resource_id" } }); -(async () => await run(args.client_id, args.tenant_id, args.ci, args.pbp))(); +(async () => await run(args.client_id, args.tenant_id, args.ci, args.pbp, args.resid))(); diff --git a/package.json b/package.json index 3c2d53d..799516a 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "azure-devops-npm-auth", - "version": "1.1.1", + "version": "1.2.1", "description": "Authentication utility for private NPM registries hosted in Azure DevOps.", "keywords": [ "azure", "devops", + "azure-devops-server", "npm", "authentication", "artifact",