@azure/msal-common 7.4.1 → 7.5.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.js +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 +160 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- 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/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.5.0 2022-10-03 */
|
|
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.5.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
|
|
|
@@ -4934,9 +4981,9 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4934
4981
|
* @param serverTokenResponse
|
|
4935
4982
|
* @param authority
|
|
4936
4983
|
*/
|
|
4937
|
-
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse) {
|
|
4984
|
+
ResponseHandler.prototype.handleServerTokenResponse = function (serverTokenResponse, authority, reqTimestamp, request, authCodePayload, userAssertionHash, handlingRefreshTokenResponse, forceCacheRefreshTokenResponse, serverRequestId) {
|
|
4938
4985
|
return __awaiter(this, void 0, void 0, function () {
|
|
4939
|
-
var idTokenObj, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
4986
|
+
var idTokenObj, authTime, requestStateObj, cacheRecord, cacheContext, key, account;
|
|
4940
4987
|
return __generator(this, function (_a) {
|
|
4941
4988
|
switch (_a.label) {
|
|
4942
4989
|
case 0:
|
|
@@ -4948,6 +4995,14 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4948
4995
|
throw ClientAuthError.createNonceMismatchError();
|
|
4949
4996
|
}
|
|
4950
4997
|
}
|
|
4998
|
+
// token max_age check
|
|
4999
|
+
if (request.maxAge || (request.maxAge === 0)) {
|
|
5000
|
+
authTime = idTokenObj.claims.auth_time;
|
|
5001
|
+
if (!authTime) {
|
|
5002
|
+
throw ClientAuthError.createAuthTimeNotFoundError();
|
|
5003
|
+
}
|
|
5004
|
+
AuthToken.checkMaxAge(authTime, request.maxAge);
|
|
5005
|
+
}
|
|
4951
5006
|
}
|
|
4952
5007
|
// generate homeAccountId
|
|
4953
5008
|
this.homeAccountIdentifier = AccountEntity.generateHomeAccountId(serverTokenResponse.client_info || Constants.EMPTY_STRING, authority.authorityType, this.logger, this.cryptoObj, idTokenObj);
|
|
@@ -4979,7 +5034,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4979
5034
|
account = this.cacheStorage.getAccount(key);
|
|
4980
5035
|
if (!account) {
|
|
4981
5036
|
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)];
|
|
5037
|
+
return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, undefined, serverRequestId)];
|
|
4983
5038
|
}
|
|
4984
5039
|
}
|
|
4985
5040
|
return [4 /*yield*/, this.cacheStorage.saveCacheRecord(cacheRecord)];
|
|
@@ -4994,7 +5049,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
4994
5049
|
_a.sent();
|
|
4995
5050
|
_a.label = 7;
|
|
4996
5051
|
case 7: return [7 /*endfinally*/];
|
|
4997
|
-
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code)];
|
|
5052
|
+
case 8: return [2 /*return*/, ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenObj, requestStateObj, serverTokenResponse.spa_code, serverRequestId)];
|
|
4998
5053
|
}
|
|
4999
5054
|
});
|
|
5000
5055
|
});
|
|
@@ -5080,7 +5135,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5080
5135
|
* @param fromTokenCache
|
|
5081
5136
|
* @param stateString
|
|
5082
5137
|
*/
|
|
5083
|
-
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code) {
|
|
5138
|
+
ResponseHandler.generateAuthenticationResult = function (cryptoObj, authority, cacheRecord, fromTokenCache, request, idTokenObj, requestState, code, requestId) {
|
|
5084
5139
|
var _a, _b, _c;
|
|
5085
5140
|
return __awaiter(this, void 0, void 0, function () {
|
|
5086
5141
|
var accessToken, responseScopes, expiresOn, extExpiresOn, familyId, popTokenGenerator, _d, secret, keyId, uid, tid;
|
|
@@ -5128,6 +5183,7 @@ var ResponseHandler = /** @class */ (function () {
|
|
|
5128
5183
|
fromCache: fromTokenCache,
|
|
5129
5184
|
expiresOn: expiresOn,
|
|
5130
5185
|
correlationId: request.correlationId,
|
|
5186
|
+
requestId: requestId || Constants.EMPTY_STRING,
|
|
5131
5187
|
extExpiresOn: extExpiresOn,
|
|
5132
5188
|
familyId: familyId,
|
|
5133
5189
|
tokenType: ((_a = cacheRecord.accessToken) === null || _a === void 0 ? void 0 : _a.tokenType) || Constants.EMPTY_STRING,
|
|
@@ -5188,10 +5244,11 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5188
5244
|
* @param request
|
|
5189
5245
|
*/
|
|
5190
5246
|
AuthorizationCodeClient.prototype.acquireToken = function (request, authCodePayload) {
|
|
5247
|
+
var _a;
|
|
5191
5248
|
return __awaiter(this, void 0, void 0, function () {
|
|
5192
|
-
var reqTimestamp, response, responseHandler;
|
|
5193
|
-
return __generator(this, function (
|
|
5194
|
-
switch (
|
|
5249
|
+
var reqTimestamp, response, requestId, responseHandler;
|
|
5250
|
+
return __generator(this, function (_b) {
|
|
5251
|
+
switch (_b.label) {
|
|
5195
5252
|
case 0:
|
|
5196
5253
|
this.logger.info("in acquireToken call");
|
|
5197
5254
|
if (!request || StringUtils.isEmpty(request.code)) {
|
|
@@ -5200,12 +5257,13 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
|
|
|
5200
5257
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5201
5258
|
return [4 /*yield*/, this.executeTokenRequest(this.authority, request)];
|
|
5202
5259
|
case 1:
|
|
5203
|
-
response =
|
|
5260
|
+
response = _b.sent();
|
|
5261
|
+
requestId = (_a = response.headers) === null || _a === void 0 ? void 0 : _a[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
5204
5262
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5205
5263
|
// Validate response. This function throws a server error if an error is returned by the server.
|
|
5206
5264
|
responseHandler.validateTokenResponse(response.body);
|
|
5207
|
-
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload)];
|
|
5208
|
-
case 2: return [2 /*return*/,
|
|
5265
|
+
return [4 /*yield*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId)];
|
|
5266
|
+
case 2: return [2 /*return*/, _b.sent()];
|
|
5209
5267
|
}
|
|
5210
5268
|
});
|
|
5211
5269
|
});
|
|
@@ -5893,10 +5951,6 @@ exports.PerformanceEvents = void 0;
|
|
|
5893
5951
|
* Used to acquire a token from Native component when native brokering is enabled.
|
|
5894
5952
|
*/
|
|
5895
5953
|
PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
|
|
5896
|
-
/**
|
|
5897
|
-
* Time spent on the network for refresh token acquisition
|
|
5898
|
-
*/
|
|
5899
|
-
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5900
5954
|
/**
|
|
5901
5955
|
* Time spent creating default headers for requests to token endpoint
|
|
5902
5956
|
*/
|
|
@@ -5910,10 +5964,21 @@ exports.PerformanceEvents = void 0;
|
|
|
5910
5964
|
*/
|
|
5911
5965
|
PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
|
|
5912
5966
|
/**
|
|
5913
|
-
*
|
|
5914
|
-
* Used to acquire a token on behalf of the embedded application (PW-Broker).
|
|
5967
|
+
* Time taken for token acquisition by broker
|
|
5915
5968
|
*/
|
|
5916
5969
|
PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
|
|
5970
|
+
/**
|
|
5971
|
+
* Time spent on the network for refresh token acquisition
|
|
5972
|
+
*/
|
|
5973
|
+
PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
|
|
5974
|
+
/**
|
|
5975
|
+
* Time taken for acquiring refresh token , records RT size
|
|
5976
|
+
*/
|
|
5977
|
+
PerformanceEvents["RefreshTokenClientAcquireToken"] = "refreshTokenClientAcquireToken";
|
|
5978
|
+
/**
|
|
5979
|
+
* Time taken for acquiring cached refresh token
|
|
5980
|
+
*/
|
|
5981
|
+
PerformanceEvents["RefreshTokenClientAcquireTokenWithCachedRefreshToken"] = "refreshTokenClientAcquireTokenWithCachedRefreshToken";
|
|
5917
5982
|
})(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
|
|
5918
5983
|
/**
|
|
5919
5984
|
* State of the performance event.
|
|
@@ -5941,18 +6006,40 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
5941
6006
|
return _super.call(this, configuration, performanceClient) || this;
|
|
5942
6007
|
}
|
|
5943
6008
|
RefreshTokenClient.prototype.acquireToken = function (request) {
|
|
6009
|
+
var _a, _b;
|
|
5944
6010
|
return __awaiter(this, void 0, void 0, function () {
|
|
5945
|
-
var reqTimestamp, response, responseHandler;
|
|
5946
|
-
|
|
5947
|
-
|
|
6011
|
+
var atsMeasurement, reqTimestamp, response, requestId, responseHandler;
|
|
6012
|
+
var _this = this;
|
|
6013
|
+
return __generator(this, function (_c) {
|
|
6014
|
+
switch (_c.label) {
|
|
5948
6015
|
case 0:
|
|
6016
|
+
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
6017
|
+
this.logger.verbose("RefreshTokenClientAcquireToken called", request.correlationId);
|
|
5949
6018
|
reqTimestamp = TimeUtils.nowSeconds();
|
|
5950
6019
|
return [4 /*yield*/, this.executeTokenRequest(request, this.authority)];
|
|
5951
6020
|
case 1:
|
|
5952
|
-
response =
|
|
6021
|
+
response = _c.sent();
|
|
6022
|
+
requestId = (_b = response.headers) === null || _b === void 0 ? void 0 : _b[exports.HeaderNames.X_MS_REQUEST_ID];
|
|
5953
6023
|
responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, this.config.serializableCache, this.config.persistencePlugin);
|
|
5954
6024
|
responseHandler.validateTokenResponse(response.body);
|
|
5955
|
-
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache)
|
|
6025
|
+
return [2 /*return*/, responseHandler.handleServerTokenResponse(response.body, this.authority, reqTimestamp, request, undefined, undefined, true, request.forceCache, requestId).then(function (result) {
|
|
6026
|
+
var _a;
|
|
6027
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6028
|
+
success: true,
|
|
6029
|
+
refreshTokenSize: ((_a = response.body.refresh_token) === null || _a === void 0 ? void 0 : _a.length) || 0
|
|
6030
|
+
});
|
|
6031
|
+
return result;
|
|
6032
|
+
})
|
|
6033
|
+
.catch(function (error) {
|
|
6034
|
+
_this.logger.verbose("Error in fetching refresh token", request.correlationId);
|
|
6035
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6036
|
+
errorCode: error.errorCode,
|
|
6037
|
+
subErrorCode: error.subError,
|
|
6038
|
+
success: false,
|
|
6039
|
+
refreshTokenSize: undefined
|
|
6040
|
+
});
|
|
6041
|
+
throw error;
|
|
6042
|
+
})];
|
|
5956
6043
|
}
|
|
5957
6044
|
});
|
|
5958
6045
|
});
|
|
@@ -6002,14 +6089,21 @@ var RefreshTokenClient = /** @class */ (function (_super) {
|
|
|
6002
6089
|
* @param request
|
|
6003
6090
|
*/
|
|
6004
6091
|
RefreshTokenClient.prototype.acquireTokenWithCachedRefreshToken = function (request, foci) {
|
|
6092
|
+
var _a;
|
|
6005
6093
|
return __awaiter(this, void 0, void 0, function () {
|
|
6006
|
-
var refreshToken, refreshTokenRequest;
|
|
6007
|
-
return __generator(this, function (
|
|
6094
|
+
var atsMeasurement, refreshToken, refreshTokenRequest;
|
|
6095
|
+
return __generator(this, function (_b) {
|
|
6096
|
+
atsMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
6097
|
+
this.logger.verbose("RefreshTokenClientAcquireTokenWithCachedRefreshToken called", request.correlationId);
|
|
6008
6098
|
refreshToken = this.cacheManager.readRefreshTokenFromCache(this.config.authOptions.clientId, request.account, foci);
|
|
6009
|
-
// no refresh Token
|
|
6010
6099
|
if (!refreshToken) {
|
|
6100
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.discardMeasurement();
|
|
6011
6101
|
throw InteractionRequiredAuthError.createNoTokensFoundError();
|
|
6012
6102
|
}
|
|
6103
|
+
// attach cached RT size to the current measurement
|
|
6104
|
+
atsMeasurement === null || atsMeasurement === void 0 ? void 0 : atsMeasurement.endMeasurement({
|
|
6105
|
+
success: true
|
|
6106
|
+
});
|
|
6013
6107
|
refreshTokenRequest = __assign(__assign({}, request), { refreshToken: refreshToken.secret, authenticationScheme: request.authenticationScheme || exports.AuthenticationScheme.BEARER, ccsCredential: {
|
|
6014
6108
|
credential: request.account.homeAccountId,
|
|
6015
6109
|
type: exports.CcsCredentialType.HOME_ACCOUNT_ID
|
|
@@ -6678,13 +6772,21 @@ var SilentFlowClient = /** @class */ (function (_super) {
|
|
|
6678
6772
|
*/
|
|
6679
6773
|
SilentFlowClient.prototype.generateResultFromCacheRecord = function (cacheRecord, request) {
|
|
6680
6774
|
return __awaiter(this, void 0, void 0, function () {
|
|
6681
|
-
var idTokenObj;
|
|
6775
|
+
var idTokenObj, authTime;
|
|
6682
6776
|
return __generator(this, function (_a) {
|
|
6683
6777
|
switch (_a.label) {
|
|
6684
6778
|
case 0:
|
|
6685
6779
|
if (cacheRecord.idToken) {
|
|
6686
6780
|
idTokenObj = new AuthToken(cacheRecord.idToken.secret, this.config.cryptoInterface);
|
|
6687
6781
|
}
|
|
6782
|
+
// token max_age check
|
|
6783
|
+
if (request.maxAge || (request.maxAge === 0)) {
|
|
6784
|
+
authTime = idTokenObj === null || idTokenObj === void 0 ? void 0 : idTokenObj.claims.auth_time;
|
|
6785
|
+
if (!authTime) {
|
|
6786
|
+
throw ClientAuthError.createAuthTimeNotFoundError();
|
|
6787
|
+
}
|
|
6788
|
+
AuthToken.checkMaxAge(authTime, request.maxAge);
|
|
6789
|
+
}
|
|
6688
6790
|
return [4 /*yield*/, ResponseHandler.generateAuthenticationResult(this.cryptoUtils, this.authority, cacheRecord, true, request, idTokenObj)];
|
|
6689
6791
|
case 1: return [2 /*return*/, _a.sent()];
|
|
6690
6792
|
}
|
|
@@ -7060,8 +7162,13 @@ var Authority = /** @class */ (function () {
|
|
|
7060
7162
|
// See above for AuthorityType
|
|
7061
7163
|
get: function () {
|
|
7062
7164
|
var pathSegments = this.canonicalAuthorityUrlComponents.PathSegments;
|
|
7063
|
-
if (pathSegments.length
|
|
7064
|
-
|
|
7165
|
+
if (pathSegments.length) {
|
|
7166
|
+
switch (pathSegments[0].toLowerCase()) {
|
|
7167
|
+
case Constants.ADFS:
|
|
7168
|
+
return exports.AuthorityType.Adfs;
|
|
7169
|
+
case Constants.DSTS:
|
|
7170
|
+
return exports.AuthorityType.Dsts;
|
|
7171
|
+
}
|
|
7065
7172
|
}
|
|
7066
7173
|
return exports.AuthorityType.Default;
|
|
7067
7174
|
},
|
|
@@ -7265,7 +7372,9 @@ var Authority = /** @class */ (function () {
|
|
|
7265
7372
|
* The default open id configuration endpoint for any canonical authority.
|
|
7266
7373
|
*/
|
|
7267
7374
|
get: function () {
|
|
7268
|
-
if (this.authorityType === exports.AuthorityType.Adfs ||
|
|
7375
|
+
if (this.authorityType === exports.AuthorityType.Adfs ||
|
|
7376
|
+
this.authorityType === exports.AuthorityType.Dsts ||
|
|
7377
|
+
this.protocolMode === exports.ProtocolMode.OIDC) {
|
|
7269
7378
|
return this.canonicalAuthority + ".well-known/openid-configuration";
|
|
7270
7379
|
}
|
|
7271
7380
|
return this.canonicalAuthority + "v2.0/.well-known/openid-configuration";
|
|
@@ -7363,8 +7472,9 @@ var Authority = /** @class */ (function () {
|
|
|
7363
7472
|
});
|
|
7364
7473
|
};
|
|
7365
7474
|
/**
|
|
7366
|
-
* Compares the number of url components after the domain to determine if the cached
|
|
7367
|
-
*
|
|
7475
|
+
* Compares the number of url components after the domain to determine if the cached
|
|
7476
|
+
* authority metadata can be used for the requested authority. Protects against same domain different
|
|
7477
|
+
* authority such as login.microsoftonline.com/tenant and login.microsoftonline.com/tfp/tenant/policy
|
|
7368
7478
|
* @param metadataEntity
|
|
7369
7479
|
*/
|
|
7370
7480
|
Authority.prototype.isAuthoritySameType = function (metadataEntity) {
|
|
@@ -7404,7 +7514,8 @@ var Authority = /** @class */ (function () {
|
|
|
7404
7514
|
_a.label = 1;
|
|
7405
7515
|
case 1:
|
|
7406
7516
|
_a.trys.push([1, 3, , 4]);
|
|
7407
|
-
return [4 /*yield*/, this.networkInterface.
|
|
7517
|
+
return [4 /*yield*/, this.networkInterface.
|
|
7518
|
+
sendGetRequestAsync(this.defaultOpenIdConfigurationEndpoint, options)];
|
|
7408
7519
|
case 2:
|
|
7409
7520
|
response = _a.sent();
|
|
7410
7521
|
return [2 /*return*/, isOpenIdConfigResponse(response.body) ? response.body : null];
|
|
@@ -7465,7 +7576,8 @@ var Authority = /** @class */ (function () {
|
|
|
7465
7576
|
});
|
|
7466
7577
|
};
|
|
7467
7578
|
/**
|
|
7468
|
-
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
7579
|
+
* Updates the AuthorityMetadataEntity with new aliases, preferred_network and preferred_cache
|
|
7580
|
+
* and returns where the information was retrieved from
|
|
7469
7581
|
* @param cachedMetadata
|
|
7470
7582
|
* @param newMetadata
|
|
7471
7583
|
*/
|
|
@@ -7688,7 +7800,7 @@ var Authority = /** @class */ (function () {
|
|
|
7688
7800
|
Authority.replaceWithRegionalInformation = function (metadata, azureRegion) {
|
|
7689
7801
|
metadata.authorization_endpoint = Authority.buildRegionalAuthorityString(metadata.authorization_endpoint, azureRegion);
|
|
7690
7802
|
// 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,
|
|
7803
|
+
metadata.token_endpoint = Authority.buildRegionalAuthorityString(metadata.token_endpoint, azureRegion, Constants.REGIONAL_AUTH_NON_MSI_QUERY_STRING);
|
|
7692
7804
|
if (metadata.end_session_endpoint) {
|
|
7693
7805
|
metadata.end_session_endpoint = Authority.buildRegionalAuthorityString(metadata.end_session_endpoint, azureRegion);
|
|
7694
7806
|
}
|
|
@@ -8331,6 +8443,9 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
8331
8443
|
if (current.idTokenSize) {
|
|
8332
8444
|
previous.idTokenSize = current.idTokenSize;
|
|
8333
8445
|
}
|
|
8446
|
+
if (current.refreshTokenSize) {
|
|
8447
|
+
previous.refreshTokenSize = current.refreshTokenSize;
|
|
8448
|
+
}
|
|
8334
8449
|
}
|
|
8335
8450
|
return previous;
|
|
8336
8451
|
}, topLevelEvent);
|
|
@@ -8461,6 +8576,7 @@ exports.JoseHeader = JoseHeader;
|
|
|
8461
8576
|
exports.Logger = Logger;
|
|
8462
8577
|
exports.NetworkManager = NetworkManager;
|
|
8463
8578
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
8579
|
+
exports.ONE_DAY_IN_MS = ONE_DAY_IN_MS;
|
|
8464
8580
|
exports.OnBehalfOfClient = OnBehalfOfClient;
|
|
8465
8581
|
exports.PerformanceClient = PerformanceClient;
|
|
8466
8582
|
exports.PopTokenGenerator = PopTokenGenerator;
|