@azure/msal-node 3.4.1 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache/NodeStorage.mjs +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
- package/dist/cache/serializer/Deserializer.mjs +1 -1
- package/dist/cache/serializer/Serializer.mjs +1 -1
- package/dist/client/ClientApplication.mjs +1 -1
- package/dist/client/ClientAssertion.mjs +1 -1
- package/dist/client/ClientCredentialClient.mjs +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +1 -1
- package/dist/client/DeviceCodeClient.mjs +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +1 -1
- package/dist/client/ManagedIdentityClient.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +10 -6
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +3 -1
- 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 +4 -2
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
- package/dist/client/OnBehalfOfClient.mjs +1 -1
- package/dist/client/PublicClientApplication.mjs +1 -1
- package/dist/client/UsernamePasswordClient.mjs +1 -1
- package/dist/config/Configuration.d.ts +5 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -1
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +4 -5
- package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
- package/dist/crypto/CryptoProvider.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/error/ManagedIdentityError.mjs +1 -1
- package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
- package/dist/error/NodeAuthError.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.mjs +1 -1
- package/dist/network/HttpClientWithRetries.d.ts +3 -2
- package/dist/network/HttpClientWithRetries.d.ts.map +1 -1
- package/dist/network/HttpClientWithRetries.mjs +7 -3
- package/dist/network/HttpClientWithRetries.mjs.map +1 -1
- package/dist/network/LoopbackClient.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.d.ts.map +1 -1
- package/dist/protocol/Authorize.mjs +2 -2
- package/dist/protocol/Authorize.mjs.map +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
- package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +49 -0
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs.map +1 -0
- package/dist/retry/ExponentialRetryStrategy.d.ts +23 -0
- package/dist/retry/ExponentialRetryStrategy.d.ts.map +1 -0
- package/dist/retry/ExponentialRetryStrategy.mjs +40 -0
- package/dist/retry/ExponentialRetryStrategy.mjs.map +1 -0
- package/dist/retry/IHttpRetryPolicy.d.ts +12 -2
- package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -1
- package/dist/retry/ImdsRetryPolicy.d.ts +22 -0
- package/dist/retry/ImdsRetryPolicy.d.ts.map +1 -0
- package/dist/retry/ImdsRetryPolicy.mjs +90 -0
- package/dist/retry/ImdsRetryPolicy.mjs.map +1 -0
- package/dist/retry/LinearRetryStrategy.d.ts +14 -0
- package/dist/retry/LinearRetryStrategy.d.ts.map +1 -0
- package/dist/retry/LinearRetryStrategy.mjs +36 -0
- package/dist/retry/LinearRetryStrategy.mjs.map +1 -0
- package/dist/utils/Constants.d.ts +4 -9
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +3 -13
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +269 -105
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.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/config/Configuration.d.ts +5 -0
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
- package/lib/types/network/HttpClientWithRetries.d.ts +3 -2
- package/lib/types/network/HttpClientWithRetries.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/protocol/Authorize.d.ts.map +1 -1
- package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
- package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
- package/lib/types/retry/ExponentialRetryStrategy.d.ts +23 -0
- package/lib/types/retry/ExponentialRetryStrategy.d.ts.map +1 -0
- package/lib/types/retry/IHttpRetryPolicy.d.ts +12 -2
- package/lib/types/retry/IHttpRetryPolicy.d.ts.map +1 -1
- package/lib/types/retry/ImdsRetryPolicy.d.ts +22 -0
- package/lib/types/retry/ImdsRetryPolicy.d.ts.map +1 -0
- package/lib/types/retry/LinearRetryStrategy.d.ts +14 -0
- package/lib/types/retry/LinearRetryStrategy.d.ts.map +1 -0
- package/lib/types/utils/Constants.d.ts +4 -9
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +14 -6
- package/src/client/ManagedIdentitySources/Imds.ts +3 -0
- package/src/client/ManagedIdentitySources/MachineLearning.ts +3 -1
- package/src/config/Configuration.ts +6 -0
- package/src/config/ManagedIdentityRequestParameters.ts +4 -14
- package/src/network/HttpClientWithRetries.ts +10 -1
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Authorize.ts +6 -1
- package/src/retry/DefaultManagedIdentityRetryPolicy.ts +70 -0
- package/src/retry/ExponentialRetryStrategy.ts +53 -0
- package/src/retry/IHttpRetryPolicy.ts +14 -5
- package/src/retry/ImdsRetryPolicy.ts +121 -0
- package/src/retry/LinearRetryStrategy.ts +40 -0
- package/src/utils/Constants.ts +4 -17
- package/dist/retry/LinearRetryPolicy.d.ts +0 -12
- package/dist/retry/LinearRetryPolicy.d.ts.map +0 -1
- package/dist/retry/LinearRetryPolicy.mjs +0 -45
- package/dist/retry/LinearRetryPolicy.mjs.map +0 -1
- package/lib/types/retry/LinearRetryPolicy.d.ts +0 -12
- package/lib/types/retry/LinearRetryPolicy.d.ts.map +0 -1
- package/src/retry/LinearRetryPolicy.ts +0 -71
|
@@ -3,16 +3,25 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { IncomingHttpHeaders } from "http";
|
|
7
|
+
import { Logger } from "@azure/msal-common";
|
|
7
8
|
|
|
8
9
|
export interface IHttpRetryPolicy {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
_isNewRequest?: boolean;
|
|
11
|
+
// set isNewRequest(value: boolean);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Pauses execution for a specified amount of time before retrying an HTTP request.
|
|
15
|
+
*
|
|
16
|
+
* @param httpStatusCode - The HTTP status code of the response.
|
|
17
|
+
* @param currentRetry - The current retry attempt number.
|
|
18
|
+
* @param retryAfterHeader - The value of the `retry-after` HTTP header, if present.
|
|
19
|
+
* @returns A promise that resolves to a boolean indicating whether to retry the request.
|
|
12
20
|
*/
|
|
13
21
|
pauseForRetry(
|
|
14
22
|
httpStatusCode: number,
|
|
15
23
|
currentRetry: number,
|
|
16
|
-
|
|
24
|
+
logger: Logger,
|
|
25
|
+
retryAfterHeader?: IncomingHttpHeaders["retry-after"]
|
|
17
26
|
): Promise<boolean>;
|
|
18
27
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { HttpStatus, Logger } from "@azure/msal-common";
|
|
7
|
+
import { ExponentialRetryStrategy } from "./ExponentialRetryStrategy.js";
|
|
8
|
+
import { IHttpRetryPolicy } from "./IHttpRetryPolicy.js";
|
|
9
|
+
|
|
10
|
+
const HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY: Array<number> = [
|
|
11
|
+
HttpStatus.NOT_FOUND,
|
|
12
|
+
HttpStatus.REQUEST_TIMEOUT,
|
|
13
|
+
HttpStatus.GONE,
|
|
14
|
+
HttpStatus.TOO_MANY_REQUESTS,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const EXPONENTIAL_STRATEGY_NUM_RETRIES = 3;
|
|
18
|
+
const LINEAR_STRATEGY_NUM_RETRIES = 7;
|
|
19
|
+
|
|
20
|
+
const MIN_EXPONENTIAL_BACKOFF_MS: number = 1000;
|
|
21
|
+
const MAX_EXPONENTIAL_BACKOFF_MS: number = 4000;
|
|
22
|
+
const EXPONENTIAL_DELTA_BACKOFF_MS: number = 2000;
|
|
23
|
+
|
|
24
|
+
const HTTP_STATUS_GONE_RETRY_AFTER_MS: number = 10 * 1000; // 10 seconds
|
|
25
|
+
|
|
26
|
+
export class ImdsRetryPolicy implements IHttpRetryPolicy {
|
|
27
|
+
/*
|
|
28
|
+
* these are defined here as static variables despite being defined as constants outside of the
|
|
29
|
+
* class because they need to be overridden in the unit tests so that the unit tests run faster
|
|
30
|
+
*/
|
|
31
|
+
static get MIN_EXPONENTIAL_BACKOFF_MS(): number {
|
|
32
|
+
return MIN_EXPONENTIAL_BACKOFF_MS;
|
|
33
|
+
}
|
|
34
|
+
static get MAX_EXPONENTIAL_BACKOFF_MS(): number {
|
|
35
|
+
return MAX_EXPONENTIAL_BACKOFF_MS;
|
|
36
|
+
}
|
|
37
|
+
static get EXPONENTIAL_DELTA_BACKOFF_MS(): number {
|
|
38
|
+
return EXPONENTIAL_DELTA_BACKOFF_MS;
|
|
39
|
+
}
|
|
40
|
+
static get HTTP_STATUS_GONE_RETRY_AFTER_MS(): number {
|
|
41
|
+
return HTTP_STATUS_GONE_RETRY_AFTER_MS;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public _isNewRequest: boolean;
|
|
45
|
+
set isNewRequest(value: boolean) {
|
|
46
|
+
this._isNewRequest = value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private maxRetries: number;
|
|
50
|
+
|
|
51
|
+
private exponentialRetryStrategy: ExponentialRetryStrategy =
|
|
52
|
+
new ExponentialRetryStrategy(
|
|
53
|
+
ImdsRetryPolicy.MIN_EXPONENTIAL_BACKOFF_MS,
|
|
54
|
+
ImdsRetryPolicy.MAX_EXPONENTIAL_BACKOFF_MS,
|
|
55
|
+
ImdsRetryPolicy.EXPONENTIAL_DELTA_BACKOFF_MS
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Pauses execution for a calculated delay before retrying a request.
|
|
60
|
+
*
|
|
61
|
+
* @param httpStatusCode - The HTTP status code of the response.
|
|
62
|
+
* @param currentRetry - The current retry attempt number.
|
|
63
|
+
* @param retryAfterHeader - The value of the "retry-after" header from the response.
|
|
64
|
+
* @returns A promise that resolves to a boolean indicating whether a retry should be attempted.
|
|
65
|
+
*/
|
|
66
|
+
async pauseForRetry(
|
|
67
|
+
httpStatusCode: number,
|
|
68
|
+
currentRetry: number,
|
|
69
|
+
logger: Logger
|
|
70
|
+
): Promise<boolean> {
|
|
71
|
+
if (this._isNewRequest) {
|
|
72
|
+
this._isNewRequest = false;
|
|
73
|
+
|
|
74
|
+
// calculate the maxRetries based on the status code, once per request
|
|
75
|
+
this.maxRetries =
|
|
76
|
+
httpStatusCode === HttpStatus.GONE
|
|
77
|
+
? LINEAR_STRATEGY_NUM_RETRIES
|
|
78
|
+
: EXPONENTIAL_STRATEGY_NUM_RETRIES;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* (status code is one of the retriable 400 status code
|
|
83
|
+
* or
|
|
84
|
+
* status code is >= 500 and <= 599)
|
|
85
|
+
* and
|
|
86
|
+
* current count of retries is less than the max number of retries
|
|
87
|
+
*/
|
|
88
|
+
if (
|
|
89
|
+
(HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY.includes(
|
|
90
|
+
httpStatusCode
|
|
91
|
+
) ||
|
|
92
|
+
(httpStatusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
|
|
93
|
+
httpStatusCode <= HttpStatus.SERVER_ERROR_RANGE_END &&
|
|
94
|
+
currentRetry < this.maxRetries)) &&
|
|
95
|
+
currentRetry < this.maxRetries
|
|
96
|
+
) {
|
|
97
|
+
const retryAfterDelay: number =
|
|
98
|
+
httpStatusCode === HttpStatus.GONE
|
|
99
|
+
? ImdsRetryPolicy.HTTP_STATUS_GONE_RETRY_AFTER_MS
|
|
100
|
+
: this.exponentialRetryStrategy.calculateDelay(
|
|
101
|
+
currentRetry
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
logger.verbose(
|
|
105
|
+
`Retrying request in ${retryAfterDelay}ms (retry attempt: ${
|
|
106
|
+
currentRetry + 1
|
|
107
|
+
})`
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// pause execution for the calculated delay
|
|
111
|
+
await new Promise((resolve) => {
|
|
112
|
+
return setTimeout(resolve, retryAfterDelay);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// if the status code is not retriable or max retries have been reached, do not retry
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IncomingHttpHeaders } from "http";
|
|
7
|
+
|
|
8
|
+
export class LinearRetryStrategy {
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the number of milliseconds to sleep based on the `retry-after` HTTP header.
|
|
11
|
+
*
|
|
12
|
+
* @param retryHeader - The value of the `retry-after` HTTP header. This can be either a number of seconds
|
|
13
|
+
* or an HTTP date string.
|
|
14
|
+
* @returns The number of milliseconds to sleep before retrying the request. If the `retry-after` header is not
|
|
15
|
+
* present or cannot be parsed, returns 0.
|
|
16
|
+
*/
|
|
17
|
+
public calculateDelay(
|
|
18
|
+
retryHeader: IncomingHttpHeaders["retry-after"],
|
|
19
|
+
minimumDelay: number
|
|
20
|
+
): number {
|
|
21
|
+
if (!retryHeader) {
|
|
22
|
+
return minimumDelay;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// retry-after header is in seconds
|
|
26
|
+
let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* retry-after header is in HTTP Date format
|
|
30
|
+
* <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
|
31
|
+
*/
|
|
32
|
+
if (isNaN(millisToSleep)) {
|
|
33
|
+
// .valueOf() is needed to subtract dates in TypeScript
|
|
34
|
+
millisToSleep =
|
|
35
|
+
new Date(retryHeader).valueOf() - new Date().valueOf();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return Math.max(minimumDelay, millisToSleep);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/utils/Constants.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { HttpStatus } from "@azure/msal-common/node";
|
|
7
|
-
import {
|
|
7
|
+
import { DefaultManagedIdentityRetryPolicy } from "../retry/DefaultManagedIdentityRetryPolicy.js";
|
|
8
|
+
import { ImdsRetryPolicy } from "../retry/ImdsRetryPolicy.js";
|
|
8
9
|
|
|
9
10
|
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
10
11
|
export const AUTHORIZATION_HEADER_NAME: string = "Authorization";
|
|
@@ -167,20 +168,6 @@ export const LOOPBACK_SERVER_CONSTANTS = {
|
|
|
167
168
|
TIMEOUT_MS: 5000,
|
|
168
169
|
};
|
|
169
170
|
|
|
170
|
-
export const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES = 4096; // 4 KB
|
|
171
|
+
export const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES: number = 4096; // 4 KB
|
|
171
172
|
|
|
172
|
-
export
|
|
173
|
-
export const MANAGED_IDENTITY_RETRY_DELAY = 1000;
|
|
174
|
-
export const MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
|
|
175
|
-
HttpStatus.NOT_FOUND,
|
|
176
|
-
HttpStatus.REQUEST_TIMEOUT,
|
|
177
|
-
HttpStatus.TOO_MANY_REQUESTS,
|
|
178
|
-
HttpStatus.SERVER_ERROR,
|
|
179
|
-
HttpStatus.SERVICE_UNAVAILABLE,
|
|
180
|
-
HttpStatus.GATEWAY_TIMEOUT,
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Retry Policy Types
|
|
185
|
-
*/
|
|
186
|
-
export type RetryPolicies = LinearRetryPolicy;
|
|
173
|
+
export type RetryPolicies = DefaultManagedIdentityRetryPolicy | ImdsRetryPolicy;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import http from "http";
|
|
3
|
-
import { IHttpRetryPolicy } from "./IHttpRetryPolicy.js";
|
|
4
|
-
export declare class LinearRetryPolicy implements IHttpRetryPolicy {
|
|
5
|
-
maxRetries: number;
|
|
6
|
-
retryDelay: number;
|
|
7
|
-
httpStatusCodesToRetryOn: Array<number>;
|
|
8
|
-
constructor(maxRetries: number, retryDelay: number, httpStatusCodesToRetryOn: Array<number>);
|
|
9
|
-
private retryAfterMillisecondsToSleep;
|
|
10
|
-
pauseForRetry(httpStatusCode: number, currentRetry: number, retryAfterHeader: http.IncomingHttpHeaders["retry-after"]): Promise<boolean>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=LinearRetryPolicy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LinearRetryPolicy.d.ts","sourceRoot":"","sources":["../../src/retry/LinearRetryPolicy.ts"],"names":[],"mappings":";AAKA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBAAa,iBAAkB,YAAW,gBAAgB;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAGpC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,wBAAwB,EAAE,KAAK,CAAC,MAAM,CAAC;IAO3C,OAAO,CAAC,6BAA6B;IAyB/B,aAAa,CACf,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,GAC1D,OAAO,CAAC,OAAO,CAAC;CAkBtB"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*! @azure/msal-node v3.4.1 2025-03-25 */
|
|
2
|
-
'use strict';
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
-
* Licensed under the MIT License.
|
|
6
|
-
*/
|
|
7
|
-
class LinearRetryPolicy {
|
|
8
|
-
constructor(maxRetries, retryDelay, httpStatusCodesToRetryOn) {
|
|
9
|
-
this.maxRetries = maxRetries;
|
|
10
|
-
this.retryDelay = retryDelay;
|
|
11
|
-
this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
|
|
12
|
-
}
|
|
13
|
-
retryAfterMillisecondsToSleep(retryHeader) {
|
|
14
|
-
if (!retryHeader) {
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
// retry-after header is in seconds
|
|
18
|
-
let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
|
|
19
|
-
/*
|
|
20
|
-
* retry-after header is in HTTP Date format
|
|
21
|
-
* <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
|
22
|
-
*/
|
|
23
|
-
if (isNaN(millisToSleep)) {
|
|
24
|
-
millisToSleep = Math.max(0,
|
|
25
|
-
// .valueOf() is needed to subtract dates in TypeScript
|
|
26
|
-
new Date(retryHeader).valueOf() - new Date().valueOf());
|
|
27
|
-
}
|
|
28
|
-
return millisToSleep;
|
|
29
|
-
}
|
|
30
|
-
async pauseForRetry(httpStatusCode, currentRetry, retryAfterHeader) {
|
|
31
|
-
if (this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
|
|
32
|
-
currentRetry < this.maxRetries) {
|
|
33
|
-
const retryAfterDelay = this.retryAfterMillisecondsToSleep(retryAfterHeader);
|
|
34
|
-
await new Promise((resolve) => {
|
|
35
|
-
// retryAfterHeader value of 0 evaluates to false, and this.retryDelay will be used
|
|
36
|
-
return setTimeout(resolve, retryAfterDelay || this.retryDelay);
|
|
37
|
-
});
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { LinearRetryPolicy };
|
|
45
|
-
//# sourceMappingURL=LinearRetryPolicy.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LinearRetryPolicy.mjs","sources":["../../src/retry/LinearRetryPolicy.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;MAKU,iBAAiB,CAAA;AAK1B,IAAA,WAAA,CACI,UAAkB,EAClB,UAAkB,EAClB,wBAAuC,EAAA;AAEvC,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AAC7B,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;AAC7B,QAAA,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;KAC5D;AAEO,IAAA,6BAA6B,CACjC,WAAoD,EAAA;QAEpD,IAAI,CAAC,WAAW,EAAE;AACd,YAAA,OAAO,CAAC,CAAC;AACZ,SAAA;;AAGD,QAAA,IAAI,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;AAE/D;;;AAGG;AACH,QAAA,IAAI,KAAK,CAAC,aAAa,CAAC,EAAE;AACtB,YAAA,aAAa,GAAG,IAAI,CAAC,GAAG,CACpB,CAAC;;AAED,YAAA,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CACzD,CAAC;AACL,SAAA;AAED,QAAA,OAAO,aAAa,CAAC;KACxB;AAED,IAAA,MAAM,aAAa,CACf,cAAsB,EACtB,YAAoB,EACpB,gBAAyD,EAAA;AAEzD,QAAA,IACI,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,cAAc,CAAC;AACtD,YAAA,YAAY,GAAG,IAAI,CAAC,UAAU,EAChC;YACE,MAAM,eAAe,GACjB,IAAI,CAAC,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;AAEzD,YAAA,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;;gBAE1B,OAAO,UAAU,CAAC,OAAO,EAAE,eAAe,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AACnE,aAAC,CAAC,CAAC;AAEH,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AAED,QAAA,OAAO,KAAK,CAAC;KAChB;AACJ;;;;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import http from "http";
|
|
3
|
-
import { IHttpRetryPolicy } from "./IHttpRetryPolicy.js";
|
|
4
|
-
export declare class LinearRetryPolicy implements IHttpRetryPolicy {
|
|
5
|
-
maxRetries: number;
|
|
6
|
-
retryDelay: number;
|
|
7
|
-
httpStatusCodesToRetryOn: Array<number>;
|
|
8
|
-
constructor(maxRetries: number, retryDelay: number, httpStatusCodesToRetryOn: Array<number>);
|
|
9
|
-
private retryAfterMillisecondsToSleep;
|
|
10
|
-
pauseForRetry(httpStatusCode: number, currentRetry: number, retryAfterHeader: http.IncomingHttpHeaders["retry-after"]): Promise<boolean>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=LinearRetryPolicy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LinearRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/LinearRetryPolicy.ts"],"names":[],"mappings":";AAKA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,qBAAa,iBAAkB,YAAW,gBAAgB;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAGpC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,wBAAwB,EAAE,KAAK,CAAC,MAAM,CAAC;IAO3C,OAAO,CAAC,6BAA6B;IAyB/B,aAAa,CACf,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,GAC1D,OAAO,CAAC,OAAO,CAAC;CAkBtB"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import http from "http";
|
|
7
|
-
import { IHttpRetryPolicy } from "./IHttpRetryPolicy.js";
|
|
8
|
-
|
|
9
|
-
export class LinearRetryPolicy implements IHttpRetryPolicy {
|
|
10
|
-
maxRetries: number;
|
|
11
|
-
retryDelay: number;
|
|
12
|
-
httpStatusCodesToRetryOn: Array<number>;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
maxRetries: number,
|
|
16
|
-
retryDelay: number,
|
|
17
|
-
httpStatusCodesToRetryOn: Array<number>
|
|
18
|
-
) {
|
|
19
|
-
this.maxRetries = maxRetries;
|
|
20
|
-
this.retryDelay = retryDelay;
|
|
21
|
-
this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private retryAfterMillisecondsToSleep(
|
|
25
|
-
retryHeader: http.IncomingHttpHeaders["retry-after"]
|
|
26
|
-
): number {
|
|
27
|
-
if (!retryHeader) {
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// retry-after header is in seconds
|
|
32
|
-
let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
|
|
33
|
-
|
|
34
|
-
/*
|
|
35
|
-
* retry-after header is in HTTP Date format
|
|
36
|
-
* <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
|
37
|
-
*/
|
|
38
|
-
if (isNaN(millisToSleep)) {
|
|
39
|
-
millisToSleep = Math.max(
|
|
40
|
-
0,
|
|
41
|
-
// .valueOf() is needed to subtract dates in TypeScript
|
|
42
|
-
new Date(retryHeader).valueOf() - new Date().valueOf()
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return millisToSleep;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async pauseForRetry(
|
|
50
|
-
httpStatusCode: number,
|
|
51
|
-
currentRetry: number,
|
|
52
|
-
retryAfterHeader: http.IncomingHttpHeaders["retry-after"]
|
|
53
|
-
): Promise<boolean> {
|
|
54
|
-
if (
|
|
55
|
-
this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
|
|
56
|
-
currentRetry < this.maxRetries
|
|
57
|
-
) {
|
|
58
|
-
const retryAfterDelay: number =
|
|
59
|
-
this.retryAfterMillisecondsToSleep(retryAfterHeader);
|
|
60
|
-
|
|
61
|
-
await new Promise((resolve) => {
|
|
62
|
-
// retryAfterHeader value of 0 evaluates to false, and this.retryDelay will be used
|
|
63
|
-
return setTimeout(resolve, retryAfterDelay || this.retryDelay);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
}
|