@azure/identity 4.10.3-alpha.20250708.2 → 4.11.0-alpha.20250717.4

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 (351) hide show
  1. package/README.md +19 -1
  2. package/dist/browser/client/identityClient.js +30 -18
  3. package/dist/browser/client/identityClient.js.map +1 -1
  4. package/dist/browser/constants.d.ts +1 -1
  5. package/dist/browser/constants.d.ts.map +1 -1
  6. package/dist/browser/constants.js +1 -1
  7. package/dist/browser/constants.js.map +1 -1
  8. package/dist/browser/credentials/brokerCredential.d.ts +35 -0
  9. package/dist/browser/credentials/brokerCredential.d.ts.map +1 -0
  10. package/dist/browser/credentials/brokerCredential.js +69 -0
  11. package/dist/browser/credentials/brokerCredential.js.map +1 -0
  12. package/dist/browser/credentials/chainedTokenCredential.js +1 -1
  13. package/dist/browser/credentials/chainedTokenCredential.js.map +1 -1
  14. package/dist/browser/credentials/clientSecretCredential-browser.mjs.map +1 -1
  15. package/dist/browser/credentials/clientSecretCredential.js +7 -2
  16. package/dist/browser/credentials/interactiveBrowserCredential-browser.mjs.map +1 -1
  17. package/dist/browser/credentials/interactiveBrowserCredential.js +19 -6
  18. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.js +4 -6
  19. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  20. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +5 -4
  21. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -1
  22. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.js +16 -6
  23. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
  24. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.js +7 -1
  25. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  26. package/dist/browser/credentials/usernamePasswordCredential-browser.mjs.map +1 -1
  27. package/dist/browser/credentials/usernamePasswordCredential.js +7 -1
  28. package/dist/browser/credentials/visualStudioCodeCredentialOptions.d.ts +0 -4
  29. package/dist/browser/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -1
  30. package/dist/browser/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
  31. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -4
  32. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -1
  33. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
  34. package/dist/browser/errors.js +21 -0
  35. package/dist/browser/errors.js.map +1 -1
  36. package/dist/browser/msal/browserFlows/msalBrowserCommon.js +15 -15
  37. package/dist/browser/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  38. package/dist/browser/msal/nodeFlows/msalClient.d.ts +13 -0
  39. package/dist/browser/msal/nodeFlows/msalClient.d.ts.map +1 -1
  40. package/dist/browser/msal/nodeFlows/msalClient.js +127 -94
  41. package/dist/browser/msal/nodeFlows/msalClient.js.map +1 -1
  42. package/dist/browser/msal/nodeFlows/msalPlugins.d.ts +19 -1
  43. package/dist/browser/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  44. package/dist/browser/msal/nodeFlows/msalPlugins.js +61 -16
  45. package/dist/browser/msal/nodeFlows/msalPlugins.js.map +1 -1
  46. package/dist/browser/msal/utils.js +3 -4
  47. package/dist/browser/msal/utils.js.map +1 -1
  48. package/dist/browser/plugins/provider.d.ts +2 -2
  49. package/dist/browser/plugins/provider.d.ts.map +1 -1
  50. package/dist/browser/plugins/provider.js.map +1 -1
  51. package/dist/browser/regionalAuthority.js +1 -2
  52. package/dist/browser/regionalAuthority.js.map +1 -1
  53. package/dist/browser/tokenProvider.js +1 -2
  54. package/dist/browser/tokenProvider.js.map +1 -1
  55. package/dist/browser/util/logging.js +6 -2
  56. package/dist/browser/util/logging.js.map +1 -1
  57. package/dist/browser/util/processMultiTenantRequest-browser.mjs.map +1 -1
  58. package/dist/browser/util/processMultiTenantRequest.js +1 -2
  59. package/dist/browser/util/processUtils.d.ts +1 -1
  60. package/dist/browser/util/processUtils.d.ts.map +1 -1
  61. package/dist/browser/util/processUtils.js +1 -1
  62. package/dist/browser/util/processUtils.js.map +1 -1
  63. package/dist/commonjs/client/identityClient.js +30 -18
  64. package/dist/commonjs/client/identityClient.js.map +1 -1
  65. package/dist/commonjs/constants.d.ts +1 -1
  66. package/dist/commonjs/constants.d.ts.map +1 -1
  67. package/dist/commonjs/constants.js +1 -1
  68. package/dist/commonjs/constants.js.map +1 -1
  69. package/dist/commonjs/credentials/authorizationCodeCredential.js +17 -3
  70. package/dist/commonjs/credentials/authorizationCodeCredential.js.map +1 -1
  71. package/dist/commonjs/credentials/azureCliCredential.js +15 -12
  72. package/dist/commonjs/credentials/azureCliCredential.js.map +1 -1
  73. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +12 -10
  74. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +1 -1
  75. package/dist/commonjs/credentials/azurePipelinesCredential.js +9 -5
  76. package/dist/commonjs/credentials/azurePipelinesCredential.js.map +1 -1
  77. package/dist/commonjs/credentials/azurePowerShellCredential.js +10 -7
  78. package/dist/commonjs/credentials/azurePowerShellCredential.js.map +1 -1
  79. package/dist/commonjs/credentials/brokerCredential.d.ts +35 -0
  80. package/dist/commonjs/credentials/brokerCredential.d.ts.map +1 -0
  81. package/dist/commonjs/credentials/brokerCredential.js +73 -0
  82. package/dist/commonjs/credentials/brokerCredential.js.map +1 -0
  83. package/dist/commonjs/credentials/chainedTokenCredential.js +1 -1
  84. package/dist/commonjs/credentials/chainedTokenCredential.js.map +1 -1
  85. package/dist/commonjs/credentials/clientAssertionCredential.js +11 -2
  86. package/dist/commonjs/credentials/clientAssertionCredential.js.map +1 -1
  87. package/dist/commonjs/credentials/clientCertificateCredential.js +19 -9
  88. package/dist/commonjs/credentials/clientCertificateCredential.js.map +1 -1
  89. package/dist/commonjs/credentials/clientSecretCredential.js +10 -2
  90. package/dist/commonjs/credentials/clientSecretCredential.js.map +1 -1
  91. package/dist/commonjs/credentials/defaultAzureCredential.d.ts +18 -0
  92. package/dist/commonjs/credentials/defaultAzureCredential.d.ts.map +1 -1
  93. package/dist/commonjs/credentials/defaultAzureCredential.js +69 -19
  94. package/dist/commonjs/credentials/defaultAzureCredential.js.map +1 -1
  95. package/dist/commonjs/credentials/deviceCodeCredential.js +24 -10
  96. package/dist/commonjs/credentials/deviceCodeCredential.js.map +1 -1
  97. package/dist/commonjs/credentials/environmentCredential.js +4 -6
  98. package/dist/commonjs/credentials/environmentCredential.js.map +1 -1
  99. package/dist/commonjs/credentials/interactiveBrowserCredential.js +30 -11
  100. package/dist/commonjs/credentials/interactiveBrowserCredential.js.map +1 -1
  101. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js +4 -6
  102. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  103. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +5 -4
  104. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -1
  105. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js +16 -6
  106. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
  107. package/dist/commonjs/credentials/managedIdentityCredential/index.js +28 -18
  108. package/dist/commonjs/credentials/managedIdentityCredential/index.js.map +1 -1
  109. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js +7 -1
  110. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  111. package/dist/commonjs/credentials/onBehalfOfCredential.js +13 -1
  112. package/dist/commonjs/credentials/onBehalfOfCredential.js.map +1 -1
  113. package/dist/commonjs/credentials/usernamePasswordCredential.js +10 -2
  114. package/dist/commonjs/credentials/usernamePasswordCredential.js.map +1 -1
  115. package/dist/commonjs/credentials/visualStudioCodeCredential.d.ts +15 -26
  116. package/dist/commonjs/credentials/visualStudioCodeCredential.d.ts.map +1 -1
  117. package/dist/commonjs/credentials/visualStudioCodeCredential.js +69 -130
  118. package/dist/commonjs/credentials/visualStudioCodeCredential.js.map +1 -1
  119. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.d.ts +0 -4
  120. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -1
  121. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
  122. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -4
  123. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -1
  124. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
  125. package/dist/commonjs/credentials/workloadIdentityCredential.js +5 -3
  126. package/dist/commonjs/credentials/workloadIdentityCredential.js.map +1 -1
  127. package/dist/commonjs/errors.js +21 -0
  128. package/dist/commonjs/errors.js.map +1 -1
  129. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js +15 -15
  130. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  131. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts +13 -0
  132. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts.map +1 -1
  133. package/dist/commonjs/msal/nodeFlows/msalClient.js +127 -94
  134. package/dist/commonjs/msal/nodeFlows/msalClient.js.map +1 -1
  135. package/dist/commonjs/msal/nodeFlows/msalPlugins.d.ts +19 -1
  136. package/dist/commonjs/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  137. package/dist/commonjs/msal/nodeFlows/msalPlugins.js +63 -17
  138. package/dist/commonjs/msal/nodeFlows/msalPlugins.js.map +1 -1
  139. package/dist/commonjs/msal/utils.js +3 -4
  140. package/dist/commonjs/msal/utils.js.map +1 -1
  141. package/dist/commonjs/plugins/consumer.d.ts.map +1 -1
  142. package/dist/commonjs/plugins/consumer.js +1 -2
  143. package/dist/commonjs/plugins/consumer.js.map +1 -1
  144. package/dist/commonjs/plugins/provider.d.ts +2 -2
  145. package/dist/commonjs/plugins/provider.d.ts.map +1 -1
  146. package/dist/commonjs/plugins/provider.js.map +1 -1
  147. package/dist/commonjs/regionalAuthority.js +1 -2
  148. package/dist/commonjs/regionalAuthority.js.map +1 -1
  149. package/dist/commonjs/tokenProvider.js +1 -2
  150. package/dist/commonjs/tokenProvider.js.map +1 -1
  151. package/dist/commonjs/util/logging.js +6 -2
  152. package/dist/commonjs/util/logging.js.map +1 -1
  153. package/dist/commonjs/util/processMultiTenantRequest.js +2 -3
  154. package/dist/commonjs/util/processMultiTenantRequest.js.map +1 -1
  155. package/dist/commonjs/util/processUtils.d.ts +1 -1
  156. package/dist/commonjs/util/processUtils.d.ts.map +1 -1
  157. package/dist/commonjs/util/processUtils.js +2 -2
  158. package/dist/commonjs/util/processUtils.js.map +1 -1
  159. package/dist/esm/client/identityClient.js +30 -18
  160. package/dist/esm/client/identityClient.js.map +1 -1
  161. package/dist/esm/constants.d.ts +1 -1
  162. package/dist/esm/constants.d.ts.map +1 -1
  163. package/dist/esm/constants.js +1 -1
  164. package/dist/esm/constants.js.map +1 -1
  165. package/dist/esm/credentials/authorizationCodeCredential.js +17 -3
  166. package/dist/esm/credentials/authorizationCodeCredential.js.map +1 -1
  167. package/dist/esm/credentials/azureCliCredential.js +15 -12
  168. package/dist/esm/credentials/azureCliCredential.js.map +1 -1
  169. package/dist/esm/credentials/azureDeveloperCliCredential.js +12 -10
  170. package/dist/esm/credentials/azureDeveloperCliCredential.js.map +1 -1
  171. package/dist/esm/credentials/azurePipelinesCredential.js +9 -5
  172. package/dist/esm/credentials/azurePipelinesCredential.js.map +1 -1
  173. package/dist/esm/credentials/azurePowerShellCredential.js +10 -7
  174. package/dist/esm/credentials/azurePowerShellCredential.js.map +1 -1
  175. package/dist/esm/credentials/brokerCredential.d.ts +35 -0
  176. package/dist/esm/credentials/brokerCredential.d.ts.map +1 -0
  177. package/dist/esm/credentials/brokerCredential.js +69 -0
  178. package/dist/esm/credentials/brokerCredential.js.map +1 -0
  179. package/dist/esm/credentials/chainedTokenCredential.js +1 -1
  180. package/dist/esm/credentials/chainedTokenCredential.js.map +1 -1
  181. package/dist/esm/credentials/clientAssertionCredential.js +11 -2
  182. package/dist/esm/credentials/clientAssertionCredential.js.map +1 -1
  183. package/dist/esm/credentials/clientCertificateCredential.js +19 -9
  184. package/dist/esm/credentials/clientCertificateCredential.js.map +1 -1
  185. package/dist/esm/credentials/clientSecretCredential.js +10 -2
  186. package/dist/esm/credentials/clientSecretCredential.js.map +1 -1
  187. package/dist/esm/credentials/defaultAzureCredential.d.ts +18 -0
  188. package/dist/esm/credentials/defaultAzureCredential.d.ts.map +1 -1
  189. package/dist/esm/credentials/defaultAzureCredential.js +67 -19
  190. package/dist/esm/credentials/defaultAzureCredential.js.map +1 -1
  191. package/dist/esm/credentials/deviceCodeCredential.js +24 -10
  192. package/dist/esm/credentials/deviceCodeCredential.js.map +1 -1
  193. package/dist/esm/credentials/environmentCredential.js +4 -6
  194. package/dist/esm/credentials/environmentCredential.js.map +1 -1
  195. package/dist/esm/credentials/interactiveBrowserCredential.js +30 -11
  196. package/dist/esm/credentials/interactiveBrowserCredential.js.map +1 -1
  197. package/dist/esm/credentials/managedIdentityCredential/imdsMsi.js +4 -6
  198. package/dist/esm/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  199. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +5 -4
  200. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -1
  201. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.js +16 -6
  202. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
  203. package/dist/esm/credentials/managedIdentityCredential/index.js +28 -18
  204. package/dist/esm/credentials/managedIdentityCredential/index.js.map +1 -1
  205. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.js +7 -1
  206. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  207. package/dist/esm/credentials/onBehalfOfCredential.js +13 -1
  208. package/dist/esm/credentials/onBehalfOfCredential.js.map +1 -1
  209. package/dist/esm/credentials/usernamePasswordCredential.js +10 -2
  210. package/dist/esm/credentials/usernamePasswordCredential.js.map +1 -1
  211. package/dist/esm/credentials/visualStudioCodeCredential.d.ts +15 -26
  212. package/dist/esm/credentials/visualStudioCodeCredential.d.ts.map +1 -1
  213. package/dist/esm/credentials/visualStudioCodeCredential.js +69 -128
  214. package/dist/esm/credentials/visualStudioCodeCredential.js.map +1 -1
  215. package/dist/esm/credentials/visualStudioCodeCredentialOptions.d.ts +0 -4
  216. package/dist/esm/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -1
  217. package/dist/esm/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
  218. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -4
  219. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -1
  220. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
  221. package/dist/esm/credentials/workloadIdentityCredential.js +5 -3
  222. package/dist/esm/credentials/workloadIdentityCredential.js.map +1 -1
  223. package/dist/esm/errors.js +21 -0
  224. package/dist/esm/errors.js.map +1 -1
  225. package/dist/esm/msal/browserFlows/msalBrowserCommon.js +15 -15
  226. package/dist/esm/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  227. package/dist/esm/msal/nodeFlows/msalClient.d.ts +13 -0
  228. package/dist/esm/msal/nodeFlows/msalClient.d.ts.map +1 -1
  229. package/dist/esm/msal/nodeFlows/msalClient.js +127 -94
  230. package/dist/esm/msal/nodeFlows/msalClient.js.map +1 -1
  231. package/dist/esm/msal/nodeFlows/msalPlugins.d.ts +19 -1
  232. package/dist/esm/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  233. package/dist/esm/msal/nodeFlows/msalPlugins.js +61 -16
  234. package/dist/esm/msal/nodeFlows/msalPlugins.js.map +1 -1
  235. package/dist/esm/msal/utils.js +3 -4
  236. package/dist/esm/msal/utils.js.map +1 -1
  237. package/dist/esm/plugins/consumer.d.ts.map +1 -1
  238. package/dist/esm/plugins/consumer.js +2 -3
  239. package/dist/esm/plugins/consumer.js.map +1 -1
  240. package/dist/esm/plugins/provider.d.ts +2 -2
  241. package/dist/esm/plugins/provider.d.ts.map +1 -1
  242. package/dist/esm/plugins/provider.js.map +1 -1
  243. package/dist/esm/regionalAuthority.js +1 -2
  244. package/dist/esm/regionalAuthority.js.map +1 -1
  245. package/dist/esm/tokenProvider.js +1 -2
  246. package/dist/esm/tokenProvider.js.map +1 -1
  247. package/dist/esm/util/logging.js +6 -2
  248. package/dist/esm/util/logging.js.map +1 -1
  249. package/dist/esm/util/processMultiTenantRequest.js +2 -3
  250. package/dist/esm/util/processMultiTenantRequest.js.map +1 -1
  251. package/dist/esm/util/processUtils.d.ts +1 -1
  252. package/dist/esm/util/processUtils.d.ts.map +1 -1
  253. package/dist/esm/util/processUtils.js +1 -1
  254. package/dist/esm/util/processUtils.js.map +1 -1
  255. package/dist/workerd/client/identityClient.js +30 -18
  256. package/dist/workerd/client/identityClient.js.map +1 -1
  257. package/dist/workerd/constants.d.ts +1 -1
  258. package/dist/workerd/constants.d.ts.map +1 -1
  259. package/dist/workerd/constants.js +1 -1
  260. package/dist/workerd/constants.js.map +1 -1
  261. package/dist/workerd/credentials/authorizationCodeCredential.js +17 -3
  262. package/dist/workerd/credentials/authorizationCodeCredential.js.map +1 -1
  263. package/dist/workerd/credentials/azureCliCredential.js +15 -12
  264. package/dist/workerd/credentials/azureCliCredential.js.map +1 -1
  265. package/dist/workerd/credentials/azureDeveloperCliCredential.js +12 -10
  266. package/dist/workerd/credentials/azureDeveloperCliCredential.js.map +1 -1
  267. package/dist/workerd/credentials/azurePipelinesCredential.js +9 -5
  268. package/dist/workerd/credentials/azurePipelinesCredential.js.map +1 -1
  269. package/dist/workerd/credentials/azurePowerShellCredential.js +10 -7
  270. package/dist/workerd/credentials/azurePowerShellCredential.js.map +1 -1
  271. package/dist/workerd/credentials/brokerCredential.d.ts +35 -0
  272. package/dist/workerd/credentials/brokerCredential.d.ts.map +1 -0
  273. package/dist/workerd/credentials/brokerCredential.js +69 -0
  274. package/dist/workerd/credentials/brokerCredential.js.map +1 -0
  275. package/dist/workerd/credentials/chainedTokenCredential.js +1 -1
  276. package/dist/workerd/credentials/chainedTokenCredential.js.map +1 -1
  277. package/dist/workerd/credentials/clientAssertionCredential.js +11 -2
  278. package/dist/workerd/credentials/clientAssertionCredential.js.map +1 -1
  279. package/dist/workerd/credentials/clientCertificateCredential.js +19 -9
  280. package/dist/workerd/credentials/clientCertificateCredential.js.map +1 -1
  281. package/dist/workerd/credentials/clientSecretCredential.js +10 -2
  282. package/dist/workerd/credentials/clientSecretCredential.js.map +1 -1
  283. package/dist/workerd/credentials/defaultAzureCredential.d.ts +18 -0
  284. package/dist/workerd/credentials/defaultAzureCredential.d.ts.map +1 -1
  285. package/dist/workerd/credentials/defaultAzureCredential.js +67 -19
  286. package/dist/workerd/credentials/defaultAzureCredential.js.map +1 -1
  287. package/dist/workerd/credentials/deviceCodeCredential.js +24 -10
  288. package/dist/workerd/credentials/deviceCodeCredential.js.map +1 -1
  289. package/dist/workerd/credentials/environmentCredential.js +4 -6
  290. package/dist/workerd/credentials/environmentCredential.js.map +1 -1
  291. package/dist/workerd/credentials/interactiveBrowserCredential.js +30 -11
  292. package/dist/workerd/credentials/interactiveBrowserCredential.js.map +1 -1
  293. package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.js +4 -6
  294. package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  295. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +5 -4
  296. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -1
  297. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.js +16 -6
  298. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
  299. package/dist/workerd/credentials/managedIdentityCredential/index.js +28 -18
  300. package/dist/workerd/credentials/managedIdentityCredential/index.js.map +1 -1
  301. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js +7 -1
  302. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  303. package/dist/workerd/credentials/onBehalfOfCredential.js +13 -1
  304. package/dist/workerd/credentials/onBehalfOfCredential.js.map +1 -1
  305. package/dist/workerd/credentials/usernamePasswordCredential.js +10 -2
  306. package/dist/workerd/credentials/usernamePasswordCredential.js.map +1 -1
  307. package/dist/workerd/credentials/visualStudioCodeCredential.d.ts +15 -26
  308. package/dist/workerd/credentials/visualStudioCodeCredential.d.ts.map +1 -1
  309. package/dist/workerd/credentials/visualStudioCodeCredential.js +69 -128
  310. package/dist/workerd/credentials/visualStudioCodeCredential.js.map +1 -1
  311. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.d.ts +0 -4
  312. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -1
  313. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
  314. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -4
  315. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -1
  316. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
  317. package/dist/workerd/credentials/workloadIdentityCredential.js +5 -3
  318. package/dist/workerd/credentials/workloadIdentityCredential.js.map +1 -1
  319. package/dist/workerd/errors.js +21 -0
  320. package/dist/workerd/errors.js.map +1 -1
  321. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js +15 -15
  322. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  323. package/dist/workerd/msal/nodeFlows/msalClient.d.ts +13 -0
  324. package/dist/workerd/msal/nodeFlows/msalClient.d.ts.map +1 -1
  325. package/dist/workerd/msal/nodeFlows/msalClient.js +127 -94
  326. package/dist/workerd/msal/nodeFlows/msalClient.js.map +1 -1
  327. package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts +19 -1
  328. package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  329. package/dist/workerd/msal/nodeFlows/msalPlugins.js +61 -16
  330. package/dist/workerd/msal/nodeFlows/msalPlugins.js.map +1 -1
  331. package/dist/workerd/msal/utils.js +3 -4
  332. package/dist/workerd/msal/utils.js.map +1 -1
  333. package/dist/workerd/plugins/consumer.d.ts.map +1 -1
  334. package/dist/workerd/plugins/consumer.js +2 -3
  335. package/dist/workerd/plugins/consumer.js.map +1 -1
  336. package/dist/workerd/plugins/provider.d.ts +2 -2
  337. package/dist/workerd/plugins/provider.d.ts.map +1 -1
  338. package/dist/workerd/plugins/provider.js.map +1 -1
  339. package/dist/workerd/regionalAuthority.js +1 -2
  340. package/dist/workerd/regionalAuthority.js.map +1 -1
  341. package/dist/workerd/tokenProvider.js +1 -2
  342. package/dist/workerd/tokenProvider.js.map +1 -1
  343. package/dist/workerd/util/logging.js +6 -2
  344. package/dist/workerd/util/logging.js.map +1 -1
  345. package/dist/workerd/util/processMultiTenantRequest.js +2 -3
  346. package/dist/workerd/util/processMultiTenantRequest.js.map +1 -1
  347. package/dist/workerd/util/processUtils.d.ts +1 -1
  348. package/dist/workerd/util/processUtils.d.ts.map +1 -1
  349. package/dist/workerd/util/processUtils.js +1 -1
  350. package/dist/workerd/util/processUtils.js.map +1 -1
  351. package/package.json +2 -2
@@ -27,11 +27,14 @@ const msalLogger = (0, logging_js_1.credentialLogger)("MsalClient");
27
27
  * @returns The MSAL configuration object.
28
28
  */
29
29
  function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
30
- var _a, _b, _c;
31
- const resolvedTenant = (0, tenantIdUtils_js_1.resolveTenantId)((_a = msalClientOptions.logger) !== null && _a !== void 0 ? _a : msalLogger, tenantId, clientId);
30
+ const resolvedTenant = (0, tenantIdUtils_js_1.resolveTenantId)(msalClientOptions.logger ?? msalLogger, tenantId, clientId);
32
31
  // TODO: move and reuse getIdentityClientAuthorityHost
33
32
  const authority = (0, utils_js_1.getAuthority)(resolvedTenant, (0, utils_js_1.getAuthorityHost)(msalClientOptions));
34
- const httpClient = new identityClient_js_1.IdentityClient(Object.assign(Object.assign({}, msalClientOptions.tokenCredentialOptions), { authorityHost: authority, loggingOptions: msalClientOptions.loggingOptions }));
33
+ const httpClient = new identityClient_js_1.IdentityClient({
34
+ ...msalClientOptions.tokenCredentialOptions,
35
+ authorityHost: authority,
36
+ loggingOptions: msalClientOptions.loggingOptions,
37
+ });
35
38
  const msalConfig = {
36
39
  auth: {
37
40
  clientId,
@@ -41,9 +44,9 @@ function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
41
44
  system: {
42
45
  networkClient: httpClient,
43
46
  loggerOptions: {
44
- loggerCallback: (0, utils_js_1.defaultLoggerCallback)((_b = msalClientOptions.logger) !== null && _b !== void 0 ? _b : msalLogger),
47
+ loggerCallback: (0, utils_js_1.defaultLoggerCallback)(msalClientOptions.logger ?? msalLogger),
45
48
  logLevel: (0, utils_js_1.getMSALLogLevel)((0, logger_1.getLogLevel)()),
46
- piiLoggingEnabled: (_c = msalClientOptions.loggingOptions) === null || _c === void 0 ? void 0 : _c.enableUnsafeSupportLogging,
49
+ piiLoggingEnabled: msalClientOptions.loggingOptions?.enableUnsafeSupportLogging,
47
50
  },
48
51
  },
49
52
  };
@@ -60,14 +63,13 @@ function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
60
63
  * @public
61
64
  */
62
65
  function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
63
- var _a;
64
66
  const state = {
65
67
  msalConfig: generateMsalConfiguration(clientId, tenantId, createMsalClientOptions),
66
68
  cachedAccount: createMsalClientOptions.authenticationRecord
67
69
  ? (0, utils_js_1.publicToMsal)(createMsalClientOptions.authenticationRecord)
68
70
  : null,
69
71
  pluginConfiguration: msalPlugins_js_1.msalPlugins.generatePluginConfiguration(createMsalClientOptions),
70
- logger: (_a = createMsalClientOptions.logger) !== null && _a !== void 0 ? _a : msalLogger,
72
+ logger: createMsalClientOptions.logger ?? msalLogger,
71
73
  };
72
74
  const publicApps = new Map();
73
75
  async function getPublicApp(options = {}) {
@@ -83,7 +85,11 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
83
85
  ? state.pluginConfiguration.cache.cachePluginCae
84
86
  : state.pluginConfiguration.cache.cachePlugin;
85
87
  state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : undefined;
86
- publicClientApp = new msal.PublicClientApplication(Object.assign(Object.assign({}, state.msalConfig), { broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin }, cache: { cachePlugin: await cachePlugin } }));
88
+ publicClientApp = new msal.PublicClientApplication({
89
+ ...state.msalConfig,
90
+ broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin },
91
+ cache: { cachePlugin: await cachePlugin },
92
+ });
87
93
  publicApps.set(appKey, publicClientApp);
88
94
  return publicClientApp;
89
95
  }
@@ -101,7 +107,11 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
101
107
  ? state.pluginConfiguration.cache.cachePluginCae
102
108
  : state.pluginConfiguration.cache.cachePlugin;
103
109
  state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : undefined;
104
- confidentialClientApp = new msal.ConfidentialClientApplication(Object.assign(Object.assign({}, state.msalConfig), { broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin }, cache: { cachePlugin: await cachePlugin } }));
110
+ confidentialClientApp = new msal.ConfidentialClientApplication({
111
+ ...state.msalConfig,
112
+ broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin },
113
+ cache: { cachePlugin: await cachePlugin },
114
+ });
105
115
  confidentialApps.set(appKey, confidentialClientApp);
106
116
  return confidentialClientApp;
107
117
  }
@@ -120,7 +130,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
120
130
  claims: state.cachedClaims,
121
131
  };
122
132
  if (state.pluginConfiguration.broker.isEnabled) {
123
- silentRequest.tokenQueryParameters || (silentRequest.tokenQueryParameters = {});
133
+ silentRequest.tokenQueryParameters ||= {};
124
134
  if (state.pluginConfiguration.broker.enableMsaPassthrough) {
125
135
  silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
126
136
  }
@@ -144,7 +154,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
144
154
  * if the user is creating cross-tenant requests
145
155
  */
146
156
  function calculateRequestAuthority(options) {
147
- if (options === null || options === void 0 ? void 0 : options.tenantId) {
157
+ if (options?.tenantId) {
148
158
  return (0, utils_js_1.getAuthority)(options.tenantId, (0, utils_js_1.getAuthorityHost)(createMsalClientOptions));
149
159
  }
150
160
  return state.msalConfig.auth.authority;
@@ -160,7 +170,6 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
160
170
  * @returns A promise that resolves to an AccessToken object containing the access token and its expiration timestamp.
161
171
  */
162
172
  async function withSilentAuthentication(msalApp, scopes, options, onAuthenticationRequired) {
163
- var _a, _b;
164
173
  let response = null;
165
174
  try {
166
175
  response = await getTokenSilent(msalApp, scopes, options);
@@ -188,17 +197,16 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
188
197
  }
189
198
  // At this point we should have a token, process it
190
199
  (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
191
- state.cachedAccount = (_a = response === null || response === void 0 ? void 0 : response.account) !== null && _a !== void 0 ? _a : null;
200
+ state.cachedAccount = response?.account ?? null;
192
201
  state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
193
202
  return {
194
203
  token: response.accessToken,
195
204
  expiresOnTimestamp: response.expiresOn.getTime(),
196
- refreshAfterTimestamp: (_b = response.refreshOn) === null || _b === void 0 ? void 0 : _b.getTime(),
205
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
197
206
  tokenType: response.tokenType,
198
207
  };
199
208
  }
200
209
  async function getTokenByClientSecret(scopes, clientSecret, options = {}) {
201
- var _a;
202
210
  state.logger.getToken.info(`Attempting to acquire token using client secret`);
203
211
  state.msalConfig.auth.clientSecret = clientSecret;
204
212
  const msalApp = await getConfidentialApp(options);
@@ -207,14 +215,14 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
207
215
  scopes,
208
216
  authority: calculateRequestAuthority(options),
209
217
  azureRegion: (0, regionalAuthority_js_1.calculateRegionalAuthority)(),
210
- claims: options === null || options === void 0 ? void 0 : options.claims,
218
+ claims: options?.claims,
211
219
  });
212
220
  (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
213
221
  state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
214
222
  return {
215
223
  token: response.accessToken,
216
224
  expiresOnTimestamp: response.expiresOn.getTime(),
217
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
225
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
218
226
  tokenType: response.tokenType,
219
227
  };
220
228
  }
@@ -223,7 +231,6 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
223
231
  }
224
232
  }
225
233
  async function getTokenByClientAssertion(scopes, clientAssertion, options = {}) {
226
- var _a;
227
234
  state.logger.getToken.info(`Attempting to acquire token using client assertion`);
228
235
  state.msalConfig.auth.clientAssertion = clientAssertion;
229
236
  const msalApp = await getConfidentialApp(options);
@@ -232,7 +239,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
232
239
  scopes,
233
240
  authority: calculateRequestAuthority(options),
234
241
  azureRegion: (0, regionalAuthority_js_1.calculateRegionalAuthority)(),
235
- claims: options === null || options === void 0 ? void 0 : options.claims,
242
+ claims: options?.claims,
236
243
  clientAssertion,
237
244
  });
238
245
  (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
@@ -240,7 +247,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
240
247
  return {
241
248
  token: response.accessToken,
242
249
  expiresOnTimestamp: response.expiresOn.getTime(),
243
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
250
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
244
251
  tokenType: response.tokenType,
245
252
  };
246
253
  }
@@ -249,7 +256,6 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
249
256
  }
250
257
  }
251
258
  async function getTokenByClientCertificate(scopes, certificate, options = {}) {
252
- var _a;
253
259
  state.logger.getToken.info(`Attempting to acquire token using client certificate`);
254
260
  state.msalConfig.auth.clientCertificate = certificate;
255
261
  const msalApp = await getConfidentialApp(options);
@@ -258,14 +264,14 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
258
264
  scopes,
259
265
  authority: calculateRequestAuthority(options),
260
266
  azureRegion: (0, regionalAuthority_js_1.calculateRegionalAuthority)(),
261
- claims: options === null || options === void 0 ? void 0 : options.claims,
267
+ claims: options?.claims,
262
268
  });
263
269
  (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
264
270
  state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
265
271
  return {
266
272
  token: response.accessToken,
267
273
  expiresOnTimestamp: response.expiresOn.getTime(),
268
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
274
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
269
275
  tokenType: response.tokenType,
270
276
  };
271
277
  }
@@ -277,13 +283,12 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
277
283
  state.logger.getToken.info(`Attempting to acquire token using device code`);
278
284
  const msalApp = await getPublicApp(options);
279
285
  return withSilentAuthentication(msalApp, scopes, options, () => {
280
- var _a, _b;
281
286
  const requestOptions = {
282
287
  scopes,
283
- cancel: (_b = (_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) !== null && _b !== void 0 ? _b : false,
288
+ cancel: options?.abortSignal?.aborted ?? false,
284
289
  deviceCodeCallback,
285
290
  authority: calculateRequestAuthority(options),
286
- claims: options === null || options === void 0 ? void 0 : options.claims,
291
+ claims: options?.claims,
287
292
  };
288
293
  const deviceCodeRequest = msalApp.acquireTokenByDeviceCode(requestOptions);
289
294
  if (options.abortSignal) {
@@ -303,7 +308,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
303
308
  username,
304
309
  password,
305
310
  authority: calculateRequestAuthority(options),
306
- claims: options === null || options === void 0 ? void 0 : options.claims,
311
+ claims: options?.claims,
307
312
  };
308
313
  return msalApp.acquireTokenByUsernamePassword(requestOptions);
309
314
  });
@@ -332,12 +337,11 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
332
337
  redirectUri,
333
338
  code: authorizationCode,
334
339
  authority: calculateRequestAuthority(options),
335
- claims: options === null || options === void 0 ? void 0 : options.claims,
340
+ claims: options?.claims,
336
341
  });
337
342
  });
338
343
  }
339
344
  async function getTokenOnBehalfOf(scopes, userAssertionToken, clientCredentials, options = {}) {
340
- var _a;
341
345
  msalLogger.getToken.info(`Attempting to acquire token on behalf of another user`);
342
346
  if (typeof clientCredentials === "string") {
343
347
  // Client secret
@@ -367,7 +371,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
367
371
  return {
368
372
  token: response.accessToken,
369
373
  expiresOnTimestamp: response.expiresOn.getTime(),
370
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
374
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
371
375
  tokenType: response.tokenType,
372
376
  };
373
377
  }
@@ -375,79 +379,107 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
375
379
  throw (0, utils_js_1.handleMsalError)(scopes, err, options);
376
380
  }
377
381
  }
378
- async function getTokenByInteractiveRequest(scopes, options = {}) {
379
- msalLogger.getToken.info(`Attempting to acquire token interactively`);
382
+ /**
383
+ * Creates a base interactive request configuration for MSAL interactive authentication.
384
+ * This is shared between interactive and brokered authentication flows.
385
+ *
386
+ * @internal
387
+ */
388
+ function createBaseInteractiveRequest(scopes, options) {
389
+ return {
390
+ openBrowser: async (url) => {
391
+ const open = await import("open");
392
+ await open.default(url, { wait: true, newInstance: true });
393
+ },
394
+ scopes,
395
+ authority: calculateRequestAuthority(options),
396
+ claims: options?.claims,
397
+ loginHint: options?.loginHint,
398
+ errorTemplate: options?.browserCustomizationOptions?.errorMessage,
399
+ successTemplate: options?.browserCustomizationOptions?.successMessage,
400
+ prompt: options?.loginHint ? "login" : "select_account",
401
+ };
402
+ }
403
+ /**
404
+ * @internal
405
+ */
406
+ async function getBrokeredTokenInternal(scopes, useDefaultBrokerAccount, options = {}) {
407
+ msalLogger.verbose("Authentication will resume through the broker");
380
408
  const app = await getPublicApp(options);
381
- /**
382
- * A helper function that supports brokered authentication through the MSAL's public application.
383
- *
384
- * When options.useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.
385
- * If the default broker account is not available, the method will fall back to interactive authentication.
386
- */
387
- async function getBrokeredToken(useDefaultBrokerAccount) {
388
- var _a;
389
- msalLogger.verbose("Authentication will resume through the broker");
390
- const interactiveRequest = createBaseInteractiveRequest();
391
- if (state.pluginConfiguration.broker.parentWindowHandle) {
392
- interactiveRequest.windowHandle = Buffer.from(state.pluginConfiguration.broker.parentWindowHandle);
393
- }
394
- else {
395
- // this is a bug, as the pluginConfiguration handler should validate this case.
396
- msalLogger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
397
- }
398
- if (state.pluginConfiguration.broker.enableMsaPassthrough) {
399
- ((_a = interactiveRequest.tokenQueryParameters) !== null && _a !== void 0 ? _a : (interactiveRequest.tokenQueryParameters = {}))["msal_request_type"] =
400
- "consumer_passthrough";
409
+ const interactiveRequest = createBaseInteractiveRequest(scopes, options);
410
+ if (state.pluginConfiguration.broker.parentWindowHandle) {
411
+ interactiveRequest.windowHandle = Buffer.from(state.pluginConfiguration.broker.parentWindowHandle);
412
+ }
413
+ else {
414
+ // this is a bug, as the pluginConfiguration handler should validate this case.
415
+ msalLogger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
416
+ }
417
+ if (state.pluginConfiguration.broker.enableMsaPassthrough) {
418
+ (interactiveRequest.tokenQueryParameters ??= {})["msal_request_type"] =
419
+ "consumer_passthrough";
420
+ }
421
+ if (useDefaultBrokerAccount) {
422
+ interactiveRequest.prompt = "none";
423
+ msalLogger.verbose("Attempting broker authentication using the default broker account");
424
+ }
425
+ else {
426
+ msalLogger.verbose("Attempting broker authentication without the default broker account");
427
+ }
428
+ if (options.proofOfPossessionOptions) {
429
+ interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
430
+ interactiveRequest.authenticationScheme = "pop";
431
+ interactiveRequest.resourceRequestMethod =
432
+ options.proofOfPossessionOptions.resourceRequestMethod;
433
+ interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
434
+ }
435
+ try {
436
+ return await app.acquireTokenInteractive(interactiveRequest);
437
+ }
438
+ catch (e) {
439
+ msalLogger.verbose(`Failed to authenticate through the broker: ${e.message}`);
440
+ if (options.disableAutomaticAuthentication) {
441
+ throw new errors_js_1.AuthenticationRequiredError({
442
+ scopes,
443
+ getTokenOptions: options,
444
+ message: "Cannot silently authenticate with default broker account.",
445
+ });
401
446
  }
447
+ // If we tried to use the default broker account and failed, fall back to interactive authentication
402
448
  if (useDefaultBrokerAccount) {
403
- interactiveRequest.prompt = "none";
404
- msalLogger.verbose("Attempting broker authentication using the default broker account");
449
+ return getBrokeredTokenInternal(scopes, false, options);
405
450
  }
406
451
  else {
407
- msalLogger.verbose("Attempting broker authentication without the default broker account");
408
- }
409
- if (options.proofOfPossessionOptions) {
410
- interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
411
- interactiveRequest.authenticationScheme = "pop";
412
- interactiveRequest.resourceRequestMethod =
413
- options.proofOfPossessionOptions.resourceRequestMethod;
414
- interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
415
- }
416
- try {
417
- return await app.acquireTokenInteractive(interactiveRequest);
418
- }
419
- catch (e) {
420
- msalLogger.verbose(`Failed to authenticate through the broker: ${e.message}`);
421
- // If we tried to use the default broker account and failed, fall back to interactive authentication
422
- if (useDefaultBrokerAccount) {
423
- return getBrokeredToken(/* useDefaultBrokerAccount: */ false);
424
- }
425
- else {
426
- throw e;
427
- }
452
+ throw e;
428
453
  }
429
454
  }
430
- function createBaseInteractiveRequest() {
431
- var _a, _b;
432
- return {
433
- openBrowser: async (url) => {
434
- const open = await import("open");
435
- await open.default(url, { wait: true, newInstance: true });
436
- },
437
- scopes,
438
- authority: calculateRequestAuthority(options),
439
- claims: options === null || options === void 0 ? void 0 : options.claims,
440
- loginHint: options === null || options === void 0 ? void 0 : options.loginHint,
441
- errorTemplate: (_a = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _a === void 0 ? void 0 : _a.errorMessage,
442
- successTemplate: (_b = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _b === void 0 ? void 0 : _b.successMessage,
443
- prompt: (options === null || options === void 0 ? void 0 : options.loginHint) ? "login" : "select_account",
444
- };
445
- }
455
+ }
456
+ /**
457
+ * A helper function that supports brokered authentication through the MSAL's public application.
458
+ *
459
+ * When useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.
460
+ * If the default broker account is not available, the method will fall back to interactive authentication.
461
+ */
462
+ async function getBrokeredToken(scopes, useDefaultBrokerAccount, options = {}) {
463
+ msalLogger.getToken.info(`Attempting to acquire token using brokered authentication with useDefaultBrokerAccount: ${useDefaultBrokerAccount}`);
464
+ const response = await getBrokeredTokenInternal(scopes, useDefaultBrokerAccount, options);
465
+ (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
466
+ (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
467
+ state.cachedAccount = response?.account ?? null;
468
+ state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
469
+ return {
470
+ token: response.accessToken,
471
+ expiresOnTimestamp: response.expiresOn.getTime(),
472
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
473
+ tokenType: response.tokenType,
474
+ };
475
+ }
476
+ async function getTokenByInteractiveRequest(scopes, options = {}) {
477
+ msalLogger.getToken.info(`Attempting to acquire token interactively`);
478
+ const app = await getPublicApp(options);
446
479
  return withSilentAuthentication(app, scopes, options, async () => {
447
- var _a;
448
- const interactiveRequest = createBaseInteractiveRequest();
480
+ const interactiveRequest = createBaseInteractiveRequest(scopes, options);
449
481
  if (state.pluginConfiguration.broker.isEnabled) {
450
- return getBrokeredToken((_a = state.pluginConfiguration.broker.useDefaultBrokerAccount) !== null && _a !== void 0 ? _a : false);
482
+ return getBrokeredTokenInternal(scopes, state.pluginConfiguration.broker.useDefaultBrokerAccount ?? false, options);
451
483
  }
452
484
  if (options.proofOfPossessionOptions) {
453
485
  interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
@@ -461,6 +493,7 @@ function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
461
493
  }
462
494
  return {
463
495
  getActiveAccount,
496
+ getBrokeredToken,
464
497
  getTokenByClientSecret,
465
498
  getTokenByClientAssertion,
466
499
  getTokenByClientCertificate,