@azure/msal-node 3.8.4 → 5.0.0-beta.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/BaseClient.d.ts +42 -0
- package/dist/client/BaseClient.d.ts.map +1 -0
- package/dist/client/BaseClient.mjs +68 -0
- package/dist/client/BaseClient.mjs.map +1 -0
- 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 +4 -2
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +23 -21
- 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 +3 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +21 -19
- 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/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 +3 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +19 -18
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +15 -14
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts +3 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +8 -7
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +2 -19
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +18 -25
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +3 -3
- 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/HashUtils.mjs +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/ManagedIdentityErrorCodes.mjs +1 -1
- package/dist/error/NodeAuthError.mjs +1 -1
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +20 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.d.ts +53 -40
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/network/HttpClient.mjs +149 -315
- 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 +6 -6
- package/dist/protocol/Authorize.mjs.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +3 -2
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts +3 -3
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/ClientCredentialRequest.d.ts +4 -4
- package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
- package/dist/request/CommonClientCredentialRequest.d.ts +17 -0
- package/dist/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts +21 -0
- package/dist/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts +13 -0
- package/dist/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/dist/request/CommonUsernamePasswordRequest.d.ts +19 -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 -3
- package/dist/request/OnBehalfOfRequest.d.ts.map +1 -1
- package/dist/request/RefreshTokenRequest.d.ts +3 -2
- package/dist/request/RefreshTokenRequest.d.ts.map +1 -1
- package/dist/request/SilentFlowRequest.d.ts +3 -2
- package/dist/request/SilentFlowRequest.d.ts.map +1 -1
- package/dist/request/UsernamePasswordRequest.d.ts +4 -3
- 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/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/utils/Constants.d.ts +2 -9
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +4 -12
- 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/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +5378 -6289
- 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/BaseClient.d.ts +42 -0
- package/lib/types/client/BaseClient.d.ts.map +1 -0
- 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 +4 -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 +3 -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 +3 -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 +3 -1
- package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +2 -19
- 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/index.d.ts +15 -11
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/network/HttpClient.d.ts +53 -40
- 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 +3 -2
- package/lib/types/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/lib/types/request/AuthorizationUrlRequest.d.ts +3 -3
- package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/lib/types/request/ClientCredentialRequest.d.ts +4 -4
- package/lib/types/request/ClientCredentialRequest.d.ts.map +1 -1
- package/lib/types/request/CommonClientCredentialRequest.d.ts +17 -0
- package/lib/types/request/CommonClientCredentialRequest.d.ts.map +1 -0
- package/lib/types/request/CommonDeviceCodeRequest.d.ts +21 -0
- package/lib/types/request/CommonDeviceCodeRequest.d.ts.map +1 -0
- package/lib/types/request/CommonOnBehalfOfRequest.d.ts +13 -0
- package/lib/types/request/CommonOnBehalfOfRequest.d.ts.map +1 -0
- package/lib/types/request/CommonUsernamePasswordRequest.d.ts +19 -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 -3
- package/lib/types/request/OnBehalfOfRequest.d.ts.map +1 -1
- package/lib/types/request/RefreshTokenRequest.d.ts +3 -2
- package/lib/types/request/RefreshTokenRequest.d.ts.map +1 -1
- package/lib/types/request/SilentFlowRequest.d.ts +3 -2
- package/lib/types/request/SilentFlowRequest.d.ts.map +1 -1
- package/lib/types/request/UsernamePasswordRequest.d.ts +4 -3
- 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 +2 -9
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/lib/types/utils/EncodingUtils.d.ts.map +1 -1
- package/package.json +4 -6
- package/src/cache/CacheHelpers.ts +3 -5
- package/src/cache/NodeStorage.ts +19 -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/BaseClient.ts +158 -0
- package/src/client/ClientApplication.ts +50 -57
- package/src/client/ClientAssertion.ts +5 -6
- package/src/client/ClientCredentialClient.ts +32 -25
- package/src/client/ConfidentialClientApplication.ts +13 -13
- package/src/client/DeviceCodeClient.ts +33 -21
- 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 +27 -21
- package/src/client/PublicClientApplication.ts +16 -16
- package/src/client/UsernamePasswordClient.ts +14 -8
- package/src/config/Configuration.ts +19 -48
- package/src/config/ManagedIdentityRequestParameters.ts +2 -2
- package/src/crypto/CryptoProvider.ts +5 -3
- package/src/crypto/PkceGenerator.ts +6 -4
- package/src/error/ClientAuthErrorCodes.ts +12 -0
- package/src/index.ts +5 -19
- package/src/network/HttpClient.ts +168 -457
- 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 +8 -10
- package/src/request/AuthorizationCodeRequest.ts +2 -2
- package/src/request/AuthorizationUrlRequest.ts +2 -3
- package/src/request/ClientCredentialRequest.ts +3 -7
- package/src/request/CommonClientCredentialRequest.ts +29 -0
- package/src/request/CommonDeviceCodeRequest.ts +30 -0
- package/src/request/CommonOnBehalfOfRequest.ts +21 -0
- package/src/request/CommonUsernamePasswordRequest.ts +24 -0
- package/src/request/DeviceCodeRequest.ts +2 -5
- package/src/request/InteractiveRequest.ts +1 -4
- package/src/request/ManagedIdentityRequest.ts +1 -1
- package/src/request/OnBehalfOfRequest.ts +1 -3
- package/src/request/RefreshTokenRequest.ts +2 -2
- package/src/request/SilentFlowRequest.ts +3 -5
- package/src/request/UsernamePasswordRequest.ts +3 -3
- 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 +2 -11
- package/src/utils/EncodingUtils.ts +8 -4
- package/dist/utils/NetworkUtils.mjs +0 -43
- package/dist/utils/NetworkUtils.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@azure/msal-node",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-beta.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Microsoft",
|
|
7
7
|
"email": "nugetaad@microsoft.com",
|
|
@@ -59,9 +59,7 @@
|
|
|
59
59
|
"apiExtractor": "api-extractor run"
|
|
60
60
|
},
|
|
61
61
|
"beachball": {
|
|
62
|
-
"disallowedChangeTypes": [
|
|
63
|
-
"major"
|
|
64
|
-
]
|
|
62
|
+
"disallowedChangeTypes": []
|
|
65
63
|
},
|
|
66
64
|
"devDependencies": {
|
|
67
65
|
"@microsoft/api-extractor": "^7.43.4",
|
|
@@ -83,11 +81,11 @@
|
|
|
83
81
|
"yargs": "^17.3.1"
|
|
84
82
|
},
|
|
85
83
|
"dependencies": {
|
|
86
|
-
"@azure/msal-common": "
|
|
84
|
+
"@azure/msal-common": "16.0.0-beta.0",
|
|
87
85
|
"jsonwebtoken": "^9.0.0",
|
|
88
86
|
"uuid": "^8.3.0"
|
|
89
87
|
},
|
|
90
88
|
"engines": {
|
|
91
|
-
"node": ">=
|
|
89
|
+
"node": ">=20"
|
|
92
90
|
}
|
|
93
91
|
}
|
|
@@ -5,21 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
AccountInfo,
|
|
8
|
-
|
|
8
|
+
Constants,
|
|
9
9
|
CredentialEntity,
|
|
10
|
-
CredentialType,
|
|
11
10
|
} from "@azure/msal-common/node";
|
|
12
11
|
import { CACHE } from "../utils/Constants.js";
|
|
13
12
|
|
|
14
13
|
export function generateCredentialKey(credential: CredentialEntity): string {
|
|
15
14
|
const familyId =
|
|
16
|
-
(credential.credentialType === CredentialType.REFRESH_TOKEN &&
|
|
15
|
+
(credential.credentialType === Constants.CredentialType.REFRESH_TOKEN &&
|
|
17
16
|
credential.familyId) ||
|
|
18
17
|
credential.clientId;
|
|
19
18
|
const scheme =
|
|
20
19
|
credential.tokenType &&
|
|
21
20
|
credential.tokenType.toLowerCase() !==
|
|
22
|
-
AuthenticationScheme.BEARER.toLowerCase()
|
|
21
|
+
Constants.AuthenticationScheme.BEARER.toLowerCase()
|
|
23
22
|
? credential.tokenType.toLowerCase()
|
|
24
23
|
: "";
|
|
25
24
|
const credentialKey = [
|
|
@@ -29,7 +28,6 @@ export function generateCredentialKey(credential: CredentialEntity): string {
|
|
|
29
28
|
familyId,
|
|
30
29
|
credential.realm || "",
|
|
31
30
|
credential.target || "",
|
|
32
|
-
credential.requestedClaimsHash || "",
|
|
33
31
|
scheme,
|
|
34
32
|
];
|
|
35
33
|
|
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
|
|
|
@@ -249,7 +250,7 @@ export class NodeStorage extends CacheManager {
|
|
|
249
250
|
*/
|
|
250
251
|
async setAccount(account: AccountEntity): Promise<void> {
|
|
251
252
|
const accountKey = this.generateAccountKey(
|
|
252
|
-
|
|
253
|
+
AccountEntityUtils.getAccountInfo(account)
|
|
253
254
|
);
|
|
254
255
|
this.setItem(accountKey, account);
|
|
255
256
|
}
|
|
@@ -452,7 +453,7 @@ export class NodeStorage extends CacheManager {
|
|
|
452
453
|
* @param inMemory - key value map of the cache
|
|
453
454
|
*/
|
|
454
455
|
removeItem(key: string): boolean {
|
|
455
|
-
this.logger.tracePii(`Item key: ${key}
|
|
456
|
+
this.logger.tracePii(`Item key: ${key}`, "");
|
|
456
457
|
|
|
457
458
|
// read inMemoryCache
|
|
458
459
|
let result: boolean = false;
|
|
@@ -491,7 +492,7 @@ export class NodeStorage extends CacheManager {
|
|
|
491
492
|
* Gets all keys in window.
|
|
492
493
|
*/
|
|
493
494
|
getKeys(): string[] {
|
|
494
|
-
this.logger.trace("Retrieving all cache keys");
|
|
495
|
+
this.logger.trace("Retrieving all cache keys", "");
|
|
495
496
|
|
|
496
497
|
// read cache
|
|
497
498
|
const cache = this.getCache();
|
|
@@ -502,7 +503,7 @@ export class NodeStorage extends CacheManager {
|
|
|
502
503
|
* Clears all cache entries created by MSAL (except tokens).
|
|
503
504
|
*/
|
|
504
505
|
clear(): void {
|
|
505
|
-
this.logger.trace("Clearing cache entries created by MSAL");
|
|
506
|
+
this.logger.trace("Clearing cache entries created by MSAL", "");
|
|
506
507
|
|
|
507
508
|
// read inMemoryCache
|
|
508
509
|
const cacheKeys = this.getKeys();
|
|
@@ -547,12 +548,14 @@ export class NodeStorage extends CacheManager {
|
|
|
547
548
|
this.removeItem(currentCacheKey);
|
|
548
549
|
this.setItem(updatedCacheKey, cacheItem);
|
|
549
550
|
this.logger.verbose(
|
|
550
|
-
`Updated an outdated ${credential.credentialType} cache key
|
|
551
|
+
`Updated an outdated ${credential.credentialType} cache key`,
|
|
552
|
+
""
|
|
551
553
|
);
|
|
552
554
|
return updatedCacheKey;
|
|
553
555
|
} else {
|
|
554
556
|
this.logger.error(
|
|
555
|
-
`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
|
+
""
|
|
556
559
|
);
|
|
557
560
|
}
|
|
558
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
|
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ClientConfiguration,
|
|
8
|
+
buildClientConfiguration,
|
|
9
|
+
CommonClientConfiguration,
|
|
10
|
+
INetworkModule,
|
|
11
|
+
NetworkRequestOptions,
|
|
12
|
+
Logger,
|
|
13
|
+
ICrypto,
|
|
14
|
+
CacheManager,
|
|
15
|
+
ServerTelemetryManager,
|
|
16
|
+
Authority,
|
|
17
|
+
CcsCredential,
|
|
18
|
+
TokenProtocol,
|
|
19
|
+
RequestThumbprint,
|
|
20
|
+
ServerAuthorizationTokenResponse,
|
|
21
|
+
NetworkResponse,
|
|
22
|
+
BaseAuthRequest,
|
|
23
|
+
StubPerformanceClient,
|
|
24
|
+
} from "@azure/msal-common/node";
|
|
25
|
+
import { version, name } from "../packageMetadata.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export abstract class BaseClient {
|
|
32
|
+
// Logger object
|
|
33
|
+
public logger: Logger;
|
|
34
|
+
|
|
35
|
+
// Application config
|
|
36
|
+
protected config: CommonClientConfiguration;
|
|
37
|
+
|
|
38
|
+
// Crypto Interface
|
|
39
|
+
protected cryptoUtils: ICrypto;
|
|
40
|
+
|
|
41
|
+
// Storage Interface
|
|
42
|
+
protected cacheManager: CacheManager;
|
|
43
|
+
|
|
44
|
+
// Network Interface
|
|
45
|
+
protected networkClient: INetworkModule;
|
|
46
|
+
|
|
47
|
+
// Server Telemetry Manager
|
|
48
|
+
protected serverTelemetryManager: ServerTelemetryManager | null;
|
|
49
|
+
|
|
50
|
+
// Default authority object
|
|
51
|
+
public authority: Authority;
|
|
52
|
+
|
|
53
|
+
protected performanceClient: StubPerformanceClient;
|
|
54
|
+
|
|
55
|
+
protected constructor(configuration: ClientConfiguration) {
|
|
56
|
+
// Set the configuration
|
|
57
|
+
this.config = buildClientConfiguration(configuration);
|
|
58
|
+
|
|
59
|
+
// Initialize the logger
|
|
60
|
+
this.logger = new Logger(this.config.loggerOptions, name, version);
|
|
61
|
+
|
|
62
|
+
// Initialize crypto
|
|
63
|
+
this.cryptoUtils = this.config.cryptoInterface;
|
|
64
|
+
|
|
65
|
+
// Initialize storage interface
|
|
66
|
+
this.cacheManager = this.config.storageInterface;
|
|
67
|
+
|
|
68
|
+
// Set the network interface
|
|
69
|
+
this.networkClient = this.config.networkInterface;
|
|
70
|
+
|
|
71
|
+
// Set TelemetryManager
|
|
72
|
+
this.serverTelemetryManager = this.config.serverTelemetryManager;
|
|
73
|
+
|
|
74
|
+
// set Authority
|
|
75
|
+
this.authority = this.config.authOptions.authority;
|
|
76
|
+
|
|
77
|
+
this.performanceClient = new StubPerformanceClient();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates default headers for requests to token endpoint
|
|
82
|
+
*/
|
|
83
|
+
protected createTokenRequestHeaders(
|
|
84
|
+
ccsCred?: CcsCredential
|
|
85
|
+
): Record<string, string> {
|
|
86
|
+
return TokenProtocol.createTokenRequestHeaders(
|
|
87
|
+
this.logger,
|
|
88
|
+
false,
|
|
89
|
+
ccsCred
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Http post to token endpoint
|
|
95
|
+
* @param tokenEndpoint
|
|
96
|
+
* @param queryString
|
|
97
|
+
* @param headers
|
|
98
|
+
* @param thumbprint
|
|
99
|
+
*/
|
|
100
|
+
protected async executePostToTokenEndpoint(
|
|
101
|
+
tokenEndpoint: string,
|
|
102
|
+
queryString: string,
|
|
103
|
+
headers: Record<string, string>,
|
|
104
|
+
thumbprint: RequestThumbprint,
|
|
105
|
+
correlationId: string
|
|
106
|
+
): Promise<NetworkResponse<ServerAuthorizationTokenResponse>> {
|
|
107
|
+
return TokenProtocol.executePostToTokenEndpoint(
|
|
108
|
+
tokenEndpoint,
|
|
109
|
+
queryString,
|
|
110
|
+
headers,
|
|
111
|
+
thumbprint,
|
|
112
|
+
correlationId,
|
|
113
|
+
this.cacheManager,
|
|
114
|
+
this.networkClient,
|
|
115
|
+
this.logger,
|
|
116
|
+
this.performanceClient,
|
|
117
|
+
this.serverTelemetryManager
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
123
|
+
* @param thumbprint - Request thumbprint for throttling
|
|
124
|
+
* @param tokenEndpoint - Endpoint to make the POST to
|
|
125
|
+
* @param options - Body and Headers to include on the POST request
|
|
126
|
+
* @param correlationId - CorrelationId for telemetry
|
|
127
|
+
*/
|
|
128
|
+
async sendPostRequest<T extends ServerAuthorizationTokenResponse>(
|
|
129
|
+
thumbprint: RequestThumbprint,
|
|
130
|
+
tokenEndpoint: string,
|
|
131
|
+
options: NetworkRequestOptions,
|
|
132
|
+
correlationId: string
|
|
133
|
+
): Promise<NetworkResponse<T>> {
|
|
134
|
+
return TokenProtocol.sendPostRequest<T>(
|
|
135
|
+
thumbprint,
|
|
136
|
+
tokenEndpoint,
|
|
137
|
+
options,
|
|
138
|
+
correlationId,
|
|
139
|
+
this.cacheManager,
|
|
140
|
+
this.networkClient,
|
|
141
|
+
this.logger,
|
|
142
|
+
this.performanceClient
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Creates query string for the /token request
|
|
148
|
+
* @param request
|
|
149
|
+
*/
|
|
150
|
+
createTokenQueryParameters(request: BaseAuthRequest): string {
|
|
151
|
+
return TokenProtocol.createTokenQueryParameters(
|
|
152
|
+
request,
|
|
153
|
+
this.config.authOptions.clientId,
|
|
154
|
+
this.config.authOptions.redirectUri,
|
|
155
|
+
this.performanceClient
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|