@azure/msal-common 14.6.1 → 14.6.2-alpha.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/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
|
@@ -31,6 +31,14 @@ export const invoke = <T extends Array<any>, U>(
|
|
|
31
31
|
eventName,
|
|
32
32
|
correlationId
|
|
33
33
|
);
|
|
34
|
+
if (correlationId) {
|
|
35
|
+
// Track number of times this API is called in a single request
|
|
36
|
+
const eventCount = eventName + "CallCount";
|
|
37
|
+
telemetryClient?.incrementFields(
|
|
38
|
+
{ [eventCount]: 1 },
|
|
39
|
+
correlationId
|
|
40
|
+
);
|
|
41
|
+
}
|
|
34
42
|
try {
|
|
35
43
|
const result = callback(...args);
|
|
36
44
|
inProgressEvent?.end({
|
|
@@ -79,6 +87,14 @@ export const invokeAsync = <T extends Array<any>, U>(
|
|
|
79
87
|
eventName,
|
|
80
88
|
correlationId
|
|
81
89
|
);
|
|
90
|
+
if (correlationId) {
|
|
91
|
+
// Track number of times this API is called in a single request
|
|
92
|
+
const eventCount = eventName + "CallCount";
|
|
93
|
+
telemetryClient?.incrementFields(
|
|
94
|
+
{ [eventCount]: 1 },
|
|
95
|
+
correlationId
|
|
96
|
+
);
|
|
97
|
+
}
|
|
82
98
|
telemetryClient?.setPreQueueTime(eventName, correlationId);
|
|
83
99
|
return callback(...args)
|
|
84
100
|
.then((response) => {
|
package/src/utils/TimeUtils.ts
CHANGED
|
@@ -4,48 +4,47 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Utility
|
|
7
|
+
* Utility functions for managing date and time operations.
|
|
8
8
|
*/
|
|
9
|
-
export class TimeUtils {
|
|
10
|
-
/**
|
|
11
|
-
* return the current time in Unix time (seconds).
|
|
12
|
-
*/
|
|
13
|
-
static nowSeconds(): number {
|
|
14
|
-
// Date.getTime() returns in milliseconds.
|
|
15
|
-
return Math.round(new Date().getTime() / 1000.0);
|
|
16
|
-
}
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
/**
|
|
11
|
+
* return the current time in Unix time (seconds).
|
|
12
|
+
*/
|
|
13
|
+
export function nowSeconds(): number {
|
|
14
|
+
// Date.getTime() returns in milliseconds.
|
|
15
|
+
return Math.round(new Date().getTime() / 1000.0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* check if a token is expired based on given UTC time in seconds.
|
|
20
|
+
* @param expiresOn
|
|
21
|
+
*/
|
|
22
|
+
export function isTokenExpired(expiresOn: string, offset: number): boolean {
|
|
23
|
+
// check for access token expiry
|
|
24
|
+
const expirationSec = Number(expiresOn) || 0;
|
|
25
|
+
const offsetCurrentTimeSec = nowSeconds() + offset;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
// If current time + offset is greater than token expiration time, then token is expired.
|
|
28
|
+
return offsetCurrentTimeSec > expirationSec;
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
/**
|
|
32
|
+
* If the current time is earlier than the time that a token was cached at, we must discard the token
|
|
33
|
+
* i.e. The system clock was turned back after acquiring the cached token
|
|
34
|
+
* @param cachedAt
|
|
35
|
+
* @param offset
|
|
36
|
+
*/
|
|
37
|
+
export function wasClockTurnedBack(cachedAt: string): boolean {
|
|
38
|
+
const cachedAtSec = Number(cachedAt);
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
return cachedAtSec > nowSeconds();
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
43
|
+
/**
|
|
44
|
+
* Waits for t number of milliseconds
|
|
45
|
+
* @param t number
|
|
46
|
+
* @param value T
|
|
47
|
+
*/
|
|
48
|
+
export function delay<T>(t: number, value?: T): Promise<T | void> {
|
|
49
|
+
return new Promise((resolve) => setTimeout(() => resolve(value), t));
|
|
51
50
|
}
|