@azure/identity 3.3.1 → 3.3.2-alpha.20231013.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/dist/index.js +84 -174
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/constants.js +1 -1
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +4 -0
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +2 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +16 -142
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/utils.browser.js +236 -0
- package/dist-esm/src/msal/utils.browser.js.map +1 -0
- package/dist-esm/src/msal/utils.js +3 -4
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/provider.js.map +1 -1
- package/package.json +15 -15
- package/types/identity.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var msalNode = require('@azure/msal-node');
|
|
3
|
+
var msalCommon = require('@azure/msal-node');
|
|
6
4
|
var logger$o = require('@azure/logger');
|
|
7
|
-
var msalCommon = require('@azure/msal-common');
|
|
8
5
|
var abortController = require('@azure/abort-controller');
|
|
9
6
|
var coreUtil = require('@azure/core-util');
|
|
10
|
-
var uuid = require('uuid');
|
|
11
7
|
var coreClient = require('@azure/core-client');
|
|
12
8
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
13
9
|
var coreTracing = require('@azure/core-tracing');
|
|
@@ -19,14 +15,9 @@ var https = require('https');
|
|
|
19
15
|
var child_process = require('child_process');
|
|
20
16
|
var crypto = require('crypto');
|
|
21
17
|
var util = require('util');
|
|
22
|
-
var http = require('http');
|
|
23
18
|
var open = require('open');
|
|
24
|
-
var stoppable = require('stoppable');
|
|
25
|
-
|
|
26
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
19
|
|
|
28
|
-
function
|
|
29
|
-
if (e && e.__esModule) return e;
|
|
20
|
+
function _interopNamespaceDefault(e) {
|
|
30
21
|
var n = Object.create(null);
|
|
31
22
|
if (e) {
|
|
32
23
|
Object.keys(e).forEach(function (k) {
|
|
@@ -39,21 +30,12 @@ function _interopNamespace(e) {
|
|
|
39
30
|
}
|
|
40
31
|
});
|
|
41
32
|
}
|
|
42
|
-
n
|
|
33
|
+
n.default = e;
|
|
43
34
|
return Object.freeze(n);
|
|
44
35
|
}
|
|
45
36
|
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
49
|
-
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
|
|
50
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
51
|
-
var https__default = /*#__PURE__*/_interopDefaultLegacy(https);
|
|
52
|
-
var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
|
|
53
|
-
var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
|
|
54
|
-
var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
|
|
55
|
-
var open__default = /*#__PURE__*/_interopDefaultLegacy(open);
|
|
56
|
-
var stoppable__default = /*#__PURE__*/_interopDefaultLegacy(stoppable);
|
|
37
|
+
var msalCommon__namespace = /*#__PURE__*/_interopNamespaceDefault(msalCommon);
|
|
38
|
+
var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_process);
|
|
57
39
|
|
|
58
40
|
// Copyright (c) Microsoft Corporation.
|
|
59
41
|
// Licensed under the MIT license.
|
|
@@ -175,6 +157,7 @@ class AuthenticationRequiredError extends Error {
|
|
|
175
157
|
}
|
|
176
158
|
|
|
177
159
|
// Copyright (c) Microsoft Corporation.
|
|
160
|
+
// Licensed under the MIT license.
|
|
178
161
|
/**
|
|
179
162
|
* The AzureLogger used for all clients within the identity package
|
|
180
163
|
*/
|
|
@@ -257,7 +240,7 @@ function credentialLogger(title, log = logger$n) {
|
|
|
257
240
|
/**
|
|
258
241
|
* Current version of the `@azure/identity` package.
|
|
259
242
|
*/
|
|
260
|
-
const SDK_VERSION = `3.3.
|
|
243
|
+
const SDK_VERSION = `3.3.2`;
|
|
261
244
|
/**
|
|
262
245
|
* The default client ID for authentication
|
|
263
246
|
* @internal
|
|
@@ -305,6 +288,7 @@ const CACHE_CAE_SUFFIX = ".cae";
|
|
|
305
288
|
const CACHE_NON_CAE_SUFFIX = ".nocae";
|
|
306
289
|
|
|
307
290
|
// Copyright (c) Microsoft Corporation.
|
|
291
|
+
// Licensed under the MIT license.
|
|
308
292
|
/**
|
|
309
293
|
* Latest AuthenticationRecord version
|
|
310
294
|
* @internal
|
|
@@ -423,7 +407,7 @@ class MsalBaseUtilities {
|
|
|
423
407
|
* Generates a UUID
|
|
424
408
|
*/
|
|
425
409
|
generateUuid() {
|
|
426
|
-
return
|
|
410
|
+
return coreUtil.randomUUID();
|
|
427
411
|
}
|
|
428
412
|
/**
|
|
429
413
|
* Handles the MSAL authentication result.
|
|
@@ -534,6 +518,7 @@ function deserializeAuthenticationRecord(serializedRecord) {
|
|
|
534
518
|
}
|
|
535
519
|
|
|
536
520
|
// Copyright (c) Microsoft Corporation.
|
|
521
|
+
// Licensed under the MIT license.
|
|
537
522
|
function createConfigurationErrorMessage(tenantId) {
|
|
538
523
|
return `The current credential is not configured to acquire tokens for tenant ${tenantId}. To enable acquiring tokens for this tenant add it to the AdditionallyAllowedTenants on the credential options, or add "*" to AdditionallyAllowedTenants to allow acquiring tokens for any tenant.`;
|
|
539
524
|
}
|
|
@@ -567,6 +552,7 @@ function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowe
|
|
|
567
552
|
}
|
|
568
553
|
|
|
569
554
|
// Copyright (c) Microsoft Corporation.
|
|
555
|
+
// Licensed under the MIT license.
|
|
570
556
|
/**
|
|
571
557
|
* @internal
|
|
572
558
|
*/
|
|
@@ -618,6 +604,7 @@ function getIdentityTokenEndpointSuffix(tenantId) {
|
|
|
618
604
|
}
|
|
619
605
|
|
|
620
606
|
// Copyright (c) Microsoft Corporation.
|
|
607
|
+
// Licensed under the MIT license.
|
|
621
608
|
/**
|
|
622
609
|
* Creates a span using the global tracer.
|
|
623
610
|
* @internal
|
|
@@ -638,6 +625,7 @@ const azureArcAPIVersion = "2019-11-01";
|
|
|
638
625
|
const azureFabricVersion = "2019-07-01-preview";
|
|
639
626
|
|
|
640
627
|
// Copyright (c) Microsoft Corporation.
|
|
628
|
+
// Licensed under the MIT license.
|
|
641
629
|
/**
|
|
642
630
|
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
|
643
631
|
* These are GET requests that require sending a `resource` parameter on the query.
|
|
@@ -688,6 +676,7 @@ function parseExpirationTimestamp(body) {
|
|
|
688
676
|
}
|
|
689
677
|
|
|
690
678
|
// Copyright (c) Microsoft Corporation.
|
|
679
|
+
// Licensed under the MIT license.
|
|
691
680
|
const noCorrelationId = "noCorrelationId";
|
|
692
681
|
/**
|
|
693
682
|
* @internal
|
|
@@ -1032,6 +1021,7 @@ var RegionalAuthority;
|
|
|
1032
1021
|
})(RegionalAuthority || (RegionalAuthority = {}));
|
|
1033
1022
|
|
|
1034
1023
|
// Copyright (c) Microsoft Corporation.
|
|
1024
|
+
// Licensed under the MIT license.
|
|
1035
1025
|
/**
|
|
1036
1026
|
* The current persistence provider, undefined by default.
|
|
1037
1027
|
* @internal
|
|
@@ -1166,10 +1156,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1166
1156
|
};
|
|
1167
1157
|
}
|
|
1168
1158
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1169
|
-
this.caeApp.public = new
|
|
1159
|
+
this.caeApp.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
1170
1160
|
}
|
|
1171
1161
|
else {
|
|
1172
|
-
this.app.public = new
|
|
1162
|
+
this.app.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
1173
1163
|
}
|
|
1174
1164
|
if (this.getAssertion) {
|
|
1175
1165
|
this.msalConfig.auth.clientAssertion = await this.getAssertion();
|
|
@@ -1179,10 +1169,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1179
1169
|
this.msalConfig.auth.clientAssertion ||
|
|
1180
1170
|
this.msalConfig.auth.clientCertificate) {
|
|
1181
1171
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1182
|
-
this.caeApp.confidential = new
|
|
1172
|
+
this.caeApp.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1183
1173
|
}
|
|
1184
1174
|
else {
|
|
1185
|
-
this.app.confidential = new
|
|
1175
|
+
this.app.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1186
1176
|
}
|
|
1187
1177
|
}
|
|
1188
1178
|
else {
|
|
@@ -1313,6 +1303,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1313
1303
|
}
|
|
1314
1304
|
|
|
1315
1305
|
// Copyright (c) Microsoft Corporation.
|
|
1306
|
+
// Licensed under the MIT license.
|
|
1316
1307
|
const CommonTenantId = "common";
|
|
1317
1308
|
const AzureAccountClientId = "aebc6443-996d-45c2-90f0-388ff96faa56"; // VSC: 'aebc6443-996d-45c2-90f0-388ff96faa56'
|
|
1318
1309
|
const logger$m = credentialLogger("VisualStudioCodeCredential");
|
|
@@ -1347,10 +1338,10 @@ function getPropertyFromVSCode(property) {
|
|
|
1347
1338
|
const settingsPath = ["User", "settings.json"];
|
|
1348
1339
|
// Eventually we can add more folders for more versions of VSCode.
|
|
1349
1340
|
const vsCodeFolder = "Code";
|
|
1350
|
-
const homedir =
|
|
1341
|
+
const homedir = os.homedir();
|
|
1351
1342
|
function loadProperty(...pathSegments) {
|
|
1352
|
-
const fullPath =
|
|
1353
|
-
const settings = JSON.parse(
|
|
1343
|
+
const fullPath = path.join(...pathSegments, vsCodeFolder, ...settingsPath);
|
|
1344
|
+
const settings = JSON.parse(fs.readFileSync(fullPath, { encoding: "utf8" }));
|
|
1354
1345
|
return settings[property];
|
|
1355
1346
|
}
|
|
1356
1347
|
try {
|
|
@@ -1493,6 +1484,7 @@ class VisualStudioCodeCredential {
|
|
|
1493
1484
|
}
|
|
1494
1485
|
|
|
1495
1486
|
// Copyright (c) Microsoft Corporation.
|
|
1487
|
+
// Licensed under the MIT license.
|
|
1496
1488
|
/**
|
|
1497
1489
|
* The context passed to an Identity plugin. This contains objects that
|
|
1498
1490
|
* plugins can use to set backend implementations.
|
|
@@ -1534,6 +1526,7 @@ function useIdentityPlugin(plugin) {
|
|
|
1534
1526
|
}
|
|
1535
1527
|
|
|
1536
1528
|
// Copyright (c) Microsoft Corporation.
|
|
1529
|
+
// Licensed under the MIT license.
|
|
1537
1530
|
const msiName$6 = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
1538
1531
|
const logger$l = credentialLogger(msiName$6);
|
|
1539
1532
|
/**
|
|
@@ -1601,6 +1594,7 @@ const appServiceMsi2017 = {
|
|
|
1601
1594
|
};
|
|
1602
1595
|
|
|
1603
1596
|
// Copyright (c) Microsoft Corporation.
|
|
1597
|
+
// Licensed under the MIT license.
|
|
1604
1598
|
const msiName$5 = "ManagedIdentityCredential - CloudShellMSI";
|
|
1605
1599
|
const logger$k = credentialLogger(msiName$5);
|
|
1606
1600
|
/**
|
|
@@ -1672,6 +1666,7 @@ const cloudShellMsi = {
|
|
|
1672
1666
|
};
|
|
1673
1667
|
|
|
1674
1668
|
// Copyright (c) Microsoft Corporation.
|
|
1669
|
+
// Licensed under the MIT license.
|
|
1675
1670
|
const msiName$4 = "ManagedIdentityCredential - IMDS";
|
|
1676
1671
|
const logger$j = credentialLogger(msiName$4);
|
|
1677
1672
|
/**
|
|
@@ -1804,6 +1799,7 @@ const imdsMsi = {
|
|
|
1804
1799
|
};
|
|
1805
1800
|
|
|
1806
1801
|
// Copyright (c) Microsoft Corporation.
|
|
1802
|
+
// Licensed under the MIT license.
|
|
1807
1803
|
const msiName$3 = "ManagedIdentityCredential - Azure Arc MSI";
|
|
1808
1804
|
const logger$i = credentialLogger(msiName$3);
|
|
1809
1805
|
/**
|
|
@@ -1914,6 +1910,7 @@ const arcMsi = {
|
|
|
1914
1910
|
};
|
|
1915
1911
|
|
|
1916
1912
|
// Copyright (c) Microsoft Corporation.
|
|
1913
|
+
// Licensed under the MIT license.
|
|
1917
1914
|
/**
|
|
1918
1915
|
* MSAL client assertion client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
1919
1916
|
* @internal
|
|
@@ -1953,6 +1950,7 @@ class MsalClientAssertion extends MsalNode {
|
|
|
1953
1950
|
}
|
|
1954
1951
|
|
|
1955
1952
|
// Copyright (c) Microsoft Corporation.
|
|
1953
|
+
// Licensed under the MIT license.
|
|
1956
1954
|
const logger$h = credentialLogger("ClientAssertionCredential");
|
|
1957
1955
|
/**
|
|
1958
1956
|
* Authenticates a service principal with a JWT assertion.
|
|
@@ -1996,6 +1994,7 @@ class ClientAssertionCredential {
|
|
|
1996
1994
|
}
|
|
1997
1995
|
|
|
1998
1996
|
// Copyright (c) Microsoft Corporation.
|
|
1997
|
+
// Licensed under the MIT license.
|
|
1999
1998
|
const credentialName$3 = "WorkloadIdentityCredential";
|
|
2000
1999
|
/**
|
|
2001
2000
|
* Contains the list of all supported environment variable names so that an
|
|
@@ -2094,6 +2093,7 @@ class WorkloadIdentityCredential {
|
|
|
2094
2093
|
}
|
|
2095
2094
|
|
|
2096
2095
|
// Copyright (c) Microsoft Corporation.
|
|
2096
|
+
// Licensed under the MIT license.
|
|
2097
2097
|
const msiName$2 = "ManagedIdentityCredential - Token Exchange";
|
|
2098
2098
|
const logger$f = credentialLogger(msiName$2);
|
|
2099
2099
|
/**
|
|
@@ -2123,6 +2123,7 @@ function tokenExchangeMsi() {
|
|
|
2123
2123
|
}
|
|
2124
2124
|
|
|
2125
2125
|
// Copyright (c) Microsoft Corporation.
|
|
2126
|
+
// Licensed under the MIT license.
|
|
2126
2127
|
// This MSI can be easily tested by deploying a container to Azure Service Fabric with the Dockerfile:
|
|
2127
2128
|
//
|
|
2128
2129
|
// FROM node:12
|
|
@@ -2201,7 +2202,7 @@ const fabricMsi = {
|
|
|
2201
2202
|
"IDENTITY_SERVER_THUMBPRINT=[REDACTED].",
|
|
2202
2203
|
].join(" "));
|
|
2203
2204
|
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$1(scopes, clientId, resourceId)));
|
|
2204
|
-
request.agent = new
|
|
2205
|
+
request.agent = new https.Agent({
|
|
2205
2206
|
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
2206
2207
|
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
2207
2208
|
rejectUnauthorized: false,
|
|
@@ -2212,6 +2213,7 @@ const fabricMsi = {
|
|
|
2212
2213
|
};
|
|
2213
2214
|
|
|
2214
2215
|
// Copyright (c) Microsoft Corporation.
|
|
2216
|
+
// Licensed under the MIT license.
|
|
2215
2217
|
const msiName = "ManagedIdentityCredential - AppServiceMSI 2019";
|
|
2216
2218
|
const logger$d = credentialLogger(msiName);
|
|
2217
2219
|
/**
|
|
@@ -2279,6 +2281,7 @@ const appServiceMsi2019 = {
|
|
|
2279
2281
|
};
|
|
2280
2282
|
|
|
2281
2283
|
// Copyright (c) Microsoft Corporation.
|
|
2284
|
+
// Licensed under the MIT license.
|
|
2282
2285
|
const logger$c = credentialLogger("ManagedIdentityCredential");
|
|
2283
2286
|
/**
|
|
2284
2287
|
* Attempts authentication using a managed identity available at the deployment environment.
|
|
@@ -2318,8 +2321,9 @@ class ManagedIdentityCredential {
|
|
|
2318
2321
|
/** authority host validation and metadata discovery to be skipped in managed identity
|
|
2319
2322
|
* since this wasn't done previously before adding token cache support
|
|
2320
2323
|
*/
|
|
2321
|
-
this.confidentialApp = new
|
|
2324
|
+
this.confidentialApp = new msalCommon.ConfidentialClientApplication({
|
|
2322
2325
|
auth: {
|
|
2326
|
+
authority: "https://login.microsoftonline.com/managed_identity",
|
|
2323
2327
|
clientId: (_a = this.clientId) !== null && _a !== void 0 ? _a : DeveloperSignOnClientId,
|
|
2324
2328
|
clientSecret: "dummy-secret",
|
|
2325
2329
|
cloudDiscoveryMetadata: '{"tenant_discovery_endpoint":"https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}',
|
|
@@ -2407,7 +2411,7 @@ class ManagedIdentityCredential {
|
|
|
2407
2411
|
else {
|
|
2408
2412
|
const appTokenParameters = {
|
|
2409
2413
|
correlationId: this.identityClient.getCorrelationId(),
|
|
2410
|
-
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "
|
|
2414
|
+
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "managed_identity",
|
|
2411
2415
|
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
2412
2416
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
2413
2417
|
};
|
|
@@ -2559,6 +2563,7 @@ class ManagedIdentityCredential {
|
|
|
2559
2563
|
}
|
|
2560
2564
|
|
|
2561
2565
|
// Copyright (c) Microsoft Corporation.
|
|
2566
|
+
// Licensed under the MIT license.
|
|
2562
2567
|
/**
|
|
2563
2568
|
* Ensures the scopes value is an array.
|
|
2564
2569
|
* @internal
|
|
@@ -2586,6 +2591,7 @@ function getScopeResource(scope) {
|
|
|
2586
2591
|
}
|
|
2587
2592
|
|
|
2588
2593
|
// Copyright (c) Microsoft Corporation.
|
|
2594
|
+
// Licensed under the MIT license.
|
|
2589
2595
|
/**
|
|
2590
2596
|
* Mockable reference to the CLI credential cliCredentialFunctions
|
|
2591
2597
|
* @internal
|
|
@@ -2617,7 +2623,7 @@ const cliCredentialInternals = {
|
|
|
2617
2623
|
}
|
|
2618
2624
|
return new Promise((resolve, reject) => {
|
|
2619
2625
|
try {
|
|
2620
|
-
|
|
2626
|
+
child_process.execFile("az", [
|
|
2621
2627
|
"account",
|
|
2622
2628
|
"get-access-token",
|
|
2623
2629
|
"--output",
|
|
@@ -2722,6 +2728,7 @@ class AzureCliCredential {
|
|
|
2722
2728
|
}
|
|
2723
2729
|
|
|
2724
2730
|
// Copyright (c) Microsoft Corporation.
|
|
2731
|
+
// Licensed under the MIT license.
|
|
2725
2732
|
/**
|
|
2726
2733
|
* Easy to mock childProcess utils.
|
|
2727
2734
|
* @internal
|
|
@@ -2752,6 +2759,7 @@ const processUtils = {
|
|
|
2752
2759
|
};
|
|
2753
2760
|
|
|
2754
2761
|
// Copyright (c) Microsoft Corporation.
|
|
2762
|
+
// Licensed under the MIT license.
|
|
2755
2763
|
const logger$a = credentialLogger("AzurePowerShellCredential");
|
|
2756
2764
|
const isWindows = process.platform === "win32";
|
|
2757
2765
|
/**
|
|
@@ -2861,11 +2869,15 @@ class AzurePowerShellCredential {
|
|
|
2861
2869
|
const results = await runCommands([
|
|
2862
2870
|
[
|
|
2863
2871
|
powerShellCommand,
|
|
2872
|
+
"-NoProfile",
|
|
2873
|
+
"-NonInteractive",
|
|
2864
2874
|
"-Command",
|
|
2865
2875
|
"Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru",
|
|
2866
2876
|
],
|
|
2867
2877
|
[
|
|
2868
2878
|
powerShellCommand,
|
|
2879
|
+
"-NoProfile",
|
|
2880
|
+
"-NonInteractive",
|
|
2869
2881
|
"-Command",
|
|
2870
2882
|
`Get-AzAccessToken ${tenantSection} -ResourceUrl "${resource}" | ConvertTo-Json`,
|
|
2871
2883
|
],
|
|
@@ -2925,6 +2937,7 @@ class AzurePowerShellCredential {
|
|
|
2925
2937
|
}
|
|
2926
2938
|
|
|
2927
2939
|
// Copyright (c) Microsoft Corporation.
|
|
2940
|
+
// Licensed under the MIT license.
|
|
2928
2941
|
/**
|
|
2929
2942
|
* @internal
|
|
2930
2943
|
*/
|
|
@@ -3003,6 +3016,7 @@ class ChainedTokenCredential {
|
|
|
3003
3016
|
}
|
|
3004
3017
|
|
|
3005
3018
|
// Copyright (c) Microsoft Corporation.
|
|
3019
|
+
// Licensed under the MIT license.
|
|
3006
3020
|
const readFileAsync = util.promisify(fs.readFile);
|
|
3007
3021
|
/**
|
|
3008
3022
|
* Tries to asynchronously load a certificate from the given path.
|
|
@@ -3108,6 +3122,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
3108
3122
|
}
|
|
3109
3123
|
|
|
3110
3124
|
// Copyright (c) Microsoft Corporation.
|
|
3125
|
+
// Licensed under the MIT license.
|
|
3111
3126
|
const credentialName$2 = "ClientCertificateCredential";
|
|
3112
3127
|
const logger$8 = credentialLogger(credentialName$2);
|
|
3113
3128
|
/**
|
|
@@ -3162,6 +3177,7 @@ class ClientCertificateCredential {
|
|
|
3162
3177
|
}
|
|
3163
3178
|
|
|
3164
3179
|
// Copyright (c) Microsoft Corporation.
|
|
3180
|
+
// Licensed under the MIT license.
|
|
3165
3181
|
/**
|
|
3166
3182
|
* MSAL client secret client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
3167
3183
|
* @internal
|
|
@@ -3192,6 +3208,7 @@ class MsalClientSecret extends MsalNode {
|
|
|
3192
3208
|
}
|
|
3193
3209
|
|
|
3194
3210
|
// Copyright (c) Microsoft Corporation.
|
|
3211
|
+
// Licensed under the MIT license.
|
|
3195
3212
|
const logger$7 = credentialLogger("ClientSecretCredential");
|
|
3196
3213
|
/**
|
|
3197
3214
|
* Enables authentication to Azure Active Directory using a client secret
|
|
@@ -3241,6 +3258,7 @@ class ClientSecretCredential {
|
|
|
3241
3258
|
}
|
|
3242
3259
|
|
|
3243
3260
|
// Copyright (c) Microsoft Corporation.
|
|
3261
|
+
// Licensed under the MIT license.
|
|
3244
3262
|
/**
|
|
3245
3263
|
* MSAL username and password client. Calls to the MSAL's public application's `acquireTokenByUsernamePassword` during `doGetToken`.
|
|
3246
3264
|
* @internal
|
|
@@ -3271,6 +3289,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
3271
3289
|
}
|
|
3272
3290
|
|
|
3273
3291
|
// Copyright (c) Microsoft Corporation.
|
|
3292
|
+
// Licensed under the MIT license.
|
|
3274
3293
|
const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
3275
3294
|
/**
|
|
3276
3295
|
* Enables authentication to Azure Active Directory with a user's
|
|
@@ -3324,6 +3343,7 @@ class UsernamePasswordCredential {
|
|
|
3324
3343
|
}
|
|
3325
3344
|
|
|
3326
3345
|
// Copyright (c) Microsoft Corporation.
|
|
3346
|
+
// Licensed under the MIT license.
|
|
3327
3347
|
/**
|
|
3328
3348
|
* Contains the list of all supported environment variable names so that an
|
|
3329
3349
|
* appropriate error message can be generated when no credentials can be
|
|
@@ -3436,6 +3456,7 @@ class EnvironmentCredential {
|
|
|
3436
3456
|
}
|
|
3437
3457
|
|
|
3438
3458
|
// Copyright (c) Microsoft Corporation.
|
|
3459
|
+
// Licensed under the MIT license.
|
|
3439
3460
|
/**
|
|
3440
3461
|
* Mockable reference to the Developer CLI credential cliCredentialFunctions
|
|
3441
3462
|
* @internal
|
|
@@ -3467,7 +3488,7 @@ const developerCliCredentialInternals = {
|
|
|
3467
3488
|
}
|
|
3468
3489
|
return new Promise((resolve, reject) => {
|
|
3469
3490
|
try {
|
|
3470
|
-
|
|
3491
|
+
child_process.execFile("azd", [
|
|
3471
3492
|
"auth",
|
|
3472
3493
|
"token",
|
|
3473
3494
|
"--output",
|
|
@@ -3599,6 +3620,7 @@ class AzureDeveloperCliCredential {
|
|
|
3599
3620
|
}
|
|
3600
3621
|
|
|
3601
3622
|
// Copyright (c) Microsoft Corporation.
|
|
3623
|
+
// Licensed under the MIT license.
|
|
3602
3624
|
/**
|
|
3603
3625
|
* A shim around ManagedIdentityCredential that adapts it to accept
|
|
3604
3626
|
* `DefaultAzureCredentialOptions`.
|
|
@@ -3695,12 +3717,13 @@ class DefaultAzureCredential extends ChainedTokenCredential {
|
|
|
3695
3717
|
}
|
|
3696
3718
|
|
|
3697
3719
|
// Copyright (c) Microsoft Corporation.
|
|
3720
|
+
// Licensed under the MIT license.
|
|
3698
3721
|
/**
|
|
3699
3722
|
* A call to open(), but mockable
|
|
3700
3723
|
* @internal
|
|
3701
3724
|
*/
|
|
3702
3725
|
const interactiveBrowserMockable = {
|
|
3703
|
-
open
|
|
3726
|
+
open,
|
|
3704
3727
|
};
|
|
3705
3728
|
/**
|
|
3706
3729
|
* 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`
|
|
@@ -3710,151 +3733,31 @@ const interactiveBrowserMockable = {
|
|
|
3710
3733
|
class MsalOpenBrowser extends MsalNode {
|
|
3711
3734
|
constructor(options) {
|
|
3712
3735
|
super(options);
|
|
3713
|
-
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3714
|
-
this.redirectUri = options.redirectUri;
|
|
3715
3736
|
this.loginHint = options.loginHint;
|
|
3716
|
-
|
|
3717
|
-
this.port = parseInt(url.port);
|
|
3718
|
-
if (isNaN(this.port)) {
|
|
3719
|
-
this.port = 80;
|
|
3720
|
-
}
|
|
3721
|
-
this.hostname = url.hostname;
|
|
3722
|
-
}
|
|
3723
|
-
async acquireTokenByCode(request, enableCae) {
|
|
3724
|
-
return this.getApp("public", enableCae).acquireTokenByCode(request);
|
|
3725
|
-
}
|
|
3726
|
-
doGetToken(scopes, options) {
|
|
3727
|
-
return new Promise((resolve, reject) => {
|
|
3728
|
-
const socketToDestroy = [];
|
|
3729
|
-
const requestListener = (req, res) => {
|
|
3730
|
-
var _a;
|
|
3731
|
-
if (!req.url) {
|
|
3732
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3733
|
-
return;
|
|
3734
|
-
}
|
|
3735
|
-
let url;
|
|
3736
|
-
try {
|
|
3737
|
-
url = new URL(req.url, this.redirectUri);
|
|
3738
|
-
}
|
|
3739
|
-
catch (e) {
|
|
3740
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3741
|
-
return;
|
|
3742
|
-
}
|
|
3743
|
-
const tokenRequest = {
|
|
3744
|
-
code: url.searchParams.get("code"),
|
|
3745
|
-
redirectUri: this.redirectUri,
|
|
3746
|
-
scopes: scopes,
|
|
3747
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3748
|
-
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
3749
|
-
};
|
|
3750
|
-
this.acquireTokenByCode(tokenRequest, options === null || options === void 0 ? void 0 : options.enableCae)
|
|
3751
|
-
.then((authResponse) => {
|
|
3752
|
-
if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.account) {
|
|
3753
|
-
this.account = msalToPublic(this.clientId, authResponse.account);
|
|
3754
|
-
}
|
|
3755
|
-
const successMessage = `Authentication Complete. You can close the browser and return to the application.`;
|
|
3756
|
-
if (authResponse && authResponse.expiresOn) {
|
|
3757
|
-
const expiresOnTimestamp = authResponse === null || authResponse === void 0 ? void 0 : authResponse.expiresOn.valueOf();
|
|
3758
|
-
res.writeHead(200);
|
|
3759
|
-
res.end(successMessage);
|
|
3760
|
-
this.logger.getToken.info(formatSuccess(scopes));
|
|
3761
|
-
resolve({
|
|
3762
|
-
expiresOnTimestamp,
|
|
3763
|
-
token: authResponse.accessToken,
|
|
3764
|
-
});
|
|
3765
|
-
}
|
|
3766
|
-
else {
|
|
3767
|
-
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3768
|
-
res.writeHead(500);
|
|
3769
|
-
res.end(errorMessage);
|
|
3770
|
-
this.logger.getToken.info(errorMessage);
|
|
3771
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3772
|
-
}
|
|
3773
|
-
cleanup();
|
|
3774
|
-
return;
|
|
3775
|
-
})
|
|
3776
|
-
.catch(() => {
|
|
3777
|
-
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3778
|
-
res.writeHead(500);
|
|
3779
|
-
res.end(errorMessage);
|
|
3780
|
-
this.logger.getToken.info(errorMessage);
|
|
3781
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3782
|
-
cleanup();
|
|
3783
|
-
});
|
|
3784
|
-
};
|
|
3785
|
-
const app = http__default["default"].createServer(requestListener);
|
|
3786
|
-
const server = stoppable__default["default"](app);
|
|
3787
|
-
const listen = app.listen(this.port, this.hostname, () => this.logger.info(`InteractiveBrowserCredential listening on port ${this.port}!`));
|
|
3788
|
-
function cleanup() {
|
|
3789
|
-
if (listen) {
|
|
3790
|
-
listen.close();
|
|
3791
|
-
}
|
|
3792
|
-
for (const socket of socketToDestroy) {
|
|
3793
|
-
socket.destroy();
|
|
3794
|
-
}
|
|
3795
|
-
if (server) {
|
|
3796
|
-
server.close();
|
|
3797
|
-
server.stop();
|
|
3798
|
-
}
|
|
3799
|
-
}
|
|
3800
|
-
app.on("connection", (socket) => socketToDestroy.push(socket));
|
|
3801
|
-
app.on("error", (err) => {
|
|
3802
|
-
cleanup();
|
|
3803
|
-
const code = err.code;
|
|
3804
|
-
if (code === "EACCES" || code === "EADDRINUSE") {
|
|
3805
|
-
reject(new CredentialUnavailableError([
|
|
3806
|
-
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3807
|
-
`Try sending a redirect URI with a different port, as follows:`,
|
|
3808
|
-
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`',
|
|
3809
|
-
].join(" ")));
|
|
3810
|
-
}
|
|
3811
|
-
else {
|
|
3812
|
-
reject(new CredentialUnavailableError(`InteractiveBrowserCredential: Failed to start the necessary web server. Error: ${err.message}`));
|
|
3813
|
-
}
|
|
3814
|
-
});
|
|
3815
|
-
app.on("listening", () => {
|
|
3816
|
-
const openPromise = this.openAuthCodeUrl(scopes, options);
|
|
3817
|
-
const abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal;
|
|
3818
|
-
if (abortSignal) {
|
|
3819
|
-
abortSignal.addEventListener("abort", () => {
|
|
3820
|
-
cleanup();
|
|
3821
|
-
reject(new Error("Aborted"));
|
|
3822
|
-
});
|
|
3823
|
-
}
|
|
3824
|
-
openPromise.catch((e) => {
|
|
3825
|
-
cleanup();
|
|
3826
|
-
reject(e);
|
|
3827
|
-
});
|
|
3828
|
-
});
|
|
3829
|
-
});
|
|
3737
|
+
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3830
3738
|
}
|
|
3831
|
-
async
|
|
3832
|
-
// Initialize CryptoProvider instance
|
|
3833
|
-
const cryptoProvider = new msalNode__namespace.CryptoProvider();
|
|
3834
|
-
// Generate PKCE Codes before starting the authorization flow
|
|
3835
|
-
this.pkceCodes = await cryptoProvider.generatePkceCodes();
|
|
3836
|
-
const authCodeUrlParameters = {
|
|
3837
|
-
scopes: scopeArray,
|
|
3838
|
-
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3839
|
-
redirectUri: this.redirectUri,
|
|
3840
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3841
|
-
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3842
|
-
loginHint: this.loginHint,
|
|
3843
|
-
codeChallenge: this.pkceCodes.challenge,
|
|
3844
|
-
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3845
|
-
};
|
|
3846
|
-
const response = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).getAuthCodeUrl(authCodeUrlParameters);
|
|
3739
|
+
async doGetToken(scopes, options) {
|
|
3847
3740
|
try {
|
|
3848
|
-
|
|
3849
|
-
|
|
3741
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive({
|
|
3742
|
+
openBrowser: async (url) => {
|
|
3743
|
+
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
|
3744
|
+
},
|
|
3745
|
+
scopes,
|
|
3746
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3747
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3748
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3749
|
+
loginHint: this.loginHint,
|
|
3750
|
+
});
|
|
3751
|
+
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3850
3752
|
}
|
|
3851
|
-
catch (
|
|
3852
|
-
throw
|
|
3753
|
+
catch (err) {
|
|
3754
|
+
throw this.handleError(scopes, err, options);
|
|
3853
3755
|
}
|
|
3854
3756
|
}
|
|
3855
3757
|
}
|
|
3856
3758
|
|
|
3857
3759
|
// Copyright (c) Microsoft Corporation.
|
|
3760
|
+
// Licensed under the MIT license.
|
|
3858
3761
|
const logger$3 = credentialLogger("InteractiveBrowserCredential");
|
|
3859
3762
|
/**
|
|
3860
3763
|
* Enables authentication to Azure Active Directory inside of the web browser
|
|
@@ -3925,6 +3828,7 @@ class InteractiveBrowserCredential {
|
|
|
3925
3828
|
}
|
|
3926
3829
|
|
|
3927
3830
|
// Copyright (c) Microsoft Corporation.
|
|
3831
|
+
// Licensed under the MIT license.
|
|
3928
3832
|
/**
|
|
3929
3833
|
* MSAL device code client. Calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`.
|
|
3930
3834
|
* @internal
|
|
@@ -3957,6 +3861,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3957
3861
|
}
|
|
3958
3862
|
|
|
3959
3863
|
// Copyright (c) Microsoft Corporation.
|
|
3864
|
+
// Licensed under the MIT license.
|
|
3960
3865
|
const logger$2 = credentialLogger("DeviceCodeCredential");
|
|
3961
3866
|
/**
|
|
3962
3867
|
* Method that logs the user code from the DeviceCodeCredential.
|
|
@@ -4035,6 +3940,7 @@ class DeviceCodeCredential {
|
|
|
4035
3940
|
}
|
|
4036
3941
|
|
|
4037
3942
|
// Copyright (c) Microsoft Corporation.
|
|
3943
|
+
// Licensed under the MIT license.
|
|
4038
3944
|
/**
|
|
4039
3945
|
* 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`
|
|
4040
3946
|
* to trigger the authentication flow, and then respond based on the values obtained from the redirect callback
|
|
@@ -4078,6 +3984,7 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
4078
3984
|
}
|
|
4079
3985
|
|
|
4080
3986
|
// Copyright (c) Microsoft Corporation.
|
|
3987
|
+
// Licensed under the MIT license.
|
|
4081
3988
|
const logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
4082
3989
|
/**
|
|
4083
3990
|
* Enables authentication to Azure Active Directory using an authorization code
|
|
@@ -4133,6 +4040,7 @@ class AuthorizationCodeCredential {
|
|
|
4133
4040
|
}
|
|
4134
4041
|
|
|
4135
4042
|
// Copyright (c) Microsoft Corporation.
|
|
4043
|
+
// Licensed under the MIT license.
|
|
4136
4044
|
/**
|
|
4137
4045
|
* MSAL on behalf of flow. Calls to MSAL's confidential application's `acquireTokenOnBehalfOf` during `doGetToken`.
|
|
4138
4046
|
* @internal
|
|
@@ -4186,6 +4094,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4186
4094
|
}
|
|
4187
4095
|
|
|
4188
4096
|
// Copyright (c) Microsoft Corporation.
|
|
4097
|
+
// Licensed under the MIT license.
|
|
4189
4098
|
const credentialName = "OnBehalfOfCredential";
|
|
4190
4099
|
const logger = credentialLogger(credentialName);
|
|
4191
4100
|
/**
|
|
@@ -4221,6 +4130,7 @@ class OnBehalfOfCredential {
|
|
|
4221
4130
|
}
|
|
4222
4131
|
|
|
4223
4132
|
// Copyright (c) Microsoft Corporation.
|
|
4133
|
+
// Licensed under the MIT license.
|
|
4224
4134
|
/**
|
|
4225
4135
|
* Returns a new instance of the {@link DefaultAzureCredential}.
|
|
4226
4136
|
*/
|