@azure/msal-common 7.4.1 → 7.6.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.
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.d.ts +4 -0
- package/dist/account/AuthToken.d.ts.map +1 -1
- package/dist/account/AuthToken.js +15 -1
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/TokenClaims.d.ts +1 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts +5 -3
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +19 -9
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityMetadata.js +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityType.d.ts +2 -1
- package/dist/authority/AuthorityType.d.ts.map +1 -1
- package/dist/authority/AuthorityType.js +2 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +7 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +10 -6
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CredentialEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +10 -8
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.js +1 -1
- package/dist/client/DeviceCodeClient.js +1 -1
- package/dist/client/OnBehalfOfClient.js +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.js +39 -10
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.js +10 -2
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.js +1 -1
- package/dist/config/ClientConfiguration.js +1 -1
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/JoseHeader.js +1 -1
- package/dist/crypto/PopTokenGenerator.js +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/ClientAuthError.d.ts +17 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +24 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.js +2 -2
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.d.ts.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/JoseHeaderError.js +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +167 -46
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.js +2 -2
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/ThrottlingUtils.js +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/BaseAuthRequest.d.ts +1 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/response/AuthenticationResult.d.ts +2 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ExternalTokenResponse.d.ts +2 -1
- package/dist/response/ExternalTokenResponse.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts +2 -2
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +15 -6
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +4 -1
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +33 -7
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +14 -7
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/utils/Constants.d.ts +6 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +9 -4
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v7.
|
|
1
|
+
/*! @azure/msal-common v7.6.0 2022-10-10 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -105,6 +105,7 @@ var Constants = {
|
|
|
105
105
|
DEFAULT_COMMON_TENANT: "common",
|
|
106
106
|
// ADFS String
|
|
107
107
|
ADFS: "adfs",
|
|
108
|
+
DSTS: "dstsv2",
|
|
108
109
|
// Default AAD Instance Discovery Endpoint
|
|
109
110
|
AAD_INSTANCE_DISCOVERY_ENDPT: "https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=",
|
|
110
111
|
// Resource delimiter - used for certain cache entries
|
|
@@ -136,6 +137,7 @@ var Constants = {
|
|
|
136
137
|
IMDS_TIMEOUT: 2000,
|
|
137
138
|
AZURE_REGION_AUTO_DISCOVER_FLAG: "TryAutoDetect",
|
|
138
139
|
REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
|
|
140
|
+
REGIONAL_AUTH_NON_MSI_QUERY_STRING: "allowestsrnonmsi=true",
|
|
139
141
|
KNOWN_PUBLIC_CLOUDS: ["login.microsoftonline.com", "login.windows.net", "login.microsoft.com", "sts.windows.net"],
|
|
140
142
|
TOKEN_RESPONSE_TYPE: "token",
|
|
141
143
|
ID_TOKEN_RESPONSE_TYPE: "id_token",
|
|
@@ -159,6 +161,7 @@ exports.HeaderNames = void 0;
|
|
|
159
161
|
HeaderNames["CCS_HEADER"] = "X-AnchorMailbox";
|
|
160
162
|
HeaderNames["WWWAuthenticate"] = "WWW-Authenticate";
|
|
161
163
|
HeaderNames["AuthenticationInfo"] = "Authentication-Info";
|
|
164
|
+
HeaderNames["X_MS_REQUEST_ID"] = "x-ms-request-id";
|
|
162
165
|
})(exports.HeaderNames || (exports.HeaderNames = {}));
|
|
163
166
|
/**
|
|
164
167
|
* Persistent cache keys MSAL which stay while user is logged in.
|
|
@@ -254,7 +257,8 @@ var PromptValue = {
|
|
|
254
257
|
SELECT_ACCOUNT: "select_account",
|
|
255
258
|
CONSENT: "consent",
|
|
256
259
|
NONE: "none",
|
|
257
|
-
CREATE: "create"
|
|
260
|
+
CREATE: "create",
|
|
261
|
+
NO_SESSION: "no_session"
|
|
258
262
|
};
|
|
259
263
|
/**
|
|
260
264
|
* SSO Types - generated to populate hints
|
|
@@ -479,7 +483,8 @@ var JsonTypes;
|
|
|
479
483
|
(function (JsonTypes) {
|
|
480
484
|
JsonTypes["Jwt"] = "JWT";
|
|
481
485
|
JsonTypes["Jwk"] = "JWK";
|
|
482
|
-
})(JsonTypes || (JsonTypes = {}));
|
|
486
|
+
})(JsonTypes || (JsonTypes = {}));
|
|
487
|
+
var ONE_DAY_IN_MS = 86400000;
|
|
483
488
|
|
|
484
489
|
/*
|
|
485
490
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -672,6 +677,16 @@ var ClientAuthErrorMessage = {
|
|
|
672
677
|
code: "nonce_not_found",
|
|
673
678
|
desc: "nonce not found"
|
|
674
679
|
},
|
|
680
|
+
authTimeNotFoundError: {
|
|
681
|
+
code: "auth_time_not_found",
|
|
682
|
+
desc: "Max Age was requested and the ID token is missing the auth_time variable." +
|
|
683
|
+
" auth_time is an optional claim and is not enabled by default - it must be enabled." +
|
|
684
|
+
" See https://aka.ms/msaljs/optional-claims for more information."
|
|
685
|
+
},
|
|
686
|
+
maxAgeTranspiredError: {
|
|
687
|
+
code: "max_age_transpired",
|
|
688
|
+
desc: "Max Age is set to 0, or too much time has elapsed since the last end-user authentication."
|
|
689
|
+
},
|
|
675
690
|
noTokensFoundError: {
|
|
676
691
|
code: "no_tokens_found",
|
|
677
692
|
desc: "No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken()."
|
|
@@ -892,6 +907,19 @@ var ClientAuthError = /** @class */ (function (_super) {
|
|
|
892
907
|
ClientAuthError.createNonceMismatchError = function () {
|
|
893
908
|
return new ClientAuthError(ClientAuthErrorMessage.nonceMismatchError.code, ClientAuthErrorMessage.nonceMismatchError.desc);
|
|
894
909
|
};
|
|
910
|
+
/**
|
|
911
|
+
* Creates an error thrown when max_age was provided in the request, but auth_time is not in the token claims
|
|
912
|
+
* @param missingNonce
|
|
913
|
+
*/
|
|
914
|
+
ClientAuthError.createAuthTimeNotFoundError = function () {
|
|
915
|
+
return new ClientAuthError(ClientAuthErrorMessage.authTimeNotFoundError.code, ClientAuthErrorMessage.authTimeNotFoundError.desc);
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* Creates an error thrown when too much time has elapsed since the last end-user authentication
|
|
919
|
+
*/
|
|
920
|
+
ClientAuthError.createMaxAgeTranspiredError = function () {
|
|
921
|
+
return new ClientAuthError(ClientAuthErrorMessage.maxAgeTranspiredError.code, ClientAuthErrorMessage.maxAgeTranspiredError.desc);
|
|
922
|
+
};
|
|
895
923
|
/**
|
|
896
924
|
* Creates an error thrown when the mnonce is not present
|
|
897
925
|
* @param missingNonce
|
|
@@ -1381,7 +1409,7 @@ var Logger = /** @class */ (function () {
|
|
|
1381
1409
|
|
|
1382
1410
|
/* eslint-disable header/header */
|
|
1383
1411
|
var name = "@azure/msal-common";
|
|
1384
|
-
var version = "7.
|
|
1412
|
+
var version = "7.6.0";
|
|
1385
1413
|
|
|
1386
1414
|
/*
|
|
1387
1415
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1606,7 +1634,7 @@ var ClientConfigurationErrorMessage = {
|
|
|
1606
1634
|
},
|
|
1607
1635
|
invalidPrompt: {
|
|
1608
1636
|
code: "invalid_prompt_value",
|
|
1609
|
-
desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create' and '
|
|
1637
|
+
desc: "Supported prompt values are 'login', 'select_account', 'consent', 'create', 'none' and 'no_session'. Please see here for valid configuration options: https://azuread.github.io/microsoft-authentication-library-for-js/ref/modules/_azure_msal_common.html#commonauthorizationurlrequest",
|
|
1610
1638
|
},
|
|
1611
1639
|
invalidClaimsRequest: {
|
|
1612
1640
|
code: "invalid_claims",
|
|
@@ -2042,6 +2070,7 @@ exports.AuthorityType = void 0;
|
|
|
2042
2070
|
(function (AuthorityType) {
|
|
2043
2071
|
AuthorityType[AuthorityType["Default"] = 0] = "Default";
|
|
2044
2072
|
AuthorityType[AuthorityType["Adfs"] = 1] = "Adfs";
|
|
2073
|
+
AuthorityType[AuthorityType["Dsts"] = 2] = "Dsts";
|
|
2045
2074
|
})(exports.AuthorityType || (exports.AuthorityType = {}));
|
|
2046
2075
|
|
|
2047
2076
|
/*
|
|
@@ -2164,10 +2193,13 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2164
2193
|
// How do you account for MSA CID here?
|
|
2165
2194
|
account.localAccountId = ((_b = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _b === void 0 ? void 0 : _b.oid) || ((_c = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _c === void 0 ? void 0 : _c.sub) || Constants.EMPTY_STRING;
|
|
2166
2195
|
/*
|
|
2167
|
-
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
2168
|
-
* This field should not be relied upon if a custom
|
|
2196
|
+
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
2197
|
+
* In most cases it will contain a single email. This field should not be relied upon if a custom
|
|
2198
|
+
* policy is configured to return more than 1 email.
|
|
2169
2199
|
*/
|
|
2170
|
-
|
|
2200
|
+
var preferredUsername = (_d = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _d === void 0 ? void 0 : _d.preferred_username;
|
|
2201
|
+
var email = ((_e = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _e === void 0 ? void 0 : _e.emails) ? idToken.claims.emails[0] : null;
|
|
2202
|
+
account.username = preferredUsername || email || Constants.EMPTY_STRING;
|
|
2171
2203
|
account.name = (_f = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _f === void 0 ? void 0 : _f.name;
|
|
2172
2204
|
}
|
|
2173
2205
|
account.cloudGraphHostName = cloudGraphHostName;
|
|
@@ -2182,7 +2214,8 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2182
2214
|
AccountEntity.createGenericAccount = function (homeAccountId, idToken, authority, cloudGraphHostName, msGraphHost, environment) {
|
|
2183
2215
|
var _a, _b, _c, _d;
|
|
2184
2216
|
var account = new AccountEntity();
|
|
2185
|
-
account.authorityType = (authority &&
|
|
2217
|
+
account.authorityType = (authority &&
|
|
2218
|
+
authority.authorityType === exports.AuthorityType.Adfs) ? exports.CacheAccountType.ADFS_ACCOUNT_TYPE : exports.CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
2186
2219
|
account.homeAccountId = homeAccountId;
|
|
2187
2220
|
// non AAD scenarios can have empty realm
|
|
2188
2221
|
account.realm = Constants.EMPTY_STRING;
|
|
@@ -2216,7 +2249,7 @@ var AccountEntity = /** @class */ (function () {
|
|
|
2216
2249
|
var _a;
|
|
2217
2250
|
var accountId = ((_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) === null || _a === void 0 ? void 0 : _a.sub) ? idToken.claims.sub : Constants.EMPTY_STRING;
|
|
2218
2251
|
// since ADFS does not have tid and does not set client_info
|
|
2219
|
-
if (authType === exports.AuthorityType.Adfs) {
|
|
2252
|
+
if (authType === exports.AuthorityType.Adfs || authType === exports.AuthorityType.Dsts) {
|
|
2220
2253
|
return accountId;
|
|
2221
2254
|
}
|
|
2222
2255
|
// for cases where there is clientInfo
|
|
@@ -2310,6 +2343,20 @@ var AuthToken = /** @class */ (function () {
|
|
|
2310
2343
|
throw ClientAuthError.createTokenParsingError(err);
|
|
2311
2344
|
}
|
|
2312
2345
|
};
|
|
2346
|
+
/**
|
|
2347
|
+
* Determine if the token's max_age has transpired
|
|
2348
|
+
*/
|
|
2349
|
+
AuthToken.checkMaxAge = function (authTime, maxAge) {
|
|
2350
|
+
/*
|
|
2351
|
+
* per https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
|
|
2352
|
+
* To force an immediate re-authentication: If an app requires that a user re-authenticate prior to access,
|
|
2353
|
+
* provide a value of 0 for the max_age parameter and the AS will force a fresh login.
|
|
2354
|
+
*/
|
|
2355
|
+
var fiveMinuteSkew = 300000; // five minutes in milliseconds
|
|
2356
|
+
if ((maxAge === 0) || ((Date.now() - fiveMinuteSkew) > (authTime + maxAge))) {
|
|
2357
|
+
throw ClientAuthError.createMaxAgeTranspiredError();
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2313
2360
|
return AuthToken;
|
|
2314
2361
|
}());
|
|
2315
2362
|
|
|
@@ -2513,7 +2560,11 @@ var CacheManager = /** @class */ (function () {
|
|
|
2513
2560
|
if (!!userAssertionHash && !_this.matchUserAssertionHash(entity, userAssertionHash)) {
|
|
2514
2561
|
return;
|
|
2515
2562
|
}
|
|
2516
|
-
|
|
2563
|
+
/*
|
|
2564
|
+
* homeAccountId can undefined, and we want to filter out cached items that have a homeAccountId of ""
|
|
2565
|
+
* because we don't want a client_credential request to return a cached token that has a homeAccountId
|
|
2566
|
+
*/
|
|
2567
|
+
if ((typeof homeAccountId === "string") && !_this.matchHomeAccountId(entity, homeAccountId)) {
|
|
2517
2568
|
return;
|
|
2518
2569
|
}
|
|
2519
2570
|
if (!!environment && !_this.matchEnvironment(entity, environment)) {
|
|
@@ -2932,7 +2983,7 @@ var CacheManager = /** @class */ (function () {
|
|
|
2932
2983
|
* @param homeAccountId
|
|
2933
2984
|
*/
|
|
2934
2985
|
CacheManager.prototype.matchHomeAccountId = function (entity, homeAccountId) {
|
|
2935
|
-
return !!(entity.homeAccountId && homeAccountId === entity.homeAccountId);
|
|
2986
|
+
return !!((typeof entity.homeAccountId === "string") && (homeAccountId === entity.homeAccountId));
|
|
2936
2987
|
};
|
|
2937
2988
|
/**
|
|
2938
2989
|
* helper to match assertion
|
|
@@ -4934,9 +4985,9 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4934
4985
|
* @param serverTokenResponse
|
|
4935
4986
|
* @param authority
|
|
4936
4987
|
*/
|
|
4937
|
-
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
|
|
4988
|
+
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
4938
4989
|
return __awaiter(this, void 0, void 0, function () {
|
|
4939
|
-
var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
4990
|
+
var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
4940
4991
|
return __generator(this, function (_a) {
|
|
4941
4992
|
switch (_a.label) {
|
|
4942
4993
|
case 0:
|
|
@@ -4948,6 +4999,14 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4948
4999
|
throw ClientAuthError.createNonceMismatchError();
|
|
4949
5000
|
}
|
|
4950
5001
|
}
|
|
5002
|
+
// token max_age check
|
|
5003
|
+
if (request.maxAge || (request.maxAge === 0)) {
|
|
5004
|
+
authTime = idTokenObj.claims.auth_time;
|
|
5005
|
+
if (!authTime) {
|
|
5006
|
+
throw ClientAuthError.createAuthTimeNotFoundError();
|
|
5007
|
+
}
|
|
5008
|
+
AuthToken.checkMaxAge(authTime, request.maxAge);
|
|
5009
|
+
}
|
|
4951
5010
|
}
|
|
4952
5011
|
// generate homeAccountId
|
|
4953
5012
|
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
@@ -4979,7 +5038,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4979
5038
|
account = this.cacheStorage.getAccount(key);
|
|
4980
5039
|
if (!account) {
|
|
4981
5040
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
4982
|
-
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined)];
|
|
5041
|
+
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId)];
|
|
4983
5042
|
}
|
|
4984
5043
|
}
|
|
4985
5044
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
@@ -4994,7 +5053,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4994
5053
|
_a.sent();
|
|
4995
5054
|
_a.label = 7;
|
|
4996
5055
|
case 7: return [7 /*endfinally*/];
|
|
4997
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
|
|
5056
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
|
|
4998
5057
|
}
|
|
4999
5058
|
});
|
|
5000
5059
|
});
|
|
@@ -5080,7 +5139,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5080
5139
|
* @param fromTokenCache
|
|
5081
5140
|
* @param stateString
|
|
5082
5141
|
*/
|
|
5083
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
|
|
5142
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
|
|
5084
5143
|
var _a, _b, _c;
|
|
5085
5144
|
return __awaiter(this, void 0, void 0, function () {
|
|
5086
5145
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5128,6 +5187,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5128
5187
|
fromCache: fromTokenCache,
|
|
5129
5188
|
expiresOn: expiresOn,
|
|
5130
5189
|
correlationId: request.correlationId,
|
|
5190
|
+
requestId: requestId || Constants.EMPTY_STRING,
|
|
5131
5191
|
extExpiresOn: extExpiresOn,
|
|
5132
5192
|
familyId: familyId,
|
|
5133
5193
|
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
@@ -5188,10 +5248,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5188
5248
|
* @param request
|
|
5189
5249
|
*/
|
|
5190
5250
|
AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
|
|
5251
|
+
var _a;
|
|
5191
5252
|
return __awaiter(this, void 0, void 0, function () {
|
|
5192
|
-
var reqTimestamp, response, responseHandler;
|
|
5193
|
-
return __generator(this, function (
|
|
5194
|
-
switch (
|
|
5253
|
+
var reqTimestamp, response, requestId, responseHandler;
|
|
5254
|
+
return __generator(this, function (_b) {
|
|
5255
|
+
switch (_b.label) {
|
|
5195
5256
|
case 0:
|
|
5196
5257
|
this.logger.info("in acquireToken call");
|
|
5197
5258
|
if (!request || StringUtils.isEmpty(request.code)) {
|
|
@@ -5200,12 +5261,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5200
5261
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5201
5262
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
5202
5263
|
case 1:
|
|
5203
|
-
response =
|
|
5264
|
+
response = _b.sent();
|
|
5265
|
+
requestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
5204
5266
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5205
5267
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5206
5268
|
responseHandler.validateTokenResponse(response.body);
|
|
5207
|
-
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload)];
|
|
5208
|
-
case 2: return [2 /*return*/,
|
|
5269
|
+
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)];
|
|
5270
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
5209
5271
|
}
|
|
5210
5272
|
});
|
|
5211
5273
|
});
|
|
@@ -5893,10 +5955,6 @@ exports.PerformanceEvents = void 0;
|
|
|
5893
5955
|
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5894
5956
|
*/
|
|
5895
5957
|
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5896
|
-
/**
|
|
5897
|
-
* Time spent on the network for refresh token acquisition
|
|
5898
|
-
*/
|
|
5899
|
-
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5900
5958
|
/**
|
|
5901
5959
|
* Time spent creating default headers for requests to token endpoint
|
|
5902
5960
|
*/
|
|
@@ -5910,10 +5968,21 @@ exports.PerformanceEvents = void 0;
|
|
|
5910
5968
|
*/
|
|
5911
5969
|
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
5912
5970
|
/**
|
|
5913
|
-
*
|
|
5914
|
-
* Used to acquire a token on behalf of the embedded application (PW-Broker).
|
|
5971
|
+
* Time taken for token acquisition by broker
|
|
5915
5972
|
*/
|
|
5916
5973
|
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
5974
|
+
/**
|
|
5975
|
+
* Time spent on the network for refresh token acquisition
|
|
5976
|
+
*/
|
|
5977
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5978
|
+
/**
|
|
5979
|
+
* Time taken for acquiring refresh token , records RT size
|
|
5980
|
+
*/
|
|
5981
|
+
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
5982
|
+
/**
|
|
5983
|
+
* Time taken for acquiring cached refresh token
|
|
5984
|
+
*/
|
|
5985
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
5917
5986
|
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5918
5987
|
/**
|
|
5919
5988
|
* State of the performance event.
|
|
@@ -5941,18 +6010,40 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5941
6010
|
return _super.call(this, configuration, performanceClient) || this;
|
|
5942
6011
|
}
|
|
5943
6012
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
6013
|
+
var _a, _b;
|
|
5944
6014
|
return __awaiter(this, void 0, void 0, function () {
|
|
5945
|
-
var reqTimestamp, response, responseHandler;
|
|
5946
|
-
|
|
5947
|
-
|
|
6015
|
+
var atsMeasurement, reqTimestamp, response, requestId, responseHandler;
|
|
6016
|
+
var _this = this;
|
|
6017
|
+
return __generator(this, function (_c) {
|
|
6018
|
+
switch (_c.label) {
|
|
5948
6019
|
case 0:
|
|
6020
|
+
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6021
|
+
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
5949
6022
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5950
6023
|
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
5951
6024
|
case 1:
|
|
5952
|
-
response =
|
|
6025
|
+
response = _c.sent();
|
|
6026
|
+
requestId = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
5953
6027
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5954
6028
|
responseHandler.validateTokenResponse(response.body);
|
|
5955
|
-
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)
|
|
6029
|
+
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
|
|
6030
|
+
var _a;
|
|
6031
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6032
|
+
success: true,
|
|
6033
|
+
refreshTokenSize: ((_a = response.body.refresh_token) === null || _a === void 0 ? void 0 : _a.length) || 0
|
|
6034
|
+
});
|
|
6035
|
+
return result;
|
|
6036
|
+
})
|
|
6037
|
+
.catch(function (error) {
|
|
6038
|
+
_this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
6039
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6040
|
+
errorCode: error.errorCode,
|
|
6041
|
+
subErrorCode: error.subError,
|
|
6042
|
+
success: false,
|
|
6043
|
+
refreshTokenSize: undefined
|
|
6044
|
+
});
|
|
6045
|
+
throw error;
|
|
6046
|
+
})];
|
|
5956
6047
|
}
|
|
5957
6048
|
});
|
|
5958
6049
|
});
|
|
@@ -6002,14 +6093,21 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6002
6093
|
* @param request
|
|
6003
6094
|
*/
|
|
6004
6095
|
RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
|
|
6096
|
+
var _a;
|
|
6005
6097
|
return __awaiter(this, void 0, void 0, function () {
|
|
6006
|
-
var refreshToken, refreshTokenRequest;
|
|
6007
|
-
return __generator(this, function (
|
|
6098
|
+
var atsMeasurement, refreshToken, refreshTokenRequest;
|
|
6099
|
+
return __generator(this, function (_b) {
|
|
6100
|
+
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6101
|
+
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6008
6102
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
6009
|
-
// no refresh Token
|
|
6010
6103
|
if (!refreshToken) {
|
|
6104
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
|
|
6011
6105
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
6012
6106
|
}
|
|
6107
|
+
// attach cached RT size to the current measurement
|
|
6108
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6109
|
+
success: true
|
|
6110
|
+
});
|
|
6013
6111
|
refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
|
|
6014
6112
|
credential: request.account.homeAccountId,
|
|
6015
6113
|
type: exports.CcsCredentialType.HOME_ACCOUNT_ID
|
|
@@ -6678,13 +6776,21 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6678
6776
|
*/
|
|
6679
6777
|
SilentFlowClient.prototype.generateResultFromCacheRecord = function (cacheRecord, request) {
|
|
6680
6778
|
return __awaiter(this, void 0, void 0, function () {
|
|
6681
|
-
var idTokenObj;
|
|
6779
|
+
var idTokenObj, authTime;
|
|
6682
6780
|
return __generator(this, function (_a) {
|
|
6683
6781
|
switch (_a.label) {
|
|
6684
6782
|
case 0:
|
|
6685
6783
|
if (cacheRecord.idToken) {
|
|
6686
6784
|
idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);
|
|
6687
6785
|
}
|
|
6786
|
+
// token max_age check
|
|
6787
|
+
if (request.maxAge || (request.maxAge === 0)) {
|
|
6788
|
+
authTime = idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.auth_time;
|
|
6789
|
+
if (!authTime) {
|
|
6790
|
+
throw ClientAuthError.createAuthTimeNotFoundError();
|
|
6791
|
+
}
|
|
6792
|
+
AuthToken.checkMaxAge(authTime, request.maxAge);
|
|
6793
|
+
}
|
|
6688
6794
|
return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, cacheRecord, true, request, idTokenObj)];
|
|
6689
6795
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6690
6796
|
}
|
|
@@ -7060,8 +7166,13 @@ var Authority = /** @class */ (function () {
|
|
|
7060
7166
|
// See above for AuthorityType
|
|
7061
7167
|
get: function () {
|
|
7062
7168
|
var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7063
|
-
if (pathSegments.length
|
|
7064
|
-
|
|
7169
|
+
if (pathSegments.length) {
|
|
7170
|
+
switch (pathSegments[0].toLowerCase()) {
|
|
7171
|
+
case Constants.ADFS:
|
|
7172
|
+
return exports.AuthorityType.Adfs;
|
|
7173
|
+
case Constants.DSTS:
|
|
7174
|
+
return exports.AuthorityType.Dsts;
|
|
7175
|
+
}
|
|
7065
7176
|
}
|
|
7066
7177
|
return exports.AuthorityType.Default;
|
|
7067
7178
|
},
|
|
@@ -7265,7 +7376,9 @@ var Authority = /** @class */ (function () {
|
|
|
7265
7376
|
* The default open id configuration endpoint for any canonical authority.
|
|
7266
7377
|
*/
|
|
7267
7378
|
get: function () {
|
|
7268
|
-
if (this.authorityType === exports.AuthorityType.Adfs ||
|
|
7379
|
+
if (this.authorityType === exports.AuthorityType.Adfs ||
|
|
7380
|
+
this.authorityType === exports.AuthorityType.Dsts ||
|
|
7381
|
+
this.protocolMode === exports.ProtocolMode.OIDC) {
|
|
7269
7382
|
return this.canonicalAuthority + ".well-known/openid-configuration";
|
|
7270
7383
|
}
|
|
7271
7384
|
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
|
|
@@ -7363,8 +7476,9 @@ var Authority = /** @class */ (function () {
|
|
|
7363
7476
|
});
|
|
7364
7477
|
};
|
|
7365
7478
|
/**
|
|
7366
|
-
* Compares the number of url components after the domain to determine if the cached
|
|
7367
|
-
*
|
|
7479
|
+
* Compares the number of url components after the domain to determine if the cached
|
|
7480
|
+
* authority metadata can be used for the requested authority. Protects against same domain different
|
|
7481
|
+
* authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
|
|
7368
7482
|
* @param metadataEntity
|
|
7369
7483
|
*/
|
|
7370
7484
|
Authority.prototype.isAuthoritySameType = function (metadataEntity) {
|
|
@@ -7404,7 +7518,8 @@ var Authority = /** @class */ (function () {
|
|
|
7404
7518
|
_a.label = 1;
|
|
7405
7519
|
case 1:
|
|
7406
7520
|
_a.trys.push([1, 3, , 4]);
|
|
7407
|
-
return [4 /*yield*/, this.networkInterface.
|
|
7521
|
+
return [4 /*yield*/, this.networkInterface.
|
|
7522
|
+
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
7408
7523
|
case 2:
|
|
7409
7524
|
response = _a.sent();
|
|
7410
7525
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
@@ -7465,7 +7580,8 @@ var Authority = /** @class */ (function () {
|
|
|
7465
7580
|
});
|
|
7466
7581
|
};
|
|
7467
7582
|
/**
|
|
7468
|
-
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
7583
|
+
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
7584
|
+
* and returns where the information was retrieved from
|
|
7469
7585
|
* @param cachedMetadata
|
|
7470
7586
|
* @param newMetadata
|
|
7471
7587
|
*/
|
|
@@ -7688,7 +7804,7 @@ var Authority = /** @class */ (function () {
|
|
|
7688
7804
|
Authority.replaceWithRegionalInformation = function (metadata, azureRegion) {
|
|
7689
7805
|
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
7690
7806
|
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
7691
|
-
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion,
|
|
7807
|
+
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
7692
7808
|
if (metadata.end_session_endpoint) {
|
|
7693
7809
|
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
7694
7810
|
}
|
|
@@ -8331,6 +8447,9 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8331
8447
|
if (current.idTokenSize) {
|
|
8332
8448
|
previous.idTokenSize = current.idTokenSize;
|
|
8333
8449
|
}
|
|
8450
|
+
if (current.refreshTokenSize) {
|
|
8451
|
+
previous.refreshTokenSize = current.refreshTokenSize;
|
|
8452
|
+
}
|
|
8334
8453
|
}
|
|
8335
8454
|
return previous;
|
|
8336
8455
|
}, topLevelEvent);
|
|
@@ -8440,6 +8559,7 @@ exports.AuthorityFactory = AuthorityFactory;
|
|
|
8440
8559
|
exports.AuthorityMetadataEntity = AuthorityMetadataEntity;
|
|
8441
8560
|
exports.AuthorizationCodeClient = AuthorizationCodeClient;
|
|
8442
8561
|
exports.CacheManager = CacheManager;
|
|
8562
|
+
exports.CacheRecord = CacheRecord;
|
|
8443
8563
|
exports.ClientAuthError = ClientAuthError;
|
|
8444
8564
|
exports.ClientAuthErrorMessage = ClientAuthErrorMessage;
|
|
8445
8565
|
exports.ClientConfigurationError = ClientConfigurationError;
|
|
@@ -8461,6 +8581,7 @@ exports.JoseHeader = JoseHeader;
|
|
|
8461
8581
|
exports.Logger = Logger;
|
|
8462
8582
|
exports.NetworkManager = NetworkManager;
|
|
8463
8583
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
8584
|
+
exports.ONE_DAY_IN_MS = ONE_DAY_IN_MS;
|
|
8464
8585
|
exports.OnBehalfOfClient = OnBehalfOfClient;
|
|
8465
8586
|
exports.PerformanceClient = PerformanceClient;
|
|
8466
8587
|
exports.PopTokenGenerator = PopTokenGenerator;
|