@azure/identity 3.3.2-alpha.20231017.9 → 3.4.0
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 +217 -123
- 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 +1 -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 +4 -4
- 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 +1 -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 +1 -1
- 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 +142 -16
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/utils.js +4 -3
- 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 +16 -15
- package/types/identity.d.ts +66 -68
- package/dist-esm/src/msal/utils.browser.js +0 -236
- package/dist-esm/src/msal/utils.browser.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var msalNode = require('@azure/msal-node');
|
|
4
6
|
var logger$o = require('@azure/logger');
|
|
7
|
+
var msalCommon = require('@azure/msal-common');
|
|
5
8
|
var abortController = require('@azure/abort-controller');
|
|
6
9
|
var coreUtil = require('@azure/core-util');
|
|
10
|
+
var uuid = require('uuid');
|
|
7
11
|
var coreClient = require('@azure/core-client');
|
|
8
12
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
9
13
|
var coreTracing = require('@azure/core-tracing');
|
|
@@ -15,9 +19,14 @@ var https = require('https');
|
|
|
15
19
|
var child_process = require('child_process');
|
|
16
20
|
var crypto = require('crypto');
|
|
17
21
|
var util = require('util');
|
|
22
|
+
var http = require('http');
|
|
18
23
|
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 }; }
|
|
19
27
|
|
|
20
|
-
function
|
|
28
|
+
function _interopNamespace(e) {
|
|
29
|
+
if (e && e.__esModule) return e;
|
|
21
30
|
var n = Object.create(null);
|
|
22
31
|
if (e) {
|
|
23
32
|
Object.keys(e).forEach(function (k) {
|
|
@@ -30,12 +39,21 @@ function _interopNamespaceDefault(e) {
|
|
|
30
39
|
}
|
|
31
40
|
});
|
|
32
41
|
}
|
|
33
|
-
n
|
|
42
|
+
n["default"] = e;
|
|
34
43
|
return Object.freeze(n);
|
|
35
44
|
}
|
|
36
45
|
|
|
37
|
-
var
|
|
38
|
-
var
|
|
46
|
+
var msalNode__namespace = /*#__PURE__*/_interopNamespace(msalNode);
|
|
47
|
+
var msalCommon__namespace = /*#__PURE__*/_interopNamespace(msalCommon);
|
|
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);
|
|
39
57
|
|
|
40
58
|
// Copyright (c) Microsoft Corporation.
|
|
41
59
|
// Licensed under the MIT license.
|
|
@@ -157,7 +175,6 @@ class AuthenticationRequiredError extends Error {
|
|
|
157
175
|
}
|
|
158
176
|
|
|
159
177
|
// Copyright (c) Microsoft Corporation.
|
|
160
|
-
// Licensed under the MIT license.
|
|
161
178
|
/**
|
|
162
179
|
* The AzureLogger used for all clients within the identity package
|
|
163
180
|
*/
|
|
@@ -240,7 +257,7 @@ function credentialLogger(title, log = logger$n) {
|
|
|
240
257
|
/**
|
|
241
258
|
* Current version of the `@azure/identity` package.
|
|
242
259
|
*/
|
|
243
|
-
const SDK_VERSION = `3.
|
|
260
|
+
const SDK_VERSION = `3.4.0`;
|
|
244
261
|
/**
|
|
245
262
|
* The default client ID for authentication
|
|
246
263
|
* @internal
|
|
@@ -288,7 +305,6 @@ const CACHE_CAE_SUFFIX = ".cae";
|
|
|
288
305
|
const CACHE_NON_CAE_SUFFIX = ".nocae";
|
|
289
306
|
|
|
290
307
|
// Copyright (c) Microsoft Corporation.
|
|
291
|
-
// Licensed under the MIT license.
|
|
292
308
|
/**
|
|
293
309
|
* Latest AuthenticationRecord version
|
|
294
310
|
* @internal
|
|
@@ -407,7 +423,7 @@ class MsalBaseUtilities {
|
|
|
407
423
|
* Generates a UUID
|
|
408
424
|
*/
|
|
409
425
|
generateUuid() {
|
|
410
|
-
return
|
|
426
|
+
return uuid.v4();
|
|
411
427
|
}
|
|
412
428
|
/**
|
|
413
429
|
* Handles the MSAL authentication result.
|
|
@@ -518,7 +534,6 @@ function deserializeAuthenticationRecord(serializedRecord) {
|
|
|
518
534
|
}
|
|
519
535
|
|
|
520
536
|
// Copyright (c) Microsoft Corporation.
|
|
521
|
-
// Licensed under the MIT license.
|
|
522
537
|
function createConfigurationErrorMessage(tenantId) {
|
|
523
538
|
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.`;
|
|
524
539
|
}
|
|
@@ -552,7 +567,6 @@ function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowe
|
|
|
552
567
|
}
|
|
553
568
|
|
|
554
569
|
// Copyright (c) Microsoft Corporation.
|
|
555
|
-
// Licensed under the MIT license.
|
|
556
570
|
/**
|
|
557
571
|
* @internal
|
|
558
572
|
*/
|
|
@@ -604,7 +618,6 @@ function getIdentityTokenEndpointSuffix(tenantId) {
|
|
|
604
618
|
}
|
|
605
619
|
|
|
606
620
|
// Copyright (c) Microsoft Corporation.
|
|
607
|
-
// Licensed under the MIT license.
|
|
608
621
|
/**
|
|
609
622
|
* Creates a span using the global tracer.
|
|
610
623
|
* @internal
|
|
@@ -625,7 +638,6 @@ const azureArcAPIVersion = "2019-11-01";
|
|
|
625
638
|
const azureFabricVersion = "2019-07-01-preview";
|
|
626
639
|
|
|
627
640
|
// Copyright (c) Microsoft Corporation.
|
|
628
|
-
// Licensed under the MIT license.
|
|
629
641
|
/**
|
|
630
642
|
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
|
631
643
|
* These are GET requests that require sending a `resource` parameter on the query.
|
|
@@ -676,7 +688,6 @@ function parseExpirationTimestamp(body) {
|
|
|
676
688
|
}
|
|
677
689
|
|
|
678
690
|
// Copyright (c) Microsoft Corporation.
|
|
679
|
-
// Licensed under the MIT license.
|
|
680
691
|
const noCorrelationId = "noCorrelationId";
|
|
681
692
|
/**
|
|
682
693
|
* @internal
|
|
@@ -1021,7 +1032,6 @@ var RegionalAuthority;
|
|
|
1021
1032
|
})(RegionalAuthority || (RegionalAuthority = {}));
|
|
1022
1033
|
|
|
1023
1034
|
// Copyright (c) Microsoft Corporation.
|
|
1024
|
-
// Licensed under the MIT license.
|
|
1025
1035
|
/**
|
|
1026
1036
|
* The current persistence provider, undefined by default.
|
|
1027
1037
|
* @internal
|
|
@@ -1156,10 +1166,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1156
1166
|
};
|
|
1157
1167
|
}
|
|
1158
1168
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1159
|
-
this.caeApp.public = new
|
|
1169
|
+
this.caeApp.public = new msalNode__namespace.PublicClientApplication(this.msalConfig);
|
|
1160
1170
|
}
|
|
1161
1171
|
else {
|
|
1162
|
-
this.app.public = new
|
|
1172
|
+
this.app.public = new msalNode__namespace.PublicClientApplication(this.msalConfig);
|
|
1163
1173
|
}
|
|
1164
1174
|
if (this.getAssertion) {
|
|
1165
1175
|
this.msalConfig.auth.clientAssertion = await this.getAssertion();
|
|
@@ -1169,10 +1179,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1169
1179
|
this.msalConfig.auth.clientAssertion ||
|
|
1170
1180
|
this.msalConfig.auth.clientCertificate) {
|
|
1171
1181
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1172
|
-
this.caeApp.confidential = new
|
|
1182
|
+
this.caeApp.confidential = new msalNode__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1173
1183
|
}
|
|
1174
1184
|
else {
|
|
1175
|
-
this.app.confidential = new
|
|
1185
|
+
this.app.confidential = new msalNode__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1176
1186
|
}
|
|
1177
1187
|
}
|
|
1178
1188
|
else {
|
|
@@ -1303,7 +1313,6 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1303
1313
|
}
|
|
1304
1314
|
|
|
1305
1315
|
// Copyright (c) Microsoft Corporation.
|
|
1306
|
-
// Licensed under the MIT license.
|
|
1307
1316
|
const CommonTenantId = "common";
|
|
1308
1317
|
const AzureAccountClientId = "aebc6443-996d-45c2-90f0-388ff96faa56"; // VSC: 'aebc6443-996d-45c2-90f0-388ff96faa56'
|
|
1309
1318
|
const logger$m = credentialLogger("VisualStudioCodeCredential");
|
|
@@ -1338,10 +1347,10 @@ function getPropertyFromVSCode(property) {
|
|
|
1338
1347
|
const settingsPath = ["User", "settings.json"];
|
|
1339
1348
|
// Eventually we can add more folders for more versions of VSCode.
|
|
1340
1349
|
const vsCodeFolder = "Code";
|
|
1341
|
-
const homedir =
|
|
1350
|
+
const homedir = os__default["default"].homedir();
|
|
1342
1351
|
function loadProperty(...pathSegments) {
|
|
1343
|
-
const fullPath =
|
|
1344
|
-
const settings = JSON.parse(
|
|
1352
|
+
const fullPath = path__default["default"].join(...pathSegments, vsCodeFolder, ...settingsPath);
|
|
1353
|
+
const settings = JSON.parse(fs__default["default"].readFileSync(fullPath, { encoding: "utf8" }));
|
|
1345
1354
|
return settings[property];
|
|
1346
1355
|
}
|
|
1347
1356
|
try {
|
|
@@ -1484,7 +1493,6 @@ class VisualStudioCodeCredential {
|
|
|
1484
1493
|
}
|
|
1485
1494
|
|
|
1486
1495
|
// Copyright (c) Microsoft Corporation.
|
|
1487
|
-
// Licensed under the MIT license.
|
|
1488
1496
|
/**
|
|
1489
1497
|
* The context passed to an Identity plugin. This contains objects that
|
|
1490
1498
|
* plugins can use to set backend implementations.
|
|
@@ -1526,7 +1534,6 @@ function useIdentityPlugin(plugin) {
|
|
|
1526
1534
|
}
|
|
1527
1535
|
|
|
1528
1536
|
// Copyright (c) Microsoft Corporation.
|
|
1529
|
-
// Licensed under the MIT license.
|
|
1530
1537
|
const msiName$6 = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
1531
1538
|
const logger$l = credentialLogger(msiName$6);
|
|
1532
1539
|
/**
|
|
@@ -1594,7 +1601,6 @@ const appServiceMsi2017 = {
|
|
|
1594
1601
|
};
|
|
1595
1602
|
|
|
1596
1603
|
// Copyright (c) Microsoft Corporation.
|
|
1597
|
-
// Licensed under the MIT license.
|
|
1598
1604
|
const msiName$5 = "ManagedIdentityCredential - CloudShellMSI";
|
|
1599
1605
|
const logger$k = credentialLogger(msiName$5);
|
|
1600
1606
|
/**
|
|
@@ -1666,7 +1672,6 @@ const cloudShellMsi = {
|
|
|
1666
1672
|
};
|
|
1667
1673
|
|
|
1668
1674
|
// Copyright (c) Microsoft Corporation.
|
|
1669
|
-
// Licensed under the MIT license.
|
|
1670
1675
|
const msiName$4 = "ManagedIdentityCredential - IMDS";
|
|
1671
1676
|
const logger$j = credentialLogger(msiName$4);
|
|
1672
1677
|
/**
|
|
@@ -1809,7 +1814,6 @@ const imdsMsi = {
|
|
|
1809
1814
|
};
|
|
1810
1815
|
|
|
1811
1816
|
// Copyright (c) Microsoft Corporation.
|
|
1812
|
-
// Licensed under the MIT license.
|
|
1813
1817
|
const msiName$3 = "ManagedIdentityCredential - Azure Arc MSI";
|
|
1814
1818
|
const logger$i = credentialLogger(msiName$3);
|
|
1815
1819
|
/**
|
|
@@ -1920,7 +1924,6 @@ const arcMsi = {
|
|
|
1920
1924
|
};
|
|
1921
1925
|
|
|
1922
1926
|
// Copyright (c) Microsoft Corporation.
|
|
1923
|
-
// Licensed under the MIT license.
|
|
1924
1927
|
/**
|
|
1925
1928
|
* MSAL client assertion client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
1926
1929
|
* @internal
|
|
@@ -1960,7 +1963,6 @@ class MsalClientAssertion extends MsalNode {
|
|
|
1960
1963
|
}
|
|
1961
1964
|
|
|
1962
1965
|
// Copyright (c) Microsoft Corporation.
|
|
1963
|
-
// Licensed under the MIT license.
|
|
1964
1966
|
const logger$h = credentialLogger("ClientAssertionCredential");
|
|
1965
1967
|
/**
|
|
1966
1968
|
* Authenticates a service principal with a JWT assertion.
|
|
@@ -1968,10 +1970,10 @@ const logger$h = credentialLogger("ClientAssertionCredential");
|
|
|
1968
1970
|
class ClientAssertionCredential {
|
|
1969
1971
|
/**
|
|
1970
1972
|
* Creates an instance of the ClientAssertionCredential with the details
|
|
1971
|
-
* needed to authenticate against
|
|
1973
|
+
* needed to authenticate against Azure Active Directory with a client
|
|
1972
1974
|
* assertion provided by the developer through the `getAssertion` function parameter.
|
|
1973
1975
|
*
|
|
1974
|
-
* @param tenantId - The
|
|
1976
|
+
* @param tenantId - The Azure Active Directory tenant (directory) ID.
|
|
1975
1977
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
1976
1978
|
* @param getAssertion - A function that retrieves the assertion for the credential to use.
|
|
1977
1979
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -1987,7 +1989,7 @@ class ClientAssertionCredential {
|
|
|
1987
1989
|
this.msalFlow = new MsalClientAssertion(Object.assign(Object.assign({}, options), { logger: logger$h, clientId: this.clientId, tenantId: this.tenantId, tokenCredentialOptions: this.options, getAssertion }));
|
|
1988
1990
|
}
|
|
1989
1991
|
/**
|
|
1990
|
-
* Authenticates with
|
|
1992
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
1991
1993
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
1992
1994
|
*
|
|
1993
1995
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2004,7 +2006,6 @@ class ClientAssertionCredential {
|
|
|
2004
2006
|
}
|
|
2005
2007
|
|
|
2006
2008
|
// Copyright (c) Microsoft Corporation.
|
|
2007
|
-
// Licensed under the MIT license.
|
|
2008
2009
|
const credentialName$3 = "WorkloadIdentityCredential";
|
|
2009
2010
|
/**
|
|
2010
2011
|
* Contains the list of all supported environment variable names so that an
|
|
@@ -2028,14 +2029,14 @@ const logger$g = credentialLogger(credentialName$3);
|
|
|
2028
2029
|
* Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
|
|
2029
2030
|
* each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
|
|
2030
2031
|
* need to worry about storing and securing sensitive credentials themselves.
|
|
2031
|
-
* The WorkloadIdentityCredential supports
|
|
2032
|
+
* The WorkloadIdentityCredential supports Azure workload identity authentication on Azure Kubernetes and acquires
|
|
2032
2033
|
* a token using the SACs available in the Azure Kubernetes environment.
|
|
2033
|
-
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">
|
|
2034
|
-
* Workload
|
|
2034
|
+
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Azure Active Directory
|
|
2035
|
+
* Workload Identity</a> for more information.
|
|
2035
2036
|
*/
|
|
2036
2037
|
class WorkloadIdentityCredential {
|
|
2037
2038
|
/**
|
|
2038
|
-
* WorkloadIdentityCredential supports
|
|
2039
|
+
* WorkloadIdentityCredential supports Azure workload identity on Kubernetes.
|
|
2039
2040
|
*
|
|
2040
2041
|
* @param options - The identity client options to use for authentication.
|
|
2041
2042
|
*/
|
|
@@ -2059,7 +2060,7 @@ class WorkloadIdentityCredential {
|
|
|
2059
2060
|
}
|
|
2060
2061
|
}
|
|
2061
2062
|
/**
|
|
2062
|
-
* Authenticates with
|
|
2063
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
2063
2064
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2064
2065
|
*
|
|
2065
2066
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2103,7 +2104,6 @@ class WorkloadIdentityCredential {
|
|
|
2103
2104
|
}
|
|
2104
2105
|
|
|
2105
2106
|
// Copyright (c) Microsoft Corporation.
|
|
2106
|
-
// Licensed under the MIT license.
|
|
2107
2107
|
const msiName$2 = "ManagedIdentityCredential - Token Exchange";
|
|
2108
2108
|
const logger$f = credentialLogger(msiName$2);
|
|
2109
2109
|
/**
|
|
@@ -2133,7 +2133,6 @@ function tokenExchangeMsi() {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
|
|
2135
2135
|
// Copyright (c) Microsoft Corporation.
|
|
2136
|
-
// Licensed under the MIT license.
|
|
2137
2136
|
// This MSI can be easily tested by deploying a container to Azure Service Fabric with the Dockerfile:
|
|
2138
2137
|
//
|
|
2139
2138
|
// FROM node:12
|
|
@@ -2212,7 +2211,7 @@ const fabricMsi = {
|
|
|
2212
2211
|
"IDENTITY_SERVER_THUMBPRINT=[REDACTED].",
|
|
2213
2212
|
].join(" "));
|
|
2214
2213
|
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$1(scopes, clientId, resourceId)));
|
|
2215
|
-
request.agent = new
|
|
2214
|
+
request.agent = new https__default["default"].Agent({
|
|
2216
2215
|
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
2217
2216
|
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
2218
2217
|
rejectUnauthorized: false,
|
|
@@ -2223,7 +2222,6 @@ const fabricMsi = {
|
|
|
2223
2222
|
};
|
|
2224
2223
|
|
|
2225
2224
|
// Copyright (c) Microsoft Corporation.
|
|
2226
|
-
// Licensed under the MIT license.
|
|
2227
2225
|
const msiName = "ManagedIdentityCredential - AppServiceMSI 2019";
|
|
2228
2226
|
const logger$d = credentialLogger(msiName);
|
|
2229
2227
|
/**
|
|
@@ -2291,7 +2289,6 @@ const appServiceMsi2019 = {
|
|
|
2291
2289
|
};
|
|
2292
2290
|
|
|
2293
2291
|
// Copyright (c) Microsoft Corporation.
|
|
2294
|
-
// Licensed under the MIT license.
|
|
2295
2292
|
const logger$c = credentialLogger("ManagedIdentityCredential");
|
|
2296
2293
|
/**
|
|
2297
2294
|
* Attempts authentication using a managed identity available at the deployment environment.
|
|
@@ -2331,9 +2328,8 @@ class ManagedIdentityCredential {
|
|
|
2331
2328
|
/** authority host validation and metadata discovery to be skipped in managed identity
|
|
2332
2329
|
* since this wasn't done previously before adding token cache support
|
|
2333
2330
|
*/
|
|
2334
|
-
this.confidentialApp = new
|
|
2331
|
+
this.confidentialApp = new msalNode.ConfidentialClientApplication({
|
|
2335
2332
|
auth: {
|
|
2336
|
-
authority: "https://login.microsoftonline.com/managed_identity",
|
|
2337
2333
|
clientId: (_a = this.clientId) !== null && _a !== void 0 ? _a : DeveloperSignOnClientId,
|
|
2338
2334
|
clientSecret: "dummy-secret",
|
|
2339
2335
|
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"]}]}',
|
|
@@ -2398,7 +2394,7 @@ class ManagedIdentityCredential {
|
|
|
2398
2394
|
}
|
|
2399
2395
|
}
|
|
2400
2396
|
/**
|
|
2401
|
-
* Authenticates with
|
|
2397
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
2402
2398
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2403
2399
|
* If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
|
|
2404
2400
|
*
|
|
@@ -2582,7 +2578,6 @@ class ManagedIdentityCredential {
|
|
|
2582
2578
|
}
|
|
2583
2579
|
|
|
2584
2580
|
// Copyright (c) Microsoft Corporation.
|
|
2585
|
-
// Licensed under the MIT license.
|
|
2586
2581
|
/**
|
|
2587
2582
|
* Ensures the scopes value is an array.
|
|
2588
2583
|
* @internal
|
|
@@ -2610,7 +2605,6 @@ function getScopeResource(scope) {
|
|
|
2610
2605
|
}
|
|
2611
2606
|
|
|
2612
2607
|
// Copyright (c) Microsoft Corporation.
|
|
2613
|
-
// Licensed under the MIT license.
|
|
2614
2608
|
/**
|
|
2615
2609
|
* Mockable reference to the CLI credential cliCredentialFunctions
|
|
2616
2610
|
* @internal
|
|
@@ -2642,7 +2636,7 @@ const cliCredentialInternals = {
|
|
|
2642
2636
|
}
|
|
2643
2637
|
return new Promise((resolve, reject) => {
|
|
2644
2638
|
try {
|
|
2645
|
-
|
|
2639
|
+
child_process__default["default"].execFile("az", [
|
|
2646
2640
|
"account",
|
|
2647
2641
|
"get-access-token",
|
|
2648
2642
|
"--output",
|
|
@@ -2685,7 +2679,7 @@ class AzureCliCredential {
|
|
|
2685
2679
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2686
2680
|
}
|
|
2687
2681
|
/**
|
|
2688
|
-
* Authenticates with
|
|
2682
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
2689
2683
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2690
2684
|
*
|
|
2691
2685
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2747,7 +2741,6 @@ class AzureCliCredential {
|
|
|
2747
2741
|
}
|
|
2748
2742
|
|
|
2749
2743
|
// Copyright (c) Microsoft Corporation.
|
|
2750
|
-
// Licensed under the MIT license.
|
|
2751
2744
|
/**
|
|
2752
2745
|
* Easy to mock childProcess utils.
|
|
2753
2746
|
* @internal
|
|
@@ -2778,7 +2771,6 @@ const processUtils = {
|
|
|
2778
2771
|
};
|
|
2779
2772
|
|
|
2780
2773
|
// Copyright (c) Microsoft Corporation.
|
|
2781
|
-
// Licensed under the MIT license.
|
|
2782
2774
|
const logger$a = credentialLogger("AzurePowerShellCredential");
|
|
2783
2775
|
const isWindows = process.platform === "win32";
|
|
2784
2776
|
/**
|
|
@@ -2912,7 +2904,7 @@ class AzurePowerShellCredential {
|
|
|
2912
2904
|
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
|
|
2913
2905
|
}
|
|
2914
2906
|
/**
|
|
2915
|
-
* Authenticates with
|
|
2907
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
2916
2908
|
* If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
|
|
2917
2909
|
*
|
|
2918
2910
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2956,7 +2948,6 @@ class AzurePowerShellCredential {
|
|
|
2956
2948
|
}
|
|
2957
2949
|
|
|
2958
2950
|
// Copyright (c) Microsoft Corporation.
|
|
2959
|
-
// Licensed under the MIT license.
|
|
2960
2951
|
/**
|
|
2961
2952
|
* @internal
|
|
2962
2953
|
*/
|
|
@@ -3035,7 +3026,6 @@ class ChainedTokenCredential {
|
|
|
3035
3026
|
}
|
|
3036
3027
|
|
|
3037
3028
|
// Copyright (c) Microsoft Corporation.
|
|
3038
|
-
// Licensed under the MIT license.
|
|
3039
3029
|
const readFileAsync = util.promisify(fs.readFile);
|
|
3040
3030
|
/**
|
|
3041
3031
|
* Tries to asynchronously load a certificate from the given path.
|
|
@@ -3141,11 +3131,10 @@ class MsalClientCertificate extends MsalNode {
|
|
|
3141
3131
|
}
|
|
3142
3132
|
|
|
3143
3133
|
// Copyright (c) Microsoft Corporation.
|
|
3144
|
-
// Licensed under the MIT license.
|
|
3145
3134
|
const credentialName$2 = "ClientCertificateCredential";
|
|
3146
3135
|
const logger$8 = credentialLogger(credentialName$2);
|
|
3147
3136
|
/**
|
|
3148
|
-
* Enables authentication to
|
|
3137
|
+
* Enables authentication to Azure Active Directory using a PEM-encoded
|
|
3149
3138
|
* certificate that is assigned to an App Registration. More information
|
|
3150
3139
|
* on how to configure certificate authentication can be found here:
|
|
3151
3140
|
*
|
|
@@ -3179,7 +3168,7 @@ class ClientCertificateCredential {
|
|
|
3179
3168
|
tenantId, sendCertificateChain: options.sendCertificateChain, tokenCredentialOptions: options }));
|
|
3180
3169
|
}
|
|
3181
3170
|
/**
|
|
3182
|
-
* Authenticates with
|
|
3171
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3183
3172
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3184
3173
|
*
|
|
3185
3174
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3196,7 +3185,6 @@ class ClientCertificateCredential {
|
|
|
3196
3185
|
}
|
|
3197
3186
|
|
|
3198
3187
|
// Copyright (c) Microsoft Corporation.
|
|
3199
|
-
// Licensed under the MIT license.
|
|
3200
3188
|
/**
|
|
3201
3189
|
* MSAL client secret client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
3202
3190
|
* @internal
|
|
@@ -3227,23 +3215,22 @@ class MsalClientSecret extends MsalNode {
|
|
|
3227
3215
|
}
|
|
3228
3216
|
|
|
3229
3217
|
// Copyright (c) Microsoft Corporation.
|
|
3230
|
-
// Licensed under the MIT license.
|
|
3231
3218
|
const logger$7 = credentialLogger("ClientSecretCredential");
|
|
3232
3219
|
/**
|
|
3233
|
-
* Enables authentication to
|
|
3220
|
+
* Enables authentication to Azure Active Directory using a client secret
|
|
3234
3221
|
* that was generated for an App Registration. More information on how
|
|
3235
3222
|
* to configure a client secret can be found here:
|
|
3236
3223
|
*
|
|
3237
|
-
* https://
|
|
3224
|
+
* https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
|
|
3238
3225
|
*
|
|
3239
3226
|
*/
|
|
3240
3227
|
class ClientSecretCredential {
|
|
3241
3228
|
/**
|
|
3242
3229
|
* Creates an instance of the ClientSecretCredential with the details
|
|
3243
|
-
* needed to authenticate against
|
|
3230
|
+
* needed to authenticate against Azure Active Directory with a client
|
|
3244
3231
|
* secret.
|
|
3245
3232
|
*
|
|
3246
|
-
* @param tenantId - The
|
|
3233
|
+
* @param tenantId - The Azure Active Directory tenant (directory) ID.
|
|
3247
3234
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3248
3235
|
* @param clientSecret - A client secret that was generated for the App Registration.
|
|
3249
3236
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -3260,7 +3247,7 @@ class ClientSecretCredential {
|
|
|
3260
3247
|
clientSecret, tokenCredentialOptions: options }));
|
|
3261
3248
|
}
|
|
3262
3249
|
/**
|
|
3263
|
-
* Authenticates with
|
|
3250
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3264
3251
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3265
3252
|
*
|
|
3266
3253
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3277,7 +3264,6 @@ class ClientSecretCredential {
|
|
|
3277
3264
|
}
|
|
3278
3265
|
|
|
3279
3266
|
// Copyright (c) Microsoft Corporation.
|
|
3280
|
-
// Licensed under the MIT license.
|
|
3281
3267
|
/**
|
|
3282
3268
|
* MSAL username and password client. Calls to the MSAL's public application's `acquireTokenByUsernamePassword` during `doGetToken`.
|
|
3283
3269
|
* @internal
|
|
@@ -3308,10 +3294,9 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
3308
3294
|
}
|
|
3309
3295
|
|
|
3310
3296
|
// Copyright (c) Microsoft Corporation.
|
|
3311
|
-
// Licensed under the MIT license.
|
|
3312
3297
|
const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
3313
3298
|
/**
|
|
3314
|
-
* Enables authentication to
|
|
3299
|
+
* Enables authentication to Azure Active Directory with a user's
|
|
3315
3300
|
* username and password. This credential requires a high degree of
|
|
3316
3301
|
* trust so you should only use it when other, more secure credential
|
|
3317
3302
|
* types can't be used.
|
|
@@ -3319,10 +3304,10 @@ const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
|
3319
3304
|
class UsernamePasswordCredential {
|
|
3320
3305
|
/**
|
|
3321
3306
|
* Creates an instance of the UsernamePasswordCredential with the details
|
|
3322
|
-
* needed to authenticate against
|
|
3307
|
+
* needed to authenticate against Azure Active Directory with a username
|
|
3323
3308
|
* and password.
|
|
3324
3309
|
*
|
|
3325
|
-
* @param tenantId - The
|
|
3310
|
+
* @param tenantId - The Azure Active Directory tenant (directory).
|
|
3326
3311
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3327
3312
|
* @param username - The user account's e-mail address (user name).
|
|
3328
3313
|
* @param password - The user account's account password
|
|
@@ -3341,7 +3326,7 @@ class UsernamePasswordCredential {
|
|
|
3341
3326
|
password, tokenCredentialOptions: options || {} }));
|
|
3342
3327
|
}
|
|
3343
3328
|
/**
|
|
3344
|
-
* Authenticates with
|
|
3329
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3345
3330
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3346
3331
|
*
|
|
3347
3332
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3362,7 +3347,6 @@ class UsernamePasswordCredential {
|
|
|
3362
3347
|
}
|
|
3363
3348
|
|
|
3364
3349
|
// Copyright (c) Microsoft Corporation.
|
|
3365
|
-
// Licensed under the MIT license.
|
|
3366
3350
|
/**
|
|
3367
3351
|
* Contains the list of all supported environment variable names so that an
|
|
3368
3352
|
* appropriate error message can be generated when no credentials can be
|
|
@@ -3388,7 +3372,7 @@ function getAdditionallyAllowedTenants() {
|
|
|
3388
3372
|
const credentialName$1 = "EnvironmentCredential";
|
|
3389
3373
|
const logger$5 = credentialLogger(credentialName$1);
|
|
3390
3374
|
/**
|
|
3391
|
-
* Enables authentication to
|
|
3375
|
+
* Enables authentication to Azure Active Directory using a client secret or certificate, or as a user
|
|
3392
3376
|
* with a username and password.
|
|
3393
3377
|
*/
|
|
3394
3378
|
class EnvironmentCredential {
|
|
@@ -3396,7 +3380,7 @@ class EnvironmentCredential {
|
|
|
3396
3380
|
* Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
|
|
3397
3381
|
*
|
|
3398
3382
|
* Required environment variables:
|
|
3399
|
-
* - `AZURE_TENANT_ID`: The
|
|
3383
|
+
* - `AZURE_TENANT_ID`: The Azure Active Directory tenant (directory) ID.
|
|
3400
3384
|
* - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
|
|
3401
3385
|
*
|
|
3402
3386
|
* If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
|
|
@@ -3447,7 +3431,7 @@ class EnvironmentCredential {
|
|
|
3447
3431
|
}
|
|
3448
3432
|
}
|
|
3449
3433
|
/**
|
|
3450
|
-
* Authenticates with
|
|
3434
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3451
3435
|
*
|
|
3452
3436
|
* @param scopes - The list of scopes for which the token will have access.
|
|
3453
3437
|
* @param options - Optional parameters. See {@link GetTokenOptions}.
|
|
@@ -3475,7 +3459,6 @@ class EnvironmentCredential {
|
|
|
3475
3459
|
}
|
|
3476
3460
|
|
|
3477
3461
|
// Copyright (c) Microsoft Corporation.
|
|
3478
|
-
// Licensed under the MIT license.
|
|
3479
3462
|
/**
|
|
3480
3463
|
* Mockable reference to the Developer CLI credential cliCredentialFunctions
|
|
3481
3464
|
* @internal
|
|
@@ -3507,7 +3490,7 @@ const developerCliCredentialInternals = {
|
|
|
3507
3490
|
}
|
|
3508
3491
|
return new Promise((resolve, reject) => {
|
|
3509
3492
|
try {
|
|
3510
|
-
|
|
3493
|
+
child_process__default["default"].execFile("azd", [
|
|
3511
3494
|
"auth",
|
|
3512
3495
|
"token",
|
|
3513
3496
|
"--output",
|
|
@@ -3532,11 +3515,11 @@ const logger$4 = credentialLogger("AzureDeveloperCliCredential");
|
|
|
3532
3515
|
* Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
|
|
3533
3516
|
* resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
|
|
3534
3517
|
* to Azure developers. It allows users to authenticate as a user and/or a service principal against
|
|
3535
|
-
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">
|
|
3536
|
-
* AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
|
|
3518
|
+
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">Azure Active Directory (Azure AD)
|
|
3519
|
+
* </a>. The AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
|
|
3537
3520
|
* the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
|
|
3538
3521
|
* service principal and executes an Azure CLI command underneath to authenticate the application against
|
|
3539
|
-
*
|
|
3522
|
+
* Azure Active Directory.
|
|
3540
3523
|
*
|
|
3541
3524
|
* <h2> Configure AzureDeveloperCliCredential </h2>
|
|
3542
3525
|
*
|
|
@@ -3571,7 +3554,7 @@ class AzureDeveloperCliCredential {
|
|
|
3571
3554
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
3572
3555
|
}
|
|
3573
3556
|
/**
|
|
3574
|
-
* Authenticates with
|
|
3557
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3575
3558
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3576
3559
|
*
|
|
3577
3560
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3639,7 +3622,6 @@ class AzureDeveloperCliCredential {
|
|
|
3639
3622
|
}
|
|
3640
3623
|
|
|
3641
3624
|
// Copyright (c) Microsoft Corporation.
|
|
3642
|
-
// Licensed under the MIT license.
|
|
3643
3625
|
/**
|
|
3644
3626
|
* A shim around ManagedIdentityCredential that adapts it to accept
|
|
3645
3627
|
* `DefaultAzureCredentialOptions`.
|
|
@@ -3736,13 +3718,12 @@ class DefaultAzureCredential extends ChainedTokenCredential {
|
|
|
3736
3718
|
}
|
|
3737
3719
|
|
|
3738
3720
|
// Copyright (c) Microsoft Corporation.
|
|
3739
|
-
// Licensed under the MIT license.
|
|
3740
3721
|
/**
|
|
3741
3722
|
* A call to open(), but mockable
|
|
3742
3723
|
* @internal
|
|
3743
3724
|
*/
|
|
3744
3725
|
const interactiveBrowserMockable = {
|
|
3745
|
-
open,
|
|
3726
|
+
open: open__default["default"],
|
|
3746
3727
|
};
|
|
3747
3728
|
/**
|
|
3748
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`
|
|
@@ -3752,46 +3733,166 @@ const interactiveBrowserMockable = {
|
|
|
3752
3733
|
class MsalOpenBrowser extends MsalNode {
|
|
3753
3734
|
constructor(options) {
|
|
3754
3735
|
super(options);
|
|
3755
|
-
this.loginHint = options.loginHint;
|
|
3756
3736
|
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3737
|
+
this.redirectUri = options.redirectUri;
|
|
3738
|
+
this.loginHint = options.loginHint;
|
|
3739
|
+
const url = new URL(this.redirectUri);
|
|
3740
|
+
this.port = parseInt(url.port);
|
|
3741
|
+
if (isNaN(this.port)) {
|
|
3742
|
+
this.port = 80;
|
|
3743
|
+
}
|
|
3744
|
+
this.hostname = url.hostname;
|
|
3757
3745
|
}
|
|
3758
|
-
async
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3746
|
+
async acquireTokenByCode(request, enableCae) {
|
|
3747
|
+
return this.getApp("public", enableCae).acquireTokenByCode(request);
|
|
3748
|
+
}
|
|
3749
|
+
doGetToken(scopes, options) {
|
|
3750
|
+
return new Promise((resolve, reject) => {
|
|
3751
|
+
const socketToDestroy = [];
|
|
3752
|
+
const requestListener = (req, res) => {
|
|
3753
|
+
var _a;
|
|
3754
|
+
if (!req.url) {
|
|
3755
|
+
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3756
|
+
return;
|
|
3757
|
+
}
|
|
3758
|
+
let url;
|
|
3759
|
+
try {
|
|
3760
|
+
url = new URL(req.url, this.redirectUri);
|
|
3761
|
+
}
|
|
3762
|
+
catch (e) {
|
|
3763
|
+
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3764
|
+
return;
|
|
3765
|
+
}
|
|
3766
|
+
const tokenRequest = {
|
|
3767
|
+
code: url.searchParams.get("code"),
|
|
3768
|
+
redirectUri: this.redirectUri,
|
|
3769
|
+
scopes: scopes,
|
|
3770
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3771
|
+
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
3772
|
+
};
|
|
3773
|
+
this.acquireTokenByCode(tokenRequest, options === null || options === void 0 ? void 0 : options.enableCae)
|
|
3774
|
+
.then((authResponse) => {
|
|
3775
|
+
if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.account) {
|
|
3776
|
+
this.account = msalToPublic(this.clientId, authResponse.account);
|
|
3777
|
+
}
|
|
3778
|
+
const successMessage = `Authentication Complete. You can close the browser and return to the application.`;
|
|
3779
|
+
if (authResponse && authResponse.expiresOn) {
|
|
3780
|
+
const expiresOnTimestamp = authResponse === null || authResponse === void 0 ? void 0 : authResponse.expiresOn.valueOf();
|
|
3781
|
+
res.writeHead(200);
|
|
3782
|
+
res.end(successMessage);
|
|
3783
|
+
this.logger.getToken.info(formatSuccess(scopes));
|
|
3784
|
+
resolve({
|
|
3785
|
+
expiresOnTimestamp,
|
|
3786
|
+
token: authResponse.accessToken,
|
|
3787
|
+
});
|
|
3788
|
+
}
|
|
3789
|
+
else {
|
|
3790
|
+
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3791
|
+
res.writeHead(500);
|
|
3792
|
+
res.end(errorMessage);
|
|
3793
|
+
this.logger.getToken.info(errorMessage);
|
|
3794
|
+
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3795
|
+
}
|
|
3796
|
+
cleanup();
|
|
3797
|
+
return;
|
|
3798
|
+
})
|
|
3799
|
+
.catch(() => {
|
|
3800
|
+
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3801
|
+
res.writeHead(500);
|
|
3802
|
+
res.end(errorMessage);
|
|
3803
|
+
this.logger.getToken.info(errorMessage);
|
|
3804
|
+
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3805
|
+
cleanup();
|
|
3806
|
+
});
|
|
3807
|
+
};
|
|
3808
|
+
const app = http__default["default"].createServer(requestListener);
|
|
3809
|
+
const server = stoppable__default["default"](app);
|
|
3810
|
+
const listen = app.listen(this.port, this.hostname, () => this.logger.info(`InteractiveBrowserCredential listening on port ${this.port}!`));
|
|
3811
|
+
function cleanup() {
|
|
3812
|
+
if (listen) {
|
|
3813
|
+
listen.close();
|
|
3814
|
+
}
|
|
3815
|
+
for (const socket of socketToDestroy) {
|
|
3816
|
+
socket.destroy();
|
|
3817
|
+
}
|
|
3818
|
+
if (server) {
|
|
3819
|
+
server.close();
|
|
3820
|
+
server.stop();
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
app.on("connection", (socket) => socketToDestroy.push(socket));
|
|
3824
|
+
app.on("error", (err) => {
|
|
3825
|
+
cleanup();
|
|
3826
|
+
const code = err.code;
|
|
3827
|
+
if (code === "EACCES" || code === "EADDRINUSE") {
|
|
3828
|
+
reject(new CredentialUnavailableError([
|
|
3829
|
+
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3830
|
+
`Try sending a redirect URI with a different port, as follows:`,
|
|
3831
|
+
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`',
|
|
3832
|
+
].join(" ")));
|
|
3833
|
+
}
|
|
3834
|
+
else {
|
|
3835
|
+
reject(new CredentialUnavailableError(`InteractiveBrowserCredential: Failed to start the necessary web server. Error: ${err.message}`));
|
|
3836
|
+
}
|
|
3769
3837
|
});
|
|
3770
|
-
|
|
3838
|
+
app.on("listening", () => {
|
|
3839
|
+
const openPromise = this.openAuthCodeUrl(scopes, options);
|
|
3840
|
+
const abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal;
|
|
3841
|
+
if (abortSignal) {
|
|
3842
|
+
abortSignal.addEventListener("abort", () => {
|
|
3843
|
+
cleanup();
|
|
3844
|
+
reject(new Error("Aborted"));
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
openPromise.catch((e) => {
|
|
3848
|
+
cleanup();
|
|
3849
|
+
reject(e);
|
|
3850
|
+
});
|
|
3851
|
+
});
|
|
3852
|
+
});
|
|
3853
|
+
}
|
|
3854
|
+
async openAuthCodeUrl(scopeArray, options) {
|
|
3855
|
+
// Initialize CryptoProvider instance
|
|
3856
|
+
const cryptoProvider = new msalNode__namespace.CryptoProvider();
|
|
3857
|
+
// Generate PKCE Codes before starting the authorization flow
|
|
3858
|
+
this.pkceCodes = await cryptoProvider.generatePkceCodes();
|
|
3859
|
+
const authCodeUrlParameters = {
|
|
3860
|
+
scopes: scopeArray,
|
|
3861
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3862
|
+
redirectUri: this.redirectUri,
|
|
3863
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3864
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3865
|
+
loginHint: this.loginHint,
|
|
3866
|
+
codeChallenge: this.pkceCodes.challenge,
|
|
3867
|
+
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3868
|
+
};
|
|
3869
|
+
const response = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).getAuthCodeUrl(authCodeUrlParameters);
|
|
3870
|
+
try {
|
|
3871
|
+
// A new instance on macOS only which allows it to not hang, does not fix the issue on linux
|
|
3872
|
+
await interactiveBrowserMockable.open(response, { wait: true, newInstance: true });
|
|
3771
3873
|
}
|
|
3772
|
-
catch (
|
|
3773
|
-
throw
|
|
3874
|
+
catch (e) {
|
|
3875
|
+
throw new CredentialUnavailableError(`InteractiveBrowserCredential: Could not open a browser window. Error: ${e.message}`);
|
|
3774
3876
|
}
|
|
3775
3877
|
}
|
|
3776
3878
|
}
|
|
3777
3879
|
|
|
3778
3880
|
// Copyright (c) Microsoft Corporation.
|
|
3779
|
-
// Licensed under the MIT license.
|
|
3780
3881
|
const logger$3 = credentialLogger("InteractiveBrowserCredential");
|
|
3781
3882
|
/**
|
|
3782
|
-
* Enables authentication to
|
|
3883
|
+
* Enables authentication to Azure Active Directory inside of the web browser
|
|
3783
3884
|
* using the interactive login flow.
|
|
3784
3885
|
*/
|
|
3785
3886
|
class InteractiveBrowserCredential {
|
|
3786
3887
|
/**
|
|
3787
3888
|
* Creates an instance of InteractiveBrowserCredential with the details needed.
|
|
3788
3889
|
*
|
|
3789
|
-
* This credential uses the [Authorization Code Flow](https://
|
|
3890
|
+
* This credential uses the [Authorization Code Flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
|
3790
3891
|
* On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
|
|
3791
3892
|
* 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.
|
|
3792
3893
|
*
|
|
3793
|
-
* For Node.js, if a `clientId` is provided, the
|
|
3794
|
-
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://
|
|
3894
|
+
* For Node.js, if a `clientId` is provided, the Azure Active Directory application will need to be configured to have a "Mobile and desktop applications" redirect endpoint.
|
|
3895
|
+
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://docs.microsoft.com/azure/active-directory/develop/scenario-desktop-app-registration#redirect-uris).
|
|
3795
3896
|
*
|
|
3796
3897
|
* @param options - Options for configuring the client which makes the authentication requests.
|
|
3797
3898
|
*/
|
|
@@ -3806,7 +3907,7 @@ class InteractiveBrowserCredential {
|
|
|
3806
3907
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3807
3908
|
}
|
|
3808
3909
|
/**
|
|
3809
|
-
* Authenticates with
|
|
3910
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3810
3911
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3811
3912
|
*
|
|
3812
3913
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3825,7 +3926,7 @@ class InteractiveBrowserCredential {
|
|
|
3825
3926
|
});
|
|
3826
3927
|
}
|
|
3827
3928
|
/**
|
|
3828
|
-
* Authenticates with
|
|
3929
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3829
3930
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3830
3931
|
*
|
|
3831
3932
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -3847,7 +3948,6 @@ class InteractiveBrowserCredential {
|
|
|
3847
3948
|
}
|
|
3848
3949
|
|
|
3849
3950
|
// Copyright (c) Microsoft Corporation.
|
|
3850
|
-
// Licensed under the MIT license.
|
|
3851
3951
|
/**
|
|
3852
3952
|
* MSAL device code client. Calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`.
|
|
3853
3953
|
* @internal
|
|
@@ -3880,7 +3980,6 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3880
3980
|
}
|
|
3881
3981
|
|
|
3882
3982
|
// Copyright (c) Microsoft Corporation.
|
|
3883
|
-
// Licensed under the MIT license.
|
|
3884
3983
|
const logger$2 = credentialLogger("DeviceCodeCredential");
|
|
3885
3984
|
/**
|
|
3886
3985
|
* Method that logs the user code from the DeviceCodeCredential.
|
|
@@ -3890,13 +3989,13 @@ function defaultDeviceCodePromptCallback(deviceCodeInfo) {
|
|
|
3890
3989
|
console.log(deviceCodeInfo.message);
|
|
3891
3990
|
}
|
|
3892
3991
|
/**
|
|
3893
|
-
* Enables authentication to
|
|
3992
|
+
* Enables authentication to Azure Active Directory using a device code
|
|
3894
3993
|
* that the user can enter into https://microsoft.com/devicelogin.
|
|
3895
3994
|
*/
|
|
3896
3995
|
class DeviceCodeCredential {
|
|
3897
3996
|
/**
|
|
3898
3997
|
* Creates an instance of DeviceCodeCredential with the details needed
|
|
3899
|
-
* to initiate the device code authorization flow with
|
|
3998
|
+
* to initiate the device code authorization flow with Azure Active Directory.
|
|
3900
3999
|
*
|
|
3901
4000
|
* A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
|
|
3902
4001
|
*
|
|
@@ -3921,7 +4020,7 @@ class DeviceCodeCredential {
|
|
|
3921
4020
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3922
4021
|
}
|
|
3923
4022
|
/**
|
|
3924
|
-
* Authenticates with
|
|
4023
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3925
4024
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3926
4025
|
*
|
|
3927
4026
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3940,7 +4039,7 @@ class DeviceCodeCredential {
|
|
|
3940
4039
|
});
|
|
3941
4040
|
}
|
|
3942
4041
|
/**
|
|
3943
|
-
* Authenticates with
|
|
4042
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
3944
4043
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3945
4044
|
*
|
|
3946
4045
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -3959,7 +4058,6 @@ class DeviceCodeCredential {
|
|
|
3959
4058
|
}
|
|
3960
4059
|
|
|
3961
4060
|
// Copyright (c) Microsoft Corporation.
|
|
3962
|
-
// Licensed under the MIT license.
|
|
3963
4061
|
/**
|
|
3964
4062
|
* 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`
|
|
3965
4063
|
* to trigger the authentication flow, and then respond based on the values obtained from the redirect callback
|
|
@@ -4003,14 +4101,13 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
4003
4101
|
}
|
|
4004
4102
|
|
|
4005
4103
|
// Copyright (c) Microsoft Corporation.
|
|
4006
|
-
// Licensed under the MIT license.
|
|
4007
4104
|
const logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
4008
4105
|
/**
|
|
4009
|
-
* Enables authentication to
|
|
4106
|
+
* Enables authentication to Azure Active Directory using an authorization code
|
|
4010
4107
|
* that was obtained through the authorization code flow, described in more detail
|
|
4011
|
-
* in the
|
|
4108
|
+
* in the Azure Active Directory documentation:
|
|
4012
4109
|
*
|
|
4013
|
-
* https://
|
|
4110
|
+
* https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
|
4014
4111
|
*/
|
|
4015
4112
|
class AuthorizationCodeCredential {
|
|
4016
4113
|
/**
|
|
@@ -4041,7 +4138,7 @@ class AuthorizationCodeCredential {
|
|
|
4041
4138
|
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
4042
4139
|
}
|
|
4043
4140
|
/**
|
|
4044
|
-
* Authenticates with
|
|
4141
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
4045
4142
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4046
4143
|
*
|
|
4047
4144
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -4059,7 +4156,6 @@ class AuthorizationCodeCredential {
|
|
|
4059
4156
|
}
|
|
4060
4157
|
|
|
4061
4158
|
// Copyright (c) Microsoft Corporation.
|
|
4062
|
-
// Licensed under the MIT license.
|
|
4063
4159
|
/**
|
|
4064
4160
|
* MSAL on behalf of flow. Calls to MSAL's confidential application's `acquireTokenOnBehalfOf` during `doGetToken`.
|
|
4065
4161
|
* @internal
|
|
@@ -4113,7 +4209,6 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4113
4209
|
}
|
|
4114
4210
|
|
|
4115
4211
|
// Copyright (c) Microsoft Corporation.
|
|
4116
|
-
// Licensed under the MIT license.
|
|
4117
4212
|
const credentialName = "OnBehalfOfCredential";
|
|
4118
4213
|
const logger = credentialLogger(credentialName);
|
|
4119
4214
|
/**
|
|
@@ -4133,7 +4228,7 @@ class OnBehalfOfCredential {
|
|
|
4133
4228
|
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
4134
4229
|
}
|
|
4135
4230
|
/**
|
|
4136
|
-
* Authenticates with
|
|
4231
|
+
* Authenticates with Azure Active Directory and returns an access token if successful.
|
|
4137
4232
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4138
4233
|
*
|
|
4139
4234
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -4149,7 +4244,6 @@ class OnBehalfOfCredential {
|
|
|
4149
4244
|
}
|
|
4150
4245
|
|
|
4151
4246
|
// Copyright (c) Microsoft Corporation.
|
|
4152
|
-
// Licensed under the MIT license.
|
|
4153
4247
|
/**
|
|
4154
4248
|
* Returns a new instance of the {@link DefaultAzureCredential}.
|
|
4155
4249
|
*/
|