@azure/msal-common 14.3.0 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.mjs +2 -3
- package/dist/authority/Authority.mjs.map +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/cache/CacheManager.d.ts +24 -19
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +36 -23
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/AppMetadataEntity.mjs +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.mjs +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.d.ts +2 -9
- package/dist/cache/entities/ServerTelemetryEntity.d.ts.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.d.ts +6 -0
- package/dist/cache/utils/CacheHelpers.d.ts.map +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +19 -3
- package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts +2 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +3 -9
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.mjs +1 -1
- package/dist/client/RefreshTokenClient.d.ts.map +1 -1
- package/dist/client/RefreshTokenClient.mjs +2 -2
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +5 -3
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/crypto/ICrypto.d.ts +3 -3
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/ICrypto.mjs.map +1 -1
- package/dist/crypto/JoseHeader.d.ts +3 -3
- package/dist/crypto/JoseHeader.d.ts.map +1 -1
- package/dist/crypto/JoseHeader.mjs +3 -3
- package/dist/crypto/JoseHeader.mjs.map +1 -1
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +3 -3
- package/dist/crypto/PopTokenGenerator.mjs.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +4 -0
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/index.cjs +139 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/NetworkManager.mjs +1 -1
- package/dist/network/RequestThumbprint.d.ts +2 -0
- package/dist/network/RequestThumbprint.d.ts.map +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/BaseAuthRequest.d.ts +3 -0
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.mjs +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +6 -2
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.d.ts.map +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +11 -8
- package/dist/telemetry/server/ServerTelemetryManager.mjs.map +1 -1
- package/dist/url/UrlString.d.ts +2 -37
- package/dist/url/UrlString.d.ts.map +1 -1
- package/dist/url/UrlString.mjs +7 -126
- package/dist/url/UrlString.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +2 -3
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +3 -4
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/UrlUtils.d.ts +11 -0
- package/dist/utils/UrlUtils.d.ts.map +1 -0
- package/dist/utils/UrlUtils.mjs +52 -0
- package/dist/utils/UrlUtils.mjs.map +1 -0
- package/package.json +1 -1
- package/src/authority/Authority.ts +2 -3
- package/src/cache/CacheManager.ts +63 -22
- package/src/cache/entities/ServerTelemetryEntity.ts +2 -30
- package/src/cache/utils/CacheHelpers.ts +21 -0
- package/src/client/AuthorizationCodeClient.ts +3 -13
- package/src/client/RefreshTokenClient.ts +7 -1
- package/src/client/SilentFlowClient.ts +8 -4
- package/src/crypto/ICrypto.ts +7 -2
- package/src/crypto/JoseHeader.ts +4 -4
- package/src/crypto/PopTokenGenerator.ts +2 -0
- package/src/crypto/SignedHttpRequest.ts +6 -0
- package/src/index.ts +3 -1
- package/src/network/RequestThumbprint.ts +2 -0
- package/src/packageMetadata.ts +1 -1
- package/src/request/BaseAuthRequest.ts +3 -0
- package/src/telemetry/performance/PerformanceEvent.ts +12 -1
- package/src/telemetry/server/ServerTelemetryManager.ts +12 -6
- package/src/url/UrlString.ts +6 -153
- package/src/utils/Constants.ts +3 -3
- package/src/utils/UrlUtils.ts +60 -0
- package/dist/cache/entities/ServerTelemetryEntity.mjs +0 -34
- package/dist/cache/entities/ServerTelemetryEntity.mjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.
|
|
1
|
+
/*! @azure/msal-common v14.4.0 2023-11-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -53,7 +53,6 @@ const Constants = {
|
|
|
53
53
|
IMDS_TIMEOUT: 2000,
|
|
54
54
|
AZURE_REGION_AUTO_DISCOVER_FLAG: "TryAutoDetect",
|
|
55
55
|
REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX: "login.microsoft.com",
|
|
56
|
-
REGIONAL_AUTH_NON_MSI_QUERY_STRING: "allowestsrnonmsi=true",
|
|
57
56
|
KNOWN_PUBLIC_CLOUDS: [
|
|
58
57
|
"login.microsoftonline.com",
|
|
59
58
|
"login.windows.net",
|
|
@@ -372,7 +371,7 @@ const CacheOutcome = {
|
|
|
372
371
|
// When the token request goes to the identity provider because refresh_in was used and the existing token needs to be refreshed
|
|
373
372
|
PROACTIVELY_REFRESHED: "4",
|
|
374
373
|
};
|
|
375
|
-
const
|
|
374
|
+
const JsonWebTokenTypes = {
|
|
376
375
|
Jwt: "JWT",
|
|
377
376
|
Jwk: "JWK",
|
|
378
377
|
Pop: "pop",
|
|
@@ -1011,7 +1010,7 @@ class Logger {
|
|
|
1011
1010
|
|
|
1012
1011
|
/* eslint-disable header/header */
|
|
1013
1012
|
const name = "@azure/msal-common";
|
|
1014
|
-
const version = "14.
|
|
1013
|
+
const version = "14.4.0";
|
|
1015
1014
|
|
|
1016
1015
|
/*
|
|
1017
1016
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1359,6 +1358,22 @@ function generateScheme(credentialEntity) {
|
|
|
1359
1358
|
? credentialEntity.tokenType.toLowerCase()
|
|
1360
1359
|
: "";
|
|
1361
1360
|
}
|
|
1361
|
+
/**
|
|
1362
|
+
* validates if a given cache entry is "Telemetry", parses <key,value>
|
|
1363
|
+
* @param key
|
|
1364
|
+
* @param entity
|
|
1365
|
+
*/
|
|
1366
|
+
function isServerTelemetryEntity(key, entity) {
|
|
1367
|
+
const validateKey = key.indexOf(SERVER_TELEM_CONSTANTS.CACHE_KEY) === 0;
|
|
1368
|
+
let validateEntity = true;
|
|
1369
|
+
if (entity) {
|
|
1370
|
+
validateEntity =
|
|
1371
|
+
entity.hasOwnProperty("failedRequests") &&
|
|
1372
|
+
entity.hasOwnProperty("errors") &&
|
|
1373
|
+
entity.hasOwnProperty("cacheHits");
|
|
1374
|
+
}
|
|
1375
|
+
return validateKey && validateEntity;
|
|
1376
|
+
}
|
|
1362
1377
|
|
|
1363
1378
|
var CacheHelpers = /*#__PURE__*/Object.freeze({
|
|
1364
1379
|
__proto__: null,
|
|
@@ -1369,7 +1384,8 @@ var CacheHelpers = /*#__PURE__*/Object.freeze({
|
|
|
1369
1384
|
isAccessTokenEntity: isAccessTokenEntity,
|
|
1370
1385
|
isCredentialEntity: isCredentialEntity,
|
|
1371
1386
|
isIdTokenEntity: isIdTokenEntity,
|
|
1372
|
-
isRefreshTokenEntity: isRefreshTokenEntity
|
|
1387
|
+
isRefreshTokenEntity: isRefreshTokenEntity,
|
|
1388
|
+
isServerTelemetryEntity: isServerTelemetryEntity
|
|
1373
1389
|
});
|
|
1374
1390
|
|
|
1375
1391
|
/*
|
|
@@ -2138,6 +2154,57 @@ class AccountEntity {
|
|
|
2138
2154
|
}
|
|
2139
2155
|
}
|
|
2140
2156
|
|
|
2157
|
+
/*
|
|
2158
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2159
|
+
* Licensed under the MIT License.
|
|
2160
|
+
*/
|
|
2161
|
+
/**
|
|
2162
|
+
* Parses hash string from given string. Returns empty string if no hash symbol is found.
|
|
2163
|
+
* @param hashString
|
|
2164
|
+
*/
|
|
2165
|
+
function stripLeadingHashOrQuery(responseString) {
|
|
2166
|
+
if (responseString.startsWith("#/")) {
|
|
2167
|
+
return responseString.substring(2);
|
|
2168
|
+
}
|
|
2169
|
+
else if (responseString.startsWith("#") ||
|
|
2170
|
+
responseString.startsWith("?")) {
|
|
2171
|
+
return responseString.substring(1);
|
|
2172
|
+
}
|
|
2173
|
+
return responseString;
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Returns URL hash as server auth code response object.
|
|
2177
|
+
*/
|
|
2178
|
+
function getDeserializedResponse(responseString) {
|
|
2179
|
+
// Check if given hash is empty
|
|
2180
|
+
if (!responseString || responseString.indexOf("=") < 0) {
|
|
2181
|
+
return null;
|
|
2182
|
+
}
|
|
2183
|
+
try {
|
|
2184
|
+
// Strip the # or ? symbol if present
|
|
2185
|
+
const normalizedResponse = stripLeadingHashOrQuery(responseString);
|
|
2186
|
+
// If # symbol was not present, above will return empty string, so give original hash value
|
|
2187
|
+
const deserializedHash = Object.fromEntries(new URLSearchParams(normalizedResponse));
|
|
2188
|
+
// Check for known response properties
|
|
2189
|
+
if (deserializedHash.code ||
|
|
2190
|
+
deserializedHash.error ||
|
|
2191
|
+
deserializedHash.error_description ||
|
|
2192
|
+
deserializedHash.state) {
|
|
2193
|
+
return deserializedHash;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
catch (e) {
|
|
2197
|
+
throw createClientAuthError(hashNotDeserialized);
|
|
2198
|
+
}
|
|
2199
|
+
return null;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
var UrlUtils = /*#__PURE__*/Object.freeze({
|
|
2203
|
+
__proto__: null,
|
|
2204
|
+
getDeserializedResponse: getDeserializedResponse,
|
|
2205
|
+
stripLeadingHashOrQuery: stripLeadingHashOrQuery
|
|
2206
|
+
});
|
|
2207
|
+
|
|
2141
2208
|
/*
|
|
2142
2209
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2143
2210
|
* Licensed under the MIT License.
|
|
@@ -2155,7 +2222,7 @@ class UrlString {
|
|
|
2155
2222
|
// Throws error if url is empty
|
|
2156
2223
|
throw createClientConfigurationError(urlEmptyError);
|
|
2157
2224
|
}
|
|
2158
|
-
if (!
|
|
2225
|
+
if (!url.includes("#")) {
|
|
2159
2226
|
this._urlString = UrlString.canonicalizeUri(url);
|
|
2160
2227
|
}
|
|
2161
2228
|
}
|
|
@@ -2237,12 +2304,6 @@ class UrlString {
|
|
|
2237
2304
|
}
|
|
2238
2305
|
return UrlString.constructAuthorityUriFromObject(urlObject);
|
|
2239
2306
|
}
|
|
2240
|
-
/**
|
|
2241
|
-
* Returns the anchor part(#) of the URL
|
|
2242
|
-
*/
|
|
2243
|
-
getHash() {
|
|
2244
|
-
return UrlString.parseHash(this.urlString);
|
|
2245
|
-
}
|
|
2246
2307
|
/**
|
|
2247
2308
|
* Parses out the components from a url string.
|
|
2248
2309
|
* @returns An object with the various components. Please cache this value insted of calling this multiple times on the same url.
|
|
@@ -2290,60 +2351,6 @@ class UrlString {
|
|
|
2290
2351
|
}
|
|
2291
2352
|
return relativeUrl;
|
|
2292
2353
|
}
|
|
2293
|
-
/**
|
|
2294
|
-
* Parses hash string from given string. Returns empty string if no hash symbol is found.
|
|
2295
|
-
* @param hashString
|
|
2296
|
-
*/
|
|
2297
|
-
static parseHash(hashString) {
|
|
2298
|
-
const hashIndex1 = hashString.indexOf("#");
|
|
2299
|
-
const hashIndex2 = hashString.indexOf("#/");
|
|
2300
|
-
if (hashIndex2 > -1) {
|
|
2301
|
-
return hashString.substring(hashIndex2 + 2);
|
|
2302
|
-
}
|
|
2303
|
-
else if (hashIndex1 > -1) {
|
|
2304
|
-
return hashString.substring(hashIndex1 + 1);
|
|
2305
|
-
}
|
|
2306
|
-
return Constants.EMPTY_STRING;
|
|
2307
|
-
}
|
|
2308
|
-
/**
|
|
2309
|
-
* Parses query string from given string. Returns empty string if no query symbol is found.
|
|
2310
|
-
* @param queryString
|
|
2311
|
-
*/
|
|
2312
|
-
static parseQueryString(queryString) {
|
|
2313
|
-
const queryIndex1 = queryString.indexOf("?");
|
|
2314
|
-
const queryIndex2 = queryString.indexOf("/?");
|
|
2315
|
-
if (queryIndex2 > -1) {
|
|
2316
|
-
return queryString.substring(queryIndex2 + 2);
|
|
2317
|
-
}
|
|
2318
|
-
else if (queryIndex1 > -1) {
|
|
2319
|
-
return queryString.substring(queryIndex1 + 1);
|
|
2320
|
-
}
|
|
2321
|
-
return Constants.EMPTY_STRING;
|
|
2322
|
-
}
|
|
2323
|
-
/**
|
|
2324
|
-
* Parses query server response string from given string.
|
|
2325
|
-
* Extract hash between '?code=' and '#' if trailing '# is present.
|
|
2326
|
-
* Returns empty string if no query symbol is found.
|
|
2327
|
-
* @param queryString
|
|
2328
|
-
*/
|
|
2329
|
-
static parseQueryServerResponse(queryString) {
|
|
2330
|
-
const queryIndex1 = queryString.indexOf("?code");
|
|
2331
|
-
const queryIndex2 = queryString.indexOf("/?code");
|
|
2332
|
-
const hashIndex = queryString.indexOf("#");
|
|
2333
|
-
if (queryIndex2 > -1 && hashIndex > -1) {
|
|
2334
|
-
return queryString.substring(queryIndex2 + 2, hashIndex);
|
|
2335
|
-
}
|
|
2336
|
-
else if (queryIndex2 > -1) {
|
|
2337
|
-
return queryString.substring(queryIndex2 + 2);
|
|
2338
|
-
}
|
|
2339
|
-
else if (queryIndex1 > -1 && hashIndex > -1) {
|
|
2340
|
-
return queryString.substring(queryIndex1 + 1, hashIndex);
|
|
2341
|
-
}
|
|
2342
|
-
else if (queryIndex1 > -1) {
|
|
2343
|
-
return queryString.substring(queryIndex1 + 1);
|
|
2344
|
-
}
|
|
2345
|
-
return Constants.EMPTY_STRING;
|
|
2346
|
-
}
|
|
2347
2354
|
static constructAuthorityUriFromObject(urlObject) {
|
|
2348
2355
|
return new UrlString(urlObject.Protocol +
|
|
2349
2356
|
"//" +
|
|
@@ -2351,70 +2358,12 @@ class UrlString {
|
|
|
2351
2358
|
"/" +
|
|
2352
2359
|
urlObject.PathSegments.join("/"));
|
|
2353
2360
|
}
|
|
2354
|
-
/**
|
|
2355
|
-
* Returns URL hash as server auth code response object.
|
|
2356
|
-
*/
|
|
2357
|
-
static getDeserializedHash(hash) {
|
|
2358
|
-
// Check if given hash is empty
|
|
2359
|
-
if (!hash) {
|
|
2360
|
-
return {};
|
|
2361
|
-
}
|
|
2362
|
-
// Strip the # symbol if present
|
|
2363
|
-
const parsedHash = UrlString.parseHash(hash);
|
|
2364
|
-
// If # symbol was not present, above will return empty string, so give original hash value
|
|
2365
|
-
const deserializedHash = StringUtils.queryStringToObject(parsedHash || hash);
|
|
2366
|
-
// Check if deserialization didn't work
|
|
2367
|
-
if (!deserializedHash) {
|
|
2368
|
-
throw createClientAuthError(hashNotDeserialized);
|
|
2369
|
-
}
|
|
2370
|
-
return deserializedHash;
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* Returns URL query string as server auth code response object.
|
|
2374
|
-
*/
|
|
2375
|
-
static getDeserializedQueryString(query) {
|
|
2376
|
-
// Check if given query is empty
|
|
2377
|
-
if (!query) {
|
|
2378
|
-
return {};
|
|
2379
|
-
}
|
|
2380
|
-
// Strip the ? symbol if present
|
|
2381
|
-
const parsedQueryString = UrlString.parseQueryString(query);
|
|
2382
|
-
// If ? symbol was not present, above will return empty string, so give original query value
|
|
2383
|
-
const deserializedQueryString = StringUtils.queryStringToObject(parsedQueryString || query);
|
|
2384
|
-
// Check if deserialization didn't work
|
|
2385
|
-
if (!deserializedQueryString) {
|
|
2386
|
-
throw createClientAuthError(hashNotDeserialized);
|
|
2387
|
-
}
|
|
2388
|
-
return deserializedQueryString;
|
|
2389
|
-
}
|
|
2390
|
-
/**
|
|
2391
|
-
* Returns either deserialized query string or deserialized hash, depending on the serverResponseType
|
|
2392
|
-
* as a server auth code response object.
|
|
2393
|
-
*/
|
|
2394
|
-
static getDeserializedCodeResponse(serverResponseType, hashFragment) {
|
|
2395
|
-
const hashUrlString = new UrlString(hashFragment);
|
|
2396
|
-
let serverParams;
|
|
2397
|
-
if (serverResponseType === ServerResponseType.QUERY) {
|
|
2398
|
-
serverParams = UrlString.getDeserializedQueryString(hashFragment);
|
|
2399
|
-
}
|
|
2400
|
-
else {
|
|
2401
|
-
serverParams = UrlString.getDeserializedHash(hashUrlString.getHash());
|
|
2402
|
-
}
|
|
2403
|
-
return serverParams;
|
|
2404
|
-
}
|
|
2405
2361
|
/**
|
|
2406
2362
|
* Check if the hash of the URL string contains known properties
|
|
2363
|
+
* @deprecated This API will be removed in a future version
|
|
2407
2364
|
*/
|
|
2408
|
-
static hashContainsKnownProperties(
|
|
2409
|
-
|
|
2410
|
-
// Hash doesn't contain key/value pairs
|
|
2411
|
-
return false;
|
|
2412
|
-
}
|
|
2413
|
-
const parameters = UrlString.getDeserializedHash(hash);
|
|
2414
|
-
return !!(parameters.code ||
|
|
2415
|
-
parameters.error_description ||
|
|
2416
|
-
parameters.error ||
|
|
2417
|
-
parameters.state);
|
|
2365
|
+
static hashContainsKnownProperties(response) {
|
|
2366
|
+
return !!getDeserializedResponse(response);
|
|
2418
2367
|
}
|
|
2419
2368
|
}
|
|
2420
2369
|
|
|
@@ -3500,18 +3449,18 @@ class CacheManager {
|
|
|
3500
3449
|
}
|
|
3501
3450
|
/**
|
|
3502
3451
|
* Retrieve the cached credentials into a cacherecord
|
|
3503
|
-
* @param account
|
|
3504
|
-
* @param
|
|
3505
|
-
* @param
|
|
3506
|
-
* @param
|
|
3507
|
-
* @param
|
|
3452
|
+
* @param account {AccountInfo}
|
|
3453
|
+
* @param request {BaseAuthRequest}
|
|
3454
|
+
* @param environment {string}
|
|
3455
|
+
* @param performanceClient {?IPerformanceClient}
|
|
3456
|
+
* @param correlationId {?string}
|
|
3508
3457
|
*/
|
|
3509
|
-
readCacheRecord(account, request, environment) {
|
|
3458
|
+
readCacheRecord(account, request, environment, performanceClient, correlationId) {
|
|
3510
3459
|
const tokenKeys = this.getTokenKeys();
|
|
3511
3460
|
const cachedAccount = this.readAccountFromCache(account);
|
|
3512
|
-
const cachedIdToken = this.getIdToken(account, tokenKeys);
|
|
3513
|
-
const cachedAccessToken = this.getAccessToken(account, request, tokenKeys);
|
|
3514
|
-
const cachedRefreshToken = this.getRefreshToken(account, false, tokenKeys);
|
|
3461
|
+
const cachedIdToken = this.getIdToken(account, tokenKeys, performanceClient, correlationId);
|
|
3462
|
+
const cachedAccessToken = this.getAccessToken(account, request, tokenKeys, performanceClient, correlationId);
|
|
3463
|
+
const cachedRefreshToken = this.getRefreshToken(account, false, tokenKeys, performanceClient, correlationId);
|
|
3515
3464
|
const cachedAppMetadata = this.readAppMetadataFromCache(environment);
|
|
3516
3465
|
if (cachedAccount && cachedIdToken) {
|
|
3517
3466
|
cachedAccount.idTokenClaims = extractTokenClaims(cachedIdToken.secret, this.cryptoImpl.base64Decode);
|
|
@@ -3534,11 +3483,12 @@ class CacheManager {
|
|
|
3534
3483
|
}
|
|
3535
3484
|
/**
|
|
3536
3485
|
* Retrieve IdTokenEntity from cache
|
|
3537
|
-
* @param
|
|
3538
|
-
* @param
|
|
3539
|
-
* @param
|
|
3486
|
+
* @param account {AccountInfo}
|
|
3487
|
+
* @param tokenKeys {?TokenKeys}
|
|
3488
|
+
* @param performanceClient {?IPerformanceClient}
|
|
3489
|
+
* @param correlationId {?string}
|
|
3540
3490
|
*/
|
|
3541
|
-
getIdToken(account, tokenKeys) {
|
|
3491
|
+
getIdToken(account, tokenKeys, performanceClient, correlationId) {
|
|
3542
3492
|
this.commonLogger.trace("CacheManager - getIdToken called");
|
|
3543
3493
|
const idTokenFilter = {
|
|
3544
3494
|
homeAccountId: account.homeAccountId,
|
|
@@ -3558,6 +3508,9 @@ class CacheManager {
|
|
|
3558
3508
|
idTokens.forEach((idToken) => {
|
|
3559
3509
|
this.removeIdToken(generateCredentialKey(idToken));
|
|
3560
3510
|
});
|
|
3511
|
+
if (performanceClient && correlationId) {
|
|
3512
|
+
performanceClient.addFields({ multiMatchedID: idTokens.length }, correlationId);
|
|
3513
|
+
}
|
|
3561
3514
|
return null;
|
|
3562
3515
|
}
|
|
3563
3516
|
this.commonLogger.info("CacheManager:getIdToken - Returning id token");
|
|
@@ -3619,12 +3572,13 @@ class CacheManager {
|
|
|
3619
3572
|
}
|
|
3620
3573
|
/**
|
|
3621
3574
|
* Retrieve AccessTokenEntity from cache
|
|
3622
|
-
* @param
|
|
3623
|
-
* @param
|
|
3624
|
-
* @param
|
|
3625
|
-
* @param
|
|
3575
|
+
* @param account {AccountInfo}
|
|
3576
|
+
* @param request {BaseAuthRequest}
|
|
3577
|
+
* @param tokenKeys {?TokenKeys}
|
|
3578
|
+
* @param performanceClient {?IPerformanceClient}
|
|
3579
|
+
* @param correlationId {?string}
|
|
3626
3580
|
*/
|
|
3627
|
-
getAccessToken(account, request, tokenKeys) {
|
|
3581
|
+
getAccessToken(account, request, tokenKeys, performanceClient, correlationId) {
|
|
3628
3582
|
this.commonLogger.trace("CacheManager - getAccessToken called");
|
|
3629
3583
|
const scopes = ScopeSet.createSearchScopes(request.scopes);
|
|
3630
3584
|
const authScheme = request.authenticationScheme || AuthenticationScheme.BEARER;
|
|
@@ -3672,6 +3626,9 @@ class CacheManager {
|
|
|
3672
3626
|
accessTokens.forEach((accessToken) => {
|
|
3673
3627
|
void this.removeAccessToken(generateCredentialKey(accessToken));
|
|
3674
3628
|
});
|
|
3629
|
+
if (performanceClient && correlationId) {
|
|
3630
|
+
performanceClient.addFields({ multiMatchedAT: accessTokens.length }, correlationId);
|
|
3631
|
+
}
|
|
3675
3632
|
return null;
|
|
3676
3633
|
}
|
|
3677
3634
|
this.commonLogger.info("CacheManager:getAccessToken - Returning access token");
|
|
@@ -3740,11 +3697,13 @@ class CacheManager {
|
|
|
3740
3697
|
}
|
|
3741
3698
|
/**
|
|
3742
3699
|
* Helper to retrieve the appropriate refresh token from cache
|
|
3743
|
-
* @param
|
|
3744
|
-
* @param
|
|
3745
|
-
* @param
|
|
3700
|
+
* @param account {AccountInfo}
|
|
3701
|
+
* @param familyRT {boolean}
|
|
3702
|
+
* @param tokenKeys {?TokenKeys}
|
|
3703
|
+
* @param performanceClient {?IPerformanceClient}
|
|
3704
|
+
* @param correlationId {?string}
|
|
3746
3705
|
*/
|
|
3747
|
-
getRefreshToken(account, familyRT, tokenKeys) {
|
|
3706
|
+
getRefreshToken(account, familyRT, tokenKeys, performanceClient, correlationId) {
|
|
3748
3707
|
this.commonLogger.trace("CacheManager - getRefreshToken called");
|
|
3749
3708
|
const id = familyRT ? THE_FAMILY_ID : undefined;
|
|
3750
3709
|
const refreshTokenFilter = {
|
|
@@ -3774,6 +3733,9 @@ class CacheManager {
|
|
|
3774
3733
|
return null;
|
|
3775
3734
|
}
|
|
3776
3735
|
// address the else case after remove functions address environment aliases
|
|
3736
|
+
if (numRefreshTokens > 1 && performanceClient && correlationId) {
|
|
3737
|
+
performanceClient.addFields({ multiMatchedRT: numRefreshTokens }, correlationId);
|
|
3738
|
+
}
|
|
3777
3739
|
this.commonLogger.info("CacheManager:getRefreshToken - returning refresh token");
|
|
3778
3740
|
return refreshTokens[0];
|
|
3779
3741
|
}
|
|
@@ -5106,7 +5068,7 @@ const PerformanceEvents = {
|
|
|
5106
5068
|
* Functions from InteractionHandler (msal-browser)
|
|
5107
5069
|
*/
|
|
5108
5070
|
HandleCodeResponseFromServer: "handleCodeResponseFromServer",
|
|
5109
|
-
|
|
5071
|
+
HandleCodeResponse: "handleCodeResponse",
|
|
5110
5072
|
UpdateTokenEndpointAuthority: "updateTokenEndpointAuthority",
|
|
5111
5073
|
/**
|
|
5112
5074
|
* APIs in Authorization Code Client (msal-common)
|
|
@@ -5124,6 +5086,7 @@ const PerformanceEvents = {
|
|
|
5124
5086
|
* handleServerTokenResponse API in ResponseHandler (msal-common)
|
|
5125
5087
|
*/
|
|
5126
5088
|
HandleServerTokenResponse: "handleServerTokenResponse",
|
|
5089
|
+
DeserializeResponse: "deserializeResponse",
|
|
5127
5090
|
/**
|
|
5128
5091
|
* Authority functions
|
|
5129
5092
|
*/
|
|
@@ -5185,6 +5148,9 @@ const IntFields = new Set([
|
|
|
5185
5148
|
"queuedTimeMs",
|
|
5186
5149
|
"startTimeMs",
|
|
5187
5150
|
"status",
|
|
5151
|
+
"multiMatchedAT",
|
|
5152
|
+
"multiMatchedID",
|
|
5153
|
+
"multiMatchedRT",
|
|
5188
5154
|
]);
|
|
5189
5155
|
|
|
5190
5156
|
/*
|
|
@@ -6105,9 +6071,8 @@ class Authority {
|
|
|
6105
6071
|
const regionalMetadata = { ...metadata };
|
|
6106
6072
|
regionalMetadata.authorization_endpoint =
|
|
6107
6073
|
Authority.buildRegionalAuthorityString(regionalMetadata.authorization_endpoint, azureRegion);
|
|
6108
|
-
// TODO: Enquire on whether we should leave the query string or remove it before releasing the feature
|
|
6109
6074
|
regionalMetadata.token_endpoint =
|
|
6110
|
-
Authority.buildRegionalAuthorityString(regionalMetadata.token_endpoint, azureRegion
|
|
6075
|
+
Authority.buildRegionalAuthorityString(regionalMetadata.token_endpoint, azureRegion);
|
|
6111
6076
|
if (regionalMetadata.end_session_endpoint) {
|
|
6112
6077
|
regionalMetadata.end_session_endpoint =
|
|
6113
6078
|
Authority.buildRegionalAuthorityString(regionalMetadata.end_session_endpoint, azureRegion);
|
|
@@ -6563,7 +6528,7 @@ class PopTokenGenerator {
|
|
|
6563
6528
|
*/
|
|
6564
6529
|
async signPayload(payload, keyId, request, claims) {
|
|
6565
6530
|
// Deconstruct request to extract SHR parameters
|
|
6566
|
-
const { resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, } = request;
|
|
6531
|
+
const { resourceRequestMethod, resourceRequestUri, shrClaims, shrNonce, shrOptions, } = request;
|
|
6567
6532
|
const resourceUrlString = resourceRequestUri
|
|
6568
6533
|
? new UrlString(resourceRequestUri)
|
|
6569
6534
|
: undefined;
|
|
@@ -6580,7 +6545,7 @@ class PopTokenGenerator {
|
|
|
6580
6545
|
: undefined,
|
|
6581
6546
|
client_claims: shrClaims || undefined,
|
|
6582
6547
|
...claims,
|
|
6583
|
-
}, keyId, request.correlationId);
|
|
6548
|
+
}, keyId, shrOptions, request.correlationId);
|
|
6584
6549
|
}
|
|
6585
6550
|
}
|
|
6586
6551
|
|
|
@@ -7045,22 +7010,16 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7045
7010
|
* the client to exchange for a token in acquireToken.
|
|
7046
7011
|
* @param hashFragment
|
|
7047
7012
|
*/
|
|
7048
|
-
handleFragmentResponse(
|
|
7013
|
+
handleFragmentResponse(serverParams, cachedState) {
|
|
7049
7014
|
// Handle responses.
|
|
7050
7015
|
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
|
|
7051
|
-
const serverParams = UrlString.getDeserializedCodeResponse(this.config.authOptions.authority.options.OIDCOptions
|
|
7052
|
-
?.serverResponseType, hashFragment);
|
|
7053
7016
|
// Get code response
|
|
7054
7017
|
responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState);
|
|
7055
7018
|
// throw when there is no auth code in the response
|
|
7056
7019
|
if (!serverParams.code) {
|
|
7057
7020
|
throw createClientAuthError(authorizationCodeMissingFromServerResponse);
|
|
7058
7021
|
}
|
|
7059
|
-
return
|
|
7060
|
-
...serverParams,
|
|
7061
|
-
// Code param is optional in ServerAuthorizationCodeResponse but required in AuthorizationCodePaylod
|
|
7062
|
-
code: serverParams.code,
|
|
7063
|
-
};
|
|
7022
|
+
return serverParams;
|
|
7064
7023
|
}
|
|
7065
7024
|
/**
|
|
7066
7025
|
* Used to log out the current user, and redirect the user to the postLogoutRedirectUri.
|
|
@@ -7469,7 +7428,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7469
7428
|
async acquireTokenWithCachedRefreshToken(request, foci) {
|
|
7470
7429
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken, request.correlationId);
|
|
7471
7430
|
// fetches family RT or application RT based on FOCI value
|
|
7472
|
-
const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci);
|
|
7431
|
+
const refreshToken = invoke(this.cacheManager.getRefreshToken.bind(this.cacheManager), PerformanceEvents.CacheManagerGetRefreshToken, this.logger, this.performanceClient, request.correlationId)(request.account, foci, undefined, this.performanceClient, request.correlationId);
|
|
7473
7432
|
if (!refreshToken) {
|
|
7474
7433
|
throw createInteractionRequiredAuthError(noTokensFound);
|
|
7475
7434
|
}
|
|
@@ -7647,7 +7606,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
7647
7606
|
throw createClientAuthError(noAccountInSilentRequest);
|
|
7648
7607
|
}
|
|
7649
7608
|
const environment = request.authority || this.authority.getPreferredCache();
|
|
7650
|
-
const cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment);
|
|
7609
|
+
const cacheRecord = this.cacheManager.readCacheRecord(request.account, request, environment, this.performanceClient, request.correlationId);
|
|
7651
7610
|
if (!cacheRecord.accessToken) {
|
|
7652
7611
|
// must refresh due to non-existent access_token
|
|
7653
7612
|
this.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN, request.correlationId);
|
|
@@ -7679,7 +7638,9 @@ class SilentFlowClient extends BaseClient {
|
|
|
7679
7638
|
this.performanceClient?.addFields({
|
|
7680
7639
|
cacheOutcome: cacheOutcome,
|
|
7681
7640
|
}, correlationId);
|
|
7682
|
-
|
|
7641
|
+
if (cacheOutcome !== CacheOutcome.NOT_APPLICABLE) {
|
|
7642
|
+
this.logger.info(`Token refresh is required due to cache outcome: ${cacheOutcome}`);
|
|
7643
|
+
}
|
|
7683
7644
|
}
|
|
7684
7645
|
/**
|
|
7685
7646
|
* Helper function to build response object from the CacheRecord
|
|
@@ -7703,34 +7664,6 @@ class SilentFlowClient extends BaseClient {
|
|
|
7703
7664
|
}
|
|
7704
7665
|
}
|
|
7705
7666
|
|
|
7706
|
-
/*
|
|
7707
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7708
|
-
* Licensed under the MIT License.
|
|
7709
|
-
*/
|
|
7710
|
-
class ServerTelemetryEntity {
|
|
7711
|
-
constructor() {
|
|
7712
|
-
this.failedRequests = [];
|
|
7713
|
-
this.errors = [];
|
|
7714
|
-
this.cacheHits = 0;
|
|
7715
|
-
}
|
|
7716
|
-
/**
|
|
7717
|
-
* validates if a given cache entry is "Telemetry", parses <key,value>
|
|
7718
|
-
* @param key
|
|
7719
|
-
* @param entity
|
|
7720
|
-
*/
|
|
7721
|
-
static isServerTelemetryEntity(key, entity) {
|
|
7722
|
-
const validateKey = key.indexOf(SERVER_TELEM_CONSTANTS.CACHE_KEY) === 0;
|
|
7723
|
-
let validateEntity = true;
|
|
7724
|
-
if (entity) {
|
|
7725
|
-
validateEntity =
|
|
7726
|
-
entity.hasOwnProperty("failedRequests") &&
|
|
7727
|
-
entity.hasOwnProperty("errors") &&
|
|
7728
|
-
entity.hasOwnProperty("cacheHits");
|
|
7729
|
-
}
|
|
7730
|
-
return validateKey && validateEntity;
|
|
7731
|
-
}
|
|
7732
|
-
}
|
|
7733
|
-
|
|
7734
7667
|
/*
|
|
7735
7668
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7736
7669
|
* Licensed under the MIT License.
|
|
@@ -7828,7 +7761,7 @@ class JoseHeader {
|
|
|
7828
7761
|
}
|
|
7829
7762
|
const shrHeader = new JoseHeader({
|
|
7830
7763
|
// Access Token PoP headers must have type pop, but the type header can be overriden for special cases
|
|
7831
|
-
typ: shrHeaderOptions.typ ||
|
|
7764
|
+
typ: shrHeaderOptions.typ || JsonWebTokenTypes.Pop,
|
|
7832
7765
|
kid: shrHeaderOptions.kid,
|
|
7833
7766
|
alg: shrHeaderOptions.alg,
|
|
7834
7767
|
});
|
|
@@ -8002,7 +7935,11 @@ class ServerTelemetryManager {
|
|
|
8002
7935
|
* Get the server telemetry entity from cache or initialize a new one
|
|
8003
7936
|
*/
|
|
8004
7937
|
getLastRequests() {
|
|
8005
|
-
const initialValue =
|
|
7938
|
+
const initialValue = {
|
|
7939
|
+
failedRequests: [],
|
|
7940
|
+
errors: [],
|
|
7941
|
+
cacheHits: 0,
|
|
7942
|
+
};
|
|
8006
7943
|
const lastRequests = this.cacheManager.getServerTelemetry(this.telemetryCacheKey);
|
|
8007
7944
|
return lastRequests || initialValue;
|
|
8008
7945
|
}
|
|
@@ -8019,11 +7956,11 @@ class ServerTelemetryManager {
|
|
|
8019
7956
|
}
|
|
8020
7957
|
else {
|
|
8021
7958
|
// Partial data was flushed to server, construct a new telemetry cache item with errors that were not flushed
|
|
8022
|
-
const serverTelemEntity =
|
|
8023
|
-
|
|
8024
|
-
lastRequests.
|
|
8025
|
-
|
|
8026
|
-
|
|
7959
|
+
const serverTelemEntity = {
|
|
7960
|
+
failedRequests: lastRequests.failedRequests.slice(numErrorsFlushed * 2),
|
|
7961
|
+
errors: lastRequests.errors.slice(numErrorsFlushed),
|
|
7962
|
+
cacheHits: 0,
|
|
7963
|
+
};
|
|
8027
7964
|
this.cacheManager.setServerTelemetry(this.telemetryCacheKey, serverTelemEntity);
|
|
8028
7965
|
}
|
|
8029
7966
|
}
|
|
@@ -8623,6 +8560,7 @@ exports.InteractionRequiredAuthError = InteractionRequiredAuthError;
|
|
|
8623
8560
|
exports.InteractionRequiredAuthErrorCodes = InteractionRequiredAuthErrorCodes;
|
|
8624
8561
|
exports.InteractionRequiredAuthErrorMessage = InteractionRequiredAuthErrorMessage;
|
|
8625
8562
|
exports.JoseHeader = JoseHeader;
|
|
8563
|
+
exports.JsonWebTokenTypes = JsonWebTokenTypes;
|
|
8626
8564
|
exports.Logger = Logger;
|
|
8627
8565
|
exports.NetworkManager = NetworkManager;
|
|
8628
8566
|
exports.OIDC_DEFAULT_SCOPES = OIDC_DEFAULT_SCOPES;
|
|
@@ -8644,7 +8582,6 @@ exports.SSOTypes = SSOTypes;
|
|
|
8644
8582
|
exports.ScopeSet = ScopeSet;
|
|
8645
8583
|
exports.ServerError = ServerError;
|
|
8646
8584
|
exports.ServerResponseType = ServerResponseType;
|
|
8647
|
-
exports.ServerTelemetryEntity = ServerTelemetryEntity;
|
|
8648
8585
|
exports.ServerTelemetryManager = ServerTelemetryManager;
|
|
8649
8586
|
exports.SilentFlowClient = SilentFlowClient;
|
|
8650
8587
|
exports.StringUtils = StringUtils;
|
|
@@ -8657,6 +8594,7 @@ exports.ThrottlingUtils = ThrottlingUtils;
|
|
|
8657
8594
|
exports.TimeUtils = TimeUtils;
|
|
8658
8595
|
exports.TokenCacheContext = TokenCacheContext;
|
|
8659
8596
|
exports.UrlString = UrlString;
|
|
8597
|
+
exports.UrlUtils = UrlUtils;
|
|
8660
8598
|
exports.buildClientInfo = buildClientInfo;
|
|
8661
8599
|
exports.buildClientInfoFromHomeAccountId = buildClientInfoFromHomeAccountId;
|
|
8662
8600
|
exports.buildStaticAuthorityOptions = buildStaticAuthorityOptions;
|