@azure/identity 4.14.0-beta.2 → 4.14.0-beta.3

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 (368) hide show
  1. package/dist/browser/constants.d.ts +1 -1
  2. package/dist/browser/constants.js +1 -1
  3. package/dist/browser/constants.js.map +1 -1
  4. package/dist/browser/credentials/authorizationCodeCredential.d.ts +3 -3
  5. package/dist/browser/credentials/authorizationCodeCredential.d.ts.map +1 -0
  6. package/dist/browser/credentials/authorizationCodeCredential.js +2 -2
  7. package/dist/browser/credentials/authorizationCodeCredential.js.map +1 -0
  8. package/dist/browser/credentials/azureCliCredential.d.ts +5 -4
  9. package/dist/browser/credentials/azureCliCredential.d.ts.map +1 -0
  10. package/dist/browser/credentials/azureCliCredential.js +3 -3
  11. package/dist/browser/credentials/azureCliCredential.js.map +1 -0
  12. package/dist/browser/credentials/azureDeveloperCliCredential.d.ts +5 -4
  13. package/dist/browser/credentials/azureDeveloperCliCredential.d.ts.map +1 -0
  14. package/dist/browser/credentials/azureDeveloperCliCredential.js +3 -3
  15. package/dist/browser/credentials/azureDeveloperCliCredential.js.map +1 -0
  16. package/dist/browser/credentials/azurePipelinesCredential.d.ts +5 -4
  17. package/dist/browser/credentials/azurePipelinesCredential.d.ts.map +1 -0
  18. package/dist/browser/credentials/azurePipelinesCredential.js +3 -3
  19. package/dist/browser/credentials/azurePipelinesCredential.js.map +1 -0
  20. package/dist/browser/credentials/azurePowerShellCredential.d.ts +5 -4
  21. package/dist/browser/credentials/azurePowerShellCredential.d.ts.map +1 -0
  22. package/dist/browser/credentials/azurePowerShellCredential.js +3 -3
  23. package/dist/browser/credentials/azurePowerShellCredential.js.map +1 -0
  24. package/dist/browser/credentials/clientAssertionCredential.d.ts +5 -4
  25. package/dist/browser/credentials/clientAssertionCredential.d.ts.map +1 -0
  26. package/dist/browser/credentials/clientAssertionCredential.js +3 -3
  27. package/dist/browser/credentials/clientAssertionCredential.js.map +1 -0
  28. package/dist/browser/credentials/clientCertificateCredential.d.ts +6 -4
  29. package/dist/browser/credentials/clientCertificateCredential.d.ts.map +1 -0
  30. package/dist/browser/credentials/clientCertificateCredential.js +3 -3
  31. package/dist/browser/credentials/clientCertificateCredential.js.map +1 -0
  32. package/dist/browser/credentials/clientSecretCredential.d.ts +1 -1
  33. package/dist/browser/credentials/clientSecretCredential.d.ts.map +1 -0
  34. package/dist/browser/credentials/clientSecretCredential.js +1 -1
  35. package/dist/browser/credentials/clientSecretCredential.js.map +1 -0
  36. package/dist/browser/credentials/defaultAzureCredential.d.ts +3 -3
  37. package/dist/browser/credentials/defaultAzureCredential.d.ts.map +1 -0
  38. package/dist/browser/credentials/defaultAzureCredential.js +2 -2
  39. package/dist/browser/credentials/defaultAzureCredential.js.map +1 -0
  40. package/dist/browser/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  41. package/dist/browser/credentials/defaultAzureCredentialOptions.js.map +1 -1
  42. package/dist/browser/credentials/deviceCodeCredential.d.ts +5 -4
  43. package/dist/browser/credentials/deviceCodeCredential.d.ts.map +1 -0
  44. package/dist/browser/credentials/deviceCodeCredential.js +3 -3
  45. package/dist/browser/credentials/deviceCodeCredential.js.map +1 -0
  46. package/dist/browser/credentials/environmentCredential.d.ts +5 -4
  47. package/dist/browser/credentials/environmentCredential.d.ts.map +1 -0
  48. package/dist/browser/credentials/environmentCredential.js +3 -3
  49. package/dist/browser/credentials/environmentCredential.js.map +1 -0
  50. package/dist/browser/credentials/interactiveBrowserCredential.d.ts +1 -1
  51. package/dist/browser/credentials/interactiveBrowserCredential.d.ts.map +1 -0
  52. package/dist/browser/credentials/interactiveBrowserCredential.js +1 -1
  53. package/dist/browser/credentials/interactiveBrowserCredential.js.map +1 -0
  54. package/dist/browser/credentials/managedIdentityCredential/index.d.ts +9 -4
  55. package/dist/browser/credentials/managedIdentityCredential/index.d.ts.map +1 -0
  56. package/dist/browser/credentials/managedIdentityCredential/index.js +3 -3
  57. package/dist/browser/credentials/managedIdentityCredential/index.js.map +1 -0
  58. package/dist/browser/credentials/onBehalfOfCredential.d.ts +5 -4
  59. package/dist/browser/credentials/onBehalfOfCredential.d.ts.map +1 -0
  60. package/dist/browser/credentials/onBehalfOfCredential.js +3 -3
  61. package/dist/browser/credentials/onBehalfOfCredential.js.map +1 -0
  62. package/dist/browser/credentials/usernamePasswordCredential.d.ts +1 -1
  63. package/dist/browser/credentials/usernamePasswordCredential.d.ts.map +1 -0
  64. package/dist/browser/credentials/usernamePasswordCredential.js +1 -1
  65. package/dist/browser/credentials/usernamePasswordCredential.js.map +1 -0
  66. package/dist/browser/credentials/visualStudioCodeCredential.d.ts +5 -4
  67. package/dist/browser/credentials/visualStudioCodeCredential.d.ts.map +1 -0
  68. package/dist/browser/credentials/visualStudioCodeCredential.js +3 -3
  69. package/dist/browser/credentials/visualStudioCodeCredential.js.map +1 -0
  70. package/dist/browser/credentials/workloadIdentityCredential.d.ts +5 -4
  71. package/dist/browser/credentials/workloadIdentityCredential.d.ts.map +1 -0
  72. package/dist/browser/credentials/workloadIdentityCredential.js +3 -3
  73. package/dist/browser/credentials/workloadIdentityCredential.js.map +1 -0
  74. package/dist/browser/index.d.ts +33 -33
  75. package/dist/browser/index.d.ts.map +1 -1
  76. package/dist/browser/index.js.map +1 -1
  77. package/dist/browser/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  78. package/dist/browser/msal/browserFlows/msalBrowserCommon.js +2 -3
  79. package/dist/browser/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  80. package/dist/browser/msal/msal.d.ts +2 -3
  81. package/dist/browser/msal/msal.d.ts.map +1 -0
  82. package/dist/browser/msal/msal.js +2 -3
  83. package/dist/browser/msal/msal.js.map +1 -0
  84. package/dist/browser/msal/nodeFlows/msalClient.d.ts +2 -2
  85. package/dist/browser/msal/nodeFlows/msalClient.d.ts.map +1 -1
  86. package/dist/browser/msal/nodeFlows/msalClient.js +3 -3
  87. package/dist/browser/msal/nodeFlows/msalClient.js.map +1 -1
  88. package/dist/browser/msal/utils.d.ts +5 -4
  89. package/dist/browser/msal/utils.d.ts.map +1 -1
  90. package/dist/browser/msal/utils.js +10 -10
  91. package/dist/browser/msal/utils.js.map +1 -1
  92. package/dist/browser/plugins/consumer.d.ts +1 -1
  93. package/dist/browser/plugins/consumer.d.ts.map +1 -0
  94. package/dist/browser/plugins/consumer.js +1 -1
  95. package/dist/browser/plugins/consumer.js.map +1 -0
  96. package/dist/browser/util/processMultiTenantRequest.d.ts +3 -2
  97. package/dist/browser/util/processMultiTenantRequest.d.ts.map +1 -0
  98. package/dist/browser/util/processMultiTenantRequest.js +2 -2
  99. package/dist/browser/util/processMultiTenantRequest.js.map +1 -0
  100. package/dist/commonjs/client/identityClient.js +294 -288
  101. package/dist/commonjs/client/identityClient.js.map +7 -1
  102. package/dist/commonjs/constants.d.ts +1 -1
  103. package/dist/commonjs/constants.js +61 -78
  104. package/dist/commonjs/constants.js.map +7 -1
  105. package/dist/commonjs/credentials/authorityValidationOptions.js +16 -5
  106. package/dist/commonjs/credentials/authorityValidationOptions.js.map +7 -1
  107. package/dist/commonjs/credentials/authorizationCodeCredential.js +98 -74
  108. package/dist/commonjs/credentials/authorizationCodeCredential.js.map +7 -1
  109. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.js +16 -5
  110. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.js.map +7 -1
  111. package/dist/commonjs/credentials/azureCliCredential.js +245 -214
  112. package/dist/commonjs/credentials/azureCliCredential.js.map +7 -1
  113. package/dist/commonjs/credentials/azureCliCredentialOptions.js +16 -5
  114. package/dist/commonjs/credentials/azureCliCredentialOptions.js.map +7 -1
  115. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +237 -225
  116. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +7 -1
  117. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.js +16 -5
  118. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.js.map +7 -1
  119. package/dist/commonjs/credentials/azurePipelinesCredential.js +173 -135
  120. package/dist/commonjs/credentials/azurePipelinesCredential.js.map +7 -1
  121. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.js +16 -5
  122. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.js.map +7 -1
  123. package/dist/commonjs/credentials/azurePowerShellCredential.js +201 -205
  124. package/dist/commonjs/credentials/azurePowerShellCredential.js.map +7 -1
  125. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.js +16 -5
  126. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.js.map +7 -1
  127. package/dist/commonjs/credentials/brokerAuthOptions.js +16 -3
  128. package/dist/commonjs/credentials/brokerAuthOptions.js.map +7 -1
  129. package/dist/commonjs/credentials/brokerCredential.js +103 -70
  130. package/dist/commonjs/credentials/brokerCredential.js.map +7 -1
  131. package/dist/commonjs/credentials/browserCustomizationOptions.js +16 -5
  132. package/dist/commonjs/credentials/browserCustomizationOptions.js.map +7 -1
  133. package/dist/commonjs/credentials/chainedTokenCredential.js +113 -93
  134. package/dist/commonjs/credentials/chainedTokenCredential.js.map +7 -1
  135. package/dist/commonjs/credentials/clientAssertionCredential.js +101 -63
  136. package/dist/commonjs/credentials/clientAssertionCredential.js.map +7 -1
  137. package/dist/commonjs/credentials/clientAssertionCredentialOptions.js +16 -5
  138. package/dist/commonjs/credentials/clientAssertionCredentialOptions.js.map +7 -1
  139. package/dist/commonjs/credentials/clientCertificateCredential.js +129 -123
  140. package/dist/commonjs/credentials/clientCertificateCredential.js.map +7 -1
  141. package/dist/commonjs/credentials/clientCertificateCredentialModels.js +16 -5
  142. package/dist/commonjs/credentials/clientCertificateCredentialModels.js.map +7 -1
  143. package/dist/commonjs/credentials/clientCertificateCredentialOptions.js +16 -5
  144. package/dist/commonjs/credentials/clientCertificateCredentialOptions.js.map +7 -1
  145. package/dist/commonjs/credentials/clientSecretCredential.js +96 -67
  146. package/dist/commonjs/credentials/clientSecretCredential.js.map +7 -1
  147. package/dist/commonjs/credentials/clientSecretCredentialOptions.js +16 -5
  148. package/dist/commonjs/credentials/clientSecretCredentialOptions.js.map +7 -1
  149. package/dist/commonjs/credentials/credentialPersistenceOptions.js +16 -5
  150. package/dist/commonjs/credentials/credentialPersistenceOptions.js.map +7 -1
  151. package/dist/commonjs/credentials/defaultAzureCredential.js +121 -159
  152. package/dist/commonjs/credentials/defaultAzureCredential.js.map +7 -1
  153. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js +110 -140
  154. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js.map +7 -1
  155. package/dist/commonjs/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  156. package/dist/commonjs/credentials/defaultAzureCredentialOptions.js +16 -5
  157. package/dist/commonjs/credentials/defaultAzureCredentialOptions.js.map +7 -1
  158. package/dist/commonjs/credentials/deviceCodeCredential.js +132 -103
  159. package/dist/commonjs/credentials/deviceCodeCredential.js.map +7 -1
  160. package/dist/commonjs/credentials/deviceCodeCredentialOptions.js +16 -5
  161. package/dist/commonjs/credentials/deviceCodeCredentialOptions.js.map +7 -1
  162. package/dist/commonjs/credentials/environmentCredential.js +157 -123
  163. package/dist/commonjs/credentials/environmentCredential.js.map +7 -1
  164. package/dist/commonjs/credentials/environmentCredentialOptions.js +16 -5
  165. package/dist/commonjs/credentials/environmentCredentialOptions.js.map +7 -1
  166. package/dist/commonjs/credentials/interactiveBrowserCredential.js +144 -107
  167. package/dist/commonjs/credentials/interactiveBrowserCredential.js.map +7 -1
  168. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.js +16 -5
  169. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.js.map +7 -1
  170. package/dist/commonjs/credentials/interactiveCredentialOptions.js +16 -5
  171. package/dist/commonjs/credentials/interactiveCredentialOptions.js.map +7 -1
  172. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js +92 -91
  173. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js.map +7 -1
  174. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js +51 -44
  175. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +7 -1
  176. package/dist/commonjs/credentials/managedIdentityCredential/index.js +256 -242
  177. package/dist/commonjs/credentials/managedIdentityCredential/index.js.map +7 -1
  178. package/dist/commonjs/credentials/managedIdentityCredential/models.js +16 -5
  179. package/dist/commonjs/credentials/managedIdentityCredential/models.js.map +7 -1
  180. package/dist/commonjs/credentials/managedIdentityCredential/options.js +16 -5
  181. package/dist/commonjs/credentials/managedIdentityCredential/options.js.map +7 -1
  182. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js +56 -39
  183. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +7 -1
  184. package/dist/commonjs/credentials/managedIdentityCredential/utils.js +79 -75
  185. package/dist/commonjs/credentials/managedIdentityCredential/utils.js.map +7 -1
  186. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.js +16 -5
  187. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.js.map +7 -1
  188. package/dist/commonjs/credentials/onBehalfOfCredential.js +168 -126
  189. package/dist/commonjs/credentials/onBehalfOfCredential.js.map +7 -1
  190. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.js +16 -5
  191. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.js.map +7 -1
  192. package/dist/commonjs/credentials/usernamePasswordCredential.js +112 -75
  193. package/dist/commonjs/credentials/usernamePasswordCredential.js.map +7 -1
  194. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.js +16 -5
  195. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.js.map +7 -1
  196. package/dist/commonjs/credentials/visualStudioCodeCredential.js +144 -132
  197. package/dist/commonjs/credentials/visualStudioCodeCredential.js.map +7 -1
  198. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js +16 -5
  199. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js.map +7 -1
  200. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js +16 -5
  201. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js.map +7 -1
  202. package/dist/commonjs/credentials/workloadIdentityCredential.js +284 -274
  203. package/dist/commonjs/credentials/workloadIdentityCredential.js.map +7 -1
  204. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.js +16 -5
  205. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.js.map +7 -1
  206. package/dist/commonjs/errors.js +131 -132
  207. package/dist/commonjs/errors.js.map +7 -1
  208. package/dist/commonjs/index.d.ts +33 -33
  209. package/dist/commonjs/index.d.ts.map +1 -1
  210. package/dist/commonjs/index.js +115 -67
  211. package/dist/commonjs/index.js.map +7 -1
  212. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  213. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js +226 -249
  214. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js.map +7 -1
  215. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js +16 -5
  216. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js.map +7 -1
  217. package/dist/commonjs/msal/credentials.js +16 -5
  218. package/dist/commonjs/msal/credentials.js.map +7 -1
  219. package/dist/commonjs/msal/msal.d.ts +1 -2
  220. package/dist/commonjs/msal/msal.d.ts.map +1 -1
  221. package/dist/commonjs/msal/msal.js +30 -9
  222. package/dist/commonjs/msal/msal.js.map +7 -1
  223. package/dist/commonjs/msal/nodeFlows/brokerOptions.js +16 -3
  224. package/dist/commonjs/msal/nodeFlows/brokerOptions.js.map +7 -1
  225. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts +2 -2
  226. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts.map +1 -1
  227. package/dist/commonjs/msal/nodeFlows/msalClient.js +450 -478
  228. package/dist/commonjs/msal/nodeFlows/msalClient.js.map +7 -1
  229. package/dist/commonjs/msal/nodeFlows/msalPlugins.js +140 -147
  230. package/dist/commonjs/msal/nodeFlows/msalPlugins.js.map +7 -1
  231. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.js +16 -5
  232. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.js.map +7 -1
  233. package/dist/commonjs/msal/types.js +16 -5
  234. package/dist/commonjs/msal/types.js.map +7 -1
  235. package/dist/commonjs/msal/utils.d.ts +5 -4
  236. package/dist/commonjs/msal/utils.d.ts.map +1 -1
  237. package/dist/commonjs/msal/utils.js +171 -211
  238. package/dist/commonjs/msal/utils.js.map +7 -1
  239. package/dist/commonjs/plugins/consumer.js +32 -40
  240. package/dist/commonjs/plugins/consumer.js.map +7 -1
  241. package/dist/commonjs/plugins/provider.js +16 -5
  242. package/dist/commonjs/plugins/provider.js.map +7 -1
  243. package/dist/commonjs/regionalAuthority.js +93 -141
  244. package/dist/commonjs/regionalAuthority.js.map +7 -1
  245. package/dist/commonjs/tokenCredentialOptions.js +16 -5
  246. package/dist/commonjs/tokenCredentialOptions.js.map +7 -1
  247. package/dist/commonjs/tokenProvider.js +52 -52
  248. package/dist/commonjs/tokenProvider.js.map +7 -1
  249. package/dist/commonjs/tsdoc-metadata.json +1 -1
  250. package/dist/commonjs/util/authorityHost.js +34 -19
  251. package/dist/commonjs/util/authorityHost.js.map +7 -1
  252. package/dist/commonjs/util/certificatesUtils.js +54 -45
  253. package/dist/commonjs/util/certificatesUtils.js.map +7 -1
  254. package/dist/commonjs/util/identityTokenEndpoint.js +32 -12
  255. package/dist/commonjs/util/identityTokenEndpoint.js.map +7 -1
  256. package/dist/commonjs/util/logging.js +91 -97
  257. package/dist/commonjs/util/logging.js.map +7 -1
  258. package/dist/commonjs/util/processMultiTenantRequest.js +43 -33
  259. package/dist/commonjs/util/processMultiTenantRequest.js.map +7 -1
  260. package/dist/commonjs/util/processUtils.js +60 -35
  261. package/dist/commonjs/util/processUtils.js.map +7 -1
  262. package/dist/commonjs/util/scopeUtils.js +39 -28
  263. package/dist/commonjs/util/scopeUtils.js.map +7 -1
  264. package/dist/commonjs/util/subscriptionUtils.js +35 -17
  265. package/dist/commonjs/util/subscriptionUtils.js.map +7 -1
  266. package/dist/commonjs/util/tenantIdUtils.js +61 -45
  267. package/dist/commonjs/util/tenantIdUtils.js.map +7 -1
  268. package/dist/commonjs/util/tracing.js +33 -16
  269. package/dist/commonjs/util/tracing.js.map +7 -1
  270. package/dist/esm/constants.d.ts +1 -1
  271. package/dist/esm/constants.js +1 -1
  272. package/dist/esm/constants.js.map +1 -1
  273. package/dist/esm/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  274. package/dist/esm/credentials/defaultAzureCredentialOptions.js.map +1 -1
  275. package/dist/esm/index.d.ts +33 -33
  276. package/dist/esm/index.d.ts.map +1 -1
  277. package/dist/esm/index.js.map +1 -1
  278. package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  279. package/dist/esm/msal/browserFlows/msalBrowserCommon.js +2 -3
  280. package/dist/esm/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  281. package/dist/esm/msal/msal.d.ts +1 -2
  282. package/dist/esm/msal/msal.d.ts.map +1 -1
  283. package/dist/esm/msal/msal.js +1 -2
  284. package/dist/esm/msal/msal.js.map +1 -1
  285. package/dist/esm/msal/nodeFlows/msalClient.d.ts +2 -2
  286. package/dist/esm/msal/nodeFlows/msalClient.d.ts.map +1 -1
  287. package/dist/esm/msal/nodeFlows/msalClient.js +3 -3
  288. package/dist/esm/msal/nodeFlows/msalClient.js.map +1 -1
  289. package/dist/esm/msal/utils.d.ts +5 -4
  290. package/dist/esm/msal/utils.d.ts.map +1 -1
  291. package/dist/esm/msal/utils.js +10 -10
  292. package/dist/esm/msal/utils.js.map +1 -1
  293. package/dist/workerd/constants.d.ts +1 -1
  294. package/dist/workerd/constants.js +1 -1
  295. package/dist/workerd/constants.js.map +1 -1
  296. package/dist/workerd/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  297. package/dist/workerd/credentials/defaultAzureCredentialOptions.js.map +1 -1
  298. package/dist/workerd/index.d.ts +33 -33
  299. package/dist/workerd/index.d.ts.map +1 -1
  300. package/dist/workerd/index.js.map +1 -1
  301. package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  302. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js +2 -3
  303. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  304. package/dist/workerd/msal/msal.d.ts +1 -2
  305. package/dist/workerd/msal/msal.d.ts.map +1 -1
  306. package/dist/workerd/msal/msal.js +1 -2
  307. package/dist/workerd/msal/msal.js.map +1 -1
  308. package/dist/workerd/msal/nodeFlows/msalClient.d.ts +2 -2
  309. package/dist/workerd/msal/nodeFlows/msalClient.d.ts.map +1 -1
  310. package/dist/workerd/msal/nodeFlows/msalClient.js +3 -3
  311. package/dist/workerd/msal/nodeFlows/msalClient.js.map +1 -1
  312. package/dist/workerd/msal/utils.d.ts +5 -4
  313. package/dist/workerd/msal/utils.d.ts.map +1 -1
  314. package/dist/workerd/msal/utils.js +10 -10
  315. package/dist/workerd/msal/utils.js.map +1 -1
  316. package/package.json +10 -27
  317. package/dist/browser/credentials/authorizationCodeCredential-browser.d.mts.map +0 -1
  318. package/dist/browser/credentials/authorizationCodeCredential-browser.mjs.map +0 -1
  319. package/dist/browser/credentials/azureCliCredential-browser.d.mts.map +0 -1
  320. package/dist/browser/credentials/azureCliCredential-browser.mjs.map +0 -1
  321. package/dist/browser/credentials/azureDeveloperCliCredential-browser.d.mts.map +0 -1
  322. package/dist/browser/credentials/azureDeveloperCliCredential-browser.mjs.map +0 -1
  323. package/dist/browser/credentials/azurePipelinesCredential-browser.d.mts.map +0 -1
  324. package/dist/browser/credentials/azurePipelinesCredential-browser.mjs.map +0 -1
  325. package/dist/browser/credentials/azurePowerShellCredential-browser.d.mts.map +0 -1
  326. package/dist/browser/credentials/azurePowerShellCredential-browser.mjs.map +0 -1
  327. package/dist/browser/credentials/clientAssertionCredential-browser.d.mts.map +0 -1
  328. package/dist/browser/credentials/clientAssertionCredential-browser.mjs.map +0 -1
  329. package/dist/browser/credentials/clientCertificateCredential-browser.d.mts.map +0 -1
  330. package/dist/browser/credentials/clientCertificateCredential-browser.mjs.map +0 -1
  331. package/dist/browser/credentials/clientSecretCredential-browser.d.mts.map +0 -1
  332. package/dist/browser/credentials/clientSecretCredential-browser.mjs.map +0 -1
  333. package/dist/browser/credentials/defaultAzureCredential-browser.d.mts.map +0 -1
  334. package/dist/browser/credentials/defaultAzureCredential-browser.mjs.map +0 -1
  335. package/dist/browser/credentials/deviceCodeCredential-browser.d.mts.map +0 -1
  336. package/dist/browser/credentials/deviceCodeCredential-browser.mjs.map +0 -1
  337. package/dist/browser/credentials/environmentCredential-browser.d.mts.map +0 -1
  338. package/dist/browser/credentials/environmentCredential-browser.mjs.map +0 -1
  339. package/dist/browser/credentials/interactiveBrowserCredential-browser.d.mts.map +0 -1
  340. package/dist/browser/credentials/interactiveBrowserCredential-browser.mjs.map +0 -1
  341. package/dist/browser/credentials/managedIdentityCredential/index-browser.d.mts.map +0 -1
  342. package/dist/browser/credentials/managedIdentityCredential/index-browser.mjs.map +0 -1
  343. package/dist/browser/credentials/onBehalfOfCredential-browser.d.mts.map +0 -1
  344. package/dist/browser/credentials/onBehalfOfCredential-browser.mjs.map +0 -1
  345. package/dist/browser/credentials/usernamePasswordCredential-browser.d.mts.map +0 -1
  346. package/dist/browser/credentials/usernamePasswordCredential-browser.mjs.map +0 -1
  347. package/dist/browser/credentials/visualStudioCodeCredential-browser.d.mts.map +0 -1
  348. package/dist/browser/credentials/visualStudioCodeCredential-browser.mjs.map +0 -1
  349. package/dist/browser/credentials/workloadIdentityCredential-browser.d.mts.map +0 -1
  350. package/dist/browser/credentials/workloadIdentityCredential-browser.mjs.map +0 -1
  351. package/dist/browser/msal/msal-browser.d.mts.map +0 -1
  352. package/dist/browser/msal/msal-browser.mjs.map +0 -1
  353. package/dist/browser/plugins/consumer-browser.d.mts.map +0 -1
  354. package/dist/browser/plugins/consumer-browser.mjs.map +0 -1
  355. package/dist/browser/util/authHostEnv-browser.d.mts +0 -4
  356. package/dist/browser/util/authHostEnv-browser.d.mts.map +0 -1
  357. package/dist/browser/util/authHostEnv-browser.mjs +0 -7
  358. package/dist/browser/util/authHostEnv-browser.mjs.map +0 -1
  359. package/dist/browser/util/processMultiTenantRequest-browser.d.mts.map +0 -1
  360. package/dist/browser/util/processMultiTenantRequest-browser.mjs.map +0 -1
  361. package/dist/esm/util/authHostEnv-browser.d.mts +0 -4
  362. package/dist/esm/util/authHostEnv-browser.d.mts.map +0 -1
  363. package/dist/esm/util/authHostEnv-browser.mjs +0 -7
  364. package/dist/esm/util/authHostEnv-browser.mjs.map +0 -1
  365. package/dist/workerd/util/authHostEnv-browser.d.mts +0 -4
  366. package/dist/workerd/util/authHostEnv-browser.d.mts.map +0 -1
  367. package/dist/workerd/util/authHostEnv-browser.mjs +0 -7
  368. package/dist/workerd/util/authHostEnv-browser.mjs.map +0 -1
@@ -1,504 +1,476 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.generateMsalConfiguration = generateMsalConfiguration;
6
- exports.createMsalClient = createMsalClient;
7
- const tslib_1 = require("tslib");
8
- const msal = tslib_1.__importStar(require("@azure/msal-node"));
9
- const logging_js_1 = require("../../util/logging.js");
10
- const msalPlugins_js_1 = require("./msalPlugins.js");
11
- const utils_js_1 = require("../utils.js");
12
- const errors_js_1 = require("../../errors.js");
13
- const identityClient_js_1 = require("../../client/identityClient.js");
14
- const regionalAuthority_js_1 = require("../../regionalAuthority.js");
15
- const logger_1 = require("@azure/logger");
16
- const tenantIdUtils_js_1 = require("../../util/tenantIdUtils.js");
17
- const authorityHost_js_1 = require("../../util/authorityHost.js");
18
- /**
19
- * The default logger used if no logger was passed in by the credential.
20
- */
21
- const msalLogger = (0, logging_js_1.credentialLogger)("MsalClient");
22
- /**
23
- * Generates the configuration for MSAL (Microsoft Authentication Library).
24
- *
25
- * @param clientId - The client ID of the application.
26
- * @param tenantId - The tenant ID of the Azure Active Directory.
27
- * @param msalClientOptions - Optional. Additional options for creating the MSAL client.
28
- * @returns The MSAL configuration object.
29
- */
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var msalClient_exports = {};
29
+ __export(msalClient_exports, {
30
+ createMsalClient: () => createMsalClient,
31
+ generateMsalConfiguration: () => generateMsalConfiguration
32
+ });
33
+ module.exports = __toCommonJS(msalClient_exports);
34
+ var msal = __toESM(require("@azure/msal-node"));
35
+ var import_logging = require("../../util/logging.js");
36
+ var import_msalPlugins = require("./msalPlugins.js");
37
+ var import_utils = require("../utils.js");
38
+ var import_errors = require("../../errors.js");
39
+ var import_identityClient = require("../../client/identityClient.js");
40
+ var import_regionalAuthority = require("../../regionalAuthority.js");
41
+ var import_logger = require("@azure/logger");
42
+ var import_tenantIdUtils = require("../../util/tenantIdUtils.js");
43
+ var import_authorityHost = require("../../util/authorityHost.js");
44
+ const msalLogger = (0, import_logging.credentialLogger)("MsalClient");
30
45
  function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
31
- const resolvedTenant = (0, tenantIdUtils_js_1.resolveTenantId)(msalClientOptions.logger ?? msalLogger, tenantId, clientId);
32
- const authority = (0, utils_js_1.getAuthority)(resolvedTenant, (0, authorityHost_js_1.getAuthorityHost)(msalClientOptions));
33
- const httpClient = new identityClient_js_1.IdentityClient({
34
- ...msalClientOptions,
35
- authorityHost: authority,
36
- loggingOptions: msalClientOptions.loggingOptions,
37
- });
38
- const msalConfig = {
39
- auth: {
40
- clientId,
41
- authority,
42
- knownAuthorities: (0, utils_js_1.getKnownAuthorities)(resolvedTenant, authority, msalClientOptions.disableInstanceDiscovery),
43
- },
44
- system: {
45
- networkClient: httpClient,
46
- loggerOptions: {
47
- loggerCallback: (0, utils_js_1.defaultLoggerCallback)(msalClientOptions.logger ?? msalLogger),
48
- logLevel: (0, utils_js_1.getMSALLogLevel)((0, logger_1.getLogLevel)()),
49
- piiLoggingEnabled: msalClientOptions.loggingOptions?.enableUnsafeSupportLogging,
50
- },
51
- },
52
- };
53
- return msalConfig;
46
+ const resolvedTenant = (0, import_tenantIdUtils.resolveTenantId)(
47
+ msalClientOptions.logger ?? msalLogger,
48
+ tenantId,
49
+ clientId
50
+ );
51
+ const authority = (0, import_utils.getAuthority)(resolvedTenant, (0, import_authorityHost.getAuthorityHost)(msalClientOptions));
52
+ const httpClient = new import_identityClient.IdentityClient({
53
+ ...msalClientOptions,
54
+ authorityHost: authority,
55
+ loggingOptions: msalClientOptions.loggingOptions
56
+ });
57
+ const msalConfig = {
58
+ auth: {
59
+ clientId,
60
+ authority,
61
+ knownAuthorities: (0, import_utils.getKnownAuthorities)(
62
+ resolvedTenant,
63
+ authority,
64
+ msalClientOptions.disableInstanceDiscovery
65
+ )
66
+ },
67
+ system: {
68
+ networkClient: httpClient,
69
+ loggerOptions: {
70
+ loggerCallback: (0, import_utils.defaultLoggerCallback)(msalClientOptions.logger ?? msalLogger),
71
+ logLevel: (0, import_utils.getMSALLogLevel)((0, import_logger.getLogLevel)()),
72
+ piiLoggingEnabled: msalClientOptions.loggingOptions?.enableUnsafeSupportLogging
73
+ }
74
+ }
75
+ };
76
+ return msalConfig;
54
77
  }
55
- /**
56
- * Creates an instance of the MSAL (Microsoft Authentication Library) client.
57
- *
58
- * @param clientId - The client ID of the application.
59
- * @param tenantId - The tenant ID of the Azure Active Directory.
60
- * @param createMsalClientOptions - Optional. Additional options for creating the MSAL client.
61
- * @returns An instance of the MSAL client.
62
- *
63
- * @public
64
- */
65
78
  function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
66
- const state = {
67
- msalConfig: generateMsalConfiguration(clientId, tenantId, createMsalClientOptions),
68
- cachedAccount: createMsalClientOptions.authenticationRecord
69
- ? (0, utils_js_1.publicToMsal)(createMsalClientOptions.authenticationRecord)
70
- : null,
71
- pluginConfiguration: msalPlugins_js_1.msalPlugins.generatePluginConfiguration(createMsalClientOptions),
72
- logger: createMsalClientOptions.logger ?? msalLogger,
73
- };
74
- const publicApps = new Map();
75
- async function getPublicApp(options = {}) {
76
- const appKey = options.enableCae ? "CAE" : "default";
77
- let publicClientApp = publicApps.get(appKey);
78
- if (publicClientApp) {
79
- state.logger.getToken.info("Existing PublicClientApplication found in cache, returning it.");
80
- return publicClientApp;
81
- }
82
- // Initialize a new app and cache it
83
- state.logger.getToken.info(`Creating new PublicClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`);
84
- const cachePlugin = options.enableCae
85
- ? state.pluginConfiguration.cache.cachePluginCae
86
- : state.pluginConfiguration.cache.cachePlugin;
87
- state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : undefined;
88
- publicClientApp = new msal.PublicClientApplication({
89
- ...state.msalConfig,
90
- broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin },
91
- cache: { cachePlugin: await cachePlugin },
92
- });
93
- publicApps.set(appKey, publicClientApp);
94
- return publicClientApp;
79
+ const state = {
80
+ msalConfig: generateMsalConfiguration(clientId, tenantId, createMsalClientOptions),
81
+ cachedAccount: createMsalClientOptions.authenticationRecord ? (0, import_utils.publicToMsal)(createMsalClientOptions.authenticationRecord) : null,
82
+ pluginConfiguration: import_msalPlugins.msalPlugins.generatePluginConfiguration(createMsalClientOptions),
83
+ logger: createMsalClientOptions.logger ?? msalLogger
84
+ };
85
+ const publicApps = /* @__PURE__ */ new Map();
86
+ async function getPublicApp(options = {}) {
87
+ const appKey = options.enableCae ? "CAE" : "default";
88
+ let publicClientApp = publicApps.get(appKey);
89
+ if (publicClientApp) {
90
+ state.logger.getToken.info("Existing PublicClientApplication found in cache, returning it.");
91
+ return publicClientApp;
95
92
  }
96
- const confidentialApps = new Map();
97
- async function getConfidentialApp(options = {}) {
98
- const appKey = options.enableCae ? "CAE" : "default";
99
- let confidentialClientApp = confidentialApps.get(appKey);
100
- if (confidentialClientApp) {
101
- state.logger.getToken.info("Existing ConfidentialClientApplication found in cache, returning it.");
102
- return confidentialClientApp;
103
- }
104
- // Initialize a new app and cache it
105
- state.logger.getToken.info(`Creating new ConfidentialClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`);
106
- const cachePlugin = options.enableCae
107
- ? state.pluginConfiguration.cache.cachePluginCae
108
- : state.pluginConfiguration.cache.cachePlugin;
109
- state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : undefined;
110
- confidentialClientApp = new msal.ConfidentialClientApplication({
111
- ...state.msalConfig,
112
- broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin },
113
- cache: { cachePlugin: await cachePlugin },
114
- });
115
- confidentialApps.set(appKey, confidentialClientApp);
116
- return confidentialClientApp;
93
+ state.logger.getToken.info(
94
+ `Creating new PublicClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`
95
+ );
96
+ const cachePlugin = options.enableCae ? state.pluginConfiguration.cache.cachePluginCae : state.pluginConfiguration.cache.cachePlugin;
97
+ state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : void 0;
98
+ publicClientApp = new msal.PublicClientApplication({
99
+ ...state.msalConfig,
100
+ broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin },
101
+ cache: { cachePlugin: await cachePlugin }
102
+ });
103
+ publicApps.set(appKey, publicClientApp);
104
+ return publicClientApp;
105
+ }
106
+ const confidentialApps = /* @__PURE__ */ new Map();
107
+ async function getConfidentialApp(options = {}) {
108
+ const appKey = options.enableCae ? "CAE" : "default";
109
+ let confidentialClientApp = confidentialApps.get(appKey);
110
+ if (confidentialClientApp) {
111
+ state.logger.getToken.info(
112
+ "Existing ConfidentialClientApplication found in cache, returning it."
113
+ );
114
+ return confidentialClientApp;
117
115
  }
118
- async function getTokenSilent(app, scopes, options = {}) {
119
- if (state.cachedAccount === null) {
120
- state.logger.getToken.info("No cached account found in local state.");
121
- throw new errors_js_1.AuthenticationRequiredError({ scopes });
122
- }
123
- // Keep track and reuse the claims we received across challenges
124
- if (options.claims) {
125
- state.cachedClaims = options.claims;
126
- }
127
- const silentRequest = {
128
- account: state.cachedAccount,
129
- scopes,
130
- claims: state.cachedClaims,
131
- };
132
- if (state.pluginConfiguration.broker.isEnabled) {
133
- silentRequest.tokenQueryParameters ||= {};
134
- if (state.pluginConfiguration.broker.enableMsaPassthrough) {
135
- silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
136
- }
137
- }
138
- if (options.proofOfPossessionOptions) {
139
- silentRequest.shrNonce = options.proofOfPossessionOptions.nonce;
140
- silentRequest.authenticationScheme = "pop";
141
- silentRequest.resourceRequestMethod = options.proofOfPossessionOptions.resourceRequestMethod;
142
- silentRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
143
- }
144
- state.logger.getToken.info("Attempting to acquire token silently");
145
- try {
146
- return await app.acquireTokenSilent(silentRequest);
147
- }
148
- catch (err) {
149
- throw (0, utils_js_1.handleMsalError)(scopes, err, options);
150
- }
116
+ state.logger.getToken.info(
117
+ `Creating new ConfidentialClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`
118
+ );
119
+ const cachePlugin = options.enableCae ? state.pluginConfiguration.cache.cachePluginCae : state.pluginConfiguration.cache.cachePlugin;
120
+ state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : void 0;
121
+ confidentialClientApp = new msal.ConfidentialClientApplication({
122
+ ...state.msalConfig,
123
+ broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin },
124
+ cache: { cachePlugin: await cachePlugin }
125
+ });
126
+ confidentialApps.set(appKey, confidentialClientApp);
127
+ return confidentialClientApp;
128
+ }
129
+ async function getTokenSilent(app, scopes, options = {}) {
130
+ if (state.cachedAccount === null) {
131
+ state.logger.getToken.info("No cached account found in local state.");
132
+ throw new import_errors.AuthenticationRequiredError({ scopes });
151
133
  }
152
- /**
153
- * Builds an authority URL for the given request. The authority may be different than the one used when creating the MSAL client
154
- * if the user is creating cross-tenant requests
155
- */
156
- function calculateRequestAuthority(options) {
157
- if (options?.tenantId) {
158
- return (0, utils_js_1.getAuthority)(options.tenantId, (0, authorityHost_js_1.getAuthorityHost)(createMsalClientOptions));
159
- }
160
- return state.msalConfig.auth.authority;
134
+ if (options.claims) {
135
+ state.cachedClaims = options.claims;
161
136
  }
162
- /**
163
- * Performs silent authentication using MSAL to acquire an access token.
164
- * If silent authentication fails, falls back to interactive authentication.
165
- *
166
- * @param msalApp - The MSAL application instance.
167
- * @param scopes - The scopes for which to acquire the access token.
168
- * @param options - The options for acquiring the access token.
169
- * @param onAuthenticationRequired - A callback function to handle interactive authentication when silent authentication fails.
170
- * @returns A promise that resolves to an AccessToken object containing the access token and its expiration timestamp.
171
- */
172
- async function withSilentAuthentication(msalApp, scopes, options, onAuthenticationRequired) {
173
- let response = null;
174
- try {
175
- response = await getTokenSilent(msalApp, scopes, options);
176
- }
177
- catch (e) {
178
- if (e.name !== "AuthenticationRequiredError") {
179
- throw e;
180
- }
181
- if (options.disableAutomaticAuthentication) {
182
- throw new errors_js_1.AuthenticationRequiredError({
183
- scopes,
184
- getTokenOptions: options,
185
- message: "Automatic authentication has been disabled. You may call the authentication() method.",
186
- });
187
- }
188
- }
189
- // Silent authentication failed
190
- if (response === null) {
191
- try {
192
- response = await onAuthenticationRequired();
193
- }
194
- catch (err) {
195
- throw (0, utils_js_1.handleMsalError)(scopes, err, options);
196
- }
197
- }
198
- // At this point we should have a token, process it
199
- (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
200
- state.cachedAccount = response?.account ?? null;
201
- state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
202
- return {
203
- token: response.accessToken,
204
- expiresOnTimestamp: response.expiresOn.getTime(),
205
- refreshAfterTimestamp: response.refreshOn?.getTime(),
206
- tokenType: response.tokenType,
207
- };
137
+ const silentRequest = {
138
+ account: state.cachedAccount,
139
+ scopes,
140
+ claims: state.cachedClaims
141
+ };
142
+ if (state.pluginConfiguration.broker.isEnabled) {
143
+ silentRequest.extraQueryParameters ||= {};
144
+ if (state.pluginConfiguration.broker.enableMsaPassthrough) {
145
+ silentRequest.extraQueryParameters["msal_request_type"] = "consumer_passthrough";
146
+ }
208
147
  }
209
- async function getTokenByClientSecret(scopes, clientSecret, options = {}) {
210
- state.logger.getToken.info(`Attempting to acquire token using client secret`);
211
- state.msalConfig.auth.clientSecret = clientSecret;
212
- const msalApp = await getConfidentialApp(options);
213
- try {
214
- const response = await msalApp.acquireTokenByClientCredential({
215
- scopes,
216
- authority: calculateRequestAuthority(options),
217
- azureRegion: (0, regionalAuthority_js_1.calculateRegionalAuthority)(),
218
- claims: options?.claims,
219
- });
220
- (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
221
- state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
222
- return {
223
- token: response.accessToken,
224
- expiresOnTimestamp: response.expiresOn.getTime(),
225
- refreshAfterTimestamp: response.refreshOn?.getTime(),
226
- tokenType: response.tokenType,
227
- };
228
- }
229
- catch (err) {
230
- throw (0, utils_js_1.handleMsalError)(scopes, err, options);
231
- }
148
+ if (options.proofOfPossessionOptions) {
149
+ silentRequest.shrNonce = options.proofOfPossessionOptions.nonce;
150
+ silentRequest.authenticationScheme = "pop";
151
+ silentRequest.resourceRequestMethod = options.proofOfPossessionOptions.resourceRequestMethod;
152
+ silentRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
232
153
  }
233
- async function getTokenByClientAssertion(scopes, clientAssertion, options = {}) {
234
- state.logger.getToken.info(`Attempting to acquire token using client assertion`);
235
- state.msalConfig.auth.clientAssertion = clientAssertion;
236
- const msalApp = await getConfidentialApp(options);
237
- try {
238
- const response = await msalApp.acquireTokenByClientCredential({
239
- scopes,
240
- authority: calculateRequestAuthority(options),
241
- azureRegion: (0, regionalAuthority_js_1.calculateRegionalAuthority)(),
242
- claims: options?.claims,
243
- clientAssertion,
244
- });
245
- (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
246
- state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
247
- return {
248
- token: response.accessToken,
249
- expiresOnTimestamp: response.expiresOn.getTime(),
250
- refreshAfterTimestamp: response.refreshOn?.getTime(),
251
- tokenType: response.tokenType,
252
- };
253
- }
254
- catch (err) {
255
- throw (0, utils_js_1.handleMsalError)(scopes, err, options);
256
- }
154
+ state.logger.getToken.info("Attempting to acquire token silently");
155
+ try {
156
+ return await app.acquireTokenSilent(silentRequest);
157
+ } catch (err) {
158
+ throw (0, import_utils.handleMsalError)(scopes, err, options);
257
159
  }
258
- async function getTokenByClientCertificate(scopes, certificate, options = {}) {
259
- state.logger.getToken.info(`Attempting to acquire token using client certificate`);
260
- state.msalConfig.auth.clientCertificate = certificate;
261
- const msalApp = await getConfidentialApp(options);
262
- try {
263
- const response = await msalApp.acquireTokenByClientCredential({
264
- scopes,
265
- authority: calculateRequestAuthority(options),
266
- azureRegion: (0, regionalAuthority_js_1.calculateRegionalAuthority)(),
267
- claims: options?.claims,
268
- });
269
- (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
270
- state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
271
- return {
272
- token: response.accessToken,
273
- expiresOnTimestamp: response.expiresOn.getTime(),
274
- refreshAfterTimestamp: response.refreshOn?.getTime(),
275
- tokenType: response.tokenType,
276
- };
277
- }
278
- catch (err) {
279
- throw (0, utils_js_1.handleMsalError)(scopes, err, options);
280
- }
160
+ }
161
+ function calculateRequestAuthority(options) {
162
+ if (options?.tenantId) {
163
+ return (0, import_utils.getAuthority)(options.tenantId, (0, import_authorityHost.getAuthorityHost)(createMsalClientOptions));
281
164
  }
282
- async function getTokenByDeviceCode(scopes, deviceCodeCallback, options = {}) {
283
- state.logger.getToken.info(`Attempting to acquire token using device code`);
284
- const msalApp = await getPublicApp(options);
285
- return withSilentAuthentication(msalApp, scopes, options, () => {
286
- const requestOptions = {
287
- scopes,
288
- cancel: options?.abortSignal?.aborted ?? false,
289
- deviceCodeCallback,
290
- authority: calculateRequestAuthority(options),
291
- claims: options?.claims,
292
- };
293
- const deviceCodeRequest = msalApp.acquireTokenByDeviceCode(requestOptions);
294
- if (options.abortSignal) {
295
- options.abortSignal.addEventListener("abort", () => {
296
- requestOptions.cancel = true;
297
- });
298
- }
299
- return deviceCodeRequest;
165
+ return state.msalConfig.auth.authority;
166
+ }
167
+ async function withSilentAuthentication(msalApp, scopes, options, onAuthenticationRequired) {
168
+ let response = null;
169
+ try {
170
+ response = await getTokenSilent(msalApp, scopes, options);
171
+ } catch (e) {
172
+ if (e.name !== "AuthenticationRequiredError") {
173
+ throw e;
174
+ }
175
+ if (options.disableAutomaticAuthentication) {
176
+ throw new import_errors.AuthenticationRequiredError({
177
+ scopes,
178
+ getTokenOptions: options,
179
+ message: "Automatic authentication has been disabled. You may call the authentication() method."
300
180
  });
181
+ }
301
182
  }
302
- async function getTokenByUsernamePassword(scopes, username, password, options = {}) {
303
- state.logger.getToken.info(`Attempting to acquire token using username and password`);
304
- const msalApp = await getPublicApp(options);
305
- return withSilentAuthentication(msalApp, scopes, options, () => {
306
- const requestOptions = {
307
- scopes,
308
- username,
309
- password,
310
- authority: calculateRequestAuthority(options),
311
- claims: options?.claims,
312
- };
313
- return msalApp.acquireTokenByUsernamePassword(requestOptions);
314
- });
183
+ if (response === null) {
184
+ try {
185
+ response = await onAuthenticationRequired();
186
+ } catch (err) {
187
+ throw (0, import_utils.handleMsalError)(scopes, err, options);
188
+ }
315
189
  }
316
- function getActiveAccount() {
317
- if (!state.cachedAccount) {
318
- return undefined;
319
- }
320
- return (0, utils_js_1.msalToPublic)(clientId, state.cachedAccount);
190
+ (0, import_utils.ensureValidMsalToken)(scopes, response, options);
191
+ state.cachedAccount = response?.account ?? null;
192
+ state.logger.getToken.info((0, import_logging.formatSuccess)(scopes));
193
+ return {
194
+ token: response.accessToken,
195
+ expiresOnTimestamp: response.expiresOn.getTime(),
196
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
197
+ tokenType: response.tokenType
198
+ };
199
+ }
200
+ async function getTokenByClientSecret(scopes, clientSecret, options = {}) {
201
+ state.logger.getToken.info(`Attempting to acquire token using client secret`);
202
+ state.msalConfig.auth.clientSecret = clientSecret;
203
+ const msalApp = await getConfidentialApp(options);
204
+ try {
205
+ const response = await msalApp.acquireTokenByClientCredential({
206
+ scopes,
207
+ authority: calculateRequestAuthority(options),
208
+ azureRegion: (0, import_regionalAuthority.calculateRegionalAuthority)(),
209
+ claims: options?.claims
210
+ });
211
+ (0, import_utils.ensureValidMsalToken)(scopes, response, options);
212
+ state.logger.getToken.info((0, import_logging.formatSuccess)(scopes));
213
+ return {
214
+ token: response.accessToken,
215
+ expiresOnTimestamp: response.expiresOn.getTime(),
216
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
217
+ tokenType: response.tokenType
218
+ };
219
+ } catch (err) {
220
+ throw (0, import_utils.handleMsalError)(scopes, err, options);
321
221
  }
322
- async function getTokenByAuthorizationCode(scopes, redirectUri, authorizationCode, clientSecret, options = {}) {
323
- state.logger.getToken.info(`Attempting to acquire token using authorization code`);
324
- let msalApp;
325
- if (clientSecret) {
326
- // If a client secret is provided, we need to use a confidential client application
327
- // See https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow#request-an-access-token-with-a-client_secret
328
- state.msalConfig.auth.clientSecret = clientSecret;
329
- msalApp = await getConfidentialApp(options);
330
- }
331
- else {
332
- msalApp = await getPublicApp(options);
333
- }
334
- return withSilentAuthentication(msalApp, scopes, options, () => {
335
- return msalApp.acquireTokenByCode({
336
- scopes,
337
- redirectUri,
338
- code: authorizationCode,
339
- authority: calculateRequestAuthority(options),
340
- claims: options?.claims,
341
- });
222
+ }
223
+ async function getTokenByClientAssertion(scopes, clientAssertion, options = {}) {
224
+ state.logger.getToken.info(`Attempting to acquire token using client assertion`);
225
+ state.msalConfig.auth.clientAssertion = clientAssertion;
226
+ const msalApp = await getConfidentialApp(options);
227
+ try {
228
+ const response = await msalApp.acquireTokenByClientCredential({
229
+ scopes,
230
+ authority: calculateRequestAuthority(options),
231
+ azureRegion: (0, import_regionalAuthority.calculateRegionalAuthority)(),
232
+ claims: options?.claims,
233
+ clientAssertion
234
+ });
235
+ (0, import_utils.ensureValidMsalToken)(scopes, response, options);
236
+ state.logger.getToken.info((0, import_logging.formatSuccess)(scopes));
237
+ return {
238
+ token: response.accessToken,
239
+ expiresOnTimestamp: response.expiresOn.getTime(),
240
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
241
+ tokenType: response.tokenType
242
+ };
243
+ } catch (err) {
244
+ throw (0, import_utils.handleMsalError)(scopes, err, options);
245
+ }
246
+ }
247
+ async function getTokenByClientCertificate(scopes, certificate, options = {}) {
248
+ state.logger.getToken.info(`Attempting to acquire token using client certificate`);
249
+ state.msalConfig.auth.clientCertificate = certificate;
250
+ const msalApp = await getConfidentialApp(options);
251
+ try {
252
+ const response = await msalApp.acquireTokenByClientCredential({
253
+ scopes,
254
+ authority: calculateRequestAuthority(options),
255
+ azureRegion: (0, import_regionalAuthority.calculateRegionalAuthority)(),
256
+ claims: options?.claims
257
+ });
258
+ (0, import_utils.ensureValidMsalToken)(scopes, response, options);
259
+ state.logger.getToken.info((0, import_logging.formatSuccess)(scopes));
260
+ return {
261
+ token: response.accessToken,
262
+ expiresOnTimestamp: response.expiresOn.getTime(),
263
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
264
+ tokenType: response.tokenType
265
+ };
266
+ } catch (err) {
267
+ throw (0, import_utils.handleMsalError)(scopes, err, options);
268
+ }
269
+ }
270
+ async function getTokenByDeviceCode(scopes, deviceCodeCallback, options = {}) {
271
+ state.logger.getToken.info(`Attempting to acquire token using device code`);
272
+ const msalApp = await getPublicApp(options);
273
+ return withSilentAuthentication(msalApp, scopes, options, () => {
274
+ const requestOptions = {
275
+ scopes,
276
+ cancel: options?.abortSignal?.aborted ?? false,
277
+ deviceCodeCallback,
278
+ authority: calculateRequestAuthority(options),
279
+ claims: options?.claims
280
+ };
281
+ const deviceCodeRequest = msalApp.acquireTokenByDeviceCode(requestOptions);
282
+ if (options.abortSignal) {
283
+ options.abortSignal.addEventListener("abort", () => {
284
+ requestOptions.cancel = true;
342
285
  });
286
+ }
287
+ return deviceCodeRequest;
288
+ });
289
+ }
290
+ async function getTokenByUsernamePassword(scopes, username, password, options = {}) {
291
+ state.logger.getToken.info(`Attempting to acquire token using username and password`);
292
+ const msalApp = await getPublicApp(options);
293
+ return withSilentAuthentication(msalApp, scopes, options, () => {
294
+ const requestOptions = {
295
+ scopes,
296
+ username,
297
+ password,
298
+ authority: calculateRequestAuthority(options),
299
+ claims: options?.claims
300
+ };
301
+ return msalApp.acquireTokenByUsernamePassword(requestOptions);
302
+ });
303
+ }
304
+ function getActiveAccount() {
305
+ if (!state.cachedAccount) {
306
+ return void 0;
343
307
  }
344
- async function getTokenOnBehalfOf(scopes, userAssertionToken, clientCredentials, options = {}) {
345
- msalLogger.getToken.info(`Attempting to acquire token on behalf of another user`);
346
- if (typeof clientCredentials === "string") {
347
- // Client secret
348
- msalLogger.getToken.info(`Using client secret for on behalf of flow`);
349
- state.msalConfig.auth.clientSecret = clientCredentials;
350
- }
351
- else if (typeof clientCredentials === "function") {
352
- // Client Assertion
353
- msalLogger.getToken.info(`Using client assertion callback for on behalf of flow`);
354
- state.msalConfig.auth.clientAssertion = clientCredentials;
355
- }
356
- else {
357
- // Client certificate
358
- msalLogger.getToken.info(`Using client certificate for on behalf of flow`);
359
- state.msalConfig.auth.clientCertificate = clientCredentials;
360
- }
361
- const msalApp = await getConfidentialApp(options);
362
- try {
363
- const response = await msalApp.acquireTokenOnBehalfOf({
364
- scopes,
365
- authority: calculateRequestAuthority(options),
366
- claims: options.claims,
367
- oboAssertion: userAssertionToken,
368
- });
369
- (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
370
- msalLogger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
371
- return {
372
- token: response.accessToken,
373
- expiresOnTimestamp: response.expiresOn.getTime(),
374
- refreshAfterTimestamp: response.refreshOn?.getTime(),
375
- tokenType: response.tokenType,
376
- };
377
- }
378
- catch (err) {
379
- throw (0, utils_js_1.handleMsalError)(scopes, err, options);
380
- }
308
+ return (0, import_utils.msalToPublic)(clientId, state.cachedAccount);
309
+ }
310
+ async function getTokenByAuthorizationCode(scopes, redirectUri, authorizationCode, clientSecret, options = {}) {
311
+ state.logger.getToken.info(`Attempting to acquire token using authorization code`);
312
+ let msalApp;
313
+ if (clientSecret) {
314
+ state.msalConfig.auth.clientSecret = clientSecret;
315
+ msalApp = await getConfidentialApp(options);
316
+ } else {
317
+ msalApp = await getPublicApp(options);
381
318
  }
382
- /**
383
- * Creates a base interactive request configuration for MSAL interactive authentication.
384
- * This is shared between interactive and brokered authentication flows.
385
- */
386
- function createBaseInteractiveRequest(scopes, options) {
387
- return {
388
- openBrowser: async (url) => {
389
- const open = await import("open");
390
- await open.default(url, { newInstance: true });
391
- },
392
- scopes,
393
- authority: calculateRequestAuthority(options),
394
- claims: options?.claims,
395
- loginHint: options?.loginHint,
396
- errorTemplate: options?.browserCustomizationOptions?.errorMessage,
397
- successTemplate: options?.browserCustomizationOptions?.successMessage,
398
- prompt: options?.loginHint ? "login" : "select_account",
399
- };
319
+ return withSilentAuthentication(msalApp, scopes, options, () => {
320
+ return msalApp.acquireTokenByCode({
321
+ scopes,
322
+ redirectUri,
323
+ code: authorizationCode,
324
+ authority: calculateRequestAuthority(options),
325
+ claims: options?.claims
326
+ });
327
+ });
328
+ }
329
+ async function getTokenOnBehalfOf(scopes, userAssertionToken, clientCredentials, options = {}) {
330
+ msalLogger.getToken.info(`Attempting to acquire token on behalf of another user`);
331
+ if (typeof clientCredentials === "string") {
332
+ msalLogger.getToken.info(`Using client secret for on behalf of flow`);
333
+ state.msalConfig.auth.clientSecret = clientCredentials;
334
+ } else if (typeof clientCredentials === "function") {
335
+ msalLogger.getToken.info(`Using client assertion callback for on behalf of flow`);
336
+ state.msalConfig.auth.clientAssertion = clientCredentials;
337
+ } else {
338
+ msalLogger.getToken.info(`Using client certificate for on behalf of flow`);
339
+ state.msalConfig.auth.clientCertificate = clientCredentials;
400
340
  }
401
- /**
402
- * @internal
403
- */
404
- async function getBrokeredTokenInternal(scopes, useDefaultBrokerAccount, options = {}) {
405
- msalLogger.verbose("Authentication will resume through the broker");
406
- const app = await getPublicApp(options);
407
- const interactiveRequest = createBaseInteractiveRequest(scopes, options);
408
- if (state.pluginConfiguration.broker.parentWindowHandle) {
409
- interactiveRequest.windowHandle = Buffer.from(state.pluginConfiguration.broker.parentWindowHandle);
410
- }
411
- else {
412
- // this is a bug, as the pluginConfiguration handler should validate this case.
413
- msalLogger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
414
- }
415
- if (state.pluginConfiguration.broker.enableMsaPassthrough) {
416
- (interactiveRequest.tokenQueryParameters ??= {})["msal_request_type"] =
417
- "consumer_passthrough";
418
- }
419
- if (useDefaultBrokerAccount) {
420
- interactiveRequest.prompt = "none";
421
- msalLogger.verbose("Attempting broker authentication using the default broker account");
422
- }
423
- else {
424
- msalLogger.verbose("Attempting broker authentication without the default broker account");
425
- }
426
- if (options.proofOfPossessionOptions) {
427
- interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
428
- interactiveRequest.authenticationScheme = "pop";
429
- interactiveRequest.resourceRequestMethod =
430
- options.proofOfPossessionOptions.resourceRequestMethod;
431
- interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
432
- }
433
- try {
434
- return await app.acquireTokenInteractive(interactiveRequest);
435
- }
436
- catch (e) {
437
- msalLogger.verbose(`Failed to authenticate through the broker: ${e.message}`);
438
- if (options.disableAutomaticAuthentication) {
439
- throw new errors_js_1.AuthenticationRequiredError({
440
- scopes,
441
- getTokenOptions: options,
442
- message: "Cannot silently authenticate with default broker account.",
443
- });
444
- }
445
- // If we tried to use the default broker account and failed, fall back to interactive authentication
446
- if (useDefaultBrokerAccount) {
447
- return getBrokeredTokenInternal(scopes, false, options);
448
- }
449
- else {
450
- throw e;
451
- }
452
- }
341
+ const msalApp = await getConfidentialApp(options);
342
+ try {
343
+ const response = await msalApp.acquireTokenOnBehalfOf({
344
+ scopes,
345
+ authority: calculateRequestAuthority(options),
346
+ claims: options.claims,
347
+ oboAssertion: userAssertionToken
348
+ });
349
+ (0, import_utils.ensureValidMsalToken)(scopes, response, options);
350
+ msalLogger.getToken.info((0, import_logging.formatSuccess)(scopes));
351
+ return {
352
+ token: response.accessToken,
353
+ expiresOnTimestamp: response.expiresOn.getTime(),
354
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
355
+ tokenType: response.tokenType
356
+ };
357
+ } catch (err) {
358
+ throw (0, import_utils.handleMsalError)(scopes, err, options);
453
359
  }
454
- /**
455
- * A helper function that supports brokered authentication through the MSAL's public application.
456
- *
457
- * When useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.
458
- * If the default broker account is not available, the method will fall back to interactive authentication.
459
- */
460
- async function getBrokeredToken(scopes, useDefaultBrokerAccount, options = {}) {
461
- msalLogger.getToken.info(`Attempting to acquire token using brokered authentication with useDefaultBrokerAccount: ${useDefaultBrokerAccount}`);
462
- const response = await getBrokeredTokenInternal(scopes, useDefaultBrokerAccount, options);
463
- (0, utils_js_1.ensureValidMsalToken)(scopes, response, options);
464
- state.cachedAccount = response?.account ?? null;
465
- state.logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
466
- return {
467
- token: response.accessToken,
468
- expiresOnTimestamp: response.expiresOn.getTime(),
469
- refreshAfterTimestamp: response.refreshOn?.getTime(),
470
- tokenType: response.tokenType,
471
- };
360
+ }
361
+ function createBaseInteractiveRequest(scopes, options) {
362
+ return {
363
+ openBrowser: async (url) => {
364
+ const open = await import("open");
365
+ await open.default(url, { newInstance: true });
366
+ },
367
+ scopes,
368
+ authority: calculateRequestAuthority(options),
369
+ claims: options?.claims,
370
+ loginHint: options?.loginHint,
371
+ errorTemplate: options?.browserCustomizationOptions?.errorMessage,
372
+ successTemplate: options?.browserCustomizationOptions?.successMessage,
373
+ prompt: options?.loginHint ? "login" : "select_account"
374
+ };
375
+ }
376
+ async function getBrokeredTokenInternal(scopes, useDefaultBrokerAccount, options = {}) {
377
+ msalLogger.verbose("Authentication will resume through the broker");
378
+ const app = await getPublicApp(options);
379
+ const interactiveRequest = createBaseInteractiveRequest(scopes, options);
380
+ if (state.pluginConfiguration.broker.parentWindowHandle) {
381
+ interactiveRequest.windowHandle = Buffer.from(
382
+ state.pluginConfiguration.broker.parentWindowHandle
383
+ );
384
+ } else {
385
+ msalLogger.warning(
386
+ "Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle."
387
+ );
388
+ }
389
+ if (state.pluginConfiguration.broker.enableMsaPassthrough) {
390
+ (interactiveRequest.extraQueryParameters ??= {})["msal_request_type"] = "consumer_passthrough";
391
+ }
392
+ if (useDefaultBrokerAccount) {
393
+ interactiveRequest.prompt = "none";
394
+ msalLogger.verbose("Attempting broker authentication using the default broker account");
395
+ } else {
396
+ msalLogger.verbose("Attempting broker authentication without the default broker account");
472
397
  }
473
- async function getTokenByInteractiveRequest(scopes, options = {}) {
474
- msalLogger.getToken.info(`Attempting to acquire token interactively`);
475
- const app = await getPublicApp(options);
476
- return withSilentAuthentication(app, scopes, options, async () => {
477
- const interactiveRequest = createBaseInteractiveRequest(scopes, options);
478
- if (state.pluginConfiguration.broker.isEnabled) {
479
- return getBrokeredTokenInternal(scopes, state.pluginConfiguration.broker.useDefaultBrokerAccount ?? false, options);
480
- }
481
- if (options.proofOfPossessionOptions) {
482
- interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
483
- interactiveRequest.authenticationScheme = "pop";
484
- interactiveRequest.resourceRequestMethod =
485
- options.proofOfPossessionOptions.resourceRequestMethod;
486
- interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
487
- }
488
- return app.acquireTokenInteractive(interactiveRequest);
398
+ if (options.proofOfPossessionOptions) {
399
+ interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
400
+ interactiveRequest.authenticationScheme = "pop";
401
+ interactiveRequest.resourceRequestMethod = options.proofOfPossessionOptions.resourceRequestMethod;
402
+ interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
403
+ }
404
+ try {
405
+ return await app.acquireTokenInteractive(interactiveRequest);
406
+ } catch (e) {
407
+ msalLogger.verbose(`Failed to authenticate through the broker: ${e.message}`);
408
+ if (options.disableAutomaticAuthentication) {
409
+ throw new import_errors.AuthenticationRequiredError({
410
+ scopes,
411
+ getTokenOptions: options,
412
+ message: "Cannot silently authenticate with default broker account."
489
413
  });
414
+ }
415
+ if (useDefaultBrokerAccount) {
416
+ return getBrokeredTokenInternal(scopes, false, options);
417
+ } else {
418
+ throw e;
419
+ }
490
420
  }
421
+ }
422
+ async function getBrokeredToken(scopes, useDefaultBrokerAccount, options = {}) {
423
+ msalLogger.getToken.info(
424
+ `Attempting to acquire token using brokered authentication with useDefaultBrokerAccount: ${useDefaultBrokerAccount}`
425
+ );
426
+ const response = await getBrokeredTokenInternal(scopes, useDefaultBrokerAccount, options);
427
+ (0, import_utils.ensureValidMsalToken)(scopes, response, options);
428
+ state.cachedAccount = response?.account ?? null;
429
+ state.logger.getToken.info((0, import_logging.formatSuccess)(scopes));
491
430
  return {
492
- getActiveAccount,
493
- getBrokeredToken,
494
- getTokenByClientSecret,
495
- getTokenByClientAssertion,
496
- getTokenByClientCertificate,
497
- getTokenByDeviceCode,
498
- getTokenByUsernamePassword,
499
- getTokenByAuthorizationCode,
500
- getTokenOnBehalfOf,
501
- getTokenByInteractiveRequest,
431
+ token: response.accessToken,
432
+ expiresOnTimestamp: response.expiresOn.getTime(),
433
+ refreshAfterTimestamp: response.refreshOn?.getTime(),
434
+ tokenType: response.tokenType
502
435
  };
436
+ }
437
+ async function getTokenByInteractiveRequest(scopes, options = {}) {
438
+ msalLogger.getToken.info(`Attempting to acquire token interactively`);
439
+ const app = await getPublicApp(options);
440
+ return withSilentAuthentication(app, scopes, options, async () => {
441
+ const interactiveRequest = createBaseInteractiveRequest(scopes, options);
442
+ if (state.pluginConfiguration.broker.isEnabled) {
443
+ return getBrokeredTokenInternal(
444
+ scopes,
445
+ state.pluginConfiguration.broker.useDefaultBrokerAccount ?? false,
446
+ options
447
+ );
448
+ }
449
+ if (options.proofOfPossessionOptions) {
450
+ interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
451
+ interactiveRequest.authenticationScheme = "pop";
452
+ interactiveRequest.resourceRequestMethod = options.proofOfPossessionOptions.resourceRequestMethod;
453
+ interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
454
+ }
455
+ return app.acquireTokenInteractive(interactiveRequest);
456
+ });
457
+ }
458
+ return {
459
+ getActiveAccount,
460
+ getBrokeredToken,
461
+ getTokenByClientSecret,
462
+ getTokenByClientAssertion,
463
+ getTokenByClientCertificate,
464
+ getTokenByDeviceCode,
465
+ getTokenByUsernamePassword,
466
+ getTokenByAuthorizationCode,
467
+ getTokenOnBehalfOf,
468
+ getTokenByInteractiveRequest
469
+ };
503
470
  }
504
- //# sourceMappingURL=msalClient.js.map
471
+ // Annotate the CommonJS export names for ESM import in node:
472
+ 0 && (module.exports = {
473
+ createMsalClient,
474
+ generateMsalConfiguration
475
+ });
476
+ //# sourceMappingURL=msalClient.js.map