@azure/msal-common 14.6.1 → 14.6.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AccountInfo.mjs +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.mjs +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.mjs +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +5 -5
- package/dist/cache/utils/CacheHelpers.mjs.map +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +3 -3
- package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
- package/dist/client/BaseClient.mjs +1 -1
- package/dist/client/RefreshTokenClient.mjs +4 -4
- package/dist/client/RefreshTokenClient.mjs.map +1 -1
- package/dist/client/SilentFlowClient.mjs +5 -5
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/constants/AADServerParamKeys.mjs +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +3 -3
- package/dist/crypto/PopTokenGenerator.mjs.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 +67 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +3 -2
- 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/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +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 +2 -2
- package/dist/response/ResponseHandler.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/FunctionWrappers.d.ts.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +11 -1
- package/dist/utils/FunctionWrappers.mjs.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.d.ts +23 -25
- package/dist/utils/TimeUtils.d.ts.map +1 -1
- package/dist/utils/TimeUtils.mjs +38 -40
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/package.json +3 -3
- package/src/cache/utils/CacheHelpers.ts +1 -1
- package/src/client/AuthorizationCodeClient.ts +1 -1
- package/src/client/RefreshTokenClient.ts +1 -1
- package/src/client/SilentFlowClient.ts +1 -1
- package/src/crypto/PopTokenGenerator.ts +1 -1
- package/src/index.ts +1 -1
- package/src/packageMetadata.ts +1 -1
- package/src/response/ResponseHandler.ts +1 -1
- package/src/utils/FunctionWrappers.ts +16 -0
- package/src/utils/TimeUtils.ts +37 -38
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common v14.6.1 2024-01-
|
|
1
|
+
/*! @azure/msal-common v14.6.2-alpha.1 2024-01-30 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -943,7 +943,7 @@ class Logger {
|
|
|
943
943
|
|
|
944
944
|
/* eslint-disable header/header */
|
|
945
945
|
const name = "@azure/msal-common";
|
|
946
|
-
const version = "14.6.1";
|
|
946
|
+
const version = "14.6.2-alpha.1";
|
|
947
947
|
|
|
948
948
|
/*
|
|
949
949
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1035,47 +1035,53 @@ var AuthToken = /*#__PURE__*/Object.freeze({
|
|
|
1035
1035
|
* Licensed under the MIT License.
|
|
1036
1036
|
*/
|
|
1037
1037
|
/**
|
|
1038
|
-
* Utility
|
|
1038
|
+
* Utility functions for managing date and time operations.
|
|
1039
1039
|
*/
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
return new Promise((resolve) => setTimeout(() => resolve(value), t));
|
|
1076
|
-
}
|
|
1040
|
+
/**
|
|
1041
|
+
* return the current time in Unix time (seconds).
|
|
1042
|
+
*/
|
|
1043
|
+
function nowSeconds() {
|
|
1044
|
+
// Date.getTime() returns in milliseconds.
|
|
1045
|
+
return Math.round(new Date().getTime() / 1000.0);
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* check if a token is expired based on given UTC time in seconds.
|
|
1049
|
+
* @param expiresOn
|
|
1050
|
+
*/
|
|
1051
|
+
function isTokenExpired(expiresOn, offset) {
|
|
1052
|
+
// check for access token expiry
|
|
1053
|
+
const expirationSec = Number(expiresOn) || 0;
|
|
1054
|
+
const offsetCurrentTimeSec = nowSeconds() + offset;
|
|
1055
|
+
// If current time + offset is greater than token expiration time, then token is expired.
|
|
1056
|
+
return offsetCurrentTimeSec > expirationSec;
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* If the current time is earlier than the time that a token was cached at, we must discard the token
|
|
1060
|
+
* i.e. The system clock was turned back after acquiring the cached token
|
|
1061
|
+
* @param cachedAt
|
|
1062
|
+
* @param offset
|
|
1063
|
+
*/
|
|
1064
|
+
function wasClockTurnedBack(cachedAt) {
|
|
1065
|
+
const cachedAtSec = Number(cachedAt);
|
|
1066
|
+
return cachedAtSec > nowSeconds();
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Waits for t number of milliseconds
|
|
1070
|
+
* @param t number
|
|
1071
|
+
* @param value T
|
|
1072
|
+
*/
|
|
1073
|
+
function delay(t, value) {
|
|
1074
|
+
return new Promise((resolve) => setTimeout(() => resolve(value), t));
|
|
1077
1075
|
}
|
|
1078
1076
|
|
|
1077
|
+
var TimeUtils = /*#__PURE__*/Object.freeze({
|
|
1078
|
+
__proto__: null,
|
|
1079
|
+
delay: delay,
|
|
1080
|
+
isTokenExpired: isTokenExpired,
|
|
1081
|
+
nowSeconds: nowSeconds,
|
|
1082
|
+
wasClockTurnedBack: wasClockTurnedBack
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1079
1085
|
/*
|
|
1080
1086
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1081
1087
|
* Licensed under the MIT License.
|
|
@@ -1132,7 +1138,7 @@ function createAccessTokenEntity(homeAccountId, environment, accessToken, client
|
|
|
1132
1138
|
homeAccountId: homeAccountId,
|
|
1133
1139
|
credentialType: CredentialType.ACCESS_TOKEN,
|
|
1134
1140
|
secret: accessToken,
|
|
1135
|
-
cachedAt:
|
|
1141
|
+
cachedAt: nowSeconds().toString(),
|
|
1136
1142
|
expiresOn: expiresOn.toString(),
|
|
1137
1143
|
extendedExpiresOn: extExpiresOn.toString(),
|
|
1138
1144
|
environment: environment,
|
|
@@ -1376,7 +1382,7 @@ function isAuthorityMetadataEntity(key, entity) {
|
|
|
1376
1382
|
* Reset the exiresAt value
|
|
1377
1383
|
*/
|
|
1378
1384
|
function generateAuthorityMetadataExpiresAt() {
|
|
1379
|
-
return (
|
|
1385
|
+
return (nowSeconds() +
|
|
1380
1386
|
AUTHORITY_METADATA_CONSTANTS.REFRESH_TIME_SECONDS);
|
|
1381
1387
|
}
|
|
1382
1388
|
function updateAuthorityEndpointMetadata(authorityMetadata, updatedValues, fromNetwork) {
|
|
@@ -1398,7 +1404,7 @@ function updateCloudDiscoveryMetadata(authorityMetadata, updatedValues, fromNetw
|
|
|
1398
1404
|
* Returns whether or not the data needs to be refreshed
|
|
1399
1405
|
*/
|
|
1400
1406
|
function isAuthorityMetadataExpired(metadata) {
|
|
1401
|
-
return metadata.expiresAt <=
|
|
1407
|
+
return metadata.expiresAt <= nowSeconds();
|
|
1402
1408
|
}
|
|
1403
1409
|
|
|
1404
1410
|
var CacheHelpers = /*#__PURE__*/Object.freeze({
|
|
@@ -5017,6 +5023,11 @@ const invoke = (callback, eventName, logger, telemetryClient, correlationId) =>
|
|
|
5017
5023
|
return (...args) => {
|
|
5018
5024
|
logger.trace(`Executing function ${eventName}`);
|
|
5019
5025
|
const inProgressEvent = telemetryClient?.startMeasurement(eventName, correlationId);
|
|
5026
|
+
if (correlationId) {
|
|
5027
|
+
// Track number of times this API is called in a single request
|
|
5028
|
+
const eventCount = eventName + "CallCount";
|
|
5029
|
+
telemetryClient?.incrementFields({ [eventCount]: 1 }, correlationId);
|
|
5030
|
+
}
|
|
5020
5031
|
try {
|
|
5021
5032
|
const result = callback(...args);
|
|
5022
5033
|
inProgressEvent?.end({
|
|
@@ -5057,6 +5068,11 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
5057
5068
|
return (...args) => {
|
|
5058
5069
|
logger.trace(`Executing function ${eventName}`);
|
|
5059
5070
|
const inProgressEvent = telemetryClient?.startMeasurement(eventName, correlationId);
|
|
5071
|
+
if (correlationId) {
|
|
5072
|
+
// Track number of times this API is called in a single request
|
|
5073
|
+
const eventCount = eventName + "CallCount";
|
|
5074
|
+
telemetryClient?.incrementFields({ [eventCount]: 1 }, correlationId);
|
|
5075
|
+
}
|
|
5060
5076
|
telemetryClient?.setPreQueueTime(eventName, correlationId);
|
|
5061
5077
|
return callback(...args)
|
|
5062
5078
|
.then((response) => {
|
|
@@ -6419,7 +6435,7 @@ class PopTokenGenerator {
|
|
|
6419
6435
|
const resourceUrlComponents = resourceUrlString?.getUrlComponents();
|
|
6420
6436
|
return this.cryptoUtils.signJwt({
|
|
6421
6437
|
at: payload,
|
|
6422
|
-
ts:
|
|
6438
|
+
ts: nowSeconds(),
|
|
6423
6439
|
m: resourceRequestMethod?.toUpperCase(),
|
|
6424
6440
|
u: resourceUrlComponents?.HostNameAndPort,
|
|
6425
6441
|
nonce: shrNonce || this.cryptoUtils.createNewGuid(),
|
|
@@ -6670,7 +6686,7 @@ class ResponseHandler {
|
|
|
6670
6686
|
? reqTimestamp + refreshIn
|
|
6671
6687
|
: undefined;
|
|
6672
6688
|
// non AAD scenarios can have empty realm
|
|
6673
|
-
cachedAccessToken = createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token, this.clientId, claimsTenantId || authority.tenant, responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj.base64Decode, refreshOnSeconds, serverTokenResponse.token_type, userAssertionHash, serverTokenResponse.key_id, request.claims, request.requestedClaimsHash);
|
|
6689
|
+
cachedAccessToken = createAccessTokenEntity(this.homeAccountIdentifier, env, serverTokenResponse.access_token, this.clientId, claimsTenantId || authority.tenant || "", responseScopes.printScopes(), tokenExpirationSeconds, extendedTokenExpirationSeconds, this.cryptoObj.base64Decode, refreshOnSeconds, serverTokenResponse.token_type, userAssertionHash, serverTokenResponse.key_id, request.claims, request.requestedClaimsHash);
|
|
6674
6690
|
}
|
|
6675
6691
|
// refreshToken
|
|
6676
6692
|
let cachedRefreshToken = null;
|
|
@@ -6851,7 +6867,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
6851
6867
|
if (!request.code) {
|
|
6852
6868
|
throw createClientAuthError(requestCannotBeMade);
|
|
6853
6869
|
}
|
|
6854
|
-
const reqTimestamp =
|
|
6870
|
+
const reqTimestamp = nowSeconds();
|
|
6855
6871
|
const response = await invokeAsync(this.executeTokenRequest.bind(this), PerformanceEvents.AuthClientExecuteTokenRequest, this.logger, this.performanceClient, request.correlationId)(this.authority, request);
|
|
6856
6872
|
// Retrieve requestId from response headers
|
|
6857
6873
|
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
@@ -7228,7 +7244,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7228
7244
|
}
|
|
7229
7245
|
async acquireToken(request) {
|
|
7230
7246
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientAcquireToken, request.correlationId);
|
|
7231
|
-
const reqTimestamp =
|
|
7247
|
+
const reqTimestamp = nowSeconds();
|
|
7232
7248
|
const response = await invokeAsync(this.executeTokenRequest.bind(this), PerformanceEvents.RefreshTokenClientExecuteTokenRequest, this.logger, this.performanceClient, request.correlationId)(request, this.authority);
|
|
7233
7249
|
// Retrieve requestId from response headers
|
|
7234
7250
|
const requestId = response.headers?.[HeaderNames.X_MS_REQUEST_ID];
|
|
@@ -7289,7 +7305,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7289
7305
|
throw createInteractionRequiredAuthError(noTokensFound);
|
|
7290
7306
|
}
|
|
7291
7307
|
if (refreshToken.expiresOn &&
|
|
7292
|
-
|
|
7308
|
+
isTokenExpired(refreshToken.expiresOn, request.refreshTokenExpirationOffsetSeconds ||
|
|
7293
7309
|
DEFAULT_REFRESH_TOKEN_EXPIRATION_OFFSET_SECONDS)) {
|
|
7294
7310
|
throw createInteractionRequiredAuthError(refreshTokenExpired);
|
|
7295
7311
|
}
|
|
@@ -7487,14 +7503,14 @@ class SilentFlowClient extends BaseClient {
|
|
|
7487
7503
|
this.setCacheOutcome(CacheOutcome.NO_CACHED_ACCESS_TOKEN, request.correlationId);
|
|
7488
7504
|
throw createClientAuthError(tokenRefreshRequired);
|
|
7489
7505
|
}
|
|
7490
|
-
else if (
|
|
7491
|
-
|
|
7506
|
+
else if (wasClockTurnedBack(cachedAccessToken.cachedAt) ||
|
|
7507
|
+
isTokenExpired(cachedAccessToken.expiresOn, this.config.systemOptions.tokenRenewalOffsetSeconds)) {
|
|
7492
7508
|
// must refresh due to the expires_in value
|
|
7493
7509
|
this.setCacheOutcome(CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED, request.correlationId);
|
|
7494
7510
|
throw createClientAuthError(tokenRefreshRequired);
|
|
7495
7511
|
}
|
|
7496
7512
|
else if (cachedAccessToken.refreshOn &&
|
|
7497
|
-
|
|
7513
|
+
isTokenExpired(cachedAccessToken.refreshOn, 0)) {
|
|
7498
7514
|
// must refresh (in the background) due to the refresh_in value
|
|
7499
7515
|
lastCacheOutcome = CacheOutcome.PROACTIVELY_REFRESHED;
|
|
7500
7516
|
// don't throw ClientAuthError.createRefreshRequiredError(), return cached token instead
|