@azure/identity 2.0.2-alpha.20211214.3 → 2.0.2-alpha.20220131.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/CHANGELOG.md +2 -0
- package/dist/index.js +308 -282
- 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 +6 -7
package/dist/index.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
5
|
var msalNode = require('@azure/msal-node');
|
|
8
6
|
var coreTracing = require('@azure/core-tracing');
|
|
9
7
|
var coreClient = require('@azure/core-client');
|
|
@@ -14,17 +12,47 @@ var logger$k = require('@azure/logger');
|
|
|
14
12
|
var msalCommon = require('@azure/msal-common');
|
|
15
13
|
var uuid = require('uuid');
|
|
16
14
|
var fs = require('fs');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var path = _interopDefault(require('path'));
|
|
15
|
+
var os = require('os');
|
|
16
|
+
var path = require('path');
|
|
20
17
|
var child_process = require('child_process');
|
|
21
|
-
var child_process__default = _interopDefault(child_process);
|
|
22
18
|
var crypto = require('crypto');
|
|
23
19
|
var util = require('util');
|
|
24
|
-
var https =
|
|
25
|
-
var http =
|
|
26
|
-
var open =
|
|
27
|
-
var stoppable =
|
|
20
|
+
var https = require('https');
|
|
21
|
+
var http = require('http');
|
|
22
|
+
var open = require('open');
|
|
23
|
+
var stoppable = require('stoppable');
|
|
24
|
+
|
|
25
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
|
+
|
|
27
|
+
function _interopNamespace(e) {
|
|
28
|
+
if (e && e.__esModule) return e;
|
|
29
|
+
var n = Object.create(null);
|
|
30
|
+
if (e) {
|
|
31
|
+
Object.keys(e).forEach(function (k) {
|
|
32
|
+
if (k !== 'default') {
|
|
33
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
34
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () { return e[k]; }
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
n["default"] = e;
|
|
42
|
+
return Object.freeze(n);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var msalNode__namespace = /*#__PURE__*/_interopNamespace(msalNode);
|
|
46
|
+
var msalCommon__namespace = /*#__PURE__*/_interopNamespace(msalCommon);
|
|
47
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
48
|
+
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
|
|
49
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
50
|
+
var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
|
|
51
|
+
var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
|
|
52
|
+
var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
53
|
+
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
54
|
+
var open__default = /*#__PURE__*/_interopDefaultLegacy(open);
|
|
55
|
+
var stoppable__default = /*#__PURE__*/_interopDefaultLegacy(stoppable);
|
|
28
56
|
|
|
29
57
|
// Copyright (c) Microsoft Corporation.
|
|
30
58
|
// Licensed under the MIT license.
|
|
@@ -62,7 +90,7 @@ class AuthenticationError extends Error {
|
|
|
62
90
|
constructor(statusCode, errorBody) {
|
|
63
91
|
let errorResponse = {
|
|
64
92
|
error: "unknown",
|
|
65
|
-
errorDescription: "An unknown error occurred and no additional details are available."
|
|
93
|
+
errorDescription: "An unknown error occurred and no additional details are available.",
|
|
66
94
|
};
|
|
67
95
|
if (isErrorResponse(errorBody)) {
|
|
68
96
|
errorResponse = convertOAuthErrorResponseToErrorResponse(errorBody);
|
|
@@ -78,13 +106,13 @@ class AuthenticationError extends Error {
|
|
|
78
106
|
if (statusCode === 400) {
|
|
79
107
|
errorResponse = {
|
|
80
108
|
error: "authority_not_found",
|
|
81
|
-
errorDescription: "The specified authority URL was not found."
|
|
109
|
+
errorDescription: "The specified authority URL was not found.",
|
|
82
110
|
};
|
|
83
111
|
}
|
|
84
112
|
else {
|
|
85
113
|
errorResponse = {
|
|
86
114
|
error: "unknown_error",
|
|
87
|
-
errorDescription: `An unknown error has occurred. Response body:\n\n${errorBody}
|
|
115
|
+
errorDescription: `An unknown error has occurred. Response body:\n\n${errorBody}`,
|
|
88
116
|
};
|
|
89
117
|
}
|
|
90
118
|
}
|
|
@@ -92,7 +120,7 @@ class AuthenticationError extends Error {
|
|
|
92
120
|
else {
|
|
93
121
|
errorResponse = {
|
|
94
122
|
error: "unknown_error",
|
|
95
|
-
errorDescription: "An unknown error occurred and no additional details are available."
|
|
123
|
+
errorDescription: "An unknown error occurred and no additional details are available.",
|
|
96
124
|
};
|
|
97
125
|
}
|
|
98
126
|
super(`${errorResponse.error}(status code ${statusCode}).\nMore details:\n${errorResponse.errorDescription}`);
|
|
@@ -126,7 +154,7 @@ function convertOAuthErrorResponseToErrorResponse(errorBody) {
|
|
|
126
154
|
correlationId: errorBody.correlation_id,
|
|
127
155
|
errorCodes: errorBody.error_codes,
|
|
128
156
|
timestamp: errorBody.timestamp,
|
|
129
|
-
traceId: errorBody.trace_id
|
|
157
|
+
traceId: errorBody.trace_id,
|
|
130
158
|
};
|
|
131
159
|
}
|
|
132
160
|
/**
|
|
@@ -171,6 +199,10 @@ const DeveloperSignOnClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
|
|
|
171
199
|
* @internal
|
|
172
200
|
*/
|
|
173
201
|
const DefaultTenantId = "common";
|
|
202
|
+
/**
|
|
203
|
+
* A list of known Azure authority hosts
|
|
204
|
+
*/
|
|
205
|
+
exports.AzureAuthorityHosts = void 0;
|
|
174
206
|
(function (AzureAuthorityHosts) {
|
|
175
207
|
/**
|
|
176
208
|
* China-based Azure Authority Host
|
|
@@ -201,7 +233,7 @@ const DefaultAuthorityHost = exports.AzureAuthorityHosts.AzurePublicCloud;
|
|
|
201
233
|
*/
|
|
202
234
|
const createSpan = coreTracing.createSpanFunction({
|
|
203
235
|
packagePrefix: "",
|
|
204
|
-
namespace: "Microsoft.AAD"
|
|
236
|
+
namespace: "Microsoft.AAD",
|
|
205
237
|
});
|
|
206
238
|
/**
|
|
207
239
|
* From: https://github.com/Azure/azure-sdk-for-js/blob/46139daa3317a0d12e8b55b02b9d9cdf1b2e762a/sdk/appconfiguration/app-configuration/src/internal/tracingHelpers.ts
|
|
@@ -221,14 +253,14 @@ async function trace(operationName, options, fn, createSpanFn = createSpan) {
|
|
|
221
253
|
const result = await fn(updatedOptions, span);
|
|
222
254
|
// otel 0.16+ needs this or else the code ends up being set as UNSET
|
|
223
255
|
span.setStatus({
|
|
224
|
-
code: coreTracing.SpanStatusCode.OK
|
|
256
|
+
code: coreTracing.SpanStatusCode.OK,
|
|
225
257
|
});
|
|
226
258
|
return result;
|
|
227
259
|
}
|
|
228
260
|
catch (err) {
|
|
229
261
|
span.setStatus({
|
|
230
262
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
231
|
-
message: err.message
|
|
263
|
+
message: err.message,
|
|
232
264
|
});
|
|
233
265
|
throw err;
|
|
234
266
|
}
|
|
@@ -241,7 +273,7 @@ async function trace(operationName, options, fn, createSpanFn = createSpan) {
|
|
|
241
273
|
/**
|
|
242
274
|
* The AzureLogger used for all clients within the identity package
|
|
243
275
|
*/
|
|
244
|
-
const logger = logger$k.createClientLogger("identity");
|
|
276
|
+
const logger$j = logger$k.createClientLogger("identity");
|
|
245
277
|
/**
|
|
246
278
|
* Separates a list of environment variable names into a plain object with two arrays: an array of missing environment variables and another array with assigned environment variables.
|
|
247
279
|
* @param supportedEnvVars - List of environment variable names
|
|
@@ -281,7 +313,7 @@ function formatError(scope, error) {
|
|
|
281
313
|
* `[title] => [message]`
|
|
282
314
|
*
|
|
283
315
|
*/
|
|
284
|
-
function credentialLoggerInstance(title, parent, log = logger) {
|
|
316
|
+
function credentialLoggerInstance(title, parent, log = logger$j) {
|
|
285
317
|
const fullTitle = parent ? `${parent.fullTitle} ${title}` : title;
|
|
286
318
|
function info(message) {
|
|
287
319
|
log.info(`${fullTitle} =>`, message);
|
|
@@ -289,7 +321,7 @@ function credentialLoggerInstance(title, parent, log = logger) {
|
|
|
289
321
|
return {
|
|
290
322
|
title,
|
|
291
323
|
fullTitle,
|
|
292
|
-
info
|
|
324
|
+
info,
|
|
293
325
|
};
|
|
294
326
|
}
|
|
295
327
|
/**
|
|
@@ -302,7 +334,7 @@ function credentialLoggerInstance(title, parent, log = logger) {
|
|
|
302
334
|
* `[title] => getToken() => [message]`
|
|
303
335
|
*
|
|
304
336
|
*/
|
|
305
|
-
function credentialLogger(title, log = logger) {
|
|
337
|
+
function credentialLogger(title, log = logger$j) {
|
|
306
338
|
const credLogger = credentialLoggerInstance(title, undefined, log);
|
|
307
339
|
return Object.assign(Object.assign({}, credLogger), { parent: log, getToken: credentialLoggerInstance("=> getToken()", credLogger, log) });
|
|
308
340
|
}
|
|
@@ -341,13 +373,13 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
341
373
|
throw new Error("The authorityHost address must use the 'https' protocol.");
|
|
342
374
|
}
|
|
343
375
|
super(Object.assign(Object.assign({ requestContentType: "application/json; charset=utf-8" }, options), { userAgentOptions: {
|
|
344
|
-
userAgentPrefix
|
|
376
|
+
userAgentPrefix,
|
|
345
377
|
}, baseUri }));
|
|
346
378
|
this.authorityHost = baseUri;
|
|
347
379
|
this.abortControllers = new Map();
|
|
348
380
|
}
|
|
349
381
|
async sendTokenRequest(request, expiresOnParser) {
|
|
350
|
-
logger.info(`IdentityClient: sending token request to [${request.url}]`);
|
|
382
|
+
logger$j.info(`IdentityClient: sending token request to [${request.url}]`);
|
|
351
383
|
const response = await this.sendRequest(request);
|
|
352
384
|
expiresOnParser =
|
|
353
385
|
expiresOnParser ||
|
|
@@ -362,16 +394,16 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
362
394
|
const token = {
|
|
363
395
|
accessToken: {
|
|
364
396
|
token: parsedBody.access_token,
|
|
365
|
-
expiresOnTimestamp: expiresOnParser(parsedBody)
|
|
397
|
+
expiresOnTimestamp: expiresOnParser(parsedBody),
|
|
366
398
|
},
|
|
367
|
-
refreshToken: parsedBody.refresh_token
|
|
399
|
+
refreshToken: parsedBody.refresh_token,
|
|
368
400
|
};
|
|
369
|
-
logger.info(`IdentityClient: [${request.url}] token acquired, expires on ${token.accessToken.expiresOnTimestamp}`);
|
|
401
|
+
logger$j.info(`IdentityClient: [${request.url}] token acquired, expires on ${token.accessToken.expiresOnTimestamp}`);
|
|
370
402
|
return token;
|
|
371
403
|
}
|
|
372
404
|
else {
|
|
373
405
|
const error = new AuthenticationError(response.status, response.bodyAsText);
|
|
374
|
-
logger.warning(`IdentityClient: authentication error. HTTP status: ${response.status}, ${error.errorResponse.errorDescription}`);
|
|
406
|
+
logger$j.warning(`IdentityClient: authentication error. HTTP status: ${response.status}, ${error.errorResponse.errorDescription}`);
|
|
375
407
|
throw error;
|
|
376
408
|
}
|
|
377
409
|
}
|
|
@@ -379,13 +411,13 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
379
411
|
if (refreshToken === undefined) {
|
|
380
412
|
return null;
|
|
381
413
|
}
|
|
382
|
-
logger.info(`IdentityClient: refreshing access token with client ID: ${clientId}, scopes: ${scopes} started`);
|
|
414
|
+
logger$j.info(`IdentityClient: refreshing access token with client ID: ${clientId}, scopes: ${scopes} started`);
|
|
383
415
|
const { span, updatedOptions } = createSpan("IdentityClient-refreshAccessToken", options);
|
|
384
416
|
const refreshParams = {
|
|
385
417
|
grant_type: "refresh_token",
|
|
386
418
|
client_id: clientId,
|
|
387
419
|
refresh_token: refreshToken,
|
|
388
|
-
scope: scopes
|
|
420
|
+
scope: scopes,
|
|
389
421
|
};
|
|
390
422
|
if (clientSecret !== undefined) {
|
|
391
423
|
refreshParams.client_secret = clientSecret;
|
|
@@ -400,12 +432,12 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
400
432
|
abortSignal: options && options.abortSignal,
|
|
401
433
|
headers: coreRestPipeline.createHttpHeaders({
|
|
402
434
|
Accept: "application/json",
|
|
403
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
435
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
404
436
|
}),
|
|
405
|
-
tracingOptions: updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.tracingOptions
|
|
437
|
+
tracingOptions: updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.tracingOptions,
|
|
406
438
|
});
|
|
407
439
|
const response = await this.sendTokenRequest(request, expiresOnParser);
|
|
408
|
-
logger.info(`IdentityClient: refreshed token for client ID: ${clientId}`);
|
|
440
|
+
logger$j.info(`IdentityClient: refreshed token for client ID: ${clientId}`);
|
|
409
441
|
return response;
|
|
410
442
|
}
|
|
411
443
|
catch (err) {
|
|
@@ -414,18 +446,18 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
414
446
|
// It's likely that the refresh token has expired, so
|
|
415
447
|
// return null so that the credential implementation will
|
|
416
448
|
// initiate the authentication flow again.
|
|
417
|
-
logger.info(`IdentityClient: interaction required for client ID: ${clientId}`);
|
|
449
|
+
logger$j.info(`IdentityClient: interaction required for client ID: ${clientId}`);
|
|
418
450
|
span.setStatus({
|
|
419
451
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
420
|
-
message: err.message
|
|
452
|
+
message: err.message,
|
|
421
453
|
});
|
|
422
454
|
return null;
|
|
423
455
|
}
|
|
424
456
|
else {
|
|
425
|
-
logger.warning(`IdentityClient: failed refreshing token for client ID: ${clientId}: ${err}`);
|
|
457
|
+
logger$j.warning(`IdentityClient: failed refreshing token for client ID: ${clientId}: ${err}`);
|
|
426
458
|
span.setStatus({
|
|
427
459
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
428
|
-
message: err.message
|
|
460
|
+
message: err.message,
|
|
429
461
|
});
|
|
430
462
|
throw err;
|
|
431
463
|
}
|
|
@@ -455,7 +487,7 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
455
487
|
const controllers = [
|
|
456
488
|
...(this.abortControllers.get(key) || []),
|
|
457
489
|
// MSAL passes no correlation ID to the get requests...
|
|
458
|
-
...(this.abortControllers.get(noCorrelationId) || [])
|
|
490
|
+
...(this.abortControllers.get(noCorrelationId) || []),
|
|
459
491
|
];
|
|
460
492
|
if (!controllers.length) {
|
|
461
493
|
return;
|
|
@@ -477,13 +509,13 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
477
509
|
method: "GET",
|
|
478
510
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
479
511
|
headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
|
|
480
|
-
abortSignal: this.generateAbortSignal(noCorrelationId)
|
|
512
|
+
abortSignal: this.generateAbortSignal(noCorrelationId),
|
|
481
513
|
});
|
|
482
514
|
const response = await this.sendRequest(request);
|
|
483
515
|
return {
|
|
484
516
|
body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
|
|
485
517
|
headers: response.headers.toJSON(),
|
|
486
|
-
status: response.status
|
|
518
|
+
status: response.status,
|
|
487
519
|
};
|
|
488
520
|
}
|
|
489
521
|
async sendPostRequestAsync(url, options) {
|
|
@@ -493,13 +525,13 @@ class IdentityClient extends coreClient.ServiceClient {
|
|
|
493
525
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
494
526
|
headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
|
|
495
527
|
// MSAL doesn't send the correlation ID on the get requests.
|
|
496
|
-
abortSignal: this.generateAbortSignal(this.getCorrelationId(options))
|
|
528
|
+
abortSignal: this.generateAbortSignal(this.getCorrelationId(options)),
|
|
497
529
|
});
|
|
498
530
|
const response = await this.sendRequest(request);
|
|
499
531
|
return {
|
|
500
532
|
body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
|
|
501
533
|
headers: response.headers.toJSON(),
|
|
502
|
-
status: response.status
|
|
534
|
+
status: response.status,
|
|
503
535
|
};
|
|
504
536
|
}
|
|
505
537
|
}
|
|
@@ -544,7 +576,7 @@ function ensureValidMsalToken(scopes, logger, msalToken, getTokenOptions) {
|
|
|
544
576
|
return new AuthenticationRequiredError({
|
|
545
577
|
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
546
578
|
getTokenOptions,
|
|
547
|
-
message
|
|
579
|
+
message,
|
|
548
580
|
});
|
|
549
581
|
};
|
|
550
582
|
if (!msalToken) {
|
|
@@ -595,16 +627,16 @@ const defaultLoggerCallback = (logger, platform = coreUtil.isNode ? "Node" : "Br
|
|
|
595
627
|
return;
|
|
596
628
|
}
|
|
597
629
|
switch (level) {
|
|
598
|
-
case
|
|
630
|
+
case msalCommon__namespace.LogLevel.Error:
|
|
599
631
|
logger.info(`MSAL ${platform} V2 error: ${message}`);
|
|
600
632
|
return;
|
|
601
|
-
case
|
|
633
|
+
case msalCommon__namespace.LogLevel.Info:
|
|
602
634
|
logger.info(`MSAL ${platform} V2 info message: ${message}`);
|
|
603
635
|
return;
|
|
604
|
-
case
|
|
636
|
+
case msalCommon__namespace.LogLevel.Verbose:
|
|
605
637
|
logger.info(`MSAL ${platform} V2 verbose message: ${message}`);
|
|
606
638
|
return;
|
|
607
|
-
case
|
|
639
|
+
case msalCommon__namespace.LogLevel.Warning:
|
|
608
640
|
logger.info(`MSAL ${platform} V2 warning: ${message}`);
|
|
609
641
|
return;
|
|
610
642
|
}
|
|
@@ -641,7 +673,7 @@ class MsalBaseUtilities {
|
|
|
641
673
|
this.logger.getToken.info(formatSuccess(scopes));
|
|
642
674
|
return {
|
|
643
675
|
token: result.accessToken,
|
|
644
|
-
expiresOnTimestamp: result.expiresOn.getTime()
|
|
676
|
+
expiresOnTimestamp: result.expiresOn.getTime(),
|
|
645
677
|
};
|
|
646
678
|
}
|
|
647
679
|
/**
|
|
@@ -688,7 +720,7 @@ function msalToPublic(clientId, account) {
|
|
|
688
720
|
tenantId: account.tenantId || DefaultTenantId,
|
|
689
721
|
username: account.username,
|
|
690
722
|
clientId,
|
|
691
|
-
version: LatestAuthenticationRecordVersion
|
|
723
|
+
version: LatestAuthenticationRecordVersion,
|
|
692
724
|
};
|
|
693
725
|
return record;
|
|
694
726
|
}
|
|
@@ -893,7 +925,7 @@ let persistenceProvider = undefined;
|
|
|
893
925
|
const msalNodeFlowCacheControl = {
|
|
894
926
|
setPersistence(pluginProvider) {
|
|
895
927
|
persistenceProvider = pluginProvider;
|
|
896
|
-
}
|
|
928
|
+
},
|
|
897
929
|
};
|
|
898
930
|
/**
|
|
899
931
|
* MSAL partial base client for Node.js.
|
|
@@ -921,7 +953,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
921
953
|
"Persistent token caching was requested, but no persistence provider was configured.",
|
|
922
954
|
"You must install the identity-cache-persistence plugin package (`npm install --save @azure/identity-cache-persistence`)",
|
|
923
955
|
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
924
|
-
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`."
|
|
956
|
+
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`.",
|
|
925
957
|
].join(" "));
|
|
926
958
|
}
|
|
927
959
|
this.azureRegion = (_c = options.regionalAuthority) !== null && _c !== void 0 ? _c : process.env.AZURE_REGIONAL_AUTHORITY_NAME;
|
|
@@ -947,15 +979,15 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
947
979
|
clientId,
|
|
948
980
|
authority,
|
|
949
981
|
knownAuthorities: getKnownAuthorities(tenantId, authority),
|
|
950
|
-
clientCapabilities
|
|
982
|
+
clientCapabilities,
|
|
951
983
|
},
|
|
952
984
|
// Cache is defined in this.prepare();
|
|
953
985
|
system: {
|
|
954
986
|
networkClient: this.identityClient,
|
|
955
987
|
loggerOptions: {
|
|
956
|
-
loggerCallback: defaultLoggerCallback(options.logger)
|
|
957
|
-
}
|
|
958
|
-
}
|
|
988
|
+
loggerCallback: defaultLoggerCallback(options.logger),
|
|
989
|
+
},
|
|
990
|
+
},
|
|
959
991
|
};
|
|
960
992
|
}
|
|
961
993
|
/**
|
|
@@ -974,15 +1006,15 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
974
1006
|
}
|
|
975
1007
|
if (this.createCachePlugin !== undefined) {
|
|
976
1008
|
this.msalConfig.cache = {
|
|
977
|
-
cachePlugin: await this.createCachePlugin()
|
|
1009
|
+
cachePlugin: await this.createCachePlugin(),
|
|
978
1010
|
};
|
|
979
1011
|
}
|
|
980
|
-
this.publicApp = new
|
|
1012
|
+
this.publicApp = new msalNode__namespace.PublicClientApplication(this.msalConfig);
|
|
981
1013
|
// The confidential client requires either a secret, assertion or certificate.
|
|
982
1014
|
if (this.msalConfig.auth.clientSecret ||
|
|
983
1015
|
this.msalConfig.auth.clientAssertion ||
|
|
984
1016
|
this.msalConfig.auth.clientCertificate) {
|
|
985
|
-
this.confidentialApp = new
|
|
1017
|
+
this.confidentialApp = new msalNode__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
986
1018
|
}
|
|
987
1019
|
else {
|
|
988
1020
|
if (this.requiresConfidential) {
|
|
@@ -1044,7 +1076,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1044
1076
|
throw new AuthenticationRequiredError({
|
|
1045
1077
|
scopes,
|
|
1046
1078
|
getTokenOptions: options,
|
|
1047
|
-
message: "Silent authentication failed. We couldn't retrieve an active account from the cache."
|
|
1079
|
+
message: "Silent authentication failed. We couldn't retrieve an active account from the cache.",
|
|
1048
1080
|
});
|
|
1049
1081
|
}
|
|
1050
1082
|
const silentRequest = {
|
|
@@ -1053,7 +1085,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1053
1085
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
1054
1086
|
scopes,
|
|
1055
1087
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1056
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
1088
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1057
1089
|
};
|
|
1058
1090
|
try {
|
|
1059
1091
|
this.logger.info("Attempting to acquire token silently");
|
|
@@ -1084,7 +1116,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1084
1116
|
throw new AuthenticationRequiredError({
|
|
1085
1117
|
scopes,
|
|
1086
1118
|
getTokenOptions: options,
|
|
1087
|
-
message: "Automatic authentication has been disabled. You may call the authentication() method."
|
|
1119
|
+
message: "Automatic authentication has been disabled. You may call the authentication() method.",
|
|
1088
1120
|
});
|
|
1089
1121
|
}
|
|
1090
1122
|
this.logger.info(`Silent authentication failed, falling back to interactive method.`);
|
|
@@ -1096,16 +1128,16 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1096
1128
|
// Copyright (c) Microsoft Corporation.
|
|
1097
1129
|
const CommonTenantId = "common";
|
|
1098
1130
|
const AzureAccountClientId = "aebc6443-996d-45c2-90f0-388ff96faa56"; // VSC: 'aebc6443-996d-45c2-90f0-388ff96faa56'
|
|
1099
|
-
const logger$
|
|
1131
|
+
const logger$i = credentialLogger("VisualStudioCodeCredential");
|
|
1100
1132
|
let findCredentials = undefined;
|
|
1101
1133
|
const vsCodeCredentialControl = {
|
|
1102
1134
|
setVsCodeCredentialFinder(finder) {
|
|
1103
1135
|
findCredentials = finder;
|
|
1104
|
-
}
|
|
1136
|
+
},
|
|
1105
1137
|
};
|
|
1106
1138
|
// Map of unsupported Tenant IDs and the errors we will be throwing.
|
|
1107
1139
|
const unsupportedTenantIds = {
|
|
1108
|
-
adfs: "The VisualStudioCodeCredential does not support authentication with ADFS tenants."
|
|
1140
|
+
adfs: "The VisualStudioCodeCredential does not support authentication with ADFS tenants.",
|
|
1109
1141
|
};
|
|
1110
1142
|
function checkUnsupportedTenant(tenantId) {
|
|
1111
1143
|
// If the Tenant ID isn't supported, we throw.
|
|
@@ -1118,7 +1150,7 @@ const mapVSCodeAuthorityHosts = {
|
|
|
1118
1150
|
AzureCloud: exports.AzureAuthorityHosts.AzurePublicCloud,
|
|
1119
1151
|
AzureChina: exports.AzureAuthorityHosts.AzureChina,
|
|
1120
1152
|
AzureGermanCloud: exports.AzureAuthorityHosts.AzureGermany,
|
|
1121
|
-
AzureUSGovernment: exports.AzureAuthorityHosts.AzureGovernment
|
|
1153
|
+
AzureUSGovernment: exports.AzureAuthorityHosts.AzureGovernment,
|
|
1122
1154
|
};
|
|
1123
1155
|
/**
|
|
1124
1156
|
* Attempts to load a specific property from the VSCode configurations of the current OS.
|
|
@@ -1128,10 +1160,10 @@ function getPropertyFromVSCode(property) {
|
|
|
1128
1160
|
const settingsPath = ["User", "settings.json"];
|
|
1129
1161
|
// Eventually we can add more folders for more versions of VSCode.
|
|
1130
1162
|
const vsCodeFolder = "Code";
|
|
1131
|
-
const homedir =
|
|
1163
|
+
const homedir = os__default["default"].homedir();
|
|
1132
1164
|
function loadProperty(...pathSegments) {
|
|
1133
|
-
const fullPath =
|
|
1134
|
-
const settings = JSON.parse(fs__default.readFileSync(fullPath, { encoding: "utf8" }));
|
|
1165
|
+
const fullPath = path__default["default"].join(...pathSegments, vsCodeFolder, ...settingsPath);
|
|
1166
|
+
const settings = JSON.parse(fs__default["default"].readFileSync(fullPath, { encoding: "utf8" }));
|
|
1135
1167
|
return settings[property];
|
|
1136
1168
|
}
|
|
1137
1169
|
try {
|
|
@@ -1149,7 +1181,7 @@ function getPropertyFromVSCode(property) {
|
|
|
1149
1181
|
}
|
|
1150
1182
|
}
|
|
1151
1183
|
catch (e) {
|
|
1152
|
-
logger$
|
|
1184
|
+
logger$i.info(`Failed to load the Visual Studio Code configuration file. Error: ${e.message}`);
|
|
1153
1185
|
return;
|
|
1154
1186
|
}
|
|
1155
1187
|
}
|
|
@@ -1177,7 +1209,7 @@ class VisualStudioCodeCredential {
|
|
|
1177
1209
|
const authorityHost = mapVSCodeAuthorityHosts[this.cloudName];
|
|
1178
1210
|
this.identityClient = new IdentityClient(Object.assign({ authorityHost }, options));
|
|
1179
1211
|
if (options && options.tenantId) {
|
|
1180
|
-
checkTenantId(logger$
|
|
1212
|
+
checkTenantId(logger$i, options.tenantId);
|
|
1181
1213
|
this.tenantId = options.tenantId;
|
|
1182
1214
|
}
|
|
1183
1215
|
else {
|
|
@@ -1222,14 +1254,14 @@ class VisualStudioCodeCredential {
|
|
|
1222
1254
|
"No implementation of `VisualStudioCodeCredential` is available.",
|
|
1223
1255
|
"You must install the identity-vscode plugin package (`npm install --save-dev @azure/identity-vscode`)",
|
|
1224
1256
|
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
1225
|
-
"`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`."
|
|
1257
|
+
"`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`.",
|
|
1226
1258
|
].join(" "));
|
|
1227
1259
|
}
|
|
1228
1260
|
let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
1229
1261
|
// Check to make sure the scope we get back is a valid scope
|
|
1230
1262
|
if (!scopeString.match(/^[0-9a-zA-Z-.:/]+$/)) {
|
|
1231
1263
|
const error = new Error("Invalid scope was specified by the user or calling client");
|
|
1232
|
-
logger$
|
|
1264
|
+
logger$i.getToken.info(formatError(scopes, error));
|
|
1233
1265
|
throw error;
|
|
1234
1266
|
}
|
|
1235
1267
|
if (scopeString.indexOf("offline_access") < 0) {
|
|
@@ -1249,18 +1281,18 @@ class VisualStudioCodeCredential {
|
|
|
1249
1281
|
if (refreshToken) {
|
|
1250
1282
|
const tokenResponse = await this.identityClient.refreshAccessToken(tenantId, AzureAccountClientId, scopeString, refreshToken, undefined);
|
|
1251
1283
|
if (tokenResponse) {
|
|
1252
|
-
logger$
|
|
1284
|
+
logger$i.getToken.info(formatSuccess(scopes));
|
|
1253
1285
|
return tokenResponse.accessToken;
|
|
1254
1286
|
}
|
|
1255
1287
|
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/
|
|
1257
|
-
logger$
|
|
1288
|
+
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.");
|
|
1289
|
+
logger$i.getToken.info(formatError(scopes, error));
|
|
1258
1290
|
throw error;
|
|
1259
1291
|
}
|
|
1260
1292
|
}
|
|
1261
1293
|
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/
|
|
1263
|
-
logger$
|
|
1294
|
+
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.");
|
|
1295
|
+
logger$i.getToken.info(formatError(scopes, error));
|
|
1264
1296
|
throw error;
|
|
1265
1297
|
}
|
|
1266
1298
|
}
|
|
@@ -1274,7 +1306,7 @@ class VisualStudioCodeCredential {
|
|
|
1274
1306
|
*/
|
|
1275
1307
|
const pluginContext = {
|
|
1276
1308
|
cachePluginControl: msalNodeFlowCacheControl,
|
|
1277
|
-
vsCodeCredentialControl: vsCodeCredentialControl
|
|
1309
|
+
vsCodeCredentialControl: vsCodeCredentialControl,
|
|
1278
1310
|
};
|
|
1279
1311
|
/**
|
|
1280
1312
|
* Extend Azure Identity with additional functionality. Pass a plugin from
|
|
@@ -1311,7 +1343,7 @@ function useIdentityPlugin(plugin) {
|
|
|
1311
1343
|
/**
|
|
1312
1344
|
* @internal
|
|
1313
1345
|
*/
|
|
1314
|
-
const logger$
|
|
1346
|
+
const logger$h = credentialLogger("ChainedTokenCredential");
|
|
1315
1347
|
/**
|
|
1316
1348
|
* Enables multiple `TokenCredential` implementations to be tried in order
|
|
1317
1349
|
* until one of the getToken methods returns an access token.
|
|
@@ -1366,7 +1398,7 @@ class ChainedTokenCredential {
|
|
|
1366
1398
|
errors.push(err);
|
|
1367
1399
|
}
|
|
1368
1400
|
else {
|
|
1369
|
-
logger$
|
|
1401
|
+
logger$h.getToken.info(formatError(scopes, err));
|
|
1370
1402
|
throw err;
|
|
1371
1403
|
}
|
|
1372
1404
|
}
|
|
@@ -1375,13 +1407,13 @@ class ChainedTokenCredential {
|
|
|
1375
1407
|
const err = new AggregateAuthenticationError(errors, "ChainedTokenCredential authentication failed.");
|
|
1376
1408
|
span.setStatus({
|
|
1377
1409
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
1378
|
-
message: err.message
|
|
1410
|
+
message: err.message,
|
|
1379
1411
|
});
|
|
1380
|
-
logger$
|
|
1412
|
+
logger$h.getToken.info(formatError(scopes, err));
|
|
1381
1413
|
throw err;
|
|
1382
1414
|
}
|
|
1383
1415
|
span.end();
|
|
1384
|
-
logger$
|
|
1416
|
+
logger$h.getToken.info(`Result for ${successfulCredentialName}: ${formatSuccess(scopes)}`);
|
|
1385
1417
|
if (token === null) {
|
|
1386
1418
|
throw new CredentialUnavailableError("Failed to retrieve a valid token");
|
|
1387
1419
|
}
|
|
@@ -1441,14 +1473,14 @@ const cliCredentialInternals = {
|
|
|
1441
1473
|
}
|
|
1442
1474
|
return new Promise((resolve, reject) => {
|
|
1443
1475
|
try {
|
|
1444
|
-
child_process__default.execFile("az", [
|
|
1476
|
+
child_process__default["default"].execFile("az", [
|
|
1445
1477
|
"account",
|
|
1446
1478
|
"get-access-token",
|
|
1447
1479
|
"--output",
|
|
1448
1480
|
"json",
|
|
1449
1481
|
"--resource",
|
|
1450
1482
|
resource,
|
|
1451
|
-
...tenantSection
|
|
1483
|
+
...tenantSection,
|
|
1452
1484
|
], { cwd: cliCredentialInternals.getSafeWorkingDir(), shell: true }, (error, stdout, stderr) => {
|
|
1453
1485
|
resolve({ stdout: stdout, stderr: stderr, error });
|
|
1454
1486
|
});
|
|
@@ -1457,9 +1489,9 @@ const cliCredentialInternals = {
|
|
|
1457
1489
|
reject(err);
|
|
1458
1490
|
}
|
|
1459
1491
|
});
|
|
1460
|
-
}
|
|
1492
|
+
},
|
|
1461
1493
|
};
|
|
1462
|
-
const logger$
|
|
1494
|
+
const logger$g = credentialLogger("AzureCliCredential");
|
|
1463
1495
|
/**
|
|
1464
1496
|
* This credential will use the currently logged-in user login information
|
|
1465
1497
|
* via the Azure CLI ('az') commandline tool.
|
|
@@ -1489,11 +1521,11 @@ class AzureCliCredential {
|
|
|
1489
1521
|
async getToken(scopes, options) {
|
|
1490
1522
|
const tenantId = processMultiTenantRequest(this.tenantId, options);
|
|
1491
1523
|
if (tenantId) {
|
|
1492
|
-
checkTenantId(logger$
|
|
1524
|
+
checkTenantId(logger$g, tenantId);
|
|
1493
1525
|
}
|
|
1494
1526
|
const scope = typeof scopes === "string" ? scopes : scopes[0];
|
|
1495
|
-
logger$
|
|
1496
|
-
ensureValidScope(scope, logger$
|
|
1527
|
+
logger$g.getToken.info(`Using the scope ${scope}`);
|
|
1528
|
+
ensureValidScope(scope, logger$g);
|
|
1497
1529
|
const resource = getScopeResource(scope);
|
|
1498
1530
|
let responseData = "";
|
|
1499
1531
|
const { span } = createSpan(`${this.constructor.name}.getToken`, options);
|
|
@@ -1504,25 +1536,25 @@ class AzureCliCredential {
|
|
|
1504
1536
|
const isNotInstallError = obj.stderr.match("az:(.*)not found") || obj.stderr.startsWith("'az' is not recognized");
|
|
1505
1537
|
if (isNotInstallError) {
|
|
1506
1538
|
const error = new CredentialUnavailableError("Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.");
|
|
1507
|
-
logger$
|
|
1539
|
+
logger$g.getToken.info(formatError(scopes, error));
|
|
1508
1540
|
throw error;
|
|
1509
1541
|
}
|
|
1510
1542
|
else if (isLoginError) {
|
|
1511
1543
|
const error = new CredentialUnavailableError("Please run 'az login' from a command prompt to authenticate before using this credential.");
|
|
1512
|
-
logger$
|
|
1544
|
+
logger$g.getToken.info(formatError(scopes, error));
|
|
1513
1545
|
throw error;
|
|
1514
1546
|
}
|
|
1515
1547
|
const error = new CredentialUnavailableError(obj.stderr);
|
|
1516
|
-
logger$
|
|
1548
|
+
logger$g.getToken.info(formatError(scopes, error));
|
|
1517
1549
|
throw error;
|
|
1518
1550
|
}
|
|
1519
1551
|
else {
|
|
1520
1552
|
responseData = obj.stdout;
|
|
1521
1553
|
const response = JSON.parse(responseData);
|
|
1522
|
-
logger$
|
|
1554
|
+
logger$g.getToken.info(formatSuccess(scopes));
|
|
1523
1555
|
const returnValue = {
|
|
1524
1556
|
token: response.accessToken,
|
|
1525
|
-
expiresOnTimestamp: new Date(response.expiresOn).getTime()
|
|
1557
|
+
expiresOnTimestamp: new Date(response.expiresOn).getTime(),
|
|
1526
1558
|
};
|
|
1527
1559
|
return returnValue;
|
|
1528
1560
|
}
|
|
@@ -1531,9 +1563,9 @@ class AzureCliCredential {
|
|
|
1531
1563
|
const error = new Error(err.message || "Unknown error while trying to retrieve the access token");
|
|
1532
1564
|
span.setStatus({
|
|
1533
1565
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
1534
|
-
message: error.message
|
|
1566
|
+
message: error.message,
|
|
1535
1567
|
});
|
|
1536
|
-
logger$
|
|
1568
|
+
logger$g.getToken.info(formatError(scopes, error));
|
|
1537
1569
|
throw error;
|
|
1538
1570
|
}
|
|
1539
1571
|
}
|
|
@@ -1551,7 +1583,7 @@ const processUtils = {
|
|
|
1551
1583
|
*/
|
|
1552
1584
|
execFile(file, params, options) {
|
|
1553
1585
|
return new Promise((resolve, reject) => {
|
|
1554
|
-
|
|
1586
|
+
child_process__namespace.execFile(file, params, options, (error, stdout, stderr) => {
|
|
1555
1587
|
if (Buffer.isBuffer(stdout)) {
|
|
1556
1588
|
stdout = stdout.toString("utf8");
|
|
1557
1589
|
}
|
|
@@ -1566,11 +1598,11 @@ const processUtils = {
|
|
|
1566
1598
|
}
|
|
1567
1599
|
});
|
|
1568
1600
|
});
|
|
1569
|
-
}
|
|
1601
|
+
},
|
|
1570
1602
|
};
|
|
1571
1603
|
|
|
1572
1604
|
// Copyright (c) Microsoft Corporation.
|
|
1573
|
-
const logger$
|
|
1605
|
+
const logger$f = credentialLogger("AzurePowerShellCredential");
|
|
1574
1606
|
const isWindows = process.platform === "win32";
|
|
1575
1607
|
/**
|
|
1576
1608
|
* Returns a platform-appropriate command name by appending ".exe" on Windows.
|
|
@@ -1605,7 +1637,7 @@ async function runCommands(commands) {
|
|
|
1605
1637
|
*/
|
|
1606
1638
|
const powerShellErrors = {
|
|
1607
1639
|
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"
|
|
1640
|
+
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
1641
|
};
|
|
1610
1642
|
/**
|
|
1611
1643
|
* Messages to use when throwing in this credential.
|
|
@@ -1614,7 +1646,7 @@ const powerShellErrors = {
|
|
|
1614
1646
|
const powerShellPublicErrorMessages = {
|
|
1615
1647
|
login: "Please run 'Connect-AzAccount' from PowerShell to authenticate before using this credential.",
|
|
1616
1648
|
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
|
|
1649
|
+
troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot.`,
|
|
1618
1650
|
};
|
|
1619
1651
|
// PowerShell Azure User not logged in error check.
|
|
1620
1652
|
const isLoginError = (err) => err.message.match(`(.*)${powerShellErrors.login}(.*)`);
|
|
@@ -1672,13 +1704,13 @@ class AzurePowerShellCredential {
|
|
|
1672
1704
|
[
|
|
1673
1705
|
powerShellCommand,
|
|
1674
1706
|
"-Command",
|
|
1675
|
-
"Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru"
|
|
1707
|
+
"Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru",
|
|
1676
1708
|
],
|
|
1677
1709
|
[
|
|
1678
1710
|
powerShellCommand,
|
|
1679
1711
|
"-Command",
|
|
1680
|
-
`Get-AzAccessToken ${tenantSection} -ResourceUrl "${resource}" | ConvertTo-Json
|
|
1681
|
-
]
|
|
1712
|
+
`Get-AzAccessToken ${tenantSection} -ResourceUrl "${resource}" | ConvertTo-Json`,
|
|
1713
|
+
],
|
|
1682
1714
|
]);
|
|
1683
1715
|
const result = results[1];
|
|
1684
1716
|
try {
|
|
@@ -1701,33 +1733,33 @@ class AzurePowerShellCredential {
|
|
|
1701
1733
|
return trace(`${this.constructor.name}.getToken`, options, async () => {
|
|
1702
1734
|
const tenantId = processMultiTenantRequest(this.tenantId, options);
|
|
1703
1735
|
if (tenantId) {
|
|
1704
|
-
checkTenantId(logger$
|
|
1736
|
+
checkTenantId(logger$f, tenantId);
|
|
1705
1737
|
}
|
|
1706
1738
|
const scope = typeof scopes === "string" ? scopes : scopes[0];
|
|
1707
|
-
ensureValidScope(scope, logger$
|
|
1708
|
-
logger$
|
|
1739
|
+
ensureValidScope(scope, logger$f);
|
|
1740
|
+
logger$f.getToken.info(`Using the scope ${scope}`);
|
|
1709
1741
|
const resource = getScopeResource(scope);
|
|
1710
1742
|
try {
|
|
1711
1743
|
const response = await this.getAzurePowerShellAccessToken(resource, tenantId);
|
|
1712
|
-
logger$
|
|
1744
|
+
logger$f.getToken.info(formatSuccess(scopes));
|
|
1713
1745
|
return {
|
|
1714
1746
|
token: response.Token,
|
|
1715
|
-
expiresOnTimestamp: new Date(response.ExpiresOn).getTime()
|
|
1747
|
+
expiresOnTimestamp: new Date(response.ExpiresOn).getTime(),
|
|
1716
1748
|
};
|
|
1717
1749
|
}
|
|
1718
1750
|
catch (err) {
|
|
1719
1751
|
if (isNotInstalledError(err)) {
|
|
1720
1752
|
const error = new CredentialUnavailableError(powerShellPublicErrorMessages.installed);
|
|
1721
|
-
logger$
|
|
1753
|
+
logger$f.getToken.info(formatError(scope, error));
|
|
1722
1754
|
throw error;
|
|
1723
1755
|
}
|
|
1724
1756
|
else if (isLoginError(err)) {
|
|
1725
1757
|
const error = new CredentialUnavailableError(powerShellPublicErrorMessages.login);
|
|
1726
|
-
logger$
|
|
1758
|
+
logger$f.getToken.info(formatError(scope, error));
|
|
1727
1759
|
throw error;
|
|
1728
1760
|
}
|
|
1729
1761
|
const error = new CredentialUnavailableError(`${err}. ${powerShellPublicErrorMessages.troubleshoot}`);
|
|
1730
|
-
logger$
|
|
1762
|
+
logger$f.getToken.info(formatError(scope, error));
|
|
1731
1763
|
throw error;
|
|
1732
1764
|
}
|
|
1733
1765
|
});
|
|
@@ -1752,7 +1784,7 @@ class MsalClientSecret extends MsalNode {
|
|
|
1752
1784
|
correlationId: options.correlationId,
|
|
1753
1785
|
azureRegion: this.azureRegion,
|
|
1754
1786
|
authority: options.authority,
|
|
1755
|
-
claims: options.claims
|
|
1787
|
+
claims: options.claims,
|
|
1756
1788
|
});
|
|
1757
1789
|
// The Client Credential flow does not return an account,
|
|
1758
1790
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -1765,7 +1797,7 @@ class MsalClientSecret extends MsalNode {
|
|
|
1765
1797
|
}
|
|
1766
1798
|
|
|
1767
1799
|
// Copyright (c) Microsoft Corporation.
|
|
1768
|
-
const logger$
|
|
1800
|
+
const logger$e = credentialLogger("ClientSecretCredential");
|
|
1769
1801
|
/**
|
|
1770
1802
|
* Enables authentication to Azure Active Directory using a client secret
|
|
1771
1803
|
* that was generated for an App Registration. More information on how
|
|
@@ -1789,7 +1821,7 @@ class ClientSecretCredential {
|
|
|
1789
1821
|
if (!tenantId || !clientId || !clientSecret) {
|
|
1790
1822
|
throw new Error("ClientSecretCredential: tenantId, clientId, and clientSecret are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
|
|
1791
1823
|
}
|
|
1792
|
-
this.msalFlow = new MsalClientSecret(Object.assign(Object.assign({}, options), { logger: logger$
|
|
1824
|
+
this.msalFlow = new MsalClientSecret(Object.assign(Object.assign({}, options), { logger: logger$e,
|
|
1793
1825
|
clientId,
|
|
1794
1826
|
tenantId,
|
|
1795
1827
|
clientSecret, tokenCredentialOptions: options }));
|
|
@@ -1811,7 +1843,7 @@ class ClientSecretCredential {
|
|
|
1811
1843
|
}
|
|
1812
1844
|
|
|
1813
1845
|
// Copyright (c) Microsoft Corporation.
|
|
1814
|
-
const readFileAsync = util.promisify(fs.readFile);
|
|
1846
|
+
const readFileAsync$2 = util.promisify(fs.readFile);
|
|
1815
1847
|
/**
|
|
1816
1848
|
* Tries to asynchronously load a certificate from the given path.
|
|
1817
1849
|
*
|
|
@@ -1823,7 +1855,7 @@ const readFileAsync = util.promisify(fs.readFile);
|
|
|
1823
1855
|
async function parseCertificate(configuration, sendCertificateChain) {
|
|
1824
1856
|
const certificateParts = {};
|
|
1825
1857
|
certificateParts.certificateContents =
|
|
1826
|
-
configuration.certificate || (await readFileAsync(configuration.certificatePath, "utf8"));
|
|
1858
|
+
configuration.certificate || (await readFileAsync$2(configuration.certificatePath, "utf8"));
|
|
1827
1859
|
if (sendCertificateChain) {
|
|
1828
1860
|
certificateParts.x5c = certificateParts.certificateContents;
|
|
1829
1861
|
}
|
|
@@ -1864,7 +1896,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1864
1896
|
this.msalConfig.auth.clientCertificate = {
|
|
1865
1897
|
thumbprint: parts.thumbprint,
|
|
1866
1898
|
privateKey: parts.certificateContents,
|
|
1867
|
-
x5c: parts.x5c
|
|
1899
|
+
x5c: parts.x5c,
|
|
1868
1900
|
};
|
|
1869
1901
|
}
|
|
1870
1902
|
catch (error) {
|
|
@@ -1880,7 +1912,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1880
1912
|
correlationId: options.correlationId,
|
|
1881
1913
|
azureRegion: this.azureRegion,
|
|
1882
1914
|
authority: options.authority,
|
|
1883
|
-
claims: options.claims
|
|
1915
|
+
claims: options.claims,
|
|
1884
1916
|
});
|
|
1885
1917
|
// Even though we're providing the same default in memory persistence cache that we use for DeviceCodeCredential,
|
|
1886
1918
|
// The Client Credential flow does not return the account information from the authentication service,
|
|
@@ -1894,8 +1926,8 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1894
1926
|
}
|
|
1895
1927
|
|
|
1896
1928
|
// Copyright (c) Microsoft Corporation.
|
|
1897
|
-
const credentialName = "ClientCertificateCredential";
|
|
1898
|
-
const logger$
|
|
1929
|
+
const credentialName$2 = "ClientCertificateCredential";
|
|
1930
|
+
const logger$d = credentialLogger(credentialName$2);
|
|
1899
1931
|
/**
|
|
1900
1932
|
* Enables authentication to Azure Active Directory using a PEM-encoded
|
|
1901
1933
|
* certificate that is assigned to an App Registration. More information
|
|
@@ -1907,21 +1939,21 @@ const logger$6 = credentialLogger(credentialName);
|
|
|
1907
1939
|
class ClientCertificateCredential {
|
|
1908
1940
|
constructor(tenantId, clientId, certificatePathOrConfiguration, options = {}) {
|
|
1909
1941
|
if (!tenantId || !clientId) {
|
|
1910
|
-
throw new Error(`${credentialName}: tenantId and clientId are required parameters.`);
|
|
1942
|
+
throw new Error(`${credentialName$2}: tenantId and clientId are required parameters.`);
|
|
1911
1943
|
}
|
|
1912
1944
|
const configuration = Object.assign({}, (typeof certificatePathOrConfiguration === "string"
|
|
1913
1945
|
? {
|
|
1914
|
-
certificatePath: certificatePathOrConfiguration
|
|
1946
|
+
certificatePath: certificatePathOrConfiguration,
|
|
1915
1947
|
}
|
|
1916
1948
|
: certificatePathOrConfiguration));
|
|
1917
1949
|
if (!configuration || !(configuration.certificate || configuration.certificatePath)) {
|
|
1918
|
-
throw new Error(`${credentialName}: Provide either a PEM certificate in string form, or the path to that certificate in the filesystem. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
|
1950
|
+
throw new Error(`${credentialName$2}: Provide either a PEM certificate in string form, or the path to that certificate in the filesystem. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
|
1919
1951
|
}
|
|
1920
1952
|
if (configuration.certificate && configuration.certificatePath) {
|
|
1921
|
-
throw new Error(`${credentialName}: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
|
1953
|
+
throw new Error(`${credentialName$2}: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
|
|
1922
1954
|
}
|
|
1923
1955
|
this.msalFlow = new MsalClientCertificate(Object.assign(Object.assign({}, options), { configuration,
|
|
1924
|
-
logger: logger$
|
|
1956
|
+
logger: logger$d,
|
|
1925
1957
|
clientId,
|
|
1926
1958
|
tenantId, sendCertificateChain: options.sendCertificateChain, tokenCredentialOptions: options }));
|
|
1927
1959
|
}
|
|
@@ -1934,7 +1966,7 @@ class ClientCertificateCredential {
|
|
|
1934
1966
|
* TokenCredential implementation might make.
|
|
1935
1967
|
*/
|
|
1936
1968
|
async getToken(scopes, options = {}) {
|
|
1937
|
-
return trace(`${credentialName}.getToken`, options, async (newOptions) => {
|
|
1969
|
+
return trace(`${credentialName$2}.getToken`, options, async (newOptions) => {
|
|
1938
1970
|
const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
|
|
1939
1971
|
return this.msalFlow.getToken(arrayScopes, newOptions);
|
|
1940
1972
|
});
|
|
@@ -1960,7 +1992,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
1960
1992
|
password: this.password,
|
|
1961
1993
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
1962
1994
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1963
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
1995
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1964
1996
|
};
|
|
1965
1997
|
const result = await this.publicApp.acquireTokenByUsernamePassword(requestOptions);
|
|
1966
1998
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
@@ -1972,7 +2004,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
1972
2004
|
}
|
|
1973
2005
|
|
|
1974
2006
|
// Copyright (c) Microsoft Corporation.
|
|
1975
|
-
const logger$
|
|
2007
|
+
const logger$c = credentialLogger("UsernamePasswordCredential");
|
|
1976
2008
|
/**
|
|
1977
2009
|
* Enables authentication to Azure Active Directory with a user's
|
|
1978
2010
|
* username and password. This credential requires a high degree of
|
|
@@ -1995,7 +2027,7 @@ class UsernamePasswordCredential {
|
|
|
1995
2027
|
if (!tenantId || !clientId || !username || !password) {
|
|
1996
2028
|
throw new Error("UsernamePasswordCredential: tenantId, clientId, username and password are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
|
|
1997
2029
|
}
|
|
1998
|
-
this.msalFlow = new MsalUsernamePassword(Object.assign(Object.assign({}, options), { logger: logger$
|
|
2030
|
+
this.msalFlow = new MsalUsernamePassword(Object.assign(Object.assign({}, options), { logger: logger$c,
|
|
1999
2031
|
clientId,
|
|
2000
2032
|
tenantId,
|
|
2001
2033
|
username,
|
|
@@ -2035,10 +2067,10 @@ const AllSupportedEnvironmentVariables = [
|
|
|
2035
2067
|
"AZURE_CLIENT_SECRET",
|
|
2036
2068
|
"AZURE_CLIENT_CERTIFICATE_PATH",
|
|
2037
2069
|
"AZURE_USERNAME",
|
|
2038
|
-
"AZURE_PASSWORD"
|
|
2070
|
+
"AZURE_PASSWORD",
|
|
2039
2071
|
];
|
|
2040
2072
|
const credentialName$1 = "EnvironmentCredential";
|
|
2041
|
-
const logger$
|
|
2073
|
+
const logger$b = credentialLogger(credentialName$1);
|
|
2042
2074
|
/**
|
|
2043
2075
|
* Enables authentication to Azure Active Directory using client secret
|
|
2044
2076
|
* details configured in environment variables
|
|
@@ -2068,26 +2100,26 @@ class EnvironmentCredential {
|
|
|
2068
2100
|
// Keep track of any missing environment variables for error details
|
|
2069
2101
|
this._credential = undefined;
|
|
2070
2102
|
const assigned = processEnvVars(AllSupportedEnvironmentVariables).assigned.join(", ");
|
|
2071
|
-
logger$
|
|
2103
|
+
logger$b.info(`Found the following environment variables: ${assigned}`);
|
|
2072
2104
|
const tenantId = process.env.AZURE_TENANT_ID, clientId = process.env.AZURE_CLIENT_ID, clientSecret = process.env.AZURE_CLIENT_SECRET;
|
|
2073
2105
|
if (tenantId) {
|
|
2074
|
-
checkTenantId(logger$
|
|
2106
|
+
checkTenantId(logger$b, tenantId);
|
|
2075
2107
|
}
|
|
2076
2108
|
if (tenantId && clientId && clientSecret) {
|
|
2077
|
-
logger$
|
|
2109
|
+
logger$b.info(`Invoking ClientSecretCredential with tenant ID: ${tenantId}, clientId: ${clientId} and clientSecret: [REDACTED]`);
|
|
2078
2110
|
this._credential = new ClientSecretCredential(tenantId, clientId, clientSecret, options);
|
|
2079
2111
|
return;
|
|
2080
2112
|
}
|
|
2081
2113
|
const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;
|
|
2082
2114
|
if (tenantId && clientId && certificatePath) {
|
|
2083
|
-
logger$
|
|
2115
|
+
logger$b.info(`Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`);
|
|
2084
2116
|
this._credential = new ClientCertificateCredential(tenantId, clientId, { certificatePath }, options);
|
|
2085
2117
|
return;
|
|
2086
2118
|
}
|
|
2087
2119
|
const username = process.env.AZURE_USERNAME;
|
|
2088
2120
|
const password = process.env.AZURE_PASSWORD;
|
|
2089
2121
|
if (tenantId && clientId && username && password) {
|
|
2090
|
-
logger$
|
|
2122
|
+
logger$b.info(`Invoking UsernamePasswordCredential with tenant ID: ${tenantId}, clientId: ${clientId} and username: ${username}`);
|
|
2091
2123
|
this._credential = new UsernamePasswordCredential(tenantId, clientId, username, password, options);
|
|
2092
2124
|
}
|
|
2093
2125
|
}
|
|
@@ -2102,18 +2134,15 @@ class EnvironmentCredential {
|
|
|
2102
2134
|
if (this._credential) {
|
|
2103
2135
|
try {
|
|
2104
2136
|
const result = await this._credential.getToken(scopes, newOptions);
|
|
2105
|
-
logger$
|
|
2137
|
+
logger$b.getToken.info(formatSuccess(scopes));
|
|
2106
2138
|
return result;
|
|
2107
2139
|
}
|
|
2108
2140
|
catch (err) {
|
|
2109
2141
|
const authenticationError = new AuthenticationError(400, {
|
|
2110
2142
|
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("")
|
|
2143
|
+
error_description: err.message.toString().split("More details:").join(""),
|
|
2115
2144
|
});
|
|
2116
|
-
logger$
|
|
2145
|
+
logger$b.getToken.info(formatError(scopes, authenticationError));
|
|
2117
2146
|
throw authenticationError;
|
|
2118
2147
|
}
|
|
2119
2148
|
}
|
|
@@ -2159,26 +2188,26 @@ function mapScopesToResource(scopes) {
|
|
|
2159
2188
|
}
|
|
2160
2189
|
|
|
2161
2190
|
// Copyright (c) Microsoft Corporation.
|
|
2162
|
-
const msiName = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
2163
|
-
const logger$
|
|
2191
|
+
const msiName$5 = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
2192
|
+
const logger$a = credentialLogger(msiName$5);
|
|
2164
2193
|
/**
|
|
2165
2194
|
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2166
2195
|
*/
|
|
2167
|
-
function expiresOnParser(requestBody) {
|
|
2196
|
+
function expiresOnParser$2(requestBody) {
|
|
2168
2197
|
// App Service always returns string expires_on values.
|
|
2169
2198
|
return Date.parse(requestBody.expires_on);
|
|
2170
2199
|
}
|
|
2171
2200
|
/**
|
|
2172
2201
|
* Generates the options used on the request for an access token.
|
|
2173
2202
|
*/
|
|
2174
|
-
function prepareRequestOptions(scopes, clientId) {
|
|
2203
|
+
function prepareRequestOptions$5(scopes, clientId) {
|
|
2175
2204
|
const resource = mapScopesToResource(scopes);
|
|
2176
2205
|
if (!resource) {
|
|
2177
|
-
throw new Error(`${msiName}: Multiple scopes are not supported.`);
|
|
2206
|
+
throw new Error(`${msiName$5}: Multiple scopes are not supported.`);
|
|
2178
2207
|
}
|
|
2179
2208
|
const queryParameters = {
|
|
2180
2209
|
resource,
|
|
2181
|
-
"api-version": "2017-09-01"
|
|
2210
|
+
"api-version": "2017-09-01",
|
|
2182
2211
|
};
|
|
2183
2212
|
if (clientId) {
|
|
2184
2213
|
queryParameters.clientid = clientId;
|
|
@@ -2186,18 +2215,18 @@ function prepareRequestOptions(scopes, clientId) {
|
|
|
2186
2215
|
const query = new URLSearchParams(queryParameters);
|
|
2187
2216
|
// This error should not bubble up, since we verify that this environment variable is defined in the isAvailable() method defined below.
|
|
2188
2217
|
if (!process.env.MSI_ENDPOINT) {
|
|
2189
|
-
throw new Error(`${msiName}: Missing environment variable: MSI_ENDPOINT`);
|
|
2218
|
+
throw new Error(`${msiName$5}: Missing environment variable: MSI_ENDPOINT`);
|
|
2190
2219
|
}
|
|
2191
2220
|
if (!process.env.MSI_SECRET) {
|
|
2192
|
-
throw new Error(`${msiName}: Missing environment variable: MSI_SECRET`);
|
|
2221
|
+
throw new Error(`${msiName$5}: Missing environment variable: MSI_SECRET`);
|
|
2193
2222
|
}
|
|
2194
2223
|
return {
|
|
2195
2224
|
url: `${process.env.MSI_ENDPOINT}?${query.toString()}`,
|
|
2196
2225
|
method: "GET",
|
|
2197
2226
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2198
2227
|
Accept: "application/json",
|
|
2199
|
-
secret: process.env.MSI_SECRET
|
|
2200
|
-
})
|
|
2228
|
+
secret: process.env.MSI_SECRET,
|
|
2229
|
+
}),
|
|
2201
2230
|
};
|
|
2202
2231
|
}
|
|
2203
2232
|
/**
|
|
@@ -2207,47 +2236,47 @@ const appServiceMsi2017 = {
|
|
|
2207
2236
|
async isAvailable(scopes) {
|
|
2208
2237
|
const resource = mapScopesToResource(scopes);
|
|
2209
2238
|
if (!resource) {
|
|
2210
|
-
logger$
|
|
2239
|
+
logger$a.info(`${msiName$5}: Unavailable. Multiple scopes are not supported.`);
|
|
2211
2240
|
return false;
|
|
2212
2241
|
}
|
|
2213
2242
|
const env = process.env;
|
|
2214
2243
|
const result = Boolean(env.MSI_ENDPOINT && env.MSI_SECRET);
|
|
2215
2244
|
if (!result) {
|
|
2216
|
-
logger$
|
|
2245
|
+
logger$a.info(`${msiName$5}: Unavailable. The environment variables needed are: MSI_ENDPOINT and MSI_SECRET.`);
|
|
2217
2246
|
}
|
|
2218
2247
|
return result;
|
|
2219
2248
|
},
|
|
2220
2249
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2221
2250
|
const { identityClient, scopes, clientId } = configuration;
|
|
2222
|
-
logger$
|
|
2223
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions(scopes, clientId)), {
|
|
2251
|
+
logger$a.info(`${msiName$5}: Using the endpoint and the secret coming form the environment variables: MSI_ENDPOINT=${process.env.MSI_ENDPOINT} and MSI_SECRET=[REDACTED].`);
|
|
2252
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$5(scopes, clientId)), {
|
|
2224
2253
|
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2225
2254
|
allowInsecureConnection: true }));
|
|
2226
|
-
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser);
|
|
2255
|
+
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser$2);
|
|
2227
2256
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2228
|
-
}
|
|
2257
|
+
},
|
|
2229
2258
|
};
|
|
2230
2259
|
|
|
2231
2260
|
// Copyright (c) Microsoft Corporation.
|
|
2232
|
-
const msiName$
|
|
2233
|
-
const logger$
|
|
2261
|
+
const msiName$4 = "ManagedIdentityCredential - CloudShellMSI";
|
|
2262
|
+
const logger$9 = credentialLogger(msiName$4);
|
|
2234
2263
|
/**
|
|
2235
2264
|
* Generates the options used on the request for an access token.
|
|
2236
2265
|
*/
|
|
2237
|
-
function prepareRequestOptions$
|
|
2266
|
+
function prepareRequestOptions$4(scopes, clientId) {
|
|
2238
2267
|
const resource = mapScopesToResource(scopes);
|
|
2239
2268
|
if (!resource) {
|
|
2240
|
-
throw new Error(`${msiName$
|
|
2269
|
+
throw new Error(`${msiName$4}: Multiple scopes are not supported.`);
|
|
2241
2270
|
}
|
|
2242
2271
|
const body = {
|
|
2243
|
-
resource
|
|
2272
|
+
resource,
|
|
2244
2273
|
};
|
|
2245
2274
|
if (clientId) {
|
|
2246
2275
|
body.client_id = clientId;
|
|
2247
2276
|
}
|
|
2248
2277
|
// This error should not bubble up, since we verify that this environment variable is defined in the isAvailable() method defined below.
|
|
2249
2278
|
if (!process.env.MSI_ENDPOINT) {
|
|
2250
|
-
throw new Error(`${msiName$
|
|
2279
|
+
throw new Error(`${msiName$4}: Missing environment variable: MSI_ENDPOINT`);
|
|
2251
2280
|
}
|
|
2252
2281
|
const params = new URLSearchParams(body);
|
|
2253
2282
|
return {
|
|
@@ -2257,8 +2286,8 @@ function prepareRequestOptions$1(scopes, clientId) {
|
|
|
2257
2286
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2258
2287
|
Accept: "application/json",
|
|
2259
2288
|
Metadata: "true",
|
|
2260
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
2261
|
-
})
|
|
2289
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
2290
|
+
}),
|
|
2262
2291
|
};
|
|
2263
2292
|
}
|
|
2264
2293
|
/**
|
|
@@ -2268,29 +2297,29 @@ const cloudShellMsi = {
|
|
|
2268
2297
|
async isAvailable(scopes) {
|
|
2269
2298
|
const resource = mapScopesToResource(scopes);
|
|
2270
2299
|
if (!resource) {
|
|
2271
|
-
logger$
|
|
2300
|
+
logger$9.info(`${msiName$4}: Unavailable. Multiple scopes are not supported.`);
|
|
2272
2301
|
return false;
|
|
2273
2302
|
}
|
|
2274
2303
|
const result = Boolean(process.env.MSI_ENDPOINT);
|
|
2275
2304
|
if (!result) {
|
|
2276
|
-
logger$
|
|
2305
|
+
logger$9.info(`${msiName$4}: Unavailable. The environment variable MSI_ENDPOINT is needed.`);
|
|
2277
2306
|
}
|
|
2278
2307
|
return result;
|
|
2279
2308
|
},
|
|
2280
2309
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2281
2310
|
const { identityClient, scopes, clientId } = configuration;
|
|
2282
|
-
logger$
|
|
2283
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$
|
|
2311
|
+
logger$9.info(`${msiName$4}: Using the endpoint coming form the environment variable MSI_ENDPOINT = ${process.env.MSI_ENDPOINT}.`);
|
|
2312
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$4(scopes, clientId)), {
|
|
2284
2313
|
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2285
2314
|
allowInsecureConnection: true }));
|
|
2286
2315
|
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2287
2316
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2288
|
-
}
|
|
2317
|
+
},
|
|
2289
2318
|
};
|
|
2290
2319
|
|
|
2291
2320
|
// Copyright (c) Microsoft Corporation.
|
|
2292
|
-
const msiName$
|
|
2293
|
-
const logger$
|
|
2321
|
+
const msiName$3 = "ManagedIdentityCredential - IMDS";
|
|
2322
|
+
const logger$8 = credentialLogger(msiName$3);
|
|
2294
2323
|
/**
|
|
2295
2324
|
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2296
2325
|
*/
|
|
@@ -2298,24 +2327,24 @@ function expiresOnParser$1(requestBody) {
|
|
|
2298
2327
|
if (requestBody.expires_on) {
|
|
2299
2328
|
// Use the expires_on timestamp if it's available
|
|
2300
2329
|
const expires = +requestBody.expires_on * 1000;
|
|
2301
|
-
logger$
|
|
2330
|
+
logger$8.info(`${msiName$3}: Using expires_on: ${expires} (original value: ${requestBody.expires_on})`);
|
|
2302
2331
|
return expires;
|
|
2303
2332
|
}
|
|
2304
2333
|
else {
|
|
2305
2334
|
// If these aren't possible, use expires_in and calculate a timestamp
|
|
2306
2335
|
const expires = Date.now() + requestBody.expires_in * 1000;
|
|
2307
|
-
logger$
|
|
2336
|
+
logger$8.info(`${msiName$3}: IMDS using expires_in: ${expires} (original value: ${requestBody.expires_in})`);
|
|
2308
2337
|
return expires;
|
|
2309
2338
|
}
|
|
2310
2339
|
}
|
|
2311
2340
|
/**
|
|
2312
2341
|
* Generates the options used on the request for an access token.
|
|
2313
2342
|
*/
|
|
2314
|
-
function prepareRequestOptions$
|
|
2343
|
+
function prepareRequestOptions$3(scopes, clientId, options) {
|
|
2315
2344
|
var _a;
|
|
2316
2345
|
const resource = mapScopesToResource(scopes);
|
|
2317
2346
|
if (!resource) {
|
|
2318
|
-
throw new Error(`${msiName$
|
|
2347
|
+
throw new Error(`${msiName$3}: Multiple scopes are not supported.`);
|
|
2319
2348
|
}
|
|
2320
2349
|
const { skipQuery, skipMetadataHeader } = options || {};
|
|
2321
2350
|
let query = "";
|
|
@@ -2324,7 +2353,7 @@ function prepareRequestOptions$2(scopes, clientId, options) {
|
|
|
2324
2353
|
if (!skipQuery) {
|
|
2325
2354
|
const queryParameters = {
|
|
2326
2355
|
resource,
|
|
2327
|
-
"api-version": imdsApiVersion
|
|
2356
|
+
"api-version": imdsApiVersion,
|
|
2328
2357
|
};
|
|
2329
2358
|
if (clientId) {
|
|
2330
2359
|
queryParameters.client_id = clientId;
|
|
@@ -2335,7 +2364,7 @@ function prepareRequestOptions$2(scopes, clientId, options) {
|
|
|
2335
2364
|
const url = new URL(imdsEndpointPath, (_a = process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) !== null && _a !== void 0 ? _a : imdsHost);
|
|
2336
2365
|
const rawHeaders = {
|
|
2337
2366
|
Accept: "application/json",
|
|
2338
|
-
Metadata: "true"
|
|
2367
|
+
Metadata: "true",
|
|
2339
2368
|
};
|
|
2340
2369
|
// Remove the Metadata header to invoke a request error from some IMDS endpoints.
|
|
2341
2370
|
if (skipMetadataHeader) {
|
|
@@ -2345,14 +2374,14 @@ function prepareRequestOptions$2(scopes, clientId, options) {
|
|
|
2345
2374
|
// In this case, the `?` should be added in the "query" variable `skipQuery` is not set.
|
|
2346
2375
|
url: `${url}${query}`,
|
|
2347
2376
|
method: "GET",
|
|
2348
|
-
headers: coreRestPipeline.createHttpHeaders(rawHeaders)
|
|
2377
|
+
headers: coreRestPipeline.createHttpHeaders(rawHeaders),
|
|
2349
2378
|
};
|
|
2350
2379
|
}
|
|
2351
2380
|
// 800ms -> 1600ms -> 3200ms
|
|
2352
2381
|
const imdsMsiRetryConfig = {
|
|
2353
2382
|
maxRetries: 3,
|
|
2354
2383
|
startDelayInMs: 800,
|
|
2355
|
-
intervalIncrement: 2
|
|
2384
|
+
intervalIncrement: 2,
|
|
2356
2385
|
};
|
|
2357
2386
|
/**
|
|
2358
2387
|
* Defines how to determine whether the Azure IMDS MSI is available, and also how to retrieve a token from the Azure IMDS MSI.
|
|
@@ -2362,7 +2391,7 @@ const imdsMsi = {
|
|
|
2362
2391
|
var _a, _b;
|
|
2363
2392
|
const resource = mapScopesToResource(scopes);
|
|
2364
2393
|
if (!resource) {
|
|
2365
|
-
logger$
|
|
2394
|
+
logger$8.info(`${msiName$3}: Unavailable. Multiple scopes are not supported.`);
|
|
2366
2395
|
return false;
|
|
2367
2396
|
}
|
|
2368
2397
|
const { span, updatedOptions: options } = createSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions);
|
|
@@ -2370,9 +2399,9 @@ const imdsMsi = {
|
|
|
2370
2399
|
if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
|
|
2371
2400
|
return true;
|
|
2372
2401
|
}
|
|
2373
|
-
const requestOptions = prepareRequestOptions$
|
|
2402
|
+
const requestOptions = prepareRequestOptions$3(resource, clientId, {
|
|
2374
2403
|
skipMetadataHeader: true,
|
|
2375
|
-
skipQuery: true
|
|
2404
|
+
skipQuery: true,
|
|
2376
2405
|
});
|
|
2377
2406
|
requestOptions.tracingOptions = options.tracingOptions;
|
|
2378
2407
|
try {
|
|
@@ -2384,7 +2413,7 @@ const imdsMsi = {
|
|
|
2384
2413
|
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
2385
2414
|
request.allowInsecureConnection = true;
|
|
2386
2415
|
try {
|
|
2387
|
-
logger$
|
|
2416
|
+
logger$8.info(`${msiName$3}: Pinging the Azure IMDS endpoint`);
|
|
2388
2417
|
await identityClient.sendRequest(request);
|
|
2389
2418
|
}
|
|
2390
2419
|
catch (err) {
|
|
@@ -2396,25 +2425,25 @@ const imdsMsi = {
|
|
|
2396
2425
|
) {
|
|
2397
2426
|
// If the request failed, or Node.js was unable to establish a connection,
|
|
2398
2427
|
// or the host was down, we'll assume the IMDS endpoint isn't available.
|
|
2399
|
-
logger$
|
|
2428
|
+
logger$8.info(`${msiName$3}: The Azure IMDS endpoint is unavailable`);
|
|
2400
2429
|
span.setStatus({
|
|
2401
2430
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2402
|
-
message: err.message
|
|
2431
|
+
message: err.message,
|
|
2403
2432
|
});
|
|
2404
2433
|
return false;
|
|
2405
2434
|
}
|
|
2406
2435
|
}
|
|
2407
2436
|
// If we received any response, the endpoint is available
|
|
2408
|
-
logger$
|
|
2437
|
+
logger$8.info(`${msiName$3}: The Azure IMDS endpoint is available`);
|
|
2409
2438
|
return true;
|
|
2410
2439
|
}
|
|
2411
2440
|
catch (err) {
|
|
2412
2441
|
// createWebResource failed.
|
|
2413
2442
|
// This error should bubble up to the user.
|
|
2414
|
-
logger$
|
|
2443
|
+
logger$8.info(`${msiName$3}: Error when creating the WebResource for the Azure IMDS endpoint: ${err.message}`);
|
|
2415
2444
|
span.setStatus({
|
|
2416
2445
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2417
|
-
message: err.message
|
|
2446
|
+
message: err.message,
|
|
2418
2447
|
});
|
|
2419
2448
|
throw err;
|
|
2420
2449
|
}
|
|
@@ -2424,11 +2453,11 @@ const imdsMsi = {
|
|
|
2424
2453
|
},
|
|
2425
2454
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2426
2455
|
const { identityClient, scopes, clientId } = configuration;
|
|
2427
|
-
logger$
|
|
2456
|
+
logger$8.info(`${msiName$3}: Using the Azure IMDS endpoint coming from the environment variable MSI_ENDPOINT=${process.env.MSI_ENDPOINT}, and using the cloud shell to proceed with the authentication.`);
|
|
2428
2457
|
let nextDelayInMs = imdsMsiRetryConfig.startDelayInMs;
|
|
2429
2458
|
for (let retries = 0; retries < imdsMsiRetryConfig.maxRetries; retries++) {
|
|
2430
2459
|
try {
|
|
2431
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$
|
|
2460
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$3(scopes, clientId)), { allowInsecureConnection: true }));
|
|
2432
2461
|
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser$1);
|
|
2433
2462
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2434
2463
|
}
|
|
@@ -2441,29 +2470,29 @@ const imdsMsi = {
|
|
|
2441
2470
|
throw error;
|
|
2442
2471
|
}
|
|
2443
2472
|
}
|
|
2444
|
-
throw new AuthenticationError(404, `${msiName$
|
|
2445
|
-
}
|
|
2473
|
+
throw new AuthenticationError(404, `${msiName$3}: Failed to retrieve IMDS token after ${imdsMsiRetryConfig.maxRetries} retries.`);
|
|
2474
|
+
},
|
|
2446
2475
|
};
|
|
2447
2476
|
|
|
2448
2477
|
// Copyright (c) Microsoft Corporation.
|
|
2449
|
-
const msiName$
|
|
2450
|
-
const logger$
|
|
2478
|
+
const msiName$2 = "ManagedIdentityCredential - Azure Arc MSI";
|
|
2479
|
+
const logger$7 = credentialLogger(msiName$2);
|
|
2451
2480
|
/**
|
|
2452
2481
|
* Generates the options used on the request for an access token.
|
|
2453
2482
|
*/
|
|
2454
|
-
function prepareRequestOptions$
|
|
2483
|
+
function prepareRequestOptions$2(scopes) {
|
|
2455
2484
|
const resource = mapScopesToResource(scopes);
|
|
2456
2485
|
if (!resource) {
|
|
2457
|
-
throw new Error(`${msiName$
|
|
2486
|
+
throw new Error(`${msiName$2}: Multiple scopes are not supported.`);
|
|
2458
2487
|
}
|
|
2459
2488
|
const queryParameters = {
|
|
2460
2489
|
resource,
|
|
2461
|
-
"api-version": azureArcAPIVersion
|
|
2490
|
+
"api-version": azureArcAPIVersion,
|
|
2462
2491
|
};
|
|
2463
2492
|
const query = new URLSearchParams(queryParameters);
|
|
2464
2493
|
// This error should not bubble up, since we verify that this environment variable is defined in the isAvailable() method defined below.
|
|
2465
2494
|
if (!process.env.IDENTITY_ENDPOINT) {
|
|
2466
|
-
throw new Error(`${msiName$
|
|
2495
|
+
throw new Error(`${msiName$2}: Missing environment variable: IDENTITY_ENDPOINT`);
|
|
2467
2496
|
}
|
|
2468
2497
|
return coreRestPipeline.createPipelineRequest({
|
|
2469
2498
|
// Should be similar to: http://localhost:40342/metadata/identity/oauth2/token
|
|
@@ -2471,8 +2500,8 @@ function prepareRequestOptions$3(scopes) {
|
|
|
2471
2500
|
method: "GET",
|
|
2472
2501
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2473
2502
|
Accept: "application/json",
|
|
2474
|
-
Metadata: "true"
|
|
2475
|
-
})
|
|
2503
|
+
Metadata: "true",
|
|
2504
|
+
}),
|
|
2476
2505
|
});
|
|
2477
2506
|
}
|
|
2478
2507
|
/**
|
|
@@ -2497,7 +2526,7 @@ async function filePathRequest(identityClient, requestPrepareOptions) {
|
|
|
2497
2526
|
if (response.bodyAsText) {
|
|
2498
2527
|
message = ` Response: ${response.bodyAsText}`;
|
|
2499
2528
|
}
|
|
2500
|
-
throw new AuthenticationError(response.status, `${msiName$
|
|
2529
|
+
throw new AuthenticationError(response.status, `${msiName$2}: To authenticate with Azure Arc MSI, status code 401 is expected on the first request. ${message}`);
|
|
2501
2530
|
}
|
|
2502
2531
|
const authHeader = response.headers.get("www-authenticate") || "";
|
|
2503
2532
|
try {
|
|
@@ -2514,26 +2543,26 @@ const arcMsi = {
|
|
|
2514
2543
|
async isAvailable(scopes) {
|
|
2515
2544
|
const resource = mapScopesToResource(scopes);
|
|
2516
2545
|
if (!resource) {
|
|
2517
|
-
logger$
|
|
2546
|
+
logger$7.info(`${msiName$2}: Unavailable. Multiple scopes are not supported.`);
|
|
2518
2547
|
return false;
|
|
2519
2548
|
}
|
|
2520
2549
|
const result = Boolean(process.env.IMDS_ENDPOINT && process.env.IDENTITY_ENDPOINT);
|
|
2521
2550
|
if (!result) {
|
|
2522
|
-
logger$
|
|
2551
|
+
logger$7.info(`${msiName$2}: The environment variables needed are: IMDS_ENDPOINT and IDENTITY_ENDPOINT`);
|
|
2523
2552
|
}
|
|
2524
2553
|
return result;
|
|
2525
2554
|
},
|
|
2526
2555
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2527
2556
|
var _a;
|
|
2528
2557
|
const { identityClient, scopes, clientId } = configuration;
|
|
2529
|
-
logger$
|
|
2558
|
+
logger$7.info(`${msiName$2}: Authenticating.`);
|
|
2530
2559
|
if (clientId) {
|
|
2531
|
-
throw new Error(`${msiName$
|
|
2560
|
+
throw new Error(`${msiName$2}: User assigned identity is not supported by the Azure Arc Managed Identity Endpoint. To authenticate with the system assigned identity, omit the client id when constructing the ManagedIdentityCredential, or if authenticating with the DefaultAzureCredential ensure the AZURE_CLIENT_ID environment variable is not set.`);
|
|
2532
2561
|
}
|
|
2533
|
-
const requestOptions = Object.assign(Object.assign({ disableJsonStringifyOnBody: true, deserializationMapper: undefined, abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$
|
|
2562
|
+
const requestOptions = Object.assign(Object.assign({ disableJsonStringifyOnBody: true, deserializationMapper: undefined, abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$2(scopes)), { allowInsecureConnection: true });
|
|
2534
2563
|
const filePath = await filePathRequest(identityClient, requestOptions);
|
|
2535
2564
|
if (!filePath) {
|
|
2536
|
-
throw new Error(`${msiName$
|
|
2565
|
+
throw new Error(`${msiName$2}: Failed to find the token file.`);
|
|
2537
2566
|
}
|
|
2538
2567
|
const key = await readFileAsync$1(filePath, { encoding: "utf-8" });
|
|
2539
2568
|
(_a = requestOptions.headers) === null || _a === void 0 ? void 0 : _a.set("Authorization", `Basic ${key}`);
|
|
@@ -2542,24 +2571,24 @@ const arcMsi = {
|
|
|
2542
2571
|
allowInsecureConnection: true }));
|
|
2543
2572
|
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2544
2573
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2545
|
-
}
|
|
2574
|
+
},
|
|
2546
2575
|
};
|
|
2547
2576
|
|
|
2548
2577
|
// Copyright (c) Microsoft Corporation.
|
|
2549
|
-
const msiName$
|
|
2550
|
-
const logger$
|
|
2551
|
-
const readFileAsync
|
|
2578
|
+
const msiName$1 = "ManagedIdentityCredential - Token Exchange";
|
|
2579
|
+
const logger$6 = credentialLogger(msiName$1);
|
|
2580
|
+
const readFileAsync = util.promisify(fs__default["default"].readFile);
|
|
2552
2581
|
/**
|
|
2553
2582
|
* Generates the options used on the request for an access token.
|
|
2554
2583
|
*/
|
|
2555
|
-
function prepareRequestOptions$
|
|
2584
|
+
function prepareRequestOptions$1(scopes, clientAssertion, clientId) {
|
|
2556
2585
|
var _a;
|
|
2557
2586
|
const bodyParams = {
|
|
2558
2587
|
scope: Array.isArray(scopes) ? scopes.join(" ") : scopes,
|
|
2559
2588
|
client_assertion: clientAssertion,
|
|
2560
2589
|
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
2561
2590
|
client_id: clientId,
|
|
2562
|
-
grant_type: "client_credentials"
|
|
2591
|
+
grant_type: "client_credentials",
|
|
2563
2592
|
};
|
|
2564
2593
|
const urlParams = new URLSearchParams(bodyParams);
|
|
2565
2594
|
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 +2597,8 @@ function prepareRequestOptions$4(scopes, clientAssertion, clientId) {
|
|
|
2568
2597
|
method: "POST",
|
|
2569
2598
|
body: urlParams.toString(),
|
|
2570
2599
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2571
|
-
Accept: "application/json"
|
|
2572
|
-
})
|
|
2600
|
+
Accept: "application/json",
|
|
2601
|
+
}),
|
|
2573
2602
|
};
|
|
2574
2603
|
}
|
|
2575
2604
|
/**
|
|
@@ -2586,7 +2615,7 @@ function tokenExchangeMsi() {
|
|
|
2586
2615
|
azureFederatedTokenFileContent = undefined;
|
|
2587
2616
|
}
|
|
2588
2617
|
if (!azureFederatedTokenFileContent) {
|
|
2589
|
-
const file = await readFileAsync
|
|
2618
|
+
const file = await readFileAsync(azureFederatedTokenFilePath, "utf8");
|
|
2590
2619
|
const value = file.trim();
|
|
2591
2620
|
if (!value) {
|
|
2592
2621
|
throw new Error(`No content on the file ${azureFederatedTokenFilePath}, indicated by the environment variable AZURE_FEDERATED_TOKEN_FILE`);
|
|
@@ -2603,26 +2632,26 @@ function tokenExchangeMsi() {
|
|
|
2603
2632
|
const env = process.env;
|
|
2604
2633
|
const result = Boolean((clientId || env.AZURE_CLIENT_ID) && env.AZURE_TENANT_ID && azureFederatedTokenFilePath);
|
|
2605
2634
|
if (!result) {
|
|
2606
|
-
logger$
|
|
2635
|
+
logger$6.info(`${msiName$1}: Unavailable. The environment variables needed are: AZURE_CLIENT_ID (or the client ID sent through the parameters), AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE`);
|
|
2607
2636
|
}
|
|
2608
2637
|
return result;
|
|
2609
2638
|
},
|
|
2610
2639
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2611
2640
|
const { identityClient, scopes, clientId } = configuration;
|
|
2612
|
-
logger$
|
|
2641
|
+
logger$6.info(`${msiName$1}: Using the client assertion coming from environment variables.`);
|
|
2613
2642
|
let assertion;
|
|
2614
2643
|
try {
|
|
2615
2644
|
assertion = await readAssertion();
|
|
2616
2645
|
}
|
|
2617
2646
|
catch (err) {
|
|
2618
|
-
throw new Error(`${msiName$
|
|
2647
|
+
throw new Error(`${msiName$1}: Failed to read ${azureFederatedTokenFilePath}, indicated by the environment variable AZURE_FEDERATED_TOKEN_FILE`);
|
|
2619
2648
|
}
|
|
2620
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$
|
|
2649
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$1(scopes, assertion, clientId || process.env.AZURE_CLIENT_ID)), {
|
|
2621
2650
|
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2622
2651
|
allowInsecureConnection: true }));
|
|
2623
2652
|
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2624
2653
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2625
|
-
}
|
|
2654
|
+
},
|
|
2626
2655
|
};
|
|
2627
2656
|
}
|
|
2628
2657
|
|
|
@@ -2637,26 +2666,26 @@ function tokenExchangeMsi() {
|
|
|
2637
2666
|
//
|
|
2638
2667
|
// curl --insecure $IDENTITY_ENDPOINT'?api-version=2019-07-01-preview&resource=https://vault.azure.net/' -H "Secret: $IDENTITY_HEADER"
|
|
2639
2668
|
//
|
|
2640
|
-
const msiName
|
|
2641
|
-
const logger$
|
|
2669
|
+
const msiName = "ManagedIdentityCredential - Fabric MSI";
|
|
2670
|
+
const logger$5 = credentialLogger(msiName);
|
|
2642
2671
|
/**
|
|
2643
2672
|
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2644
2673
|
*/
|
|
2645
|
-
function expiresOnParser
|
|
2674
|
+
function expiresOnParser(requestBody) {
|
|
2646
2675
|
// Parses a string representation of the milliseconds since epoch into a number value
|
|
2647
2676
|
return Number(requestBody.expires_on);
|
|
2648
2677
|
}
|
|
2649
2678
|
/**
|
|
2650
2679
|
* Generates the options used on the request for an access token.
|
|
2651
2680
|
*/
|
|
2652
|
-
function prepareRequestOptions
|
|
2681
|
+
function prepareRequestOptions(scopes, clientId) {
|
|
2653
2682
|
const resource = mapScopesToResource(scopes);
|
|
2654
2683
|
if (!resource) {
|
|
2655
|
-
throw new Error(`${msiName
|
|
2684
|
+
throw new Error(`${msiName}: Multiple scopes are not supported.`);
|
|
2656
2685
|
}
|
|
2657
2686
|
const queryParameters = {
|
|
2658
2687
|
resource,
|
|
2659
|
-
"api-version": azureFabricVersion
|
|
2688
|
+
"api-version": azureFabricVersion,
|
|
2660
2689
|
};
|
|
2661
2690
|
if (clientId) {
|
|
2662
2691
|
queryParameters.client_id = clientId;
|
|
@@ -2674,8 +2703,8 @@ function prepareRequestOptions$5(scopes, clientId) {
|
|
|
2674
2703
|
method: "GET",
|
|
2675
2704
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2676
2705
|
Accept: "application/json",
|
|
2677
|
-
secret: process.env.IDENTITY_HEADER
|
|
2678
|
-
})
|
|
2706
|
+
secret: process.env.IDENTITY_HEADER,
|
|
2707
|
+
}),
|
|
2679
2708
|
};
|
|
2680
2709
|
}
|
|
2681
2710
|
/**
|
|
@@ -2685,41 +2714,38 @@ const fabricMsi = {
|
|
|
2685
2714
|
async isAvailable(scopes) {
|
|
2686
2715
|
const resource = mapScopesToResource(scopes);
|
|
2687
2716
|
if (!resource) {
|
|
2688
|
-
logger$
|
|
2717
|
+
logger$5.info(`${msiName}: Unavailable. Multiple scopes are not supported.`);
|
|
2689
2718
|
return false;
|
|
2690
2719
|
}
|
|
2691
2720
|
const env = process.env;
|
|
2692
2721
|
const result = Boolean(env.IDENTITY_ENDPOINT && env.IDENTITY_HEADER && env.IDENTITY_SERVER_THUMBPRINT);
|
|
2693
2722
|
if (!result) {
|
|
2694
|
-
logger$
|
|
2723
|
+
logger$5.info(`${msiName}: Unavailable. The environment variables needed are: IDENTITY_ENDPOINT, IDENTITY_HEADER and IDENTITY_SERVER_THUMBPRINT`);
|
|
2695
2724
|
}
|
|
2696
2725
|
return result;
|
|
2697
2726
|
},
|
|
2698
2727
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2699
2728
|
const { scopes, identityClient, clientId } = configuration;
|
|
2700
|
-
logger$
|
|
2701
|
-
`${msiName
|
|
2729
|
+
logger$5.info([
|
|
2730
|
+
`${msiName}:`,
|
|
2702
2731
|
"Using the endpoint and the secret coming from the environment variables:",
|
|
2703
2732
|
`IDENTITY_ENDPOINT=${process.env.IDENTITY_ENDPOINT},`,
|
|
2704
2733
|
"IDENTITY_HEADER=[REDACTED] and",
|
|
2705
|
-
"IDENTITY_SERVER_THUMBPRINT=[REDACTED]."
|
|
2734
|
+
"IDENTITY_SERVER_THUMBPRINT=[REDACTED].",
|
|
2706
2735
|
].join(" "));
|
|
2707
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions
|
|
2708
|
-
|
|
2709
|
-
// allowInsecureConnection: true
|
|
2710
|
-
));
|
|
2711
|
-
request.agent = new https.Agent({
|
|
2736
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions(scopes, clientId)));
|
|
2737
|
+
request.agent = new https__default["default"].Agent({
|
|
2712
2738
|
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
2713
2739
|
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
2714
|
-
rejectUnauthorized: false
|
|
2740
|
+
rejectUnauthorized: false,
|
|
2715
2741
|
});
|
|
2716
|
-
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser
|
|
2742
|
+
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser);
|
|
2717
2743
|
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2718
|
-
}
|
|
2744
|
+
},
|
|
2719
2745
|
};
|
|
2720
2746
|
|
|
2721
2747
|
// Copyright (c) Microsoft Corporation.
|
|
2722
|
-
const logger$
|
|
2748
|
+
const logger$4 = credentialLogger("ManagedIdentityCredential");
|
|
2723
2749
|
/**
|
|
2724
2750
|
* Attempts authentication using a managed identity available at the deployment environment.
|
|
2725
2751
|
* This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
|
|
@@ -2766,13 +2792,13 @@ class ManagedIdentityCredential {
|
|
|
2766
2792
|
return availableMSI.getToken({
|
|
2767
2793
|
identityClient: this.identityClient,
|
|
2768
2794
|
scopes,
|
|
2769
|
-
clientId
|
|
2795
|
+
clientId,
|
|
2770
2796
|
}, updatedOptions);
|
|
2771
2797
|
}
|
|
2772
2798
|
catch (err) {
|
|
2773
2799
|
span.setStatus({
|
|
2774
2800
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2775
|
-
message: err.message
|
|
2801
|
+
message: err.message,
|
|
2776
2802
|
});
|
|
2777
2803
|
throw err;
|
|
2778
2804
|
}
|
|
@@ -2806,7 +2832,7 @@ class ManagedIdentityCredential {
|
|
|
2806
2832
|
// It also means that the endpoint answered with either 200 or 201 (see the sendTokenRequest method),
|
|
2807
2833
|
// yet we had no access token. For this reason, we'll throw once with a specific message:
|
|
2808
2834
|
const error = new CredentialUnavailableError("The managed identity endpoint was reached, yet no tokens were received.");
|
|
2809
|
-
logger$
|
|
2835
|
+
logger$4.getToken.info(formatError(scopes, error));
|
|
2810
2836
|
throw error;
|
|
2811
2837
|
}
|
|
2812
2838
|
// Since `authenticateManagedIdentity` didn't throw, and the result was not null,
|
|
@@ -2818,10 +2844,10 @@ class ManagedIdentityCredential {
|
|
|
2818
2844
|
// We've previously determined that the endpoint was unavailable,
|
|
2819
2845
|
// either because it was unreachable or permanently unable to authenticate.
|
|
2820
2846
|
const error = new CredentialUnavailableError("The managed identity endpoint is not currently available");
|
|
2821
|
-
logger$
|
|
2847
|
+
logger$4.getToken.info(formatError(scopes, error));
|
|
2822
2848
|
throw error;
|
|
2823
2849
|
}
|
|
2824
|
-
logger$
|
|
2850
|
+
logger$4.getToken.info(formatSuccess(scopes));
|
|
2825
2851
|
return result;
|
|
2826
2852
|
}
|
|
2827
2853
|
catch (err) {
|
|
@@ -2837,20 +2863,20 @@ class ManagedIdentityCredential {
|
|
|
2837
2863
|
// but no identity is available.
|
|
2838
2864
|
span.setStatus({
|
|
2839
2865
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2840
|
-
message: err.message
|
|
2866
|
+
message: err.message,
|
|
2841
2867
|
});
|
|
2842
2868
|
// If either the network is unreachable,
|
|
2843
2869
|
// we can safely assume the credential is unavailable.
|
|
2844
2870
|
if (err.code === "ENETUNREACH") {
|
|
2845
2871
|
const error = new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Unavailable. Network unreachable. Message: ${err.message}`);
|
|
2846
|
-
logger$
|
|
2872
|
+
logger$4.getToken.info(formatError(scopes, error));
|
|
2847
2873
|
throw error;
|
|
2848
2874
|
}
|
|
2849
2875
|
// If either the host was unreachable,
|
|
2850
2876
|
// we can safely assume the credential is unavailable.
|
|
2851
2877
|
if (err.code === "EHOSTUNREACH") {
|
|
2852
2878
|
const error = new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Unavailable. No managed identity endpoint found. Message: ${err.message}`);
|
|
2853
|
-
logger$
|
|
2879
|
+
logger$4.getToken.info(formatError(scopes, error));
|
|
2854
2880
|
throw error;
|
|
2855
2881
|
}
|
|
2856
2882
|
// If err.statusCode has a value of 400, it comes from sendTokenRequest,
|
|
@@ -2866,7 +2892,7 @@ class ManagedIdentityCredential {
|
|
|
2866
2892
|
// Any other error should break the chain.
|
|
2867
2893
|
throw new AuthenticationError(err.statusCode, {
|
|
2868
2894
|
error: `${ManagedIdentityCredential.name} authentication failed.`,
|
|
2869
|
-
error_description: err.message
|
|
2895
|
+
error_description: err.message,
|
|
2870
2896
|
});
|
|
2871
2897
|
}
|
|
2872
2898
|
finally {
|
|
@@ -2900,7 +2926,7 @@ const defaultCredentials = [
|
|
|
2900
2926
|
DefaultManagedIdentityCredential,
|
|
2901
2927
|
VisualStudioCodeCredential,
|
|
2902
2928
|
AzureCliCredential,
|
|
2903
|
-
AzurePowerShellCredential
|
|
2929
|
+
AzurePowerShellCredential,
|
|
2904
2930
|
];
|
|
2905
2931
|
/**
|
|
2906
2932
|
* Provides a default {@link ChainedTokenCredential} configuration that should
|
|
@@ -2944,7 +2970,7 @@ class DefaultAzureCredential extends ChainedTokenCredential {
|
|
|
2944
2970
|
* @internal
|
|
2945
2971
|
*/
|
|
2946
2972
|
const interactiveBrowserMockable = {
|
|
2947
|
-
open
|
|
2973
|
+
open: open__default["default"],
|
|
2948
2974
|
};
|
|
2949
2975
|
/**
|
|
2950
2976
|
* 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 +3015,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
2989
3015
|
redirectUri: this.redirectUri,
|
|
2990
3016
|
scopes: scopes,
|
|
2991
3017
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
2992
|
-
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier
|
|
3018
|
+
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
2993
3019
|
};
|
|
2994
3020
|
this.acquireTokenByCode(tokenRequest)
|
|
2995
3021
|
.then((authResponse) => {
|
|
@@ -3004,7 +3030,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3004
3030
|
this.logger.getToken.info(formatSuccess(scopes));
|
|
3005
3031
|
resolve({
|
|
3006
3032
|
expiresOnTimestamp,
|
|
3007
|
-
token: authResponse.accessToken
|
|
3033
|
+
token: authResponse.accessToken,
|
|
3008
3034
|
});
|
|
3009
3035
|
}
|
|
3010
3036
|
else {
|
|
@@ -3026,8 +3052,8 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3026
3052
|
cleanup();
|
|
3027
3053
|
});
|
|
3028
3054
|
};
|
|
3029
|
-
const app =
|
|
3030
|
-
const server =
|
|
3055
|
+
const app = http__default["default"].createServer(requestListener);
|
|
3056
|
+
const server = stoppable__default["default"](app);
|
|
3031
3057
|
const listen = app.listen(this.port, this.hostname, () => this.logger.info(`InteractiveBrowserCredential listening on port ${this.port}!`));
|
|
3032
3058
|
function cleanup() {
|
|
3033
3059
|
if (listen) {
|
|
@@ -3049,7 +3075,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3049
3075
|
reject(new CredentialUnavailableError([
|
|
3050
3076
|
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3051
3077
|
`Try sending a redirect URI with a different port, as follows:`,
|
|
3052
|
-
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`'
|
|
3078
|
+
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`',
|
|
3053
3079
|
].join(" ")));
|
|
3054
3080
|
}
|
|
3055
3081
|
else {
|
|
@@ -3074,7 +3100,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3074
3100
|
}
|
|
3075
3101
|
async openAuthCodeUrl(scopeArray, options) {
|
|
3076
3102
|
// Initialize CryptoProvider instance
|
|
3077
|
-
const cryptoProvider = new
|
|
3103
|
+
const cryptoProvider = new msalNode__namespace.CryptoProvider();
|
|
3078
3104
|
// Generate PKCE Codes before starting the authorization flow
|
|
3079
3105
|
this.pkceCodes = await cryptoProvider.generatePkceCodes();
|
|
3080
3106
|
const authCodeUrlParameters = {
|
|
@@ -3085,7 +3111,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3085
3111
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3086
3112
|
loginHint: this.loginHint,
|
|
3087
3113
|
codeChallenge: this.pkceCodes.challenge,
|
|
3088
|
-
codeChallengeMethod: "S256" // Use SHA256 Algorithm
|
|
3114
|
+
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3089
3115
|
};
|
|
3090
3116
|
const response = await this.publicApp.getAuthCodeUrl(authCodeUrlParameters);
|
|
3091
3117
|
try {
|
|
@@ -3098,7 +3124,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3098
3124
|
}
|
|
3099
3125
|
|
|
3100
3126
|
// Copyright (c) Microsoft Corporation.
|
|
3101
|
-
const logger$
|
|
3127
|
+
const logger$3 = credentialLogger("InteractiveBrowserCredential");
|
|
3102
3128
|
/**
|
|
3103
3129
|
* Enables authentication to Azure Active Directory inside of the web browser
|
|
3104
3130
|
* using the interactive login flow.
|
|
@@ -3120,7 +3146,7 @@ class InteractiveBrowserCredential {
|
|
|
3120
3146
|
const redirectUri = typeof options.redirectUri === "function"
|
|
3121
3147
|
? options.redirectUri()
|
|
3122
3148
|
: options.redirectUri || "http://localhost";
|
|
3123
|
-
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$
|
|
3149
|
+
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$3,
|
|
3124
3150
|
redirectUri }));
|
|
3125
3151
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3126
3152
|
}
|
|
@@ -3182,7 +3208,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3182
3208
|
cancel: false,
|
|
3183
3209
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3184
3210
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3185
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
3211
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3186
3212
|
};
|
|
3187
3213
|
const promise = this.publicApp.acquireTokenByDeviceCode(requestOptions);
|
|
3188
3214
|
// TODO:
|
|
@@ -3199,7 +3225,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3199
3225
|
}
|
|
3200
3226
|
|
|
3201
3227
|
// Copyright (c) Microsoft Corporation.
|
|
3202
|
-
const logger$
|
|
3228
|
+
const logger$2 = credentialLogger("DeviceCodeCredential");
|
|
3203
3229
|
/**
|
|
3204
3230
|
* Method that logs the user code from the DeviceCodeCredential.
|
|
3205
3231
|
* @param deviceCodeInfo - The device code.
|
|
@@ -3233,7 +3259,7 @@ class DeviceCodeCredential {
|
|
|
3233
3259
|
* @param options - Options for configuring the client which makes the authentication requests.
|
|
3234
3260
|
*/
|
|
3235
3261
|
constructor(options) {
|
|
3236
|
-
this.msalFlow = new MsalDeviceCode(Object.assign(Object.assign({}, options), { logger: logger$
|
|
3262
|
+
this.msalFlow = new MsalDeviceCode(Object.assign(Object.assign({}, options), { logger: logger$2, userPromptCallback: (options === null || options === void 0 ? void 0 : options.userPromptCallback) || defaultDeviceCodePromptCallback, tokenCredentialOptions: options || {} }));
|
|
3237
3263
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3238
3264
|
}
|
|
3239
3265
|
/**
|
|
@@ -3302,7 +3328,7 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3302
3328
|
code: this.authorizationCode,
|
|
3303
3329
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3304
3330
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3305
|
-
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
3331
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3306
3332
|
}));
|
|
3307
3333
|
// The Client Credential flow does not return an account,
|
|
3308
3334
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -3315,7 +3341,7 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3315
3341
|
}
|
|
3316
3342
|
|
|
3317
3343
|
// Copyright (c) Microsoft Corporation.
|
|
3318
|
-
const logger$
|
|
3344
|
+
const logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
3319
3345
|
/**
|
|
3320
3346
|
* Enables authentication to Azure Active Directory using an authorization code
|
|
3321
3347
|
* that was obtained through the authorization code flow, described in more detail
|
|
@@ -3329,7 +3355,7 @@ class AuthorizationCodeCredential {
|
|
|
3329
3355
|
* @internal
|
|
3330
3356
|
*/
|
|
3331
3357
|
constructor(tenantId, clientId, clientSecretOrAuthorizationCode, authorizationCodeOrRedirectUri, redirectUriOrOptions, options) {
|
|
3332
|
-
checkTenantId(logger$
|
|
3358
|
+
checkTenantId(logger$1, tenantId);
|
|
3333
3359
|
let clientSecret = clientSecretOrAuthorizationCode;
|
|
3334
3360
|
if (typeof redirectUriOrOptions === "string") {
|
|
3335
3361
|
// the clientId+clientSecret constructor
|
|
@@ -3345,7 +3371,7 @@ class AuthorizationCodeCredential {
|
|
|
3345
3371
|
options = redirectUriOrOptions;
|
|
3346
3372
|
}
|
|
3347
3373
|
this.msalFlow = new MsalAuthorizationCode(Object.assign(Object.assign({}, options), { clientSecret,
|
|
3348
|
-
clientId, tokenCredentialOptions: options || {}, logger: logger$
|
|
3374
|
+
clientId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
3349
3375
|
}
|
|
3350
3376
|
/**
|
|
3351
3377
|
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
@@ -3386,7 +3412,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3386
3412
|
this.msalConfig.auth.clientCertificate = {
|
|
3387
3413
|
thumbprint: parts.thumbprint,
|
|
3388
3414
|
privateKey: parts.certificateContents,
|
|
3389
|
-
x5c: parts.x5c
|
|
3415
|
+
x5c: parts.x5c,
|
|
3390
3416
|
};
|
|
3391
3417
|
}
|
|
3392
3418
|
catch (error) {
|
|
@@ -3406,7 +3432,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3406
3432
|
correlationId: options.correlationId,
|
|
3407
3433
|
authority: options.authority,
|
|
3408
3434
|
claims: options.claims,
|
|
3409
|
-
oboAssertion: this.userAssertionToken
|
|
3435
|
+
oboAssertion: this.userAssertionToken,
|
|
3410
3436
|
});
|
|
3411
3437
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3412
3438
|
}
|
|
@@ -3417,8 +3443,8 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3417
3443
|
}
|
|
3418
3444
|
|
|
3419
3445
|
// Copyright (c) Microsoft Corporation.
|
|
3420
|
-
const credentialName
|
|
3421
|
-
const logger
|
|
3446
|
+
const credentialName = "OnBehalfOfCredential";
|
|
3447
|
+
const logger = credentialLogger(credentialName);
|
|
3422
3448
|
/**
|
|
3423
3449
|
* Enables authentication to Azure Active Directory using the [On Behalf Of flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
|
|
3424
3450
|
*/
|
|
@@ -3450,9 +3476,9 @@ class OnBehalfOfCredential {
|
|
|
3450
3476
|
const { certificatePath } = options;
|
|
3451
3477
|
const { tenantId, clientId, userAssertionToken } = options;
|
|
3452
3478
|
if (!tenantId || !clientId || !(clientSecret || certificatePath) || !userAssertionToken) {
|
|
3453
|
-
throw new Error(`${credentialName
|
|
3479
|
+
throw new Error(`${credentialName}: tenantId, clientId, clientSecret (or certificatePath) and userAssertionToken are required parameters.`);
|
|
3454
3480
|
}
|
|
3455
|
-
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger
|
|
3481
|
+
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
3456
3482
|
}
|
|
3457
3483
|
/**
|
|
3458
3484
|
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
@@ -3462,7 +3488,7 @@ class OnBehalfOfCredential {
|
|
|
3462
3488
|
* @param options - The options used to configure the underlying network requests.
|
|
3463
3489
|
*/
|
|
3464
3490
|
async getToken(scopes, options = {}) {
|
|
3465
|
-
return trace(`${credentialName
|
|
3491
|
+
return trace(`${credentialName}.getToken`, options, async (newOptions) => {
|
|
3466
3492
|
const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
|
|
3467
3493
|
return this.msalFlow.getToken(arrayScopes, newOptions);
|
|
3468
3494
|
});
|
|
@@ -3500,7 +3526,7 @@ exports.UsernamePasswordCredential = UsernamePasswordCredential;
|
|
|
3500
3526
|
exports.VisualStudioCodeCredential = VisualStudioCodeCredential;
|
|
3501
3527
|
exports.deserializeAuthenticationRecord = deserializeAuthenticationRecord;
|
|
3502
3528
|
exports.getDefaultAzureCredential = getDefaultAzureCredential;
|
|
3503
|
-
exports.logger = logger;
|
|
3529
|
+
exports.logger = logger$j;
|
|
3504
3530
|
exports.serializeAuthenticationRecord = serializeAuthenticationRecord;
|
|
3505
3531
|
exports.useIdentityPlugin = useIdentityPlugin;
|
|
3506
3532
|
//# sourceMappingURL=index.js.map
|