@azure/msal-node 3.2.3 → 3.4.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 (172) hide show
  1. package/dist/cache/NodeStorage.mjs +1 -1
  2. package/dist/cache/TokenCache.mjs +1 -1
  3. package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
  4. package/dist/cache/serializer/Deserializer.mjs +1 -1
  5. package/dist/cache/serializer/Serializer.mjs +1 -1
  6. package/dist/client/ClientApplication.d.ts +3 -3
  7. package/dist/client/ClientApplication.d.ts.map +1 -1
  8. package/dist/client/ClientApplication.mjs +14 -17
  9. package/dist/client/ClientApplication.mjs.map +1 -1
  10. package/dist/client/ClientAssertion.mjs +1 -1
  11. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  12. package/dist/client/ClientCredentialClient.mjs +16 -16
  13. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  14. package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
  15. package/dist/client/ConfidentialClientApplication.mjs +5 -3
  16. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  17. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  18. package/dist/client/DeviceCodeClient.mjs +24 -24
  19. package/dist/client/DeviceCodeClient.mjs.map +1 -1
  20. package/dist/client/ManagedIdentityApplication.d.ts.map +1 -1
  21. package/dist/client/ManagedIdentityApplication.mjs +2 -2
  22. package/dist/client/ManagedIdentityApplication.mjs.map +1 -1
  23. package/dist/client/ManagedIdentityClient.d.ts +2 -1
  24. package/dist/client/ManagedIdentityClient.d.ts.map +1 -1
  25. package/dist/client/ManagedIdentityClient.mjs +11 -10
  26. package/dist/client/ManagedIdentityClient.mjs.map +1 -1
  27. package/dist/client/ManagedIdentitySources/AppService.d.ts +2 -2
  28. package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
  29. package/dist/client/ManagedIdentitySources/AppService.mjs +5 -5
  30. package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
  31. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +2 -2
  32. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
  33. package/dist/client/ManagedIdentitySources/AzureArc.mjs +5 -5
  34. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
  35. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  36. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  37. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +15 -5
  38. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  39. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +2 -2
  40. package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
  41. package/dist/client/ManagedIdentitySources/CloudShell.mjs +5 -5
  42. package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
  43. package/dist/client/ManagedIdentitySources/Imds.d.ts +2 -2
  44. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  45. package/dist/client/ManagedIdentitySources/Imds.mjs +5 -5
  46. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
  47. package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +2 -2
  48. package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  49. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +5 -5
  50. package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
  51. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +2 -2
  52. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
  53. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +5 -5
  54. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
  55. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  56. package/dist/client/OnBehalfOfClient.mjs +19 -19
  57. package/dist/client/OnBehalfOfClient.mjs.map +1 -1
  58. package/dist/client/PublicClientApplication.d.ts.map +1 -1
  59. package/dist/client/PublicClientApplication.mjs +3 -2
  60. package/dist/client/PublicClientApplication.mjs.map +1 -1
  61. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  62. package/dist/client/UsernamePasswordClient.mjs +21 -21
  63. package/dist/client/UsernamePasswordClient.mjs.map +1 -1
  64. package/dist/config/Configuration.d.ts +1 -0
  65. package/dist/config/Configuration.d.ts.map +1 -1
  66. package/dist/config/Configuration.mjs +2 -9
  67. package/dist/config/Configuration.mjs.map +1 -1
  68. package/dist/config/ManagedIdentityId.mjs +1 -1
  69. package/dist/config/ManagedIdentityRequestParameters.d.ts +3 -2
  70. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  71. package/dist/config/ManagedIdentityRequestParameters.mjs +13 -9
  72. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
  73. package/dist/crypto/CryptoProvider.mjs +1 -1
  74. package/dist/crypto/GuidGenerator.mjs +1 -1
  75. package/dist/crypto/HashUtils.mjs +1 -1
  76. package/dist/crypto/PkceGenerator.mjs +1 -1
  77. package/dist/error/ManagedIdentityError.mjs +1 -1
  78. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  79. package/dist/error/NodeAuthError.mjs +1 -1
  80. package/dist/index.d.ts +5 -1
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.mjs +1 -1
  83. package/dist/internals.mjs +1 -1
  84. package/dist/network/HttpClient.mjs +1 -1
  85. package/dist/network/HttpClientWithRetries.mjs +1 -1
  86. package/dist/network/ILoopbackClient.d.ts +2 -2
  87. package/dist/network/ILoopbackClient.d.ts.map +1 -1
  88. package/dist/network/LoopbackClient.d.ts +2 -2
  89. package/dist/network/LoopbackClient.d.ts.map +1 -1
  90. package/dist/network/LoopbackClient.mjs +3 -2
  91. package/dist/network/LoopbackClient.mjs.map +1 -1
  92. package/dist/packageMetadata.d.ts +1 -1
  93. package/dist/packageMetadata.mjs +2 -2
  94. package/dist/protocol/Authorize.d.ts +12 -0
  95. package/dist/protocol/Authorize.d.ts.map +1 -0
  96. package/dist/protocol/Authorize.mjs +42 -0
  97. package/dist/protocol/Authorize.mjs.map +1 -0
  98. package/dist/retry/LinearRetryPolicy.mjs +1 -1
  99. package/dist/utils/Constants.d.ts +5 -0
  100. package/dist/utils/Constants.d.ts.map +1 -1
  101. package/dist/utils/Constants.mjs +1 -1
  102. package/dist/utils/Constants.mjs.map +1 -1
  103. package/dist/utils/EncodingUtils.mjs +1 -1
  104. package/dist/utils/NetworkUtils.mjs +1 -1
  105. package/dist/utils/TimeUtils.mjs +1 -1
  106. package/lib/msal-node.cjs +1006 -1082
  107. package/lib/msal-node.cjs.map +1 -1
  108. package/lib/types/client/ClientApplication.d.ts +3 -3
  109. package/lib/types/client/ClientApplication.d.ts.map +1 -1
  110. package/lib/types/client/ClientCredentialClient.d.ts.map +1 -1
  111. package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
  112. package/lib/types/client/DeviceCodeClient.d.ts.map +1 -1
  113. package/lib/types/client/ManagedIdentityApplication.d.ts.map +1 -1
  114. package/lib/types/client/ManagedIdentityClient.d.ts +2 -1
  115. package/lib/types/client/ManagedIdentityClient.d.ts.map +1 -1
  116. package/lib/types/client/ManagedIdentitySources/AppService.d.ts +2 -2
  117. package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
  118. package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts +2 -2
  119. package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
  120. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  121. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  122. package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts +2 -2
  123. package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
  124. package/lib/types/client/ManagedIdentitySources/Imds.d.ts +2 -2
  125. package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  126. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +2 -2
  127. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  128. package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts +2 -2
  129. package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
  130. package/lib/types/client/OnBehalfOfClient.d.ts.map +1 -1
  131. package/lib/types/client/PublicClientApplication.d.ts.map +1 -1
  132. package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
  133. package/lib/types/config/Configuration.d.ts +1 -0
  134. package/lib/types/config/Configuration.d.ts.map +1 -1
  135. package/lib/types/config/ManagedIdentityRequestParameters.d.ts +3 -2
  136. package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  137. package/lib/types/index.d.ts +5 -1
  138. package/lib/types/index.d.ts.map +1 -1
  139. package/lib/types/network/ILoopbackClient.d.ts +2 -2
  140. package/lib/types/network/ILoopbackClient.d.ts.map +1 -1
  141. package/lib/types/network/LoopbackClient.d.ts +2 -2
  142. package/lib/types/network/LoopbackClient.d.ts.map +1 -1
  143. package/lib/types/packageMetadata.d.ts +1 -1
  144. package/lib/types/protocol/Authorize.d.ts +12 -0
  145. package/lib/types/protocol/Authorize.d.ts.map +1 -0
  146. package/lib/types/utils/Constants.d.ts +5 -0
  147. package/lib/types/utils/Constants.d.ts.map +1 -1
  148. package/package.json +2 -2
  149. package/src/client/ClientApplication.ts +42 -44
  150. package/src/client/ClientCredentialClient.ts +32 -14
  151. package/src/client/ConfidentialClientApplication.ts +15 -7
  152. package/src/client/DeviceCodeClient.ts +46 -24
  153. package/src/client/ManagedIdentityApplication.ts +2 -1
  154. package/src/client/ManagedIdentityClient.ts +20 -4
  155. package/src/client/ManagedIdentitySources/AppService.ts +11 -2
  156. package/src/client/ManagedIdentitySources/AzureArc.ts +10 -1
  157. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +20 -4
  158. package/src/client/ManagedIdentitySources/CloudShell.ts +10 -1
  159. package/src/client/ManagedIdentitySources/Imds.ts +11 -2
  160. package/src/client/ManagedIdentitySources/MachineLearning.ts +11 -2
  161. package/src/client/ManagedIdentitySources/ServiceFabric.ts +10 -1
  162. package/src/client/OnBehalfOfClient.ts +38 -17
  163. package/src/client/PublicClientApplication.ts +9 -5
  164. package/src/client/UsernamePasswordClient.ts +37 -19
  165. package/src/config/Configuration.ts +2 -20
  166. package/src/config/ManagedIdentityRequestParameters.ts +38 -9
  167. package/src/index.ts +5 -2
  168. package/src/network/ILoopbackClient.ts +2 -2
  169. package/src/network/LoopbackClient.ts +43 -46
  170. package/src/packageMetadata.ts +1 -1
  171. package/src/protocol/Authorize.ts +63 -0
  172. package/src/utils/Constants.ts +6 -0
@@ -5,7 +5,7 @@
5
5
 
6
6
  import {
7
7
  Constants as CommonConstants,
8
- ServerAuthorizationCodeResponse,
8
+ AuthorizeResponse,
9
9
  HttpStatus,
10
10
  UrlUtils,
11
11
  } from "@azure/msal-common/node";
@@ -26,57 +26,54 @@ export class LoopbackClient implements ILoopbackClient {
26
26
  async listenForAuthCode(
27
27
  successTemplate?: string,
28
28
  errorTemplate?: string
29
- ): Promise<ServerAuthorizationCodeResponse> {
29
+ ): Promise<AuthorizeResponse> {
30
30
  if (this.server) {
31
31
  throw NodeAuthError.createLoopbackServerAlreadyExistsError();
32
32
  }
33
33
 
34
- return new Promise<ServerAuthorizationCodeResponse>(
35
- (resolve, reject) => {
36
- this.server = http.createServer(
37
- (req: http.IncomingMessage, res: http.ServerResponse) => {
38
- const url = req.url;
39
- if (!url) {
40
- res.end(
41
- errorTemplate ||
42
- "Error occurred loading redirectUrl"
43
- );
44
- reject(
45
- NodeAuthError.createUnableToLoadRedirectUrlError()
46
- );
47
- return;
48
- } else if (url === CommonConstants.FORWARD_SLASH) {
49
- res.end(
50
- successTemplate ||
51
- "Auth code was successfully acquired. You can close this window now."
52
- );
53
- return;
54
- }
34
+ return new Promise<AuthorizeResponse>((resolve, reject) => {
35
+ this.server = http.createServer(
36
+ (req: http.IncomingMessage, res: http.ServerResponse) => {
37
+ const url = req.url;
38
+ if (!url) {
39
+ res.end(
40
+ errorTemplate ||
41
+ "Error occurred loading redirectUrl"
42
+ );
43
+ reject(
44
+ NodeAuthError.createUnableToLoadRedirectUrlError()
45
+ );
46
+ return;
47
+ } else if (url === CommonConstants.FORWARD_SLASH) {
48
+ res.end(
49
+ successTemplate ||
50
+ "Auth code was successfully acquired. You can close this window now."
51
+ );
52
+ return;
53
+ }
55
54
 
56
- const redirectUri = this.getRedirectUri();
57
- const parsedUrl = new URL(url, redirectUri);
58
- const authCodeResponse =
59
- UrlUtils.getDeserializedResponse(
60
- parsedUrl.search
61
- ) || {};
62
- if (authCodeResponse.code) {
63
- res.writeHead(HttpStatus.REDIRECT, {
64
- location: redirectUri,
65
- }); // Prevent auth code from being saved in the browser history
66
- res.end();
67
- }
68
- if (authCodeResponse.error) {
69
- res.end(
70
- errorTemplate ||
71
- `Error occurred: ${authCodeResponse.error}`
72
- );
73
- }
74
- resolve(authCodeResponse);
55
+ const redirectUri = this.getRedirectUri();
56
+ const parsedUrl = new URL(url, redirectUri);
57
+ const authCodeResponse =
58
+ UrlUtils.getDeserializedResponse(parsedUrl.search) ||
59
+ {};
60
+ if (authCodeResponse.code) {
61
+ res.writeHead(HttpStatus.REDIRECT, {
62
+ location: redirectUri,
63
+ }); // Prevent auth code from being saved in the browser history
64
+ res.end();
75
65
  }
76
- );
77
- this.server.listen(0, "127.0.0.1"); // Listen on any available port
78
- }
79
- );
66
+ if (authCodeResponse.error) {
67
+ res.end(
68
+ errorTemplate ||
69
+ `Error occurred: ${authCodeResponse.error}`
70
+ );
71
+ }
72
+ resolve(authCodeResponse);
73
+ }
74
+ );
75
+ this.server.listen(0, "127.0.0.1"); // Listen on any available port
76
+ });
80
77
  }
81
78
 
82
79
  /**
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-node";
3
- export const version = "3.2.3";
3
+ export const version = "3.4.0";
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ Authority,
8
+ AuthorizeProtocol,
9
+ CommonAuthorizationUrlRequest,
10
+ Logger,
11
+ ProtocolMode,
12
+ RequestParameterBuilder,
13
+ } from "@azure/msal-common/node";
14
+ import { NodeConfiguration } from "../config/Configuration.js";
15
+ import { Constants as NodeConstants } from "../utils/Constants.js";
16
+ import { version } from "../packageMetadata.js";
17
+
18
+ /**
19
+ * Constructs the full /authorize URL with request parameters
20
+ * @param config
21
+ * @param authority
22
+ * @param request
23
+ * @param logger
24
+ * @returns
25
+ */
26
+ export function getAuthCodeRequestUrl(
27
+ config: NodeConfiguration,
28
+ authority: Authority,
29
+ request: CommonAuthorizationUrlRequest,
30
+ logger: Logger
31
+ ): string {
32
+ const parameters = AuthorizeProtocol.getStandardAuthorizeRequestParameters(
33
+ {
34
+ ...config.auth,
35
+ authority: authority,
36
+ redirectUri: request.redirectUri || "",
37
+ },
38
+ request,
39
+ logger
40
+ );
41
+ RequestParameterBuilder.addLibraryInfo(parameters, {
42
+ sku: NodeConstants.MSAL_SKU,
43
+ version: version,
44
+ cpu: process.arch || "",
45
+ os: process.platform || "",
46
+ });
47
+ if (config.auth.protocolMode !== ProtocolMode.OIDC) {
48
+ RequestParameterBuilder.addApplicationTelemetry(
49
+ parameters,
50
+ config.telemetry.application
51
+ );
52
+ }
53
+ RequestParameterBuilder.addResponseTypeCode(parameters);
54
+ if (request.codeChallenge && request.codeChallengeMethod) {
55
+ RequestParameterBuilder.addCodeChallengeParams(
56
+ parameters,
57
+ request.codeChallenge,
58
+ request.codeChallengeMethod
59
+ );
60
+ }
61
+
62
+ return AuthorizeProtocol.getAuthorizeUrl(authority, parameters);
63
+ }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { HttpStatus } from "@azure/msal-common/node";
7
+ import { LinearRetryPolicy } from "../retry/LinearRetryPolicy.js";
7
8
 
8
9
  // MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
9
10
  export const AUTHORIZATION_HEADER_NAME: string = "Authorization";
@@ -178,3 +179,8 @@ export const MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
178
179
  HttpStatus.SERVICE_UNAVAILABLE,
179
180
  HttpStatus.GATEWAY_TIMEOUT,
180
181
  ];
182
+
183
+ /**
184
+ * Retry Policy Types
185
+ */
186
+ export type RetryPolicies = LinearRetryPolicy;