@azure/identity 3.2.0-alpha.20230323.2 → 3.2.0-alpha.20230405.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/dist/index.js +40 -15
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +4 -3
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +8 -3
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +9 -5
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js +18 -3
- package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredentialOptions.js.map +1 -1
- package/dist-esm/src/msal/utils.js +1 -1
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +16 -0
package/dist/index.js
CHANGED
|
@@ -473,7 +473,7 @@ class MsalBaseUtilities {
|
|
|
473
473
|
}
|
|
474
474
|
// transformations.ts
|
|
475
475
|
function publicToMsal(account) {
|
|
476
|
-
const [environment] = account.authority.match(/([a-z]*\.[a-z]*\.[a-z]*)/) || [];
|
|
476
|
+
const [environment] = account.authority.match(/([a-z]*\.[a-z]*\.[a-z]*)/) || [""];
|
|
477
477
|
return Object.assign(Object.assign({}, account), { localAccountId: account.homeAccountId, environment });
|
|
478
478
|
}
|
|
479
479
|
function msalToPublic(clientId, account) {
|
|
@@ -2584,7 +2584,7 @@ const cliCredentialInternals = {
|
|
|
2584
2584
|
* @param resource - The resource to use when getting the token
|
|
2585
2585
|
* @internal
|
|
2586
2586
|
*/
|
|
2587
|
-
async getAzureCliAccessToken(resource, tenantId) {
|
|
2587
|
+
async getAzureCliAccessToken(resource, tenantId, timeout) {
|
|
2588
2588
|
let tenantSection = [];
|
|
2589
2589
|
if (tenantId) {
|
|
2590
2590
|
tenantSection = ["--tenant", tenantId];
|
|
@@ -2599,7 +2599,7 @@ const cliCredentialInternals = {
|
|
|
2599
2599
|
"--resource",
|
|
2600
2600
|
resource,
|
|
2601
2601
|
...tenantSection,
|
|
2602
|
-
], { cwd: cliCredentialInternals.getSafeWorkingDir(), shell: true }, (error, stdout, stderr) => {
|
|
2602
|
+
], { cwd: cliCredentialInternals.getSafeWorkingDir(), shell: true, timeout }, (error, stdout, stderr) => {
|
|
2603
2603
|
resolve({ stdout: stdout, stderr: stderr, error });
|
|
2604
2604
|
});
|
|
2605
2605
|
}
|
|
@@ -2628,6 +2628,7 @@ class AzureCliCredential {
|
|
|
2628
2628
|
constructor(options) {
|
|
2629
2629
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
2630
2630
|
this.additionallyAllowedTenantIds = resolveAddionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
2631
|
+
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2631
2632
|
}
|
|
2632
2633
|
/**
|
|
2633
2634
|
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
@@ -2646,7 +2647,7 @@ class AzureCliCredential {
|
|
|
2646
2647
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
|
|
2647
2648
|
var _a, _b, _c, _d;
|
|
2648
2649
|
try {
|
|
2649
|
-
const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId);
|
|
2650
|
+
const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId, this.timeout);
|
|
2650
2651
|
const specificScope = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("(.*)az login --scope(.*)");
|
|
2651
2652
|
const isLoginError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("(.*)az login(.*)")) && !specificScope;
|
|
2652
2653
|
const isNotInstallError = ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.match("az:(.*)not found")) || ((_d = obj.stderr) === null || _d === void 0 ? void 0 : _d.startsWith("'az' is not recognized"));
|
|
@@ -2739,11 +2740,14 @@ function formatCommand(commandName) {
|
|
|
2739
2740
|
* If anything fails, an error is thrown.
|
|
2740
2741
|
* @internal
|
|
2741
2742
|
*/
|
|
2742
|
-
async function runCommands(commands) {
|
|
2743
|
+
async function runCommands(commands, timeout) {
|
|
2743
2744
|
const results = [];
|
|
2744
2745
|
for (const command of commands) {
|
|
2745
2746
|
const [file, ...parameters] = command;
|
|
2746
|
-
const result = (await processUtils.execFile(file, parameters, {
|
|
2747
|
+
const result = (await processUtils.execFile(file, parameters, {
|
|
2748
|
+
encoding: "utf8",
|
|
2749
|
+
timeout,
|
|
2750
|
+
}));
|
|
2747
2751
|
results.push(result);
|
|
2748
2752
|
}
|
|
2749
2753
|
return results;
|
|
@@ -2798,16 +2802,17 @@ class AzurePowerShellCredential {
|
|
|
2798
2802
|
constructor(options) {
|
|
2799
2803
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
2800
2804
|
this.additionallyAllowedTenantIds = resolveAddionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
2805
|
+
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2801
2806
|
}
|
|
2802
2807
|
/**
|
|
2803
2808
|
* Gets the access token from Azure PowerShell
|
|
2804
2809
|
* @param resource - The resource to use when getting the token
|
|
2805
2810
|
*/
|
|
2806
|
-
async getAzurePowerShellAccessToken(resource, tenantId) {
|
|
2811
|
+
async getAzurePowerShellAccessToken(resource, tenantId, timeout) {
|
|
2807
2812
|
// Clone the stack to avoid mutating it while iterating
|
|
2808
2813
|
for (const powerShellCommand of [...commandStack]) {
|
|
2809
2814
|
try {
|
|
2810
|
-
await runCommands([[powerShellCommand, "/?"]]);
|
|
2815
|
+
await runCommands([[powerShellCommand, "/?"]], timeout);
|
|
2811
2816
|
}
|
|
2812
2817
|
catch (e) {
|
|
2813
2818
|
// Remove this credential from the original stack so that we don't try it again.
|
|
@@ -2855,7 +2860,7 @@ class AzurePowerShellCredential {
|
|
|
2855
2860
|
logger$a.getToken.info(`Using the scope ${scope}`);
|
|
2856
2861
|
const resource = getScopeResource(scope);
|
|
2857
2862
|
try {
|
|
2858
|
-
const response = await this.getAzurePowerShellAccessToken(resource, tenantId);
|
|
2863
|
+
const response = await this.getAzurePowerShellAccessToken(resource, tenantId, this.timeout);
|
|
2859
2864
|
logger$a.getToken.info(formatSuccess(scopes));
|
|
2860
2865
|
return {
|
|
2861
2866
|
token: response.Token,
|
|
@@ -3413,7 +3418,7 @@ const developerCliCredentialInternals = {
|
|
|
3413
3418
|
* @param scopes - The scopes to use when getting the token
|
|
3414
3419
|
* @internal
|
|
3415
3420
|
*/
|
|
3416
|
-
async getAzdAccessToken(scopes, tenantId) {
|
|
3421
|
+
async getAzdAccessToken(scopes, tenantId, timeout) {
|
|
3417
3422
|
let tenantSection = [];
|
|
3418
3423
|
if (tenantId) {
|
|
3419
3424
|
tenantSection = ["--tenant-id", tenantId];
|
|
@@ -3427,7 +3432,11 @@ const developerCliCredentialInternals = {
|
|
|
3427
3432
|
"json",
|
|
3428
3433
|
...scopes.reduce((previous, current) => previous.concat("--scope", current), []),
|
|
3429
3434
|
...tenantSection,
|
|
3430
|
-
], {
|
|
3435
|
+
], {
|
|
3436
|
+
cwd: developerCliCredentialInternals.getSafeWorkingDir(),
|
|
3437
|
+
shell: true,
|
|
3438
|
+
timeout,
|
|
3439
|
+
}, (error, stdout, stderr) => {
|
|
3431
3440
|
resolve({ stdout, stderr, error });
|
|
3432
3441
|
});
|
|
3433
3442
|
}
|
|
@@ -3456,6 +3465,7 @@ class AzureDeveloperCliCredential {
|
|
|
3456
3465
|
constructor(options) {
|
|
3457
3466
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3458
3467
|
this.additionallyAllowedTenantIds = resolveAddionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3468
|
+
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
3459
3469
|
}
|
|
3460
3470
|
/**
|
|
3461
3471
|
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
@@ -3478,7 +3488,7 @@ class AzureDeveloperCliCredential {
|
|
|
3478
3488
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
|
|
3479
3489
|
var _a, _b, _c;
|
|
3480
3490
|
try {
|
|
3481
|
-
const obj = await developerCliCredentialInternals.getAzdAccessToken(scopeList, tenantId);
|
|
3491
|
+
const obj = await developerCliCredentialInternals.getAzdAccessToken(scopeList, tenantId, this.timeout);
|
|
3482
3492
|
const isNotLoggedInError = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("not logged in, run `azd login` to login");
|
|
3483
3493
|
const isNotInstallError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("azd:(.*)not found")) ||
|
|
3484
3494
|
((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.startsWith("'azd' is not recognized"));
|
|
@@ -3553,13 +3563,28 @@ class DefaultManagedIdentityCredential extends ManagedIdentityCredential {
|
|
|
3553
3563
|
}
|
|
3554
3564
|
}
|
|
3555
3565
|
}
|
|
3566
|
+
class DefaultAzureDeveloperCliCredential extends AzureDeveloperCliCredential {
|
|
3567
|
+
constructor(options) {
|
|
3568
|
+
super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
class DefaultAzureCliCredential extends AzureCliCredential {
|
|
3572
|
+
constructor(options) {
|
|
3573
|
+
super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
class DefaultAzurePowershellCredential extends AzurePowerShellCredential {
|
|
3577
|
+
constructor(options) {
|
|
3578
|
+
super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3556
3581
|
const defaultCredentials = [
|
|
3557
3582
|
EnvironmentCredential,
|
|
3558
3583
|
WorkloadIdentityCredential,
|
|
3559
3584
|
DefaultManagedIdentityCredential,
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3585
|
+
DefaultAzureDeveloperCliCredential,
|
|
3586
|
+
DefaultAzureCliCredential,
|
|
3587
|
+
DefaultAzurePowershellCredential,
|
|
3563
3588
|
];
|
|
3564
3589
|
/**
|
|
3565
3590
|
* Provides a default {@link ChainedTokenCredential} configuration that should
|