@azure/msal-node 3.8.0 → 5.0.0-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/README.md +2 -1
- package/dist/cache/CacheHelpers.d.ts.map +1 -1
- package/dist/cache/CacheHelpers.mjs +4 -5
- package/dist/cache/CacheHelpers.mjs.map +1 -1
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +17 -18
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +15 -15
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.d.ts.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +3 -3
- package/dist/cache/distributed/DistributedCachePlugin.mjs.map +1 -1
- package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
- package/dist/cache/serializer/Deserializer.mjs +3 -5
- package/dist/cache/serializer/Deserializer.mjs.map +1 -1
- package/dist/cache/serializer/Serializer.d.ts.map +1 -1
- package/dist/cache/serializer/Serializer.mjs +1 -3
- package/dist/cache/serializer/Serializer.mjs.map +1 -1
- package/dist/cache/serializer/SerializerTypes.d.ts +0 -2
- package/dist/cache/serializer/SerializerTypes.d.ts.map +1 -1
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +33 -43
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.d.ts.map +1 -1
- package/dist/client/ClientAssertion.mjs +6 -5
- package/dist/client/ClientAssertion.mjs.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts +3 -2
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +23 -22
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +10 -9
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts +2 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +19 -18
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- package/dist/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +7 -6
- package/dist/client/ManagedIdentityApplication.mjs.map +1 -1
- package/dist/client/ManagedIdentityClient.mjs +1 -1
- package/dist/client/ManagedIdentityClient.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +3 -3
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +8 -8
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +12 -11
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +3 -3
- package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +3 -3
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +3 -3
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +4 -4
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts +2 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +19 -19
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +12 -27
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts +2 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +8 -8
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +2 -13
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +17 -22
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityId.mjs.map +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
- package/dist/crypto/CryptoProvider.d.ts.map +1 -1
- package/dist/crypto/CryptoProvider.mjs +5 -3
- package/dist/crypto/CryptoProvider.mjs.map +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs.map +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/HashUtils.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +6 -4
- package/dist/crypto/PkceGenerator.mjs.map +1 -1
- package/dist/error/ClientAuthErrorCodes.d.ts +8 -0
- package/dist/error/ClientAuthErrorCodes.d.ts.map +1 -0
- package/dist/error/ClientAuthErrorCodes.mjs +16 -0
- package/dist/error/ClientAuthErrorCodes.mjs.map +1 -0
- package/dist/error/ManagedIdentityError.mjs +1 -1
- package/dist/error/ManagedIdentityError.mjs.map +1 -1
- package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
- package/dist/error/ManagedIdentityErrorCodes.mjs.map +1 -1
- package/dist/error/NodeAuthError.d.ts +0 -8
- package/dist/error/NodeAuthError.d.ts.map +1 -1
- package/dist/error/NodeAuthError.mjs +1 -11
- package/dist/error/NodeAuthError.mjs.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +20 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/network/HttpClient.mjs +15 -13
- package/dist/network/HttpClient.mjs.map +1 -1
- package/dist/network/HttpClientWithRetries.mjs +3 -3
- package/dist/network/HttpClientWithRetries.mjs.map +1 -1
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +3 -3
- package/dist/network/LoopbackClient.mjs.map +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/protocol/Authorize.d.ts.map +1 -1
- package/dist/protocol/Authorize.mjs +5 -5
- package/dist/protocol/Authorize.mjs.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/ClientCredentialRequest.d.ts +4 -3
- package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts +16 -0
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts +20 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts +14 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts +18 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts.map +1 -0
- package/dist/request/DeviceCodeRequest.d.ts +3 -2
- package/dist/request/DeviceCodeRequest.d.ts.map +1 -1
- package/dist/request/InteractiveRequest.d.ts +1 -1
- package/dist/request/InteractiveRequest.d.ts.map +1 -1
- package/dist/request/ManagedIdentityRequest.d.ts +1 -1
- package/dist/request/ManagedIdentityRequest.d.ts.map +1 -1
- package/dist/request/OnBehalfOfRequest.d.ts +2 -2
- package/dist/request/OnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/RefreshTokenRequest.d.ts +1 -1
- package/dist/request/RefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/SilentFlowRequest.d.ts +1 -1
- package/dist/request/SilentFlowRequest.d.ts.map +1 -1
- package/dist/request/UsernamePasswordRequest.d.ts +2 -2
- package/dist/request/UsernamePasswordRequest.d.ts.map +1 -1
- package/dist/response/ManagedIdentityTokenResponse.d.ts +2 -2
- package/dist/response/ManagedIdentityTokenResponse.d.ts.map +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +9 -9
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs.map +1 -1
- package/dist/retry/ExponentialRetryStrategy.mjs +1 -1
- package/dist/retry/ExponentialRetryStrategy.mjs.map +1 -1
- package/dist/retry/IHttpRetryPolicy.d.ts +1 -1
- package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -1
- package/dist/retry/ImdsRetryPolicy.d.ts +1 -1
- package/dist/retry/ImdsRetryPolicy.d.ts.map +1 -1
- package/dist/retry/ImdsRetryPolicy.mjs +11 -11
- package/dist/retry/ImdsRetryPolicy.mjs.map +1 -1
- package/dist/retry/LinearRetryStrategy.mjs +1 -1
- package/dist/retry/LinearRetryStrategy.mjs.map +1 -1
- package/dist/utils/Constants.d.ts +4 -4
- package/dist/utils/Constants.mjs +5 -5
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.d.ts.map +1 -1
- package/dist/utils/EncodingUtils.mjs +5 -5
- package/dist/utils/EncodingUtils.mjs.map +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs.map +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs.map +1 -1
- package/lib/msal-node.cjs +1396 -2249
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/cache/CacheHelpers.d.ts.map +1 -1
- package/lib/types/cache/NodeStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/cache/distributed/DistributedCachePlugin.d.ts.map +1 -1
- package/lib/types/cache/serializer/Deserializer.d.ts.map +1 -1
- package/lib/types/cache/serializer/Serializer.d.ts.map +1 -1
- package/lib/types/cache/serializer/SerializerTypes.d.ts +0 -2
- package/lib/types/cache/serializer/SerializerTypes.d.ts.map +1 -1
- package/lib/types/client/ClientApplication.d.ts.map +1 -1
- package/lib/types/client/ClientAssertion.d.ts.map +1 -1
- package/lib/types/client/ClientCredentialClient.d.ts +3 -2
- package/lib/types/client/ClientCredentialClient.d.ts.map +1 -1
- package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/lib/types/client/DeviceCodeClient.d.ts +2 -1
- package/lib/types/client/DeviceCodeClient.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/client/OnBehalfOfClient.d.ts +2 -1
- package/lib/types/client/OnBehalfOfClient.d.ts.map +1 -1
- package/lib/types/client/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/client/UsernamePasswordClient.d.ts +2 -1
- package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +2 -13
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/crypto/CryptoProvider.d.ts.map +1 -1
- package/lib/types/crypto/PkceGenerator.d.ts.map +1 -1
- package/lib/types/error/ClientAuthErrorCodes.d.ts +8 -0
- package/lib/types/error/ClientAuthErrorCodes.d.ts.map +1 -0
- package/lib/types/error/NodeAuthError.d.ts +0 -8
- package/lib/types/error/NodeAuthError.d.ts.map +1 -1
- package/lib/types/index.d.ts +15 -5
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/network/HttpClient.d.ts.map +1 -1
- package/lib/types/network/LoopbackClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/packageMetadata.d.ts.map +1 -1
- package/lib/types/protocol/Authorize.d.ts.map +1 -1
- package/lib/types/request/AuthorizationCodeRequest.d.ts +1 -1
- package/lib/types/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/lib/types/request/ClientCredentialRequest.d.ts +4 -3
- package/lib/types/request/ClientCredentialRequest.d.ts.map +1 -1
- package/lib/types/request/CommonClientCredentialRequest.d.ts +16 -0
- package/lib/types/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/lib/types/request/CommonDeviceCodeRequest.d.ts +20 -0
- package/lib/types/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/lib/types/request/CommonOnBehalfOfRequest.d.ts +14 -0
- package/lib/types/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/lib/types/request/CommonUsernamePasswordRequest.d.ts +18 -0
- package/lib/types/request/CommonUsernamePasswordRequest.d.ts.map +1 -0
- package/lib/types/request/DeviceCodeRequest.d.ts +3 -2
- package/lib/types/request/DeviceCodeRequest.d.ts.map +1 -1
- package/lib/types/request/InteractiveRequest.d.ts +1 -1
- package/lib/types/request/InteractiveRequest.d.ts.map +1 -1
- package/lib/types/request/ManagedIdentityRequest.d.ts +1 -1
- package/lib/types/request/ManagedIdentityRequest.d.ts.map +1 -1
- package/lib/types/request/OnBehalfOfRequest.d.ts +2 -2
- package/lib/types/request/OnBehalfOfRequest.d.ts.map +1 -1
- package/lib/types/request/RefreshTokenRequest.d.ts +1 -1
- package/lib/types/request/RefreshTokenRequest.d.ts.map +1 -1
- package/lib/types/request/SilentFlowRequest.d.ts +1 -1
- package/lib/types/request/SilentFlowRequest.d.ts.map +1 -1
- package/lib/types/request/UsernamePasswordRequest.d.ts +2 -2
- package/lib/types/request/UsernamePasswordRequest.d.ts.map +1 -1
- package/lib/types/response/ManagedIdentityTokenResponse.d.ts +2 -2
- package/lib/types/response/ManagedIdentityTokenResponse.d.ts.map +1 -1
- package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts +1 -1
- package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -1
- package/lib/types/retry/IHttpRetryPolicy.d.ts +1 -1
- package/lib/types/retry/IHttpRetryPolicy.d.ts.map +1 -1
- package/lib/types/retry/ImdsRetryPolicy.d.ts +1 -1
- package/lib/types/retry/ImdsRetryPolicy.d.ts.map +1 -1
- package/lib/types/utils/Constants.d.ts +4 -4
- package/lib/types/utils/EncodingUtils.d.ts.map +1 -1
- package/package.json +88 -90
- package/src/cache/CacheHelpers.ts +3 -5
- package/src/cache/NodeStorage.ts +21 -16
- package/src/cache/TokenCache.ts +18 -14
- package/src/cache/distributed/DistributedCachePlugin.ts +2 -1
- package/src/cache/serializer/Deserializer.ts +7 -9
- package/src/cache/serializer/Serializer.ts +0 -2
- package/src/cache/serializer/SerializerTypes.ts +0 -2
- package/src/client/ClientApplication.ts +50 -57
- package/src/client/ClientAssertion.ts +5 -6
- package/src/client/ClientCredentialClient.ts +33 -25
- package/src/client/ConfidentialClientApplication.ts +13 -13
- package/src/client/DeviceCodeClient.ts +32 -19
- package/src/client/ManagedIdentityApplication.ts +10 -7
- package/src/client/ManagedIdentitySources/AppService.ts +4 -2
- package/src/client/ManagedIdentitySources/AzureArc.ts +14 -8
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +18 -9
- package/src/client/ManagedIdentitySources/CloudShell.ts +4 -2
- package/src/client/ManagedIdentitySources/Imds.ts +4 -2
- package/src/client/ManagedIdentitySources/MachineLearning.ts +4 -2
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +6 -3
- package/src/client/OnBehalfOfClient.ts +28 -21
- package/src/client/PublicClientApplication.ts +13 -31
- package/src/client/UsernamePasswordClient.ts +15 -8
- package/src/config/Configuration.ts +18 -35
- package/src/crypto/CryptoProvider.ts +5 -3
- package/src/crypto/PkceGenerator.ts +6 -4
- package/src/error/ClientAuthErrorCodes.ts +12 -0
- package/src/error/NodeAuthError.ts +0 -14
- package/src/index.ts +5 -11
- package/src/network/HttpClient.ts +11 -9
- package/src/network/HttpClientWithRetries.ts +2 -2
- package/src/network/LoopbackClient.ts +2 -3
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Authorize.ts +7 -9
- package/src/request/AuthorizationCodeRequest.ts +0 -1
- package/src/request/AuthorizationUrlRequest.ts +0 -1
- package/src/request/ClientCredentialRequest.ts +3 -6
- package/src/request/CommonClientCredentialRequest.ts +25 -0
- package/src/request/CommonDeviceCodeRequest.ts +33 -0
- package/src/request/CommonOnBehalfOfRequest.ts +19 -0
- package/src/request/CommonUsernamePasswordRequest.ts +23 -0
- package/src/request/DeviceCodeRequest.ts +2 -5
- package/src/request/InteractiveRequest.ts +1 -1
- package/src/request/ManagedIdentityRequest.ts +1 -1
- package/src/request/OnBehalfOfRequest.ts +1 -2
- package/src/request/RefreshTokenRequest.ts +0 -1
- package/src/request/SilentFlowRequest.ts +1 -4
- package/src/request/UsernamePasswordRequest.ts +1 -2
- package/src/response/ManagedIdentityTokenResponse.ts +2 -2
- package/src/retry/DefaultManagedIdentityRetryPolicy.ts +9 -8
- package/src/retry/IHttpRetryPolicy.ts +1 -1
- package/src/retry/ImdsRetryPolicy.ts +11 -10
- package/src/utils/Constants.ts +5 -5
- package/src/utils/EncodingUtils.ts +8 -4
package/src/cache/NodeStorage.ts
CHANGED
|
@@ -20,8 +20,10 @@ import {
|
|
|
20
20
|
ValidCredentialType,
|
|
21
21
|
StaticAuthorityOptions,
|
|
22
22
|
CacheHelpers,
|
|
23
|
+
AccountEntityUtils,
|
|
23
24
|
CredentialEntity,
|
|
24
25
|
AccountInfo,
|
|
26
|
+
StubPerformanceClient,
|
|
25
27
|
} from "@azure/msal-common/node";
|
|
26
28
|
|
|
27
29
|
import { Deserializer } from "./serializer/Deserializer.js";
|
|
@@ -31,7 +33,6 @@ import {
|
|
|
31
33
|
JsonCache,
|
|
32
34
|
CacheKVStore,
|
|
33
35
|
} from "./serializer/SerializerTypes.js";
|
|
34
|
-
import { StubPerformanceClient } from "@azure/msal-common";
|
|
35
36
|
import { generateAccountKey, generateCredentialKey } from "./CacheHelpers.js";
|
|
36
37
|
|
|
37
38
|
/**
|
|
@@ -93,7 +94,7 @@ export class NodeStorage extends CacheManager {
|
|
|
93
94
|
if (typeof value !== "object") {
|
|
94
95
|
continue;
|
|
95
96
|
}
|
|
96
|
-
if (value
|
|
97
|
+
if (AccountEntityUtils.isAccountEntity(value)) {
|
|
97
98
|
inMemoryCache.accounts[key] = value as AccountEntity;
|
|
98
99
|
} else if (CacheHelpers.isIdTokenEntity(value)) {
|
|
99
100
|
inMemoryCache.idTokens[key] = value as IdTokenEntity;
|
|
@@ -136,7 +137,7 @@ export class NodeStorage extends CacheManager {
|
|
|
136
137
|
* gets the current in memory cache for the client
|
|
137
138
|
*/
|
|
138
139
|
getInMemoryCache(): InMemoryCache {
|
|
139
|
-
this.logger.trace("Getting in-memory cache");
|
|
140
|
+
this.logger.trace("Getting in-memory cache", "");
|
|
140
141
|
|
|
141
142
|
// convert the cache key value store to inMemoryCache
|
|
142
143
|
const inMemoryCache = this.cacheToInMemoryCache(this.getCache());
|
|
@@ -148,7 +149,7 @@ export class NodeStorage extends CacheManager {
|
|
|
148
149
|
* @param inMemoryCache - key value map in memory
|
|
149
150
|
*/
|
|
150
151
|
setInMemoryCache(inMemoryCache: InMemoryCache): void {
|
|
151
|
-
this.logger.trace("Setting in-memory cache");
|
|
152
|
+
this.logger.trace("Setting in-memory cache", "");
|
|
152
153
|
|
|
153
154
|
// convert and append the inMemoryCache to cacheKVStore
|
|
154
155
|
const cache = this.inMemoryCacheToCache(inMemoryCache);
|
|
@@ -161,7 +162,7 @@ export class NodeStorage extends CacheManager {
|
|
|
161
162
|
* get the current cache key-value store
|
|
162
163
|
*/
|
|
163
164
|
getCache(): CacheKVStore {
|
|
164
|
-
this.logger.trace("Getting cache key-value store");
|
|
165
|
+
this.logger.trace("Getting cache key-value store", "");
|
|
165
166
|
return this.cache;
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -170,7 +171,7 @@ export class NodeStorage extends CacheManager {
|
|
|
170
171
|
* @param cacheMap - key value map
|
|
171
172
|
*/
|
|
172
173
|
setCache(cache: CacheKVStore): void {
|
|
173
|
-
this.logger.trace("Setting cache key value store");
|
|
174
|
+
this.logger.trace("Setting cache key value store", "");
|
|
174
175
|
this.cache = cache;
|
|
175
176
|
|
|
176
177
|
// mark change in cache
|
|
@@ -182,7 +183,7 @@ export class NodeStorage extends CacheManager {
|
|
|
182
183
|
* @param key - lookup key for the cache entry
|
|
183
184
|
*/
|
|
184
185
|
getItem(key: string): ValidCacheType {
|
|
185
|
-
this.logger.tracePii(`Item key: ${key}
|
|
186
|
+
this.logger.tracePii(`Item key: ${key}`, "");
|
|
186
187
|
|
|
187
188
|
// read cache
|
|
188
189
|
const cache = this.getCache();
|
|
@@ -195,7 +196,7 @@ export class NodeStorage extends CacheManager {
|
|
|
195
196
|
* @param value - value of the cache entry
|
|
196
197
|
*/
|
|
197
198
|
setItem(key: string, value: ValidCacheType): void {
|
|
198
|
-
this.logger.tracePii(`Item key: ${key}
|
|
199
|
+
this.logger.tracePii(`Item key: ${key}`, "");
|
|
199
200
|
|
|
200
201
|
// read cache
|
|
201
202
|
const cache = this.getCache();
|
|
@@ -238,8 +239,8 @@ export class NodeStorage extends CacheManager {
|
|
|
238
239
|
*/
|
|
239
240
|
getAccount(accountKey: string): AccountEntity | null {
|
|
240
241
|
const cachedAccount = this.getItem(accountKey);
|
|
241
|
-
return cachedAccount
|
|
242
|
-
?
|
|
242
|
+
return cachedAccount && typeof cachedAccount === "object"
|
|
243
|
+
? ({ ...cachedAccount } as AccountEntity)
|
|
243
244
|
: null;
|
|
244
245
|
}
|
|
245
246
|
|
|
@@ -248,7 +249,9 @@ export class NodeStorage extends CacheManager {
|
|
|
248
249
|
* @param account - cache value to be set of type AccountEntity
|
|
249
250
|
*/
|
|
250
251
|
async setAccount(account: AccountEntity): Promise<void> {
|
|
251
|
-
const accountKey = this.generateAccountKey(
|
|
252
|
+
const accountKey = this.generateAccountKey(
|
|
253
|
+
AccountEntityUtils.getAccountInfo(account)
|
|
254
|
+
);
|
|
252
255
|
this.setItem(accountKey, account);
|
|
253
256
|
}
|
|
254
257
|
|
|
@@ -450,7 +453,7 @@ export class NodeStorage extends CacheManager {
|
|
|
450
453
|
* @param inMemory - key value map of the cache
|
|
451
454
|
*/
|
|
452
455
|
removeItem(key: string): boolean {
|
|
453
|
-
this.logger.tracePii(`Item key: ${key}
|
|
456
|
+
this.logger.tracePii(`Item key: ${key}`, "");
|
|
454
457
|
|
|
455
458
|
// read inMemoryCache
|
|
456
459
|
let result: boolean = false;
|
|
@@ -489,7 +492,7 @@ export class NodeStorage extends CacheManager {
|
|
|
489
492
|
* Gets all keys in window.
|
|
490
493
|
*/
|
|
491
494
|
getKeys(): string[] {
|
|
492
|
-
this.logger.trace("Retrieving all cache keys");
|
|
495
|
+
this.logger.trace("Retrieving all cache keys", "");
|
|
493
496
|
|
|
494
497
|
// read cache
|
|
495
498
|
const cache = this.getCache();
|
|
@@ -500,7 +503,7 @@ export class NodeStorage extends CacheManager {
|
|
|
500
503
|
* Clears all cache entries created by MSAL (except tokens).
|
|
501
504
|
*/
|
|
502
505
|
clear(): void {
|
|
503
|
-
this.logger.trace("Clearing cache entries created by MSAL");
|
|
506
|
+
this.logger.trace("Clearing cache entries created by MSAL", "");
|
|
504
507
|
|
|
505
508
|
// read inMemoryCache
|
|
506
509
|
const cacheKeys = this.getKeys();
|
|
@@ -545,12 +548,14 @@ export class NodeStorage extends CacheManager {
|
|
|
545
548
|
this.removeItem(currentCacheKey);
|
|
546
549
|
this.setItem(updatedCacheKey, cacheItem);
|
|
547
550
|
this.logger.verbose(
|
|
548
|
-
`Updated an outdated ${credential.credentialType} cache key
|
|
551
|
+
`Updated an outdated ${credential.credentialType} cache key`,
|
|
552
|
+
""
|
|
549
553
|
);
|
|
550
554
|
return updatedCacheKey;
|
|
551
555
|
} else {
|
|
552
556
|
this.logger.error(
|
|
553
|
-
`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage
|
|
557
|
+
`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`,
|
|
558
|
+
""
|
|
554
559
|
);
|
|
555
560
|
}
|
|
556
561
|
}
|
package/src/cache/TokenCache.ts
CHANGED
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
import { Deserializer } from "./serializer/Deserializer.js";
|
|
25
25
|
import { Serializer } from "./serializer/Serializer.js";
|
|
26
26
|
import { ITokenCache } from "./ITokenCache.js";
|
|
27
|
-
import { CryptoProvider } from "../crypto/CryptoProvider.js";
|
|
28
27
|
import { GuidGenerator } from "../crypto/GuidGenerator.js";
|
|
28
|
+
import { CryptoProvider } from "../crypto/CryptoProvider.js";
|
|
29
29
|
|
|
30
30
|
const defaultSerializedCache: JsonCache = {
|
|
31
31
|
Account: {},
|
|
@@ -71,20 +71,20 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
71
71
|
* Serializes in memory cache to JSON
|
|
72
72
|
*/
|
|
73
73
|
serialize(): string {
|
|
74
|
-
this.logger.trace("Serializing in-memory cache");
|
|
74
|
+
this.logger.trace("Serializing in-memory cache", "");
|
|
75
75
|
let finalState = Serializer.serializeAllCache(
|
|
76
76
|
this.storage.getInMemoryCache() as InMemoryCache
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
// if cacheSnapshot not null or empty, merge
|
|
80
80
|
if (this.cacheSnapshot) {
|
|
81
|
-
this.logger.trace("Reading cache snapshot from disk");
|
|
81
|
+
this.logger.trace("Reading cache snapshot from disk", "");
|
|
82
82
|
finalState = this.mergeState(
|
|
83
83
|
JSON.parse(this.cacheSnapshot),
|
|
84
84
|
finalState
|
|
85
85
|
);
|
|
86
86
|
} else {
|
|
87
|
-
this.logger.trace("No cache snapshot to merge");
|
|
87
|
+
this.logger.trace("No cache snapshot to merge", "");
|
|
88
88
|
}
|
|
89
89
|
this.cacheHasChanged = false;
|
|
90
90
|
|
|
@@ -96,17 +96,17 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
96
96
|
* @param cache - blob formatted cache
|
|
97
97
|
*/
|
|
98
98
|
deserialize(cache: string): void {
|
|
99
|
-
this.logger.trace("Deserializing JSON to in-memory cache");
|
|
99
|
+
this.logger.trace("Deserializing JSON to in-memory cache", "");
|
|
100
100
|
this.cacheSnapshot = cache;
|
|
101
101
|
|
|
102
102
|
if (this.cacheSnapshot) {
|
|
103
|
-
this.logger.trace("Reading cache snapshot from disk");
|
|
103
|
+
this.logger.trace("Reading cache snapshot from disk", "");
|
|
104
104
|
const deserializedCache = Deserializer.deserializeAllCache(
|
|
105
105
|
this.overlayDefaults(JSON.parse(this.cacheSnapshot))
|
|
106
106
|
);
|
|
107
107
|
this.storage.setInMemoryCache(deserializedCache);
|
|
108
108
|
} else {
|
|
109
|
-
this.logger.trace("No cache snapshot to deserialize");
|
|
109
|
+
this.logger.trace("No cache snapshot to deserialize", "");
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -133,7 +133,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
133
133
|
async getAllAccounts(
|
|
134
134
|
correlationId: string = new CryptoProvider().createNewGuid()
|
|
135
135
|
): Promise<AccountInfo[]> {
|
|
136
|
-
this.logger.trace("getAllAccounts called");
|
|
136
|
+
this.logger.trace("getAllAccounts called", correlationId);
|
|
137
137
|
let cacheContext;
|
|
138
138
|
try {
|
|
139
139
|
if (this.persistence) {
|
|
@@ -198,7 +198,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
198
198
|
account: AccountInfo,
|
|
199
199
|
correlationId?: string
|
|
200
200
|
): Promise<void> {
|
|
201
|
-
this.logger.trace("removeAccount called");
|
|
201
|
+
this.logger.trace("removeAccount called", correlationId || "");
|
|
202
202
|
let cacheContext;
|
|
203
203
|
try {
|
|
204
204
|
if (this.persistence) {
|
|
@@ -222,11 +222,15 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
222
222
|
async overwriteCache(): Promise<void> {
|
|
223
223
|
if (!this.persistence) {
|
|
224
224
|
this.logger.info(
|
|
225
|
-
"No persistence layer specified, cache cannot be overwritten"
|
|
225
|
+
"No persistence layer specified, cache cannot be overwritten",
|
|
226
|
+
""
|
|
226
227
|
);
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
229
|
-
this.logger.info(
|
|
230
|
+
this.logger.info(
|
|
231
|
+
"Overwriting in-memory cache with persistent cache",
|
|
232
|
+
""
|
|
233
|
+
);
|
|
230
234
|
this.storage.clear();
|
|
231
235
|
const cacheContext = new TokenCacheContext(this, false);
|
|
232
236
|
await this.persistence.beforeCacheAccess(cacheContext);
|
|
@@ -251,7 +255,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
251
255
|
oldState: JsonCache,
|
|
252
256
|
currentState: JsonCache
|
|
253
257
|
): JsonCache {
|
|
254
|
-
this.logger.trace("Merging in-memory cache with cache snapshot");
|
|
258
|
+
this.logger.trace("Merging in-memory cache with cache snapshot", "");
|
|
255
259
|
const stateAfterRemoval = this.mergeRemovals(oldState, currentState);
|
|
256
260
|
return this.mergeUpdates(stateAfterRemoval, currentState);
|
|
257
261
|
}
|
|
@@ -302,7 +306,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
302
306
|
* @param newState - updated cache
|
|
303
307
|
*/
|
|
304
308
|
private mergeRemovals(oldState: JsonCache, newState: JsonCache): JsonCache {
|
|
305
|
-
this.logger.trace("Remove updated entries in cache");
|
|
309
|
+
this.logger.trace("Remove updated entries in cache", "");
|
|
306
310
|
const accounts = oldState.Account
|
|
307
311
|
? this.mergeRemovalsDict<SerializedAccountEntity>(
|
|
308
312
|
oldState.Account,
|
|
@@ -367,7 +371,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
|
|
|
367
371
|
* @param passedInCache - cache read from the blob
|
|
368
372
|
*/
|
|
369
373
|
private overlayDefaults(passedInCache: JsonCache): JsonCache {
|
|
370
|
-
this.logger.trace("Overlaying input cache with the default cache");
|
|
374
|
+
this.logger.trace("Overlaying input cache with the default cache", "");
|
|
371
375
|
return {
|
|
372
376
|
Account: {
|
|
373
377
|
...defaultSerializedCache.Account,
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import {
|
|
7
7
|
AccountEntity,
|
|
8
8
|
ICachePlugin,
|
|
9
|
+
AccountEntityUtils,
|
|
9
10
|
TokenCacheContext,
|
|
10
11
|
} from "@azure/msal-common/node";
|
|
11
12
|
import { TokenCache } from "../TokenCache.js";
|
|
@@ -49,7 +50,7 @@ export class DistributedCachePlugin implements ICachePlugin {
|
|
|
49
50
|
cacheContext.tokenCache as TokenCache
|
|
50
51
|
).getKVStore();
|
|
51
52
|
const accountEntities = Object.values(kvStore).filter((value) =>
|
|
52
|
-
|
|
53
|
+
AccountEntityUtils.isAccountEntity(value as object)
|
|
53
54
|
);
|
|
54
55
|
|
|
55
56
|
let partitionKey: string;
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
AccessTokenEntity,
|
|
15
15
|
RefreshTokenEntity,
|
|
16
16
|
CacheManager,
|
|
17
|
-
|
|
18
|
-
AuthenticationScheme,
|
|
17
|
+
Constants,
|
|
19
18
|
} from "@azure/msal-common/node";
|
|
20
19
|
import {
|
|
21
20
|
JsonCache,
|
|
@@ -70,7 +69,7 @@ export class Deserializer {
|
|
|
70
69
|
),
|
|
71
70
|
lastUpdatedAt: Date.now().toString(),
|
|
72
71
|
};
|
|
73
|
-
const account: AccountEntity =
|
|
72
|
+
const account: AccountEntity = {} as AccountEntity;
|
|
74
73
|
CacheManager.toObject(account, mappedAcc);
|
|
75
74
|
accountObjects[key] = account;
|
|
76
75
|
});
|
|
@@ -94,7 +93,7 @@ export class Deserializer {
|
|
|
94
93
|
homeAccountId: serializedIdT.home_account_id,
|
|
95
94
|
environment: serializedIdT.environment,
|
|
96
95
|
credentialType:
|
|
97
|
-
serializedIdT.credential_type as CredentialType,
|
|
96
|
+
serializedIdT.credential_type as Constants.CredentialType,
|
|
98
97
|
clientId: serializedIdT.client_id,
|
|
99
98
|
secret: serializedIdT.secret,
|
|
100
99
|
realm: serializedIdT.realm,
|
|
@@ -121,7 +120,7 @@ export class Deserializer {
|
|
|
121
120
|
homeAccountId: serializedAT.home_account_id,
|
|
122
121
|
environment: serializedAT.environment,
|
|
123
122
|
credentialType:
|
|
124
|
-
serializedAT.credential_type as CredentialType,
|
|
123
|
+
serializedAT.credential_type as Constants.CredentialType,
|
|
125
124
|
clientId: serializedAT.client_id,
|
|
126
125
|
secret: serializedAT.secret,
|
|
127
126
|
realm: serializedAT.realm,
|
|
@@ -131,9 +130,8 @@ export class Deserializer {
|
|
|
131
130
|
extendedExpiresOn: serializedAT.extended_expires_on,
|
|
132
131
|
refreshOn: serializedAT.refresh_on,
|
|
133
132
|
keyId: serializedAT.key_id,
|
|
134
|
-
tokenType:
|
|
135
|
-
|
|
136
|
-
requestedClaimsHash: serializedAT.requestedClaimsHash,
|
|
133
|
+
tokenType:
|
|
134
|
+
serializedAT.token_type as Constants.AuthenticationScheme,
|
|
137
135
|
userAssertionHash: serializedAT.userAssertionHash,
|
|
138
136
|
lastUpdatedAt: Date.now().toString(),
|
|
139
137
|
};
|
|
@@ -159,7 +157,7 @@ export class Deserializer {
|
|
|
159
157
|
homeAccountId: serializedRT.home_account_id,
|
|
160
158
|
environment: serializedRT.environment,
|
|
161
159
|
credentialType:
|
|
162
|
-
serializedRT.credential_type as CredentialType,
|
|
160
|
+
serializedRT.credential_type as Constants.CredentialType,
|
|
163
161
|
clientId: serializedRT.client_id,
|
|
164
162
|
secret: serializedRT.secret,
|
|
165
163
|
familyId: serializedRT.family_id,
|
|
@@ -112,8 +112,6 @@ export class Serializer {
|
|
|
112
112
|
refresh_on: atEntity.refreshOn,
|
|
113
113
|
key_id: atEntity.keyId,
|
|
114
114
|
token_type: atEntity.tokenType,
|
|
115
|
-
requestedClaims: atEntity.requestedClaims,
|
|
116
|
-
requestedClaimsHash: atEntity.requestedClaimsHash,
|
|
117
115
|
userAssertionHash: atEntity.userAssertionHash,
|
|
118
116
|
};
|
|
119
117
|
});
|
|
@@ -19,25 +19,20 @@ import {
|
|
|
19
19
|
CommonRefreshTokenRequest,
|
|
20
20
|
CommonAuthorizationCodeRequest,
|
|
21
21
|
CommonAuthorizationUrlRequest,
|
|
22
|
-
CommonUsernamePasswordRequest,
|
|
23
|
-
AuthenticationScheme,
|
|
24
|
-
ResponseMode,
|
|
25
22
|
AuthorityOptions,
|
|
26
|
-
OIDC_DEFAULT_SCOPES,
|
|
27
23
|
AzureRegionConfiguration,
|
|
28
24
|
AuthError,
|
|
29
25
|
AzureCloudOptions,
|
|
30
26
|
AuthorizationCodePayload,
|
|
31
|
-
Constants,
|
|
32
|
-
StringUtils,
|
|
33
27
|
createClientAuthError,
|
|
34
28
|
ClientAuthErrorCodes,
|
|
35
29
|
buildStaticAuthorityOptions,
|
|
36
30
|
ClientAssertion as ClientAssertionType,
|
|
37
31
|
getClientAssertion,
|
|
38
32
|
ClientAssertionCallback,
|
|
39
|
-
|
|
33
|
+
Constants,
|
|
40
34
|
ClientAuthError,
|
|
35
|
+
StubPerformanceClient,
|
|
41
36
|
} from "@azure/msal-common/node";
|
|
42
37
|
import {
|
|
43
38
|
Configuration,
|
|
@@ -55,6 +50,7 @@ import { RefreshTokenRequest } from "../request/RefreshTokenRequest.js";
|
|
|
55
50
|
import { SilentFlowRequest } from "../request/SilentFlowRequest.js";
|
|
56
51
|
import { version, name } from "../packageMetadata.js";
|
|
57
52
|
import { UsernamePasswordRequest } from "../request/UsernamePasswordRequest.js";
|
|
53
|
+
import { CommonUsernamePasswordRequest } from "../request/CommonUsernamePasswordRequest.js";
|
|
58
54
|
import { NodeAuthError } from "../error/NodeAuthError.js";
|
|
59
55
|
import { UsernamePasswordClient } from "./UsernamePasswordClient.js";
|
|
60
56
|
import { getAuthCodeRequestUrl } from "../protocol/Authorize.js";
|
|
@@ -125,12 +121,12 @@ export abstract class ClientApplication {
|
|
|
125
121
|
* `acquireTokenByCode(AuthorizationCodeRequest)`.
|
|
126
122
|
*/
|
|
127
123
|
async getAuthCodeUrl(request: AuthorizationUrlRequest): Promise<string> {
|
|
128
|
-
this.logger.info("getAuthCodeUrl called", request.correlationId);
|
|
124
|
+
this.logger.info("getAuthCodeUrl called", request.correlationId || "");
|
|
129
125
|
const validRequest: CommonAuthorizationUrlRequest = {
|
|
130
126
|
...request,
|
|
131
127
|
...(await this.initializeBaseRequest(request)),
|
|
132
|
-
responseMode: request.responseMode || ResponseMode.QUERY,
|
|
133
|
-
authenticationScheme: AuthenticationScheme.BEARER,
|
|
128
|
+
responseMode: request.responseMode || Constants.ResponseMode.QUERY,
|
|
129
|
+
authenticationScheme: Constants.AuthenticationScheme.BEARER,
|
|
134
130
|
state: request.state || "",
|
|
135
131
|
nonce: request.nonce || "",
|
|
136
132
|
};
|
|
@@ -161,9 +157,15 @@ export abstract class ClientApplication {
|
|
|
161
157
|
request: AuthorizationCodeRequest,
|
|
162
158
|
authCodePayLoad?: AuthorizationCodePayload
|
|
163
159
|
): Promise<AuthenticationResult> {
|
|
164
|
-
this.logger.info(
|
|
160
|
+
this.logger.info(
|
|
161
|
+
"acquireTokenByCode called",
|
|
162
|
+
request.correlationId || ""
|
|
163
|
+
);
|
|
165
164
|
if (request.state && authCodePayLoad) {
|
|
166
|
-
this.logger.info(
|
|
165
|
+
this.logger.info(
|
|
166
|
+
"acquireTokenByCode - validating state",
|
|
167
|
+
request.correlationId || ""
|
|
168
|
+
);
|
|
167
169
|
this.validateState(request.state, authCodePayLoad.state || "");
|
|
168
170
|
// eslint-disable-next-line no-param-reassign
|
|
169
171
|
authCodePayLoad = { ...authCodePayLoad, state: "" };
|
|
@@ -171,7 +173,7 @@ export abstract class ClientApplication {
|
|
|
171
173
|
const validRequest: CommonAuthorizationCodeRequest = {
|
|
172
174
|
...request,
|
|
173
175
|
...(await this.initializeBaseRequest(request)),
|
|
174
|
-
authenticationScheme: AuthenticationScheme.BEARER,
|
|
176
|
+
authenticationScheme: Constants.AuthenticationScheme.BEARER,
|
|
175
177
|
};
|
|
176
178
|
|
|
177
179
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
@@ -192,7 +194,8 @@ export abstract class ClientApplication {
|
|
|
192
194
|
serverTelemetryManager
|
|
193
195
|
);
|
|
194
196
|
const authorizationCodeClient = new AuthorizationCodeClient(
|
|
195
|
-
authClientConfig
|
|
197
|
+
authClientConfig,
|
|
198
|
+
new StubPerformanceClient()
|
|
196
199
|
);
|
|
197
200
|
this.logger.verbose(
|
|
198
201
|
"Auth code client created",
|
|
@@ -223,12 +226,12 @@ export abstract class ClientApplication {
|
|
|
223
226
|
): Promise<AuthenticationResult | null> {
|
|
224
227
|
this.logger.info(
|
|
225
228
|
"acquireTokenByRefreshToken called",
|
|
226
|
-
request.correlationId
|
|
229
|
+
request.correlationId || ""
|
|
227
230
|
);
|
|
228
231
|
const validRequest: CommonRefreshTokenRequest = {
|
|
229
232
|
...request,
|
|
230
233
|
...(await this.initializeBaseRequest(request)),
|
|
231
|
-
authenticationScheme: AuthenticationScheme.BEARER,
|
|
234
|
+
authenticationScheme: Constants.AuthenticationScheme.BEARER,
|
|
232
235
|
};
|
|
233
236
|
|
|
234
237
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
@@ -250,7 +253,8 @@ export abstract class ClientApplication {
|
|
|
250
253
|
serverTelemetryManager
|
|
251
254
|
);
|
|
252
255
|
const refreshTokenClient = new RefreshTokenClient(
|
|
253
|
-
refreshTokenClientConfig
|
|
256
|
+
refreshTokenClientConfig,
|
|
257
|
+
new StubPerformanceClient()
|
|
254
258
|
);
|
|
255
259
|
this.logger.verbose(
|
|
256
260
|
"Refresh token client created",
|
|
@@ -303,7 +307,10 @@ export abstract class ClientApplication {
|
|
|
303
307
|
validRequest.redirectUri || "",
|
|
304
308
|
serverTelemetryManager
|
|
305
309
|
);
|
|
306
|
-
const silentFlowClient = new SilentFlowClient(
|
|
310
|
+
const silentFlowClient = new SilentFlowClient(
|
|
311
|
+
clientConfiguration,
|
|
312
|
+
new StubPerformanceClient()
|
|
313
|
+
);
|
|
307
314
|
this.logger.verbose(
|
|
308
315
|
"Silent flow client created",
|
|
309
316
|
validRequest.correlationId
|
|
@@ -323,7 +330,8 @@ export abstract class ClientApplication {
|
|
|
323
330
|
ClientAuthErrorCodes.tokenRefreshRequired
|
|
324
331
|
) {
|
|
325
332
|
const refreshTokenClient = new RefreshTokenClient(
|
|
326
|
-
clientConfiguration
|
|
333
|
+
clientConfiguration,
|
|
334
|
+
new StubPerformanceClient()
|
|
327
335
|
);
|
|
328
336
|
return refreshTokenClient.acquireTokenByRefreshToken(
|
|
329
337
|
validRequest
|
|
@@ -350,16 +358,18 @@ export abstract class ClientApplication {
|
|
|
350
358
|
...validRequest,
|
|
351
359
|
scopes: validRequest.scopes?.length
|
|
352
360
|
? validRequest.scopes
|
|
353
|
-
: [...OIDC_DEFAULT_SCOPES],
|
|
361
|
+
: [...Constants.OIDC_DEFAULT_SCOPES],
|
|
354
362
|
});
|
|
355
363
|
|
|
356
|
-
if (cacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
|
|
364
|
+
if (cacheOutcome === Constants.CacheOutcome.PROACTIVELY_REFRESHED) {
|
|
357
365
|
this.logger.info(
|
|
358
|
-
"ClientApplication:acquireCachedTokenSilent - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed."
|
|
366
|
+
"ClientApplication:acquireCachedTokenSilent - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.",
|
|
367
|
+
validRequest.correlationId
|
|
359
368
|
);
|
|
360
369
|
// refresh the access token in the background
|
|
361
370
|
const refreshTokenClient = new RefreshTokenClient(
|
|
362
|
-
clientConfiguration
|
|
371
|
+
clientConfiguration,
|
|
372
|
+
new StubPerformanceClient()
|
|
363
373
|
);
|
|
364
374
|
|
|
365
375
|
try {
|
|
@@ -391,7 +401,7 @@ export abstract class ClientApplication {
|
|
|
391
401
|
): Promise<AuthenticationResult | null> {
|
|
392
402
|
this.logger.info(
|
|
393
403
|
"acquireTokenByUsernamePassword called",
|
|
394
|
-
request.correlationId
|
|
404
|
+
request.correlationId || ""
|
|
395
405
|
);
|
|
396
406
|
const validRequest: CommonUsernamePasswordRequest = {
|
|
397
407
|
...request,
|
|
@@ -436,7 +446,7 @@ export abstract class ClientApplication {
|
|
|
436
446
|
* Gets the token cache for the application.
|
|
437
447
|
*/
|
|
438
448
|
getTokenCache(): TokenCache {
|
|
439
|
-
this.logger.info("getTokenCache called");
|
|
449
|
+
this.logger.info("getTokenCache called", "");
|
|
440
450
|
return this.tokenCache;
|
|
441
451
|
}
|
|
442
452
|
|
|
@@ -513,10 +523,6 @@ export abstract class ClientApplication {
|
|
|
513
523
|
this.config.system.loggerOptions.piiLoggingEnabled,
|
|
514
524
|
correlationId: requestCorrelationId,
|
|
515
525
|
},
|
|
516
|
-
cacheOptions: {
|
|
517
|
-
claimsBasedCachingEnabled:
|
|
518
|
-
this.config.cache.claimsBasedCachingEnabled,
|
|
519
|
-
},
|
|
520
526
|
cryptoInterface: this.cryptoProvider,
|
|
521
527
|
networkInterface: this.config.system.networkClient,
|
|
522
528
|
storageInterface: this.storage,
|
|
@@ -530,8 +536,8 @@ export abstract class ClientApplication {
|
|
|
530
536
|
libraryInfo: {
|
|
531
537
|
sku: NodeConstants.MSAL_SKU,
|
|
532
538
|
version: version,
|
|
533
|
-
cpu: process.arch ||
|
|
534
|
-
os: process.platform ||
|
|
539
|
+
cpu: process.arch || "",
|
|
540
|
+
os: process.platform || "",
|
|
535
541
|
},
|
|
536
542
|
telemetry: this.config.telemetry,
|
|
537
543
|
persistencePlugin: this.config.cache.cachePlugin,
|
|
@@ -573,43 +579,31 @@ export abstract class ClientApplication {
|
|
|
573
579
|
protected async initializeBaseRequest(
|
|
574
580
|
authRequest: Partial<BaseAuthRequest>
|
|
575
581
|
): Promise<BaseAuthRequest> {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
);
|
|
582
|
+
const correlationId =
|
|
583
|
+
authRequest.correlationId || this.cryptoProvider.createNewGuid();
|
|
584
|
+
this.logger.verbose("initializeRequestScopes called", correlationId);
|
|
580
585
|
// Default authenticationScheme to Bearer, log that POP isn't supported yet
|
|
581
586
|
if (
|
|
582
587
|
authRequest.authenticationScheme &&
|
|
583
|
-
authRequest.authenticationScheme ===
|
|
588
|
+
authRequest.authenticationScheme ===
|
|
589
|
+
Constants.AuthenticationScheme.POP
|
|
584
590
|
) {
|
|
585
591
|
this.logger.verbose(
|
|
586
592
|
"Authentication Scheme 'pop' is not supported yet, setting Authentication Scheme to 'Bearer' for request",
|
|
587
|
-
|
|
593
|
+
correlationId
|
|
588
594
|
);
|
|
589
595
|
}
|
|
590
596
|
|
|
591
|
-
authRequest.authenticationScheme =
|
|
592
|
-
|
|
593
|
-
// Set requested claims hash if claims-based caching is enabled and claims were requested
|
|
594
|
-
if (
|
|
595
|
-
this.config.cache.claimsBasedCachingEnabled &&
|
|
596
|
-
authRequest.claims &&
|
|
597
|
-
// Checks for empty stringified object "{}" which doesn't qualify as requested claims
|
|
598
|
-
!StringUtils.isEmptyObj(authRequest.claims)
|
|
599
|
-
) {
|
|
600
|
-
authRequest.requestedClaimsHash =
|
|
601
|
-
await this.cryptoProvider.hashString(authRequest.claims);
|
|
602
|
-
}
|
|
597
|
+
authRequest.authenticationScheme =
|
|
598
|
+
Constants.AuthenticationScheme.BEARER;
|
|
603
599
|
|
|
604
600
|
return {
|
|
605
601
|
...authRequest,
|
|
606
602
|
scopes: [
|
|
607
603
|
...((authRequest && authRequest.scopes) || []),
|
|
608
|
-
...OIDC_DEFAULT_SCOPES,
|
|
604
|
+
...Constants.OIDC_DEFAULT_SCOPES,
|
|
609
605
|
],
|
|
610
|
-
correlationId
|
|
611
|
-
(authRequest && authRequest.correlationId) ||
|
|
612
|
-
this.cryptoProvider.createNewGuid(),
|
|
606
|
+
correlationId,
|
|
613
607
|
authority: authRequest.authority || this.config.auth.authority,
|
|
614
608
|
};
|
|
615
609
|
}
|
|
@@ -655,13 +649,11 @@ export abstract class ClientApplication {
|
|
|
655
649
|
);
|
|
656
650
|
|
|
657
651
|
const authorityOptions: AuthorityOptions = {
|
|
658
|
-
protocolMode: this.config.
|
|
652
|
+
protocolMode: this.config.system.protocolMode,
|
|
659
653
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
660
654
|
cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
|
|
661
655
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
662
656
|
azureRegionConfiguration,
|
|
663
|
-
skipAuthorityMetadataCache:
|
|
664
|
-
this.config.auth.skipAuthorityMetadataCache,
|
|
665
657
|
};
|
|
666
658
|
|
|
667
659
|
return AuthorityFactory.createDiscoveredInstance(
|
|
@@ -670,7 +662,8 @@ export abstract class ClientApplication {
|
|
|
670
662
|
this.storage,
|
|
671
663
|
authorityOptions,
|
|
672
664
|
this.logger,
|
|
673
|
-
requestCorrelationId
|
|
665
|
+
requestCorrelationId,
|
|
666
|
+
new StubPerformanceClient()
|
|
674
667
|
);
|
|
675
668
|
}
|
|
676
669
|
|
|
@@ -6,14 +6,13 @@
|
|
|
6
6
|
import jwt from "jsonwebtoken";
|
|
7
7
|
import {
|
|
8
8
|
TimeUtils,
|
|
9
|
-
Constants,
|
|
10
9
|
createClientAuthError,
|
|
11
|
-
|
|
12
|
-
EncodingTypes,
|
|
10
|
+
Constants,
|
|
13
11
|
} from "@azure/msal-common/node";
|
|
14
12
|
import { CryptoProvider } from "../crypto/CryptoProvider.js";
|
|
15
13
|
import { EncodingUtils } from "../utils/EncodingUtils.js";
|
|
16
14
|
import { JwtConstants } from "../utils/Constants.js";
|
|
15
|
+
import * as NodeClientAuthErrorCodes from "../error/ClientAuthErrorCodes.js";
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Client assertion of type jwt-bearer used in confidential client flows
|
|
@@ -117,7 +116,7 @@ export class ClientAssertion {
|
|
|
117
116
|
return this.jwt;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
throw createClientAuthError(
|
|
119
|
+
throw createClientAuthError(NodeClientAuthErrorCodes.invalidAssertion);
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
/**
|
|
@@ -146,7 +145,7 @@ export class ClientAssertion {
|
|
|
146
145
|
Object.assign(header, {
|
|
147
146
|
[thumbprintHeader]: EncodingUtils.base64EncodeUrl(
|
|
148
147
|
this.thumbprint,
|
|
149
|
-
EncodingTypes.HEX
|
|
148
|
+
Constants.EncodingTypes.HEX
|
|
150
149
|
),
|
|
151
150
|
} as Partial<jwt.JwtHeader>);
|
|
152
151
|
|
|
@@ -195,7 +194,7 @@ export class ClientAssertion {
|
|
|
195
194
|
let matches;
|
|
196
195
|
while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
|
|
197
196
|
// matches[1] represents the first parens capture group in the regex.
|
|
198
|
-
certs.push(matches[1].replace(/\r*\n/g,
|
|
197
|
+
certs.push(matches[1].replace(/\r*\n/g, ""));
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
return certs;
|