@azure/identity 3.3.1 → 3.3.2-alpha.20231016.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/README.md +14 -14
- package/dist/index.js +129 -219
- 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/authorityValidationOptions.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +4 -4
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +4 -4
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +5 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.js +3 -3
- package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +2 -2
- 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 +5 -5
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js +4 -4
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +3 -3
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +5 -5
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +6 -6
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +3 -2
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js +2 -2
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.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 +4 -4
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js +2 -2
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.js +5 -5
- package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredentialOptions.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/dist-esm/src/tokenCredentialOptions.js.map +1 -1
- package/package.json +15 -15
- package/types/identity.d.ts +69 -67
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.
|
|
@@ -1960,10 +1958,10 @@ const logger$h = credentialLogger("ClientAssertionCredential");
|
|
|
1960
1958
|
class ClientAssertionCredential {
|
|
1961
1959
|
/**
|
|
1962
1960
|
* Creates an instance of the ClientAssertionCredential with the details
|
|
1963
|
-
* needed to authenticate against
|
|
1961
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
1964
1962
|
* assertion provided by the developer through the `getAssertion` function parameter.
|
|
1965
1963
|
*
|
|
1966
|
-
* @param tenantId - The
|
|
1964
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
1967
1965
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
1968
1966
|
* @param getAssertion - A function that retrieves the assertion for the credential to use.
|
|
1969
1967
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -1979,7 +1977,7 @@ class ClientAssertionCredential {
|
|
|
1979
1977
|
this.msalFlow = new MsalClientAssertion(Object.assign(Object.assign({}, options), { logger: logger$h, clientId: this.clientId, tenantId: this.tenantId, tokenCredentialOptions: this.options, getAssertion }));
|
|
1980
1978
|
}
|
|
1981
1979
|
/**
|
|
1982
|
-
* Authenticates with
|
|
1980
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
1983
1981
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
1984
1982
|
*
|
|
1985
1983
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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
|
|
@@ -2019,14 +2018,14 @@ const logger$g = credentialLogger(credentialName$3);
|
|
|
2019
2018
|
* Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
|
|
2020
2019
|
* each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
|
|
2021
2020
|
* need to worry about storing and securing sensitive credentials themselves.
|
|
2022
|
-
* The WorkloadIdentityCredential supports
|
|
2021
|
+
* The WorkloadIdentityCredential supports Microsoft Entra Workload ID authentication on Azure Kubernetes and acquires
|
|
2023
2022
|
* a token using the SACs available in the Azure Kubernetes environment.
|
|
2024
|
-
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">
|
|
2025
|
-
* Workload
|
|
2023
|
+
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Microsoft Entra
|
|
2024
|
+
* Workload ID</a> for more information.
|
|
2026
2025
|
*/
|
|
2027
2026
|
class WorkloadIdentityCredential {
|
|
2028
2027
|
/**
|
|
2029
|
-
* WorkloadIdentityCredential supports
|
|
2028
|
+
* WorkloadIdentityCredential supports Microsoft Entra Workload ID on Kubernetes.
|
|
2030
2029
|
*
|
|
2031
2030
|
* @param options - The identity client options to use for authentication.
|
|
2032
2031
|
*/
|
|
@@ -2050,7 +2049,7 @@ class WorkloadIdentityCredential {
|
|
|
2050
2049
|
}
|
|
2051
2050
|
}
|
|
2052
2051
|
/**
|
|
2053
|
-
* Authenticates with
|
|
2052
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2054
2053
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2055
2054
|
*
|
|
2056
2055
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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"]}]}',
|
|
@@ -2384,7 +2388,7 @@ class ManagedIdentityCredential {
|
|
|
2384
2388
|
}
|
|
2385
2389
|
}
|
|
2386
2390
|
/**
|
|
2387
|
-
* Authenticates with
|
|
2391
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2388
2392
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2389
2393
|
* If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
|
|
2390
2394
|
*
|
|
@@ -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",
|
|
@@ -2660,7 +2666,7 @@ class AzureCliCredential {
|
|
|
2660
2666
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2661
2667
|
}
|
|
2662
2668
|
/**
|
|
2663
|
-
* Authenticates with
|
|
2669
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2664
2670
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2665
2671
|
*
|
|
2666
2672
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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
|
],
|
|
@@ -2881,7 +2893,7 @@ class AzurePowerShellCredential {
|
|
|
2881
2893
|
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
|
|
2882
2894
|
}
|
|
2883
2895
|
/**
|
|
2884
|
-
* Authenticates with
|
|
2896
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2885
2897
|
* If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
|
|
2886
2898
|
*
|
|
2887
2899
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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,10 +3122,11 @@ 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
|
/**
|
|
3114
|
-
* Enables authentication to
|
|
3129
|
+
* Enables authentication to Microsoft Entra ID using a PEM-encoded
|
|
3115
3130
|
* certificate that is assigned to an App Registration. More information
|
|
3116
3131
|
* on how to configure certificate authentication can be found here:
|
|
3117
3132
|
*
|
|
@@ -3145,7 +3160,7 @@ class ClientCertificateCredential {
|
|
|
3145
3160
|
tenantId, sendCertificateChain: options.sendCertificateChain, tokenCredentialOptions: options }));
|
|
3146
3161
|
}
|
|
3147
3162
|
/**
|
|
3148
|
-
* Authenticates with
|
|
3163
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3149
3164
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3150
3165
|
*
|
|
3151
3166
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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,22 +3208,23 @@ 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
|
-
* Enables authentication to
|
|
3214
|
+
* Enables authentication to Microsoft Entra ID using a client secret
|
|
3198
3215
|
* that was generated for an App Registration. More information on how
|
|
3199
3216
|
* to configure a client secret can be found here:
|
|
3200
3217
|
*
|
|
3201
|
-
* https://
|
|
3218
|
+
* https://learn.microsoft.com/azure/active-directory/develop/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
|
|
3202
3219
|
*
|
|
3203
3220
|
*/
|
|
3204
3221
|
class ClientSecretCredential {
|
|
3205
3222
|
/**
|
|
3206
3223
|
* Creates an instance of the ClientSecretCredential with the details
|
|
3207
|
-
* needed to authenticate against
|
|
3224
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
3208
3225
|
* secret.
|
|
3209
3226
|
*
|
|
3210
|
-
* @param tenantId - The
|
|
3227
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
3211
3228
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3212
3229
|
* @param clientSecret - A client secret that was generated for the App Registration.
|
|
3213
3230
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -3224,7 +3241,7 @@ class ClientSecretCredential {
|
|
|
3224
3241
|
clientSecret, tokenCredentialOptions: options }));
|
|
3225
3242
|
}
|
|
3226
3243
|
/**
|
|
3227
|
-
* Authenticates with
|
|
3244
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3228
3245
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3229
3246
|
*
|
|
3230
3247
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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,9 +3289,10 @@ 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
|
-
* Enables authentication to
|
|
3295
|
+
* Enables authentication to Microsoft Entra ID with a user's
|
|
3277
3296
|
* username and password. This credential requires a high degree of
|
|
3278
3297
|
* trust so you should only use it when other, more secure credential
|
|
3279
3298
|
* types can't be used.
|
|
@@ -3281,10 +3300,10 @@ const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
|
3281
3300
|
class UsernamePasswordCredential {
|
|
3282
3301
|
/**
|
|
3283
3302
|
* Creates an instance of the UsernamePasswordCredential with the details
|
|
3284
|
-
* needed to authenticate against
|
|
3303
|
+
* needed to authenticate against Microsoft Entra ID with a username
|
|
3285
3304
|
* and password.
|
|
3286
3305
|
*
|
|
3287
|
-
* @param tenantId - The
|
|
3306
|
+
* @param tenantId - The Microsoft Entra tenant (directory).
|
|
3288
3307
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3289
3308
|
* @param username - The user account's e-mail address (user name).
|
|
3290
3309
|
* @param password - The user account's account password
|
|
@@ -3303,7 +3322,7 @@ class UsernamePasswordCredential {
|
|
|
3303
3322
|
password, tokenCredentialOptions: options || {} }));
|
|
3304
3323
|
}
|
|
3305
3324
|
/**
|
|
3306
|
-
* Authenticates with
|
|
3325
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3307
3326
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3308
3327
|
*
|
|
3309
3328
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -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
|
|
@@ -3349,7 +3369,7 @@ function getAdditionallyAllowedTenants() {
|
|
|
3349
3369
|
const credentialName$1 = "EnvironmentCredential";
|
|
3350
3370
|
const logger$5 = credentialLogger(credentialName$1);
|
|
3351
3371
|
/**
|
|
3352
|
-
* Enables authentication to
|
|
3372
|
+
* Enables authentication to Microsoft Entra ID using a client secret or certificate, or as a user
|
|
3353
3373
|
* with a username and password.
|
|
3354
3374
|
*/
|
|
3355
3375
|
class EnvironmentCredential {
|
|
@@ -3357,7 +3377,7 @@ class EnvironmentCredential {
|
|
|
3357
3377
|
* Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
|
|
3358
3378
|
*
|
|
3359
3379
|
* Required environment variables:
|
|
3360
|
-
* - `AZURE_TENANT_ID`: The
|
|
3380
|
+
* - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
|
|
3361
3381
|
* - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
|
|
3362
3382
|
*
|
|
3363
3383
|
* If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
|
|
@@ -3408,7 +3428,7 @@ class EnvironmentCredential {
|
|
|
3408
3428
|
}
|
|
3409
3429
|
}
|
|
3410
3430
|
/**
|
|
3411
|
-
* Authenticates with
|
|
3431
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3412
3432
|
*
|
|
3413
3433
|
* @param scopes - The list of scopes for which the token will have access.
|
|
3414
3434
|
* @param options - Optional parameters. See {@link GetTokenOptions}.
|
|
@@ -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",
|
|
@@ -3492,11 +3513,11 @@ const logger$4 = credentialLogger("AzureDeveloperCliCredential");
|
|
|
3492
3513
|
* Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
|
|
3493
3514
|
* resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
|
|
3494
3515
|
* to Azure developers. It allows users to authenticate as a user and/or a service principal against
|
|
3495
|
-
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">
|
|
3496
|
-
*
|
|
3516
|
+
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">Microsoft Entra ID</a>. The
|
|
3517
|
+
* AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
|
|
3497
3518
|
* the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
|
|
3498
3519
|
* service principal and executes an Azure CLI command underneath to authenticate the application against
|
|
3499
|
-
*
|
|
3520
|
+
* Microsoft Entra ID.
|
|
3500
3521
|
*
|
|
3501
3522
|
* <h2> Configure AzureDeveloperCliCredential </h2>
|
|
3502
3523
|
*
|
|
@@ -3531,7 +3552,7 @@ class AzureDeveloperCliCredential {
|
|
|
3531
3552
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
3532
3553
|
}
|
|
3533
3554
|
/**
|
|
3534
|
-
* Authenticates with
|
|
3555
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3535
3556
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3536
3557
|
*
|
|
3537
3558
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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,166 +3733,46 @@ 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
|
-
* Enables authentication to
|
|
3763
|
+
* Enables authentication to Microsoft Entra ID inside of the web browser
|
|
3861
3764
|
* using the interactive login flow.
|
|
3862
3765
|
*/
|
|
3863
3766
|
class InteractiveBrowserCredential {
|
|
3864
3767
|
/**
|
|
3865
3768
|
* Creates an instance of InteractiveBrowserCredential with the details needed.
|
|
3866
3769
|
*
|
|
3867
|
-
* This credential uses the [Authorization Code Flow](https://
|
|
3770
|
+
* This credential uses the [Authorization Code Flow](https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
|
3868
3771
|
* On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
|
|
3869
3772
|
* On browsers, it authenticates via popups. The `loginStyle` optional parameter can be set to `redirect` to authenticate by redirecting the user to an Azure secure login page, which then will redirect the user back to the web application where the authentication started.
|
|
3870
3773
|
*
|
|
3871
|
-
* For Node.js, if a `clientId` is provided, the
|
|
3872
|
-
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://
|
|
3774
|
+
* For Node.js, if a `clientId` is provided, the Microsoft Entra application will need to be configured to have a "Mobile and desktop applications" redirect endpoint.
|
|
3775
|
+
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://learn.microsoft.com/azure/active-directory/develop/scenario-desktop-app-registration#redirect-uris).
|
|
3873
3776
|
*
|
|
3874
3777
|
* @param options - Options for configuring the client which makes the authentication requests.
|
|
3875
3778
|
*/
|
|
@@ -3884,7 +3787,7 @@ class InteractiveBrowserCredential {
|
|
|
3884
3787
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3885
3788
|
}
|
|
3886
3789
|
/**
|
|
3887
|
-
* Authenticates with
|
|
3790
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3888
3791
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3889
3792
|
*
|
|
3890
3793
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3903,7 +3806,7 @@ class InteractiveBrowserCredential {
|
|
|
3903
3806
|
});
|
|
3904
3807
|
}
|
|
3905
3808
|
/**
|
|
3906
|
-
* Authenticates with
|
|
3809
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3907
3810
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3908
3811
|
*
|
|
3909
3812
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -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.
|
|
@@ -3966,13 +3871,13 @@ function defaultDeviceCodePromptCallback(deviceCodeInfo) {
|
|
|
3966
3871
|
console.log(deviceCodeInfo.message);
|
|
3967
3872
|
}
|
|
3968
3873
|
/**
|
|
3969
|
-
* Enables authentication to
|
|
3874
|
+
* Enables authentication to Microsoft Entra ID using a device code
|
|
3970
3875
|
* that the user can enter into https://microsoft.com/devicelogin.
|
|
3971
3876
|
*/
|
|
3972
3877
|
class DeviceCodeCredential {
|
|
3973
3878
|
/**
|
|
3974
3879
|
* Creates an instance of DeviceCodeCredential with the details needed
|
|
3975
|
-
* to initiate the device code authorization flow with
|
|
3880
|
+
* to initiate the device code authorization flow with Microsoft Entra ID.
|
|
3976
3881
|
*
|
|
3977
3882
|
* A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
|
|
3978
3883
|
*
|
|
@@ -3997,7 +3902,7 @@ class DeviceCodeCredential {
|
|
|
3997
3902
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3998
3903
|
}
|
|
3999
3904
|
/**
|
|
4000
|
-
* Authenticates with
|
|
3905
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4001
3906
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4002
3907
|
*
|
|
4003
3908
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -4016,7 +3921,7 @@ class DeviceCodeCredential {
|
|
|
4016
3921
|
});
|
|
4017
3922
|
}
|
|
4018
3923
|
/**
|
|
4019
|
-
* Authenticates with
|
|
3924
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4020
3925
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4021
3926
|
*
|
|
4022
3927
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -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,13 +3984,14 @@ 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
|
-
* Enables authentication to
|
|
3990
|
+
* Enables authentication to Microsoft Entra ID using an authorization code
|
|
4084
3991
|
* that was obtained through the authorization code flow, described in more detail
|
|
4085
|
-
* in the
|
|
3992
|
+
* in the Microsoft Entra ID documentation:
|
|
4086
3993
|
*
|
|
4087
|
-
* https://
|
|
3994
|
+
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
|
4088
3995
|
*/
|
|
4089
3996
|
class AuthorizationCodeCredential {
|
|
4090
3997
|
/**
|
|
@@ -4115,7 +4022,7 @@ class AuthorizationCodeCredential {
|
|
|
4115
4022
|
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
4116
4023
|
}
|
|
4117
4024
|
/**
|
|
4118
|
-
* Authenticates with
|
|
4025
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4119
4026
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4120
4027
|
*
|
|
4121
4028
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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,10 +4094,11 @@ 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
|
/**
|
|
4192
|
-
* Enables authentication to
|
|
4101
|
+
* Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
|
|
4193
4102
|
*/
|
|
4194
4103
|
class OnBehalfOfCredential {
|
|
4195
4104
|
constructor(options) {
|
|
@@ -4205,7 +4114,7 @@ class OnBehalfOfCredential {
|
|
|
4205
4114
|
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
4206
4115
|
}
|
|
4207
4116
|
/**
|
|
4208
|
-
* Authenticates with
|
|
4117
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4209
4118
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4210
4119
|
*
|
|
4211
4120
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -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
|
*/
|