@azure/msal-node 2.5.1 → 2.7.0-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 (265) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +423 -405
  3. package/dist/cache/NodeStorage.cjs.map +1 -1
  4. package/dist/cache/NodeStorage.d.ts +193 -182
  5. package/dist/cache/NodeStorage.d.ts.map +1 -1
  6. package/dist/cache/NodeStorage.mjs +424 -406
  7. package/dist/cache/NodeStorage.mjs.map +1 -1
  8. package/dist/cache/TokenCache.cjs +265 -265
  9. package/dist/cache/TokenCache.cjs.map +1 -1
  10. package/dist/cache/TokenCache.d.ts +90 -90
  11. package/dist/cache/TokenCache.mjs +265 -265
  12. package/dist/cache/TokenCache.mjs.map +1 -1
  13. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  14. package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
  15. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  16. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  17. package/dist/cache/distributed/DistributedCachePlugin.mjs.map +1 -1
  18. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  19. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  20. package/dist/cache/serializer/Deserializer.cjs +170 -167
  21. package/dist/cache/serializer/Deserializer.cjs.map +1 -1
  22. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  23. package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
  24. package/dist/cache/serializer/Deserializer.mjs +170 -167
  25. package/dist/cache/serializer/Deserializer.mjs.map +1 -1
  26. package/dist/cache/serializer/Serializer.cjs +137 -134
  27. package/dist/cache/serializer/Serializer.cjs.map +1 -1
  28. package/dist/cache/serializer/Serializer.d.ts +39 -39
  29. package/dist/cache/serializer/Serializer.d.ts.map +1 -1
  30. package/dist/cache/serializer/Serializer.mjs +137 -134
  31. package/dist/cache/serializer/Serializer.mjs.map +1 -1
  32. package/dist/cache/serializer/SerializerTypes.d.ts +102 -101
  33. package/dist/cache/serializer/SerializerTypes.d.ts.map +1 -1
  34. package/dist/client/ClientApplication.cjs +333 -333
  35. package/dist/client/ClientApplication.cjs.map +1 -1
  36. package/dist/client/ClientApplication.d.ts +142 -142
  37. package/dist/client/ClientApplication.d.ts.map +1 -1
  38. package/dist/client/ClientApplication.mjs +333 -333
  39. package/dist/client/ClientApplication.mjs.map +1 -1
  40. package/dist/client/ClientAssertion.cjs +116 -116
  41. package/dist/client/ClientAssertion.cjs.map +1 -1
  42. package/dist/client/ClientAssertion.d.ts +46 -46
  43. package/dist/client/ClientAssertion.mjs +116 -116
  44. package/dist/client/ClientAssertion.mjs.map +1 -1
  45. package/dist/client/ClientCredentialClient.cjs +194 -189
  46. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  47. package/dist/client/ClientCredentialClient.d.ts +33 -33
  48. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  49. package/dist/client/ClientCredentialClient.mjs +195 -190
  50. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  51. package/dist/client/ConfidentialClientApplication.cjs +163 -163
  52. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  53. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  54. package/dist/client/ConfidentialClientApplication.mjs +163 -163
  55. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  56. package/dist/client/DeviceCodeClient.cjs +207 -207
  57. package/dist/client/DeviceCodeClient.cjs.map +1 -1
  58. package/dist/client/DeviceCodeClient.d.ts +53 -53
  59. package/dist/client/DeviceCodeClient.mjs +207 -207
  60. package/dist/client/DeviceCodeClient.mjs.map +1 -1
  61. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  62. package/dist/client/IPublicClientApplication.d.ts +42 -42
  63. package/dist/client/ManagedIdentityApplication.cjs +96 -0
  64. package/dist/client/ManagedIdentityApplication.cjs.map +1 -0
  65. package/dist/client/ManagedIdentityApplication.d.ts +24 -0
  66. package/dist/client/ManagedIdentityApplication.d.ts.map +1 -0
  67. package/dist/client/ManagedIdentityApplication.mjs +94 -0
  68. package/dist/client/ManagedIdentityApplication.mjs.map +1 -0
  69. package/dist/client/ManagedIdentityClient.cjs +49 -0
  70. package/dist/client/ManagedIdentityClient.cjs.map +1 -0
  71. package/dist/client/ManagedIdentityClient.d.ts +25 -0
  72. package/dist/client/ManagedIdentityClient.d.ts.map +1 -0
  73. package/dist/client/ManagedIdentityClient.mjs +47 -0
  74. package/dist/client/ManagedIdentityClient.mjs.map +1 -0
  75. package/dist/client/ManagedIdentitySources/AppService.cjs +79 -0
  76. package/dist/client/ManagedIdentitySources/AppService.cjs.map +1 -0
  77. package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -0
  78. package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -0
  79. package/dist/client/ManagedIdentitySources/AppService.mjs +77 -0
  80. package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -0
  81. package/dist/client/ManagedIdentitySources/AzureArc.cjs +107 -0
  82. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -0
  83. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +19 -0
  84. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -0
  85. package/dist/client/ManagedIdentitySources/AzureArc.mjs +104 -0
  86. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -0
  87. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +87 -0
  88. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -0
  89. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +19 -0
  90. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -0
  91. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +85 -0
  92. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -0
  93. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +7 -0
  94. package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -0
  95. package/dist/client/ManagedIdentitySources/Imds.cjs +63 -0
  96. package/dist/client/ManagedIdentitySources/Imds.cjs.map +1 -0
  97. package/dist/client/ManagedIdentitySources/Imds.d.ts +13 -0
  98. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -0
  99. package/dist/client/ManagedIdentitySources/Imds.mjs +61 -0
  100. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -0
  101. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +7 -0
  102. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -0
  103. package/dist/client/OnBehalfOfClient.cjs +202 -202
  104. package/dist/client/OnBehalfOfClient.cjs.map +1 -1
  105. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  106. package/dist/client/OnBehalfOfClient.mjs +202 -202
  107. package/dist/client/OnBehalfOfClient.mjs.map +1 -1
  108. package/dist/client/PublicClientApplication.cjs +229 -229
  109. package/dist/client/PublicClientApplication.cjs.map +1 -1
  110. package/dist/client/PublicClientApplication.d.ts +71 -71
  111. package/dist/client/PublicClientApplication.mjs +229 -229
  112. package/dist/client/PublicClientApplication.mjs.map +1 -1
  113. package/dist/client/UsernamePasswordClient.cjs +95 -95
  114. package/dist/client/UsernamePasswordClient.cjs.map +1 -1
  115. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  116. package/dist/client/UsernamePasswordClient.mjs +95 -95
  117. package/dist/client/UsernamePasswordClient.mjs.map +1 -1
  118. package/dist/config/Configuration.cjs +88 -72
  119. package/dist/config/Configuration.cjs.map +1 -1
  120. package/dist/config/Configuration.d.ts +122 -107
  121. package/dist/config/Configuration.d.ts.map +1 -1
  122. package/dist/config/Configuration.mjs +88 -73
  123. package/dist/config/Configuration.mjs.map +1 -1
  124. package/dist/config/ManagedIdentityId.cjs +59 -0
  125. package/dist/config/ManagedIdentityId.cjs.map +1 -0
  126. package/dist/config/ManagedIdentityId.d.ts +12 -0
  127. package/dist/config/ManagedIdentityId.d.ts.map +1 -0
  128. package/dist/config/ManagedIdentityId.mjs +57 -0
  129. package/dist/config/ManagedIdentityId.mjs.map +1 -0
  130. package/dist/config/ManagedIdentityRequestParameters.cjs +38 -0
  131. package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -0
  132. package/dist/config/ManagedIdentityRequestParameters.d.ts +12 -0
  133. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -0
  134. package/dist/config/ManagedIdentityRequestParameters.mjs +36 -0
  135. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -0
  136. package/dist/crypto/CryptoProvider.cjs +75 -75
  137. package/dist/crypto/CryptoProvider.cjs.map +1 -1
  138. package/dist/crypto/CryptoProvider.d.ts +52 -52
  139. package/dist/crypto/CryptoProvider.mjs +75 -75
  140. package/dist/crypto/CryptoProvider.mjs.map +1 -1
  141. package/dist/crypto/GuidGenerator.cjs +22 -22
  142. package/dist/crypto/GuidGenerator.cjs.map +1 -1
  143. package/dist/crypto/GuidGenerator.d.ts +14 -14
  144. package/dist/crypto/GuidGenerator.mjs +22 -22
  145. package/dist/crypto/GuidGenerator.mjs.map +1 -1
  146. package/dist/crypto/HashUtils.cjs +13 -13
  147. package/dist/crypto/HashUtils.cjs.map +1 -1
  148. package/dist/crypto/HashUtils.d.ts +8 -8
  149. package/dist/crypto/HashUtils.mjs +13 -13
  150. package/dist/crypto/HashUtils.mjs.map +1 -1
  151. package/dist/crypto/PkceGenerator.cjs +49 -49
  152. package/dist/crypto/PkceGenerator.cjs.map +1 -1
  153. package/dist/crypto/PkceGenerator.d.ts +22 -22
  154. package/dist/crypto/PkceGenerator.mjs +49 -49
  155. package/dist/crypto/PkceGenerator.mjs.map +1 -1
  156. package/dist/error/ManagedIdentityError.cjs +40 -0
  157. package/dist/error/ManagedIdentityError.cjs.map +1 -0
  158. package/dist/error/ManagedIdentityError.d.ts +22 -0
  159. package/dist/error/ManagedIdentityError.d.ts.map +1 -0
  160. package/dist/error/ManagedIdentityError.mjs +36 -0
  161. package/dist/error/ManagedIdentityError.mjs.map +1 -0
  162. package/dist/error/ManagedIdentityErrorCodes.cjs +28 -0
  163. package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -0
  164. package/dist/error/ManagedIdentityErrorCodes.d.ts +10 -0
  165. package/dist/error/ManagedIdentityErrorCodes.d.ts.map +1 -0
  166. package/dist/error/ManagedIdentityErrorCodes.mjs +18 -0
  167. package/dist/error/ManagedIdentityErrorCodes.mjs.map +1 -0
  168. package/dist/error/NodeAuthError.cjs +85 -85
  169. package/dist/error/NodeAuthError.cjs.map +1 -1
  170. package/dist/error/NodeAuthError.d.ts +65 -65
  171. package/dist/error/NodeAuthError.mjs +85 -85
  172. package/dist/error/NodeAuthError.mjs.map +1 -1
  173. package/dist/index.cjs +3 -1
  174. package/dist/index.cjs.map +1 -1
  175. package/dist/index.d.ts +44 -42
  176. package/dist/index.d.ts.map +1 -1
  177. package/dist/index.mjs +2 -1
  178. package/dist/index.mjs.map +1 -1
  179. package/dist/internals.cjs +8 -8
  180. package/dist/internals.cjs.map +1 -1
  181. package/dist/internals.d.ts +6 -6
  182. package/dist/internals.mjs +8 -8
  183. package/dist/internals.mjs.map +1 -1
  184. package/dist/network/HttpClient.cjs +283 -276
  185. package/dist/network/HttpClient.cjs.map +1 -1
  186. package/dist/network/HttpClient.d.ts +26 -25
  187. package/dist/network/HttpClient.d.ts.map +1 -1
  188. package/dist/network/HttpClient.mjs +283 -276
  189. package/dist/network/HttpClient.mjs.map +1 -1
  190. package/dist/network/ILoopbackClient.d.ts +10 -10
  191. package/dist/network/LoopbackClient.cjs +77 -77
  192. package/dist/network/LoopbackClient.cjs.map +1 -1
  193. package/dist/network/LoopbackClient.d.ts +21 -21
  194. package/dist/network/LoopbackClient.mjs +77 -77
  195. package/dist/network/LoopbackClient.mjs.map +1 -1
  196. package/dist/packageMetadata.cjs +4 -4
  197. package/dist/packageMetadata.cjs.map +1 -1
  198. package/dist/packageMetadata.d.ts +2 -2
  199. package/dist/packageMetadata.d.ts.map +1 -1
  200. package/dist/packageMetadata.mjs +4 -4
  201. package/dist/packageMetadata.mjs.map +1 -1
  202. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  203. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  204. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  205. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  206. package/dist/request/InteractiveRequest.d.ts +22 -22
  207. package/dist/request/ManagedIdentityRequest.d.ts +9 -0
  208. package/dist/request/ManagedIdentityRequest.d.ts.map +1 -0
  209. package/dist/request/ManagedIdentityRequestParams.d.ts +10 -0
  210. package/dist/request/ManagedIdentityRequestParams.d.ts.map +1 -0
  211. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  212. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  213. package/dist/request/SignOutRequest.d.ts +5 -5
  214. package/dist/request/SilentFlowRequest.d.ts +16 -16
  215. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  216. package/dist/response/ManagedIdentityTokenResponse.d.ts +25 -0
  217. package/dist/response/ManagedIdentityTokenResponse.d.ts.map +1 -0
  218. package/dist/utils/Constants.cjs +109 -80
  219. package/dist/utils/Constants.cjs.map +1 -1
  220. package/dist/utils/Constants.d.ts +106 -86
  221. package/dist/utils/Constants.d.ts.map +1 -1
  222. package/dist/utils/Constants.mjs +100 -81
  223. package/dist/utils/Constants.mjs.map +1 -1
  224. package/dist/utils/EncodingUtils.cjs +44 -44
  225. package/dist/utils/EncodingUtils.cjs.map +1 -1
  226. package/dist/utils/EncodingUtils.d.ts +26 -26
  227. package/dist/utils/EncodingUtils.mjs +44 -44
  228. package/dist/utils/EncodingUtils.mjs.map +1 -1
  229. package/dist/utils/NetworkUtils.cjs +38 -38
  230. package/dist/utils/NetworkUtils.cjs.map +1 -1
  231. package/dist/utils/NetworkUtils.d.ts +5 -5
  232. package/dist/utils/NetworkUtils.mjs +38 -38
  233. package/dist/utils/NetworkUtils.mjs.map +1 -1
  234. package/package.json +3 -3
  235. package/src/cache/NodeStorage.ts +24 -7
  236. package/src/cache/TokenCache.ts +1 -1
  237. package/src/cache/serializer/Deserializer.ts +5 -0
  238. package/src/cache/serializer/Serializer.ts +5 -0
  239. package/src/cache/serializer/SerializerTypes.ts +1 -0
  240. package/src/client/ClientApplication.ts +10 -9
  241. package/src/client/ClientCredentialClient.ts +72 -27
  242. package/src/client/ConfidentialClientApplication.ts +2 -2
  243. package/src/client/DeviceCodeClient.ts +1 -1
  244. package/src/client/ManagedIdentityApplication.ts +194 -0
  245. package/src/client/ManagedIdentityClient.ts +111 -0
  246. package/src/client/ManagedIdentitySources/AppService.ts +151 -0
  247. package/src/client/ManagedIdentitySources/AzureArc.ts +208 -0
  248. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +169 -0
  249. package/src/client/ManagedIdentitySources/CloudShell.ts +19 -0
  250. package/src/client/ManagedIdentitySources/Imds.ts +112 -0
  251. package/src/client/ManagedIdentitySources/ServiceFabric.ts +19 -0
  252. package/src/client/OnBehalfOfClient.ts +5 -5
  253. package/src/client/PublicClientApplication.ts +1 -1
  254. package/src/config/Configuration.ts +47 -1
  255. package/src/config/ManagedIdentityId.ts +73 -0
  256. package/src/config/ManagedIdentityRequestParameters.ts +53 -0
  257. package/src/error/ManagedIdentityError.ts +46 -0
  258. package/src/error/ManagedIdentityErrorCodes.ts +15 -0
  259. package/src/index.ts +4 -0
  260. package/src/network/HttpClient.ts +17 -5
  261. package/src/packageMetadata.ts +1 -1
  262. package/src/request/ManagedIdentityRequest.ts +15 -0
  263. package/src/request/ManagedIdentityRequestParams.ts +14 -0
  264. package/src/response/ManagedIdentityTokenResponse.ts +33 -0
  265. package/src/utils/Constants.ts +27 -0
@@ -1 +1 @@
1
- {"version":3,"file":"EncodingUtils.mjs","sources":["../../src/utils/EncodingUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAOA;AACI;;;;AAKG;AACH;AAIA;;;AAGG,IAAA,OAAA,YAAA,CAAA,GAAA,EAAA,QAAA,EAAA;AACH,QAAA,OAAO,MAAA,CAAA,IAAe,CAAC,GAAG,EAAE,QAAQ,CAAA,CAAA,QAAS,CAAE,QAAc,CAAA,CAAA;AAO7D,KAAA;;;;;AAKG,IAAA,OAAA,eAAA,CAAA,GAAA,EAAA,QAAA,EAAA;AACH,QAAA,OAAmB,0BAAkB,IAAS,EAAA,QAAA,CAAA;AAI9C,aAAA,OAAA,CAAA,IAAA,EAAA,SAAA,CAAA,YAAA,CAAA;;AAEG,aAAA,OAAA,CAAA,KAAA,EAAA,GAAA,CAAA,CAAA;AACH,KAAA;AAOH;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"EncodingUtils.mjs","sources":["../../src/utils/EncodingUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;MAIU,aAAa,CAAA;AACtB;;;;;AAKG;AACH,IAAA,OAAO,YAAY,CAAC,GAAW,EAAE,QAAyB,EAAA;AACtD,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACxD;AAED;;;AAGG;AACH,IAAA,OAAO,eAAe,CAAC,GAAW,EAAE,QAAyB,EAAA;AACzD,QAAA,OAAO,aAAa,CAAC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC;AAC3C,aAAA,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,YAAY,CAAC;AACrC,aAAA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AACnB,aAAA,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KAC5B;AAED;;;;;AAKG;IACH,OAAO,YAAY,CAAC,SAAiB,EAAA;AACjC,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAC5D;AAED;;AAEG;IACH,OAAO,eAAe,CAAC,SAAiB,EAAA;AACpC,QAAA,IAAI,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC1D,QAAA,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,GAAG,IAAI,GAAG,CAAC;AACd,SAAA;AACD,QAAA,OAAO,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;KAC1C;AACJ;;;;"}
@@ -1,44 +1,44 @@
1
- /*! @azure/msal-node v2.5.1 2023-11-07 */
1
+ /*! @azure/msal-node v2.7.0-alpha.0 2023-12-15 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
- /*
6
- * Copyright (c) Microsoft Corporation. All rights reserved.
7
- * Licensed under the MIT License.
8
- */
9
- class NetworkUtils {
10
- static getNetworkResponse(headers, body, statusCode) {
11
- return {
12
- headers: headers,
13
- body: body,
14
- status: statusCode,
15
- };
16
- }
17
- /*
18
- * Utility function that converts a URL object into an ordinary options object as expected by the
19
- * http.request and https.request APIs.
20
- * https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
21
- */
22
- static urlToHttpOptions(url) {
23
- const options = {
24
- protocol: url.protocol,
25
- hostname: url.hostname && url.hostname.startsWith("[")
26
- ? url.hostname.slice(1, -1)
27
- : url.hostname,
28
- hash: url.hash,
29
- search: url.search,
30
- pathname: url.pathname,
31
- path: `${url.pathname || ""}${url.search || ""}`,
32
- href: url.href,
33
- };
34
- if (url.port !== "") {
35
- options.port = Number(url.port);
36
- }
37
- if (url.username || url.password) {
38
- options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
39
- }
40
- return options;
41
- }
5
+ /*
6
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7
+ * Licensed under the MIT License.
8
+ */
9
+ class NetworkUtils {
10
+ static getNetworkResponse(headers, body, statusCode) {
11
+ return {
12
+ headers: headers,
13
+ body: body,
14
+ status: statusCode,
15
+ };
16
+ }
17
+ /*
18
+ * Utility function that converts a URL object into an ordinary options object as expected by the
19
+ * http.request and https.request APIs.
20
+ * https://github.com/nodejs/node/blob/main/lib/internal/url.js#L1090
21
+ */
22
+ static urlToHttpOptions(url) {
23
+ const options = {
24
+ protocol: url.protocol,
25
+ hostname: url.hostname && url.hostname.startsWith("[")
26
+ ? url.hostname.slice(1, -1)
27
+ : url.hostname,
28
+ hash: url.hash,
29
+ search: url.search,
30
+ pathname: url.pathname,
31
+ path: `${url.pathname || ""}${url.search || ""}`,
32
+ href: url.href,
33
+ };
34
+ if (url.port !== "") {
35
+ options.port = Number(url.port);
36
+ }
37
+ if (url.username || url.password) {
38
+ options.auth = `${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;
39
+ }
40
+ return options;
41
+ }
42
42
  }
43
43
 
44
44
  exports.NetworkUtils = NetworkUtils;
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkUtils.cjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAKA;AAEA;;AAkBI;AAuBH,MAAA,YAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"NetworkUtils.cjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;AAGG;MAIU,YAAY,CAAA;AACrB,IAAA,OAAO,kBAAkB,CACrB,OAA+B,EAC/B,IAAO,EACP,UAAkB,EAAA;QAElB,OAAO;AACH,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,MAAM,EAAE,UAAU;SACrB,CAAC;KACL;AAED;;;;AAIG;IACH,OAAO,gBAAgB,CAAC,GAAQ,EAAA;AAC5B,QAAA,MAAM,OAAO,GAA4B;YACrC,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,QAAQ,EACJ,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;kBACtC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;kBACzB,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAE,CAAA;YAChD,IAAI,EAAE,GAAG,CAAC,IAAI;SACjB,CAAC;AACF,QAAA,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnC,SAAA;AACD,QAAA,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE;AAC9B,YAAA,OAAO,CAAC,IAAI,GAAG,GAAG,kBAAkB,CAChC,GAAG,CAAC,QAAQ,CACf,CAAA,CAAA,EAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC3C,SAAA;AACD,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
@@ -1,6 +1,6 @@
1
- import { NetworkResponse, UrlToHttpRequestOptions } from "@azure/msal-common";
2
- export declare class NetworkUtils {
3
- static getNetworkResponse<T>(headers: Record<string, string>, body: T, statusCode: number): NetworkResponse<T>;
4
- static urlToHttpOptions(url: URL): UrlToHttpRequestOptions;
5
- }
1
+ import { NetworkResponse, UrlToHttpRequestOptions } from "@azure/msal-common";
2
+ export declare class NetworkUtils {
3
+ static getNetworkResponse<T>(headers: Record<string, string>, body: T, statusCode: number): NetworkResponse<T>;
4
+ static urlToHttpOptions(url: URL): UrlToHttpRequestOptions;
5
+ }
6
6
  //# sourceMappingURL=NetworkUtils.d.ts.map
@@ -1,42 +1,42 @@
1
- /*! @azure/msal-node v2.5.1 2023-11-07 */
1
+ /*! @azure/msal-node v2.7.0-alpha.0 2023-12-15 */
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 };
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkUtils.mjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;AAEA;;AAkBI;AAuBH,MAAA,YAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"NetworkUtils.mjs","sources":["../../src/utils/NetworkUtils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;MAIU,YAAY,CAAA;AACrB,IAAA,OAAO,kBAAkB,CACrB,OAA+B,EAC/B,IAAO,EACP,UAAkB,EAAA;QAElB,OAAO;AACH,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,IAAI,EAAE,IAAI;AACV,YAAA,MAAM,EAAE,UAAU;SACrB,CAAC;KACL;AAED;;;;AAIG;IACH,OAAO,gBAAgB,CAAC,GAAQ,EAAA;AAC5B,QAAA,MAAM,OAAO,GAA4B;YACrC,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,QAAQ,EACJ,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;kBACtC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;kBACzB,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;AACtB,YAAA,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAA,EAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAE,CAAA;YAChD,IAAI,EAAE,GAAG,CAAC,IAAI;SACjB,CAAC;AACF,QAAA,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnC,SAAA;AACD,QAAA,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE;AAC9B,YAAA,OAAO,CAAC,IAAI,GAAG,GAAG,kBAAkB,CAChC,GAAG,CAAC,QAAQ,CACf,CAAA,CAAA,EAAI,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC3C,SAAA;AACD,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
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.5.1",
4
+ "version": "2.7.0-alpha.0",
5
5
  "author": {
6
6
  "name": "Microsoft",
7
7
  "email": "nugetaad@microsoft.com",
@@ -77,11 +77,11 @@
77
77
  "yargs": "^17.3.1"
78
78
  },
79
79
  "dependencies": {
80
- "@azure/msal-common": "14.4.0",
80
+ "@azure/msal-common": "14.6.0-alpha.0",
81
81
  "jsonwebtoken": "^9.0.0",
82
82
  "uuid": "^8.3.0"
83
83
  },
84
84
  "engines": {
85
- "node": "16|| 18 || 20"
85
+ "node": ">=16"
86
86
  }
87
87
  }
@@ -218,13 +218,25 @@ export class NodeStorage extends CacheManager {
218
218
  * @param accountKey - lookup key to fetch cache type AccountEntity
219
219
  */
220
220
  getAccount(accountKey: string): AccountEntity | null {
221
- const account = this.getItem(accountKey) as AccountEntity;
222
- if (AccountEntity.isAccountEntity(account)) {
223
- return account;
221
+ const accountEntity = this.getCachedAccountEntity(accountKey);
222
+ if (accountEntity && AccountEntity.isAccountEntity(accountEntity)) {
223
+ return this.updateOutdatedCachedAccount(accountKey, accountEntity);
224
224
  }
225
225
  return null;
226
226
  }
227
227
 
228
+ /**
229
+ * Reads account from cache, builds it into an account entity and returns it.
230
+ * @param accountKey
231
+ * @returns
232
+ */
233
+ getCachedAccountEntity(accountKey: string): AccountEntity | null {
234
+ const cachedAccount = this.getItem(accountKey);
235
+ return cachedAccount
236
+ ? Object.assign(new AccountEntity(), this.getItem(accountKey))
237
+ : null;
238
+ }
239
+
228
240
  /**
229
241
  * set account entity
230
242
  * @param account - cache value to be set of type AccountEntity
@@ -409,10 +421,7 @@ export class NodeStorage extends CacheManager {
409
421
  ) as ThrottlingEntity;
410
422
  if (
411
423
  throttlingCache &&
412
- ThrottlingEntity.isThrottlingEntity(
413
- throttlingCacheKey,
414
- throttlingCache
415
- )
424
+ CacheHelpers.isThrottlingEntity(throttlingCacheKey, throttlingCache)
416
425
  ) {
417
426
  return throttlingCache;
418
427
  }
@@ -456,6 +465,14 @@ export class NodeStorage extends CacheManager {
456
465
  return result;
457
466
  }
458
467
 
468
+ /**
469
+ * Remove account entity from the platform cache if it's outdated
470
+ * @param accountKey
471
+ */
472
+ removeOutdatedAccount(accountKey: string): void {
473
+ this.removeItem(accountKey);
474
+ }
475
+
459
476
  /**
460
477
  * Checks whether key is in cache.
461
478
  * @param key - look up key for a cache entity
@@ -124,7 +124,7 @@ export class TokenCache implements ISerializableTokenCache, ITokenCache {
124
124
  let cacheContext;
125
125
  try {
126
126
  if (this.persistence) {
127
- cacheContext = new TokenCacheContext(this, false);
127
+ cacheContext = new TokenCacheContext(this, true);
128
128
  await this.persistence.beforeCacheAccess(cacheContext);
129
129
  }
130
130
  return this.storage.getAllAccounts();
@@ -63,6 +63,11 @@ export class Deserializer {
63
63
  clientInfo: serializedAcc.client_info,
64
64
  lastModificationTime: serializedAcc.last_modification_time,
65
65
  lastModificationApp: serializedAcc.last_modification_app,
66
+ tenantProfiles: serializedAcc.tenantProfiles?.map(
67
+ (serializedTenantProfile) => {
68
+ return JSON.parse(serializedTenantProfile);
69
+ }
70
+ ),
66
71
  };
67
72
  const account: AccountEntity = new AccountEntity();
68
73
  CacheManager.toObject(account, mappedAcc);
@@ -50,6 +50,11 @@ export class Serializer {
50
50
  client_info: accountEntity.clientInfo,
51
51
  last_modification_time: accountEntity.lastModificationTime,
52
52
  last_modification_app: accountEntity.lastModificationApp,
53
+ tenantProfiles: accountEntity.tenantProfiles?.map(
54
+ (tenantProfile) => {
55
+ return JSON.stringify(tenantProfile);
56
+ }
57
+ ),
53
58
  };
54
59
  });
55
60
 
@@ -57,6 +57,7 @@ export type SerializedAccountEntity = {
57
57
  client_info?: string;
58
58
  last_modification_time?: string;
59
59
  last_modification_app?: string;
60
+ tenantProfiles?: string[];
60
61
  };
61
62
 
62
63
  /**
@@ -185,7 +185,7 @@ export abstract class ClientApplication {
185
185
  "Auth code client created",
186
186
  validRequest.correlationId
187
187
  );
188
- return authorizationCodeClient.acquireToken(
188
+ return await authorizationCodeClient.acquireToken(
189
189
  validRequest,
190
190
  authCodePayLoad
191
191
  );
@@ -238,7 +238,7 @@ export abstract class ClientApplication {
238
238
  "Refresh token client created",
239
239
  validRequest.correlationId
240
240
  );
241
- return refreshTokenClient.acquireToken(validRequest);
241
+ return await refreshTokenClient.acquireToken(validRequest);
242
242
  } catch (e) {
243
243
  if (e instanceof AuthError) {
244
244
  e.setCorrelationId(validRequest.correlationId);
@@ -286,7 +286,7 @@ export abstract class ClientApplication {
286
286
  "Silent flow client created",
287
287
  validRequest.correlationId
288
288
  );
289
- return silentFlowClient.acquireToken(validRequest);
289
+ return await silentFlowClient.acquireToken(validRequest);
290
290
  } catch (e) {
291
291
  if (e instanceof AuthError) {
292
292
  e.setCorrelationId(validRequest.correlationId);
@@ -337,7 +337,7 @@ export abstract class ClientApplication {
337
337
  "Username password client created",
338
338
  validRequest.correlationId
339
339
  );
340
- return usernamePasswordClient.acquireToken(validRequest);
340
+ return await usernamePasswordClient.acquireToken(validRequest);
341
341
  } catch (e) {
342
342
  if (e instanceof AuthError) {
343
343
  e.setCorrelationId(validRequest.correlationId);
@@ -412,10 +412,6 @@ export abstract class ClientApplication {
412
412
  : this.config.auth.azureCloudOptions;
413
413
 
414
414
  // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
415
- this.logger.verbose(
416
- `building oauth client configuration with the authority: ${authority}`,
417
- requestCorrelationId
418
- );
419
415
  const discoveredAuthority = await this.createAuthority(
420
416
  authority,
421
417
  azureRegionConfiguration,
@@ -423,6 +419,11 @@ export abstract class ClientApplication {
423
419
  userAzureCloudOptions
424
420
  );
425
421
 
422
+ this.logger.info(
423
+ `Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`,
424
+ requestCorrelationId
425
+ );
426
+
426
427
  serverTelemetryManager?.updateRegionDiscoveryMetadata(
427
428
  discoveredAuthority.regionDiscoveryMetadata
428
429
  );
@@ -580,7 +581,7 @@ export abstract class ClientApplication {
580
581
  this.config.auth.skipAuthorityMetadataCache,
581
582
  };
582
583
 
583
- return await AuthorityFactory.createDiscoveredInstance(
584
+ return AuthorityFactory.createDiscoveredInstance(
584
585
  authorityUrl,
585
586
  this.config.system.networkClient,
586
587
  this.storage,
@@ -9,6 +9,7 @@ import {
9
9
  AuthenticationScheme,
10
10
  Authority,
11
11
  BaseClient,
12
+ CacheManager,
12
13
  CacheOutcome,
13
14
  ClientAuthErrorCodes,
14
15
  ClientConfiguration,
@@ -16,25 +17,31 @@ import {
16
17
  Constants,
17
18
  CredentialFilter,
18
19
  CredentialType,
20
+ DEFAULT_TOKEN_RENEWAL_OFFSET_SEC,
19
21
  GrantType,
20
22
  IAppTokenProvider,
23
+ ICrypto,
21
24
  RequestParameterBuilder,
22
25
  RequestThumbprint,
23
26
  ResponseHandler,
24
27
  ScopeSet,
25
28
  ServerAuthorizationTokenResponse,
29
+ ServerTelemetryManager,
26
30
  StringUtils,
27
31
  TimeUtils,
28
32
  TokenCacheContext,
29
33
  UrlString,
30
34
  createClientAuthError,
31
35
  } from "@azure/msal-common";
36
+ import {
37
+ ManagedIdentityConfiguration,
38
+ ManagedIdentityNodeConfiguration,
39
+ } from "../config/Configuration";
32
40
 
33
41
  /**
34
42
  * OAuth2.0 client credential grant
35
43
  */
36
44
  export class ClientCredentialClient extends BaseClient {
37
- private scopeSet: ScopeSet;
38
45
  private readonly appTokenProvider?: IAppTokenProvider;
39
46
 
40
47
  constructor(
@@ -52,14 +59,19 @@ export class ClientCredentialClient extends BaseClient {
52
59
  public async acquireToken(
53
60
  request: CommonClientCredentialRequest
54
61
  ): Promise<AuthenticationResult | null> {
55
- this.scopeSet = new ScopeSet(request.scopes || []);
56
-
57
62
  if (request.skipCache) {
58
- return await this.executeTokenRequest(request, this.authority);
63
+ return this.executeTokenRequest(request, this.authority);
59
64
  }
60
65
 
61
66
  const [cachedAuthenticationResult, lastCacheOutcome] =
62
- await this.getCachedAuthenticationResult(request);
67
+ await this.getCachedAuthenticationResult(
68
+ request,
69
+ this.config,
70
+ this.cryptoUtils,
71
+ this.authority,
72
+ this.cacheManager,
73
+ this.serverTelemetryManager
74
+ );
63
75
 
64
76
  if (cachedAuthenticationResult) {
65
77
  // if the token is not expired but must be refreshed; get a new one in the background
@@ -80,41 +92,63 @@ export class ClientCredentialClient extends BaseClient {
80
92
  // return the cached token
81
93
  return cachedAuthenticationResult;
82
94
  } else {
83
- return await this.executeTokenRequest(request, this.authority);
95
+ return this.executeTokenRequest(request, this.authority);
84
96
  }
85
97
  }
86
98
 
87
99
  /**
88
100
  * looks up cache if the tokens are cached already
89
101
  */
90
- private async getCachedAuthenticationResult(
91
- request: CommonClientCredentialRequest
102
+ public async getCachedAuthenticationResult(
103
+ request: CommonClientCredentialRequest,
104
+ config: ClientConfiguration | ManagedIdentityConfiguration,
105
+ cryptoUtils: ICrypto,
106
+ authority: Authority,
107
+ cacheManager: CacheManager,
108
+ serverTelemetryManager?: ServerTelemetryManager | null
92
109
  ): Promise<[AuthenticationResult | null, CacheOutcome]> {
110
+ const clientConfiguration = config as ClientConfiguration;
111
+ const managedIdentityConfiguration =
112
+ config as ManagedIdentityNodeConfiguration;
113
+
93
114
  let lastCacheOutcome: CacheOutcome = CacheOutcome.NOT_APPLICABLE;
94
115
 
95
116
  // read the user-supplied cache into memory, if applicable
96
117
  let cacheContext;
97
- if (this.config.serializableCache && this.config.persistencePlugin) {
118
+ if (
119
+ clientConfiguration.serializableCache &&
120
+ clientConfiguration.persistencePlugin
121
+ ) {
98
122
  cacheContext = new TokenCacheContext(
99
- this.config.serializableCache,
123
+ clientConfiguration.serializableCache,
100
124
  false
101
125
  );
102
- await this.config.persistencePlugin.beforeCacheAccess(cacheContext);
126
+ await clientConfiguration.persistencePlugin.beforeCacheAccess(
127
+ cacheContext
128
+ );
103
129
  }
104
130
 
105
- const cachedAccessToken = this.readAccessTokenFromCache();
131
+ const cachedAccessToken = this.readAccessTokenFromCache(
132
+ authority,
133
+ managedIdentityConfiguration.managedIdentityId?.id ||
134
+ clientConfiguration.authOptions.clientId,
135
+ new ScopeSet(request.scopes || []),
136
+ cacheManager
137
+ );
106
138
 
107
139
  if (
108
- this.config.serializableCache &&
109
- this.config.persistencePlugin &&
140
+ clientConfiguration.serializableCache &&
141
+ clientConfiguration.persistencePlugin &&
110
142
  cacheContext
111
143
  ) {
112
- await this.config.persistencePlugin.afterCacheAccess(cacheContext);
144
+ await clientConfiguration.persistencePlugin.afterCacheAccess(
145
+ cacheContext
146
+ );
113
147
  }
114
148
 
115
149
  // must refresh due to non-existent access_token
116
150
  if (!cachedAccessToken) {
117
- this.serverTelemetryManager?.setCacheOutcome(
151
+ serverTelemetryManager?.setCacheOutcome(
118
152
  CacheOutcome.NO_CACHED_ACCESS_TOKEN
119
153
  );
120
154
  return [null, CacheOutcome.NO_CACHED_ACCESS_TOKEN];
@@ -124,10 +158,11 @@ export class ClientCredentialClient extends BaseClient {
124
158
  if (
125
159
  TimeUtils.isTokenExpired(
126
160
  cachedAccessToken.expiresOn,
127
- this.config.systemOptions.tokenRenewalOffsetSeconds
161
+ clientConfiguration.systemOptions?.tokenRenewalOffsetSeconds ||
162
+ DEFAULT_TOKEN_RENEWAL_OFFSET_SEC
128
163
  )
129
164
  ) {
130
- this.serverTelemetryManager?.setCacheOutcome(
165
+ serverTelemetryManager?.setCacheOutcome(
131
166
  CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED
132
167
  );
133
168
  return [null, CacheOutcome.CACHED_ACCESS_TOKEN_EXPIRED];
@@ -139,15 +174,15 @@ export class ClientCredentialClient extends BaseClient {
139
174
  TimeUtils.isTokenExpired(cachedAccessToken.refreshOn.toString(), 0)
140
175
  ) {
141
176
  lastCacheOutcome = CacheOutcome.PROACTIVELY_REFRESHED;
142
- this.serverTelemetryManager?.setCacheOutcome(
177
+ serverTelemetryManager?.setCacheOutcome(
143
178
  CacheOutcome.PROACTIVELY_REFRESHED
144
179
  );
145
180
  }
146
181
 
147
182
  return [
148
183
  await ResponseHandler.generateAuthenticationResult(
149
- this.cryptoUtils,
150
- this.authority,
184
+ cryptoUtils,
185
+ authority,
151
186
  {
152
187
  account: null,
153
188
  idToken: null,
@@ -165,19 +200,24 @@ export class ClientCredentialClient extends BaseClient {
165
200
  /**
166
201
  * Reads access token from the cache
167
202
  */
168
- private readAccessTokenFromCache(): AccessTokenEntity | null {
203
+ private readAccessTokenFromCache(
204
+ authority: Authority,
205
+ id: string,
206
+ scopeSet: ScopeSet,
207
+ cacheManager: CacheManager
208
+ ): AccessTokenEntity | null {
169
209
  const accessTokenFilter: CredentialFilter = {
170
210
  homeAccountId: Constants.EMPTY_STRING,
171
211
  environment:
172
- this.authority.canonicalAuthorityUrlComponents.HostNameAndPort,
212
+ authority.canonicalAuthorityUrlComponents.HostNameAndPort,
173
213
  credentialType: CredentialType.ACCESS_TOKEN,
174
- clientId: this.config.authOptions.clientId,
175
- realm: this.authority.tenant,
176
- target: ScopeSet.createSearchScopes(this.scopeSet.asArray()),
214
+ clientId: id,
215
+ realm: authority.tenant,
216
+ target: ScopeSet.createSearchScopes(scopeSet.asArray()),
177
217
  };
178
218
 
179
219
  const accessTokens =
180
- this.cacheManager.getAccessTokensByFilter(accessTokenFilter);
220
+ cacheManager.getAccessTokensByFilter(accessTokenFilter);
181
221
  if (accessTokens.length < 1) {
182
222
  return null;
183
223
  } else if (accessTokens.length > 1) {
@@ -229,6 +269,7 @@ export class ClientCredentialClient extends BaseClient {
229
269
  authority.tokenEndpoint,
230
270
  queryParametersString
231
271
  );
272
+
232
273
  const requestBody = this.createTokenRequestBody(request);
233
274
  const headers: Record<string, string> =
234
275
  this.createTokenRequestHeaders();
@@ -244,6 +285,10 @@ export class ClientCredentialClient extends BaseClient {
244
285
  sshKid: request.sshKid,
245
286
  };
246
287
 
288
+ this.logger.info(
289
+ "Sending token request to endpoint: " + authority.tokenEndpoint
290
+ );
291
+
247
292
  reqTimestamp = TimeUtils.nowSeconds();
248
293
  const response = await this.executePostToTokenEndpoint(
249
294
  endpoint,
@@ -158,7 +158,7 @@ export class ConfidentialClientApplication
158
158
  "Client credential client created",
159
159
  validRequest.correlationId
160
160
  );
161
- return clientCredentialClient.acquireToken(validRequest);
161
+ return await clientCredentialClient.acquireToken(validRequest);
162
162
  } catch (e) {
163
163
  if (e instanceof AuthError) {
164
164
  e.setCorrelationId(validRequest.correlationId);
@@ -203,7 +203,7 @@ export class ConfidentialClientApplication
203
203
  "On behalf of client created",
204
204
  validRequest.correlationId
205
205
  );
206
- return oboClient.acquireToken(validRequest);
206
+ return await oboClient.acquireToken(validRequest);
207
207
  } catch (e) {
208
208
  if (e instanceof AuthError) {
209
209
  e.setCorrelationId(validRequest.correlationId);
@@ -60,7 +60,7 @@ export class DeviceCodeClient extends BaseClient {
60
60
 
61
61
  // Validate response. This function throws a server error if an error is returned by the server.
62
62
  responseHandler.validateTokenResponse(response);
63
- return await responseHandler.handleServerTokenResponse(
63
+ return responseHandler.handleServerTokenResponse(
64
64
  response,
65
65
  this.authority,
66
66
  reqTimestamp,