@azure/identity 3.3.2 → 4.0.0-alpha.20231026.4
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 +228 -225
- 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/brokerAuthOptions.js +2 -0
- package/dist-esm/src/credentials/brokerAuthOptions.js.map +1 -0
- package/dist-esm/src/credentials/browserCustomizationOptions.js +4 -0
- package/dist-esm/src/credentials/browserCustomizationOptions.js.map +1 -0
- 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 +26 -9
- 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 +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/index.js.map +1 -1
- package/dist-esm/src/msal/flows.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/brokerOptions.js +2 -0
- package/dist-esm/src/msal/nodeFlows/brokerOptions.js.map +1 -0
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +56 -8
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +40 -139
- 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 +7 -4
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/consumer.js +2 -1
- package/dist-esm/src/plugins/consumer.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 +17 -18
- package/types/identity.d.ts +142 -68
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 = `
|
|
243
|
+
const SDK_VERSION = `4.0.0-beta.1`;
|
|
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.
|
|
@@ -470,6 +454,10 @@ class MsalBaseUtilities {
|
|
|
470
454
|
error.name === "AbortError") {
|
|
471
455
|
return error;
|
|
472
456
|
}
|
|
457
|
+
if (error.name === "NativeAuthError") {
|
|
458
|
+
this.logger.info(formatError(scopes, `Error from the native broker: ${error.message} with status code: ${error.statusCode}`));
|
|
459
|
+
return error;
|
|
460
|
+
}
|
|
473
461
|
return new AuthenticationRequiredError({ scopes, getTokenOptions, message: error.message });
|
|
474
462
|
}
|
|
475
463
|
}
|
|
@@ -534,6 +522,7 @@ function deserializeAuthenticationRecord(serializedRecord) {
|
|
|
534
522
|
}
|
|
535
523
|
|
|
536
524
|
// Copyright (c) Microsoft Corporation.
|
|
525
|
+
// Licensed under the MIT license.
|
|
537
526
|
function createConfigurationErrorMessage(tenantId) {
|
|
538
527
|
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
528
|
}
|
|
@@ -567,6 +556,7 @@ function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowe
|
|
|
567
556
|
}
|
|
568
557
|
|
|
569
558
|
// Copyright (c) Microsoft Corporation.
|
|
559
|
+
// Licensed under the MIT license.
|
|
570
560
|
/**
|
|
571
561
|
* @internal
|
|
572
562
|
*/
|
|
@@ -618,6 +608,7 @@ function getIdentityTokenEndpointSuffix(tenantId) {
|
|
|
618
608
|
}
|
|
619
609
|
|
|
620
610
|
// Copyright (c) Microsoft Corporation.
|
|
611
|
+
// Licensed under the MIT license.
|
|
621
612
|
/**
|
|
622
613
|
* Creates a span using the global tracer.
|
|
623
614
|
* @internal
|
|
@@ -638,6 +629,7 @@ const azureArcAPIVersion = "2019-11-01";
|
|
|
638
629
|
const azureFabricVersion = "2019-07-01-preview";
|
|
639
630
|
|
|
640
631
|
// Copyright (c) Microsoft Corporation.
|
|
632
|
+
// Licensed under the MIT license.
|
|
641
633
|
/**
|
|
642
634
|
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
|
643
635
|
* These are GET requests that require sending a `resource` parameter on the query.
|
|
@@ -688,6 +680,7 @@ function parseExpirationTimestamp(body) {
|
|
|
688
680
|
}
|
|
689
681
|
|
|
690
682
|
// Copyright (c) Microsoft Corporation.
|
|
683
|
+
// Licensed under the MIT license.
|
|
691
684
|
const noCorrelationId = "noCorrelationId";
|
|
692
685
|
/**
|
|
693
686
|
* @internal
|
|
@@ -1032,6 +1025,7 @@ var RegionalAuthority;
|
|
|
1032
1025
|
})(RegionalAuthority || (RegionalAuthority = {}));
|
|
1033
1026
|
|
|
1034
1027
|
// Copyright (c) Microsoft Corporation.
|
|
1028
|
+
// Licensed under the MIT license.
|
|
1035
1029
|
/**
|
|
1036
1030
|
* The current persistence provider, undefined by default.
|
|
1037
1031
|
* @internal
|
|
@@ -1046,6 +1040,25 @@ const msalNodeFlowCacheControl = {
|
|
|
1046
1040
|
persistenceProvider = pluginProvider;
|
|
1047
1041
|
},
|
|
1048
1042
|
};
|
|
1043
|
+
/**
|
|
1044
|
+
* The current native broker provider, undefined by default.
|
|
1045
|
+
* @internal
|
|
1046
|
+
*/
|
|
1047
|
+
let nativeBrokerInfo = undefined;
|
|
1048
|
+
function hasNativeBroker() {
|
|
1049
|
+
return nativeBrokerInfo !== undefined;
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* An object that allows setting the native broker provider.
|
|
1053
|
+
* @internal
|
|
1054
|
+
*/
|
|
1055
|
+
const msalNodeFlowNativeBrokerControl = {
|
|
1056
|
+
setNativeBroker(broker) {
|
|
1057
|
+
nativeBrokerInfo = {
|
|
1058
|
+
broker,
|
|
1059
|
+
};
|
|
1060
|
+
},
|
|
1061
|
+
};
|
|
1049
1062
|
/**
|
|
1050
1063
|
* MSAL partial base client for Node.js.
|
|
1051
1064
|
*
|
|
@@ -1057,12 +1070,8 @@ const msalNodeFlowCacheControl = {
|
|
|
1057
1070
|
*/
|
|
1058
1071
|
class MsalNode extends MsalBaseUtilities {
|
|
1059
1072
|
constructor(options) {
|
|
1060
|
-
var _a, _b, _c, _d;
|
|
1073
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1061
1074
|
super(options);
|
|
1062
|
-
// protected publicApp: msalNode.PublicClientApplication | undefined;
|
|
1063
|
-
// protected publicAppCae: msalNode.PublicClientApplication | undefined;
|
|
1064
|
-
// protected confidentialApp: msalNode.ConfidentialClientApplication | undefined;
|
|
1065
|
-
// protected confidentialAppCae: msalNode.ConfidentialClientApplication | undefined;
|
|
1066
1075
|
this.app = {};
|
|
1067
1076
|
this.caeApp = {};
|
|
1068
1077
|
this.requiresConfidential = false;
|
|
@@ -1073,14 +1082,17 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1073
1082
|
if (options === null || options === void 0 ? void 0 : options.getAssertion) {
|
|
1074
1083
|
this.getAssertion = options.getAssertion;
|
|
1075
1084
|
}
|
|
1085
|
+
this.enableBroker = (_b = options === null || options === void 0 ? void 0 : options.brokerOptions) === null || _b === void 0 ? void 0 : _b.enabled;
|
|
1086
|
+
this.enableMsaPassthrough = (_c = options === null || options === void 0 ? void 0 : options.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough;
|
|
1087
|
+
this.parentWindowHandle = (_d = options.brokerOptions) === null || _d === void 0 ? void 0 : _d.parentWindowHandle;
|
|
1076
1088
|
// If persistence has been configured
|
|
1077
|
-
if (persistenceProvider !== undefined && ((
|
|
1089
|
+
if (persistenceProvider !== undefined && ((_e = options.tokenCachePersistenceOptions) === null || _e === void 0 ? void 0 : _e.enabled)) {
|
|
1078
1090
|
const nonCaeOptions = Object.assign({ name: `${options.tokenCachePersistenceOptions.name}.${CACHE_NON_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);
|
|
1079
1091
|
const caeOptions = Object.assign({ name: `${options.tokenCachePersistenceOptions.name}.${CACHE_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);
|
|
1080
1092
|
this.createCachePlugin = () => persistenceProvider(nonCaeOptions);
|
|
1081
1093
|
this.createCachePluginCae = () => persistenceProvider(caeOptions);
|
|
1082
1094
|
}
|
|
1083
|
-
else if ((
|
|
1095
|
+
else if ((_f = options.tokenCachePersistenceOptions) === null || _f === void 0 ? void 0 : _f.enabled) {
|
|
1084
1096
|
throw new Error([
|
|
1085
1097
|
"Persistent token caching was requested, but no persistence provider was configured.",
|
|
1086
1098
|
"You must install the identity-cache-persistence plugin package (`npm install --save @azure/identity-cache-persistence`)",
|
|
@@ -1088,7 +1100,16 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1088
1100
|
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`.",
|
|
1089
1101
|
].join(" "));
|
|
1090
1102
|
}
|
|
1091
|
-
|
|
1103
|
+
// If broker has not been configured
|
|
1104
|
+
if (!hasNativeBroker() && this.enableBroker) {
|
|
1105
|
+
throw new Error([
|
|
1106
|
+
"Broker for WAM was requested to be enabled, but no native broker was configured.",
|
|
1107
|
+
"You must install the identity-broker plugin package (`npm install --save @azure/identity-broker`)",
|
|
1108
|
+
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
1109
|
+
"`useIdentityPlugin(createNativeBrokerPlugin())` before using `enableBroker`.",
|
|
1110
|
+
].join(" "));
|
|
1111
|
+
}
|
|
1112
|
+
this.azureRegion = (_g = options.regionalAuthority) !== null && _g !== void 0 ? _g : process.env.AZURE_REGIONAL_AUTHORITY_NAME;
|
|
1092
1113
|
if (this.azureRegion === RegionalAuthority.AutoDiscoverRegion) {
|
|
1093
1114
|
this.azureRegion = "AUTO_DISCOVER";
|
|
1094
1115
|
}
|
|
@@ -1165,11 +1186,20 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1165
1186
|
cachePlugin: await this.createCachePlugin(),
|
|
1166
1187
|
};
|
|
1167
1188
|
}
|
|
1189
|
+
if (hasNativeBroker() && this.enableBroker) {
|
|
1190
|
+
this.msalConfig.broker = {
|
|
1191
|
+
nativeBrokerPlugin: nativeBrokerInfo.broker,
|
|
1192
|
+
};
|
|
1193
|
+
if (!this.parentWindowHandle) {
|
|
1194
|
+
// error should have been thrown from within the constructor of InteractiveBrowserCredential
|
|
1195
|
+
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1168
1198
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1169
|
-
this.caeApp.public = new
|
|
1199
|
+
this.caeApp.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
1170
1200
|
}
|
|
1171
1201
|
else {
|
|
1172
|
-
this.app.public = new
|
|
1202
|
+
this.app.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
1173
1203
|
}
|
|
1174
1204
|
if (this.getAssertion) {
|
|
1175
1205
|
this.msalConfig.auth.clientAssertion = await this.getAssertion();
|
|
@@ -1179,10 +1209,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1179
1209
|
this.msalConfig.auth.clientAssertion ||
|
|
1180
1210
|
this.msalConfig.auth.clientCertificate) {
|
|
1181
1211
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1182
|
-
this.caeApp.confidential = new
|
|
1212
|
+
this.caeApp.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1183
1213
|
}
|
|
1184
1214
|
else {
|
|
1185
|
-
this.app.confidential = new
|
|
1215
|
+
this.app.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1186
1216
|
}
|
|
1187
1217
|
}
|
|
1188
1218
|
else {
|
|
@@ -1255,6 +1285,18 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1255
1285
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1256
1286
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
1257
1287
|
};
|
|
1288
|
+
if (hasNativeBroker() && this.enableBroker) {
|
|
1289
|
+
if (!silentRequest.tokenQueryParameters) {
|
|
1290
|
+
silentRequest.tokenQueryParameters = {};
|
|
1291
|
+
}
|
|
1292
|
+
if (!this.parentWindowHandle) {
|
|
1293
|
+
// error should have been thrown from within the constructor of InteractiveBrowserCredential
|
|
1294
|
+
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
1295
|
+
}
|
|
1296
|
+
if (this.enableMsaPassthrough) {
|
|
1297
|
+
silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1258
1300
|
try {
|
|
1259
1301
|
this.logger.info("Attempting to acquire token silently");
|
|
1260
1302
|
/**
|
|
@@ -1313,6 +1355,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1313
1355
|
}
|
|
1314
1356
|
|
|
1315
1357
|
// Copyright (c) Microsoft Corporation.
|
|
1358
|
+
// Licensed under the MIT license.
|
|
1316
1359
|
const CommonTenantId = "common";
|
|
1317
1360
|
const AzureAccountClientId = "aebc6443-996d-45c2-90f0-388ff96faa56"; // VSC: 'aebc6443-996d-45c2-90f0-388ff96faa56'
|
|
1318
1361
|
const logger$m = credentialLogger("VisualStudioCodeCredential");
|
|
@@ -1347,10 +1390,10 @@ function getPropertyFromVSCode(property) {
|
|
|
1347
1390
|
const settingsPath = ["User", "settings.json"];
|
|
1348
1391
|
// Eventually we can add more folders for more versions of VSCode.
|
|
1349
1392
|
const vsCodeFolder = "Code";
|
|
1350
|
-
const homedir =
|
|
1393
|
+
const homedir = os.homedir();
|
|
1351
1394
|
function loadProperty(...pathSegments) {
|
|
1352
|
-
const fullPath =
|
|
1353
|
-
const settings = JSON.parse(
|
|
1395
|
+
const fullPath = path.join(...pathSegments, vsCodeFolder, ...settingsPath);
|
|
1396
|
+
const settings = JSON.parse(fs.readFileSync(fullPath, { encoding: "utf8" }));
|
|
1354
1397
|
return settings[property];
|
|
1355
1398
|
}
|
|
1356
1399
|
try {
|
|
@@ -1493,6 +1536,7 @@ class VisualStudioCodeCredential {
|
|
|
1493
1536
|
}
|
|
1494
1537
|
|
|
1495
1538
|
// Copyright (c) Microsoft Corporation.
|
|
1539
|
+
// Licensed under the MIT license.
|
|
1496
1540
|
/**
|
|
1497
1541
|
* The context passed to an Identity plugin. This contains objects that
|
|
1498
1542
|
* plugins can use to set backend implementations.
|
|
@@ -1500,6 +1544,7 @@ class VisualStudioCodeCredential {
|
|
|
1500
1544
|
*/
|
|
1501
1545
|
const pluginContext = {
|
|
1502
1546
|
cachePluginControl: msalNodeFlowCacheControl,
|
|
1547
|
+
nativeBrokerPluginControl: msalNodeFlowNativeBrokerControl,
|
|
1503
1548
|
vsCodeCredentialControl: vsCodeCredentialControl,
|
|
1504
1549
|
};
|
|
1505
1550
|
/**
|
|
@@ -1534,6 +1579,7 @@ function useIdentityPlugin(plugin) {
|
|
|
1534
1579
|
}
|
|
1535
1580
|
|
|
1536
1581
|
// Copyright (c) Microsoft Corporation.
|
|
1582
|
+
// Licensed under the MIT license.
|
|
1537
1583
|
const msiName$6 = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
1538
1584
|
const logger$l = credentialLogger(msiName$6);
|
|
1539
1585
|
/**
|
|
@@ -1601,6 +1647,7 @@ const appServiceMsi2017 = {
|
|
|
1601
1647
|
};
|
|
1602
1648
|
|
|
1603
1649
|
// Copyright (c) Microsoft Corporation.
|
|
1650
|
+
// Licensed under the MIT license.
|
|
1604
1651
|
const msiName$5 = "ManagedIdentityCredential - CloudShellMSI";
|
|
1605
1652
|
const logger$k = credentialLogger(msiName$5);
|
|
1606
1653
|
/**
|
|
@@ -1672,6 +1719,7 @@ const cloudShellMsi = {
|
|
|
1672
1719
|
};
|
|
1673
1720
|
|
|
1674
1721
|
// Copyright (c) Microsoft Corporation.
|
|
1722
|
+
// Licensed under the MIT license.
|
|
1675
1723
|
const msiName$4 = "ManagedIdentityCredential - IMDS";
|
|
1676
1724
|
const logger$j = credentialLogger(msiName$4);
|
|
1677
1725
|
/**
|
|
@@ -1814,6 +1862,7 @@ const imdsMsi = {
|
|
|
1814
1862
|
};
|
|
1815
1863
|
|
|
1816
1864
|
// Copyright (c) Microsoft Corporation.
|
|
1865
|
+
// Licensed under the MIT license.
|
|
1817
1866
|
const msiName$3 = "ManagedIdentityCredential - Azure Arc MSI";
|
|
1818
1867
|
const logger$i = credentialLogger(msiName$3);
|
|
1819
1868
|
/**
|
|
@@ -1924,6 +1973,7 @@ const arcMsi = {
|
|
|
1924
1973
|
};
|
|
1925
1974
|
|
|
1926
1975
|
// Copyright (c) Microsoft Corporation.
|
|
1976
|
+
// Licensed under the MIT license.
|
|
1927
1977
|
/**
|
|
1928
1978
|
* MSAL client assertion client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
1929
1979
|
* @internal
|
|
@@ -1963,6 +2013,7 @@ class MsalClientAssertion extends MsalNode {
|
|
|
1963
2013
|
}
|
|
1964
2014
|
|
|
1965
2015
|
// Copyright (c) Microsoft Corporation.
|
|
2016
|
+
// Licensed under the MIT license.
|
|
1966
2017
|
const logger$h = credentialLogger("ClientAssertionCredential");
|
|
1967
2018
|
/**
|
|
1968
2019
|
* Authenticates a service principal with a JWT assertion.
|
|
@@ -1970,10 +2021,10 @@ const logger$h = credentialLogger("ClientAssertionCredential");
|
|
|
1970
2021
|
class ClientAssertionCredential {
|
|
1971
2022
|
/**
|
|
1972
2023
|
* Creates an instance of the ClientAssertionCredential with the details
|
|
1973
|
-
* needed to authenticate against
|
|
2024
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
1974
2025
|
* assertion provided by the developer through the `getAssertion` function parameter.
|
|
1975
2026
|
*
|
|
1976
|
-
* @param tenantId - The
|
|
2027
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
1977
2028
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
1978
2029
|
* @param getAssertion - A function that retrieves the assertion for the credential to use.
|
|
1979
2030
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -1989,7 +2040,7 @@ class ClientAssertionCredential {
|
|
|
1989
2040
|
this.msalFlow = new MsalClientAssertion(Object.assign(Object.assign({}, options), { logger: logger$h, clientId: this.clientId, tenantId: this.tenantId, tokenCredentialOptions: this.options, getAssertion }));
|
|
1990
2041
|
}
|
|
1991
2042
|
/**
|
|
1992
|
-
* Authenticates with
|
|
2043
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
1993
2044
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
1994
2045
|
*
|
|
1995
2046
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2006,6 +2057,7 @@ class ClientAssertionCredential {
|
|
|
2006
2057
|
}
|
|
2007
2058
|
|
|
2008
2059
|
// Copyright (c) Microsoft Corporation.
|
|
2060
|
+
// Licensed under the MIT license.
|
|
2009
2061
|
const credentialName$3 = "WorkloadIdentityCredential";
|
|
2010
2062
|
/**
|
|
2011
2063
|
* Contains the list of all supported environment variable names so that an
|
|
@@ -2029,14 +2081,14 @@ const logger$g = credentialLogger(credentialName$3);
|
|
|
2029
2081
|
* Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
|
|
2030
2082
|
* each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
|
|
2031
2083
|
* need to worry about storing and securing sensitive credentials themselves.
|
|
2032
|
-
* The WorkloadIdentityCredential supports
|
|
2084
|
+
* The WorkloadIdentityCredential supports Microsoft Entra Workload ID authentication on Azure Kubernetes and acquires
|
|
2033
2085
|
* a token using the SACs available in the Azure Kubernetes environment.
|
|
2034
|
-
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">
|
|
2035
|
-
* Workload
|
|
2086
|
+
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Microsoft Entra
|
|
2087
|
+
* Workload ID</a> for more information.
|
|
2036
2088
|
*/
|
|
2037
2089
|
class WorkloadIdentityCredential {
|
|
2038
2090
|
/**
|
|
2039
|
-
* WorkloadIdentityCredential supports
|
|
2091
|
+
* WorkloadIdentityCredential supports Microsoft Entra Workload ID on Kubernetes.
|
|
2040
2092
|
*
|
|
2041
2093
|
* @param options - The identity client options to use for authentication.
|
|
2042
2094
|
*/
|
|
@@ -2060,7 +2112,7 @@ class WorkloadIdentityCredential {
|
|
|
2060
2112
|
}
|
|
2061
2113
|
}
|
|
2062
2114
|
/**
|
|
2063
|
-
* Authenticates with
|
|
2115
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2064
2116
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2065
2117
|
*
|
|
2066
2118
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2104,6 +2156,7 @@ class WorkloadIdentityCredential {
|
|
|
2104
2156
|
}
|
|
2105
2157
|
|
|
2106
2158
|
// Copyright (c) Microsoft Corporation.
|
|
2159
|
+
// Licensed under the MIT license.
|
|
2107
2160
|
const msiName$2 = "ManagedIdentityCredential - Token Exchange";
|
|
2108
2161
|
const logger$f = credentialLogger(msiName$2);
|
|
2109
2162
|
/**
|
|
@@ -2133,6 +2186,7 @@ function tokenExchangeMsi() {
|
|
|
2133
2186
|
}
|
|
2134
2187
|
|
|
2135
2188
|
// Copyright (c) Microsoft Corporation.
|
|
2189
|
+
// Licensed under the MIT license.
|
|
2136
2190
|
// This MSI can be easily tested by deploying a container to Azure Service Fabric with the Dockerfile:
|
|
2137
2191
|
//
|
|
2138
2192
|
// FROM node:12
|
|
@@ -2211,7 +2265,7 @@ const fabricMsi = {
|
|
|
2211
2265
|
"IDENTITY_SERVER_THUMBPRINT=[REDACTED].",
|
|
2212
2266
|
].join(" "));
|
|
2213
2267
|
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$1(scopes, clientId, resourceId)));
|
|
2214
|
-
request.agent = new
|
|
2268
|
+
request.agent = new https.Agent({
|
|
2215
2269
|
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
2216
2270
|
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
2217
2271
|
rejectUnauthorized: false,
|
|
@@ -2222,6 +2276,7 @@ const fabricMsi = {
|
|
|
2222
2276
|
};
|
|
2223
2277
|
|
|
2224
2278
|
// Copyright (c) Microsoft Corporation.
|
|
2279
|
+
// Licensed under the MIT license.
|
|
2225
2280
|
const msiName = "ManagedIdentityCredential - AppServiceMSI 2019";
|
|
2226
2281
|
const logger$d = credentialLogger(msiName);
|
|
2227
2282
|
/**
|
|
@@ -2289,6 +2344,7 @@ const appServiceMsi2019 = {
|
|
|
2289
2344
|
};
|
|
2290
2345
|
|
|
2291
2346
|
// Copyright (c) Microsoft Corporation.
|
|
2347
|
+
// Licensed under the MIT license.
|
|
2292
2348
|
const logger$c = credentialLogger("ManagedIdentityCredential");
|
|
2293
2349
|
/**
|
|
2294
2350
|
* Attempts authentication using a managed identity available at the deployment environment.
|
|
@@ -2328,8 +2384,9 @@ class ManagedIdentityCredential {
|
|
|
2328
2384
|
/** authority host validation and metadata discovery to be skipped in managed identity
|
|
2329
2385
|
* since this wasn't done previously before adding token cache support
|
|
2330
2386
|
*/
|
|
2331
|
-
this.confidentialApp = new
|
|
2387
|
+
this.confidentialApp = new msalCommon.ConfidentialClientApplication({
|
|
2332
2388
|
auth: {
|
|
2389
|
+
authority: "https://login.microsoftonline.com/managed_identity",
|
|
2333
2390
|
clientId: (_a = this.clientId) !== null && _a !== void 0 ? _a : DeveloperSignOnClientId,
|
|
2334
2391
|
clientSecret: "dummy-secret",
|
|
2335
2392
|
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"]}]}',
|
|
@@ -2394,7 +2451,7 @@ class ManagedIdentityCredential {
|
|
|
2394
2451
|
}
|
|
2395
2452
|
}
|
|
2396
2453
|
/**
|
|
2397
|
-
* Authenticates with
|
|
2454
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2398
2455
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2399
2456
|
* If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
|
|
2400
2457
|
*
|
|
@@ -2417,7 +2474,7 @@ class ManagedIdentityCredential {
|
|
|
2417
2474
|
else {
|
|
2418
2475
|
const appTokenParameters = {
|
|
2419
2476
|
correlationId: this.identityClient.getCorrelationId(),
|
|
2420
|
-
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "
|
|
2477
|
+
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "managed_identity",
|
|
2421
2478
|
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
2422
2479
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
2423
2480
|
};
|
|
@@ -2578,6 +2635,7 @@ class ManagedIdentityCredential {
|
|
|
2578
2635
|
}
|
|
2579
2636
|
|
|
2580
2637
|
// Copyright (c) Microsoft Corporation.
|
|
2638
|
+
// Licensed under the MIT license.
|
|
2581
2639
|
/**
|
|
2582
2640
|
* Ensures the scopes value is an array.
|
|
2583
2641
|
* @internal
|
|
@@ -2605,6 +2663,7 @@ function getScopeResource(scope) {
|
|
|
2605
2663
|
}
|
|
2606
2664
|
|
|
2607
2665
|
// Copyright (c) Microsoft Corporation.
|
|
2666
|
+
// Licensed under the MIT license.
|
|
2608
2667
|
/**
|
|
2609
2668
|
* Mockable reference to the CLI credential cliCredentialFunctions
|
|
2610
2669
|
* @internal
|
|
@@ -2636,7 +2695,7 @@ const cliCredentialInternals = {
|
|
|
2636
2695
|
}
|
|
2637
2696
|
return new Promise((resolve, reject) => {
|
|
2638
2697
|
try {
|
|
2639
|
-
|
|
2698
|
+
child_process.execFile("az", [
|
|
2640
2699
|
"account",
|
|
2641
2700
|
"get-access-token",
|
|
2642
2701
|
"--output",
|
|
@@ -2679,7 +2738,7 @@ class AzureCliCredential {
|
|
|
2679
2738
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2680
2739
|
}
|
|
2681
2740
|
/**
|
|
2682
|
-
* Authenticates with
|
|
2741
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2683
2742
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2684
2743
|
*
|
|
2685
2744
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2741,6 +2800,7 @@ class AzureCliCredential {
|
|
|
2741
2800
|
}
|
|
2742
2801
|
|
|
2743
2802
|
// Copyright (c) Microsoft Corporation.
|
|
2803
|
+
// Licensed under the MIT license.
|
|
2744
2804
|
/**
|
|
2745
2805
|
* Easy to mock childProcess utils.
|
|
2746
2806
|
* @internal
|
|
@@ -2771,6 +2831,7 @@ const processUtils = {
|
|
|
2771
2831
|
};
|
|
2772
2832
|
|
|
2773
2833
|
// Copyright (c) Microsoft Corporation.
|
|
2834
|
+
// Licensed under the MIT license.
|
|
2774
2835
|
const logger$a = credentialLogger("AzurePowerShellCredential");
|
|
2775
2836
|
const isWindows = process.platform === "win32";
|
|
2776
2837
|
/**
|
|
@@ -2904,7 +2965,7 @@ class AzurePowerShellCredential {
|
|
|
2904
2965
|
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
|
|
2905
2966
|
}
|
|
2906
2967
|
/**
|
|
2907
|
-
* Authenticates with
|
|
2968
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2908
2969
|
* If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
|
|
2909
2970
|
*
|
|
2910
2971
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2948,6 +3009,7 @@ class AzurePowerShellCredential {
|
|
|
2948
3009
|
}
|
|
2949
3010
|
|
|
2950
3011
|
// Copyright (c) Microsoft Corporation.
|
|
3012
|
+
// Licensed under the MIT license.
|
|
2951
3013
|
/**
|
|
2952
3014
|
* @internal
|
|
2953
3015
|
*/
|
|
@@ -3026,6 +3088,7 @@ class ChainedTokenCredential {
|
|
|
3026
3088
|
}
|
|
3027
3089
|
|
|
3028
3090
|
// Copyright (c) Microsoft Corporation.
|
|
3091
|
+
// Licensed under the MIT license.
|
|
3029
3092
|
const readFileAsync = util.promisify(fs.readFile);
|
|
3030
3093
|
/**
|
|
3031
3094
|
* Tries to asynchronously load a certificate from the given path.
|
|
@@ -3131,10 +3194,11 @@ class MsalClientCertificate extends MsalNode {
|
|
|
3131
3194
|
}
|
|
3132
3195
|
|
|
3133
3196
|
// Copyright (c) Microsoft Corporation.
|
|
3197
|
+
// Licensed under the MIT license.
|
|
3134
3198
|
const credentialName$2 = "ClientCertificateCredential";
|
|
3135
3199
|
const logger$8 = credentialLogger(credentialName$2);
|
|
3136
3200
|
/**
|
|
3137
|
-
* Enables authentication to
|
|
3201
|
+
* Enables authentication to Microsoft Entra ID using a PEM-encoded
|
|
3138
3202
|
* certificate that is assigned to an App Registration. More information
|
|
3139
3203
|
* on how to configure certificate authentication can be found here:
|
|
3140
3204
|
*
|
|
@@ -3168,7 +3232,7 @@ class ClientCertificateCredential {
|
|
|
3168
3232
|
tenantId, sendCertificateChain: options.sendCertificateChain, tokenCredentialOptions: options }));
|
|
3169
3233
|
}
|
|
3170
3234
|
/**
|
|
3171
|
-
* Authenticates with
|
|
3235
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3172
3236
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3173
3237
|
*
|
|
3174
3238
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3185,6 +3249,7 @@ class ClientCertificateCredential {
|
|
|
3185
3249
|
}
|
|
3186
3250
|
|
|
3187
3251
|
// Copyright (c) Microsoft Corporation.
|
|
3252
|
+
// Licensed under the MIT license.
|
|
3188
3253
|
/**
|
|
3189
3254
|
* MSAL client secret client. Calls to MSAL's confidential application's `acquireTokenByClientCredential` during `doGetToken`.
|
|
3190
3255
|
* @internal
|
|
@@ -3215,22 +3280,23 @@ class MsalClientSecret extends MsalNode {
|
|
|
3215
3280
|
}
|
|
3216
3281
|
|
|
3217
3282
|
// Copyright (c) Microsoft Corporation.
|
|
3283
|
+
// Licensed under the MIT license.
|
|
3218
3284
|
const logger$7 = credentialLogger("ClientSecretCredential");
|
|
3219
3285
|
/**
|
|
3220
|
-
* Enables authentication to
|
|
3286
|
+
* Enables authentication to Microsoft Entra ID using a client secret
|
|
3221
3287
|
* that was generated for an App Registration. More information on how
|
|
3222
3288
|
* to configure a client secret can be found here:
|
|
3223
3289
|
*
|
|
3224
|
-
* https://
|
|
3290
|
+
* https://learn.microsoft.com/azure/active-directory/develop/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
|
|
3225
3291
|
*
|
|
3226
3292
|
*/
|
|
3227
3293
|
class ClientSecretCredential {
|
|
3228
3294
|
/**
|
|
3229
3295
|
* Creates an instance of the ClientSecretCredential with the details
|
|
3230
|
-
* needed to authenticate against
|
|
3296
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
3231
3297
|
* secret.
|
|
3232
3298
|
*
|
|
3233
|
-
* @param tenantId - The
|
|
3299
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
3234
3300
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3235
3301
|
* @param clientSecret - A client secret that was generated for the App Registration.
|
|
3236
3302
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -3247,7 +3313,7 @@ class ClientSecretCredential {
|
|
|
3247
3313
|
clientSecret, tokenCredentialOptions: options }));
|
|
3248
3314
|
}
|
|
3249
3315
|
/**
|
|
3250
|
-
* Authenticates with
|
|
3316
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3251
3317
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3252
3318
|
*
|
|
3253
3319
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3264,6 +3330,7 @@ class ClientSecretCredential {
|
|
|
3264
3330
|
}
|
|
3265
3331
|
|
|
3266
3332
|
// Copyright (c) Microsoft Corporation.
|
|
3333
|
+
// Licensed under the MIT license.
|
|
3267
3334
|
/**
|
|
3268
3335
|
* MSAL username and password client. Calls to the MSAL's public application's `acquireTokenByUsernamePassword` during `doGetToken`.
|
|
3269
3336
|
* @internal
|
|
@@ -3294,9 +3361,10 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
3294
3361
|
}
|
|
3295
3362
|
|
|
3296
3363
|
// Copyright (c) Microsoft Corporation.
|
|
3364
|
+
// Licensed under the MIT license.
|
|
3297
3365
|
const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
3298
3366
|
/**
|
|
3299
|
-
* Enables authentication to
|
|
3367
|
+
* Enables authentication to Microsoft Entra ID with a user's
|
|
3300
3368
|
* username and password. This credential requires a high degree of
|
|
3301
3369
|
* trust so you should only use it when other, more secure credential
|
|
3302
3370
|
* types can't be used.
|
|
@@ -3304,10 +3372,10 @@ const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
|
3304
3372
|
class UsernamePasswordCredential {
|
|
3305
3373
|
/**
|
|
3306
3374
|
* Creates an instance of the UsernamePasswordCredential with the details
|
|
3307
|
-
* needed to authenticate against
|
|
3375
|
+
* needed to authenticate against Microsoft Entra ID with a username
|
|
3308
3376
|
* and password.
|
|
3309
3377
|
*
|
|
3310
|
-
* @param tenantId - The
|
|
3378
|
+
* @param tenantId - The Microsoft Entra tenant (directory).
|
|
3311
3379
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3312
3380
|
* @param username - The user account's e-mail address (user name).
|
|
3313
3381
|
* @param password - The user account's account password
|
|
@@ -3326,7 +3394,7 @@ class UsernamePasswordCredential {
|
|
|
3326
3394
|
password, tokenCredentialOptions: options || {} }));
|
|
3327
3395
|
}
|
|
3328
3396
|
/**
|
|
3329
|
-
* Authenticates with
|
|
3397
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3330
3398
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3331
3399
|
*
|
|
3332
3400
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3347,6 +3415,7 @@ class UsernamePasswordCredential {
|
|
|
3347
3415
|
}
|
|
3348
3416
|
|
|
3349
3417
|
// Copyright (c) Microsoft Corporation.
|
|
3418
|
+
// Licensed under the MIT license.
|
|
3350
3419
|
/**
|
|
3351
3420
|
* Contains the list of all supported environment variable names so that an
|
|
3352
3421
|
* appropriate error message can be generated when no credentials can be
|
|
@@ -3372,7 +3441,7 @@ function getAdditionallyAllowedTenants() {
|
|
|
3372
3441
|
const credentialName$1 = "EnvironmentCredential";
|
|
3373
3442
|
const logger$5 = credentialLogger(credentialName$1);
|
|
3374
3443
|
/**
|
|
3375
|
-
* Enables authentication to
|
|
3444
|
+
* Enables authentication to Microsoft Entra ID using a client secret or certificate, or as a user
|
|
3376
3445
|
* with a username and password.
|
|
3377
3446
|
*/
|
|
3378
3447
|
class EnvironmentCredential {
|
|
@@ -3380,7 +3449,7 @@ class EnvironmentCredential {
|
|
|
3380
3449
|
* Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
|
|
3381
3450
|
*
|
|
3382
3451
|
* Required environment variables:
|
|
3383
|
-
* - `AZURE_TENANT_ID`: The
|
|
3452
|
+
* - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
|
|
3384
3453
|
* - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
|
|
3385
3454
|
*
|
|
3386
3455
|
* If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
|
|
@@ -3431,7 +3500,7 @@ class EnvironmentCredential {
|
|
|
3431
3500
|
}
|
|
3432
3501
|
}
|
|
3433
3502
|
/**
|
|
3434
|
-
* Authenticates with
|
|
3503
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3435
3504
|
*
|
|
3436
3505
|
* @param scopes - The list of scopes for which the token will have access.
|
|
3437
3506
|
* @param options - Optional parameters. See {@link GetTokenOptions}.
|
|
@@ -3459,6 +3528,7 @@ class EnvironmentCredential {
|
|
|
3459
3528
|
}
|
|
3460
3529
|
|
|
3461
3530
|
// Copyright (c) Microsoft Corporation.
|
|
3531
|
+
// Licensed under the MIT license.
|
|
3462
3532
|
/**
|
|
3463
3533
|
* Mockable reference to the Developer CLI credential cliCredentialFunctions
|
|
3464
3534
|
* @internal
|
|
@@ -3490,7 +3560,7 @@ const developerCliCredentialInternals = {
|
|
|
3490
3560
|
}
|
|
3491
3561
|
return new Promise((resolve, reject) => {
|
|
3492
3562
|
try {
|
|
3493
|
-
|
|
3563
|
+
child_process.execFile("azd", [
|
|
3494
3564
|
"auth",
|
|
3495
3565
|
"token",
|
|
3496
3566
|
"--output",
|
|
@@ -3515,11 +3585,11 @@ const logger$4 = credentialLogger("AzureDeveloperCliCredential");
|
|
|
3515
3585
|
* Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
|
|
3516
3586
|
* resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
|
|
3517
3587
|
* to Azure developers. It allows users to authenticate as a user and/or a service principal against
|
|
3518
|
-
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">
|
|
3519
|
-
*
|
|
3588
|
+
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">Microsoft Entra ID</a>. The
|
|
3589
|
+
* AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
|
|
3520
3590
|
* the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
|
|
3521
3591
|
* service principal and executes an Azure CLI command underneath to authenticate the application against
|
|
3522
|
-
*
|
|
3592
|
+
* Microsoft Entra ID.
|
|
3523
3593
|
*
|
|
3524
3594
|
* <h2> Configure AzureDeveloperCliCredential </h2>
|
|
3525
3595
|
*
|
|
@@ -3554,7 +3624,7 @@ class AzureDeveloperCliCredential {
|
|
|
3554
3624
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
3555
3625
|
}
|
|
3556
3626
|
/**
|
|
3557
|
-
* Authenticates with
|
|
3627
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3558
3628
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3559
3629
|
*
|
|
3560
3630
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3622,6 +3692,7 @@ class AzureDeveloperCliCredential {
|
|
|
3622
3692
|
}
|
|
3623
3693
|
|
|
3624
3694
|
// Copyright (c) Microsoft Corporation.
|
|
3695
|
+
// Licensed under the MIT license.
|
|
3625
3696
|
/**
|
|
3626
3697
|
* A shim around ManagedIdentityCredential that adapts it to accept
|
|
3627
3698
|
* `DefaultAzureCredentialOptions`.
|
|
@@ -3718,12 +3789,13 @@ class DefaultAzureCredential extends ChainedTokenCredential {
|
|
|
3718
3789
|
}
|
|
3719
3790
|
|
|
3720
3791
|
// Copyright (c) Microsoft Corporation.
|
|
3792
|
+
// Licensed under the MIT license.
|
|
3721
3793
|
/**
|
|
3722
3794
|
* A call to open(), but mockable
|
|
3723
3795
|
* @internal
|
|
3724
3796
|
*/
|
|
3725
3797
|
const interactiveBrowserMockable = {
|
|
3726
|
-
open
|
|
3798
|
+
open,
|
|
3727
3799
|
};
|
|
3728
3800
|
/**
|
|
3729
3801
|
* 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`
|
|
@@ -3732,182 +3804,106 @@ const interactiveBrowserMockable = {
|
|
|
3732
3804
|
*/
|
|
3733
3805
|
class MsalOpenBrowser extends MsalNode {
|
|
3734
3806
|
constructor(options) {
|
|
3807
|
+
var _a, _b;
|
|
3735
3808
|
super(options);
|
|
3736
|
-
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3737
|
-
this.redirectUri = options.redirectUri;
|
|
3738
3809
|
this.loginHint = options.loginHint;
|
|
3739
|
-
|
|
3740
|
-
this.
|
|
3741
|
-
|
|
3742
|
-
this.port = 80;
|
|
3743
|
-
}
|
|
3744
|
-
this.hostname = url.hostname;
|
|
3745
|
-
}
|
|
3746
|
-
async acquireTokenByCode(request, enableCae) {
|
|
3747
|
-
return this.getApp("public", enableCae).acquireTokenByCode(request);
|
|
3810
|
+
this.errorTemplate = (_a = options.browserCustomizationOptions) === null || _a === void 0 ? void 0 : _a.errorMessage;
|
|
3811
|
+
this.successTemplate = (_b = options.browserCustomizationOptions) === null || _b === void 0 ? void 0 : _b.successMessage;
|
|
3812
|
+
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3748
3813
|
}
|
|
3749
|
-
doGetToken(scopes, options) {
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
const
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
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
|
-
});
|
|
3814
|
+
async doGetToken(scopes, options) {
|
|
3815
|
+
var _a;
|
|
3816
|
+
try {
|
|
3817
|
+
const interactiveRequest = {
|
|
3818
|
+
openBrowser: async (url) => {
|
|
3819
|
+
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
|
3820
|
+
},
|
|
3821
|
+
scopes,
|
|
3822
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3823
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3824
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3825
|
+
loginHint: this.loginHint,
|
|
3826
|
+
errorTemplate: this.errorTemplate,
|
|
3827
|
+
successTemplate: this.successTemplate,
|
|
3807
3828
|
};
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
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(" ")));
|
|
3829
|
+
if (hasNativeBroker() && this.enableBroker) {
|
|
3830
|
+
this.logger.verbose("Authentication will resume through the broker");
|
|
3831
|
+
if (this.parentWindowHandle) {
|
|
3832
|
+
interactiveRequest.windowHandle = Buffer.from(this.parentWindowHandle);
|
|
3833
3833
|
}
|
|
3834
3834
|
else {
|
|
3835
|
-
|
|
3835
|
+
// error should have been thrown from within the constructor of InteractiveBrowserCredential
|
|
3836
|
+
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
3836
3837
|
}
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
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
|
-
});
|
|
3838
|
+
if (this.enableMsaPassthrough) {
|
|
3839
|
+
((_a = interactiveRequest.tokenQueryParameters) !== null && _a !== void 0 ? _a : (interactiveRequest.tokenQueryParameters = {}))["msal_request_type"] =
|
|
3840
|
+
"consumer_passthrough";
|
|
3846
3841
|
}
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
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 });
|
|
3842
|
+
}
|
|
3843
|
+
if (hasNativeBroker() && !this.enableBroker) {
|
|
3844
|
+
this.logger.verbose("Authentication will resume normally without the broker, since it's not enabled");
|
|
3845
|
+
}
|
|
3846
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive(interactiveRequest);
|
|
3847
|
+
if (result.fromNativeBroker) {
|
|
3848
|
+
this.logger.verbose(`This result is returned from native broker`);
|
|
3849
|
+
}
|
|
3850
|
+
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3873
3851
|
}
|
|
3874
|
-
catch (
|
|
3875
|
-
throw
|
|
3852
|
+
catch (err) {
|
|
3853
|
+
throw this.handleError(scopes, err, options);
|
|
3876
3854
|
}
|
|
3877
3855
|
}
|
|
3878
3856
|
}
|
|
3879
3857
|
|
|
3880
3858
|
// Copyright (c) Microsoft Corporation.
|
|
3859
|
+
// Licensed under the MIT license.
|
|
3881
3860
|
const logger$3 = credentialLogger("InteractiveBrowserCredential");
|
|
3882
3861
|
/**
|
|
3883
|
-
* Enables authentication to
|
|
3862
|
+
* Enables authentication to Microsoft Entra ID inside of the web browser
|
|
3884
3863
|
* using the interactive login flow.
|
|
3885
3864
|
*/
|
|
3886
3865
|
class InteractiveBrowserCredential {
|
|
3887
3866
|
/**
|
|
3888
3867
|
* Creates an instance of InteractiveBrowserCredential with the details needed.
|
|
3889
3868
|
*
|
|
3890
|
-
* This credential uses the [Authorization Code Flow](https://
|
|
3869
|
+
* This credential uses the [Authorization Code Flow](https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
|
3891
3870
|
* On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
|
|
3892
3871
|
* 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.
|
|
3893
3872
|
*
|
|
3894
|
-
* For Node.js, if a `clientId` is provided, the
|
|
3895
|
-
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://
|
|
3873
|
+
* 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.
|
|
3874
|
+
* 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).
|
|
3896
3875
|
*
|
|
3897
3876
|
* @param options - Options for configuring the client which makes the authentication requests.
|
|
3898
3877
|
*/
|
|
3899
|
-
constructor(options
|
|
3878
|
+
constructor(options) {
|
|
3879
|
+
var _a, _b, _c;
|
|
3900
3880
|
const redirectUri = typeof options.redirectUri === "function"
|
|
3901
3881
|
? options.redirectUri()
|
|
3902
3882
|
: options.redirectUri || "http://localhost";
|
|
3903
3883
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3904
3884
|
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3905
|
-
|
|
3906
|
-
|
|
3885
|
+
const ibcNodeOptions = options;
|
|
3886
|
+
if ((_a = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
3887
|
+
if (!((_b = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _b === void 0 ? void 0 : _b.parentWindowHandle)) {
|
|
3888
|
+
throw new Error("In order to do WAM authentication, `parentWindowHandle` under `brokerOptions` is a required parameter");
|
|
3889
|
+
}
|
|
3890
|
+
else {
|
|
3891
|
+
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$3,
|
|
3892
|
+
redirectUri, browserCustomizationOptions: ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.browserCustomizationOptions, brokerOptions: {
|
|
3893
|
+
enabled: true,
|
|
3894
|
+
parentWindowHandle: ibcNodeOptions.brokerOptions.parentWindowHandle,
|
|
3895
|
+
legacyEnableMsaPassthrough: (_c = ibcNodeOptions.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough,
|
|
3896
|
+
} }));
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
else {
|
|
3900
|
+
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$3,
|
|
3901
|
+
redirectUri, browserCustomizationOptions: ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.browserCustomizationOptions }));
|
|
3902
|
+
}
|
|
3907
3903
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3908
3904
|
}
|
|
3909
3905
|
/**
|
|
3910
|
-
* Authenticates with
|
|
3906
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3911
3907
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3912
3908
|
*
|
|
3913
3909
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3926,7 +3922,7 @@ class InteractiveBrowserCredential {
|
|
|
3926
3922
|
});
|
|
3927
3923
|
}
|
|
3928
3924
|
/**
|
|
3929
|
-
* Authenticates with
|
|
3925
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3930
3926
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3931
3927
|
*
|
|
3932
3928
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -3948,6 +3944,7 @@ class InteractiveBrowserCredential {
|
|
|
3948
3944
|
}
|
|
3949
3945
|
|
|
3950
3946
|
// Copyright (c) Microsoft Corporation.
|
|
3947
|
+
// Licensed under the MIT license.
|
|
3951
3948
|
/**
|
|
3952
3949
|
* MSAL device code client. Calls to the MSAL's public application's `acquireTokenByDeviceCode` during `doGetToken`.
|
|
3953
3950
|
* @internal
|
|
@@ -3980,6 +3977,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3980
3977
|
}
|
|
3981
3978
|
|
|
3982
3979
|
// Copyright (c) Microsoft Corporation.
|
|
3980
|
+
// Licensed under the MIT license.
|
|
3983
3981
|
const logger$2 = credentialLogger("DeviceCodeCredential");
|
|
3984
3982
|
/**
|
|
3985
3983
|
* Method that logs the user code from the DeviceCodeCredential.
|
|
@@ -3989,13 +3987,13 @@ function defaultDeviceCodePromptCallback(deviceCodeInfo) {
|
|
|
3989
3987
|
console.log(deviceCodeInfo.message);
|
|
3990
3988
|
}
|
|
3991
3989
|
/**
|
|
3992
|
-
* Enables authentication to
|
|
3990
|
+
* Enables authentication to Microsoft Entra ID using a device code
|
|
3993
3991
|
* that the user can enter into https://microsoft.com/devicelogin.
|
|
3994
3992
|
*/
|
|
3995
3993
|
class DeviceCodeCredential {
|
|
3996
3994
|
/**
|
|
3997
3995
|
* Creates an instance of DeviceCodeCredential with the details needed
|
|
3998
|
-
* to initiate the device code authorization flow with
|
|
3996
|
+
* to initiate the device code authorization flow with Microsoft Entra ID.
|
|
3999
3997
|
*
|
|
4000
3998
|
* A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
|
|
4001
3999
|
*
|
|
@@ -4020,7 +4018,7 @@ class DeviceCodeCredential {
|
|
|
4020
4018
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
4021
4019
|
}
|
|
4022
4020
|
/**
|
|
4023
|
-
* Authenticates with
|
|
4021
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4024
4022
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4025
4023
|
*
|
|
4026
4024
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -4039,7 +4037,7 @@ class DeviceCodeCredential {
|
|
|
4039
4037
|
});
|
|
4040
4038
|
}
|
|
4041
4039
|
/**
|
|
4042
|
-
* Authenticates with
|
|
4040
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4043
4041
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4044
4042
|
*
|
|
4045
4043
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -4058,6 +4056,7 @@ class DeviceCodeCredential {
|
|
|
4058
4056
|
}
|
|
4059
4057
|
|
|
4060
4058
|
// Copyright (c) Microsoft Corporation.
|
|
4059
|
+
// Licensed under the MIT license.
|
|
4061
4060
|
/**
|
|
4062
4061
|
* 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`
|
|
4063
4062
|
* to trigger the authentication flow, and then respond based on the values obtained from the redirect callback
|
|
@@ -4101,13 +4100,14 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
4101
4100
|
}
|
|
4102
4101
|
|
|
4103
4102
|
// Copyright (c) Microsoft Corporation.
|
|
4103
|
+
// Licensed under the MIT license.
|
|
4104
4104
|
const logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
4105
4105
|
/**
|
|
4106
|
-
* Enables authentication to
|
|
4106
|
+
* Enables authentication to Microsoft Entra ID using an authorization code
|
|
4107
4107
|
* that was obtained through the authorization code flow, described in more detail
|
|
4108
|
-
* in the
|
|
4108
|
+
* in the Microsoft Entra ID documentation:
|
|
4109
4109
|
*
|
|
4110
|
-
* https://
|
|
4110
|
+
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
|
4111
4111
|
*/
|
|
4112
4112
|
class AuthorizationCodeCredential {
|
|
4113
4113
|
/**
|
|
@@ -4138,7 +4138,7 @@ class AuthorizationCodeCredential {
|
|
|
4138
4138
|
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
4139
4139
|
}
|
|
4140
4140
|
/**
|
|
4141
|
-
* Authenticates with
|
|
4141
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4142
4142
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4143
4143
|
*
|
|
4144
4144
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -4156,6 +4156,7 @@ class AuthorizationCodeCredential {
|
|
|
4156
4156
|
}
|
|
4157
4157
|
|
|
4158
4158
|
// Copyright (c) Microsoft Corporation.
|
|
4159
|
+
// Licensed under the MIT license.
|
|
4159
4160
|
/**
|
|
4160
4161
|
* MSAL on behalf of flow. Calls to MSAL's confidential application's `acquireTokenOnBehalfOf` during `doGetToken`.
|
|
4161
4162
|
* @internal
|
|
@@ -4209,6 +4210,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4209
4210
|
}
|
|
4210
4211
|
|
|
4211
4212
|
// Copyright (c) Microsoft Corporation.
|
|
4213
|
+
// Licensed under the MIT license.
|
|
4212
4214
|
const credentialName = "OnBehalfOfCredential";
|
|
4213
4215
|
const logger = credentialLogger(credentialName);
|
|
4214
4216
|
/**
|
|
@@ -4228,7 +4230,7 @@ class OnBehalfOfCredential {
|
|
|
4228
4230
|
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
4229
4231
|
}
|
|
4230
4232
|
/**
|
|
4231
|
-
* Authenticates with
|
|
4233
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4232
4234
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4233
4235
|
*
|
|
4234
4236
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -4244,6 +4246,7 @@ class OnBehalfOfCredential {
|
|
|
4244
4246
|
}
|
|
4245
4247
|
|
|
4246
4248
|
// Copyright (c) Microsoft Corporation.
|
|
4249
|
+
// Licensed under the MIT license.
|
|
4247
4250
|
/**
|
|
4248
4251
|
* Returns a new instance of the {@link DefaultAzureCredential}.
|
|
4249
4252
|
*/
|