@azure/msal-node 2.7.0-alpha.0 → 2.7.1-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 (245) hide show
  1. package/README.md +1 -1
  2. package/dist/cache/ITokenCache.d.ts +15 -15
  3. package/dist/cache/NodeStorage.cjs +423 -423
  4. package/dist/cache/NodeStorage.cjs.map +1 -1
  5. package/dist/cache/NodeStorage.d.ts +193 -193
  6. package/dist/cache/NodeStorage.d.ts.map +1 -1
  7. package/dist/cache/NodeStorage.mjs +424 -424
  8. package/dist/cache/NodeStorage.mjs.map +1 -1
  9. package/dist/cache/TokenCache.cjs +265 -265
  10. package/dist/cache/TokenCache.d.ts +90 -90
  11. package/dist/cache/TokenCache.mjs +265 -265
  12. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  13. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  14. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  15. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  16. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  17. package/dist/cache/serializer/Deserializer.cjs +167 -170
  18. package/dist/cache/serializer/Deserializer.cjs.map +1 -1
  19. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  20. package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
  21. package/dist/cache/serializer/Deserializer.mjs +168 -171
  22. package/dist/cache/serializer/Deserializer.mjs.map +1 -1
  23. package/dist/cache/serializer/Serializer.cjs +137 -137
  24. package/dist/cache/serializer/Serializer.d.ts +39 -39
  25. package/dist/cache/serializer/Serializer.mjs +137 -137
  26. package/dist/cache/serializer/SerializerTypes.d.ts +102 -102
  27. package/dist/client/ClientApplication.cjs +335 -333
  28. package/dist/client/ClientApplication.cjs.map +1 -1
  29. package/dist/client/ClientApplication.d.ts +143 -142
  30. package/dist/client/ClientApplication.d.ts.map +1 -1
  31. package/dist/client/ClientApplication.mjs +336 -334
  32. package/dist/client/ClientApplication.mjs.map +1 -1
  33. package/dist/client/ClientAssertion.cjs +116 -116
  34. package/dist/client/ClientAssertion.d.ts +46 -46
  35. package/dist/client/ClientAssertion.mjs +116 -116
  36. package/dist/client/ClientCredentialClient.cjs +194 -194
  37. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  38. package/dist/client/ClientCredentialClient.d.ts +33 -33
  39. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  40. package/dist/client/ClientCredentialClient.mjs +195 -195
  41. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  42. package/dist/client/ConfidentialClientApplication.cjs +166 -163
  43. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  44. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  45. package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
  46. package/dist/client/ConfidentialClientApplication.mjs +168 -165
  47. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  48. package/dist/client/DeviceCodeClient.cjs +207 -207
  49. package/dist/client/DeviceCodeClient.d.ts +53 -53
  50. package/dist/client/DeviceCodeClient.mjs +207 -207
  51. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  52. package/dist/client/IPublicClientApplication.d.ts +42 -42
  53. package/dist/client/ManagedIdentityApplication.cjs +75 -80
  54. package/dist/client/ManagedIdentityApplication.cjs.map +1 -1
  55. package/dist/client/ManagedIdentityApplication.d.ts +23 -23
  56. package/dist/client/ManagedIdentityApplication.d.ts.map +1 -1
  57. package/dist/client/ManagedIdentityApplication.mjs +76 -81
  58. package/dist/client/ManagedIdentityApplication.mjs.map +1 -1
  59. package/dist/client/ManagedIdentityClient.cjs +40 -36
  60. package/dist/client/ManagedIdentityClient.cjs.map +1 -1
  61. package/dist/client/ManagedIdentityClient.d.ts +19 -24
  62. package/dist/client/ManagedIdentityClient.d.ts.map +1 -1
  63. package/dist/client/ManagedIdentityClient.mjs +40 -36
  64. package/dist/client/ManagedIdentityClient.mjs.map +1 -1
  65. package/dist/client/ManagedIdentitySources/AppService.cjs +42 -69
  66. package/dist/client/ManagedIdentitySources/AppService.cjs.map +1 -1
  67. package/dist/client/ManagedIdentitySources/AppService.d.ts +16 -16
  68. package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
  69. package/dist/client/ManagedIdentitySources/AppService.mjs +43 -70
  70. package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
  71. package/dist/client/ManagedIdentitySources/AzureArc.cjs +81 -92
  72. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -1
  73. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +18 -18
  74. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
  75. package/dist/client/ManagedIdentitySources/AzureArc.mjs +84 -95
  76. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
  77. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +116 -77
  78. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -1
  79. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +30 -18
  80. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  81. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +118 -80
  82. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  83. package/dist/client/ManagedIdentitySources/CloudShell.cjs +47 -0
  84. package/dist/client/ManagedIdentitySources/CloudShell.cjs.map +1 -0
  85. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +15 -6
  86. package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
  87. package/dist/client/ManagedIdentitySources/CloudShell.mjs +45 -0
  88. package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -0
  89. package/dist/client/ManagedIdentitySources/Imds.cjs +43 -52
  90. package/dist/client/ManagedIdentitySources/Imds.cjs.map +1 -1
  91. package/dist/client/ManagedIdentitySources/Imds.d.ts +12 -12
  92. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  93. package/dist/client/ManagedIdentitySources/Imds.mjs +44 -53
  94. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
  95. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +61 -0
  96. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs.map +1 -0
  97. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +16 -6
  98. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
  99. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +59 -0
  100. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -0
  101. package/dist/client/OnBehalfOfClient.cjs +202 -202
  102. package/dist/client/OnBehalfOfClient.cjs.map +1 -1
  103. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  104. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  105. package/dist/client/OnBehalfOfClient.mjs +203 -203
  106. package/dist/client/OnBehalfOfClient.mjs.map +1 -1
  107. package/dist/client/PublicClientApplication.cjs +229 -229
  108. package/dist/client/PublicClientApplication.d.ts +71 -71
  109. package/dist/client/PublicClientApplication.mjs +229 -229
  110. package/dist/client/UsernamePasswordClient.cjs +95 -95
  111. package/dist/client/UsernamePasswordClient.cjs.map +1 -1
  112. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  113. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  114. package/dist/client/UsernamePasswordClient.mjs +96 -96
  115. package/dist/client/UsernamePasswordClient.mjs.map +1 -1
  116. package/dist/config/Configuration.cjs +102 -86
  117. package/dist/config/Configuration.cjs.map +1 -1
  118. package/dist/config/Configuration.d.ts +126 -122
  119. package/dist/config/Configuration.d.ts.map +1 -1
  120. package/dist/config/Configuration.mjs +102 -86
  121. package/dist/config/Configuration.mjs.map +1 -1
  122. package/dist/config/ManagedIdentityId.cjs +48 -48
  123. package/dist/config/ManagedIdentityId.d.ts +11 -11
  124. package/dist/config/ManagedIdentityId.mjs +48 -48
  125. package/dist/config/ManagedIdentityRequestParameters.cjs +28 -29
  126. package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -1
  127. package/dist/config/ManagedIdentityRequestParameters.d.ts +11 -11
  128. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  129. package/dist/config/ManagedIdentityRequestParameters.mjs +28 -29
  130. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
  131. package/dist/crypto/CryptoProvider.cjs +75 -75
  132. package/dist/crypto/CryptoProvider.d.ts +52 -52
  133. package/dist/crypto/CryptoProvider.mjs +75 -75
  134. package/dist/crypto/GuidGenerator.cjs +22 -22
  135. package/dist/crypto/GuidGenerator.d.ts +14 -14
  136. package/dist/crypto/GuidGenerator.mjs +22 -22
  137. package/dist/crypto/HashUtils.cjs +13 -13
  138. package/dist/crypto/HashUtils.d.ts +8 -8
  139. package/dist/crypto/HashUtils.mjs +13 -13
  140. package/dist/crypto/PkceGenerator.cjs +49 -49
  141. package/dist/crypto/PkceGenerator.d.ts +22 -22
  142. package/dist/crypto/PkceGenerator.mjs +49 -49
  143. package/dist/error/ManagedIdentityError.cjs +38 -28
  144. package/dist/error/ManagedIdentityError.cjs.map +1 -1
  145. package/dist/error/ManagedIdentityError.d.ts +26 -21
  146. package/dist/error/ManagedIdentityError.d.ts.map +1 -1
  147. package/dist/error/ManagedIdentityError.mjs +39 -29
  148. package/dist/error/ManagedIdentityError.mjs.map +1 -1
  149. package/dist/error/ManagedIdentityErrorCodes.cjs +26 -15
  150. package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -1
  151. package/dist/error/ManagedIdentityErrorCodes.d.ts +18 -9
  152. package/dist/error/ManagedIdentityErrorCodes.d.ts.map +1 -1
  153. package/dist/error/ManagedIdentityErrorCodes.mjs +23 -14
  154. package/dist/error/ManagedIdentityErrorCodes.mjs.map +1 -1
  155. package/dist/error/NodeAuthError.cjs +85 -85
  156. package/dist/error/NodeAuthError.d.ts +65 -65
  157. package/dist/error/NodeAuthError.mjs +85 -85
  158. package/dist/index.cjs +21 -21
  159. package/dist/index.d.ts +44 -44
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.mjs +1 -1
  162. package/dist/internals.cjs +8 -8
  163. package/dist/internals.d.ts +6 -6
  164. package/dist/internals.mjs +8 -8
  165. package/dist/network/HttpClient.cjs +281 -283
  166. package/dist/network/HttpClient.cjs.map +1 -1
  167. package/dist/network/HttpClient.d.ts +25 -26
  168. package/dist/network/HttpClient.d.ts.map +1 -1
  169. package/dist/network/HttpClient.mjs +281 -283
  170. package/dist/network/HttpClient.mjs.map +1 -1
  171. package/dist/network/HttpClientWithRetries.cjs +44 -0
  172. package/dist/network/HttpClientWithRetries.cjs.map +1 -0
  173. package/dist/network/HttpClientWithRetries.d.ts +12 -0
  174. package/dist/network/HttpClientWithRetries.d.ts.map +1 -0
  175. package/dist/network/HttpClientWithRetries.mjs +42 -0
  176. package/dist/network/HttpClientWithRetries.mjs.map +1 -0
  177. package/dist/network/ILoopbackClient.d.ts +10 -10
  178. package/dist/network/LoopbackClient.cjs +77 -77
  179. package/dist/network/LoopbackClient.d.ts +21 -21
  180. package/dist/network/LoopbackClient.mjs +77 -77
  181. package/dist/packageMetadata.cjs +4 -4
  182. package/dist/packageMetadata.d.ts +2 -2
  183. package/dist/packageMetadata.mjs +4 -4
  184. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  185. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  186. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  187. package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
  188. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  189. package/dist/request/InteractiveRequest.d.ts +22 -22
  190. package/dist/request/ManagedIdentityRequest.d.ts +8 -8
  191. package/dist/request/ManagedIdentityRequestParams.d.ts +9 -9
  192. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  193. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  194. package/dist/request/SignOutRequest.d.ts +5 -5
  195. package/dist/request/SilentFlowRequest.d.ts +16 -16
  196. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  197. package/dist/response/ManagedIdentityTokenResponse.d.ts +24 -24
  198. package/dist/retry/IHttpRetryPolicy.d.ts +6 -0
  199. package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -0
  200. package/dist/retry/LinearRetryPolicy.cjs +47 -0
  201. package/dist/retry/LinearRetryPolicy.cjs.map +1 -0
  202. package/dist/retry/LinearRetryPolicy.d.ts +12 -0
  203. package/dist/retry/LinearRetryPolicy.d.ts.map +1 -0
  204. package/dist/retry/LinearRetryPolicy.mjs +45 -0
  205. package/dist/retry/LinearRetryPolicy.mjs.map +1 -0
  206. package/dist/utils/Constants.cjs +142 -103
  207. package/dist/utils/Constants.cjs.map +1 -1
  208. package/dist/utils/Constants.d.ts +132 -106
  209. package/dist/utils/Constants.d.ts.map +1 -1
  210. package/dist/utils/Constants.mjs +134 -100
  211. package/dist/utils/Constants.mjs.map +1 -1
  212. package/dist/utils/EncodingUtils.cjs +44 -44
  213. package/dist/utils/EncodingUtils.d.ts +26 -26
  214. package/dist/utils/EncodingUtils.mjs +44 -44
  215. package/dist/utils/NetworkUtils.cjs +38 -38
  216. package/dist/utils/NetworkUtils.d.ts +5 -5
  217. package/dist/utils/NetworkUtils.mjs +38 -38
  218. package/package.json +5 -5
  219. package/src/cache/NodeStorage.ts +4 -9
  220. package/src/cache/serializer/Deserializer.ts +1 -5
  221. package/src/client/ClientApplication.ts +24 -10
  222. package/src/client/ClientCredentialClient.ts +14 -6
  223. package/src/client/ConfidentialClientApplication.ts +10 -5
  224. package/src/client/ManagedIdentityApplication.ts +8 -16
  225. package/src/client/ManagedIdentityClient.ts +23 -11
  226. package/src/client/ManagedIdentitySources/AppService.ts +68 -97
  227. package/src/client/ManagedIdentitySources/AzureArc.ts +59 -68
  228. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +82 -11
  229. package/src/client/ManagedIdentitySources/CloudShell.ts +93 -8
  230. package/src/client/ManagedIdentitySources/Imds.ts +54 -40
  231. package/src/client/ManagedIdentitySources/ServiceFabric.ts +126 -5
  232. package/src/client/OnBehalfOfClient.ts +18 -7
  233. package/src/client/UsernamePasswordClient.ts +16 -7
  234. package/src/config/Configuration.ts +50 -18
  235. package/src/config/ManagedIdentityRequestParameters.ts +1 -6
  236. package/src/error/ManagedIdentityError.ts +15 -4
  237. package/src/error/ManagedIdentityErrorCodes.ts +19 -1
  238. package/src/index.ts +1 -0
  239. package/src/network/HttpClient.ts +27 -39
  240. package/src/network/HttpClientWithRetries.ts +80 -0
  241. package/src/packageMetadata.ts +1 -1
  242. package/src/request/ClientCredentialRequest.ts +6 -3
  243. package/src/retry/IHttpRetryPolicy.ts +18 -0
  244. package/src/retry/LinearRetryPolicy.ts +71 -0
  245. package/src/utils/Constants.ts +47 -10
@@ -1,42 +1,42 @@
1
- /*! @azure/msal-node v2.7.0-alpha.0 2023-12-15 */
1
+ /*! @azure/msal-node v2.7.1-alpha.0 2024-05-01 */
2
2
  'use strict';
3
- /*
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Licensed under the MIT License.
6
- */
7
- class NetworkUtils {
8
- static getNetworkResponse(headers, body, statusCode) {
9
- return {
10
- headers: headers,
11
- body: body,
12
- status: statusCode,
13
- };
14
- }
15
- /*
16
- * Utility function that converts a URL object into an ordinary options object as expected by the
17
- * http.request and https.request APIs.
18
- * https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
19
- */
20
- static urlToHttpOptions(url) {
21
- const options = {
22
- protocol: url.protocol,
23
- hostname: url.hostname && url.hostname.startsWith("[")
24
- ? url.hostname.slice(1, -1)
25
- : url.hostname,
26
- hash: url.hash,
27
- search: url.search,
28
- pathname: url.pathname,
29
- path: `${url.pathname || ""}${url.search || ""}`,
30
- href: url.href,
31
- };
32
- if (url.port !== "") {
33
- options.port = Number(url.port);
34
- }
35
- if (url.username || url.password) {
36
- options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
37
- }
38
- return options;
39
- }
3
+ /*
4
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5
+ * Licensed under the MIT License.
6
+ */
7
+ class NetworkUtils {
8
+ static getNetworkResponse(headers, body, statusCode) {
9
+ return {
10
+ headers: headers,
11
+ body: body,
12
+ status: statusCode,
13
+ };
14
+ }
15
+ /*
16
+ * Utility function that converts a URL object into an ordinary options object as expected by the
17
+ * http.request and https.request APIs.
18
+ * https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
19
+ */
20
+ static urlToHttpOptions(url) {
21
+ const options = {
22
+ protocol: url.protocol,
23
+ hostname: url.hostname && url.hostname.startsWith("[")
24
+ ? url.hostname.slice(1, -1)
25
+ : url.hostname,
26
+ hash: url.hash,
27
+ search: url.search,
28
+ pathname: url.pathname,
29
+ path: `${url.pathname || ""}${url.search || ""}`,
30
+ href: url.href,
31
+ };
32
+ if (url.port !== "") {
33
+ options.port = Number(url.port);
34
+ }
35
+ if (url.username || url.password) {
36
+ options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
37
+ }
38
+ return options;
39
+ }
40
40
  }
41
41
 
42
42
  export { NetworkUtils };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@azure/msal-node",
4
- "version": "2.7.0-alpha.0",
4
+ "version": "2.7.1-alpha.0",
5
5
  "author": {
6
6
  "name": "Microsoft",
7
7
  "email": "nugetaad@microsoft.com",
@@ -49,8 +49,8 @@
49
49
  "lint:fix": "npm run lint -- --fix",
50
50
  "build:all": "cd ../.. && npm run build --workspace=@azure/msal-common --workspace=@azure/msal-node",
51
51
  "prepack": "npm run build:all",
52
- "format:check": "npx prettier --ignore-path .gitignore --check src test",
53
- "format:fix": "npx prettier --ignore-path .gitignore --write src test"
52
+ "format:check": "prettier --ignore-path .gitignore --check src test",
53
+ "format:fix": "prettier --ignore-path .gitignore --write src test"
54
54
  },
55
55
  "beachball": {
56
56
  "disallowedChangeTypes": [
@@ -66,7 +66,7 @@
66
66
  "@types/node": "^20.3.1",
67
67
  "@types/sinon": "^7.5.0",
68
68
  "@types/uuid": "^7.0.0",
69
- "eslint-config-msal": "^0.0.0",
69
+ "eslint-config-msal": "file:../../shared-configs/eslint-config-msal",
70
70
  "jest": "^29.5.0",
71
71
  "prettier": "2.8.7",
72
72
  "rollup": "^3.20.1",
@@ -77,7 +77,7 @@
77
77
  "yargs": "^17.3.1"
78
78
  },
79
79
  "dependencies": {
80
- "@azure/msal-common": "14.6.0-alpha.0",
80
+ "@azure/msal-common": "14.9.1-alpha.0",
81
81
  "jsonwebtoken": "^9.0.0",
82
82
  "uuid": "^8.3.0"
83
83
  },
@@ -91,7 +91,7 @@ export class NodeStorage extends CacheManager {
91
91
  inMemoryCache.accessTokens[key] = value as AccessTokenEntity;
92
92
  } else if (CacheHelpers.isRefreshTokenEntity(value)) {
93
93
  inMemoryCache.refreshTokens[key] = value as RefreshTokenEntity;
94
- } else if (value instanceof AppMetadataEntity) {
94
+ } else if (CacheHelpers.isAppMetadataEntity(key, value)) {
95
95
  inMemoryCache.appMetadata[key] = value as AppMetadataEntity;
96
96
  } else {
97
97
  continue;
@@ -322,9 +322,7 @@ export class NodeStorage extends CacheManager {
322
322
  const appMetadata: AppMetadataEntity = this.getItem(
323
323
  appMetadataKey
324
324
  ) as AppMetadataEntity;
325
- if (
326
- AppMetadataEntity.isAppMetadataEntity(appMetadataKey, appMetadata)
327
- ) {
325
+ if (CacheHelpers.isAppMetadataEntity(appMetadataKey, appMetadata)) {
328
326
  return appMetadata;
329
327
  }
330
328
  return null;
@@ -335,7 +333,7 @@ export class NodeStorage extends CacheManager {
335
333
  * @param appMetadata - cache value to be set of type AppMetadataEntity
336
334
  */
337
335
  setAppMetadata(appMetadata: AppMetadataEntity): void {
338
- const appMetadataKey = appMetadata.generateAppMetadataKey();
336
+ const appMetadataKey = CacheHelpers.generateAppMetadataKey(appMetadata);
339
337
  this.setItem(appMetadataKey, appMetadata);
340
338
  }
341
339
 
@@ -383,10 +381,7 @@ export class NodeStorage extends CacheManager {
383
381
  ) as AuthorityMetadataEntity;
384
382
  if (
385
383
  authorityMetadataEntity &&
386
- AuthorityMetadataEntity.isAuthorityMetadataEntity(
387
- key,
388
- authorityMetadataEntity
389
- )
384
+ CacheHelpers.isAuthorityMetadataEntity(key, authorityMetadataEntity)
390
385
  ) {
391
386
  return authorityMetadataEntity;
392
387
  }
@@ -13,7 +13,6 @@ import {
13
13
  IdTokenEntity,
14
14
  AccessTokenEntity,
15
15
  RefreshTokenEntity,
16
- AppMetadataEntity,
17
16
  CacheManager,
18
17
  CredentialType,
19
18
  AuthenticationScheme,
@@ -181,14 +180,11 @@ export class Deserializer {
181
180
  if (appMetadata) {
182
181
  Object.keys(appMetadata).map(function (key) {
183
182
  const serializedAmdt = appMetadata[key];
184
- const mappedAmd = {
183
+ appMetadataObjects[key] = {
185
184
  clientId: serializedAmdt.client_id,
186
185
  environment: serializedAmdt.environment,
187
186
  familyId: serializedAmdt.family_id,
188
187
  };
189
- const amd: AppMetadataEntity = new AppMetadataEntity();
190
- CacheManager.toObject(amd, mappedAmd);
191
- appMetadataObjects[key] = amd;
192
188
  });
193
189
  }
194
190
 
@@ -33,6 +33,9 @@ import {
33
33
  createClientAuthError,
34
34
  ClientAuthErrorCodes,
35
35
  buildStaticAuthorityOptions,
36
+ ClientAssertion as ClientAssertionType,
37
+ getClientAssertion,
38
+ ClientAssertionCallback,
36
39
  } from "@azure/msal-common";
37
40
  import {
38
41
  Configuration,
@@ -77,6 +80,9 @@ export abstract class ClientApplication {
77
80
  * Client assertion passed by the user for confidential client flows
78
81
  */
79
82
  protected clientAssertion: ClientAssertion;
83
+ protected developerProvidedClientAssertion:
84
+ | string
85
+ | ClientAssertionCallback;
80
86
  /**
81
87
  * Client secret passed by the user for confidential client flows
82
88
  */
@@ -396,7 +402,7 @@ export abstract class ClientApplication {
396
402
  */
397
403
  protected async buildOauthClientConfiguration(
398
404
  authority: string,
399
- requestCorrelationId?: string,
405
+ requestCorrelationId: string,
400
406
  serverTelemetryManager?: ServerTelemetryManager,
401
407
  azureRegionConfiguration?: AzureRegionConfiguration,
402
408
  azureCloudOptions?: AzureCloudOptions
@@ -414,8 +420,8 @@ export abstract class ClientApplication {
414
420
  // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
415
421
  const discoveredAuthority = await this.createAuthority(
416
422
  authority,
417
- azureRegionConfiguration,
418
423
  requestCorrelationId,
424
+ azureRegionConfiguration,
419
425
  userAzureCloudOptions
420
426
  );
421
427
 
@@ -451,8 +457,8 @@ export abstract class ClientApplication {
451
457
  serverTelemetryManager: serverTelemetryManager,
452
458
  clientCredentials: {
453
459
  clientSecret: this.clientSecret,
454
- clientAssertion: this.clientAssertion
455
- ? this.getClientAssertion(discoveredAuthority)
460
+ clientAssertion: this.developerProvidedClientAssertion
461
+ ? await this.getClientAssertion(discoveredAuthority)
456
462
  : undefined,
457
463
  },
458
464
  libraryInfo: {
@@ -469,10 +475,17 @@ export abstract class ClientApplication {
469
475
  return clientConfiguration;
470
476
  }
471
477
 
472
- private getClientAssertion(authority: Authority): {
473
- assertion: string;
474
- assertionType: string;
475
- } {
478
+ private async getClientAssertion(
479
+ authority: Authority
480
+ ): Promise<ClientAssertionType> {
481
+ this.clientAssertion = ClientAssertion.fromAssertion(
482
+ await getClientAssertion(
483
+ this.developerProvidedClientAssertion,
484
+ this.config.auth.clientId,
485
+ authority.tokenEndpoint
486
+ )
487
+ );
488
+
476
489
  return {
477
490
  assertion: this.clientAssertion.getJwt(
478
491
  this.cryptoProvider,
@@ -559,8 +572,8 @@ export abstract class ClientApplication {
559
572
  */
560
573
  private async createAuthority(
561
574
  authorityString: string,
575
+ requestCorrelationId: string,
562
576
  azureRegionConfiguration?: AzureRegionConfiguration,
563
- requestCorrelationId?: string,
564
577
  azureCloudOptions?: AzureCloudOptions
565
578
  ): Promise<Authority> {
566
579
  this.logger.verbose("createAuthority called", requestCorrelationId);
@@ -586,7 +599,8 @@ export abstract class ClientApplication {
586
599
  this.config.system.networkClient,
587
600
  this.storage,
588
601
  authorityOptions,
589
- this.logger
602
+ this.logger,
603
+ requestCorrelationId
590
604
  );
591
605
  }
592
606
 
@@ -32,6 +32,8 @@ import {
32
32
  TokenCacheContext,
33
33
  UrlString,
34
34
  createClientAuthError,
35
+ ClientAssertion,
36
+ getClientAssertion,
35
37
  } from "@azure/msal-common";
36
38
  import {
37
39
  ManagedIdentityConfiguration,
@@ -59,7 +61,7 @@ export class ClientCredentialClient extends BaseClient {
59
61
  public async acquireToken(
60
62
  request: CommonClientCredentialRequest
61
63
  ): Promise<AuthenticationResult | null> {
62
- if (request.skipCache) {
64
+ if (request.skipCache || request.claims) {
63
65
  return this.executeTokenRequest(request, this.authority);
64
66
  }
65
67
 
@@ -270,7 +272,7 @@ export class ClientCredentialClient extends BaseClient {
270
272
  queryParametersString
271
273
  );
272
274
 
273
- const requestBody = this.createTokenRequestBody(request);
275
+ const requestBody = await this.createTokenRequestBody(request);
274
276
  const headers: Record<string, string> =
275
277
  this.createTokenRequestHeaders();
276
278
  const thumbprint: RequestThumbprint = {
@@ -330,9 +332,9 @@ export class ClientCredentialClient extends BaseClient {
330
332
  * generate the request to the server in the acceptable format
331
333
  * @param request
332
334
  */
333
- private createTokenRequestBody(
335
+ private async createTokenRequestBody(
334
336
  request: CommonClientCredentialRequest
335
- ): string {
337
+ ): Promise<string> {
336
338
  const parameterBuilder = new RequestParameterBuilder();
337
339
 
338
340
  parameterBuilder.addClientId(this.config.authOptions.clientId);
@@ -364,12 +366,18 @@ export class ClientCredentialClient extends BaseClient {
364
366
  }
365
367
 
366
368
  // Use clientAssertion from request, fallback to client assertion in base configuration
367
- const clientAssertion =
369
+ const clientAssertion: ClientAssertion | undefined =
368
370
  request.clientAssertion ||
369
371
  this.config.clientCredentials.clientAssertion;
370
372
 
371
373
  if (clientAssertion) {
372
- parameterBuilder.addClientAssertion(clientAssertion.assertion);
374
+ parameterBuilder.addClientAssertion(
375
+ await getClientAssertion(
376
+ clientAssertion.assertion,
377
+ this.config.authOptions.clientId,
378
+ request.resourceRequestUri
379
+ )
380
+ );
373
381
  parameterBuilder.addClientAssertionType(
374
382
  clientAssertion.assertionType
375
383
  );
@@ -26,6 +26,8 @@ import {
26
26
  AADAuthorityConstants,
27
27
  createClientAuthError,
28
28
  ClientAuthErrorCodes,
29
+ ClientAssertion as ClientAssertionType,
30
+ getClientAssertion,
29
31
  } from "@azure/msal-common";
30
32
  import { IConfidentialClientApplication } from "./IConfidentialClientApplication.js";
31
33
  import { OnBehalfOfRequest } from "../request/OnBehalfOfRequest.js";
@@ -91,10 +93,14 @@ export class ConfidentialClientApplication
91
93
  );
92
94
 
93
95
  // If there is a client assertion present in the request, it overrides the one present in the client configuration
94
- let clientAssertion;
96
+ let clientAssertion: ClientAssertionType | undefined;
95
97
  if (request.clientAssertion) {
96
98
  clientAssertion = {
97
- assertion: request.clientAssertion,
99
+ assertion: await getClientAssertion(
100
+ request.clientAssertion,
101
+ this.config.auth.clientId
102
+ // tokenEndpoint will be undefined. resourceRequestUri is omitted in ClientCredentialRequest
103
+ ),
98
104
  assertionType: NodeConstants.JWT_BEARER_ASSERTION_TYPE,
99
105
  };
100
106
  }
@@ -247,9 +253,8 @@ export class ConfidentialClientApplication
247
253
  }
248
254
 
249
255
  if (configuration.auth.clientAssertion) {
250
- this.clientAssertion = ClientAssertion.fromAssertion(
251
- configuration.auth.clientAssertion
252
- );
256
+ this.developerProvidedClientAssertion =
257
+ configuration.auth.clientAssertion;
253
258
  return;
254
259
  }
255
260
 
@@ -16,7 +16,8 @@ import {
16
16
  ProtocolMode,
17
17
  StaticAuthorityOptions,
18
18
  AuthenticationResult,
19
- UrlString,
19
+ createClientConfigurationError,
20
+ ClientConfigurationErrorCodes,
20
21
  } from "@azure/msal-common";
21
22
  import {
22
23
  ManagedIdentityConfiguration,
@@ -31,10 +32,6 @@ import { ManagedIdentityClient } from "./ManagedIdentityClient";
31
32
  import { ManagedIdentityRequestParams } from "../request/ManagedIdentityRequestParams";
32
33
  import { NodeStorage } from "../cache/NodeStorage";
33
34
  import { DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY } from "../utils/Constants";
34
- import {
35
- ManagedIdentityErrorCodes,
36
- createManagedIdentityError,
37
- } from "../error/ManagedIdentityError";
38
35
 
39
36
  /**
40
37
  * Class to initialize a managed identity and identify the service
@@ -43,7 +40,7 @@ export class ManagedIdentityApplication {
43
40
  private config: ManagedIdentityNodeConfiguration;
44
41
 
45
42
  private logger: Logger;
46
- private static nodeStorage: NodeStorage | undefined;
43
+ private static nodeStorage?: NodeStorage;
47
44
  private networkClient: INetworkModule;
48
45
  private cryptoProvider: CryptoProvider;
49
46
 
@@ -94,7 +91,7 @@ export class ManagedIdentityApplication {
94
91
  ManagedIdentityApplication.nodeStorage as NodeStorage,
95
92
  fakeAuthorityOptions,
96
93
  this.logger,
97
- undefined,
94
+ this.cryptoProvider.createNewGuid(), // correlationID
98
95
  undefined,
99
96
  true
100
97
  );
@@ -122,14 +119,9 @@ export class ManagedIdentityApplication {
122
119
  public async acquireToken(
123
120
  managedIdentityRequestParams: ManagedIdentityRequestParams
124
121
  ): Promise<AuthenticationResult> {
125
- const resourceUrlString = new UrlString(
126
- managedIdentityRequestParams.resource.replace("/.default", "")
127
- );
128
- try {
129
- resourceUrlString.validateAsUri();
130
- } catch (e) {
131
- throw createManagedIdentityError(
132
- ManagedIdentityErrorCodes.invalidResource
122
+ if (!managedIdentityRequestParams.resource) {
123
+ throw createClientConfigurationError(
124
+ ClientConfigurationErrorCodes.urlEmptyError
133
125
  );
134
126
  }
135
127
 
@@ -143,7 +135,7 @@ export class ManagedIdentityApplication {
143
135
  managedIdentityRequestParams.resource.replace("/.default", ""),
144
136
  ],
145
137
  authority: this.fakeAuthority.canonicalAuthority,
146
- correlationId: this.config.managedIdentityId.id,
138
+ correlationId: this.cryptoProvider.createNewGuid(),
147
139
  };
148
140
 
149
141
  if (managedIdentityRequest.forceRefresh) {
@@ -22,6 +22,7 @@ import {
22
22
  import { ManagedIdentityRequest } from "../request/ManagedIdentityRequest";
23
23
  import { ManagedIdentityId } from "../config/ManagedIdentityId";
24
24
  import { NodeStorage } from "../cache/NodeStorage";
25
+ import { BaseManagedIdentitySource } from "./ManagedIdentitySources/BaseManagedIdentitySource";
25
26
 
26
27
  /*
27
28
  * Class to initialize a managed identity and identify the service.
@@ -33,13 +34,7 @@ export class ManagedIdentityClient {
33
34
  private networkClient: INetworkModule;
34
35
  private cryptoProvider: CryptoProvider;
35
36
 
36
- static identitySource:
37
- | ServiceFabric
38
- | AppService
39
- | CloudShell
40
- | AzureArc
41
- | Imds
42
- | undefined;
37
+ private static identitySource?: BaseManagedIdentitySource;
43
38
 
44
39
  constructor(
45
40
  logger: Logger,
@@ -65,7 +60,8 @@ export class ManagedIdentityClient {
65
60
  this.logger,
66
61
  this.nodeStorage,
67
62
  this.networkClient,
68
- this.cryptoProvider
63
+ this.cryptoProvider,
64
+ managedIdentityId
69
65
  );
70
66
  }
71
67
 
@@ -85,20 +81,36 @@ export class ManagedIdentityClient {
85
81
  logger: Logger,
86
82
  nodeStorage: NodeStorage,
87
83
  networkClient: INetworkModule,
88
- cryptoProvider: CryptoProvider
89
- ): ServiceFabric | AppService | CloudShell | AzureArc | Imds {
84
+ cryptoProvider: CryptoProvider,
85
+ managedIdentityId: ManagedIdentityId
86
+ ): BaseManagedIdentitySource {
90
87
  const source =
88
+ ServiceFabric.tryCreate(
89
+ logger,
90
+ nodeStorage,
91
+ networkClient,
92
+ cryptoProvider,
93
+ managedIdentityId
94
+ ) ||
91
95
  AppService.tryCreate(
92
96
  logger,
93
97
  nodeStorage,
94
98
  networkClient,
95
99
  cryptoProvider
96
100
  ) ||
101
+ CloudShell.tryCreate(
102
+ logger,
103
+ nodeStorage,
104
+ networkClient,
105
+ cryptoProvider,
106
+ managedIdentityId
107
+ ) ||
97
108
  AzureArc.tryCreate(
98
109
  logger,
99
110
  nodeStorage,
100
111
  networkClient,
101
- cryptoProvider
112
+ cryptoProvider,
113
+ managedIdentityId
102
114
  ) ||
103
115
  Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);
104
116
  if (!source) {