@azure/identity 3.2.4-alpha.20230804.2 → 3.2.4-alpha.20230807.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/dist/index.js +73 -29
- package/dist/index.js.map +1 -1
- package/dist-esm/src/constants.js +2 -0
- package/dist-esm/src/constants.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +1 -0
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/msal/credentials.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +6 -4
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientAssertion.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +55 -16
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +4 -4
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +1 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
- package/dist-esm/src/msal/types.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -301,6 +301,8 @@ const DefaultAuthorityHost = exports.AzureAuthorityHosts.AzurePublicCloud;
|
|
|
301
301
|
* Allow acquiring tokens for any tenant for multi-tentant auth.
|
|
302
302
|
*/
|
|
303
303
|
const ALL_TENANTS = ["*"];
|
|
304
|
+
const CACHE_CAE_SUFFIX = ".cae";
|
|
305
|
+
const CACHE_NON_CAE_SUFFIX = ".nocae";
|
|
304
306
|
|
|
305
307
|
// Copyright (c) Microsoft Corporation.
|
|
306
308
|
/**
|
|
@@ -1057,6 +1059,12 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1057
1059
|
constructor(options) {
|
|
1058
1060
|
var _a, _b, _c, _d;
|
|
1059
1061
|
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
|
+
this.app = {};
|
|
1067
|
+
this.caeApp = {};
|
|
1060
1068
|
this.requiresConfidential = false;
|
|
1061
1069
|
this.msalConfig = this.defaultNodeMsalConfig(options);
|
|
1062
1070
|
this.tenantId = resolveTenantId(options.logger, options.tenantId, options.clientId);
|
|
@@ -1067,7 +1075,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1067
1075
|
}
|
|
1068
1076
|
// If persistence has been configured
|
|
1069
1077
|
if (persistenceProvider !== undefined && ((_b = options.tokenCachePersistenceOptions) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
1070
|
-
|
|
1078
|
+
const nonCaeOptions = Object.assign({ name: `${options.tokenCachePersistenceOptions.name}.${CACHE_NON_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);
|
|
1079
|
+
const caeOptions = Object.assign({ name: `${options.tokenCachePersistenceOptions.name}.${CACHE_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);
|
|
1080
|
+
this.createCachePlugin = () => persistenceProvider(nonCaeOptions);
|
|
1081
|
+
this.createCachePluginCae = () => persistenceProvider(caeOptions);
|
|
1071
1082
|
}
|
|
1072
1083
|
else if ((_c = options.tokenCachePersistenceOptions) === null || _c === void 0 ? void 0 : _c.enabled) {
|
|
1073
1084
|
throw new Error([
|
|
@@ -1091,10 +1102,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1091
1102
|
this.authorityHost = options.authorityHost || process.env.AZURE_AUTHORITY_HOST;
|
|
1092
1103
|
const authority = getAuthority(tenantId, this.authorityHost);
|
|
1093
1104
|
this.identityClient = new IdentityClient(Object.assign(Object.assign({}, options.tokenCredentialOptions), { authorityHost: authority, loggingOptions: options.loggingOptions }));
|
|
1094
|
-
|
|
1095
|
-
if (process.env.AZURE_IDENTITY_DISABLE_CP1) {
|
|
1096
|
-
clientCapabilities = [];
|
|
1097
|
-
}
|
|
1105
|
+
const clientCapabilities = [];
|
|
1098
1106
|
return {
|
|
1099
1107
|
auth: {
|
|
1100
1108
|
clientId,
|
|
@@ -1112,6 +1120,21 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1112
1120
|
},
|
|
1113
1121
|
};
|
|
1114
1122
|
}
|
|
1123
|
+
getApp(appType, enableCae) {
|
|
1124
|
+
const app = enableCae ? this.caeApp : this.app;
|
|
1125
|
+
if (appType === "publicFirst") {
|
|
1126
|
+
return (app.public || app.confidential);
|
|
1127
|
+
}
|
|
1128
|
+
else if (appType === "confidentialFirst") {
|
|
1129
|
+
return (app.confidential || app.public);
|
|
1130
|
+
}
|
|
1131
|
+
else if (appType === "confidential") {
|
|
1132
|
+
return app.confidential;
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
return app.public;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1115
1138
|
/**
|
|
1116
1139
|
* Prepares the MSAL applications.
|
|
1117
1140
|
*/
|
|
@@ -1123,15 +1146,29 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1123
1146
|
this.identityClient.abortRequests(options.correlationId);
|
|
1124
1147
|
});
|
|
1125
1148
|
}
|
|
1126
|
-
|
|
1149
|
+
const app = (options === null || options === void 0 ? void 0 : options.enableCae) ? this.caeApp : this.app;
|
|
1150
|
+
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1151
|
+
this.msalConfig.auth.clientCapabilities = ["cp1"];
|
|
1152
|
+
}
|
|
1153
|
+
if (app.public || app.confidential) {
|
|
1127
1154
|
return;
|
|
1128
1155
|
}
|
|
1156
|
+
if ((options === null || options === void 0 ? void 0 : options.enableCae) && this.createCachePluginCae !== undefined) {
|
|
1157
|
+
this.msalConfig.cache = {
|
|
1158
|
+
cachePlugin: await this.createCachePluginCae(),
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1129
1161
|
if (this.createCachePlugin !== undefined) {
|
|
1130
1162
|
this.msalConfig.cache = {
|
|
1131
1163
|
cachePlugin: await this.createCachePlugin(),
|
|
1132
1164
|
};
|
|
1133
1165
|
}
|
|
1134
|
-
|
|
1166
|
+
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1167
|
+
this.caeApp.public = new msalNode__namespace.PublicClientApplication(this.msalConfig);
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
this.app.public = new msalNode__namespace.PublicClientApplication(this.msalConfig);
|
|
1171
|
+
}
|
|
1135
1172
|
if (this.getAssertion) {
|
|
1136
1173
|
this.msalConfig.auth.clientAssertion = await this.getAssertion();
|
|
1137
1174
|
}
|
|
@@ -1139,7 +1176,12 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1139
1176
|
if (this.msalConfig.auth.clientSecret ||
|
|
1140
1177
|
this.msalConfig.auth.clientAssertion ||
|
|
1141
1178
|
this.msalConfig.auth.clientCertificate) {
|
|
1142
|
-
|
|
1179
|
+
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1180
|
+
this.caeApp.confidential = new msalNode__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
this.app.confidential = new msalNode__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1184
|
+
}
|
|
1143
1185
|
}
|
|
1144
1186
|
else {
|
|
1145
1187
|
if (this.requiresConfidential) {
|
|
@@ -1167,12 +1209,11 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1167
1209
|
/**
|
|
1168
1210
|
* Returns the existing account, attempts to load the account from MSAL.
|
|
1169
1211
|
*/
|
|
1170
|
-
async getActiveAccount() {
|
|
1171
|
-
var _a, _b, _c;
|
|
1212
|
+
async getActiveAccount(enableCae = false) {
|
|
1172
1213
|
if (this.account) {
|
|
1173
1214
|
return this.account;
|
|
1174
1215
|
}
|
|
1175
|
-
const cache =
|
|
1216
|
+
const cache = this.getApp("confidentialFirst", enableCae).getTokenCache();
|
|
1176
1217
|
const accountsByTenant = await (cache === null || cache === void 0 ? void 0 : cache.getAllAccounts());
|
|
1177
1218
|
if (!accountsByTenant) {
|
|
1178
1219
|
return;
|
|
@@ -1196,7 +1237,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1196
1237
|
*/
|
|
1197
1238
|
async getTokenSilent(scopes, options) {
|
|
1198
1239
|
var _a, _b, _c;
|
|
1199
|
-
await this.getActiveAccount();
|
|
1240
|
+
await this.getActiveAccount(options === null || options === void 0 ? void 0 : options.enableCae);
|
|
1200
1241
|
if (!this.account) {
|
|
1201
1242
|
throw new AuthenticationRequiredError({
|
|
1202
1243
|
scopes,
|
|
@@ -1218,10 +1259,10 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1218
1259
|
* The following code to retrieve all accounts is done as a workaround in an attempt to force the
|
|
1219
1260
|
* refresh of the token cache with the token and the account passed in through the
|
|
1220
1261
|
* `authenticationRecord` parameter. See issue - https://github.com/Azure/azure-sdk-for-js/issues/24349#issuecomment-1496715651
|
|
1221
|
-
* This workaround serves as a
|
|
1262
|
+
* This workaround serves as a workaround for silent authentication not happening when authenticationRecord is passed.
|
|
1222
1263
|
*/
|
|
1223
|
-
await ((_a =
|
|
1224
|
-
const response = (_c = (await ((_b = this.
|
|
1264
|
+
await ((_a = this.getApp("publicFirst", options === null || options === void 0 ? void 0 : options.enableCae)) === null || _a === void 0 ? void 0 : _a.getTokenCache().getAllAccounts());
|
|
1265
|
+
const response = (_c = (await ((_b = this.getApp("confidential", options === null || options === void 0 ? void 0 : options.enableCae)) === null || _b === void 0 ? void 0 : _b.acquireTokenSilent(silentRequest)))) !== null && _c !== void 0 ? _c : (await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenSilent(silentRequest));
|
|
1225
1266
|
return this.handleResult(scopes, this.clientId, response || undefined);
|
|
1226
1267
|
}
|
|
1227
1268
|
catch (err) {
|
|
@@ -1884,7 +1925,7 @@ class MsalClientAssertion extends MsalNode {
|
|
|
1884
1925
|
async doGetToken(scopes, options = {}) {
|
|
1885
1926
|
try {
|
|
1886
1927
|
const assertion = await this.getAssertion();
|
|
1887
|
-
const result = await this.
|
|
1928
|
+
const result = await this.getApp("confidential", options.enableCae).acquireTokenByClientCredential({
|
|
1888
1929
|
scopes,
|
|
1889
1930
|
correlationId: options.correlationId,
|
|
1890
1931
|
azureRegion: this.azureRegion,
|
|
@@ -2281,6 +2322,7 @@ class ManagedIdentityCredential {
|
|
|
2281
2322
|
clientSecret: "dummy-secret",
|
|
2282
2323
|
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"]}]}',
|
|
2283
2324
|
authorityMetadata: '{"token_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/common/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/{tenantid}/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/common/kerberos","tenant_region_scope":null,"cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}',
|
|
2325
|
+
clientCapabilities: [],
|
|
2284
2326
|
},
|
|
2285
2327
|
system: {
|
|
2286
2328
|
loggerOptions: {
|
|
@@ -3039,7 +3081,7 @@ class MsalClientCertificate extends MsalNode {
|
|
|
3039
3081
|
authority: options.authority,
|
|
3040
3082
|
claims: options.claims,
|
|
3041
3083
|
};
|
|
3042
|
-
const result = await this.
|
|
3084
|
+
const result = await this.getApp("confidential", options.enableCae).acquireTokenByClientCredential(clientCredReq);
|
|
3043
3085
|
// Even though we're providing the same default in memory persistence cache that we use for DeviceCodeCredential,
|
|
3044
3086
|
// The Client Credential flow does not return the account information from the authentication service,
|
|
3045
3087
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -3118,7 +3160,7 @@ class MsalClientSecret extends MsalNode {
|
|
|
3118
3160
|
}
|
|
3119
3161
|
async doGetToken(scopes, options = {}) {
|
|
3120
3162
|
try {
|
|
3121
|
-
const result = await this.
|
|
3163
|
+
const result = await this.getApp("confidential", options.enableCae).acquireTokenByClientCredential({
|
|
3122
3164
|
scopes,
|
|
3123
3165
|
correlationId: options.correlationId,
|
|
3124
3166
|
azureRegion: this.azureRegion,
|
|
@@ -3205,7 +3247,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
3205
3247
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3206
3248
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3207
3249
|
};
|
|
3208
|
-
const result = await this.
|
|
3250
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenByUsernamePassword(requestOptions);
|
|
3209
3251
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3210
3252
|
}
|
|
3211
3253
|
catch (error) {
|
|
@@ -3656,8 +3698,8 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3656
3698
|
}
|
|
3657
3699
|
this.hostname = url.hostname;
|
|
3658
3700
|
}
|
|
3659
|
-
async acquireTokenByCode(request) {
|
|
3660
|
-
return this.
|
|
3701
|
+
async acquireTokenByCode(request, enableCae) {
|
|
3702
|
+
return this.getApp("public", enableCae).acquireTokenByCode(request);
|
|
3661
3703
|
}
|
|
3662
3704
|
doGetToken(scopes, options) {
|
|
3663
3705
|
return new Promise((resolve, reject) => {
|
|
@@ -3683,7 +3725,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3683
3725
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3684
3726
|
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
3685
3727
|
};
|
|
3686
|
-
this.acquireTokenByCode(tokenRequest)
|
|
3728
|
+
this.acquireTokenByCode(tokenRequest, options === null || options === void 0 ? void 0 : options.enableCae)
|
|
3687
3729
|
.then((authResponse) => {
|
|
3688
3730
|
if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.account) {
|
|
3689
3731
|
this.account = msalToPublic(this.clientId, authResponse.account);
|
|
@@ -3779,7 +3821,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3779
3821
|
codeChallenge: this.pkceCodes.challenge,
|
|
3780
3822
|
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3781
3823
|
};
|
|
3782
|
-
const response = await this.
|
|
3824
|
+
const response = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).getAuthCodeUrl(authCodeUrlParameters);
|
|
3783
3825
|
try {
|
|
3784
3826
|
// A new instance on macOS only which allows it to not hang, does not fix the issue on linux
|
|
3785
3827
|
await interactiveBrowserMockable.open(response, { wait: true, newInstance: true });
|
|
@@ -3880,7 +3922,7 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3880
3922
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3881
3923
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3882
3924
|
};
|
|
3883
|
-
const promise = this.
|
|
3925
|
+
const promise = this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenByDeviceCode(requestOptions);
|
|
3884
3926
|
const deviceResponse = await this.withCancellation(promise, options === null || options === void 0 ? void 0 : options.abortSignal, () => {
|
|
3885
3927
|
requestOptions.cancel = true;
|
|
3886
3928
|
});
|
|
@@ -3988,19 +4030,21 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3988
4030
|
}
|
|
3989
4031
|
async getAuthCodeUrl(options) {
|
|
3990
4032
|
await this.init();
|
|
3991
|
-
return
|
|
4033
|
+
return this.getApp("confidentialFirst", options.enableCae).getAuthCodeUrl({
|
|
4034
|
+
scopes: options.scopes,
|
|
4035
|
+
redirectUri: options.redirectUri,
|
|
4036
|
+
});
|
|
3992
4037
|
}
|
|
3993
4038
|
async doGetToken(scopes, options) {
|
|
3994
|
-
var _a;
|
|
3995
4039
|
try {
|
|
3996
|
-
const result = await
|
|
4040
|
+
const result = await this.getApp("confidentialFirst", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenByCode({
|
|
3997
4041
|
scopes,
|
|
3998
4042
|
redirectUri: this.redirectUri,
|
|
3999
4043
|
code: this.authorizationCode,
|
|
4000
4044
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
4001
4045
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
4002
4046
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
4003
|
-
})
|
|
4047
|
+
});
|
|
4004
4048
|
// The Client Credential flow does not return an account,
|
|
4005
4049
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
4006
4050
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
@@ -4104,7 +4148,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4104
4148
|
}
|
|
4105
4149
|
async doGetToken(scopes, options = {}) {
|
|
4106
4150
|
try {
|
|
4107
|
-
const result = await this.
|
|
4151
|
+
const result = await this.getApp("confidential", options.enableCae).acquireTokenOnBehalfOf({
|
|
4108
4152
|
scopes,
|
|
4109
4153
|
correlationId: options.correlationId,
|
|
4110
4154
|
authority: options.authority,
|