@azure/identity 3.3.1-alpha.20230927.1 → 3.3.1-alpha.20231012.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/dist/index.js +79 -173
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.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 +8 -10
- 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
|
*/
|
|
@@ -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",
|
|
@@ -2716,6 +2722,7 @@ class AzureCliCredential {
|
|
|
2716
2722
|
}
|
|
2717
2723
|
|
|
2718
2724
|
// Copyright (c) Microsoft Corporation.
|
|
2725
|
+
// Licensed under the MIT license.
|
|
2719
2726
|
/**
|
|
2720
2727
|
* Easy to mock childProcess utils.
|
|
2721
2728
|
* @internal
|
|
@@ -2746,6 +2753,7 @@ const processUtils = {
|
|
|
2746
2753
|
};
|
|
2747
2754
|
|
|
2748
2755
|
// Copyright (c) Microsoft Corporation.
|
|
2756
|
+
// Licensed under the MIT license.
|
|
2749
2757
|
const logger$a = credentialLogger("AzurePowerShellCredential");
|
|
2750
2758
|
const isWindows = process.platform === "win32";
|
|
2751
2759
|
/**
|
|
@@ -2917,6 +2925,7 @@ class AzurePowerShellCredential {
|
|
|
2917
2925
|
}
|
|
2918
2926
|
|
|
2919
2927
|
// Copyright (c) Microsoft Corporation.
|
|
2928
|
+
// Licensed under the MIT license.
|
|
2920
2929
|
/**
|
|
2921
2930
|
* @internal
|
|
2922
2931
|
*/
|
|
@@ -2995,6 +3004,7 @@ class ChainedTokenCredential {
|
|
|
2995
3004
|
}
|
|
2996
3005
|
|
|
2997
3006
|
// Copyright (c) Microsoft Corporation.
|
|
3007
|
+
// Licensed under the MIT license.
|
|
2998
3008
|
const readFileAsync = util.promisify(fs.readFile);
|
|
2999
3009
|
/**
|
|
3000
3010
|
* Tries to asynchronously load a certificate from the given path.
|
|
@@ -3100,6 +3110,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
3100
3110
|
}
|
|
3101
3111
|
|
|
3102
3112
|
// Copyright (c) Microsoft Corporation.
|
|
3113
|
+
// Licensed under the MIT license.
|
|
3103
3114
|
const credentialName$2 = "ClientCertificateCredential";
|
|
3104
3115
|
const logger$8 = credentialLogger(credentialName$2);
|
|
3105
3116
|
/**
|
|
@@ -3154,6 +3165,7 @@ class ClientCertificateCredential {
|
|
|
3154
3165
|
}
|
|
3155
3166
|
|
|
3156
3167
|
// Copyright (c) Microsoft Corporation.
|
|
3168
|
+
// Licensed under the MIT license.
|
|
3157
3169
|
/**
|
|
3158
3170
|
* MSAL client secret client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
3159
3171
|
* @internal
|
|
@@ -3184,6 +3196,7 @@ class MsalClientSecret extends MsalNode {
|
|
|
3184
3196
|
}
|
|
3185
3197
|
|
|
3186
3198
|
// Copyright (c) Microsoft Corporation.
|
|
3199
|
+
// Licensed under the MIT license.
|
|
3187
3200
|
const logger$7 = credentialLogger("ClientSecretCredential");
|
|
3188
3201
|
/**
|
|
3189
3202
|
* Enables authentication to Azure Active Directory using a client secret
|
|
@@ -3233,6 +3246,7 @@ class ClientSecretCredential {
|
|
|
3233
3246
|
}
|
|
3234
3247
|
|
|
3235
3248
|
// Copyright (c) Microsoft Corporation.
|
|
3249
|
+
// Licensed under the MIT license.
|
|
3236
3250
|
/**
|
|
3237
3251
|
* MSAL username and password client. Calls to the MSAL's public application's `acquireTokenByUsernamePassword` during `doGetToken`.
|
|
3238
3252
|
* @internal
|
|
@@ -3263,6 +3277,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
3263
3277
|
}
|
|
3264
3278
|
|
|
3265
3279
|
// Copyright (c) Microsoft Corporation.
|
|
3280
|
+
// Licensed under the MIT license.
|
|
3266
3281
|
const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
3267
3282
|
/**
|
|
3268
3283
|
* Enables authentication to Azure Active Directory with a user's
|
|
@@ -3316,6 +3331,7 @@ class UsernamePasswordCredential {
|
|
|
3316
3331
|
}
|
|
3317
3332
|
|
|
3318
3333
|
// Copyright (c) Microsoft Corporation.
|
|
3334
|
+
// Licensed under the MIT license.
|
|
3319
3335
|
/**
|
|
3320
3336
|
* Contains the list of all supported environment variable names so that an
|
|
3321
3337
|
* appropriate error message can be generated when no credentials can be
|
|
@@ -3428,6 +3444,7 @@ class EnvironmentCredential {
|
|
|
3428
3444
|
}
|
|
3429
3445
|
|
|
3430
3446
|
// Copyright (c) Microsoft Corporation.
|
|
3447
|
+
// Licensed under the MIT license.
|
|
3431
3448
|
/**
|
|
3432
3449
|
* Mockable reference to the Developer CLI credential cliCredentialFunctions
|
|
3433
3450
|
* @internal
|
|
@@ -3459,7 +3476,7 @@ const developerCliCredentialInternals = {
|
|
|
3459
3476
|
}
|
|
3460
3477
|
return new Promise((resolve, reject) => {
|
|
3461
3478
|
try {
|
|
3462
|
-
|
|
3479
|
+
child_process.execFile("azd", [
|
|
3463
3480
|
"auth",
|
|
3464
3481
|
"token",
|
|
3465
3482
|
"--output",
|
|
@@ -3583,6 +3600,7 @@ class AzureDeveloperCliCredential {
|
|
|
3583
3600
|
}
|
|
3584
3601
|
|
|
3585
3602
|
// Copyright (c) Microsoft Corporation.
|
|
3603
|
+
// Licensed under the MIT license.
|
|
3586
3604
|
/**
|
|
3587
3605
|
* A shim around ManagedIdentityCredential that adapts it to accept
|
|
3588
3606
|
* `DefaultAzureCredentialOptions`.
|
|
@@ -3679,12 +3697,13 @@ class DefaultAzureCredential extends ChainedTokenCredential {
|
|
|
3679
3697
|
}
|
|
3680
3698
|
|
|
3681
3699
|
// Copyright (c) Microsoft Corporation.
|
|
3700
|
+
// Licensed under the MIT license.
|
|
3682
3701
|
/**
|
|
3683
3702
|
* A call to open(), but mockable
|
|
3684
3703
|
* @internal
|
|
3685
3704
|
*/
|
|
3686
3705
|
const interactiveBrowserMockable = {
|
|
3687
|
-
open
|
|
3706
|
+
open,
|
|
3688
3707
|
};
|
|
3689
3708
|
/**
|
|
3690
3709
|
* 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`
|
|
@@ -3694,151 +3713,31 @@ const interactiveBrowserMockable = {
|
|
|
3694
3713
|
class MsalOpenBrowser extends MsalNode {
|
|
3695
3714
|
constructor(options) {
|
|
3696
3715
|
super(options);
|
|
3697
|
-
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3698
|
-
this.redirectUri = options.redirectUri;
|
|
3699
3716
|
this.loginHint = options.loginHint;
|
|
3700
|
-
|
|
3701
|
-
this.port = parseInt(url.port);
|
|
3702
|
-
if (isNaN(this.port)) {
|
|
3703
|
-
this.port = 80;
|
|
3704
|
-
}
|
|
3705
|
-
this.hostname = url.hostname;
|
|
3706
|
-
}
|
|
3707
|
-
async acquireTokenByCode(request, enableCae) {
|
|
3708
|
-
return this.getApp("public", enableCae).acquireTokenByCode(request);
|
|
3709
|
-
}
|
|
3710
|
-
doGetToken(scopes, options) {
|
|
3711
|
-
return new Promise((resolve, reject) => {
|
|
3712
|
-
const socketToDestroy = [];
|
|
3713
|
-
const requestListener = (req, res) => {
|
|
3714
|
-
var _a;
|
|
3715
|
-
if (!req.url) {
|
|
3716
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3717
|
-
return;
|
|
3718
|
-
}
|
|
3719
|
-
let url;
|
|
3720
|
-
try {
|
|
3721
|
-
url = new URL(req.url, this.redirectUri);
|
|
3722
|
-
}
|
|
3723
|
-
catch (e) {
|
|
3724
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3725
|
-
return;
|
|
3726
|
-
}
|
|
3727
|
-
const tokenRequest = {
|
|
3728
|
-
code: url.searchParams.get("code"),
|
|
3729
|
-
redirectUri: this.redirectUri,
|
|
3730
|
-
scopes: scopes,
|
|
3731
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3732
|
-
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
3733
|
-
};
|
|
3734
|
-
this.acquireTokenByCode(tokenRequest, options === null || options === void 0 ? void 0 : options.enableCae)
|
|
3735
|
-
.then((authResponse) => {
|
|
3736
|
-
if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.account) {
|
|
3737
|
-
this.account = msalToPublic(this.clientId, authResponse.account);
|
|
3738
|
-
}
|
|
3739
|
-
const successMessage = `Authentication Complete. You can close the browser and return to the application.`;
|
|
3740
|
-
if (authResponse && authResponse.expiresOn) {
|
|
3741
|
-
const expiresOnTimestamp = authResponse === null || authResponse === void 0 ? void 0 : authResponse.expiresOn.valueOf();
|
|
3742
|
-
res.writeHead(200);
|
|
3743
|
-
res.end(successMessage);
|
|
3744
|
-
this.logger.getToken.info(formatSuccess(scopes));
|
|
3745
|
-
resolve({
|
|
3746
|
-
expiresOnTimestamp,
|
|
3747
|
-
token: authResponse.accessToken,
|
|
3748
|
-
});
|
|
3749
|
-
}
|
|
3750
|
-
else {
|
|
3751
|
-
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3752
|
-
res.writeHead(500);
|
|
3753
|
-
res.end(errorMessage);
|
|
3754
|
-
this.logger.getToken.info(errorMessage);
|
|
3755
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3756
|
-
}
|
|
3757
|
-
cleanup();
|
|
3758
|
-
return;
|
|
3759
|
-
})
|
|
3760
|
-
.catch(() => {
|
|
3761
|
-
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3762
|
-
res.writeHead(500);
|
|
3763
|
-
res.end(errorMessage);
|
|
3764
|
-
this.logger.getToken.info(errorMessage);
|
|
3765
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3766
|
-
cleanup();
|
|
3767
|
-
});
|
|
3768
|
-
};
|
|
3769
|
-
const app = http__default["default"].createServer(requestListener);
|
|
3770
|
-
const server = stoppable__default["default"](app);
|
|
3771
|
-
const listen = app.listen(this.port, this.hostname, () => this.logger.info(`InteractiveBrowserCredential listening on port ${this.port}!`));
|
|
3772
|
-
function cleanup() {
|
|
3773
|
-
if (listen) {
|
|
3774
|
-
listen.close();
|
|
3775
|
-
}
|
|
3776
|
-
for (const socket of socketToDestroy) {
|
|
3777
|
-
socket.destroy();
|
|
3778
|
-
}
|
|
3779
|
-
if (server) {
|
|
3780
|
-
server.close();
|
|
3781
|
-
server.stop();
|
|
3782
|
-
}
|
|
3783
|
-
}
|
|
3784
|
-
app.on("connection", (socket) => socketToDestroy.push(socket));
|
|
3785
|
-
app.on("error", (err) => {
|
|
3786
|
-
cleanup();
|
|
3787
|
-
const code = err.code;
|
|
3788
|
-
if (code === "EACCES" || code === "EADDRINUSE") {
|
|
3789
|
-
reject(new CredentialUnavailableError([
|
|
3790
|
-
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3791
|
-
`Try sending a redirect URI with a different port, as follows:`,
|
|
3792
|
-
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`',
|
|
3793
|
-
].join(" ")));
|
|
3794
|
-
}
|
|
3795
|
-
else {
|
|
3796
|
-
reject(new CredentialUnavailableError(`InteractiveBrowserCredential: Failed to start the necessary web server. Error: ${err.message}`));
|
|
3797
|
-
}
|
|
3798
|
-
});
|
|
3799
|
-
app.on("listening", () => {
|
|
3800
|
-
const openPromise = this.openAuthCodeUrl(scopes, options);
|
|
3801
|
-
const abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal;
|
|
3802
|
-
if (abortSignal) {
|
|
3803
|
-
abortSignal.addEventListener("abort", () => {
|
|
3804
|
-
cleanup();
|
|
3805
|
-
reject(new Error("Aborted"));
|
|
3806
|
-
});
|
|
3807
|
-
}
|
|
3808
|
-
openPromise.catch((e) => {
|
|
3809
|
-
cleanup();
|
|
3810
|
-
reject(e);
|
|
3811
|
-
});
|
|
3812
|
-
});
|
|
3813
|
-
});
|
|
3717
|
+
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3814
3718
|
}
|
|
3815
|
-
async
|
|
3816
|
-
// Initialize CryptoProvider instance
|
|
3817
|
-
const cryptoProvider = new msalNode__namespace.CryptoProvider();
|
|
3818
|
-
// Generate PKCE Codes before starting the authorization flow
|
|
3819
|
-
this.pkceCodes = await cryptoProvider.generatePkceCodes();
|
|
3820
|
-
const authCodeUrlParameters = {
|
|
3821
|
-
scopes: scopeArray,
|
|
3822
|
-
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3823
|
-
redirectUri: this.redirectUri,
|
|
3824
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3825
|
-
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3826
|
-
loginHint: this.loginHint,
|
|
3827
|
-
codeChallenge: this.pkceCodes.challenge,
|
|
3828
|
-
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3829
|
-
};
|
|
3830
|
-
const response = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).getAuthCodeUrl(authCodeUrlParameters);
|
|
3719
|
+
async doGetToken(scopes, options) {
|
|
3831
3720
|
try {
|
|
3832
|
-
|
|
3833
|
-
|
|
3721
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive({
|
|
3722
|
+
openBrowser: async (url) => {
|
|
3723
|
+
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
|
3724
|
+
},
|
|
3725
|
+
scopes,
|
|
3726
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3727
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3728
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3729
|
+
loginHint: this.loginHint,
|
|
3730
|
+
});
|
|
3731
|
+
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3834
3732
|
}
|
|
3835
|
-
catch (
|
|
3836
|
-
throw
|
|
3733
|
+
catch (err) {
|
|
3734
|
+
throw this.handleError(scopes, err, options);
|
|
3837
3735
|
}
|
|
3838
3736
|
}
|
|
3839
3737
|
}
|
|
3840
3738
|
|
|
3841
3739
|
// Copyright (c) Microsoft Corporation.
|
|
3740
|
+
// Licensed under the MIT license.
|
|
3842
3741
|
const logger$3 = credentialLogger("InteractiveBrowserCredential");
|
|
3843
3742
|
/**
|
|
3844
3743
|
* Enables authentication to Azure Active Directory inside of the web browser
|
|
@@ -3909,6 +3808,7 @@ class InteractiveBrowserCredential {
|
|
|
3909
3808
|
}
|
|
3910
3809
|
|
|
3911
3810
|
// Copyright (c) Microsoft Corporation.
|
|
3811
|
+
// Licensed under the MIT license.
|
|
3912
3812
|
/**
|
|
3913
3813
|
* MSAL device code client. Calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`.
|
|
3914
3814
|
* @internal
|
|
@@ -3941,6 +3841,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3941
3841
|
}
|
|
3942
3842
|
|
|
3943
3843
|
// Copyright (c) Microsoft Corporation.
|
|
3844
|
+
// Licensed under the MIT license.
|
|
3944
3845
|
const logger$2 = credentialLogger("DeviceCodeCredential");
|
|
3945
3846
|
/**
|
|
3946
3847
|
* Method that logs the user code from the DeviceCodeCredential.
|
|
@@ -4019,6 +3920,7 @@ class DeviceCodeCredential {
|
|
|
4019
3920
|
}
|
|
4020
3921
|
|
|
4021
3922
|
// Copyright (c) Microsoft Corporation.
|
|
3923
|
+
// Licensed under the MIT license.
|
|
4022
3924
|
/**
|
|
4023
3925
|
* 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`
|
|
4024
3926
|
* to trigger the authentication flow, and then respond based on the values obtained from the redirect callback
|
|
@@ -4062,6 +3964,7 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
4062
3964
|
}
|
|
4063
3965
|
|
|
4064
3966
|
// Copyright (c) Microsoft Corporation.
|
|
3967
|
+
// Licensed under the MIT license.
|
|
4065
3968
|
const logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
4066
3969
|
/**
|
|
4067
3970
|
* Enables authentication to Azure Active Directory using an authorization code
|
|
@@ -4117,6 +4020,7 @@ class AuthorizationCodeCredential {
|
|
|
4117
4020
|
}
|
|
4118
4021
|
|
|
4119
4022
|
// Copyright (c) Microsoft Corporation.
|
|
4023
|
+
// Licensed under the MIT license.
|
|
4120
4024
|
/**
|
|
4121
4025
|
* MSAL on behalf of flow. Calls to MSAL's confidential application's `acquireTokenOnBehalfOf` during `doGetToken`.
|
|
4122
4026
|
* @internal
|
|
@@ -4170,6 +4074,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4170
4074
|
}
|
|
4171
4075
|
|
|
4172
4076
|
// Copyright (c) Microsoft Corporation.
|
|
4077
|
+
// Licensed under the MIT license.
|
|
4173
4078
|
const credentialName = "OnBehalfOfCredential";
|
|
4174
4079
|
const logger = credentialLogger(credentialName);
|
|
4175
4080
|
/**
|
|
@@ -4205,6 +4110,7 @@ class OnBehalfOfCredential {
|
|
|
4205
4110
|
}
|
|
4206
4111
|
|
|
4207
4112
|
// Copyright (c) Microsoft Corporation.
|
|
4113
|
+
// Licensed under the MIT license.
|
|
4208
4114
|
/**
|
|
4209
4115
|
* Returns a new instance of the {@link DefaultAzureCredential}.
|
|
4210
4116
|
*/
|