@azure/msal-node 3.7.4 → 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 +1397 -2244
- 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/index.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
14
14
|
*/
|
|
15
15
|
import * as internals from "./internals.js";
|
|
16
|
+
import { Constants as CommonConstants } from "@azure/msal-common/node";
|
|
16
17
|
export { internals };
|
|
17
18
|
|
|
18
19
|
// Interfaces
|
|
@@ -78,36 +79,29 @@ export type { InteractiveRequest } from "./request/InteractiveRequest.js";
|
|
|
78
79
|
export type { SignOutRequest } from "./request/SignOutRequest.js";
|
|
79
80
|
export type { ManagedIdentityRequestParams } from "./request/ManagedIdentityRequestParams.js";
|
|
80
81
|
|
|
82
|
+
const PromptValue = CommonConstants.PromptValue;
|
|
83
|
+
const ResponseMode = CommonConstants.ResponseMode;
|
|
84
|
+
export { PromptValue, ResponseMode };
|
|
85
|
+
|
|
81
86
|
// Common Object Formats
|
|
82
87
|
export {
|
|
83
|
-
// Request
|
|
84
|
-
PromptValue,
|
|
85
|
-
ResponseMode,
|
|
86
88
|
AuthorizationCodePayload,
|
|
87
89
|
// Response
|
|
88
90
|
AuthenticationResult,
|
|
89
91
|
AuthorizeResponse,
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated Use AuthorizeResponse instead
|
|
92
|
-
*/
|
|
93
|
-
AuthorizeResponse as ServerAuthorizationCodeResponse,
|
|
94
92
|
IdTokenClaims,
|
|
95
93
|
// Cache
|
|
96
94
|
AccountInfo,
|
|
97
95
|
ValidCacheType,
|
|
98
96
|
// Error
|
|
99
97
|
AuthError,
|
|
100
|
-
AuthErrorMessage,
|
|
101
98
|
AuthErrorCodes,
|
|
102
99
|
ClientAuthError,
|
|
103
100
|
ClientAuthErrorCodes,
|
|
104
|
-
ClientAuthErrorMessage,
|
|
105
101
|
ClientConfigurationError,
|
|
106
102
|
ClientConfigurationErrorCodes,
|
|
107
|
-
ClientConfigurationErrorMessage,
|
|
108
103
|
InteractionRequiredAuthError,
|
|
109
104
|
InteractionRequiredAuthErrorCodes,
|
|
110
|
-
InteractionRequiredAuthErrorMessage,
|
|
111
105
|
ServerError,
|
|
112
106
|
// Network Interface
|
|
113
107
|
INetworkModule,
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
+
Constants as CommonConstants,
|
|
7
8
|
INetworkModule,
|
|
8
9
|
NetworkRequestOptions,
|
|
9
10
|
NetworkResponse,
|
|
10
|
-
HttpStatus,
|
|
11
11
|
} from "@azure/msal-common/node";
|
|
12
12
|
import { HttpMethod, Constants, ProxyStatus } from "../utils/Constants.js";
|
|
13
13
|
import { NetworkUtils } from "../utils/NetworkUtils.js";
|
|
@@ -240,8 +240,10 @@ const networkRequestViaProxy = <T>(
|
|
|
240
240
|
);
|
|
241
241
|
|
|
242
242
|
if (
|
|
243
|
-
(httpStatusCode <
|
|
244
|
-
|
|
243
|
+
(httpStatusCode <
|
|
244
|
+
CommonConstants.HTTP_SUCCESS_RANGE_START ||
|
|
245
|
+
httpStatusCode >
|
|
246
|
+
CommonConstants.HTTP_SUCCESS_RANGE_END) &&
|
|
245
247
|
// do not destroy the request for the device code flow
|
|
246
248
|
networkResponse.body["error"] !==
|
|
247
249
|
Constants.AUTHORIZATION_PENDING
|
|
@@ -349,8 +351,8 @@ const networkRequestViaHttps = <T>(
|
|
|
349
351
|
);
|
|
350
352
|
|
|
351
353
|
if (
|
|
352
|
-
(statusCode <
|
|
353
|
-
statusCode >
|
|
354
|
+
(statusCode < CommonConstants.HTTP_SUCCESS_RANGE_START ||
|
|
355
|
+
statusCode > CommonConstants.HTTP_SUCCESS_RANGE_END) &&
|
|
354
356
|
// do not destroy the request for the device code flow
|
|
355
357
|
networkResponse.body["error"] !==
|
|
356
358
|
Constants.AUTHORIZATION_PENDING
|
|
@@ -397,14 +399,14 @@ const parseBody = (
|
|
|
397
399
|
let errorType;
|
|
398
400
|
let errorDescriptionHelper;
|
|
399
401
|
if (
|
|
400
|
-
statusCode >=
|
|
401
|
-
statusCode <=
|
|
402
|
+
statusCode >= CommonConstants.HTTP_CLIENT_ERROR_RANGE_START &&
|
|
403
|
+
statusCode <= CommonConstants.HTTP_CLIENT_ERROR_RANGE_END
|
|
402
404
|
) {
|
|
403
405
|
errorType = "client_error";
|
|
404
406
|
errorDescriptionHelper = "A client";
|
|
405
407
|
} else if (
|
|
406
|
-
statusCode >=
|
|
407
|
-
statusCode <=
|
|
408
|
+
statusCode >= CommonConstants.HTTP_SERVER_ERROR_RANGE_START &&
|
|
409
|
+
statusCode <= CommonConstants.HTTP_SERVER_ERROR_RANGE_END
|
|
408
410
|
) {
|
|
409
411
|
errorType = "server_error";
|
|
410
412
|
errorDescriptionHelper = "A server";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
Constants,
|
|
8
8
|
INetworkModule,
|
|
9
9
|
Logger,
|
|
10
10
|
NetworkRequestOptions,
|
|
@@ -59,7 +59,7 @@ export class HttpClientWithRetries implements INetworkModule {
|
|
|
59
59
|
response.status,
|
|
60
60
|
currentRetry,
|
|
61
61
|
this.logger,
|
|
62
|
-
response.headers[HeaderNames.RETRY_AFTER]
|
|
62
|
+
response.headers[Constants.HeaderNames.RETRY_AFTER]
|
|
63
63
|
)
|
|
64
64
|
) {
|
|
65
65
|
response = await this.sendNetworkRequestAsyncHelper(
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
Constants as CommonConstants,
|
|
8
7
|
AuthorizeResponse,
|
|
9
|
-
|
|
8
|
+
Constants as CommonConstants,
|
|
10
9
|
UrlUtils,
|
|
11
10
|
} from "@azure/msal-common/node";
|
|
12
11
|
import http from "http";
|
|
@@ -58,7 +57,7 @@ export class LoopbackClient implements ILoopbackClient {
|
|
|
58
57
|
UrlUtils.getDeserializedResponse(parsedUrl.search) ||
|
|
59
58
|
{};
|
|
60
59
|
if (authCodeResponse.code) {
|
|
61
|
-
res.writeHead(
|
|
60
|
+
res.writeHead(CommonConstants.HTTP_REDIRECT, {
|
|
62
61
|
location: redirectUri,
|
|
63
62
|
}); // Prevent auth code from being saved in the browser history
|
|
64
63
|
res.end();
|
package/src/packageMetadata.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
AuthorizeProtocol,
|
|
9
9
|
CommonAuthorizationUrlRequest,
|
|
10
10
|
Logger,
|
|
11
|
-
|
|
11
|
+
Constants,
|
|
12
12
|
ProtocolMode,
|
|
13
13
|
RequestParameterBuilder,
|
|
14
14
|
} from "@azure/msal-common/node";
|
|
@@ -45,13 +45,16 @@ export function getAuthCodeRequestUrl(
|
|
|
45
45
|
cpu: process.arch || "",
|
|
46
46
|
os: process.platform || "",
|
|
47
47
|
});
|
|
48
|
-
if (config.
|
|
48
|
+
if (config.system.protocolMode !== ProtocolMode.OIDC) {
|
|
49
49
|
RequestParameterBuilder.addApplicationTelemetry(
|
|
50
50
|
parameters,
|
|
51
51
|
config.telemetry.application
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
RequestParameterBuilder.addResponseType(
|
|
54
|
+
RequestParameterBuilder.addResponseType(
|
|
55
|
+
parameters,
|
|
56
|
+
Constants.OAuthResponseType.CODE
|
|
57
|
+
);
|
|
55
58
|
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
56
59
|
RequestParameterBuilder.addCodeChallengeParams(
|
|
57
60
|
parameters,
|
|
@@ -65,10 +68,5 @@ export function getAuthCodeRequestUrl(
|
|
|
65
68
|
request.extraQueryParameters || {}
|
|
66
69
|
);
|
|
67
70
|
|
|
68
|
-
return AuthorizeProtocol.getAuthorizeUrl(
|
|
69
|
-
authority,
|
|
70
|
-
parameters,
|
|
71
|
-
config.auth.encodeExtraQueryParams,
|
|
72
|
-
request.extraQueryParameters
|
|
73
|
-
);
|
|
71
|
+
return AuthorizeProtocol.getAuthorizeUrl(authority, parameters);
|
|
74
72
|
}
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
CommonClientCredentialRequest,
|
|
9
|
-
} from "@azure/msal-common/node";
|
|
6
|
+
import { ClientAssertionCallback } from "@azure/msal-common/node";
|
|
7
|
+
import { CommonClientCredentialRequest } from "./CommonClientCredentialRequest.js";
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* ClientCredentialRequest
|
|
13
11
|
* - scopes - Array of scopes the application is requesting access to. Typically contains only the .default scope for a single resource. See: https://learn.microsoft.com/azure/active-directory/develop/scopes-oidc#the-default-scope
|
|
14
12
|
* - authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
|
|
15
13
|
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
@@ -23,7 +21,6 @@ export type ClientCredentialRequest = Partial<
|
|
|
23
21
|
CommonClientCredentialRequest,
|
|
24
22
|
| "resourceRequestMethod"
|
|
25
23
|
| "resourceRequestUri"
|
|
26
|
-
| "requestedClaimsHash"
|
|
27
24
|
| "clientAssertion"
|
|
28
25
|
| "storeInCache"
|
|
29
26
|
>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
BaseAuthRequest,
|
|
8
|
+
AzureRegion,
|
|
9
|
+
ClientAssertion,
|
|
10
|
+
} from "@azure/msal-common/node";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* CommonClientCredentialRequest
|
|
14
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
15
|
+
* - authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
|
|
16
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
17
|
+
* - skipCache - Skip token cache lookup and force request to authority to get a a new token. Defaults to false.
|
|
18
|
+
* - preferredAzureRegionOptions - Options of the user's preferred azure region
|
|
19
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
20
|
+
*/
|
|
21
|
+
export type CommonClientCredentialRequest = BaseAuthRequest & {
|
|
22
|
+
skipCache?: boolean;
|
|
23
|
+
azureRegion?: AzureRegion;
|
|
24
|
+
clientAssertion?: ClientAssertion;
|
|
25
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DeviceCodeResponse,
|
|
8
|
+
StringDict,
|
|
9
|
+
BaseAuthRequest,
|
|
10
|
+
} from "@azure/msal-common/node";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parameters for Oauth2 device code flow.
|
|
14
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
15
|
+
* - authority: - URL of the authority, the security token service (STS) from which MSAL will acquire tokens. If authority is set on client application object, this will override that value. Overriding the value will cause for authority validation to happen each time. If the same authority will be used for all request, set on the application object instead of the requests.
|
|
16
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
17
|
+
* - deviceCodeCallback - Callback containing device code response. Message should be shown to end user. End user can then navigate to the verification_uri, input the user_code, and input credentials.
|
|
18
|
+
* - cancel - Boolean to cancel polling of device code endpoint. While the user authenticates on a separate device, MSAL polls the the token endpoint of security token service for the interval specified in the device code response (usually 15 minutes). To stop polling and cancel the request, set cancel=true.
|
|
19
|
+
* - resourceRequestMethod - HTTP Request type used to request data from the resource (i.e. "GET", "POST", etc.). Used for proof-of-possession flows.
|
|
20
|
+
* - resourceRequestUri - URI that token will be used for. Used for proof-of-possession flows.
|
|
21
|
+
* - timeout - Timeout period in seconds which the user explicitly configures for the polling of the device code endpoint. At the end of this period; assuming the device code has not expired yet; the device code polling is stopped and the request cancelled. The device code expiration window will always take precedence over this set period.
|
|
22
|
+
* - extraQueryParameters - String to string map of custom query parameters added to the query string
|
|
23
|
+
*/
|
|
24
|
+
// export type CommonDeviceCodeRequest = BaseAuthRequest & {
|
|
25
|
+
export type CommonDeviceCodeRequest = Omit<
|
|
26
|
+
BaseAuthRequest,
|
|
27
|
+
"tokenQueryParameters" | "tokenBodyParameters"
|
|
28
|
+
> & {
|
|
29
|
+
deviceCodeCallback: (response: DeviceCodeResponse) => void;
|
|
30
|
+
cancel?: boolean;
|
|
31
|
+
timeout?: number;
|
|
32
|
+
extraQueryParameters?: StringDict;
|
|
33
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseAuthRequest } from "@azure/msal-common/node";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
10
|
+
* - authority - URL of the authority, the security token service (STS) from which MSAL will acquire tokens.
|
|
11
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
12
|
+
* - oboAssertion - The access token that was sent to the middle-tier API. This token must have an audience of the app making this OBO request.
|
|
13
|
+
* - skipCache - Skip token cache lookup and force request to authority to get a a new token. Defaults to false.
|
|
14
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
15
|
+
*/
|
|
16
|
+
export type CommonOnBehalfOfRequest = BaseAuthRequest & {
|
|
17
|
+
oboAssertion: string;
|
|
18
|
+
skipCache?: boolean;
|
|
19
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BaseAuthRequest } from "@azure/msal-common/node";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* CommonUsernamePassword parameters passed by the user to retrieve credentials
|
|
10
|
+
* Note: The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely. This flow is added for internal testing.
|
|
11
|
+
*
|
|
12
|
+
* - scopes - Array of scopes the application is requesting access to.
|
|
13
|
+
* - claims - A stringified claims request which will be added to all /authorize and /token calls. When included on a silent request, cache lookup will be skipped and token will be refreshed.
|
|
14
|
+
* - authority - Url of the authority which the application acquires tokens from.
|
|
15
|
+
* - correlationId - Unique GUID set per request to trace a request end-to-end for telemetry purposes.
|
|
16
|
+
* - username - username of the client
|
|
17
|
+
* - password - credentials
|
|
18
|
+
* - tokenQueryParameters - String to string map of custom query parameters added to the /token call
|
|
19
|
+
*/
|
|
20
|
+
export type CommonUsernamePasswordRequest = BaseAuthRequest & {
|
|
21
|
+
username: string;
|
|
22
|
+
password: string;
|
|
23
|
+
};
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
DeviceCodeResponse,
|
|
9
|
-
} from "@azure/msal-common/node";
|
|
6
|
+
import { DeviceCodeResponse } from "@azure/msal-common/node";
|
|
7
|
+
import { CommonDeviceCodeRequest } from "./CommonDeviceCodeRequest.js";
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Parameters for Oauth2 device code flow.
|
|
@@ -25,7 +23,6 @@ export type DeviceCodeRequest = Partial<
|
|
|
25
23
|
| "deviceCodeCallback"
|
|
26
24
|
| "resourceRequestMethod"
|
|
27
25
|
| "resourceRequestUri"
|
|
28
|
-
| "requestedClaimsHash"
|
|
29
26
|
| "storeInCache"
|
|
30
27
|
>
|
|
31
28
|
> & {
|
|
@@ -20,7 +20,7 @@ import { ILoopbackClient } from "../network/ILoopbackClient.js";
|
|
|
20
20
|
export type InteractiveRequest = Partial<
|
|
21
21
|
Omit<
|
|
22
22
|
CommonAuthorizationUrlRequest,
|
|
23
|
-
"scopes" | "
|
|
23
|
+
"scopes" | "redirectUri" | "storeInCache"
|
|
24
24
|
>
|
|
25
25
|
> & {
|
|
26
26
|
openBrowser: (url: string) => Promise<void>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { CommonClientCredentialRequest } from "
|
|
6
|
+
import { CommonClientCredentialRequest } from "./CommonClientCredentialRequest.js";
|
|
7
7
|
import { ManagedIdentityRequestParams } from "./ManagedIdentityRequestParams.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { CommonOnBehalfOfRequest } from "
|
|
6
|
+
import { CommonOnBehalfOfRequest } from "./CommonOnBehalfOfRequest.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* - scopes - Array of scopes the application is requesting access to.
|
|
@@ -21,7 +21,6 @@ export type OnBehalfOfRequest = Partial<
|
|
|
21
21
|
| "scopes"
|
|
22
22
|
| "resourceRequestMethod"
|
|
23
23
|
| "resourceRequestUri"
|
|
24
|
-
| "requestedClaimsHash"
|
|
25
24
|
| "storeInCache"
|
|
26
25
|
>
|
|
27
26
|
> & {
|
|
@@ -17,10 +17,7 @@ import { AccountInfo, CommonSilentFlowRequest } from "@azure/msal-common/node";
|
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
export type SilentFlowRequest = Partial<
|
|
20
|
-
Omit<
|
|
21
|
-
CommonSilentFlowRequest,
|
|
22
|
-
"account" | "scopes" | "requestedClaimsHash" | "storeInCache"
|
|
23
|
-
>
|
|
20
|
+
Omit<CommonSilentFlowRequest, "account" | "scopes" | "storeInCache">
|
|
24
21
|
> & {
|
|
25
22
|
account: AccountInfo;
|
|
26
23
|
scopes: Array<string>;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { CommonUsernamePasswordRequest } from "
|
|
6
|
+
import { CommonUsernamePasswordRequest } from "./CommonUsernamePasswordRequest.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* UsernamePassword parameters passed by the user to retrieve credentials
|
|
@@ -26,7 +26,6 @@ export type UsernamePasswordRequest = Partial<
|
|
|
26
26
|
| "resourceRequestUri"
|
|
27
27
|
| "username"
|
|
28
28
|
| "password"
|
|
29
|
-
| "requestedClaimsHash"
|
|
30
29
|
| "storeInCache"
|
|
31
30
|
>
|
|
32
31
|
> & {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { Constants } from "@azure/msal-common/node";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Deserialized response object from server managed identity request.
|
|
@@ -25,7 +25,7 @@ export type ManagedIdentityTokenResponse = {
|
|
|
25
25
|
client_id?: string;
|
|
26
26
|
expires_on?: number; // will be converted to expires_in
|
|
27
27
|
resource?: string; // equivalent to ServerAuthorizationTokenResponse's "scope" field
|
|
28
|
-
token_type?: AuthenticationScheme;
|
|
28
|
+
token_type?: Constants.AuthenticationScheme;
|
|
29
29
|
|
|
30
30
|
// error
|
|
31
31
|
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IncomingHttpHeaders } from "http";
|
|
7
|
-
import {
|
|
7
|
+
import { Constants, Logger } from "@azure/msal-common/node";
|
|
8
8
|
import { IHttpRetryPolicy } from "./IHttpRetryPolicy.js";
|
|
9
9
|
import { LinearRetryStrategy } from "./LinearRetryStrategy.js";
|
|
10
10
|
|
|
11
11
|
export const DEFAULT_MANAGED_IDENTITY_MAX_RETRIES: number = 3; // referenced in unit test
|
|
12
12
|
const DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS: number = 1000;
|
|
13
13
|
const DEFAULT_MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON: Array<number> = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
Constants.HTTP_NOT_FOUND,
|
|
15
|
+
Constants.HTTP_REQUEST_TIMEOUT,
|
|
16
|
+
Constants.HTTP_TOO_MANY_REQUESTS,
|
|
17
|
+
Constants.HTTP_SERVER_ERROR,
|
|
18
|
+
Constants.HTTP_SERVICE_UNAVAILABLE,
|
|
19
|
+
Constants.HTTP_GATEWAY_TIMEOUT,
|
|
20
20
|
];
|
|
21
21
|
|
|
22
22
|
export class DefaultManagedIdentityRetryPolicy implements IHttpRetryPolicy {
|
|
@@ -52,7 +52,8 @@ export class DefaultManagedIdentityRetryPolicy implements IHttpRetryPolicy {
|
|
|
52
52
|
logger.verbose(
|
|
53
53
|
`Retrying request in ${retryAfterDelay}ms (retry attempt: ${
|
|
54
54
|
currentRetry + 1
|
|
55
|
-
})
|
|
55
|
+
})`,
|
|
56
|
+
""
|
|
56
57
|
);
|
|
57
58
|
|
|
58
59
|
// pause execution for the calculated delay
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { Constants, Logger } from "@azure/msal-common/node";
|
|
7
7
|
import { ExponentialRetryStrategy } from "./ExponentialRetryStrategy.js";
|
|
8
8
|
import { IHttpRetryPolicy } from "./IHttpRetryPolicy.js";
|
|
9
9
|
|
|
10
10
|
const HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY: Array<number> = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
Constants.HTTP_NOT_FOUND,
|
|
12
|
+
Constants.HTTP_REQUEST_TIMEOUT,
|
|
13
|
+
Constants.HTTP_GONE,
|
|
14
|
+
Constants.HTTP_TOO_MANY_REQUESTS,
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
const EXPONENTIAL_STRATEGY_NUM_RETRIES = 3;
|
|
@@ -73,7 +73,7 @@ export class ImdsRetryPolicy implements IHttpRetryPolicy {
|
|
|
73
73
|
|
|
74
74
|
// calculate the maxRetries based on the status code, once per request
|
|
75
75
|
this.maxRetries =
|
|
76
|
-
httpStatusCode ===
|
|
76
|
+
httpStatusCode === Constants.HTTP_GONE
|
|
77
77
|
? LINEAR_STRATEGY_NUM_RETRIES
|
|
78
78
|
: EXPONENTIAL_STRATEGY_NUM_RETRIES;
|
|
79
79
|
}
|
|
@@ -89,13 +89,13 @@ export class ImdsRetryPolicy implements IHttpRetryPolicy {
|
|
|
89
89
|
(HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY.includes(
|
|
90
90
|
httpStatusCode
|
|
91
91
|
) ||
|
|
92
|
-
(httpStatusCode >=
|
|
93
|
-
httpStatusCode <=
|
|
92
|
+
(httpStatusCode >= Constants.HTTP_SERVER_ERROR_RANGE_START &&
|
|
93
|
+
httpStatusCode <= Constants.HTTP_SERVER_ERROR_RANGE_END &&
|
|
94
94
|
currentRetry < this.maxRetries)) &&
|
|
95
95
|
currentRetry < this.maxRetries
|
|
96
96
|
) {
|
|
97
97
|
const retryAfterDelay: number =
|
|
98
|
-
httpStatusCode ===
|
|
98
|
+
httpStatusCode === Constants.HTTP_GONE
|
|
99
99
|
? ImdsRetryPolicy.HTTP_STATUS_GONE_RETRY_AFTER_MS
|
|
100
100
|
: this.exponentialRetryStrategy.calculateDelay(
|
|
101
101
|
currentRetry
|
|
@@ -104,7 +104,8 @@ export class ImdsRetryPolicy implements IHttpRetryPolicy {
|
|
|
104
104
|
logger.verbose(
|
|
105
105
|
`Retrying request in ${retryAfterDelay}ms (retry attempt: ${
|
|
106
106
|
currentRetry + 1
|
|
107
|
-
})
|
|
107
|
+
})`,
|
|
108
|
+
""
|
|
108
109
|
);
|
|
109
110
|
|
|
110
111
|
// pause execution for the calculated delay
|
package/src/utils/Constants.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { Constants as CommonConstants } from "@azure/msal-common/node";
|
|
7
7
|
import { DefaultManagedIdentityRetryPolicy } from "../retry/DefaultManagedIdentityRetryPolicy.js";
|
|
8
8
|
import { ImdsRetryPolicy } from "../retry/ImdsRetryPolicy.js";
|
|
9
9
|
|
|
@@ -94,10 +94,10 @@ export const HttpMethod = {
|
|
|
94
94
|
export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod];
|
|
95
95
|
|
|
96
96
|
export const ProxyStatus = {
|
|
97
|
-
SUCCESS:
|
|
98
|
-
SUCCESS_RANGE_START:
|
|
99
|
-
SUCCESS_RANGE_END:
|
|
100
|
-
SERVER_ERROR:
|
|
97
|
+
SUCCESS: CommonConstants.HTTP_SUCCESS,
|
|
98
|
+
SUCCESS_RANGE_START: CommonConstants.HTTP_SUCCESS_RANGE_START,
|
|
99
|
+
SUCCESS_RANGE_END: CommonConstants.HTTP_SUCCESS_RANGE_END,
|
|
100
|
+
SERVER_ERROR: CommonConstants.HTTP_SERVER_ERROR,
|
|
101
101
|
} as const;
|
|
102
102
|
export type ProxyStatus = (typeof ProxyStatus)[keyof typeof ProxyStatus];
|
|
103
103
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Constants
|
|
6
|
+
import { Constants } from "@azure/msal-common/node";
|
|
7
7
|
|
|
8
8
|
export class EncodingUtils {
|
|
9
9
|
/**
|
|
@@ -13,7 +13,9 @@ export class EncodingUtils {
|
|
|
13
13
|
* @param str text
|
|
14
14
|
*/
|
|
15
15
|
static base64Encode(str: string, encoding?: BufferEncoding): string {
|
|
16
|
-
return Buffer.from(str, encoding).toString(
|
|
16
|
+
return Buffer.from(str, encoding).toString(
|
|
17
|
+
Constants.EncodingTypes.BASE64
|
|
18
|
+
);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -22,7 +24,7 @@ export class EncodingUtils {
|
|
|
22
24
|
*/
|
|
23
25
|
static base64EncodeUrl(str: string, encoding?: BufferEncoding): string {
|
|
24
26
|
return EncodingUtils.base64Encode(str, encoding)
|
|
25
|
-
.replace(/=/g,
|
|
27
|
+
.replace(/=/g, "")
|
|
26
28
|
.replace(/\+/g, "-")
|
|
27
29
|
.replace(/\//g, "_");
|
|
28
30
|
}
|
|
@@ -34,7 +36,9 @@ export class EncodingUtils {
|
|
|
34
36
|
* @param base64Str Base64 encoded text
|
|
35
37
|
*/
|
|
36
38
|
static base64Decode(base64Str: string): string {
|
|
37
|
-
return Buffer.from(base64Str, EncodingTypes.BASE64).toString(
|
|
39
|
+
return Buffer.from(base64Str, Constants.EncodingTypes.BASE64).toString(
|
|
40
|
+
"utf8"
|
|
41
|
+
);
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
/**
|