@azure/msal-node 2.6.3 → 2.6.5-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.
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 +27 -23
  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 +28 -24
  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/ManagedIdentityApplication.cjs +97 -0
  26. package/dist/client/ManagedIdentityApplication.cjs.map +1 -0
  27. package/dist/client/ManagedIdentityApplication.d.ts +24 -0
  28. package/dist/client/ManagedIdentityApplication.d.ts.map +1 -0
  29. package/dist/client/ManagedIdentityApplication.mjs +95 -0
  30. package/dist/client/ManagedIdentityApplication.mjs.map +1 -0
  31. package/dist/client/ManagedIdentityClient.cjs +53 -0
  32. package/dist/client/ManagedIdentityClient.cjs.map +1 -0
  33. package/dist/client/ManagedIdentityClient.d.ts +25 -0
  34. package/dist/client/ManagedIdentityClient.d.ts.map +1 -0
  35. package/dist/client/ManagedIdentityClient.mjs +51 -0
  36. package/dist/client/ManagedIdentityClient.mjs.map +1 -0
  37. package/dist/client/ManagedIdentitySources/AppService.cjs +52 -0
  38. package/dist/client/ManagedIdentitySources/AppService.cjs.map +1 -0
  39. package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -0
  40. package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -0
  41. package/dist/client/ManagedIdentitySources/AppService.mjs +50 -0
  42. package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -0
  43. package/dist/client/ManagedIdentitySources/AzureArc.cjs +96 -0
  44. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -0
  45. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +19 -0
  46. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -0
  47. package/dist/client/ManagedIdentitySources/AzureArc.mjs +93 -0
  48. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -0
  49. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +122 -0
  50. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -0
  51. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +31 -0
  52. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -0
  53. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +119 -0
  54. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -0
  55. package/dist/client/ManagedIdentitySources/CloudShell.cjs +47 -0
  56. package/dist/client/ManagedIdentitySources/CloudShell.cjs.map +1 -0
  57. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +16 -0
  58. package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -0
  59. package/dist/client/ManagedIdentitySources/CloudShell.mjs +45 -0
  60. package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -0
  61. package/dist/client/ManagedIdentitySources/Imds.cjs +54 -0
  62. package/dist/client/ManagedIdentitySources/Imds.cjs.map +1 -0
  63. package/dist/client/ManagedIdentitySources/Imds.d.ts +13 -0
  64. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -0
  65. package/dist/client/ManagedIdentitySources/Imds.mjs +52 -0
  66. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -0
  67. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +61 -0
  68. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs.map +1 -0
  69. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +17 -0
  70. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -0
  71. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +59 -0
  72. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -0
  73. package/dist/client/OnBehalfOfClient.cjs +1 -1
  74. package/dist/client/OnBehalfOfClient.mjs +1 -1
  75. package/dist/client/PublicClientApplication.cjs +1 -1
  76. package/dist/client/PublicClientApplication.mjs +1 -1
  77. package/dist/client/UsernamePasswordClient.cjs +1 -1
  78. package/dist/client/UsernamePasswordClient.mjs +1 -1
  79. package/dist/config/Configuration.cjs +36 -2
  80. package/dist/config/Configuration.cjs.map +1 -1
  81. package/dist/config/Configuration.d.ts +16 -0
  82. package/dist/config/Configuration.d.ts.map +1 -1
  83. package/dist/config/Configuration.mjs +36 -3
  84. package/dist/config/Configuration.mjs.map +1 -1
  85. package/dist/config/ManagedIdentityId.cjs +59 -0
  86. package/dist/config/ManagedIdentityId.cjs.map +1 -0
  87. package/dist/config/ManagedIdentityId.d.ts +12 -0
  88. package/dist/config/ManagedIdentityId.d.ts.map +1 -0
  89. package/dist/config/ManagedIdentityId.mjs +57 -0
  90. package/dist/config/ManagedIdentityId.mjs.map +1 -0
  91. package/dist/config/ManagedIdentityRequestParameters.cjs +37 -0
  92. package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -0
  93. package/dist/config/ManagedIdentityRequestParameters.d.ts +12 -0
  94. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -0
  95. package/dist/config/ManagedIdentityRequestParameters.mjs +35 -0
  96. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -0
  97. package/dist/crypto/CryptoProvider.cjs +1 -1
  98. package/dist/crypto/CryptoProvider.mjs +1 -1
  99. package/dist/crypto/GuidGenerator.cjs +1 -1
  100. package/dist/crypto/GuidGenerator.mjs +1 -1
  101. package/dist/crypto/HashUtils.cjs +1 -1
  102. package/dist/crypto/HashUtils.mjs +1 -1
  103. package/dist/crypto/PkceGenerator.cjs +1 -1
  104. package/dist/crypto/PkceGenerator.mjs +1 -1
  105. package/dist/error/ManagedIdentityError.cjs +51 -0
  106. package/dist/error/ManagedIdentityError.cjs.map +1 -0
  107. package/dist/error/ManagedIdentityError.d.ts +28 -0
  108. package/dist/error/ManagedIdentityError.d.ts.map +1 -0
  109. package/dist/error/ManagedIdentityError.mjs +47 -0
  110. package/dist/error/ManagedIdentityError.mjs.map +1 -0
  111. package/dist/error/ManagedIdentityErrorCodes.cjs +41 -0
  112. package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -0
  113. package/dist/error/ManagedIdentityErrorCodes.d.ts +20 -0
  114. package/dist/error/ManagedIdentityErrorCodes.d.ts.map +1 -0
  115. package/dist/error/ManagedIdentityErrorCodes.mjs +28 -0
  116. package/dist/error/ManagedIdentityErrorCodes.mjs.map +1 -0
  117. package/dist/error/NodeAuthError.cjs +1 -1
  118. package/dist/error/NodeAuthError.mjs +1 -1
  119. package/dist/index.cjs +3 -1
  120. package/dist/index.cjs.map +1 -1
  121. package/dist/index.d.ts +3 -1
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.mjs +2 -1
  124. package/dist/index.mjs.map +1 -1
  125. package/dist/internals.cjs +1 -1
  126. package/dist/internals.mjs +1 -1
  127. package/dist/network/HttpClient.cjs +13 -6
  128. package/dist/network/HttpClient.cjs.map +1 -1
  129. package/dist/network/HttpClient.d.ts +2 -1
  130. package/dist/network/HttpClient.d.ts.map +1 -1
  131. package/dist/network/HttpClient.mjs +13 -6
  132. package/dist/network/HttpClient.mjs.map +1 -1
  133. package/dist/network/HttpClientWithRetries.cjs +44 -0
  134. package/dist/network/HttpClientWithRetries.cjs.map +1 -0
  135. package/dist/network/HttpClientWithRetries.d.ts +12 -0
  136. package/dist/network/HttpClientWithRetries.d.ts.map +1 -0
  137. package/dist/network/HttpClientWithRetries.mjs +42 -0
  138. package/dist/network/HttpClientWithRetries.mjs.map +1 -0
  139. package/dist/network/LoopbackClient.cjs +1 -1
  140. package/dist/network/LoopbackClient.mjs +1 -1
  141. package/dist/packageMetadata.cjs +2 -2
  142. package/dist/packageMetadata.d.ts +1 -1
  143. package/dist/packageMetadata.d.ts.map +1 -1
  144. package/dist/packageMetadata.mjs +2 -2
  145. package/dist/request/ManagedIdentityRequest.d.ts +9 -0
  146. package/dist/request/ManagedIdentityRequest.d.ts.map +1 -0
  147. package/dist/request/ManagedIdentityRequestParams.d.ts +10 -0
  148. package/dist/request/ManagedIdentityRequestParams.d.ts.map +1 -0
  149. package/dist/response/ManagedIdentityTokenResponse.d.ts +25 -0
  150. package/dist/response/ManagedIdentityTokenResponse.d.ts.map +1 -0
  151. package/dist/retry/IHttpRetryPolicy.d.ts +6 -0
  152. package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -0
  153. package/dist/retry/LinearRetryPolicy.cjs +47 -0
  154. package/dist/retry/LinearRetryPolicy.cjs.map +1 -0
  155. package/dist/retry/LinearRetryPolicy.d.ts +12 -0
  156. package/dist/retry/LinearRetryPolicy.d.ts.map +1 -0
  157. package/dist/retry/LinearRetryPolicy.mjs +45 -0
  158. package/dist/retry/LinearRetryPolicy.mjs.map +1 -0
  159. package/dist/utils/Constants.cjs +68 -1
  160. package/dist/utils/Constants.cjs.map +1 -1
  161. package/dist/utils/Constants.d.ts +45 -0
  162. package/dist/utils/Constants.d.ts.map +1 -1
  163. package/dist/utils/Constants.mjs +54 -2
  164. package/dist/utils/Constants.mjs.map +1 -1
  165. package/dist/utils/EncodingUtils.cjs +1 -1
  166. package/dist/utils/EncodingUtils.mjs +1 -1
  167. package/dist/utils/NetworkUtils.cjs +1 -1
  168. package/dist/utils/NetworkUtils.mjs +1 -1
  169. package/package.json +2 -2
  170. package/src/client/ClientCredentialClient.ts +65 -25
  171. package/src/client/ManagedIdentityApplication.ts +194 -0
  172. package/src/client/ManagedIdentityClient.ts +128 -0
  173. package/src/client/ManagedIdentitySources/AppService.ts +122 -0
  174. package/src/client/ManagedIdentitySources/AzureArc.ts +199 -0
  175. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +237 -0
  176. package/src/client/ManagedIdentitySources/CloudShell.ts +104 -0
  177. package/src/client/ManagedIdentitySources/Imds.ts +126 -0
  178. package/src/client/ManagedIdentitySources/ServiceFabric.ts +140 -0
  179. package/src/config/Configuration.ts +81 -1
  180. package/src/config/ManagedIdentityId.ts +73 -0
  181. package/src/config/ManagedIdentityRequestParameters.ts +48 -0
  182. package/src/error/ManagedIdentityError.ts +59 -0
  183. package/src/error/ManagedIdentityErrorCodes.ts +34 -0
  184. package/src/index.ts +4 -0
  185. package/src/network/HttpClient.ts +17 -5
  186. package/src/network/HttpClientWithRetries.ts +80 -0
  187. package/src/packageMetadata.ts +1 -1
  188. package/src/request/ManagedIdentityRequest.ts +15 -0
  189. package/src/request/ManagedIdentityRequestParams.ts +14 -0
  190. package/src/response/ManagedIdentityTokenResponse.ts +33 -0
  191. package/src/retry/IHttpRetryPolicy.ts +18 -0
  192. package/src/retry/LinearRetryPolicy.ts +71 -0
  193. package/src/utils/Constants.ts +63 -0
@@ -0,0 +1,80 @@
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,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-node";
3
- export const version = "2.6.3";
3
+ export const version = "2.6.5-alpha.0";
@@ -0,0 +1,15 @@
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;
@@ -0,0 +1,14 @@
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
+ };
@@ -0,0 +1,33 @@
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
+ };
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,71 @@
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
+ }
@@ -3,6 +3,58 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { HttpStatus } from "@azure/msal-common";
7
+
8
+ // MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
9
+ export const AUTHORIZATION_HEADER_NAME: string = "Authorization";
10
+ export const METADATA_HEADER_NAME: string = "Metadata";
11
+ export const APP_SERVICE_SECRET_HEADER_NAME: string = "X-IDENTITY-HEADER";
12
+ export const SERVICE_FABRIC_SECRET_HEADER_NAME: string = "secret";
13
+ export const API_VERSION_QUERY_PARAMETER_NAME: string = "api-version";
14
+ export const RESOURCE_BODY_OR_QUERY_PARAMETER_NAME: string = "resource";
15
+ export const DEFAULT_MANAGED_IDENTITY_ID = "system_assigned_managed_identity";
16
+ export const MANAGED_IDENTITY_DEFAULT_TENANT = "managed_identity";
17
+ export const DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY = `https://login.microsoftonline.com/${MANAGED_IDENTITY_DEFAULT_TENANT}/`;
18
+
19
+ /**
20
+ * Managed Identity Environment Variable Names
21
+ */
22
+ export const ManagedIdentityEnvironmentVariableNames = {
23
+ AZURE_POD_IDENTITY_AUTHORITY_HOST: "AZURE_POD_IDENTITY_AUTHORITY_HOST",
24
+ IDENTITY_ENDPOINT: "IDENTITY_ENDPOINT",
25
+ IDENTITY_HEADER: "IDENTITY_HEADER",
26
+ IDENTITY_SERVER_THUMBPRINT: "IDENTITY_SERVER_THUMBPRINT",
27
+ IMDS_ENDPOINT: "IMDS_ENDPOINT",
28
+ MSI_ENDPOINT: "MSI_ENDPOINT",
29
+ } as const;
30
+ export type ManagedIdentityEnvironmentVariableNames =
31
+ (typeof ManagedIdentityEnvironmentVariableNames)[keyof typeof ManagedIdentityEnvironmentVariableNames];
32
+
33
+ /**
34
+ * Managed Identity Source Names
35
+ */
36
+ export const ManagedIdentitySourceNames = {
37
+ APP_SERVICE: "App Service",
38
+ AZURE_ARC: "Azure Arc",
39
+ CLOUD_SHELL: "Cloud Shell",
40
+ IMDS: "IMDS",
41
+ SERVICE_FABRIC: "Service Fabric",
42
+ } as const;
43
+ export type ManagedIdentitySourceNames =
44
+ (typeof ManagedIdentitySourceNames)[keyof typeof ManagedIdentitySourceNames];
45
+
46
+ /**
47
+ * Managed Identity Ids
48
+ */
49
+ export const ManagedIdentityIdType = {
50
+ SYSTEM_ASSIGNED: "system-assigned",
51
+ USER_ASSIGNED_CLIENT_ID: "user-assigned-client-id",
52
+ USER_ASSIGNED_RESOURCE_ID: "user-assigned-resource-id",
53
+ USER_ASSIGNED_OBJECT_ID: "user-assigned-object-id",
54
+ } as const;
55
+ export type ManagedIdentityIdType =
56
+ (typeof ManagedIdentityIdType)[keyof typeof ManagedIdentityIdType];
57
+
6
58
  /**
7
59
  * http methods
8
60
  */
@@ -101,3 +153,14 @@ export const LOOPBACK_SERVER_CONSTANTS = {
101
153
  INTERVAL_MS: 100,
102
154
  TIMEOUT_MS: 5000,
103
155
  };
156
+
157
+ export const MANAGED_IDENTITY_MAX_RETRIES = 1;
158
+ export const MANAGED_IDENTITY_RETRY_DELAY = 1000;
159
+ export const MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
160
+ HttpStatus.NOT_FOUND,
161
+ HttpStatus.REQUEST_TIMEOUT,
162
+ HttpStatus.TOO_MANY_REQUESTS,
163
+ HttpStatus.INTERNAL_SERVER_ERROR,
164
+ HttpStatus.SERVICE_UNAVAILABLE,
165
+ HttpStatus.GATEWAY_TIMEOUT,
166
+ ];