@azure/msal-node 2.6.5-alpha.0 → 2.6.6

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.
Files changed (193) hide show
  1. package/dist/cache/NodeStorage.cjs +1 -1
  2. package/dist/cache/NodeStorage.mjs +1 -1
  3. package/dist/cache/TokenCache.cjs +1 -1
  4. package/dist/cache/TokenCache.mjs +1 -1
  5. package/dist/cache/distributed/DistributedCachePlugin.cjs +1 -1
  6. package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
  7. package/dist/cache/serializer/Deserializer.cjs +1 -1
  8. package/dist/cache/serializer/Deserializer.mjs +1 -1
  9. package/dist/cache/serializer/Serializer.cjs +1 -1
  10. package/dist/cache/serializer/Serializer.mjs +1 -1
  11. package/dist/client/ClientApplication.cjs +1 -1
  12. package/dist/client/ClientApplication.mjs +1 -1
  13. package/dist/client/ClientAssertion.cjs +1 -1
  14. package/dist/client/ClientAssertion.mjs +1 -1
  15. package/dist/client/ClientCredentialClient.cjs +23 -27
  16. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  17. package/dist/client/ClientCredentialClient.d.ts +3 -3
  18. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  19. package/dist/client/ClientCredentialClient.mjs +24 -28
  20. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  21. package/dist/client/ConfidentialClientApplication.cjs +1 -1
  22. package/dist/client/ConfidentialClientApplication.mjs +1 -1
  23. package/dist/client/DeviceCodeClient.cjs +1 -1
  24. package/dist/client/DeviceCodeClient.mjs +1 -1
  25. package/dist/client/OnBehalfOfClient.cjs +1 -1
  26. package/dist/client/OnBehalfOfClient.mjs +1 -1
  27. package/dist/client/PublicClientApplication.cjs +1 -1
  28. package/dist/client/PublicClientApplication.mjs +1 -1
  29. package/dist/client/UsernamePasswordClient.cjs +1 -1
  30. package/dist/client/UsernamePasswordClient.mjs +1 -1
  31. package/dist/config/Configuration.cjs +2 -36
  32. package/dist/config/Configuration.cjs.map +1 -1
  33. package/dist/config/Configuration.d.ts +0 -16
  34. package/dist/config/Configuration.d.ts.map +1 -1
  35. package/dist/config/Configuration.mjs +3 -36
  36. package/dist/config/Configuration.mjs.map +1 -1
  37. package/dist/crypto/CryptoProvider.cjs +1 -1
  38. package/dist/crypto/CryptoProvider.mjs +1 -1
  39. package/dist/crypto/GuidGenerator.cjs +1 -1
  40. package/dist/crypto/GuidGenerator.mjs +1 -1
  41. package/dist/crypto/HashUtils.cjs +1 -1
  42. package/dist/crypto/HashUtils.mjs +1 -1
  43. package/dist/crypto/PkceGenerator.cjs +1 -1
  44. package/dist/crypto/PkceGenerator.mjs +1 -1
  45. package/dist/error/NodeAuthError.cjs +1 -1
  46. package/dist/error/NodeAuthError.mjs +1 -1
  47. package/dist/index.cjs +1 -3
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.ts +1 -3
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.mjs +1 -2
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/internals.cjs +1 -1
  54. package/dist/internals.mjs +1 -1
  55. package/dist/network/HttpClient.cjs +6 -13
  56. package/dist/network/HttpClient.cjs.map +1 -1
  57. package/dist/network/HttpClient.d.ts +1 -2
  58. package/dist/network/HttpClient.d.ts.map +1 -1
  59. package/dist/network/HttpClient.mjs +6 -13
  60. package/dist/network/HttpClient.mjs.map +1 -1
  61. package/dist/network/LoopbackClient.cjs +1 -1
  62. package/dist/network/LoopbackClient.mjs +1 -1
  63. package/dist/packageMetadata.cjs +2 -2
  64. package/dist/packageMetadata.d.ts +1 -1
  65. package/dist/packageMetadata.d.ts.map +1 -1
  66. package/dist/packageMetadata.mjs +2 -2
  67. package/dist/utils/Constants.cjs +1 -68
  68. package/dist/utils/Constants.cjs.map +1 -1
  69. package/dist/utils/Constants.d.ts +0 -45
  70. package/dist/utils/Constants.d.ts.map +1 -1
  71. package/dist/utils/Constants.mjs +2 -54
  72. package/dist/utils/Constants.mjs.map +1 -1
  73. package/dist/utils/EncodingUtils.cjs +1 -1
  74. package/dist/utils/EncodingUtils.mjs +1 -1
  75. package/dist/utils/NetworkUtils.cjs +1 -1
  76. package/dist/utils/NetworkUtils.mjs +1 -1
  77. package/package.json +2 -2
  78. package/src/client/ClientCredentialClient.ts +25 -65
  79. package/src/config/Configuration.ts +1 -81
  80. package/src/index.ts +0 -4
  81. package/src/network/HttpClient.ts +5 -17
  82. package/src/packageMetadata.ts +1 -1
  83. package/src/utils/Constants.ts +0 -63
  84. package/dist/client/ManagedIdentityApplication.cjs +0 -97
  85. package/dist/client/ManagedIdentityApplication.cjs.map +0 -1
  86. package/dist/client/ManagedIdentityApplication.d.ts +0 -24
  87. package/dist/client/ManagedIdentityApplication.d.ts.map +0 -1
  88. package/dist/client/ManagedIdentityApplication.mjs +0 -95
  89. package/dist/client/ManagedIdentityApplication.mjs.map +0 -1
  90. package/dist/client/ManagedIdentityClient.cjs +0 -53
  91. package/dist/client/ManagedIdentityClient.cjs.map +0 -1
  92. package/dist/client/ManagedIdentityClient.d.ts +0 -25
  93. package/dist/client/ManagedIdentityClient.d.ts.map +0 -1
  94. package/dist/client/ManagedIdentityClient.mjs +0 -51
  95. package/dist/client/ManagedIdentityClient.mjs.map +0 -1
  96. package/dist/client/ManagedIdentitySources/AppService.cjs +0 -52
  97. package/dist/client/ManagedIdentitySources/AppService.cjs.map +0 -1
  98. package/dist/client/ManagedIdentitySources/AppService.d.ts +0 -17
  99. package/dist/client/ManagedIdentitySources/AppService.d.ts.map +0 -1
  100. package/dist/client/ManagedIdentitySources/AppService.mjs +0 -50
  101. package/dist/client/ManagedIdentitySources/AppService.mjs.map +0 -1
  102. package/dist/client/ManagedIdentitySources/AzureArc.cjs +0 -96
  103. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +0 -1
  104. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +0 -19
  105. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +0 -1
  106. package/dist/client/ManagedIdentitySources/AzureArc.mjs +0 -93
  107. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +0 -1
  108. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +0 -122
  109. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +0 -1
  110. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +0 -31
  111. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +0 -1
  112. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +0 -119
  113. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +0 -1
  114. package/dist/client/ManagedIdentitySources/CloudShell.cjs +0 -47
  115. package/dist/client/ManagedIdentitySources/CloudShell.cjs.map +0 -1
  116. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +0 -16
  117. package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +0 -1
  118. package/dist/client/ManagedIdentitySources/CloudShell.mjs +0 -45
  119. package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +0 -1
  120. package/dist/client/ManagedIdentitySources/Imds.cjs +0 -54
  121. package/dist/client/ManagedIdentitySources/Imds.cjs.map +0 -1
  122. package/dist/client/ManagedIdentitySources/Imds.d.ts +0 -13
  123. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +0 -1
  124. package/dist/client/ManagedIdentitySources/Imds.mjs +0 -52
  125. package/dist/client/ManagedIdentitySources/Imds.mjs.map +0 -1
  126. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +0 -61
  127. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs.map +0 -1
  128. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +0 -17
  129. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +0 -1
  130. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +0 -59
  131. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +0 -1
  132. package/dist/config/ManagedIdentityId.cjs +0 -59
  133. package/dist/config/ManagedIdentityId.cjs.map +0 -1
  134. package/dist/config/ManagedIdentityId.d.ts +0 -12
  135. package/dist/config/ManagedIdentityId.d.ts.map +0 -1
  136. package/dist/config/ManagedIdentityId.mjs +0 -57
  137. package/dist/config/ManagedIdentityId.mjs.map +0 -1
  138. package/dist/config/ManagedIdentityRequestParameters.cjs +0 -37
  139. package/dist/config/ManagedIdentityRequestParameters.cjs.map +0 -1
  140. package/dist/config/ManagedIdentityRequestParameters.d.ts +0 -12
  141. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +0 -1
  142. package/dist/config/ManagedIdentityRequestParameters.mjs +0 -35
  143. package/dist/config/ManagedIdentityRequestParameters.mjs.map +0 -1
  144. package/dist/error/ManagedIdentityError.cjs +0 -51
  145. package/dist/error/ManagedIdentityError.cjs.map +0 -1
  146. package/dist/error/ManagedIdentityError.d.ts +0 -28
  147. package/dist/error/ManagedIdentityError.d.ts.map +0 -1
  148. package/dist/error/ManagedIdentityError.mjs +0 -47
  149. package/dist/error/ManagedIdentityError.mjs.map +0 -1
  150. package/dist/error/ManagedIdentityErrorCodes.cjs +0 -41
  151. package/dist/error/ManagedIdentityErrorCodes.cjs.map +0 -1
  152. package/dist/error/ManagedIdentityErrorCodes.d.ts +0 -20
  153. package/dist/error/ManagedIdentityErrorCodes.d.ts.map +0 -1
  154. package/dist/error/ManagedIdentityErrorCodes.mjs +0 -28
  155. package/dist/error/ManagedIdentityErrorCodes.mjs.map +0 -1
  156. package/dist/network/HttpClientWithRetries.cjs +0 -44
  157. package/dist/network/HttpClientWithRetries.cjs.map +0 -1
  158. package/dist/network/HttpClientWithRetries.d.ts +0 -12
  159. package/dist/network/HttpClientWithRetries.d.ts.map +0 -1
  160. package/dist/network/HttpClientWithRetries.mjs +0 -42
  161. package/dist/network/HttpClientWithRetries.mjs.map +0 -1
  162. package/dist/request/ManagedIdentityRequest.d.ts +0 -9
  163. package/dist/request/ManagedIdentityRequest.d.ts.map +0 -1
  164. package/dist/request/ManagedIdentityRequestParams.d.ts +0 -10
  165. package/dist/request/ManagedIdentityRequestParams.d.ts.map +0 -1
  166. package/dist/response/ManagedIdentityTokenResponse.d.ts +0 -25
  167. package/dist/response/ManagedIdentityTokenResponse.d.ts.map +0 -1
  168. package/dist/retry/IHttpRetryPolicy.d.ts +0 -6
  169. package/dist/retry/IHttpRetryPolicy.d.ts.map +0 -1
  170. package/dist/retry/LinearRetryPolicy.cjs +0 -47
  171. package/dist/retry/LinearRetryPolicy.cjs.map +0 -1
  172. package/dist/retry/LinearRetryPolicy.d.ts +0 -12
  173. package/dist/retry/LinearRetryPolicy.d.ts.map +0 -1
  174. package/dist/retry/LinearRetryPolicy.mjs +0 -45
  175. package/dist/retry/LinearRetryPolicy.mjs.map +0 -1
  176. package/src/client/ManagedIdentityApplication.ts +0 -194
  177. package/src/client/ManagedIdentityClient.ts +0 -128
  178. package/src/client/ManagedIdentitySources/AppService.ts +0 -122
  179. package/src/client/ManagedIdentitySources/AzureArc.ts +0 -199
  180. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +0 -237
  181. package/src/client/ManagedIdentitySources/CloudShell.ts +0 -104
  182. package/src/client/ManagedIdentitySources/Imds.ts +0 -126
  183. package/src/client/ManagedIdentitySources/ServiceFabric.ts +0 -140
  184. package/src/config/ManagedIdentityId.ts +0 -73
  185. package/src/config/ManagedIdentityRequestParameters.ts +0 -48
  186. package/src/error/ManagedIdentityError.ts +0 -59
  187. package/src/error/ManagedIdentityErrorCodes.ts +0 -34
  188. package/src/network/HttpClientWithRetries.ts +0 -80
  189. package/src/request/ManagedIdentityRequest.ts +0 -15
  190. package/src/request/ManagedIdentityRequestParams.ts +0 -14
  191. package/src/response/ManagedIdentityTokenResponse.ts +0 -33
  192. package/src/retry/IHttpRetryPolicy.ts +0 -18
  193. package/src/retry/LinearRetryPolicy.ts +0 -71
@@ -1,48 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { RequestParameterBuilder, UrlString } from "@azure/msal-common";
7
- import { HttpMethod } from "../utils/Constants";
8
-
9
- export class ManagedIdentityRequestParameters {
10
- private _baseEndpoint: string;
11
- public httpMethod: HttpMethod;
12
- public headers: Record<string, string>;
13
- public bodyParameters: Record<string, string>;
14
- public queryParameters: Record<string, string>;
15
-
16
- constructor(httpMethod: HttpMethod, endpoint: string) {
17
- this.httpMethod = httpMethod;
18
- this._baseEndpoint = endpoint;
19
- this.headers = {} as Record<string, string>;
20
- this.bodyParameters = {} as Record<string, string>;
21
- this.queryParameters = {} as Record<string, string>;
22
- }
23
-
24
- public computeUri(): string {
25
- const parameterBuilder = new RequestParameterBuilder();
26
-
27
- if (this.queryParameters) {
28
- parameterBuilder.addExtraQueryParameters(this.queryParameters);
29
- }
30
-
31
- const queryParametersString = parameterBuilder.createQueryString();
32
-
33
- return UrlString.appendQueryString(
34
- this._baseEndpoint,
35
- queryParametersString
36
- );
37
- }
38
-
39
- public computeParametersBodyString(): string {
40
- const parameterBuilder = new RequestParameterBuilder();
41
-
42
- if (this.bodyParameters) {
43
- parameterBuilder.addExtraQueryParameters(this.bodyParameters);
44
- }
45
-
46
- return parameterBuilder.createQueryString();
47
- }
48
- }
@@ -1,59 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { AuthError } from "@azure/msal-common";
7
- import * as ManagedIdentityErrorCodes from "./ManagedIdentityErrorCodes";
8
- import { ManagedIdentityEnvironmentVariableNames } from "../utils/Constants";
9
- export { ManagedIdentityErrorCodes };
10
-
11
- /**
12
- * ManagedIdentityErrorMessage class containing string constants used by error codes and messages.
13
- */
14
- export const ManagedIdentityErrorMessages = {
15
- [ManagedIdentityErrorCodes.invalidManagedIdentityIdType]:
16
- "More than one ManagedIdentityIdType was provided.",
17
- [ManagedIdentityErrorCodes.invalidResource]:
18
- "The supplied resource is an invalid URL.",
19
- [ManagedIdentityErrorCodes.missingId]:
20
- "A ManagedIdentityId id was not provided.",
21
- [ManagedIdentityErrorCodes.MsiEnvironmentVariableUrlMalformedErrorCodes
22
- .AZURE_POD_IDENTITY_AUTHORITY_HOST]: `The Managed Identity's '${ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST}' environment variable is malformed.`,
23
- [ManagedIdentityErrorCodes.MsiEnvironmentVariableUrlMalformedErrorCodes
24
- .IDENTITY_ENDPOINT]: `The Managed Identity's '${ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' environment variable is malformed.`,
25
- [ManagedIdentityErrorCodes.MsiEnvironmentVariableUrlMalformedErrorCodes
26
- .IMDS_ENDPOINT]: `The Managed Identity's '${ManagedIdentityEnvironmentVariableNames.IMDS_ENDPOINT}' environment variable is malformed.`,
27
- [ManagedIdentityErrorCodes.MsiEnvironmentVariableUrlMalformedErrorCodes
28
- .MSI_ENDPOINT]: `The Managed Identity's '${ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT}' environment variable is malformed.`,
29
- [ManagedIdentityErrorCodes.networkUnavailable]:
30
- "Authentication unavailable. The request to the managed identity endpoint timed out.",
31
- [ManagedIdentityErrorCodes.unableToCreateAzureArc]:
32
- "Azure Arc Managed Identities can only be system assigned.",
33
- [ManagedIdentityErrorCodes.unableToCreateCloudShell]:
34
- "Cloud Shell Managed Identities can only be system assigned.",
35
- [ManagedIdentityErrorCodes.unableToCreateSource]:
36
- "Unable to create a Managed Identity source based on environment variables.",
37
- [ManagedIdentityErrorCodes.unableToReadSecretFile]:
38
- "Unable to read the secret file.",
39
- [ManagedIdentityErrorCodes.userAssignedNotAvailableAtRuntime]:
40
- "Service Fabric user assigned managed identity ClientId or ResourceId is not configurable at runtime.",
41
- [ManagedIdentityErrorCodes.wwwAuthenticateHeaderMissing]:
42
- "A 401 response was received form the Azure Arc Managed Identity, but the www-authenticate header is missing.",
43
- [ManagedIdentityErrorCodes.wwwAuthenticateHeaderUnsupportedFormat]:
44
- "A 401 response was received form the Azure Arc Managed Identity, but the www-authenticate header is in an unsupported format.",
45
- };
46
-
47
- export class ManagedIdentityError extends AuthError {
48
- constructor(errorCode: string) {
49
- super(errorCode, ManagedIdentityErrorMessages[errorCode]);
50
- this.name = "ManagedIdentityError";
51
- Object.setPrototypeOf(this, ManagedIdentityError.prototype);
52
- }
53
- }
54
-
55
- export function createManagedIdentityError(
56
- errorCode: string
57
- ): ManagedIdentityError {
58
- return new ManagedIdentityError(errorCode);
59
- }
@@ -1,34 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { ManagedIdentityEnvironmentVariableNames } from "../utils/Constants";
7
-
8
- export const invalidManagedIdentityIdType = "invalid_managed_identity_id_type";
9
- export const invalidResource = "invalid_resource";
10
- export const missingId = "missing_client_id";
11
- export const networkUnavailable = "network_unavailable";
12
- export const unableToCreateAzureArc = "unable_to_create_azure_arc";
13
- export const unableToCreateCloudShell = "unable_to_create_cloud_shell";
14
- export const unableToCreateSource = "unable_to_create_source";
15
- export const unableToReadSecretFile = "unable_to_read_secret_file";
16
- export const urlParseError = "url_parse_error";
17
- export const userAssignedNotAvailableAtRuntime =
18
- "user_assigned_not_available_at_runtime";
19
- export const wwwAuthenticateHeaderMissing = "www_authenticate_header_missing";
20
- export const wwwAuthenticateHeaderUnsupportedFormat =
21
- "www_authenticate_header_unsupported_format";
22
-
23
- export const MsiEnvironmentVariableUrlMalformedErrorCodes = {
24
- [ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST]:
25
- "azure_pod_identity_authority_host_url_malformed",
26
- [ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT]:
27
- "identity_endpoint_url_malformed",
28
- [ManagedIdentityEnvironmentVariableNames.IMDS_ENDPOINT]:
29
- "imds_endpoint_url_malformed",
30
- [ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT]:
31
- "msi_endpoint_url_malformed",
32
- } as const;
33
- export type MsiEnvironmentVariableErrorCodes =
34
- (typeof MsiEnvironmentVariableUrlMalformedErrorCodes)[keyof typeof MsiEnvironmentVariableUrlMalformedErrorCodes];
@@ -1,80 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import {
7
- HeaderNames,
8
- INetworkModule,
9
- NetworkRequestOptions,
10
- NetworkResponse,
11
- } from "@azure/msal-common";
12
- import { IHttpRetryPolicy } from "../retry/IHttpRetryPolicy";
13
- import { HttpMethod } from "../utils/Constants";
14
-
15
- export class HttpClientWithRetries implements INetworkModule {
16
- private httpClientNoRetries: INetworkModule;
17
- private retryPolicy: IHttpRetryPolicy;
18
-
19
- constructor(
20
- httpClientNoRetries: INetworkModule,
21
- retryPolicy: IHttpRetryPolicy
22
- ) {
23
- this.httpClientNoRetries = httpClientNoRetries;
24
- this.retryPolicy = retryPolicy;
25
- }
26
-
27
- private async sendNetworkRequestAsyncHelper<T>(
28
- httpMethod: HttpMethod,
29
- url: string,
30
- options?: NetworkRequestOptions
31
- ): Promise<NetworkResponse<T>> {
32
- if (httpMethod === HttpMethod.GET) {
33
- return this.httpClientNoRetries.sendGetRequestAsync(url, options);
34
- } else {
35
- return this.httpClientNoRetries.sendPostRequestAsync(url, options);
36
- }
37
- }
38
-
39
- private async sendNetworkRequestAsync<T>(
40
- httpMethod: HttpMethod,
41
- url: string,
42
- options?: NetworkRequestOptions
43
- ): Promise<NetworkResponse<T>> {
44
- // the underlying network module (custom or HttpClient) will make the call
45
- let response: NetworkResponse<T> =
46
- await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
47
-
48
- let currentRetry: number = 0;
49
- while (
50
- await this.retryPolicy.pauseForRetry(
51
- response.status,
52
- currentRetry,
53
- response.headers[HeaderNames.RETRY_AFTER]
54
- )
55
- ) {
56
- response = await this.sendNetworkRequestAsyncHelper(
57
- httpMethod,
58
- url,
59
- options
60
- );
61
- currentRetry++;
62
- }
63
-
64
- return response;
65
- }
66
-
67
- async sendGetRequestAsync<T>(
68
- url: string,
69
- options?: NetworkRequestOptions
70
- ): Promise<NetworkResponse<T>> {
71
- return this.sendNetworkRequestAsync(HttpMethod.GET, url, options);
72
- }
73
-
74
- async sendPostRequestAsync<T>(
75
- url: string,
76
- options?: NetworkRequestOptions
77
- ): Promise<NetworkResponse<T>> {
78
- return this.sendNetworkRequestAsync(HttpMethod.POST, url, options);
79
- }
80
- }
@@ -1,15 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { CommonClientCredentialRequest } from "@azure/msal-common";
7
- import { ManagedIdentityRequestParams } from "./ManagedIdentityRequestParams";
8
-
9
- /**
10
- * ManagedIdentityRequest
11
- * - forceRefresh - forces managed identity requests to skip the cache and make network calls if true
12
- * - resource - resource requested to access the protected API. It should be of the form "{ResourceIdUri}" or {ResourceIdUri/.default}. For instance https://management.azure.net or, for Microsoft Graph, https://graph.microsoft.com/.default
13
- */
14
- export type ManagedIdentityRequest = ManagedIdentityRequestParams &
15
- CommonClientCredentialRequest;
@@ -1,14 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /**
7
- * ManagedIdentityRequest
8
- * - forceRefresh - forces managed identity requests to skip the cache and make network calls if true
9
- * - resource - resource requested to access the protected API. It should be of the form "{ResourceIdUri}" or {ResourceIdUri/.default}. For instance https://management.azure.net or, for Microsoft Graph, https://graph.microsoft.com/.default
10
- */
11
- export type ManagedIdentityRequestParams = {
12
- forceRefresh?: boolean;
13
- resource: string;
14
- };
@@ -1,33 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- import { AuthenticationScheme } from "@azure/msal-common";
7
-
8
- /**
9
- * Deserialized response object from server managed identity request.
10
- *
11
- * In case of success:
12
- * - access_token - The requested access token. When called via a secured REST API, the token is embedded in the Authorization request header field as a "bearer" token, allowing the API to authenticate the caller
13
- * - client_id - A unique identifier generated by Azure AD for the Azure Resource. The Client ID is a GUID value that uniquely identifies the application and its configuration within the identity platform
14
- * - expires_on - The timespan when the access token expires. The date is represented as the number of seconds from "1970-01-01T0:0:0Z UTC" (corresponds to the token's exp claim)
15
- * - resource - The resource the access token was requested for. It matches the resource query string parameter of the request
16
- * - token_type - The type of token returned by the Managed Identity endpoint. It's a "Bearer" access token, which means the resource can give access to the bearer of this token
17
- *
18
- * In case of error:
19
- * - message: A specific error message that can help a developer identify the root cause of an authentication error.
20
- * - correlationId: A unique identifier for the request that can help in diagnostics across components.
21
- */
22
- export type ManagedIdentityTokenResponse = {
23
- // success
24
- access_token?: string;
25
- client_id?: string;
26
- expires_on?: number; // will be converted to expires_in
27
- resource?: string; // equivalent to ServerAuthorizationTokenResponse's "scope" field
28
- token_type?: AuthenticationScheme;
29
-
30
- // error
31
- message?: string; // will be converted to error
32
- correlationId?: string; // will be converted to correlation_id
33
- };
@@ -1,18 +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
-
8
- export interface IHttpRetryPolicy {
9
- /*
10
- * if retry conditions occur, pauses and returns true
11
- * otherwise return false
12
- */
13
- pauseForRetry(
14
- httpStatusCode: number,
15
- currentRetry: number,
16
- retryAfterHeader: http.IncomingHttpHeaders["retry-after"]
17
- ): Promise<boolean>;
18
- }
@@ -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";
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
- }