@azure/identity 2.0.2-alpha.20211206.2 → 2.0.2-alpha.20211221.3
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/README.md +1 -1
- package/dist/index.js +106 -112
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js +14 -14
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +4 -4
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +6 -6
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js +1 -1
- package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js +4 -4
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +2 -5
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +5 -5
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +5 -5
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +5 -5
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +8 -11
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +9 -9
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +4 -4
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +5 -5
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +4 -4
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +6 -6
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/errors.js +5 -5
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/index.js +5 -5
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +9 -9
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +3 -3
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +2 -2
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +11 -11
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +2 -2
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +5 -5
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
- package/dist-esm/src/msal/utils.js +3 -3
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/consumer.js +1 -1
- package/dist-esm/src/plugins/consumer.js.map +1 -1
- package/dist-esm/src/regionalAuthority.js.map +1 -1
- package/dist-esm/src/util/logging.js +1 -1
- package/dist-esm/src/util/logging.js.map +1 -1
- package/dist-esm/src/util/processUtils.js +1 -1
- package/dist-esm/src/util/processUtils.js.map +1 -1
- package/dist-esm/src/util/tracing.js +3 -3
- package/dist-esm/src/util/tracing.js.map +1 -1
- package/package.json +22 -12
- package/types/identity.d.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ class AuthenticationError extends Error {
|
|
|
62
62
|
constructor(statusCode, errorBody) {
|
|
63
63
|
let errorResponse = {
|
|
64
64
|
error: "unknown",
|
|
65
|
-
errorDescription: "An unknown error occurred and no additional details are available."
|
|
65
|
+
errorDescription: "An unknown error occurred and no additional details are available.",
|
|
66
66
|
};
|
|
67
67
|
if (isErrorResponse(errorBody)) {
|
|
68
68
|
errorResponse = convertOAuthErrorResponseToErrorResponse(errorBody);
|
|
@@ -78,13 +78,13 @@ class AuthenticationError extends Error {
|
|
|
78
78
|
if (statusCode === 400) {
|
|
79
79
|
errorResponse = {
|
|
80
80
|
error: "authority_not_found",
|
|
81
|
-
errorDescription: "The specified authority URL was not found."
|
|
81
|
+
errorDescription: "The specified authority URL was not found.",
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
errorResponse = {
|
|
86
86
|
error: "unknown_error",
|
|
87
|
-
errorDescription: `An unknown error has occurred. Response body:\n\n${errorBody}
|
|
87
|
+
errorDescription: `An unknown error has occurred. Response body:\n\n${errorBody}`,
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -92,7 +92,7 @@ class AuthenticationError extends Error {
|
|
|
92
92
|
else {
|
|
93
93
|
errorResponse = {
|
|
94
94
|
error: "unknown_error",
|
|
95
|
-
errorDescription: "An unknown error occurred and no additional details are available."
|
|
95
|
+
errorDescription: "An unknown error occurred and no additional details are available.",
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
super(`${errorResponse.error}(status code ${statusCode}).\nMore details:\n${errorResponse.errorDescription}`);
|
|
@@ -126,7 +126,7 @@ function convertOAuthErrorResponseToErrorResponse(errorBody) {
|
|
|
126
126
|
correlationId: errorBody.correlation_id,
|
|
127
127
|
errorCodes: errorBody.error_codes,
|
|
128
128
|
timestamp: errorBody.timestamp,
|
|
129
|
-
traceId: errorBody.trace_id
|
|
129
|
+
traceId: errorBody.trace_id,
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
@@ -201,7 +201,7 @@ const DefaultAuthorityHost = exports.AzureAuthorityHosts.AzurePublicCloud;
|
|
|
201
201
|
*/
|
|
202
202
|
const createSpan = coreTracing.createSpanFunction({
|
|
203
203
|
packagePrefix: "",
|
|
204
|
-
namespace: "Microsoft.AAD"
|
|
204
|
+
namespace: "Microsoft.AAD",
|
|
205
205
|
});
|
|
206
206
|
/**
|
|
207
207
|
* From: https://github.com/Azure/azure-sdk-for-js/blob/46139daa3317a0d12e8b55b02b9d9cdf1b2e762a/sdk/appconfiguration/app-configuration/src/internal/tracingHelpers.ts
|
|
@@ -221,14 +221,14 @@ async function trace(operationName, options, fn, createSpanFn = createSpan) {
|
|
|
221
221
|
const result = await fn(updatedOptions, span);
|
|
222
222
|
// otel 0.16+ needs this or else the code ends up being set as UNSET
|
|
223
223
|
span.setStatus({
|
|
224
|
-
code: coreTracing.SpanStatusCode.OK
|
|
224
|
+
code: coreTracing.SpanStatusCode.OK,
|
|
225
225
|
});
|
|
226
226
|
return result;
|
|
227
227
|
}
|
|
228
228
|
catch (err) {
|
|
229
229
|
span.setStatus({
|
|
230
230
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
231
|
-
message: err.message
|
|
231
|
+
message: err.message,
|
|
232
232
|
});
|
|
233
233
|
throw err;
|
|
234
234
|
}
|
|
@@ -289,7 +289,7 @@ function credentialLoggerInstance(title, parent, log = logger) {
|
|
|
289
289
|
return {
|
|
290
290
|
title,
|
|
291
291
|
fullTitle,
|
|
292
|
-
info
|
|
292
|
+
info,
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
@@ -341,7 +341,7 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
341
341
|
throw new Error("The authorityHost address must use the 'https' protocol.");
|
|
342
342
|
}
|
|
343
343
|
super(Object.assign(Object.assign({ requestContentType: "application/json; charset=utf-8" }, options), { userAgentOptions: {
|
|
344
|
-
userAgentPrefix
|
|
344
|
+
userAgentPrefix,
|
|
345
345
|
}, baseUri }));
|
|
346
346
|
this.authorityHost = baseUri;
|
|
347
347
|
this.abortControllers = new Map();
|
|
@@ -362,9 +362,9 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
362
362
|
const token = {
|
|
363
363
|
accessToken: {
|
|
364
364
|
token: parsedBody.access_token,
|
|
365
|
-
expiresOnTimestamp: expiresOnParser(parsedBody)
|
|
365
|
+
expiresOnTimestamp: expiresOnParser(parsedBody),
|
|
366
366
|
},
|
|
367
|
-
refreshToken: parsedBody.refresh_token
|
|
367
|
+
refreshToken: parsedBody.refresh_token,
|
|
368
368
|
};
|
|
369
369
|
logger.info(`IdentityClient: [${request.url}] token acquired, expires on ${token.accessToken.expiresOnTimestamp}`);
|
|
370
370
|
return token;
|
|
@@ -385,7 +385,7 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
385
385
|
grant_type: "refresh_token",
|
|
386
386
|
client_id: clientId,
|
|
387
387
|
refresh_token: refreshToken,
|
|
388
|
-
scope: scopes
|
|
388
|
+
scope: scopes,
|
|
389
389
|
};
|
|
390
390
|
if (clientSecret !== undefined) {
|
|
391
391
|
refreshParams.client_secret = clientSecret;
|
|
@@ -400,9 +400,9 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
400
400
|
abortSignal: options && options.abortSignal,
|
|
401
401
|
headers: coreRestPipeline.createHttpHeaders({
|
|
402
402
|
Accept: "application/json",
|
|
403
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
403
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
404
404
|
}),
|
|
405
|
-
tracingOptions: updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.tracingOptions
|
|
405
|
+
tracingOptions: updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.tracingOptions,
|
|
406
406
|
});
|
|
407
407
|
const response = await this.sendTokenRequest(request, expiresOnParser);
|
|
408
408
|
logger.info(`IdentityClient: refreshed token for client ID: ${clientId}`);
|
|
@@ -417,7 +417,7 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
417
417
|
logger.info(`IdentityClient: interaction required for client ID: ${clientId}`);
|
|
418
418
|
span.setStatus({
|
|
419
419
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
420
|
-
message: err.message
|
|
420
|
+
message: err.message,
|
|
421
421
|
});
|
|
422
422
|
return null;
|
|
423
423
|
}
|
|
@@ -425,7 +425,7 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
425
425
|
logger.warning(`IdentityClient: failed refreshing token for client ID: ${clientId}: ${err}`);
|
|
426
426
|
span.setStatus({
|
|
427
427
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
428
|
-
message: err.message
|
|
428
|
+
message: err.message,
|
|
429
429
|
});
|
|
430
430
|
throw err;
|
|
431
431
|
}
|
|
@@ -455,7 +455,7 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
455
455
|
const controllers = [
|
|
456
456
|
...(this.abortControllers.get(key) || []),
|
|
457
457
|
// MSAL passes no correlation ID to the get requests...
|
|
458
|
-
...(this.abortControllers.get(noCorrelationId) || [])
|
|
458
|
+
...(this.abortControllers.get(noCorrelationId) || []),
|
|
459
459
|
];
|
|
460
460
|
if (!controllers.length) {
|
|
461
461
|
return;
|
|
@@ -477,13 +477,13 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
477
477
|
method: "GET",
|
|
478
478
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
479
479
|
headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
|
|
480
|
-
abortSignal: this.generateAbortSignal(noCorrelationId)
|
|
480
|
+
abortSignal: this.generateAbortSignal(noCorrelationId),
|
|
481
481
|
});
|
|
482
482
|
const response = await this.sendRequest(request);
|
|
483
483
|
return {
|
|
484
484
|
body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
|
|
485
485
|
headers: response.headers.toJSON(),
|
|
486
|
-
status: response.status
|
|
486
|
+
status: response.status,
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
489
|
async sendPostRequestAsync(url, options) {
|
|
@@ -493,13 +493,13 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
493
493
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
494
494
|
headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
|
|
495
495
|
// MSAL doesn't send the correlation ID on the get requests.
|
|
496
|
-
abortSignal: this.generateAbortSignal(this.getCorrelationId(options))
|
|
496
|
+
abortSignal: this.generateAbortSignal(this.getCorrelationId(options)),
|
|
497
497
|
});
|
|
498
498
|
const response = await this.sendRequest(request);
|
|
499
499
|
return {
|
|
500
500
|
body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
|
|
501
501
|
headers: response.headers.toJSON(),
|
|
502
|
-
status: response.status
|
|
502
|
+
status: response.status,
|
|
503
503
|
};
|
|
504
504
|
}
|
|
505
505
|
}
|
|
@@ -544,7 +544,7 @@ function ensureValidMsalToken(scopes, logger, msalToken, getTokenOptions) {
|
|
|
544
544
|
return new AuthenticationRequiredError({
|
|
545
545
|
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
546
546
|
getTokenOptions,
|
|
547
|
-
message
|
|
547
|
+
message,
|
|
548
548
|
});
|
|
549
549
|
};
|
|
550
550
|
if (!msalToken) {
|
|
@@ -641,7 +641,7 @@ class MsalBaseUtilities {
|
|
|
641
641
|
this.logger.getToken.info(formatSuccess(scopes));
|
|
642
642
|
return {
|
|
643
643
|
token: result.accessToken,
|
|
644
|
-
expiresOnTimestamp: result.expiresOn.getTime()
|
|
644
|
+
expiresOnTimestamp: result.expiresOn.getTime(),
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
647
|
/**
|
|
@@ -688,7 +688,7 @@ function msalToPublic(clientId, account) {
|
|
|
688
688
|
tenantId: account.tenantId || DefaultTenantId,
|
|
689
689
|
username: account.username,
|
|
690
690
|
clientId,
|
|
691
|
-
version: LatestAuthenticationRecordVersion
|
|
691
|
+
version: LatestAuthenticationRecordVersion,
|
|
692
692
|
};
|
|
693
693
|
return record;
|
|
694
694
|
}
|
|
@@ -893,7 +893,7 @@ let persistenceProvider = undefined;
|
|
|
893
893
|
const msalNodeFlowCacheControl = {
|
|
894
894
|
setPersistence(pluginProvider) {
|
|
895
895
|
persistenceProvider = pluginProvider;
|
|
896
|
-
}
|
|
896
|
+
},
|
|
897
897
|
};
|
|
898
898
|
/**
|
|
899
899
|
* MSAL partial base client for Node.js.
|
|
@@ -921,7 +921,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
921
921
|
"Persistent token caching was requested, but no persistence provider was configured.",
|
|
922
922
|
"You must install the identity-cache-persistence plugin package (`npm install --save @azure/identity-cache-persistence`)",
|
|
923
923
|
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
924
|
-
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`."
|
|
924
|
+
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`.",
|
|
925
925
|
].join(" "));
|
|
926
926
|
}
|
|
927
927
|
this.azureRegion = (_c = options.regionalAuthority) !== null && _c !== void 0 ? _c : process.env.AZURE_REGIONAL_AUTHORITY_NAME;
|
|
@@ -947,15 +947,15 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
947
947
|
clientId,
|
|
948
948
|
authority,
|
|
949
949
|
knownAuthorities: getKnownAuthorities(tenantId, authority),
|
|
950
|
-
clientCapabilities
|
|
950
|
+
clientCapabilities,
|
|
951
951
|
},
|
|
952
952
|
// Cache is defined in this.prepare();
|
|
953
953
|
system: {
|
|
954
954
|
networkClient: this.identityClient,
|
|
955
955
|
loggerOptions: {
|
|
956
|
-
loggerCallback: defaultLoggerCallback(options.logger)
|
|
957
|
-
}
|
|
958
|
-
}
|
|
956
|
+
loggerCallback: defaultLoggerCallback(options.logger),
|
|
957
|
+
},
|
|
958
|
+
},
|
|
959
959
|
};
|
|
960
960
|
}
|
|
961
961
|
/**
|
|
@@ -974,7 +974,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
974
974
|
}
|
|
975
975
|
if (this.createCachePlugin !== undefined) {
|
|
976
976
|
this.msalConfig.cache = {
|
|
977
|
-
cachePlugin: await this.createCachePlugin()
|
|
977
|
+
cachePlugin: await this.createCachePlugin(),
|
|
978
978
|
};
|
|
979
979
|
}
|
|
980
980
|
this.publicApp = new msalNode.PublicClientApplication(this.msalConfig);
|
|
@@ -1044,7 +1044,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1044
1044
|
throw new AuthenticationRequiredError({
|
|
1045
1045
|
scopes,
|
|
1046
1046
|
getTokenOptions: options,
|
|
1047
|
-
message: "Silent authentication failed. We couldn't retrieve an active account from the cache."
|
|
1047
|
+
message: "Silent authentication failed. We couldn't retrieve an active account from the cache.",
|
|
1048
1048
|
});
|
|
1049
1049
|
}
|
|
1050
1050
|
const silentRequest = {
|
|
@@ -1053,7 +1053,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1053
1053
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
1054
1054
|
scopes,
|
|
1055
1055
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1056
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
1056
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1057
1057
|
};
|
|
1058
1058
|
try {
|
|
1059
1059
|
this.logger.info("Attempting to acquire token silently");
|
|
@@ -1084,7 +1084,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1084
1084
|
throw new AuthenticationRequiredError({
|
|
1085
1085
|
scopes,
|
|
1086
1086
|
getTokenOptions: options,
|
|
1087
|
-
message: "Automatic authentication has been disabled. You may call the authentication() method."
|
|
1087
|
+
message: "Automatic authentication has been disabled. You may call the authentication() method.",
|
|
1088
1088
|
});
|
|
1089
1089
|
}
|
|
1090
1090
|
this.logger.info(`Silent authentication failed, falling back to interactive method.`);
|
|
@@ -1101,11 +1101,11 @@ let findCredentials = undefined;
|
|
|
1101
1101
|
const vsCodeCredentialControl = {
|
|
1102
1102
|
setVsCodeCredentialFinder(finder) {
|
|
1103
1103
|
findCredentials = finder;
|
|
1104
|
-
}
|
|
1104
|
+
},
|
|
1105
1105
|
};
|
|
1106
1106
|
// Map of unsupported Tenant IDs and the errors we will be throwing.
|
|
1107
1107
|
const unsupportedTenantIds = {
|
|
1108
|
-
adfs: "The VisualStudioCodeCredential does not support authentication with ADFS tenants."
|
|
1108
|
+
adfs: "The VisualStudioCodeCredential does not support authentication with ADFS tenants.",
|
|
1109
1109
|
};
|
|
1110
1110
|
function checkUnsupportedTenant(tenantId) {
|
|
1111
1111
|
// If the Tenant ID isn't supported, we throw.
|
|
@@ -1118,7 +1118,7 @@ const mapVSCodeAuthorityHosts = {
|
|
|
1118
1118
|
AzureCloud: exports.AzureAuthorityHosts.AzurePublicCloud,
|
|
1119
1119
|
AzureChina: exports.AzureAuthorityHosts.AzureChina,
|
|
1120
1120
|
AzureGermanCloud: exports.AzureAuthorityHosts.AzureGermany,
|
|
1121
|
-
AzureUSGovernment: exports.AzureAuthorityHosts.AzureGovernment
|
|
1121
|
+
AzureUSGovernment: exports.AzureAuthorityHosts.AzureGovernment,
|
|
1122
1122
|
};
|
|
1123
1123
|
/**
|
|
1124
1124
|
* Attempts to load a specific property from the VSCode configurations of the current OS.
|
|
@@ -1222,7 +1222,7 @@ class VisualStudioCodeCredential {
|
|
|
1222
1222
|
"No implementation of `VisualStudioCodeCredential` is available.",
|
|
1223
1223
|
"You must install the identity-vscode plugin package (`npm install --save-dev @azure/identity-vscode`)",
|
|
1224
1224
|
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
1225
|
-
"`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`."
|
|
1225
|
+
"`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`.",
|
|
1226
1226
|
].join(" "));
|
|
1227
1227
|
}
|
|
1228
1228
|
let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
@@ -1253,13 +1253,13 @@ class VisualStudioCodeCredential {
|
|
|
1253
1253
|
return tokenResponse.accessToken;
|
|
1254
1254
|
}
|
|
1255
1255
|
else {
|
|
1256
|
-
const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Have you connected using the 'Azure Account' extension recently? To troubleshoot, visit https://aka.ms/azsdk/js/identity/
|
|
1256
|
+
const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Have you connected using the 'Azure Account' extension recently? To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.");
|
|
1257
1257
|
logger$1.getToken.info(formatError(scopes, error));
|
|
1258
1258
|
throw error;
|
|
1259
1259
|
}
|
|
1260
1260
|
}
|
|
1261
1261
|
else {
|
|
1262
|
-
const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Did you connect using the 'Azure Account' extension? To troubleshoot, visit https://aka.ms/azsdk/js/identity/
|
|
1262
|
+
const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Did you connect using the 'Azure Account' extension? To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.");
|
|
1263
1263
|
logger$1.getToken.info(formatError(scopes, error));
|
|
1264
1264
|
throw error;
|
|
1265
1265
|
}
|
|
@@ -1274,7 +1274,7 @@ class VisualStudioCodeCredential {
|
|
|
1274
1274
|
*/
|
|
1275
1275
|
const pluginContext = {
|
|
1276
1276
|
cachePluginControl: msalNodeFlowCacheControl,
|
|
1277
|
-
vsCodeCredentialControl: vsCodeCredentialControl
|
|
1277
|
+
vsCodeCredentialControl: vsCodeCredentialControl,
|
|
1278
1278
|
};
|
|
1279
1279
|
/**
|
|
1280
1280
|
* Extend Azure Identity with additional functionality. Pass a plugin from
|
|
@@ -1375,7 +1375,7 @@ class ChainedTokenCredential {
|
|
|
1375
1375
|
const err = new AggregateAuthenticationError(errors, "ChainedTokenCredential authentication failed.");
|
|
1376
1376
|
span.setStatus({
|
|
1377
1377
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
1378
|
-
message: err.message
|
|
1378
|
+
message: err.message,
|
|
1379
1379
|
});
|
|
1380
1380
|
logger$2.getToken.info(formatError(scopes, err));
|
|
1381
1381
|
throw err;
|
|
@@ -1448,7 +1448,7 @@ const cliCredentialInternals = {
|
|
|
1448
1448
|
"json",
|
|
1449
1449
|
"--resource",
|
|
1450
1450
|
resource,
|
|
1451
|
-
...tenantSection
|
|
1451
|
+
...tenantSection,
|
|
1452
1452
|
], { cwd: cliCredentialInternals.getSafeWorkingDir(), shell: true }, (error, stdout, stderr) => {
|
|
1453
1453
|
resolve({ stdout: stdout, stderr: stderr, error });
|
|
1454
1454
|
});
|
|
@@ -1457,7 +1457,7 @@ const cliCredentialInternals = {
|
|
|
1457
1457
|
reject(err);
|
|
1458
1458
|
}
|
|
1459
1459
|
});
|
|
1460
|
-
}
|
|
1460
|
+
},
|
|
1461
1461
|
};
|
|
1462
1462
|
const logger$3 = credentialLogger("AzureCliCredential");
|
|
1463
1463
|
/**
|
|
@@ -1522,7 +1522,7 @@ class AzureCliCredential {
|
|
|
1522
1522
|
logger$3.getToken.info(formatSuccess(scopes));
|
|
1523
1523
|
const returnValue = {
|
|
1524
1524
|
token: response.accessToken,
|
|
1525
|
-
expiresOnTimestamp: new Date(response.expiresOn).getTime()
|
|
1525
|
+
expiresOnTimestamp: new Date(response.expiresOn).getTime(),
|
|
1526
1526
|
};
|
|
1527
1527
|
return returnValue;
|
|
1528
1528
|
}
|
|
@@ -1531,7 +1531,7 @@ class AzureCliCredential {
|
|
|
1531
1531
|
const error = new Error(err.message || "Unknown error while trying to retrieve the access token");
|
|
1532
1532
|
span.setStatus({
|
|
1533
1533
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
1534
|
-
message: error.message
|
|
1534
|
+
message: error.message,
|
|
1535
1535
|
});
|
|
1536
1536
|
logger$3.getToken.info(formatError(scopes, error));
|
|
1537
1537
|
throw error;
|
|
@@ -1566,7 +1566,7 @@ const processUtils = {
|
|
|
1566
1566
|
}
|
|
1567
1567
|
});
|
|
1568
1568
|
});
|
|
1569
|
-
}
|
|
1569
|
+
},
|
|
1570
1570
|
};
|
|
1571
1571
|
|
|
1572
1572
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1605,7 +1605,7 @@ async function runCommands(commands) {
|
|
|
1605
1605
|
*/
|
|
1606
1606
|
const powerShellErrors = {
|
|
1607
1607
|
login: "Run Connect-AzAccount to login",
|
|
1608
|
-
installed: "The specified module 'Az.Accounts' with version '2.2.0' was not loaded because no valid module file was found in any module directory"
|
|
1608
|
+
installed: "The specified module 'Az.Accounts' with version '2.2.0' was not loaded because no valid module file was found in any module directory",
|
|
1609
1609
|
};
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Messages to use when throwing in this credential.
|
|
@@ -1614,7 +1614,7 @@ const powerShellErrors = {
|
|
|
1614
1614
|
const powerShellPublicErrorMessages = {
|
|
1615
1615
|
login: "Please run 'Connect-AzAccount' from PowerShell to authenticate before using this credential.",
|
|
1616
1616
|
installed: `The 'Az.Account' module >= 2.2.0 is not installed. Install the Azure Az PowerShell module with: "Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force".`,
|
|
1617
|
-
troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot
|
|
1617
|
+
troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot.`,
|
|
1618
1618
|
};
|
|
1619
1619
|
// PowerShell Azure User not logged in error check.
|
|
1620
1620
|
const isLoginError = (err) => err.message.match(`(.*)${powerShellErrors.login}(.*)`);
|
|
@@ -1672,13 +1672,13 @@ class AzurePowerShellCredential {
|
|
|
1672
1672
|
[
|
|
1673
1673
|
powerShellCommand,
|
|
1674
1674
|
"-Command",
|
|
1675
|
-
"Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru"
|
|
1675
|
+
"Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru",
|
|
1676
1676
|
],
|
|
1677
1677
|
[
|
|
1678
1678
|
powerShellCommand,
|
|
1679
1679
|
"-Command",
|
|
1680
|
-
`Get-AzAccessToken ${tenantSection} -ResourceUrl "${resource}" | ConvertTo-Json
|
|
1681
|
-
]
|
|
1680
|
+
`Get-AzAccessToken ${tenantSection} -ResourceUrl "${resource}" | ConvertTo-Json`,
|
|
1681
|
+
],
|
|
1682
1682
|
]);
|
|
1683
1683
|
const result = results[1];
|
|
1684
1684
|
try {
|
|
@@ -1712,7 +1712,7 @@ class AzurePowerShellCredential {
|
|
|
1712
1712
|
logger$4.getToken.info(formatSuccess(scopes));
|
|
1713
1713
|
return {
|
|
1714
1714
|
token: response.Token,
|
|
1715
|
-
expiresOnTimestamp: new Date(response.ExpiresOn).getTime()
|
|
1715
|
+
expiresOnTimestamp: new Date(response.ExpiresOn).getTime(),
|
|
1716
1716
|
};
|
|
1717
1717
|
}
|
|
1718
1718
|
catch (err) {
|
|
@@ -1752,7 +1752,7 @@ class MsalClientSecret extends MsalNode {
|
|
|
1752
1752
|
correlationId: options.correlationId,
|
|
1753
1753
|
azureRegion: this.azureRegion,
|
|
1754
1754
|
authority: options.authority,
|
|
1755
|
-
claims: options.claims
|
|
1755
|
+
claims: options.claims,
|
|
1756
1756
|
});
|
|
1757
1757
|
// The Client Credential flow does not return an account,
|
|
1758
1758
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -1864,7 +1864,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1864
1864
|
this.msalConfig.auth.clientCertificate = {
|
|
1865
1865
|
thumbprint: parts.thumbprint,
|
|
1866
1866
|
privateKey: parts.certificateContents,
|
|
1867
|
-
x5c: parts.x5c
|
|
1867
|
+
x5c: parts.x5c,
|
|
1868
1868
|
};
|
|
1869
1869
|
}
|
|
1870
1870
|
catch (error) {
|
|
@@ -1880,7 +1880,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1880
1880
|
correlationId: options.correlationId,
|
|
1881
1881
|
azureRegion: this.azureRegion,
|
|
1882
1882
|
authority: options.authority,
|
|
1883
|
-
claims: options.claims
|
|
1883
|
+
claims: options.claims,
|
|
1884
1884
|
});
|
|
1885
1885
|
// Even though we're providing the same default in memory persistence cache that we use for DeviceCodeCredential,
|
|
1886
1886
|
// The Client Credential flow does not return the account information from the authentication service,
|
|
@@ -1911,7 +1911,7 @@ class ClientCertificateCredential {
|
|
|
1911
1911
|
}
|
|
1912
1912
|
const configuration = Object.assign({}, (typeof certificatePathOrConfiguration === "string"
|
|
1913
1913
|
? {
|
|
1914
|
-
certificatePath: certificatePathOrConfiguration
|
|
1914
|
+
certificatePath: certificatePathOrConfiguration,
|
|
1915
1915
|
}
|
|
1916
1916
|
: certificatePathOrConfiguration));
|
|
1917
1917
|
if (!configuration || !(configuration.certificate || configuration.certificatePath)) {
|
|
@@ -1960,7 +1960,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
1960
1960
|
password: this.password,
|
|
1961
1961
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
1962
1962
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1963
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
1963
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1964
1964
|
};
|
|
1965
1965
|
const result = await this.publicApp.acquireTokenByUsernamePassword(requestOptions);
|
|
1966
1966
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
@@ -2035,7 +2035,7 @@ const AllSupportedEnvironmentVariables = [
|
|
|
2035
2035
|
"AZURE_CLIENT_SECRET",
|
|
2036
2036
|
"AZURE_CLIENT_CERTIFICATE_PATH",
|
|
2037
2037
|
"AZURE_USERNAME",
|
|
2038
|
-
"AZURE_PASSWORD"
|
|
2038
|
+
"AZURE_PASSWORD",
|
|
2039
2039
|
];
|
|
2040
2040
|
const credentialName$1 = "EnvironmentCredential";
|
|
2041
2041
|
const logger$8 = credentialLogger(credentialName$1);
|
|
@@ -2108,10 +2108,7 @@ class EnvironmentCredential {
|
|
|
2108
2108
|
catch (err) {
|
|
2109
2109
|
const authenticationError = new AuthenticationError(400, {
|
|
2110
2110
|
error: `${credentialName$1} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,
|
|
2111
|
-
error_description: err.message
|
|
2112
|
-
.toString()
|
|
2113
|
-
.split("More details:")
|
|
2114
|
-
.join("")
|
|
2111
|
+
error_description: err.message.toString().split("More details:").join(""),
|
|
2115
2112
|
});
|
|
2116
2113
|
logger$8.getToken.info(formatError(scopes, authenticationError));
|
|
2117
2114
|
throw authenticationError;
|
|
@@ -2178,7 +2175,7 @@ function prepareRequestOptions(scopes, clientId) {
|
|
|
2178
2175
|
}
|
|
2179
2176
|
const queryParameters = {
|
|
2180
2177
|
resource,
|
|
2181
|
-
"api-version": "2017-09-01"
|
|
2178
|
+
"api-version": "2017-09-01",
|
|
2182
2179
|
};
|
|
2183
2180
|
if (clientId) {
|
|
2184
2181
|
queryParameters.clientid = clientId;
|
|
@@ -2196,8 +2193,8 @@ function prepareRequestOptions(scopes, clientId) {
|
|
|
2196
2193
|
method: "GET",
|
|
2197
2194
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2198
2195
|
Accept: "application/json",
|
|
2199
|
-
secret: process.env.MSI_SECRET
|
|
2200
|
-
})
|
|
2196
|
+
secret: process.env.MSI_SECRET,
|
|
2197
|
+
}),
|
|
2201
2198
|
};
|
|
2202
2199
|
}
|
|
2203
2200
|
/**
|
|
@@ -2225,7 +2222,7 @@ const appServiceMsi2017 = {
|
|
|
2225
2222
|
allowInsecureConnection: true }));
|
|
2226
2223
|
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser);
|
|
2227
2224
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2228
|
-
}
|
|
2225
|
+
},
|
|
2229
2226
|
};
|
|
2230
2227
|
|
|
2231
2228
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2240,7 +2237,7 @@ function prepareRequestOptions$1(scopes, clientId) {
|
|
|
2240
2237
|
throw new Error(`${msiName$1}: Multiple scopes are not supported.`);
|
|
2241
2238
|
}
|
|
2242
2239
|
const body = {
|
|
2243
|
-
resource
|
|
2240
|
+
resource,
|
|
2244
2241
|
};
|
|
2245
2242
|
if (clientId) {
|
|
2246
2243
|
body.client_id = clientId;
|
|
@@ -2257,8 +2254,8 @@ function prepareRequestOptions$1(scopes, clientId) {
|
|
|
2257
2254
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2258
2255
|
Accept: "application/json",
|
|
2259
2256
|
Metadata: "true",
|
|
2260
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
2261
|
-
})
|
|
2257
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
2258
|
+
}),
|
|
2262
2259
|
};
|
|
2263
2260
|
}
|
|
2264
2261
|
/**
|
|
@@ -2285,7 +2282,7 @@ const cloudShellMsi = {
|
|
|
2285
2282
|
allowInsecureConnection: true }));
|
|
2286
2283
|
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2287
2284
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2288
|
-
}
|
|
2285
|
+
},
|
|
2289
2286
|
};
|
|
2290
2287
|
|
|
2291
2288
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2324,7 +2321,7 @@ function prepareRequestOptions$2(scopes, clientId, options) {
|
|
|
2324
2321
|
if (!skipQuery) {
|
|
2325
2322
|
const queryParameters = {
|
|
2326
2323
|
resource,
|
|
2327
|
-
"api-version": imdsApiVersion
|
|
2324
|
+
"api-version": imdsApiVersion,
|
|
2328
2325
|
};
|
|
2329
2326
|
if (clientId) {
|
|
2330
2327
|
queryParameters.client_id = clientId;
|
|
@@ -2335,7 +2332,7 @@ function prepareRequestOptions$2(scopes, clientId, options) {
|
|
|
2335
2332
|
const url = new URL(imdsEndpointPath, (_a = process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) !== null && _a !== void 0 ? _a : imdsHost);
|
|
2336
2333
|
const rawHeaders = {
|
|
2337
2334
|
Accept: "application/json",
|
|
2338
|
-
Metadata: "true"
|
|
2335
|
+
Metadata: "true",
|
|
2339
2336
|
};
|
|
2340
2337
|
// Remove the Metadata header to invoke a request error from some IMDS endpoints.
|
|
2341
2338
|
if (skipMetadataHeader) {
|
|
@@ -2345,14 +2342,14 @@ function prepareRequestOptions$2(scopes, clientId, options) {
|
|
|
2345
2342
|
// In this case, the `?` should be added in the "query" variable `skipQuery` is not set.
|
|
2346
2343
|
url: `${url}${query}`,
|
|
2347
2344
|
method: "GET",
|
|
2348
|
-
headers: coreRestPipeline.createHttpHeaders(rawHeaders)
|
|
2345
|
+
headers: coreRestPipeline.createHttpHeaders(rawHeaders),
|
|
2349
2346
|
};
|
|
2350
2347
|
}
|
|
2351
2348
|
// 800ms -> 1600ms -> 3200ms
|
|
2352
2349
|
const imdsMsiRetryConfig = {
|
|
2353
2350
|
maxRetries: 3,
|
|
2354
2351
|
startDelayInMs: 800,
|
|
2355
|
-
intervalIncrement: 2
|
|
2352
|
+
intervalIncrement: 2,
|
|
2356
2353
|
};
|
|
2357
2354
|
/**
|
|
2358
2355
|
* Defines how to determine whether the Azure IMDS MSI is available, and also how to retrieve a token from the Azure IMDS MSI.
|
|
@@ -2372,7 +2369,7 @@ const imdsMsi = {
|
|
|
2372
2369
|
}
|
|
2373
2370
|
const requestOptions = prepareRequestOptions$2(resource, clientId, {
|
|
2374
2371
|
skipMetadataHeader: true,
|
|
2375
|
-
skipQuery: true
|
|
2372
|
+
skipQuery: true,
|
|
2376
2373
|
});
|
|
2377
2374
|
requestOptions.tracingOptions = options.tracingOptions;
|
|
2378
2375
|
try {
|
|
@@ -2399,7 +2396,7 @@ const imdsMsi = {
|
|
|
2399
2396
|
logger$b.info(`${msiName$2}: The Azure IMDS endpoint is unavailable`);
|
|
2400
2397
|
span.setStatus({
|
|
2401
2398
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2402
|
-
message: err.message
|
|
2399
|
+
message: err.message,
|
|
2403
2400
|
});
|
|
2404
2401
|
return false;
|
|
2405
2402
|
}
|
|
@@ -2414,7 +2411,7 @@ const imdsMsi = {
|
|
|
2414
2411
|
logger$b.info(`${msiName$2}: Error when creating the WebResource for the Azure IMDS endpoint: ${err.message}`);
|
|
2415
2412
|
span.setStatus({
|
|
2416
2413
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2417
|
-
message: err.message
|
|
2414
|
+
message: err.message,
|
|
2418
2415
|
});
|
|
2419
2416
|
throw err;
|
|
2420
2417
|
}
|
|
@@ -2442,7 +2439,7 @@ const imdsMsi = {
|
|
|
2442
2439
|
}
|
|
2443
2440
|
}
|
|
2444
2441
|
throw new AuthenticationError(404, `${msiName$2}: Failed to retrieve IMDS token after ${imdsMsiRetryConfig.maxRetries} retries.`);
|
|
2445
|
-
}
|
|
2442
|
+
},
|
|
2446
2443
|
};
|
|
2447
2444
|
|
|
2448
2445
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2458,7 +2455,7 @@ function prepareRequestOptions$3(scopes) {
|
|
|
2458
2455
|
}
|
|
2459
2456
|
const queryParameters = {
|
|
2460
2457
|
resource,
|
|
2461
|
-
"api-version": azureArcAPIVersion
|
|
2458
|
+
"api-version": azureArcAPIVersion,
|
|
2462
2459
|
};
|
|
2463
2460
|
const query = new URLSearchParams(queryParameters);
|
|
2464
2461
|
// This error should not bubble up, since we verify that this environment variable is defined in the isAvailable() method defined below.
|
|
@@ -2471,8 +2468,8 @@ function prepareRequestOptions$3(scopes) {
|
|
|
2471
2468
|
method: "GET",
|
|
2472
2469
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2473
2470
|
Accept: "application/json",
|
|
2474
|
-
Metadata: "true"
|
|
2475
|
-
})
|
|
2471
|
+
Metadata: "true",
|
|
2472
|
+
}),
|
|
2476
2473
|
});
|
|
2477
2474
|
}
|
|
2478
2475
|
/**
|
|
@@ -2542,7 +2539,7 @@ const arcMsi = {
|
|
|
2542
2539
|
allowInsecureConnection: true }));
|
|
2543
2540
|
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2544
2541
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2545
|
-
}
|
|
2542
|
+
},
|
|
2546
2543
|
};
|
|
2547
2544
|
|
|
2548
2545
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2559,7 +2556,7 @@ function prepareRequestOptions$4(scopes, clientAssertion, clientId) {
|
|
|
2559
2556
|
client_assertion: clientAssertion,
|
|
2560
2557
|
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
2561
2558
|
client_id: clientId,
|
|
2562
|
-
grant_type: "client_credentials"
|
|
2559
|
+
grant_type: "client_credentials",
|
|
2563
2560
|
};
|
|
2564
2561
|
const urlParams = new URLSearchParams(bodyParams);
|
|
2565
2562
|
const url = new URL(`${process.env.AZURE_TENANT_ID}/oauth2/v2.0/token`, (_a = process.env.AZURE_AUTHORITY_HOST) !== null && _a !== void 0 ? _a : DefaultAuthorityHost);
|
|
@@ -2568,8 +2565,8 @@ function prepareRequestOptions$4(scopes, clientAssertion, clientId) {
|
|
|
2568
2565
|
method: "POST",
|
|
2569
2566
|
body: urlParams.toString(),
|
|
2570
2567
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2571
|
-
Accept: "application/json"
|
|
2572
|
-
})
|
|
2568
|
+
Accept: "application/json",
|
|
2569
|
+
}),
|
|
2573
2570
|
};
|
|
2574
2571
|
}
|
|
2575
2572
|
/**
|
|
@@ -2622,7 +2619,7 @@ function tokenExchangeMsi() {
|
|
|
2622
2619
|
allowInsecureConnection: true }));
|
|
2623
2620
|
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2624
2621
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2625
|
-
}
|
|
2622
|
+
},
|
|
2626
2623
|
};
|
|
2627
2624
|
}
|
|
2628
2625
|
|
|
@@ -2656,7 +2653,7 @@ function prepareRequestOptions$5(scopes, clientId) {
|
|
|
2656
2653
|
}
|
|
2657
2654
|
const queryParameters = {
|
|
2658
2655
|
resource,
|
|
2659
|
-
"api-version": azureFabricVersion
|
|
2656
|
+
"api-version": azureFabricVersion,
|
|
2660
2657
|
};
|
|
2661
2658
|
if (clientId) {
|
|
2662
2659
|
queryParameters.client_id = clientId;
|
|
@@ -2674,8 +2671,8 @@ function prepareRequestOptions$5(scopes, clientId) {
|
|
|
2674
2671
|
method: "GET",
|
|
2675
2672
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2676
2673
|
Accept: "application/json",
|
|
2677
|
-
secret: process.env.IDENTITY_HEADER
|
|
2678
|
-
})
|
|
2674
|
+
secret: process.env.IDENTITY_HEADER,
|
|
2675
|
+
}),
|
|
2679
2676
|
};
|
|
2680
2677
|
}
|
|
2681
2678
|
/**
|
|
@@ -2702,20 +2699,17 @@ const fabricMsi = {
|
|
|
2702
2699
|
"Using the endpoint and the secret coming from the environment variables:",
|
|
2703
2700
|
`IDENTITY_ENDPOINT=${process.env.IDENTITY_ENDPOINT},`,
|
|
2704
2701
|
"IDENTITY_HEADER=[REDACTED] and",
|
|
2705
|
-
"IDENTITY_SERVER_THUMBPRINT=[REDACTED]."
|
|
2702
|
+
"IDENTITY_SERVER_THUMBPRINT=[REDACTED].",
|
|
2706
2703
|
].join(" "));
|
|
2707
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$5(scopes, clientId)
|
|
2708
|
-
// The service fabric MSI endpoint will be HTTPS (however, the certificate will be self-signed).
|
|
2709
|
-
// allowInsecureConnection: true
|
|
2710
|
-
));
|
|
2704
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$5(scopes, clientId)));
|
|
2711
2705
|
request.agent = new https.Agent({
|
|
2712
2706
|
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
2713
2707
|
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
2714
|
-
rejectUnauthorized: false
|
|
2708
|
+
rejectUnauthorized: false,
|
|
2715
2709
|
});
|
|
2716
2710
|
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser$2);
|
|
2717
2711
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2718
|
-
}
|
|
2712
|
+
},
|
|
2719
2713
|
};
|
|
2720
2714
|
|
|
2721
2715
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -2766,13 +2760,13 @@ class ManagedIdentityCredential {
|
|
|
2766
2760
|
return availableMSI.getToken({
|
|
2767
2761
|
identityClient: this.identityClient,
|
|
2768
2762
|
scopes,
|
|
2769
|
-
clientId
|
|
2763
|
+
clientId,
|
|
2770
2764
|
}, updatedOptions);
|
|
2771
2765
|
}
|
|
2772
2766
|
catch (err) {
|
|
2773
2767
|
span.setStatus({
|
|
2774
2768
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2775
|
-
message: err.message
|
|
2769
|
+
message: err.message,
|
|
2776
2770
|
});
|
|
2777
2771
|
throw err;
|
|
2778
2772
|
}
|
|
@@ -2837,7 +2831,7 @@ class ManagedIdentityCredential {
|
|
|
2837
2831
|
// but no identity is available.
|
|
2838
2832
|
span.setStatus({
|
|
2839
2833
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2840
|
-
message: err.message
|
|
2834
|
+
message: err.message,
|
|
2841
2835
|
});
|
|
2842
2836
|
// If either the network is unreachable,
|
|
2843
2837
|
// we can safely assume the credential is unavailable.
|
|
@@ -2866,7 +2860,7 @@ class ManagedIdentityCredential {
|
|
|
2866
2860
|
// Any other error should break the chain.
|
|
2867
2861
|
throw new AuthenticationError(err.statusCode, {
|
|
2868
2862
|
error: `${ManagedIdentityCredential.name} authentication failed.`,
|
|
2869
|
-
error_description: err.message
|
|
2863
|
+
error_description: err.message,
|
|
2870
2864
|
});
|
|
2871
2865
|
}
|
|
2872
2866
|
finally {
|
|
@@ -2900,7 +2894,7 @@ const defaultCredentials = [
|
|
|
2900
2894
|
DefaultManagedIdentityCredential,
|
|
2901
2895
|
VisualStudioCodeCredential,
|
|
2902
2896
|
AzureCliCredential,
|
|
2903
|
-
AzurePowerShellCredential
|
|
2897
|
+
AzurePowerShellCredential,
|
|
2904
2898
|
];
|
|
2905
2899
|
/**
|
|
2906
2900
|
* Provides a default {@link ChainedTokenCredential} configuration that should
|
|
@@ -2944,7 +2938,7 @@ class DefaultAzureCredential extends ChainedTokenCredential {
|
|
|
2944
2938
|
* @internal
|
|
2945
2939
|
*/
|
|
2946
2940
|
const interactiveBrowserMockable = {
|
|
2947
|
-
open
|
|
2941
|
+
open,
|
|
2948
2942
|
};
|
|
2949
2943
|
/**
|
|
2950
2944
|
* This MSAL client sets up a web server to listen for redirect callbacks, then calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`
|
|
@@ -2989,7 +2983,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
2989
2983
|
redirectUri: this.redirectUri,
|
|
2990
2984
|
scopes: scopes,
|
|
2991
2985
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
2992
|
-
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier
|
|
2986
|
+
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
2993
2987
|
};
|
|
2994
2988
|
this.acquireTokenByCode(tokenRequest)
|
|
2995
2989
|
.then((authResponse) => {
|
|
@@ -3004,7 +2998,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3004
2998
|
this.logger.getToken.info(formatSuccess(scopes));
|
|
3005
2999
|
resolve({
|
|
3006
3000
|
expiresOnTimestamp,
|
|
3007
|
-
token: authResponse.accessToken
|
|
3001
|
+
token: authResponse.accessToken,
|
|
3008
3002
|
});
|
|
3009
3003
|
}
|
|
3010
3004
|
else {
|
|
@@ -3049,7 +3043,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3049
3043
|
reject(new CredentialUnavailableError([
|
|
3050
3044
|
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3051
3045
|
`Try sending a redirect URI with a different port, as follows:`,
|
|
3052
|
-
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`'
|
|
3046
|
+
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`',
|
|
3053
3047
|
].join(" ")));
|
|
3054
3048
|
}
|
|
3055
3049
|
else {
|
|
@@ -3085,7 +3079,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3085
3079
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3086
3080
|
loginHint: this.loginHint,
|
|
3087
3081
|
codeChallenge: this.pkceCodes.challenge,
|
|
3088
|
-
codeChallengeMethod: "S256" // Use SHA256 Algorithm
|
|
3082
|
+
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3089
3083
|
};
|
|
3090
3084
|
const response = await this.publicApp.getAuthCodeUrl(authCodeUrlParameters);
|
|
3091
3085
|
try {
|
|
@@ -3182,7 +3176,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3182
3176
|
cancel: false,
|
|
3183
3177
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3184
3178
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3185
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
3179
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3186
3180
|
};
|
|
3187
3181
|
const promise = this.publicApp.acquireTokenByDeviceCode(requestOptions);
|
|
3188
3182
|
// TODO:
|
|
@@ -3302,7 +3296,7 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3302
3296
|
code: this.authorizationCode,
|
|
3303
3297
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3304
3298
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3305
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
3299
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3306
3300
|
}));
|
|
3307
3301
|
// The Client Credential flow does not return an account,
|
|
3308
3302
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -3386,7 +3380,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3386
3380
|
this.msalConfig.auth.clientCertificate = {
|
|
3387
3381
|
thumbprint: parts.thumbprint,
|
|
3388
3382
|
privateKey: parts.certificateContents,
|
|
3389
|
-
x5c: parts.x5c
|
|
3383
|
+
x5c: parts.x5c,
|
|
3390
3384
|
};
|
|
3391
3385
|
}
|
|
3392
3386
|
catch (error) {
|
|
@@ -3406,7 +3400,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3406
3400
|
correlationId: options.correlationId,
|
|
3407
3401
|
authority: options.authority,
|
|
3408
3402
|
claims: options.claims,
|
|
3409
|
-
oboAssertion: this.userAssertionToken
|
|
3403
|
+
oboAssertion: this.userAssertionToken,
|
|
3410
3404
|
});
|
|
3411
3405
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3412
3406
|
}
|