@azure/identity 4.6.0 → 4.6.1-alpha.20250116.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1115) hide show
  1. package/README.md +5 -1
  2. package/dist/browser/client/identityClient.d.ts +65 -0
  3. package/dist/browser/client/identityClient.d.ts.map +1 -0
  4. package/dist/browser/client/identityClient.js +248 -0
  5. package/dist/browser/client/identityClient.js.map +1 -0
  6. package/dist/browser/constants.d.ts +69 -0
  7. package/dist/browser/constants.d.ts.map +1 -0
  8. package/dist/browser/constants.js +75 -0
  9. package/dist/browser/constants.js.map +1 -0
  10. package/dist/browser/credentials/authorityValidationOptions.d.ts +16 -0
  11. package/dist/browser/credentials/authorityValidationOptions.d.ts.map +1 -0
  12. package/dist/browser/credentials/authorizationCodeCredential-browser.d.mts.map +1 -0
  13. package/dist/browser/credentials/authorizationCodeCredential-browser.mjs.map +1 -0
  14. package/dist/browser/credentials/authorizationCodeCredential.d.ts +11 -0
  15. package/dist/browser/credentials/authorizationCodeCredential.js +16 -0
  16. package/dist/browser/credentials/authorizationCodeCredentialOptions.d.ts +8 -0
  17. package/dist/browser/credentials/authorizationCodeCredentialOptions.d.ts.map +1 -0
  18. package/dist/browser/credentials/authorizationCodeCredentialOptions.js.map +1 -0
  19. package/dist/browser/credentials/azureApplicationCredential-browser.d.mts.map +1 -0
  20. package/dist/browser/credentials/azureApplicationCredential-browser.mjs.map +1 -0
  21. package/dist/browser/credentials/azureApplicationCredential.d.ts +24 -0
  22. package/dist/browser/credentials/azureApplicationCredential.js +34 -0
  23. package/dist/browser/credentials/azureApplicationCredentialOptions.d.ts +13 -0
  24. package/dist/browser/credentials/azureApplicationCredentialOptions.d.ts.map +1 -0
  25. package/dist/browser/credentials/azureApplicationCredentialOptions.js.map +1 -0
  26. package/dist/browser/credentials/azureCliCredential-browser.d.mts.map +1 -0
  27. package/dist/browser/credentials/azureCliCredential-browser.mjs.map +1 -0
  28. package/dist/browser/credentials/azureCliCredential.d.ts +13 -0
  29. package/dist/browser/credentials/azureCliCredential.js +23 -0
  30. package/dist/browser/credentials/azureCliCredentialOptions.d.ts +20 -0
  31. package/dist/browser/credentials/azureCliCredentialOptions.d.ts.map +1 -0
  32. package/dist/browser/credentials/azureCliCredentialOptions.js.map +1 -0
  33. package/dist/browser/credentials/azureDeveloperCliCredential-browser.d.mts.map +1 -0
  34. package/dist/browser/credentials/azureDeveloperCliCredential-browser.mjs.map +1 -0
  35. package/dist/browser/credentials/azureDeveloperCliCredential.d.ts +13 -0
  36. package/dist/browser/credentials/azureDeveloperCliCredential.js +23 -0
  37. package/dist/browser/credentials/azureDeveloperCliCredentialOptions.d.ts +15 -0
  38. package/dist/browser/credentials/azureDeveloperCliCredentialOptions.d.ts.map +1 -0
  39. package/dist/browser/credentials/azureDeveloperCliCredentialOptions.js.map +1 -0
  40. package/dist/browser/credentials/azurePipelinesCredential-browser.d.mts.map +1 -0
  41. package/dist/browser/credentials/azurePipelinesCredential-browser.mjs.map +1 -0
  42. package/dist/browser/credentials/azurePipelinesCredential.d.ts +13 -0
  43. package/dist/browser/credentials/azurePipelinesCredential.js +23 -0
  44. package/dist/browser/credentials/azurePipelinesCredentialOptions.d.ts +9 -0
  45. package/dist/browser/credentials/azurePipelinesCredentialOptions.d.ts.map +1 -0
  46. package/dist/browser/credentials/azurePipelinesCredentialOptions.js.map +1 -0
  47. package/dist/browser/credentials/azurePowerShellCredential-browser.d.mts.map +1 -0
  48. package/dist/browser/credentials/azurePowerShellCredential-browser.mjs.map +1 -0
  49. package/dist/browser/credentials/azurePowerShellCredential.d.ts +12 -0
  50. package/dist/browser/credentials/azurePowerShellCredential.js +22 -0
  51. package/dist/browser/credentials/azurePowerShellCredentialOptions.d.ts +15 -0
  52. package/dist/browser/credentials/azurePowerShellCredentialOptions.d.ts.map +1 -0
  53. package/dist/browser/credentials/azurePowerShellCredentialOptions.js.map +1 -0
  54. package/dist/browser/credentials/brokerAuthOptions.d.ts +13 -0
  55. package/dist/browser/credentials/brokerAuthOptions.d.ts.map +1 -0
  56. package/dist/browser/credentials/brokerAuthOptions.js.map +1 -0
  57. package/dist/browser/credentials/browserCustomizationOptions.d.ts +19 -0
  58. package/dist/browser/credentials/browserCustomizationOptions.d.ts.map +1 -0
  59. package/dist/browser/credentials/chainedTokenCredential.d.ts +51 -0
  60. package/dist/browser/credentials/chainedTokenCredential.d.ts.map +1 -0
  61. package/dist/browser/credentials/chainedTokenCredential.js +92 -0
  62. package/dist/browser/credentials/chainedTokenCredential.js.map +1 -0
  63. package/dist/browser/credentials/clientAssertionCredential-browser.d.mts.map +1 -0
  64. package/dist/browser/credentials/clientAssertionCredential-browser.mjs.map +1 -0
  65. package/dist/browser/credentials/clientAssertionCredential.d.ts +12 -0
  66. package/dist/browser/credentials/clientAssertionCredential.js +22 -0
  67. package/dist/browser/credentials/clientAssertionCredentialOptions.d.ts +9 -0
  68. package/dist/browser/credentials/clientAssertionCredentialOptions.d.ts.map +1 -0
  69. package/dist/browser/credentials/clientAssertionCredentialOptions.js.map +1 -0
  70. package/dist/browser/credentials/clientCertificateCredential-browser.d.mts.map +1 -0
  71. package/dist/browser/credentials/clientCertificateCredential-browser.mjs.map +1 -0
  72. package/dist/browser/credentials/clientCertificateCredential.d.ts +13 -0
  73. package/dist/browser/credentials/clientCertificateCredential.js +23 -0
  74. package/dist/browser/credentials/clientCertificateCredentialModels.d.ts +31 -0
  75. package/dist/browser/credentials/clientCertificateCredentialModels.d.ts.map +1 -0
  76. package/dist/browser/credentials/clientCertificateCredentialModels.js +4 -0
  77. package/dist/browser/credentials/clientCertificateCredentialModels.js.map +1 -0
  78. package/dist/browser/credentials/clientCertificateCredentialOptions.d.ts +14 -0
  79. package/dist/browser/credentials/clientCertificateCredentialOptions.d.ts.map +1 -0
  80. package/dist/browser/credentials/clientCertificateCredentialOptions.js.map +1 -0
  81. package/dist/browser/credentials/clientSecretCredential-browser.d.mts.map +1 -0
  82. package/dist/browser/credentials/clientSecretCredential-browser.mjs.map +1 -0
  83. package/dist/browser/credentials/clientSecretCredential.d.ts +40 -0
  84. package/dist/browser/credentials/clientSecretCredential.js +83 -0
  85. package/dist/browser/credentials/clientSecretCredentialOptions.d.ts +9 -0
  86. package/dist/browser/credentials/clientSecretCredentialOptions.d.ts.map +1 -0
  87. package/dist/browser/credentials/clientSecretCredentialOptions.js.map +1 -0
  88. package/dist/browser/credentials/credentialPersistenceOptions.d.ts +30 -0
  89. package/dist/browser/credentials/credentialPersistenceOptions.d.ts.map +1 -0
  90. package/dist/browser/credentials/credentialPersistenceOptions.js.map +1 -0
  91. package/dist/browser/credentials/defaultAzureCredential-browser.d.mts.map +1 -0
  92. package/dist/browser/credentials/defaultAzureCredential-browser.mjs.map +1 -0
  93. package/dist/browser/credentials/defaultAzureCredential.d.ts +19 -0
  94. package/dist/browser/credentials/defaultAzureCredential.js +29 -0
  95. package/dist/browser/credentials/defaultAzureCredentialOptions.d.ts +49 -0
  96. package/dist/browser/credentials/defaultAzureCredentialOptions.d.ts.map +1 -0
  97. package/dist/browser/credentials/defaultAzureCredentialOptions.js.map +1 -0
  98. package/dist/browser/credentials/deviceCodeCredential-browser.d.mts.map +1 -0
  99. package/dist/browser/credentials/deviceCodeCredential-browser.mjs.map +1 -0
  100. package/dist/browser/credentials/deviceCodeCredential.d.ts +13 -0
  101. package/dist/browser/credentials/deviceCodeCredential.js +23 -0
  102. package/dist/browser/credentials/deviceCodeCredentialOptions.d.ts +53 -0
  103. package/dist/browser/credentials/deviceCodeCredentialOptions.d.ts.map +1 -0
  104. package/dist/browser/credentials/deviceCodeCredentialOptions.js.map +1 -0
  105. package/dist/browser/credentials/environmentCredential-browser.d.mts.map +1 -0
  106. package/dist/browser/credentials/environmentCredential-browser.mjs.map +1 -0
  107. package/dist/browser/credentials/environmentCredential.d.ts +13 -0
  108. package/dist/browser/credentials/environmentCredential.js +23 -0
  109. package/dist/browser/credentials/environmentCredentialOptions.d.ts +9 -0
  110. package/dist/browser/credentials/environmentCredentialOptions.d.ts.map +1 -0
  111. package/dist/browser/credentials/environmentCredentialOptions.js.map +1 -0
  112. package/dist/browser/credentials/interactiveBrowserCredential-browser.d.mts.map +1 -0
  113. package/dist/browser/credentials/interactiveBrowserCredential-browser.mjs.map +1 -0
  114. package/dist/browser/credentials/interactiveBrowserCredential.d.ts +53 -0
  115. package/dist/browser/credentials/interactiveBrowserCredential.js +86 -0
  116. package/dist/browser/credentials/interactiveBrowserCredentialOptions.d.ts +77 -0
  117. package/dist/browser/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
  118. package/dist/browser/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
  119. package/dist/browser/credentials/interactiveCredentialOptions.d.ts +25 -0
  120. package/dist/browser/credentials/interactiveCredentialOptions.d.ts.map +1 -0
  121. package/dist/browser/credentials/interactiveCredentialOptions.js.map +1 -0
  122. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.d.ts +18 -0
  123. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.d.ts.map +1 -0
  124. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.js +122 -0
  125. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.js.map +1 -0
  126. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +12 -0
  127. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -0
  128. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -0
  129. package/dist/browser/credentials/managedIdentityCredential/index-browser.d.mts.map +1 -0
  130. package/dist/browser/credentials/managedIdentityCredential/index-browser.mjs.map +1 -0
  131. package/dist/browser/credentials/managedIdentityCredential/index.d.ts +6 -0
  132. package/dist/browser/credentials/managedIdentityCredential/index.js +16 -0
  133. package/dist/browser/credentials/managedIdentityCredential/models.d.ts +24 -0
  134. package/dist/browser/credentials/managedIdentityCredential/models.d.ts.map +1 -0
  135. package/dist/browser/credentials/managedIdentityCredential/models.js.map +1 -0
  136. package/dist/browser/credentials/managedIdentityCredential/options.d.ts +37 -0
  137. package/dist/browser/credentials/managedIdentityCredential/options.d.ts.map +1 -0
  138. package/dist/browser/credentials/managedIdentityCredential/options.js +4 -0
  139. package/dist/browser/credentials/managedIdentityCredential/options.js.map +1 -0
  140. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts +14 -0
  141. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts.map +1 -0
  142. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.js +32 -0
  143. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
  144. package/dist/browser/credentials/managedIdentityCredential/utils.d.ts +33 -0
  145. package/dist/browser/credentials/managedIdentityCredential/utils.d.ts.map +1 -0
  146. package/dist/browser/credentials/managedIdentityCredential/utils.js +77 -0
  147. package/dist/browser/credentials/managedIdentityCredential/utils.js.map +1 -0
  148. package/dist/browser/credentials/multiTenantTokenCredentialOptions.d.ts +12 -0
  149. package/dist/browser/credentials/multiTenantTokenCredentialOptions.d.ts.map +1 -0
  150. package/dist/browser/credentials/multiTenantTokenCredentialOptions.js.map +1 -0
  151. package/dist/browser/credentials/onBehalfOfCredential-browser.d.mts.map +1 -0
  152. package/dist/browser/credentials/onBehalfOfCredential-browser.mjs.map +1 -0
  153. package/dist/browser/credentials/onBehalfOfCredential.d.ts +12 -0
  154. package/dist/browser/credentials/onBehalfOfCredential.js +23 -0
  155. package/dist/browser/credentials/onBehalfOfCredentialOptions.d.ts +76 -0
  156. package/dist/browser/credentials/onBehalfOfCredentialOptions.d.ts.map +1 -0
  157. package/dist/browser/credentials/onBehalfOfCredentialOptions.js.map +1 -0
  158. package/dist/browser/credentials/usernamePasswordCredential-browser.d.mts.map +1 -0
  159. package/dist/browser/credentials/usernamePasswordCredential-browser.mjs.map +1 -0
  160. package/dist/browser/credentials/usernamePasswordCredential.d.ts +40 -0
  161. package/dist/browser/credentials/usernamePasswordCredential.js +77 -0
  162. package/dist/browser/credentials/usernamePasswordCredentialOptions.d.ts +9 -0
  163. package/dist/browser/credentials/usernamePasswordCredentialOptions.d.ts.map +1 -0
  164. package/dist/browser/credentials/usernamePasswordCredentialOptions.js.map +1 -0
  165. package/dist/browser/credentials/visualStudioCodeCredential-browser.d.mts.map +1 -0
  166. package/dist/browser/credentials/visualStudioCodeCredential-browser.mjs.map +1 -0
  167. package/dist/browser/credentials/visualStudioCodeCredential.d.ts +15 -0
  168. package/dist/browser/credentials/visualStudioCodeCredential.js +27 -0
  169. package/dist/browser/credentials/visualStudioCodeCredentialOptions.d.ts +11 -0
  170. package/dist/browser/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -0
  171. package/dist/browser/credentials/visualStudioCodeCredentialOptions.js.map +1 -0
  172. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.d.ts +11 -0
  173. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -0
  174. package/dist/browser/credentials/workloadIdentityCredential-browser.d.mts.map +1 -0
  175. package/dist/browser/credentials/workloadIdentityCredential-browser.mjs.map +1 -0
  176. package/dist/browser/credentials/workloadIdentityCredential.d.ts +17 -0
  177. package/dist/browser/credentials/workloadIdentityCredential.js +27 -0
  178. package/dist/browser/credentials/workloadIdentityCredentialOptions.d.ts +20 -0
  179. package/dist/browser/credentials/workloadIdentityCredentialOptions.d.ts.map +1 -0
  180. package/dist/browser/credentials/workloadIdentityCredentialOptions.js.map +1 -0
  181. package/dist/browser/errors.d.ts +139 -0
  182. package/dist/browser/errors.d.ts.map +1 -0
  183. package/dist/browser/errors.js.map +1 -0
  184. package/dist/browser/index.d.ts +61 -0
  185. package/dist/browser/index.d.ts.map +1 -0
  186. package/dist/browser/index.js +34 -0
  187. package/dist/browser/index.js.map +1 -0
  188. package/dist/browser/msal/browserFlows/flows.d.ts +42 -0
  189. package/dist/browser/msal/browserFlows/flows.d.ts.map +1 -0
  190. package/dist/browser/msal/browserFlows/flows.js.map +1 -0
  191. package/dist/browser/msal/browserFlows/msalAuthCode.d.ts +48 -0
  192. package/dist/browser/msal/browserFlows/msalAuthCode.d.ts.map +1 -0
  193. package/dist/browser/msal/browserFlows/msalAuthCode.js +203 -0
  194. package/dist/browser/msal/browserFlows/msalAuthCode.js.map +1 -0
  195. package/dist/browser/msal/browserFlows/msalBrowserCommon.d.ts +106 -0
  196. package/dist/browser/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -0
  197. package/dist/browser/msal/browserFlows/msalBrowserCommon.js +116 -0
  198. package/dist/browser/msal/browserFlows/msalBrowserCommon.js.map +1 -0
  199. package/dist/browser/msal/credentials.d.ts +52 -0
  200. package/dist/browser/msal/credentials.d.ts.map +1 -0
  201. package/dist/browser/msal/credentials.js.map +1 -0
  202. package/dist/browser/msal/msal-browser.d.mts.map +1 -0
  203. package/dist/browser/msal/msal-browser.mjs.map +1 -0
  204. package/dist/browser/msal/msal.d.ts +3 -0
  205. package/dist/browser/msal/msal.js +5 -0
  206. package/dist/browser/msal/nodeFlows/brokerOptions.d.ts +44 -0
  207. package/dist/browser/msal/nodeFlows/brokerOptions.d.ts.map +1 -0
  208. package/dist/browser/msal/nodeFlows/msalClient.d.ts +186 -0
  209. package/dist/browser/msal/nodeFlows/msalClient.d.ts.map +1 -0
  210. package/dist/browser/msal/nodeFlows/msalClient.js +477 -0
  211. package/dist/browser/msal/nodeFlows/msalClient.js.map +1 -0
  212. package/dist/browser/msal/nodeFlows/msalPlugins.d.ts +91 -0
  213. package/dist/browser/msal/nodeFlows/msalPlugins.d.ts.map +1 -0
  214. package/dist/browser/msal/nodeFlows/msalPlugins.js +87 -0
  215. package/dist/browser/msal/nodeFlows/msalPlugins.js.map +1 -0
  216. package/dist/browser/msal/nodeFlows/tokenCachePersistenceOptions.d.ts +24 -0
  217. package/dist/browser/msal/nodeFlows/tokenCachePersistenceOptions.d.ts.map +1 -0
  218. package/dist/browser/msal/types.d.ts +87 -0
  219. package/dist/browser/msal/types.d.ts.map +1 -0
  220. package/dist/browser/msal/types.js.map +1 -0
  221. package/dist/browser/msal/utils.d.ts +95 -0
  222. package/dist/browser/msal/utils.d.ts.map +1 -0
  223. package/dist/browser/msal/utils.js +238 -0
  224. package/dist/browser/msal/utils.js.map +1 -0
  225. package/dist/browser/package.json +3 -0
  226. package/dist/browser/plugins/consumer-browser.d.mts.map +1 -0
  227. package/dist/browser/plugins/consumer-browser.mjs.map +1 -0
  228. package/dist/browser/plugins/consumer.d.ts +2 -0
  229. package/dist/browser/plugins/consumer.js +7 -0
  230. package/dist/browser/plugins/provider.d.ts +36 -0
  231. package/dist/browser/plugins/provider.d.ts.map +1 -0
  232. package/dist/browser/plugins/provider.js.map +1 -0
  233. package/dist/browser/regionalAuthority.d.ts +122 -0
  234. package/dist/browser/regionalAuthority.d.ts.map +1 -0
  235. package/dist/browser/tokenCredentialOptions.d.ts +28 -0
  236. package/dist/browser/tokenCredentialOptions.d.ts.map +1 -0
  237. package/dist/browser/tokenCredentialOptions.js.map +1 -0
  238. package/dist/browser/tokenProvider.d.ts +39 -0
  239. package/dist/browser/tokenProvider.d.ts.map +1 -0
  240. package/dist/browser/tokenProvider.js +53 -0
  241. package/dist/browser/tokenProvider.js.map +1 -0
  242. package/dist/browser/util/authHostEnv-browser.d.mts +4 -0
  243. package/dist/browser/util/authHostEnv-browser.d.mts.map +1 -0
  244. package/dist/browser/util/authHostEnv-browser.mjs +7 -0
  245. package/dist/browser/util/authHostEnv-browser.mjs.map +1 -0
  246. package/dist/browser/util/identityTokenEndpoint.d.ts +2 -0
  247. package/dist/browser/util/identityTokenEndpoint.d.ts.map +1 -0
  248. package/dist/browser/util/logging.d.ts +70 -0
  249. package/dist/browser/util/logging.d.ts.map +1 -0
  250. package/dist/browser/util/logging.js.map +1 -0
  251. package/dist/browser/util/processMultiTenantRequest-browser.d.mts.map +1 -0
  252. package/dist/browser/util/processMultiTenantRequest-browser.mjs.map +1 -0
  253. package/dist/browser/util/processMultiTenantRequest.d.ts +9 -0
  254. package/dist/browser/util/processMultiTenantRequest.js +29 -0
  255. package/dist/browser/util/processUtils.d.ts +13 -0
  256. package/dist/browser/util/processUtils.d.ts.map +1 -0
  257. package/dist/browser/util/scopeUtils.d.ts +17 -0
  258. package/dist/browser/util/scopeUtils.d.ts.map +1 -0
  259. package/dist/browser/util/scopeUtils.js +29 -0
  260. package/dist/browser/util/scopeUtils.js.map +1 -0
  261. package/dist/browser/util/subscriptionUtils.d.ts +6 -0
  262. package/dist/browser/util/subscriptionUtils.d.ts.map +1 -0
  263. package/dist/browser/util/subscriptionUtils.js +14 -0
  264. package/dist/browser/util/subscriptionUtils.js.map +1 -0
  265. package/dist/browser/util/tenantIdUtils.d.ts +15 -0
  266. package/dist/browser/util/tenantIdUtils.d.ts.map +1 -0
  267. package/dist/browser/util/tenantIdUtils.js +44 -0
  268. package/dist/browser/util/tenantIdUtils.js.map +1 -0
  269. package/dist/browser/util/tracing.d.ts +6 -0
  270. package/dist/browser/util/tracing.d.ts.map +1 -0
  271. package/dist/browser/util/tracing.js +14 -0
  272. package/dist/browser/util/tracing.js.map +1 -0
  273. package/dist/commonjs/client/identityClient.d.ts +65 -0
  274. package/dist/commonjs/client/identityClient.d.ts.map +1 -0
  275. package/dist/commonjs/client/identityClient.js +253 -0
  276. package/dist/commonjs/client/identityClient.js.map +1 -0
  277. package/dist/commonjs/constants.d.ts +69 -0
  278. package/dist/commonjs/constants.d.ts.map +1 -0
  279. package/dist/commonjs/constants.js +78 -0
  280. package/dist/commonjs/constants.js.map +1 -0
  281. package/dist/commonjs/credentials/authorityValidationOptions.d.ts +16 -0
  282. package/dist/commonjs/credentials/authorityValidationOptions.d.ts.map +1 -0
  283. package/dist/commonjs/credentials/authorityValidationOptions.js +5 -0
  284. package/dist/commonjs/credentials/authorityValidationOptions.js.map +1 -0
  285. package/dist/commonjs/credentials/authorizationCodeCredential.d.ts +73 -0
  286. package/dist/commonjs/credentials/authorizationCodeCredential.d.ts.map +1 -0
  287. package/dist/commonjs/credentials/authorizationCodeCredential.js +64 -0
  288. package/dist/commonjs/credentials/authorizationCodeCredential.js.map +1 -0
  289. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.d.ts +8 -0
  290. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.d.ts.map +1 -0
  291. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.js +5 -0
  292. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.js.map +1 -0
  293. package/dist/commonjs/credentials/azureApplicationCredential.d.ts +24 -0
  294. package/dist/commonjs/credentials/azureApplicationCredential.d.ts.map +1 -0
  295. package/dist/commonjs/credentials/azureApplicationCredential.js +36 -0
  296. package/dist/commonjs/credentials/azureApplicationCredential.js.map +1 -0
  297. package/dist/commonjs/credentials/azureApplicationCredentialOptions.d.ts +13 -0
  298. package/dist/commonjs/credentials/azureApplicationCredentialOptions.d.ts.map +1 -0
  299. package/dist/commonjs/credentials/azureApplicationCredentialOptions.js +5 -0
  300. package/dist/commonjs/credentials/azureApplicationCredentialOptions.js.map +1 -0
  301. package/dist/commonjs/credentials/azureCliCredential.d.ts +64 -0
  302. package/dist/commonjs/credentials/azureCliCredential.d.ts.map +1 -0
  303. package/dist/commonjs/credentials/azureCliCredential.js +194 -0
  304. package/dist/commonjs/credentials/azureCliCredential.js.map +1 -0
  305. package/dist/commonjs/credentials/azureCliCredentialOptions.d.ts +20 -0
  306. package/dist/commonjs/credentials/azureCliCredentialOptions.d.ts.map +1 -0
  307. package/dist/commonjs/credentials/azureCliCredentialOptions.js +5 -0
  308. package/dist/commonjs/credentials/azureCliCredentialOptions.js.map +1 -0
  309. package/dist/commonjs/credentials/azureDeveloperCliCredential.d.ts +71 -0
  310. package/dist/commonjs/credentials/azureDeveloperCliCredential.d.ts.map +1 -0
  311. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +176 -0
  312. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +1 -0
  313. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.d.ts +15 -0
  314. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.d.ts.map +1 -0
  315. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.js +5 -0
  316. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.js.map +1 -0
  317. package/dist/commonjs/credentials/azurePipelinesCredential.d.ts +38 -0
  318. package/dist/commonjs/credentials/azurePipelinesCredential.d.ts.map +1 -0
  319. package/dist/commonjs/credentials/azurePipelinesCredential.js +146 -0
  320. package/dist/commonjs/credentials/azurePipelinesCredential.js.map +1 -0
  321. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.d.ts +9 -0
  322. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.d.ts.map +1 -0
  323. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.js +5 -0
  324. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.js.map +1 -0
  325. package/dist/commonjs/credentials/azurePowerShellCredential.d.ts +75 -0
  326. package/dist/commonjs/credentials/azurePowerShellCredential.d.ts.map +1 -0
  327. package/dist/commonjs/credentials/azurePowerShellCredential.js +235 -0
  328. package/dist/commonjs/credentials/azurePowerShellCredential.js.map +1 -0
  329. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.d.ts +15 -0
  330. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.d.ts.map +1 -0
  331. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.js +5 -0
  332. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.js.map +1 -0
  333. package/dist/commonjs/credentials/brokerAuthOptions.d.ts +13 -0
  334. package/dist/commonjs/credentials/brokerAuthOptions.d.ts.map +1 -0
  335. package/dist/commonjs/credentials/brokerAuthOptions.js +3 -0
  336. package/dist/commonjs/credentials/brokerAuthOptions.js.map +1 -0
  337. package/dist/commonjs/credentials/browserCustomizationOptions.d.ts +19 -0
  338. package/dist/commonjs/credentials/browserCustomizationOptions.d.ts.map +1 -0
  339. package/dist/commonjs/credentials/browserCustomizationOptions.js +5 -0
  340. package/dist/commonjs/credentials/browserCustomizationOptions.js.map +1 -0
  341. package/dist/commonjs/credentials/chainedTokenCredential.d.ts +51 -0
  342. package/dist/commonjs/credentials/chainedTokenCredential.d.ts.map +1 -0
  343. package/dist/commonjs/credentials/chainedTokenCredential.js +96 -0
  344. package/dist/commonjs/credentials/chainedTokenCredential.js.map +1 -0
  345. package/dist/commonjs/credentials/clientAssertionCredential.d.ts +33 -0
  346. package/dist/commonjs/credentials/clientAssertionCredential.d.ts.map +1 -0
  347. package/dist/commonjs/credentials/clientAssertionCredential.js +59 -0
  348. package/dist/commonjs/credentials/clientAssertionCredential.js.map +1 -0
  349. package/dist/commonjs/credentials/clientAssertionCredentialOptions.d.ts +9 -0
  350. package/dist/commonjs/credentials/clientAssertionCredentialOptions.d.ts.map +1 -0
  351. package/dist/commonjs/credentials/clientAssertionCredentialOptions.js +5 -0
  352. package/dist/commonjs/credentials/clientAssertionCredentialOptions.js.map +1 -0
  353. package/dist/commonjs/credentials/clientCertificateCredential.d.ts +72 -0
  354. package/dist/commonjs/credentials/clientCertificateCredential.d.ts.map +1 -0
  355. package/dist/commonjs/credentials/clientCertificateCredential.js +127 -0
  356. package/dist/commonjs/credentials/clientCertificateCredential.js.map +1 -0
  357. package/dist/commonjs/credentials/clientCertificateCredentialModels.d.ts +31 -0
  358. package/dist/commonjs/credentials/clientCertificateCredentialModels.d.ts.map +1 -0
  359. package/dist/commonjs/credentials/clientCertificateCredentialModels.js +5 -0
  360. package/dist/commonjs/credentials/clientCertificateCredentialModels.js.map +1 -0
  361. package/dist/commonjs/credentials/clientCertificateCredentialOptions.d.ts +14 -0
  362. package/dist/commonjs/credentials/clientCertificateCredentialOptions.d.ts.map +1 -0
  363. package/dist/commonjs/credentials/clientCertificateCredentialOptions.js +5 -0
  364. package/dist/commonjs/credentials/clientCertificateCredentialOptions.js.map +1 -0
  365. package/dist/commonjs/credentials/clientSecretCredential.d.ts +37 -0
  366. package/dist/commonjs/credentials/clientSecretCredential.d.ts.map +1 -0
  367. package/dist/commonjs/credentials/clientSecretCredential.js +64 -0
  368. package/dist/commonjs/credentials/clientSecretCredential.js.map +1 -0
  369. package/dist/commonjs/credentials/clientSecretCredentialOptions.d.ts +9 -0
  370. package/dist/commonjs/credentials/clientSecretCredentialOptions.d.ts.map +1 -0
  371. package/dist/commonjs/credentials/clientSecretCredentialOptions.js +5 -0
  372. package/dist/commonjs/credentials/clientSecretCredentialOptions.js.map +1 -0
  373. package/dist/commonjs/credentials/credentialPersistenceOptions.d.ts +30 -0
  374. package/dist/commonjs/credentials/credentialPersistenceOptions.d.ts.map +1 -0
  375. package/dist/commonjs/credentials/credentialPersistenceOptions.js +5 -0
  376. package/dist/commonjs/credentials/credentialPersistenceOptions.js.map +1 -0
  377. package/dist/commonjs/credentials/defaultAzureCredential.d.ts +65 -0
  378. package/dist/commonjs/credentials/defaultAzureCredential.d.ts.map +1 -0
  379. package/dist/commonjs/credentials/defaultAzureCredential.js +171 -0
  380. package/dist/commonjs/credentials/defaultAzureCredential.js.map +1 -0
  381. package/dist/commonjs/credentials/defaultAzureCredentialOptions.d.ts +49 -0
  382. package/dist/commonjs/credentials/defaultAzureCredentialOptions.d.ts.map +1 -0
  383. package/dist/commonjs/credentials/defaultAzureCredentialOptions.js +5 -0
  384. package/dist/commonjs/credentials/defaultAzureCredentialOptions.js.map +1 -0
  385. package/dist/commonjs/credentials/deviceCodeCredential.d.ts +67 -0
  386. package/dist/commonjs/credentials/deviceCodeCredential.d.ts.map +1 -0
  387. package/dist/commonjs/credentials/deviceCodeCredential.js +96 -0
  388. package/dist/commonjs/credentials/deviceCodeCredential.js.map +1 -0
  389. package/dist/commonjs/credentials/deviceCodeCredentialOptions.d.ts +53 -0
  390. package/dist/commonjs/credentials/deviceCodeCredentialOptions.d.ts.map +1 -0
  391. package/dist/commonjs/credentials/deviceCodeCredentialOptions.js +5 -0
  392. package/dist/commonjs/credentials/deviceCodeCredentialOptions.js.map +1 -0
  393. package/dist/commonjs/credentials/environmentCredential.d.ts +52 -0
  394. package/dist/commonjs/credentials/environmentCredential.d.ts.map +1 -0
  395. package/dist/commonjs/credentials/environmentCredential.js +135 -0
  396. package/dist/commonjs/credentials/environmentCredential.js.map +1 -0
  397. package/dist/commonjs/credentials/environmentCredentialOptions.d.ts +9 -0
  398. package/dist/commonjs/credentials/environmentCredentialOptions.d.ts.map +1 -0
  399. package/dist/commonjs/credentials/environmentCredentialOptions.js +5 -0
  400. package/dist/commonjs/credentials/environmentCredentialOptions.js.map +1 -0
  401. package/dist/commonjs/credentials/interactiveBrowserCredential.d.ts +56 -0
  402. package/dist/commonjs/credentials/interactiveBrowserCredential.d.ts.map +1 -0
  403. package/dist/commonjs/credentials/interactiveBrowserCredential.js +95 -0
  404. package/dist/commonjs/credentials/interactiveBrowserCredential.js.map +1 -0
  405. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.d.ts +77 -0
  406. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
  407. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.js +5 -0
  408. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
  409. package/dist/commonjs/credentials/interactiveCredentialOptions.d.ts +25 -0
  410. package/dist/commonjs/credentials/interactiveCredentialOptions.d.ts.map +1 -0
  411. package/dist/commonjs/credentials/interactiveCredentialOptions.js +5 -0
  412. package/dist/commonjs/credentials/interactiveCredentialOptions.js.map +1 -0
  413. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.d.ts +18 -0
  414. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.d.ts.map +1 -0
  415. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js +125 -0
  416. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js.map +1 -0
  417. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +12 -0
  418. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -0
  419. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js +36 -0
  420. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -0
  421. package/dist/commonjs/credentials/managedIdentityCredential/index.d.ts +61 -0
  422. package/dist/commonjs/credentials/managedIdentityCredential/index.d.ts.map +1 -0
  423. package/dist/commonjs/credentials/managedIdentityCredential/index.js +221 -0
  424. package/dist/commonjs/credentials/managedIdentityCredential/index.js.map +1 -0
  425. package/dist/commonjs/credentials/managedIdentityCredential/models.d.ts +24 -0
  426. package/dist/commonjs/credentials/managedIdentityCredential/models.d.ts.map +1 -0
  427. package/dist/commonjs/credentials/managedIdentityCredential/models.js +5 -0
  428. package/dist/commonjs/credentials/managedIdentityCredential/models.js.map +1 -0
  429. package/dist/commonjs/credentials/managedIdentityCredential/options.d.ts +37 -0
  430. package/dist/commonjs/credentials/managedIdentityCredential/options.d.ts.map +1 -0
  431. package/dist/commonjs/credentials/managedIdentityCredential/options.js +5 -0
  432. package/dist/commonjs/credentials/managedIdentityCredential/options.js.map +1 -0
  433. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts +14 -0
  434. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts.map +1 -0
  435. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js +35 -0
  436. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
  437. package/dist/commonjs/credentials/managedIdentityCredential/utils.d.ts +33 -0
  438. package/dist/commonjs/credentials/managedIdentityCredential/utils.d.ts.map +1 -0
  439. package/dist/commonjs/credentials/managedIdentityCredential/utils.js +82 -0
  440. package/dist/commonjs/credentials/managedIdentityCredential/utils.js.map +1 -0
  441. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.d.ts +12 -0
  442. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.d.ts.map +1 -0
  443. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.js +5 -0
  444. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.js.map +1 -0
  445. package/dist/commonjs/credentials/onBehalfOfCredential.d.ts +105 -0
  446. package/dist/commonjs/credentials/onBehalfOfCredential.d.ts.map +1 -0
  447. package/dist/commonjs/credentials/onBehalfOfCredential.js +116 -0
  448. package/dist/commonjs/credentials/onBehalfOfCredential.js.map +1 -0
  449. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.d.ts +76 -0
  450. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.d.ts.map +1 -0
  451. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.js +5 -0
  452. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.js.map +1 -0
  453. package/dist/commonjs/credentials/usernamePasswordCredential.d.ts +41 -0
  454. package/dist/commonjs/credentials/usernamePasswordCredential.d.ts.map +1 -0
  455. package/dist/commonjs/credentials/usernamePasswordCredential.js +71 -0
  456. package/dist/commonjs/credentials/usernamePasswordCredential.js.map +1 -0
  457. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.d.ts +9 -0
  458. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.d.ts.map +1 -0
  459. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.js +5 -0
  460. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.js.map +1 -0
  461. package/dist/commonjs/credentials/visualStudioCodeCredential.d.ts +60 -0
  462. package/dist/commonjs/credentials/visualStudioCodeCredential.d.ts.map +1 -0
  463. package/dist/commonjs/credentials/visualStudioCodeCredential.js +196 -0
  464. package/dist/commonjs/credentials/visualStudioCodeCredential.js.map +1 -0
  465. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.d.ts +11 -0
  466. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -0
  467. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js +5 -0
  468. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js.map +1 -0
  469. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.d.ts +11 -0
  470. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -0
  471. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js +5 -0
  472. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js.map +1 -0
  473. package/dist/commonjs/credentials/workloadIdentityCredential.d.ts +47 -0
  474. package/dist/commonjs/credentials/workloadIdentityCredential.d.ts.map +1 -0
  475. package/dist/commonjs/credentials/workloadIdentityCredential.js +118 -0
  476. package/dist/commonjs/credentials/workloadIdentityCredential.js.map +1 -0
  477. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.d.ts +20 -0
  478. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.d.ts.map +1 -0
  479. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.js +5 -0
  480. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.js.map +1 -0
  481. package/dist/commonjs/errors.d.ts +139 -0
  482. package/dist/commonjs/errors.d.ts.map +1 -0
  483. package/dist/commonjs/errors.js +130 -0
  484. package/dist/commonjs/errors.js.map +1 -0
  485. package/dist/commonjs/index.d.ts +61 -0
  486. package/dist/commonjs/index.d.ts.map +1 -0
  487. package/dist/commonjs/index.js +69 -0
  488. package/dist/commonjs/index.js.map +1 -0
  489. package/dist/commonjs/msal/browserFlows/flows.d.ts +42 -0
  490. package/dist/commonjs/msal/browserFlows/flows.d.ts.map +1 -0
  491. package/dist/commonjs/msal/browserFlows/flows.js +5 -0
  492. package/dist/commonjs/msal/browserFlows/flows.js.map +1 -0
  493. package/dist/commonjs/msal/browserFlows/msalAuthCode.d.ts +48 -0
  494. package/dist/commonjs/msal/browserFlows/msalAuthCode.d.ts.map +1 -0
  495. package/dist/commonjs/msal/browserFlows/msalAuthCode.js +208 -0
  496. package/dist/commonjs/msal/browserFlows/msalAuthCode.js.map +1 -0
  497. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts +106 -0
  498. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -0
  499. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js +121 -0
  500. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js.map +1 -0
  501. package/dist/commonjs/msal/credentials.d.ts +52 -0
  502. package/dist/commonjs/msal/credentials.d.ts.map +1 -0
  503. package/dist/commonjs/msal/credentials.js +5 -0
  504. package/dist/commonjs/msal/credentials.js.map +1 -0
  505. package/dist/commonjs/msal/msal.d.ts +3 -0
  506. package/dist/commonjs/msal/msal.d.ts.map +1 -0
  507. package/dist/commonjs/msal/msal.js +9 -0
  508. package/dist/commonjs/msal/msal.js.map +1 -0
  509. package/dist/commonjs/msal/nodeFlows/brokerOptions.d.ts +44 -0
  510. package/dist/commonjs/msal/nodeFlows/brokerOptions.d.ts.map +1 -0
  511. package/dist/commonjs/msal/nodeFlows/brokerOptions.js +3 -0
  512. package/dist/commonjs/msal/nodeFlows/brokerOptions.js.map +1 -0
  513. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts +186 -0
  514. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts.map +1 -0
  515. package/dist/commonjs/msal/nodeFlows/msalClient.js +482 -0
  516. package/dist/commonjs/msal/nodeFlows/msalClient.js.map +1 -0
  517. package/dist/commonjs/msal/nodeFlows/msalPlugins.d.ts +91 -0
  518. package/dist/commonjs/msal/nodeFlows/msalPlugins.d.ts.map +1 -0
  519. package/dist/commonjs/msal/nodeFlows/msalPlugins.js +91 -0
  520. package/dist/commonjs/msal/nodeFlows/msalPlugins.js.map +1 -0
  521. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.d.ts +24 -0
  522. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.d.ts.map +1 -0
  523. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.js +5 -0
  524. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -0
  525. package/dist/commonjs/msal/types.d.ts +87 -0
  526. package/dist/commonjs/msal/types.d.ts.map +1 -0
  527. package/dist/commonjs/msal/types.js +5 -0
  528. package/dist/commonjs/msal/types.js.map +1 -0
  529. package/dist/commonjs/msal/utils.d.ts +95 -0
  530. package/dist/commonjs/msal/utils.d.ts.map +1 -0
  531. package/dist/commonjs/msal/utils.js +253 -0
  532. package/dist/commonjs/msal/utils.js.map +1 -0
  533. package/dist/commonjs/package.json +3 -0
  534. package/dist/commonjs/plugins/consumer.d.ts +28 -0
  535. package/dist/commonjs/plugins/consumer.d.ts.map +1 -0
  536. package/dist/commonjs/plugins/consumer.js +46 -0
  537. package/dist/commonjs/plugins/consumer.js.map +1 -0
  538. package/dist/commonjs/plugins/provider.d.ts +36 -0
  539. package/dist/commonjs/plugins/provider.d.ts.map +1 -0
  540. package/dist/commonjs/plugins/provider.js +5 -0
  541. package/dist/commonjs/plugins/provider.js.map +1 -0
  542. package/dist/commonjs/regionalAuthority.d.ts +122 -0
  543. package/dist/commonjs/regionalAuthority.d.ts.map +1 -0
  544. package/dist/commonjs/regionalAuthority.js +144 -0
  545. package/dist/commonjs/regionalAuthority.js.map +1 -0
  546. package/dist/commonjs/tokenCredentialOptions.d.ts +28 -0
  547. package/dist/commonjs/tokenCredentialOptions.d.ts.map +1 -0
  548. package/dist/commonjs/tokenCredentialOptions.js +5 -0
  549. package/dist/commonjs/tokenCredentialOptions.js.map +1 -0
  550. package/dist/commonjs/tokenProvider.d.ts +39 -0
  551. package/dist/commonjs/tokenProvider.d.ts.map +1 -0
  552. package/dist/commonjs/tokenProvider.js +56 -0
  553. package/dist/commonjs/tokenProvider.js.map +1 -0
  554. package/dist/commonjs/tsdoc-metadata.json +11 -0
  555. package/dist/commonjs/util/identityTokenEndpoint.d.ts +2 -0
  556. package/dist/commonjs/util/identityTokenEndpoint.d.ts.map +1 -0
  557. package/dist/commonjs/util/identityTokenEndpoint.js +14 -0
  558. package/dist/commonjs/util/identityTokenEndpoint.js.map +1 -0
  559. package/dist/commonjs/util/logging.d.ts +70 -0
  560. package/dist/commonjs/util/logging.d.ts.map +1 -0
  561. package/dist/commonjs/util/logging.js +103 -0
  562. package/dist/commonjs/util/logging.js.map +1 -0
  563. package/dist/commonjs/util/processMultiTenantRequest.d.ts +10 -0
  564. package/dist/commonjs/util/processMultiTenantRequest.d.ts.map +1 -0
  565. package/dist/commonjs/util/processMultiTenantRequest.js +38 -0
  566. package/dist/commonjs/util/processMultiTenantRequest.js.map +1 -0
  567. package/dist/commonjs/util/processUtils.d.ts +13 -0
  568. package/dist/commonjs/util/processUtils.d.ts.map +1 -0
  569. package/dist/commonjs/util/processUtils.js +36 -0
  570. package/dist/commonjs/util/processUtils.js.map +1 -0
  571. package/dist/commonjs/util/scopeUtils.d.ts +17 -0
  572. package/dist/commonjs/util/scopeUtils.d.ts.map +1 -0
  573. package/dist/commonjs/util/scopeUtils.js +34 -0
  574. package/dist/commonjs/util/scopeUtils.js.map +1 -0
  575. package/dist/commonjs/util/subscriptionUtils.d.ts +6 -0
  576. package/dist/commonjs/util/subscriptionUtils.d.ts.map +1 -0
  577. package/dist/commonjs/util/subscriptionUtils.js +17 -0
  578. package/dist/commonjs/util/subscriptionUtils.js.map +1 -0
  579. package/dist/commonjs/util/tenantIdUtils.d.ts +15 -0
  580. package/dist/commonjs/util/tenantIdUtils.d.ts.map +1 -0
  581. package/dist/commonjs/util/tenantIdUtils.js +51 -0
  582. package/dist/commonjs/util/tenantIdUtils.js.map +1 -0
  583. package/dist/commonjs/util/tracing.d.ts +6 -0
  584. package/dist/commonjs/util/tracing.d.ts.map +1 -0
  585. package/dist/commonjs/util/tracing.js +17 -0
  586. package/dist/commonjs/util/tracing.js.map +1 -0
  587. package/dist/esm/client/identityClient.d.ts +65 -0
  588. package/dist/esm/client/identityClient.d.ts.map +1 -0
  589. package/dist/esm/client/identityClient.js +248 -0
  590. package/dist/esm/client/identityClient.js.map +1 -0
  591. package/dist/esm/constants.d.ts +69 -0
  592. package/dist/esm/constants.d.ts.map +1 -0
  593. package/dist/esm/constants.js +75 -0
  594. package/dist/esm/constants.js.map +1 -0
  595. package/dist/esm/credentials/authorityValidationOptions.d.ts +16 -0
  596. package/dist/esm/credentials/authorityValidationOptions.d.ts.map +1 -0
  597. package/dist/esm/credentials/authorityValidationOptions.js +4 -0
  598. package/dist/esm/credentials/authorityValidationOptions.js.map +1 -0
  599. package/dist/esm/credentials/authorizationCodeCredential.d.ts +73 -0
  600. package/dist/esm/credentials/authorizationCodeCredential.d.ts.map +1 -0
  601. package/dist/esm/credentials/authorizationCodeCredential.js +60 -0
  602. package/dist/esm/credentials/authorizationCodeCredential.js.map +1 -0
  603. package/dist/esm/credentials/authorizationCodeCredentialOptions.d.ts +8 -0
  604. package/dist/esm/credentials/authorizationCodeCredentialOptions.d.ts.map +1 -0
  605. package/dist/esm/credentials/authorizationCodeCredentialOptions.js +4 -0
  606. package/dist/esm/credentials/authorizationCodeCredentialOptions.js.map +1 -0
  607. package/dist/esm/credentials/azureApplicationCredential.d.ts +24 -0
  608. package/dist/esm/credentials/azureApplicationCredential.d.ts.map +1 -0
  609. package/dist/esm/credentials/azureApplicationCredential.js +32 -0
  610. package/dist/esm/credentials/azureApplicationCredential.js.map +1 -0
  611. package/dist/esm/credentials/azureApplicationCredentialOptions.d.ts +13 -0
  612. package/dist/esm/credentials/azureApplicationCredentialOptions.d.ts.map +1 -0
  613. package/dist/esm/credentials/azureApplicationCredentialOptions.js +4 -0
  614. package/dist/esm/credentials/azureApplicationCredentialOptions.js.map +1 -0
  615. package/dist/esm/credentials/azureCliCredential.d.ts +64 -0
  616. package/dist/esm/credentials/azureCliCredential.d.ts.map +1 -0
  617. package/dist/esm/credentials/azureCliCredential.js +189 -0
  618. package/dist/esm/credentials/azureCliCredential.js.map +1 -0
  619. package/dist/esm/credentials/azureCliCredentialOptions.d.ts +20 -0
  620. package/dist/esm/credentials/azureCliCredentialOptions.d.ts.map +1 -0
  621. package/dist/esm/credentials/azureCliCredentialOptions.js +4 -0
  622. package/dist/esm/credentials/azureCliCredentialOptions.js.map +1 -0
  623. package/dist/esm/credentials/azureDeveloperCliCredential.d.ts +71 -0
  624. package/dist/esm/credentials/azureDeveloperCliCredential.d.ts.map +1 -0
  625. package/dist/esm/credentials/azureDeveloperCliCredential.js +171 -0
  626. package/dist/esm/credentials/azureDeveloperCliCredential.js.map +1 -0
  627. package/dist/esm/credentials/azureDeveloperCliCredentialOptions.d.ts +15 -0
  628. package/dist/esm/credentials/azureDeveloperCliCredentialOptions.d.ts.map +1 -0
  629. package/dist/esm/credentials/azureDeveloperCliCredentialOptions.js +4 -0
  630. package/dist/esm/credentials/azureDeveloperCliCredentialOptions.js.map +1 -0
  631. package/dist/esm/credentials/azurePipelinesCredential.d.ts +38 -0
  632. package/dist/esm/credentials/azurePipelinesCredential.d.ts.map +1 -0
  633. package/dist/esm/credentials/azurePipelinesCredential.js +141 -0
  634. package/dist/esm/credentials/azurePipelinesCredential.js.map +1 -0
  635. package/dist/esm/credentials/azurePipelinesCredentialOptions.d.ts +9 -0
  636. package/dist/esm/credentials/azurePipelinesCredentialOptions.d.ts.map +1 -0
  637. package/dist/esm/credentials/azurePipelinesCredentialOptions.js +4 -0
  638. package/dist/esm/credentials/azurePipelinesCredentialOptions.js.map +1 -0
  639. package/dist/esm/credentials/azurePowerShellCredential.d.ts +75 -0
  640. package/dist/esm/credentials/azurePowerShellCredential.d.ts.map +1 -0
  641. package/dist/esm/credentials/azurePowerShellCredential.js +229 -0
  642. package/dist/esm/credentials/azurePowerShellCredential.js.map +1 -0
  643. package/dist/esm/credentials/azurePowerShellCredentialOptions.d.ts +15 -0
  644. package/dist/esm/credentials/azurePowerShellCredentialOptions.d.ts.map +1 -0
  645. package/dist/esm/credentials/azurePowerShellCredentialOptions.js +4 -0
  646. package/dist/esm/credentials/azurePowerShellCredentialOptions.js.map +1 -0
  647. package/dist/esm/credentials/brokerAuthOptions.d.ts +13 -0
  648. package/dist/esm/credentials/brokerAuthOptions.d.ts.map +1 -0
  649. package/dist/esm/credentials/brokerAuthOptions.js +2 -0
  650. package/dist/esm/credentials/brokerAuthOptions.js.map +1 -0
  651. package/dist/esm/credentials/browserCustomizationOptions.d.ts +19 -0
  652. package/dist/esm/credentials/browserCustomizationOptions.d.ts.map +1 -0
  653. package/dist/esm/credentials/browserCustomizationOptions.js +4 -0
  654. package/dist/esm/credentials/browserCustomizationOptions.js.map +1 -0
  655. package/dist/esm/credentials/chainedTokenCredential.d.ts +51 -0
  656. package/dist/esm/credentials/chainedTokenCredential.d.ts.map +1 -0
  657. package/dist/esm/credentials/chainedTokenCredential.js +92 -0
  658. package/dist/esm/credentials/chainedTokenCredential.js.map +1 -0
  659. package/dist/esm/credentials/clientAssertionCredential.d.ts +33 -0
  660. package/dist/esm/credentials/clientAssertionCredential.d.ts.map +1 -0
  661. package/dist/esm/credentials/clientAssertionCredential.js +55 -0
  662. package/dist/esm/credentials/clientAssertionCredential.js.map +1 -0
  663. package/dist/esm/credentials/clientAssertionCredentialOptions.d.ts +9 -0
  664. package/dist/esm/credentials/clientAssertionCredentialOptions.d.ts.map +1 -0
  665. package/dist/esm/credentials/clientAssertionCredentialOptions.js +4 -0
  666. package/dist/esm/credentials/clientAssertionCredentialOptions.js.map +1 -0
  667. package/dist/esm/credentials/clientCertificateCredential.d.ts +72 -0
  668. package/dist/esm/credentials/clientCertificateCredential.d.ts.map +1 -0
  669. package/dist/esm/credentials/clientCertificateCredential.js +122 -0
  670. package/dist/esm/credentials/clientCertificateCredential.js.map +1 -0
  671. package/dist/esm/credentials/clientCertificateCredentialModels.d.ts +31 -0
  672. package/dist/esm/credentials/clientCertificateCredentialModels.d.ts.map +1 -0
  673. package/dist/esm/credentials/clientCertificateCredentialModels.js +4 -0
  674. package/dist/esm/credentials/clientCertificateCredentialModels.js.map +1 -0
  675. package/dist/esm/credentials/clientCertificateCredentialOptions.d.ts +14 -0
  676. package/dist/esm/credentials/clientCertificateCredentialOptions.d.ts.map +1 -0
  677. package/dist/esm/credentials/clientCertificateCredentialOptions.js +4 -0
  678. package/dist/esm/credentials/clientCertificateCredentialOptions.js.map +1 -0
  679. package/dist/esm/credentials/clientSecretCredential.d.ts +37 -0
  680. package/dist/esm/credentials/clientSecretCredential.d.ts.map +1 -0
  681. package/dist/esm/credentials/clientSecretCredential.js +60 -0
  682. package/dist/esm/credentials/clientSecretCredential.js.map +1 -0
  683. package/dist/esm/credentials/clientSecretCredentialOptions.d.ts +9 -0
  684. package/dist/esm/credentials/clientSecretCredentialOptions.d.ts.map +1 -0
  685. package/dist/esm/credentials/clientSecretCredentialOptions.js +4 -0
  686. package/dist/esm/credentials/clientSecretCredentialOptions.js.map +1 -0
  687. package/dist/esm/credentials/credentialPersistenceOptions.d.ts +30 -0
  688. package/dist/esm/credentials/credentialPersistenceOptions.d.ts.map +1 -0
  689. package/dist/esm/credentials/credentialPersistenceOptions.js +4 -0
  690. package/dist/esm/credentials/credentialPersistenceOptions.js.map +1 -0
  691. package/dist/esm/credentials/defaultAzureCredential.d.ts +65 -0
  692. package/dist/esm/credentials/defaultAzureCredential.d.ts.map +1 -0
  693. package/dist/esm/credentials/defaultAzureCredential.js +164 -0
  694. package/dist/esm/credentials/defaultAzureCredential.js.map +1 -0
  695. package/dist/esm/credentials/defaultAzureCredentialOptions.d.ts +49 -0
  696. package/dist/esm/credentials/defaultAzureCredentialOptions.d.ts.map +1 -0
  697. package/dist/esm/credentials/defaultAzureCredentialOptions.js +4 -0
  698. package/dist/esm/credentials/defaultAzureCredentialOptions.js.map +1 -0
  699. package/dist/esm/credentials/deviceCodeCredential.d.ts +67 -0
  700. package/dist/esm/credentials/deviceCodeCredential.d.ts.map +1 -0
  701. package/dist/esm/credentials/deviceCodeCredential.js +91 -0
  702. package/dist/esm/credentials/deviceCodeCredential.js.map +1 -0
  703. package/dist/esm/credentials/deviceCodeCredentialOptions.d.ts +53 -0
  704. package/dist/esm/credentials/deviceCodeCredentialOptions.d.ts.map +1 -0
  705. package/dist/esm/credentials/deviceCodeCredentialOptions.js +4 -0
  706. package/dist/esm/credentials/deviceCodeCredentialOptions.js.map +1 -0
  707. package/dist/esm/credentials/environmentCredential.d.ts +52 -0
  708. package/dist/esm/credentials/environmentCredential.d.ts.map +1 -0
  709. package/dist/esm/credentials/environmentCredential.js +130 -0
  710. package/dist/esm/credentials/environmentCredential.js.map +1 -0
  711. package/dist/esm/credentials/environmentCredentialOptions.d.ts +9 -0
  712. package/dist/esm/credentials/environmentCredentialOptions.d.ts.map +1 -0
  713. package/dist/esm/credentials/environmentCredentialOptions.js +4 -0
  714. package/dist/esm/credentials/environmentCredentialOptions.js.map +1 -0
  715. package/dist/esm/credentials/interactiveBrowserCredential.d.ts +56 -0
  716. package/dist/esm/credentials/interactiveBrowserCredential.d.ts.map +1 -0
  717. package/dist/esm/credentials/interactiveBrowserCredential.js +91 -0
  718. package/dist/esm/credentials/interactiveBrowserCredential.js.map +1 -0
  719. package/dist/esm/credentials/interactiveBrowserCredentialOptions.d.ts +77 -0
  720. package/dist/esm/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
  721. package/dist/esm/credentials/interactiveBrowserCredentialOptions.js +4 -0
  722. package/dist/esm/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
  723. package/dist/esm/credentials/interactiveCredentialOptions.d.ts +25 -0
  724. package/dist/esm/credentials/interactiveCredentialOptions.d.ts.map +1 -0
  725. package/dist/esm/credentials/interactiveCredentialOptions.js +4 -0
  726. package/dist/esm/credentials/interactiveCredentialOptions.js.map +1 -0
  727. package/dist/esm/credentials/managedIdentityCredential/imdsMsi.d.ts +18 -0
  728. package/dist/esm/credentials/managedIdentityCredential/imdsMsi.d.ts.map +1 -0
  729. package/dist/esm/credentials/managedIdentityCredential/imdsMsi.js +122 -0
  730. package/dist/esm/credentials/managedIdentityCredential/imdsMsi.js.map +1 -0
  731. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +12 -0
  732. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -0
  733. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.js +33 -0
  734. package/dist/esm/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -0
  735. package/dist/esm/credentials/managedIdentityCredential/index.d.ts +61 -0
  736. package/dist/esm/credentials/managedIdentityCredential/index.d.ts.map +1 -0
  737. package/dist/esm/credentials/managedIdentityCredential/index.js +217 -0
  738. package/dist/esm/credentials/managedIdentityCredential/index.js.map +1 -0
  739. package/dist/esm/credentials/managedIdentityCredential/models.d.ts +24 -0
  740. package/dist/esm/credentials/managedIdentityCredential/models.d.ts.map +1 -0
  741. package/dist/esm/credentials/managedIdentityCredential/models.js +4 -0
  742. package/dist/esm/credentials/managedIdentityCredential/models.js.map +1 -0
  743. package/dist/esm/credentials/managedIdentityCredential/options.d.ts +37 -0
  744. package/dist/esm/credentials/managedIdentityCredential/options.d.ts.map +1 -0
  745. package/dist/esm/credentials/managedIdentityCredential/options.js +4 -0
  746. package/dist/esm/credentials/managedIdentityCredential/options.js.map +1 -0
  747. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts +14 -0
  748. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts.map +1 -0
  749. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.js +32 -0
  750. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
  751. package/dist/esm/credentials/managedIdentityCredential/utils.d.ts +33 -0
  752. package/dist/esm/credentials/managedIdentityCredential/utils.d.ts.map +1 -0
  753. package/dist/esm/credentials/managedIdentityCredential/utils.js +77 -0
  754. package/dist/esm/credentials/managedIdentityCredential/utils.js.map +1 -0
  755. package/dist/esm/credentials/multiTenantTokenCredentialOptions.d.ts +12 -0
  756. package/dist/esm/credentials/multiTenantTokenCredentialOptions.d.ts.map +1 -0
  757. package/dist/esm/credentials/multiTenantTokenCredentialOptions.js +4 -0
  758. package/dist/esm/credentials/multiTenantTokenCredentialOptions.js.map +1 -0
  759. package/dist/esm/credentials/onBehalfOfCredential.d.ts +105 -0
  760. package/dist/esm/credentials/onBehalfOfCredential.d.ts.map +1 -0
  761. package/dist/esm/credentials/onBehalfOfCredential.js +112 -0
  762. package/dist/esm/credentials/onBehalfOfCredential.js.map +1 -0
  763. package/dist/esm/credentials/onBehalfOfCredentialOptions.d.ts +76 -0
  764. package/dist/esm/credentials/onBehalfOfCredentialOptions.d.ts.map +1 -0
  765. package/dist/esm/credentials/onBehalfOfCredentialOptions.js +4 -0
  766. package/dist/esm/credentials/onBehalfOfCredentialOptions.js.map +1 -0
  767. package/dist/esm/credentials/usernamePasswordCredential.d.ts +41 -0
  768. package/dist/esm/credentials/usernamePasswordCredential.d.ts.map +1 -0
  769. package/dist/esm/credentials/usernamePasswordCredential.js +67 -0
  770. package/dist/esm/credentials/usernamePasswordCredential.js.map +1 -0
  771. package/dist/esm/credentials/usernamePasswordCredentialOptions.d.ts +9 -0
  772. package/dist/esm/credentials/usernamePasswordCredentialOptions.d.ts.map +1 -0
  773. package/dist/esm/credentials/usernamePasswordCredentialOptions.js +4 -0
  774. package/dist/esm/credentials/usernamePasswordCredentialOptions.js.map +1 -0
  775. package/dist/esm/credentials/visualStudioCodeCredential.d.ts +60 -0
  776. package/dist/esm/credentials/visualStudioCodeCredential.d.ts.map +1 -0
  777. package/dist/esm/credentials/visualStudioCodeCredential.js +190 -0
  778. package/dist/esm/credentials/visualStudioCodeCredential.js.map +1 -0
  779. package/dist/esm/credentials/visualStudioCodeCredentialOptions.d.ts +11 -0
  780. package/dist/esm/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -0
  781. package/dist/esm/credentials/visualStudioCodeCredentialOptions.js +4 -0
  782. package/dist/esm/credentials/visualStudioCodeCredentialOptions.js.map +1 -0
  783. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.d.ts +11 -0
  784. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -0
  785. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.js +4 -0
  786. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.js.map +1 -0
  787. package/dist/esm/credentials/workloadIdentityCredential.d.ts +47 -0
  788. package/dist/esm/credentials/workloadIdentityCredential.d.ts.map +1 -0
  789. package/dist/esm/credentials/workloadIdentityCredential.js +114 -0
  790. package/dist/esm/credentials/workloadIdentityCredential.js.map +1 -0
  791. package/dist/esm/credentials/workloadIdentityCredentialOptions.d.ts +20 -0
  792. package/dist/esm/credentials/workloadIdentityCredentialOptions.d.ts.map +1 -0
  793. package/dist/esm/credentials/workloadIdentityCredentialOptions.js +4 -0
  794. package/dist/esm/credentials/workloadIdentityCredentialOptions.js.map +1 -0
  795. package/dist/esm/errors.d.ts +139 -0
  796. package/dist/esm/errors.d.ts.map +1 -0
  797. package/dist/esm/errors.js +123 -0
  798. package/dist/esm/errors.js.map +1 -0
  799. package/dist/esm/index.d.ts +61 -0
  800. package/dist/esm/index.d.ts.map +1 -0
  801. package/dist/esm/index.js +34 -0
  802. package/dist/esm/index.js.map +1 -0
  803. package/dist/esm/msal/browserFlows/flows.d.ts +42 -0
  804. package/dist/esm/msal/browserFlows/flows.d.ts.map +1 -0
  805. package/dist/esm/msal/browserFlows/flows.js +4 -0
  806. package/dist/esm/msal/browserFlows/flows.js.map +1 -0
  807. package/dist/esm/msal/browserFlows/msalAuthCode.d.ts +48 -0
  808. package/dist/esm/msal/browserFlows/msalAuthCode.d.ts.map +1 -0
  809. package/dist/esm/msal/browserFlows/msalAuthCode.js +203 -0
  810. package/dist/esm/msal/browserFlows/msalAuthCode.js.map +1 -0
  811. package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts +106 -0
  812. package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -0
  813. package/dist/esm/msal/browserFlows/msalBrowserCommon.js +116 -0
  814. package/dist/esm/msal/browserFlows/msalBrowserCommon.js.map +1 -0
  815. package/dist/esm/msal/credentials.d.ts +52 -0
  816. package/dist/esm/msal/credentials.d.ts.map +1 -0
  817. package/dist/esm/msal/credentials.js +4 -0
  818. package/dist/esm/msal/credentials.js.map +1 -0
  819. package/dist/esm/msal/msal.d.ts +3 -0
  820. package/dist/esm/msal/msal.d.ts.map +1 -0
  821. package/dist/esm/msal/nodeFlows/brokerOptions.d.ts +44 -0
  822. package/dist/esm/msal/nodeFlows/brokerOptions.d.ts.map +1 -0
  823. package/dist/esm/msal/nodeFlows/brokerOptions.js +2 -0
  824. package/dist/esm/msal/nodeFlows/brokerOptions.js.map +1 -0
  825. package/dist/esm/msal/nodeFlows/msalClient.d.ts +186 -0
  826. package/dist/esm/msal/nodeFlows/msalClient.d.ts.map +1 -0
  827. package/dist/esm/msal/nodeFlows/msalClient.js +477 -0
  828. package/dist/esm/msal/nodeFlows/msalClient.js.map +1 -0
  829. package/dist/esm/msal/nodeFlows/msalPlugins.d.ts +91 -0
  830. package/dist/esm/msal/nodeFlows/msalPlugins.d.ts.map +1 -0
  831. package/dist/esm/msal/nodeFlows/msalPlugins.js +87 -0
  832. package/dist/esm/msal/nodeFlows/msalPlugins.js.map +1 -0
  833. package/dist/esm/msal/nodeFlows/tokenCachePersistenceOptions.d.ts +24 -0
  834. package/dist/esm/msal/nodeFlows/tokenCachePersistenceOptions.d.ts.map +1 -0
  835. package/dist/esm/msal/nodeFlows/tokenCachePersistenceOptions.js +4 -0
  836. package/dist/esm/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -0
  837. package/dist/esm/msal/types.d.ts +87 -0
  838. package/dist/esm/msal/types.d.ts.map +1 -0
  839. package/dist/esm/msal/types.js +4 -0
  840. package/dist/esm/msal/types.js.map +1 -0
  841. package/dist/esm/msal/utils.d.ts +95 -0
  842. package/dist/esm/msal/utils.d.ts.map +1 -0
  843. package/dist/esm/msal/utils.js +238 -0
  844. package/dist/esm/msal/utils.js.map +1 -0
  845. package/dist/esm/package.json +3 -0
  846. package/dist/esm/plugins/consumer.d.ts +28 -0
  847. package/dist/esm/plugins/consumer.d.ts.map +1 -0
  848. package/dist/esm/plugins/consumer.js +43 -0
  849. package/dist/esm/plugins/consumer.js.map +1 -0
  850. package/dist/esm/plugins/provider.d.ts +36 -0
  851. package/dist/esm/plugins/provider.d.ts.map +1 -0
  852. package/dist/esm/plugins/provider.js +4 -0
  853. package/dist/esm/plugins/provider.js.map +1 -0
  854. package/dist/esm/regionalAuthority.d.ts +122 -0
  855. package/dist/esm/regionalAuthority.d.ts.map +1 -0
  856. package/dist/esm/regionalAuthority.js +140 -0
  857. package/dist/esm/regionalAuthority.js.map +1 -0
  858. package/dist/esm/tokenCredentialOptions.d.ts +28 -0
  859. package/dist/esm/tokenCredentialOptions.d.ts.map +1 -0
  860. package/dist/esm/tokenCredentialOptions.js +4 -0
  861. package/dist/esm/tokenCredentialOptions.js.map +1 -0
  862. package/dist/esm/tokenProvider.d.ts +39 -0
  863. package/dist/esm/tokenProvider.d.ts.map +1 -0
  864. package/dist/esm/tokenProvider.js +53 -0
  865. package/dist/esm/tokenProvider.js.map +1 -0
  866. package/dist/esm/util/authHostEnv-browser.d.mts +4 -0
  867. package/dist/esm/util/authHostEnv-browser.d.mts.map +1 -0
  868. package/dist/esm/util/authHostEnv-browser.mjs +7 -0
  869. package/dist/esm/util/authHostEnv-browser.mjs.map +1 -0
  870. package/dist/esm/util/identityTokenEndpoint.d.ts +2 -0
  871. package/dist/esm/util/identityTokenEndpoint.d.ts.map +1 -0
  872. package/dist/esm/util/identityTokenEndpoint.js +11 -0
  873. package/dist/esm/util/identityTokenEndpoint.js.map +1 -0
  874. package/dist/esm/util/logging.d.ts +70 -0
  875. package/dist/esm/util/logging.d.ts.map +1 -0
  876. package/dist/esm/util/logging.js +94 -0
  877. package/dist/esm/util/logging.js.map +1 -0
  878. package/dist/esm/util/processMultiTenantRequest.d.ts +10 -0
  879. package/dist/esm/util/processMultiTenantRequest.d.ts.map +1 -0
  880. package/dist/esm/util/processMultiTenantRequest.js +35 -0
  881. package/dist/esm/util/processMultiTenantRequest.js.map +1 -0
  882. package/dist/esm/util/processUtils.d.ts +13 -0
  883. package/dist/esm/util/processUtils.d.ts.map +1 -0
  884. package/dist/esm/util/processUtils.js +32 -0
  885. package/dist/esm/util/processUtils.js.map +1 -0
  886. package/dist/esm/util/scopeUtils.d.ts +17 -0
  887. package/dist/esm/util/scopeUtils.d.ts.map +1 -0
  888. package/dist/esm/util/scopeUtils.js +29 -0
  889. package/dist/esm/util/scopeUtils.js.map +1 -0
  890. package/dist/esm/util/subscriptionUtils.d.ts +6 -0
  891. package/dist/esm/util/subscriptionUtils.d.ts.map +1 -0
  892. package/dist/esm/util/subscriptionUtils.js +14 -0
  893. package/dist/esm/util/subscriptionUtils.js.map +1 -0
  894. package/dist/esm/util/tenantIdUtils.d.ts +15 -0
  895. package/dist/esm/util/tenantIdUtils.d.ts.map +1 -0
  896. package/dist/esm/util/tenantIdUtils.js +44 -0
  897. package/dist/esm/util/tenantIdUtils.js.map +1 -0
  898. package/dist/esm/util/tracing.d.ts +6 -0
  899. package/dist/esm/util/tracing.d.ts.map +1 -0
  900. package/dist/esm/util/tracing.js +14 -0
  901. package/dist/esm/util/tracing.js.map +1 -0
  902. package/package.json +65 -79
  903. package/dist/index.js +0 -4211
  904. package/dist/index.js.map +0 -1
  905. package/dist-esm/src/client/identityClient.js +0 -248
  906. package/dist-esm/src/client/identityClient.js.map +0 -1
  907. package/dist-esm/src/constants.js +0 -67
  908. package/dist-esm/src/constants.js.map +0 -1
  909. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js +0 -16
  910. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +0 -1
  911. package/dist-esm/src/credentials/authorizationCodeCredential.js +0 -60
  912. package/dist-esm/src/credentials/authorizationCodeCredential.js.map +0 -1
  913. package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js.map +0 -1
  914. package/dist-esm/src/credentials/azureApplicationCredential.browser.js +0 -34
  915. package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +0 -1
  916. package/dist-esm/src/credentials/azureApplicationCredential.js +0 -32
  917. package/dist-esm/src/credentials/azureApplicationCredential.js.map +0 -1
  918. package/dist-esm/src/credentials/azureApplicationCredentialOptions.js.map +0 -1
  919. package/dist-esm/src/credentials/azureCliCredential.browser.js +0 -23
  920. package/dist-esm/src/credentials/azureCliCredential.browser.js.map +0 -1
  921. package/dist-esm/src/credentials/azureCliCredential.js +0 -175
  922. package/dist-esm/src/credentials/azureCliCredential.js.map +0 -1
  923. package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +0 -1
  924. package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js +0 -23
  925. package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js.map +0 -1
  926. package/dist-esm/src/credentials/azureDeveloperCliCredential.js +0 -171
  927. package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +0 -1
  928. package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js.map +0 -1
  929. package/dist-esm/src/credentials/azurePipelinesCredential.browser.js +0 -23
  930. package/dist-esm/src/credentials/azurePipelinesCredential.browser.js.map +0 -1
  931. package/dist-esm/src/credentials/azurePipelinesCredential.js +0 -141
  932. package/dist-esm/src/credentials/azurePipelinesCredential.js.map +0 -1
  933. package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js.map +0 -1
  934. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +0 -22
  935. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +0 -1
  936. package/dist-esm/src/credentials/azurePowerShellCredential.js +0 -229
  937. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +0 -1
  938. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +0 -1
  939. package/dist-esm/src/credentials/brokerAuthOptions.js.map +0 -1
  940. package/dist-esm/src/credentials/chainedTokenCredential.js +0 -89
  941. package/dist-esm/src/credentials/chainedTokenCredential.js.map +0 -1
  942. package/dist-esm/src/credentials/clientAssertionCredential.browser.js +0 -22
  943. package/dist-esm/src/credentials/clientAssertionCredential.browser.js.map +0 -1
  944. package/dist-esm/src/credentials/clientAssertionCredential.js +0 -55
  945. package/dist-esm/src/credentials/clientAssertionCredential.js.map +0 -1
  946. package/dist-esm/src/credentials/clientAssertionCredentialOptions.js.map +0 -1
  947. package/dist-esm/src/credentials/clientCertificateCredential.browser.js +0 -23
  948. package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +0 -1
  949. package/dist-esm/src/credentials/clientCertificateCredential.js +0 -119
  950. package/dist-esm/src/credentials/clientCertificateCredential.js.map +0 -1
  951. package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +0 -1
  952. package/dist-esm/src/credentials/clientSecretCredential.browser.js +0 -83
  953. package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +0 -1
  954. package/dist-esm/src/credentials/clientSecretCredential.js +0 -60
  955. package/dist-esm/src/credentials/clientSecretCredential.js.map +0 -1
  956. package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +0 -1
  957. package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +0 -1
  958. package/dist-esm/src/credentials/defaultAzureCredential.browser.js +0 -29
  959. package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +0 -1
  960. package/dist-esm/src/credentials/defaultAzureCredential.js +0 -151
  961. package/dist-esm/src/credentials/defaultAzureCredential.js.map +0 -1
  962. package/dist-esm/src/credentials/defaultAzureCredentialOptions.js.map +0 -1
  963. package/dist-esm/src/credentials/deviceCodeCredential.browser.js +0 -23
  964. package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +0 -1
  965. package/dist-esm/src/credentials/deviceCodeCredential.js +0 -91
  966. package/dist-esm/src/credentials/deviceCodeCredential.js.map +0 -1
  967. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +0 -1
  968. package/dist-esm/src/credentials/environmentCredential.browser.js +0 -23
  969. package/dist-esm/src/credentials/environmentCredential.browser.js.map +0 -1
  970. package/dist-esm/src/credentials/environmentCredential.js +0 -130
  971. package/dist-esm/src/credentials/environmentCredential.js.map +0 -1
  972. package/dist-esm/src/credentials/environmentCredentialOptions.js.map +0 -1
  973. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +0 -86
  974. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +0 -1
  975. package/dist-esm/src/credentials/interactiveBrowserCredential.js +0 -91
  976. package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +0 -1
  977. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +0 -1
  978. package/dist-esm/src/credentials/interactiveCredentialOptions.js.map +0 -1
  979. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +0 -71
  980. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +0 -1
  981. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js +0 -71
  982. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js.map +0 -1
  983. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +0 -140
  984. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +0 -1
  985. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +0 -75
  986. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +0 -1
  987. package/dist-esm/src/credentials/managedIdentityCredential/constants.js +0 -9
  988. package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +0 -1
  989. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +0 -95
  990. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +0 -1
  991. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +0 -144
  992. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +0 -1
  993. package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +0 -1
  994. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js +0 -16
  995. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +0 -1
  996. package/dist-esm/src/credentials/managedIdentityCredential/index.js +0 -37
  997. package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +0 -1
  998. package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js +0 -309
  999. package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js.map +0 -1
  1000. package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +0 -1
  1001. package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js +0 -212
  1002. package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js.map +0 -1
  1003. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +0 -29
  1004. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +0 -1
  1005. package/dist-esm/src/credentials/managedIdentityCredential/utils.js +0 -77
  1006. package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +0 -1
  1007. package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js.map +0 -1
  1008. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +0 -23
  1009. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +0 -1
  1010. package/dist-esm/src/credentials/onBehalfOfCredential.js +0 -112
  1011. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +0 -1
  1012. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +0 -1
  1013. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +0 -77
  1014. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +0 -1
  1015. package/dist-esm/src/credentials/usernamePasswordCredential.js +0 -67
  1016. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +0 -1
  1017. package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +0 -1
  1018. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +0 -27
  1019. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +0 -1
  1020. package/dist-esm/src/credentials/visualStudioCodeCredential.js +0 -190
  1021. package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +0 -1
  1022. package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js.map +0 -1
  1023. package/dist-esm/src/credentials/workloadIdentityCredential.browser.js +0 -27
  1024. package/dist-esm/src/credentials/workloadIdentityCredential.browser.js.map +0 -1
  1025. package/dist-esm/src/credentials/workloadIdentityCredential.js +0 -114
  1026. package/dist-esm/src/credentials/workloadIdentityCredential.js.map +0 -1
  1027. package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js.map +0 -1
  1028. package/dist-esm/src/errors.js.map +0 -1
  1029. package/dist-esm/src/index.js +0 -34
  1030. package/dist-esm/src/index.js.map +0 -1
  1031. package/dist-esm/src/msal/browserFlows/flows.js.map +0 -1
  1032. package/dist-esm/src/msal/browserFlows/msalAuthCode.js +0 -203
  1033. package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +0 -1
  1034. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +0 -116
  1035. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +0 -1
  1036. package/dist-esm/src/msal/credentials.js.map +0 -1
  1037. package/dist-esm/src/msal/msal.browser.js +0 -5
  1038. package/dist-esm/src/msal/msal.browser.js.map +0 -1
  1039. package/dist-esm/src/msal/nodeFlows/msalClient.js +0 -484
  1040. package/dist-esm/src/msal/nodeFlows/msalClient.js.map +0 -1
  1041. package/dist-esm/src/msal/nodeFlows/msalPlugins.js +0 -87
  1042. package/dist-esm/src/msal/nodeFlows/msalPlugins.js.map +0 -1
  1043. package/dist-esm/src/msal/types.js.map +0 -1
  1044. package/dist-esm/src/msal/utils.js +0 -232
  1045. package/dist-esm/src/msal/utils.js.map +0 -1
  1046. package/dist-esm/src/plugins/consumer.browser.js +0 -7
  1047. package/dist-esm/src/plugins/consumer.browser.js.map +0 -1
  1048. package/dist-esm/src/plugins/consumer.js +0 -43
  1049. package/dist-esm/src/plugins/consumer.js.map +0 -1
  1050. package/dist-esm/src/plugins/provider.js.map +0 -1
  1051. package/dist-esm/src/tokenCredentialOptions.js.map +0 -1
  1052. package/dist-esm/src/tokenProvider.js +0 -52
  1053. package/dist-esm/src/tokenProvider.js.map +0 -1
  1054. package/dist-esm/src/util/authHostEnv.browser.js +0 -7
  1055. package/dist-esm/src/util/authHostEnv.browser.js.map +0 -1
  1056. package/dist-esm/src/util/logging.js.map +0 -1
  1057. package/dist-esm/src/util/processMultiTenantRequest.browser.js +0 -29
  1058. package/dist-esm/src/util/processMultiTenantRequest.browser.js.map +0 -1
  1059. package/dist-esm/src/util/processMultiTenantRequest.js +0 -35
  1060. package/dist-esm/src/util/processMultiTenantRequest.js.map +0 -1
  1061. package/dist-esm/src/util/scopeUtils.js +0 -29
  1062. package/dist-esm/src/util/scopeUtils.js.map +0 -1
  1063. package/dist-esm/src/util/tenantIdUtils.js +0 -44
  1064. package/dist-esm/src/util/tenantIdUtils.js.map +0 -1
  1065. package/dist-esm/src/util/tracing.js +0 -14
  1066. package/dist-esm/src/util/tracing.js.map +0 -1
  1067. package/types/identity.d.ts +0 -1853
  1068. /package/{dist-esm/src → dist/browser}/credentials/authorityValidationOptions.js +0 -0
  1069. /package/{dist-esm/src → dist/browser}/credentials/authorityValidationOptions.js.map +0 -0
  1070. /package/{dist-esm/src → dist/browser}/credentials/authorizationCodeCredentialOptions.js +0 -0
  1071. /package/{dist-esm/src → dist/browser}/credentials/azureApplicationCredentialOptions.js +0 -0
  1072. /package/{dist-esm/src → dist/browser}/credentials/azureCliCredentialOptions.js +0 -0
  1073. /package/{dist-esm/src → dist/browser}/credentials/azureDeveloperCliCredentialOptions.js +0 -0
  1074. /package/{dist-esm/src → dist/browser}/credentials/azurePipelinesCredentialOptions.js +0 -0
  1075. /package/{dist-esm/src → dist/browser}/credentials/azurePowerShellCredentialOptions.js +0 -0
  1076. /package/{dist-esm/src → dist/browser}/credentials/brokerAuthOptions.js +0 -0
  1077. /package/{dist-esm/src → dist/browser}/credentials/browserCustomizationOptions.js +0 -0
  1078. /package/{dist-esm/src → dist/browser}/credentials/browserCustomizationOptions.js.map +0 -0
  1079. /package/{dist-esm/src → dist/browser}/credentials/clientAssertionCredentialOptions.js +0 -0
  1080. /package/{dist-esm/src → dist/browser}/credentials/clientCertificateCredentialOptions.js +0 -0
  1081. /package/{dist-esm/src → dist/browser}/credentials/clientSecretCredentialOptions.js +0 -0
  1082. /package/{dist-esm/src → dist/browser}/credentials/credentialPersistenceOptions.js +0 -0
  1083. /package/{dist-esm/src → dist/browser}/credentials/defaultAzureCredentialOptions.js +0 -0
  1084. /package/{dist-esm/src → dist/browser}/credentials/deviceCodeCredentialOptions.js +0 -0
  1085. /package/{dist-esm/src → dist/browser}/credentials/environmentCredentialOptions.js +0 -0
  1086. /package/{dist-esm/src → dist/browser}/credentials/interactiveBrowserCredentialOptions.js +0 -0
  1087. /package/{dist-esm/src → dist/browser}/credentials/interactiveCredentialOptions.js +0 -0
  1088. /package/{dist-esm/src → dist/browser}/credentials/managedIdentityCredential/imdsRetryPolicy.js +0 -0
  1089. /package/{dist-esm/src → dist/browser}/credentials/managedIdentityCredential/models.js +0 -0
  1090. /package/{dist-esm/src → dist/browser}/credentials/multiTenantTokenCredentialOptions.js +0 -0
  1091. /package/{dist-esm/src → dist/browser}/credentials/onBehalfOfCredentialOptions.js +0 -0
  1092. /package/{dist-esm/src → dist/browser}/credentials/usernamePasswordCredentialOptions.js +0 -0
  1093. /package/{dist-esm/src → dist/browser}/credentials/visualStudioCodeCredentialOptions.js +0 -0
  1094. /package/{dist-esm/src → dist/browser}/credentials/visualStudioCodeCredentialPlugin.js +0 -0
  1095. /package/{dist-esm/src → dist/browser}/credentials/visualStudioCodeCredentialPlugin.js.map +0 -0
  1096. /package/{dist-esm/src → dist/browser}/credentials/workloadIdentityCredentialOptions.js +0 -0
  1097. /package/{dist-esm/src → dist/browser}/errors.js +0 -0
  1098. /package/{dist-esm/src → dist/browser}/msal/browserFlows/flows.js +0 -0
  1099. /package/{dist-esm/src → dist/browser}/msal/credentials.js +0 -0
  1100. /package/{dist-esm/src → dist/browser}/msal/nodeFlows/brokerOptions.js +0 -0
  1101. /package/{dist-esm/src → dist/browser}/msal/nodeFlows/brokerOptions.js.map +0 -0
  1102. /package/{dist-esm/src → dist/browser}/msal/nodeFlows/tokenCachePersistenceOptions.js +0 -0
  1103. /package/{dist-esm/src → dist/browser}/msal/nodeFlows/tokenCachePersistenceOptions.js.map +0 -0
  1104. /package/{dist-esm/src → dist/browser}/msal/types.js +0 -0
  1105. /package/{dist-esm/src → dist/browser}/plugins/provider.js +0 -0
  1106. /package/{dist-esm/src → dist/browser}/regionalAuthority.js +0 -0
  1107. /package/{dist-esm/src → dist/browser}/regionalAuthority.js.map +0 -0
  1108. /package/{dist-esm/src → dist/browser}/tokenCredentialOptions.js +0 -0
  1109. /package/{dist-esm/src → dist/browser}/util/identityTokenEndpoint.js +0 -0
  1110. /package/{dist-esm/src → dist/browser}/util/identityTokenEndpoint.js.map +0 -0
  1111. /package/{dist-esm/src → dist/browser}/util/logging.js +0 -0
  1112. /package/{dist-esm/src → dist/browser}/util/processUtils.js +0 -0
  1113. /package/{dist-esm/src → dist/browser}/util/processUtils.js.map +0 -0
  1114. /package/{dist-esm/src → dist/esm}/msal/msal.js +0 -0
  1115. /package/{dist-esm/src → dist/esm}/msal/msal.js.map +0 -0
package/dist/index.js DELETED
@@ -1,4211 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var logger$m = require('@azure/logger');
6
- var coreClient = require('@azure/core-client');
7
- var coreUtil = require('@azure/core-util');
8
- var coreRestPipeline = require('@azure/core-rest-pipeline');
9
- var coreTracing = require('@azure/core-tracing');
10
- var fs = require('fs');
11
- var os = require('os');
12
- var path = require('path');
13
- var abortController = require('@azure/abort-controller');
14
- var msalCommon = require('@azure/msal-node');
15
- var open = require('open');
16
- var promises = require('fs/promises');
17
- var child_process = require('child_process');
18
- var crypto = require('crypto');
19
- var node_crypto = require('node:crypto');
20
- var promises$1 = require('node:fs/promises');
21
-
22
- function _interopNamespaceDefault(e) {
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- if (k !== 'default') {
27
- var d = Object.getOwnPropertyDescriptor(e, k);
28
- Object.defineProperty(n, k, d.get ? d : {
29
- enumerable: true,
30
- get: function () { return e[k]; }
31
- });
32
- }
33
- });
34
- }
35
- n.default = e;
36
- return Object.freeze(n);
37
- }
38
-
39
- var msalCommon__namespace = /*#__PURE__*/_interopNamespaceDefault(msalCommon);
40
- var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_process);
41
-
42
- // Copyright (c) Microsoft Corporation.
43
- // Licensed under the MIT License.
44
- /**
45
- * Current version of the `@azure/identity` package.
46
- */
47
- const SDK_VERSION = `4.6.0`;
48
- /**
49
- * The default client ID for authentication
50
- * @internal
51
- */
52
- // TODO: temporary - this is the Azure CLI clientID - we'll replace it when
53
- // Developer Sign On application is available
54
- // https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9
55
- const DeveloperSignOnClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
56
- /**
57
- * The default tenant for authentication
58
- * @internal
59
- */
60
- const DefaultTenantId = "common";
61
- /**
62
- * A list of known Azure authority hosts
63
- */
64
- exports.AzureAuthorityHosts = void 0;
65
- (function (AzureAuthorityHosts) {
66
- /**
67
- * China-based Azure Authority Host
68
- */
69
- AzureAuthorityHosts["AzureChina"] = "https://login.chinacloudapi.cn";
70
- /**
71
- * Germany-based Azure Authority Host
72
- */
73
- AzureAuthorityHosts["AzureGermany"] = "https://login.microsoftonline.de";
74
- /**
75
- * US Government Azure Authority Host
76
- */
77
- AzureAuthorityHosts["AzureGovernment"] = "https://login.microsoftonline.us";
78
- /**
79
- * Public Cloud Azure Authority Host
80
- */
81
- AzureAuthorityHosts["AzurePublicCloud"] = "https://login.microsoftonline.com";
82
- })(exports.AzureAuthorityHosts || (exports.AzureAuthorityHosts = {}));
83
- /**
84
- * @internal
85
- * The default authority host.
86
- */
87
- const DefaultAuthorityHost = exports.AzureAuthorityHosts.AzurePublicCloud;
88
- /**
89
- * @internal
90
- * Allow acquiring tokens for any tenant for multi-tentant auth.
91
- */
92
- const ALL_TENANTS = ["*"];
93
- /**
94
- * @internal
95
- */
96
- const CACHE_CAE_SUFFIX = "cae";
97
- /**
98
- * @internal
99
- */
100
- const CACHE_NON_CAE_SUFFIX = "nocae";
101
- /**
102
- * @internal
103
- *
104
- * The default name for the cache persistence plugin.
105
- * Matches the constant defined in the cache persistence package.
106
- */
107
- const DEFAULT_TOKEN_CACHE_NAME = "msal.cache";
108
-
109
- // Copyright (c) Microsoft Corporation.
110
- // Licensed under the MIT License.
111
- /**
112
- * The current persistence provider, undefined by default.
113
- * @internal
114
- */
115
- let persistenceProvider = undefined;
116
- /**
117
- * An object that allows setting the persistence provider.
118
- * @internal
119
- */
120
- const msalNodeFlowCacheControl = {
121
- setPersistence(pluginProvider) {
122
- persistenceProvider = pluginProvider;
123
- },
124
- };
125
- /**
126
- * The current native broker provider, undefined by default.
127
- * @internal
128
- */
129
- let nativeBrokerInfo = undefined;
130
- /**
131
- * An object that allows setting the native broker provider.
132
- * @internal
133
- */
134
- const msalNodeFlowNativeBrokerControl = {
135
- setNativeBroker(broker) {
136
- nativeBrokerInfo = {
137
- broker,
138
- };
139
- },
140
- };
141
- /**
142
- * Configures plugins, validating that required plugins are available and enabled.
143
- *
144
- * Does not create the plugins themselves, but rather returns the configuration that will be used to create them.
145
- *
146
- * @param options - options for creating the MSAL client
147
- * @returns plugin configuration
148
- */
149
- function generatePluginConfiguration(options) {
150
- var _a, _b, _c, _d, _e, _f, _g;
151
- const config = {
152
- cache: {},
153
- broker: {
154
- isEnabled: (_b = (_a = options.brokerOptions) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false,
155
- enableMsaPassthrough: (_d = (_c = options.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough) !== null && _d !== void 0 ? _d : false,
156
- parentWindowHandle: (_e = options.brokerOptions) === null || _e === void 0 ? void 0 : _e.parentWindowHandle,
157
- },
158
- };
159
- if ((_f = options.tokenCachePersistenceOptions) === null || _f === void 0 ? void 0 : _f.enabled) {
160
- if (persistenceProvider === undefined) {
161
- throw new Error([
162
- "Persistent token caching was requested, but no persistence provider was configured.",
163
- "You must install the identity-cache-persistence plugin package (`npm install --save @azure/identity-cache-persistence`)",
164
- "and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
165
- "`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`.",
166
- ].join(" "));
167
- }
168
- const cacheBaseName = options.tokenCachePersistenceOptions.name || DEFAULT_TOKEN_CACHE_NAME;
169
- config.cache.cachePlugin = persistenceProvider(Object.assign({ name: `${cacheBaseName}.${CACHE_NON_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions));
170
- config.cache.cachePluginCae = persistenceProvider(Object.assign({ name: `${cacheBaseName}.${CACHE_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions));
171
- }
172
- if ((_g = options.brokerOptions) === null || _g === void 0 ? void 0 : _g.enabled) {
173
- if (nativeBrokerInfo === undefined) {
174
- throw new Error([
175
- "Broker for WAM was requested to be enabled, but no native broker was configured.",
176
- "You must install the identity-broker plugin package (`npm install --save @azure/identity-broker`)",
177
- "and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
178
- "`useIdentityPlugin(createNativeBrokerPlugin())` before using `enableBroker`.",
179
- ].join(" "));
180
- }
181
- config.broker.nativeBrokerPlugin = nativeBrokerInfo.broker;
182
- }
183
- return config;
184
- }
185
- /**
186
- * Wraps generatePluginConfiguration as a writeable property for test stubbing purposes.
187
- */
188
- const msalPlugins = {
189
- generatePluginConfiguration,
190
- };
191
-
192
- // Copyright (c) Microsoft Corporation.
193
- // Licensed under the MIT License.
194
- /**
195
- * The AzureLogger used for all clients within the identity package
196
- */
197
- const logger$l = logger$m.createClientLogger("identity");
198
- /**
199
- * Separates a list of environment variable names into a plain object with two arrays: an array of missing environment variables and another array with assigned environment variables.
200
- * @param supportedEnvVars - List of environment variable names
201
- */
202
- function processEnvVars(supportedEnvVars) {
203
- return supportedEnvVars.reduce((acc, envVariable) => {
204
- if (process.env[envVariable]) {
205
- acc.assigned.push(envVariable);
206
- }
207
- else {
208
- acc.missing.push(envVariable);
209
- }
210
- return acc;
211
- }, { missing: [], assigned: [] });
212
- }
213
- /**
214
- * Formatting the success event on the credentials
215
- */
216
- function formatSuccess(scope) {
217
- return `SUCCESS. Scopes: ${Array.isArray(scope) ? scope.join(", ") : scope}.`;
218
- }
219
- /**
220
- * Formatting the success event on the credentials
221
- */
222
- function formatError(scope, error) {
223
- let message = "ERROR.";
224
- if (scope === null || scope === void 0 ? void 0 : scope.length) {
225
- message += ` Scopes: ${Array.isArray(scope) ? scope.join(", ") : scope}.`;
226
- }
227
- return `${message} Error message: ${typeof error === "string" ? error : error.message}.`;
228
- }
229
- /**
230
- * Generates a CredentialLoggerInstance.
231
- *
232
- * It logs with the format:
233
- *
234
- * `[title] => [message]`
235
- *
236
- */
237
- function credentialLoggerInstance(title, parent, log = logger$l) {
238
- const fullTitle = parent ? `${parent.fullTitle} ${title}` : title;
239
- function info(message) {
240
- log.info(`${fullTitle} =>`, message);
241
- }
242
- function warning(message) {
243
- log.warning(`${fullTitle} =>`, message);
244
- }
245
- function verbose(message) {
246
- log.verbose(`${fullTitle} =>`, message);
247
- }
248
- function error(message) {
249
- log.error(`${fullTitle} =>`, message);
250
- }
251
- return {
252
- title,
253
- fullTitle,
254
- info,
255
- warning,
256
- verbose,
257
- error,
258
- };
259
- }
260
- /**
261
- * Generates a CredentialLogger, which is a logger declared at the credential's constructor, and used at any point in the credential.
262
- * It has all the properties of a CredentialLoggerInstance, plus other logger instances, one per method.
263
- *
264
- * It logs with the format:
265
- *
266
- * `[title] => [message]`
267
- * `[title] => getToken() => [message]`
268
- *
269
- */
270
- function credentialLogger(title, log = logger$l) {
271
- const credLogger = credentialLoggerInstance(title, undefined, log);
272
- return Object.assign(Object.assign({}, credLogger), { parent: log, getToken: credentialLoggerInstance("=> getToken()", credLogger, log) });
273
- }
274
-
275
- // Copyright (c) Microsoft Corporation.
276
- // Licensed under the MIT License.
277
- function isErrorResponse(errorResponse) {
278
- return (errorResponse &&
279
- typeof errorResponse.error === "string" &&
280
- typeof errorResponse.error_description === "string");
281
- }
282
- /**
283
- * The Error.name value of an CredentialUnavailable
284
- */
285
- const CredentialUnavailableErrorName = "CredentialUnavailableError";
286
- /**
287
- * This signifies that the credential that was tried in a chained credential
288
- * was not available to be used as the credential. Rather than treating this as
289
- * an error that should halt the chain, it's caught and the chain continues
290
- */
291
- class CredentialUnavailableError extends Error {
292
- constructor(message, options) {
293
- // @ts-expect-error - TypeScript does not recognize this until we use ES2022 as the target; however, all our major runtimes do support the `cause` property
294
- super(message, options);
295
- this.name = CredentialUnavailableErrorName;
296
- }
297
- }
298
- /**
299
- * The Error.name value of an AuthenticationError
300
- */
301
- const AuthenticationErrorName = "AuthenticationError";
302
- /**
303
- * Provides details about a failure to authenticate with Azure Active
304
- * Directory. The `errorResponse` field contains more details about
305
- * the specific failure.
306
- */
307
- class AuthenticationError extends Error {
308
- constructor(statusCode, errorBody, options) {
309
- let errorResponse = {
310
- error: "unknown",
311
- errorDescription: "An unknown error occurred and no additional details are available.",
312
- };
313
- if (isErrorResponse(errorBody)) {
314
- errorResponse = convertOAuthErrorResponseToErrorResponse(errorBody);
315
- }
316
- else if (typeof errorBody === "string") {
317
- try {
318
- // Most error responses will contain JSON-formatted error details
319
- // in the response body
320
- const oauthErrorResponse = JSON.parse(errorBody);
321
- errorResponse = convertOAuthErrorResponseToErrorResponse(oauthErrorResponse);
322
- }
323
- catch (e) {
324
- if (statusCode === 400) {
325
- errorResponse = {
326
- error: "invalid_request",
327
- errorDescription: `The service indicated that the request was invalid.\n\n${errorBody}`,
328
- };
329
- }
330
- else {
331
- errorResponse = {
332
- error: "unknown_error",
333
- errorDescription: `An unknown error has occurred. Response body:\n\n${errorBody}`,
334
- };
335
- }
336
- }
337
- }
338
- else {
339
- errorResponse = {
340
- error: "unknown_error",
341
- errorDescription: "An unknown error occurred and no additional details are available.",
342
- };
343
- }
344
- super(`${errorResponse.error} Status code: ${statusCode}\nMore details:\n${errorResponse.errorDescription},`,
345
- // @ts-expect-error - TypeScript does not recognize this until we use ES2022 as the target; however, all our major runtimes do support the `cause` property
346
- options);
347
- this.statusCode = statusCode;
348
- this.errorResponse = errorResponse;
349
- // Ensure that this type reports the correct name
350
- this.name = AuthenticationErrorName;
351
- }
352
- }
353
- /**
354
- * The Error.name value of an AggregateAuthenticationError
355
- */
356
- const AggregateAuthenticationErrorName = "AggregateAuthenticationError";
357
- /**
358
- * Provides an `errors` array containing {@link AuthenticationError} instance
359
- * for authentication failures from credentials in a {@link ChainedTokenCredential}.
360
- */
361
- class AggregateAuthenticationError extends Error {
362
- constructor(errors, errorMessage) {
363
- const errorDetail = errors.join("\n");
364
- super(`${errorMessage}\n${errorDetail}`);
365
- this.errors = errors;
366
- // Ensure that this type reports the correct name
367
- this.name = AggregateAuthenticationErrorName;
368
- }
369
- }
370
- function convertOAuthErrorResponseToErrorResponse(errorBody) {
371
- return {
372
- error: errorBody.error,
373
- errorDescription: errorBody.error_description,
374
- correlationId: errorBody.correlation_id,
375
- errorCodes: errorBody.error_codes,
376
- timestamp: errorBody.timestamp,
377
- traceId: errorBody.trace_id,
378
- };
379
- }
380
- /**
381
- * Error used to enforce authentication after trying to retrieve a token silently.
382
- */
383
- class AuthenticationRequiredError extends Error {
384
- constructor(
385
- /**
386
- * Optional parameters. A message can be specified. The {@link GetTokenOptions} of the request can also be specified to more easily associate the error with the received parameters.
387
- */
388
- options) {
389
- super(options.message,
390
- // @ts-expect-error - TypeScript does not recognize this until we use ES2022 as the target; however, all our major runtimes do support the `cause` property
391
- options.cause ? { cause: options.cause } : undefined);
392
- this.scopes = options.scopes;
393
- this.getTokenOptions = options.getTokenOptions;
394
- this.name = "AuthenticationRequiredError";
395
- }
396
- }
397
-
398
- // Copyright (c) Microsoft Corporation.
399
- // Licensed under the MIT License.
400
- function createConfigurationErrorMessage(tenantId) {
401
- return `The current credential is not configured to acquire tokens for tenant ${tenantId}. To enable acquiring tokens for this tenant add it to the AdditionallyAllowedTenants on the credential options, or add "*" to AdditionallyAllowedTenants to allow acquiring tokens for any tenant.`;
402
- }
403
- /**
404
- * Of getToken contains a tenantId, this functions allows picking this tenantId as the appropriate for authentication,
405
- * unless multitenant authentication has been disabled through the AZURE_IDENTITY_DISABLE_MULTITENANTAUTH (on Node.js),
406
- * or unless the original tenant Id is `adfs`.
407
- * @internal
408
- */
409
- function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowedTenantIds = [], logger) {
410
- var _a;
411
- let resolvedTenantId;
412
- if (process.env.AZURE_IDENTITY_DISABLE_MULTITENANTAUTH) {
413
- resolvedTenantId = tenantId;
414
- }
415
- else if (tenantId === "adfs") {
416
- resolvedTenantId = tenantId;
417
- }
418
- else {
419
- resolvedTenantId = (_a = getTokenOptions === null || getTokenOptions === void 0 ? void 0 : getTokenOptions.tenantId) !== null && _a !== void 0 ? _a : tenantId;
420
- }
421
- if (tenantId &&
422
- resolvedTenantId !== tenantId &&
423
- !additionallyAllowedTenantIds.includes("*") &&
424
- !additionallyAllowedTenantIds.some((t) => t.localeCompare(resolvedTenantId) === 0)) {
425
- const message = createConfigurationErrorMessage(tenantId);
426
- logger === null || logger === void 0 ? void 0 : logger.info(message);
427
- throw new CredentialUnavailableError(message);
428
- }
429
- return resolvedTenantId;
430
- }
431
-
432
- // Copyright (c) Microsoft Corporation.
433
- // Licensed under the MIT License.
434
- /**
435
- * @internal
436
- */
437
- function checkTenantId(logger, tenantId) {
438
- if (!tenantId.match(/^[0-9a-zA-Z-.]+$/)) {
439
- const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://learn.microsoft.com/partner-center/find-ids-and-domain-names.");
440
- logger.info(formatError("", error));
441
- throw error;
442
- }
443
- }
444
- /**
445
- * @internal
446
- */
447
- function resolveTenantId(logger, tenantId, clientId) {
448
- if (tenantId) {
449
- checkTenantId(logger, tenantId);
450
- return tenantId;
451
- }
452
- if (!clientId) {
453
- clientId = DeveloperSignOnClientId;
454
- }
455
- if (clientId !== DeveloperSignOnClientId) {
456
- return "common";
457
- }
458
- return "organizations";
459
- }
460
- /**
461
- * @internal
462
- */
463
- function resolveAdditionallyAllowedTenantIds(additionallyAllowedTenants) {
464
- if (!additionallyAllowedTenants || additionallyAllowedTenants.length === 0) {
465
- return [];
466
- }
467
- if (additionallyAllowedTenants.includes("*")) {
468
- return ALL_TENANTS;
469
- }
470
- return additionallyAllowedTenants;
471
- }
472
-
473
- // Copyright (c) Microsoft Corporation.
474
- // Licensed under the MIT License.
475
- function getIdentityTokenEndpointSuffix(tenantId) {
476
- if (tenantId === "adfs") {
477
- return "oauth2/token";
478
- }
479
- else {
480
- return "oauth2/v2.0/token";
481
- }
482
- }
483
-
484
- // Copyright (c) Microsoft Corporation.
485
- // Licensed under the MIT License.
486
- /**
487
- * Creates a span using the global tracer.
488
- * @internal
489
- */
490
- const tracingClient = coreTracing.createTracingClient({
491
- namespace: "Microsoft.AAD",
492
- packageName: "@azure/identity",
493
- packageVersion: SDK_VERSION,
494
- });
495
-
496
- // Copyright (c) Microsoft Corporation.
497
- // Licensed under the MIT License.
498
- const DefaultScopeSuffix = "/.default";
499
- const imdsHost = "http://169.254.169.254";
500
- const imdsEndpointPath = "/metadata/identity/oauth2/token";
501
- const imdsApiVersion = "2018-02-01";
502
-
503
- // Copyright (c) Microsoft Corporation.
504
- // Licensed under the MIT License.
505
- /**
506
- * Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
507
- * These are GET requests that require sending a `resource` parameter on the query.
508
- * This resource can be derived from the scopes received through the getToken call, as long as only one scope is received.
509
- * Multiple scopes assume that the resulting token will have access to multiple resources, which won't be the case.
510
- *
511
- * For that reason, when we encounter multiple scopes, we return undefined.
512
- * It's up to the individual MSI implementations to throw the errors (which helps us provide less generic errors).
513
- */
514
- function mapScopesToResource(scopes) {
515
- let scope = "";
516
- if (Array.isArray(scopes)) {
517
- if (scopes.length !== 1) {
518
- return;
519
- }
520
- scope = scopes[0];
521
- }
522
- else if (typeof scopes === "string") {
523
- scope = scopes;
524
- }
525
- if (!scope.endsWith(DefaultScopeSuffix)) {
526
- return scope;
527
- }
528
- return scope.substr(0, scope.lastIndexOf(DefaultScopeSuffix));
529
- }
530
- /**
531
- * Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.
532
- * @param body - A parsed response body from the authentication endpoint.
533
- */
534
- function parseExpirationTimestamp(body) {
535
- if (typeof body.expires_on === "number") {
536
- return body.expires_on * 1000;
537
- }
538
- if (typeof body.expires_on === "string") {
539
- const asNumber = +body.expires_on;
540
- if (!isNaN(asNumber)) {
541
- return asNumber * 1000;
542
- }
543
- const asDate = Date.parse(body.expires_on);
544
- if (!isNaN(asDate)) {
545
- return asDate;
546
- }
547
- }
548
- if (typeof body.expires_in === "number") {
549
- return Date.now() + body.expires_in * 1000;
550
- }
551
- throw new Error(`Failed to parse token expiration from body. expires_in="${body.expires_in}", expires_on="${body.expires_on}"`);
552
- }
553
- /**
554
- * Given a token response, return the expiration timestamp as the number of milliseconds from the Unix epoch.
555
- * @param body - A parsed response body from the authentication endpoint.
556
- */
557
- function parseRefreshTimestamp(body) {
558
- if (body.refresh_on) {
559
- if (typeof body.refresh_on === "number") {
560
- return body.refresh_on * 1000;
561
- }
562
- if (typeof body.refresh_on === "string") {
563
- const asNumber = +body.refresh_on;
564
- if (!isNaN(asNumber)) {
565
- return asNumber * 1000;
566
- }
567
- const asDate = Date.parse(body.refresh_on);
568
- if (!isNaN(asDate)) {
569
- return asDate;
570
- }
571
- }
572
- throw new Error(`Failed to parse refresh_on from body. refresh_on="${body.refresh_on}"`);
573
- }
574
- else {
575
- return undefined;
576
- }
577
- }
578
-
579
- // Copyright (c) Microsoft Corporation.
580
- // Licensed under the MIT License.
581
- const noCorrelationId = "noCorrelationId";
582
- /**
583
- * @internal
584
- */
585
- function getIdentityClientAuthorityHost(options) {
586
- // The authorityHost can come from options or from the AZURE_AUTHORITY_HOST environment variable.
587
- let authorityHost = options === null || options === void 0 ? void 0 : options.authorityHost;
588
- // The AZURE_AUTHORITY_HOST environment variable can only be provided in Node.js.
589
- if (coreUtil.isNode) {
590
- authorityHost = authorityHost !== null && authorityHost !== void 0 ? authorityHost : process.env.AZURE_AUTHORITY_HOST;
591
- }
592
- // If the authorityHost is not provided, we use the default one from the public cloud: https://login.microsoftonline.com
593
- return authorityHost !== null && authorityHost !== void 0 ? authorityHost : DefaultAuthorityHost;
594
- }
595
- /**
596
- * The network module used by the Identity credentials.
597
- *
598
- * It allows for credentials to abort any pending request independently of the MSAL flow,
599
- * by calling to the `abortRequests()` method.
600
- *
601
- */
602
- class IdentityClient extends coreClient.ServiceClient {
603
- constructor(options) {
604
- var _a, _b;
605
- const packageDetails = `azsdk-js-identity/${SDK_VERSION}`;
606
- const userAgentPrefix = ((_a = options === null || options === void 0 ? void 0 : options.userAgentOptions) === null || _a === void 0 ? void 0 : _a.userAgentPrefix)
607
- ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
608
- : `${packageDetails}`;
609
- const baseUri = getIdentityClientAuthorityHost(options);
610
- if (!baseUri.startsWith("https:")) {
611
- throw new Error("The authorityHost address must use the 'https' protocol.");
612
- }
613
- super(Object.assign(Object.assign({ requestContentType: "application/json; charset=utf-8", retryOptions: {
614
- maxRetries: 3,
615
- } }, options), { userAgentOptions: {
616
- userAgentPrefix,
617
- }, baseUri }));
618
- this.allowInsecureConnection = false;
619
- this.authorityHost = baseUri;
620
- this.abortControllers = new Map();
621
- this.allowLoggingAccountIdentifiers = (_b = options === null || options === void 0 ? void 0 : options.loggingOptions) === null || _b === void 0 ? void 0 : _b.allowLoggingAccountIdentifiers;
622
- // used for WorkloadIdentity
623
- this.tokenCredentialOptions = Object.assign({}, options);
624
- // used for ManagedIdentity
625
- if (options === null || options === void 0 ? void 0 : options.allowInsecureConnection) {
626
- this.allowInsecureConnection = options.allowInsecureConnection;
627
- }
628
- }
629
- async sendTokenRequest(request) {
630
- logger$l.info(`IdentityClient: sending token request to [${request.url}]`);
631
- const response = await this.sendRequest(request);
632
- if (response.bodyAsText && (response.status === 200 || response.status === 201)) {
633
- const parsedBody = JSON.parse(response.bodyAsText);
634
- if (!parsedBody.access_token) {
635
- return null;
636
- }
637
- this.logIdentifiers(response);
638
- const token = {
639
- accessToken: {
640
- token: parsedBody.access_token,
641
- expiresOnTimestamp: parseExpirationTimestamp(parsedBody),
642
- refreshAfterTimestamp: parseRefreshTimestamp(parsedBody),
643
- tokenType: "Bearer",
644
- },
645
- refreshToken: parsedBody.refresh_token,
646
- };
647
- logger$l.info(`IdentityClient: [${request.url}] token acquired, expires on ${token.accessToken.expiresOnTimestamp}`);
648
- return token;
649
- }
650
- else {
651
- const error = new AuthenticationError(response.status, response.bodyAsText);
652
- logger$l.warning(`IdentityClient: authentication error. HTTP status: ${response.status}, ${error.errorResponse.errorDescription}`);
653
- throw error;
654
- }
655
- }
656
- async refreshAccessToken(tenantId, clientId, scopes, refreshToken, clientSecret, options = {}) {
657
- if (refreshToken === undefined) {
658
- return null;
659
- }
660
- logger$l.info(`IdentityClient: refreshing access token with client ID: ${clientId}, scopes: ${scopes} started`);
661
- const refreshParams = {
662
- grant_type: "refresh_token",
663
- client_id: clientId,
664
- refresh_token: refreshToken,
665
- scope: scopes,
666
- };
667
- if (clientSecret !== undefined) {
668
- refreshParams.client_secret = clientSecret;
669
- }
670
- const query = new URLSearchParams(refreshParams);
671
- return tracingClient.withSpan("IdentityClient.refreshAccessToken", options, async (updatedOptions) => {
672
- try {
673
- const urlSuffix = getIdentityTokenEndpointSuffix(tenantId);
674
- const request = coreRestPipeline.createPipelineRequest({
675
- url: `${this.authorityHost}/${tenantId}/${urlSuffix}`,
676
- method: "POST",
677
- body: query.toString(),
678
- abortSignal: options.abortSignal,
679
- headers: coreRestPipeline.createHttpHeaders({
680
- Accept: "application/json",
681
- "Content-Type": "application/x-www-form-urlencoded",
682
- }),
683
- tracingOptions: updatedOptions.tracingOptions,
684
- });
685
- const response = await this.sendTokenRequest(request);
686
- logger$l.info(`IdentityClient: refreshed token for client ID: ${clientId}`);
687
- return response;
688
- }
689
- catch (err) {
690
- if (err.name === AuthenticationErrorName &&
691
- err.errorResponse.error === "interaction_required") {
692
- // It's likely that the refresh token has expired, so
693
- // return null so that the credential implementation will
694
- // initiate the authentication flow again.
695
- logger$l.info(`IdentityClient: interaction required for client ID: ${clientId}`);
696
- return null;
697
- }
698
- else {
699
- logger$l.warning(`IdentityClient: failed refreshing token for client ID: ${clientId}: ${err}`);
700
- throw err;
701
- }
702
- }
703
- });
704
- }
705
- // Here is a custom layer that allows us to abort requests that go through MSAL,
706
- // since MSAL doesn't allow us to pass options all the way through.
707
- generateAbortSignal(correlationId) {
708
- const controller = new AbortController();
709
- const controllers = this.abortControllers.get(correlationId) || [];
710
- controllers.push(controller);
711
- this.abortControllers.set(correlationId, controllers);
712
- const existingOnAbort = controller.signal.onabort;
713
- controller.signal.onabort = (...params) => {
714
- this.abortControllers.set(correlationId, undefined);
715
- if (existingOnAbort) {
716
- existingOnAbort.apply(controller.signal, params);
717
- }
718
- };
719
- return controller.signal;
720
- }
721
- abortRequests(correlationId) {
722
- const key = correlationId || noCorrelationId;
723
- const controllers = [
724
- ...(this.abortControllers.get(key) || []),
725
- // MSAL passes no correlation ID to the get requests...
726
- ...(this.abortControllers.get(noCorrelationId) || []),
727
- ];
728
- if (!controllers.length) {
729
- return;
730
- }
731
- for (const controller of controllers) {
732
- controller.abort();
733
- }
734
- this.abortControllers.set(key, undefined);
735
- }
736
- getCorrelationId(options) {
737
- var _a;
738
- const parameter = (_a = options === null || options === void 0 ? void 0 : options.body) === null || _a === void 0 ? void 0 : _a.split("&").map((part) => part.split("=")).find(([key]) => key === "client-request-id");
739
- return parameter && parameter.length ? parameter[1] || noCorrelationId : noCorrelationId;
740
- }
741
- // The MSAL network module methods follow
742
- async sendGetRequestAsync(url, options) {
743
- const request = coreRestPipeline.createPipelineRequest({
744
- url,
745
- method: "GET",
746
- body: options === null || options === void 0 ? void 0 : options.body,
747
- allowInsecureConnection: this.allowInsecureConnection,
748
- headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
749
- abortSignal: this.generateAbortSignal(noCorrelationId),
750
- });
751
- const response = await this.sendRequest(request);
752
- this.logIdentifiers(response);
753
- return {
754
- body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
755
- headers: response.headers.toJSON(),
756
- status: response.status,
757
- };
758
- }
759
- async sendPostRequestAsync(url, options) {
760
- const request = coreRestPipeline.createPipelineRequest({
761
- url,
762
- method: "POST",
763
- body: options === null || options === void 0 ? void 0 : options.body,
764
- headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
765
- allowInsecureConnection: this.allowInsecureConnection,
766
- // MSAL doesn't send the correlation ID on the get requests.
767
- abortSignal: this.generateAbortSignal(this.getCorrelationId(options)),
768
- });
769
- const response = await this.sendRequest(request);
770
- this.logIdentifiers(response);
771
- return {
772
- body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
773
- headers: response.headers.toJSON(),
774
- status: response.status,
775
- };
776
- }
777
- /**
778
- *
779
- * @internal
780
- */
781
- getTokenCredentialOptions() {
782
- return this.tokenCredentialOptions;
783
- }
784
- /**
785
- * If allowLoggingAccountIdentifiers was set on the constructor options
786
- * we try to log the account identifiers by parsing the received access token.
787
- *
788
- * The account identifiers we try to log are:
789
- * - `appid`: The application or Client Identifier.
790
- * - `upn`: User Principal Name.
791
- * - It might not be available in some authentication scenarios.
792
- * - If it's not available, we put a placeholder: "No User Principal Name available".
793
- * - `tid`: Tenant Identifier.
794
- * - `oid`: Object Identifier of the authenticated user.
795
- */
796
- logIdentifiers(response) {
797
- if (!this.allowLoggingAccountIdentifiers || !response.bodyAsText) {
798
- return;
799
- }
800
- const unavailableUpn = "No User Principal Name available";
801
- try {
802
- const parsed = response.parsedBody || JSON.parse(response.bodyAsText);
803
- const accessToken = parsed.access_token;
804
- if (!accessToken) {
805
- // Without an access token allowLoggingAccountIdentifiers isn't useful.
806
- return;
807
- }
808
- const base64Metadata = accessToken.split(".")[1];
809
- const { appid, upn, tid, oid } = JSON.parse(Buffer.from(base64Metadata, "base64").toString("utf8"));
810
- logger$l.info(`[Authenticated account] Client ID: ${appid}. Tenant ID: ${tid}. User Principal Name: ${upn || unavailableUpn}. Object ID (user): ${oid}`);
811
- }
812
- catch (e) {
813
- logger$l.warning("allowLoggingAccountIdentifiers was set, but we couldn't log the account information. Error:", e.message);
814
- }
815
- }
816
- }
817
-
818
- // Copyright (c) Microsoft Corporation.
819
- // Licensed under the MIT License.
820
- const CommonTenantId = "common";
821
- const AzureAccountClientId = "aebc6443-996d-45c2-90f0-388ff96faa56"; // VSC: 'aebc6443-996d-45c2-90f0-388ff96faa56'
822
- const logger$k = credentialLogger("VisualStudioCodeCredential");
823
- let findCredentials = undefined;
824
- const vsCodeCredentialControl = {
825
- setVsCodeCredentialFinder(finder) {
826
- findCredentials = finder;
827
- },
828
- };
829
- // Map of unsupported Tenant IDs and the errors we will be throwing.
830
- const unsupportedTenantIds = {
831
- adfs: "The VisualStudioCodeCredential does not support authentication with ADFS tenants.",
832
- };
833
- function checkUnsupportedTenant(tenantId) {
834
- // If the Tenant ID isn't supported, we throw.
835
- const unsupportedTenantError = unsupportedTenantIds[tenantId];
836
- if (unsupportedTenantError) {
837
- throw new CredentialUnavailableError(unsupportedTenantError);
838
- }
839
- }
840
- const mapVSCodeAuthorityHosts = {
841
- AzureCloud: exports.AzureAuthorityHosts.AzurePublicCloud,
842
- AzureChina: exports.AzureAuthorityHosts.AzureChina,
843
- AzureGermanCloud: exports.AzureAuthorityHosts.AzureGermany,
844
- AzureUSGovernment: exports.AzureAuthorityHosts.AzureGovernment,
845
- };
846
- /**
847
- * Attempts to load a specific property from the VSCode configurations of the current OS.
848
- * If it fails at any point, returns undefined.
849
- */
850
- function getPropertyFromVSCode(property) {
851
- const settingsPath = ["User", "settings.json"];
852
- // Eventually we can add more folders for more versions of VSCode.
853
- const vsCodeFolder = "Code";
854
- const homedir = os.homedir();
855
- function loadProperty(...pathSegments) {
856
- const fullPath = path.join(...pathSegments, vsCodeFolder, ...settingsPath);
857
- const settings = JSON.parse(fs.readFileSync(fullPath, { encoding: "utf8" }));
858
- return settings[property];
859
- }
860
- try {
861
- let appData;
862
- switch (process.platform) {
863
- case "win32":
864
- appData = process.env.APPDATA;
865
- return appData ? loadProperty(appData) : undefined;
866
- case "darwin":
867
- return loadProperty(homedir, "Library", "Application Support");
868
- case "linux":
869
- return loadProperty(homedir, ".config");
870
- default:
871
- return;
872
- }
873
- }
874
- catch (e) {
875
- logger$k.info(`Failed to load the Visual Studio Code configuration file. Error: ${e.message}`);
876
- return;
877
- }
878
- }
879
- /**
880
- * Connects to Azure using the credential provided by the VSCode extension 'Azure Account'.
881
- * Once the user has logged in via the extension, this credential can share the same refresh token
882
- * that is cached by the extension.
883
- *
884
- * It's a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500) that this credential doesn't
885
- * work with [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account)
886
- * versions newer than **0.9.11**. A long-term fix to this problem is in progress. In the meantime, consider
887
- * authenticating with {@link AzureCliCredential}.
888
- */
889
- class VisualStudioCodeCredential {
890
- /**
891
- * Creates an instance of VisualStudioCodeCredential to use for automatically authenticating via VSCode.
892
- *
893
- * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
894
- * `@azure/identity-vscode`. If this package is not installed and registered
895
- * using the plugin API (`useIdentityPlugin`), then authentication using
896
- * `VisualStudioCodeCredential` will not be available.
897
- *
898
- * @param options - Options for configuring the client which makes the authentication request.
899
- */
900
- constructor(options) {
901
- // We want to make sure we use the one assigned by the user on the VSCode settings.
902
- // Or just `AzureCloud` by default.
903
- this.cloudName = (getPropertyFromVSCode("azure.cloud") || "AzureCloud");
904
- // Picking an authority host based on the cloud name.
905
- const authorityHost = mapVSCodeAuthorityHosts[this.cloudName];
906
- this.identityClient = new IdentityClient(Object.assign({ authorityHost }, options));
907
- if (options && options.tenantId) {
908
- checkTenantId(logger$k, options.tenantId);
909
- this.tenantId = options.tenantId;
910
- }
911
- else {
912
- this.tenantId = CommonTenantId;
913
- }
914
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
915
- checkUnsupportedTenant(this.tenantId);
916
- }
917
- /**
918
- * Runs preparations for any further getToken request.
919
- */
920
- async prepare() {
921
- // Attempts to load the tenant from the VSCode configuration file.
922
- const settingsTenant = getPropertyFromVSCode("azure.tenant");
923
- if (settingsTenant) {
924
- this.tenantId = settingsTenant;
925
- }
926
- checkUnsupportedTenant(this.tenantId);
927
- }
928
- /**
929
- * Runs preparations for any further getToken, but only once.
930
- */
931
- prepareOnce() {
932
- if (!this.preparePromise) {
933
- this.preparePromise = this.prepare();
934
- }
935
- return this.preparePromise;
936
- }
937
- /**
938
- * Returns the token found by searching VSCode's authentication cache or
939
- * returns null if no token could be found.
940
- *
941
- * @param scopes - The list of scopes for which the token will have access.
942
- * @param options - The options used to configure any requests this
943
- * `TokenCredential` implementation might make.
944
- */
945
- async getToken(scopes, options) {
946
- var _a, _b;
947
- await this.prepareOnce();
948
- const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds, logger$k) || this.tenantId;
949
- if (findCredentials === undefined) {
950
- throw new CredentialUnavailableError([
951
- "No implementation of `VisualStudioCodeCredential` is available.",
952
- "You must install the identity-vscode plugin package (`npm install --save-dev @azure/identity-vscode`)",
953
- "and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
954
- "`useIdentityPlugin(vsCodePlugin)` before creating a `VisualStudioCodeCredential`.",
955
- "To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.",
956
- ].join(" "));
957
- }
958
- let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
959
- // Check to make sure the scope we get back is a valid scope
960
- if (!scopeString.match(/^[0-9a-zA-Z-.:/]+$/)) {
961
- const error = new Error("Invalid scope was specified by the user or calling client");
962
- logger$k.getToken.info(formatError(scopes, error));
963
- throw error;
964
- }
965
- if (scopeString.indexOf("offline_access") < 0) {
966
- scopeString += " offline_access";
967
- }
968
- // findCredentials returns an array similar to:
969
- // [
970
- // {
971
- // account: "",
972
- // password: "",
973
- // },
974
- // /* ... */
975
- // ]
976
- const credentials = await findCredentials();
977
- // If we can't find the credential based on the name, we'll pick the first one available.
978
- const { password: refreshToken } = (_b = (_a = credentials.find(({ account }) => account === this.cloudName)) !== null && _a !== void 0 ? _a : credentials[0]) !== null && _b !== void 0 ? _b : {};
979
- if (refreshToken) {
980
- const tokenResponse = await this.identityClient.refreshAccessToken(tenantId, AzureAccountClientId, scopeString, refreshToken, undefined);
981
- if (tokenResponse) {
982
- logger$k.getToken.info(formatSuccess(scopes));
983
- return tokenResponse.accessToken;
984
- }
985
- else {
986
- const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Have you connected using the 'Azure Account' extension recently? To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.");
987
- logger$k.getToken.info(formatError(scopes, error));
988
- throw error;
989
- }
990
- }
991
- else {
992
- const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Did you connect using the 'Azure Account' extension? To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.");
993
- logger$k.getToken.info(formatError(scopes, error));
994
- throw error;
995
- }
996
- }
997
- }
998
-
999
- // Copyright (c) Microsoft Corporation.
1000
- // Licensed under the MIT License.
1001
- /**
1002
- * The context passed to an Identity plugin. This contains objects that
1003
- * plugins can use to set backend implementations.
1004
- * @internal
1005
- */
1006
- const pluginContext = {
1007
- cachePluginControl: msalNodeFlowCacheControl,
1008
- nativeBrokerPluginControl: msalNodeFlowNativeBrokerControl,
1009
- vsCodeCredentialControl: vsCodeCredentialControl,
1010
- };
1011
- /**
1012
- * Extend Azure Identity with additional functionality. Pass a plugin from
1013
- * a plugin package, such as:
1014
- *
1015
- * - `@azure/identity-cache-persistence`: provides persistent token caching
1016
- * - `@azure/identity-vscode`: provides the dependencies of
1017
- * `VisualStudioCodeCredential` and enables it
1018
- *
1019
- * Example:
1020
- *
1021
- * ```ts snippet:consumer_example
1022
- * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
1023
- *
1024
- * useIdentityPlugin(cachePersistencePlugin);
1025
- * // The plugin has the capability to extend `DeviceCodeCredential` and to
1026
- * // add middleware to the underlying credentials, such as persistence.
1027
- * const credential = new DeviceCodeCredential({
1028
- * tokenCachePersistenceOptions: {
1029
- * enabled: true,
1030
- * },
1031
- * });
1032
- * ```
1033
- *
1034
- * @param plugin - the plugin to register
1035
- */
1036
- function useIdentityPlugin(plugin) {
1037
- plugin(pluginContext);
1038
- }
1039
-
1040
- // Copyright (c) Microsoft Corporation.
1041
- // Licensed under the MIT License.
1042
- /**
1043
- * @internal
1044
- */
1045
- const logger$j = credentialLogger("IdentityUtils");
1046
- /**
1047
- * Latest AuthenticationRecord version
1048
- * @internal
1049
- */
1050
- const LatestAuthenticationRecordVersion = "1.0";
1051
- /**
1052
- * Ensures the validity of the MSAL token
1053
- * @internal
1054
- */
1055
- function ensureValidMsalToken(scopes, msalToken, getTokenOptions) {
1056
- const error = (message) => {
1057
- logger$j.getToken.info(message);
1058
- return new AuthenticationRequiredError({
1059
- scopes: Array.isArray(scopes) ? scopes : [scopes],
1060
- getTokenOptions,
1061
- message,
1062
- });
1063
- };
1064
- if (!msalToken) {
1065
- throw error("No response");
1066
- }
1067
- if (!msalToken.expiresOn) {
1068
- throw error(`Response had no "expiresOn" property.`);
1069
- }
1070
- if (!msalToken.accessToken) {
1071
- throw error(`Response had no "accessToken" property.`);
1072
- }
1073
- }
1074
- /**
1075
- * Returns the authority host from either the options bag or the AZURE_AUTHORITY_HOST environment variable.
1076
- *
1077
- * Defaults to {@link DefaultAuthorityHost}.
1078
- * @internal
1079
- */
1080
- function getAuthorityHost(options) {
1081
- let authorityHost = options === null || options === void 0 ? void 0 : options.authorityHost;
1082
- if (!authorityHost && coreUtil.isNodeLike) {
1083
- authorityHost = process.env.AZURE_AUTHORITY_HOST;
1084
- }
1085
- return authorityHost !== null && authorityHost !== void 0 ? authorityHost : DefaultAuthorityHost;
1086
- }
1087
- /**
1088
- * Generates a valid authority by combining a host with a tenantId.
1089
- * @internal
1090
- */
1091
- function getAuthority(tenantId, host) {
1092
- if (!host) {
1093
- host = DefaultAuthorityHost;
1094
- }
1095
- if (new RegExp(`${tenantId}/?$`).test(host)) {
1096
- return host;
1097
- }
1098
- if (host.endsWith("/")) {
1099
- return host + tenantId;
1100
- }
1101
- else {
1102
- return `${host}/${tenantId}`;
1103
- }
1104
- }
1105
- /**
1106
- * Generates the known authorities.
1107
- * If the Tenant Id is `adfs`, the authority can't be validated since the format won't match the expected one.
1108
- * For that reason, we have to force MSAL to disable validating the authority
1109
- * by sending it within the known authorities in the MSAL configuration.
1110
- * @internal
1111
- */
1112
- function getKnownAuthorities(tenantId, authorityHost, disableInstanceDiscovery) {
1113
- if ((tenantId === "adfs" && authorityHost) || disableInstanceDiscovery) {
1114
- return [authorityHost];
1115
- }
1116
- return [];
1117
- }
1118
- /**
1119
- * Generates a logger that can be passed to the MSAL clients.
1120
- * @param credLogger - The logger of the credential.
1121
- * @internal
1122
- */
1123
- const defaultLoggerCallback = (credLogger, platform = coreUtil.isNode ? "Node" : "Browser") => (level, message, containsPii) => {
1124
- if (containsPii) {
1125
- return;
1126
- }
1127
- switch (level) {
1128
- case msalCommon__namespace.LogLevel.Error:
1129
- credLogger.info(`MSAL ${platform} V2 error: ${message}`);
1130
- return;
1131
- case msalCommon__namespace.LogLevel.Info:
1132
- credLogger.info(`MSAL ${platform} V2 info message: ${message}`);
1133
- return;
1134
- case msalCommon__namespace.LogLevel.Verbose:
1135
- credLogger.info(`MSAL ${platform} V2 verbose message: ${message}`);
1136
- return;
1137
- case msalCommon__namespace.LogLevel.Warning:
1138
- credLogger.info(`MSAL ${platform} V2 warning: ${message}`);
1139
- return;
1140
- }
1141
- };
1142
- /**
1143
- * @internal
1144
- */
1145
- function getMSALLogLevel(logLevel) {
1146
- switch (logLevel) {
1147
- case "error":
1148
- return msalCommon__namespace.LogLevel.Error;
1149
- case "info":
1150
- return msalCommon__namespace.LogLevel.Info;
1151
- case "verbose":
1152
- return msalCommon__namespace.LogLevel.Verbose;
1153
- case "warning":
1154
- return msalCommon__namespace.LogLevel.Warning;
1155
- default:
1156
- // default msal logging level should be Info
1157
- return msalCommon__namespace.LogLevel.Info;
1158
- }
1159
- }
1160
- /**
1161
- * Handles MSAL errors.
1162
- */
1163
- function handleMsalError(scopes, error, getTokenOptions) {
1164
- if (error.name === "AuthError" ||
1165
- error.name === "ClientAuthError" ||
1166
- error.name === "BrowserAuthError") {
1167
- const msalError = error;
1168
- switch (msalError.errorCode) {
1169
- case "endpoints_resolution_error":
1170
- logger$j.info(formatError(scopes, error.message));
1171
- return new CredentialUnavailableError(error.message);
1172
- case "device_code_polling_cancelled":
1173
- return new abortController.AbortError("The authentication has been aborted by the caller.");
1174
- case "consent_required":
1175
- case "interaction_required":
1176
- case "login_required":
1177
- logger$j.info(formatError(scopes, `Authentication returned errorCode ${msalError.errorCode}`));
1178
- break;
1179
- default:
1180
- logger$j.info(formatError(scopes, `Failed to acquire token: ${error.message}`));
1181
- break;
1182
- }
1183
- }
1184
- if (error.name === "ClientConfigurationError" ||
1185
- error.name === "BrowserConfigurationAuthError" ||
1186
- error.name === "AbortError" ||
1187
- error.name === "AuthenticationError") {
1188
- return error;
1189
- }
1190
- if (error.name === "NativeAuthError") {
1191
- logger$j.info(formatError(scopes, `Error from the native broker: ${error.message} with status code: ${error.statusCode}`));
1192
- return error;
1193
- }
1194
- return new AuthenticationRequiredError({ scopes, getTokenOptions, message: error.message });
1195
- }
1196
- // transformations.ts
1197
- function publicToMsal(account) {
1198
- const [environment] = account.authority.match(/([a-z]*\.[a-z]*\.[a-z]*)/) || [""];
1199
- return Object.assign(Object.assign({}, account), { localAccountId: account.homeAccountId, environment });
1200
- }
1201
- function msalToPublic(clientId, account) {
1202
- const record = {
1203
- authority: getAuthority(account.tenantId, account.environment),
1204
- homeAccountId: account.homeAccountId,
1205
- tenantId: account.tenantId || DefaultTenantId,
1206
- username: account.username,
1207
- clientId,
1208
- version: LatestAuthenticationRecordVersion,
1209
- };
1210
- return record;
1211
- }
1212
- /**
1213
- * Serializes an `AuthenticationRecord` into a string.
1214
- *
1215
- * The output of a serialized authentication record will contain the following properties:
1216
- *
1217
- * - "authority"
1218
- * - "homeAccountId"
1219
- * - "clientId"
1220
- * - "tenantId"
1221
- * - "username"
1222
- * - "version"
1223
- *
1224
- * To later convert this string to a serialized `AuthenticationRecord`, please use the exported function `deserializeAuthenticationRecord()`.
1225
- */
1226
- function serializeAuthenticationRecord(record) {
1227
- return JSON.stringify(record);
1228
- }
1229
- /**
1230
- * Deserializes a previously serialized authentication record from a string into an object.
1231
- *
1232
- * The input string must contain the following properties:
1233
- *
1234
- * - "authority"
1235
- * - "homeAccountId"
1236
- * - "clientId"
1237
- * - "tenantId"
1238
- * - "username"
1239
- * - "version"
1240
- *
1241
- * If the version we receive is unsupported, an error will be thrown.
1242
- *
1243
- * At the moment, the only available version is: "1.0", which is always set when the authentication record is serialized.
1244
- *
1245
- * @param serializedRecord - Authentication record previously serialized into string.
1246
- * @returns AuthenticationRecord.
1247
- */
1248
- function deserializeAuthenticationRecord(serializedRecord) {
1249
- const parsed = JSON.parse(serializedRecord);
1250
- if (parsed.version && parsed.version !== LatestAuthenticationRecordVersion) {
1251
- throw Error("Unsupported AuthenticationRecord version");
1252
- }
1253
- return parsed;
1254
- }
1255
-
1256
- // Copyright (c) Microsoft Corporation.
1257
- // Licensed under the MIT License.
1258
- const msiName$1 = "ManagedIdentityCredential - IMDS";
1259
- const logger$i = credentialLogger(msiName$1);
1260
- /**
1261
- * Generates the options used on the request for an access token.
1262
- */
1263
- function prepareRequestOptions(scopes, clientId, resourceId, options) {
1264
- var _a;
1265
- const resource = mapScopesToResource(scopes);
1266
- if (!resource) {
1267
- throw new Error(`${msiName$1}: Multiple scopes are not supported.`);
1268
- }
1269
- const { skipQuery, skipMetadataHeader } = options || {};
1270
- let query = "";
1271
- // Pod Identity will try to process this request even if the Metadata header is missing.
1272
- // We can exclude the request query to ensure no IMDS endpoint tries to process the ping request.
1273
- if (!skipQuery) {
1274
- const queryParameters = {
1275
- resource,
1276
- "api-version": imdsApiVersion,
1277
- };
1278
- if (clientId) {
1279
- queryParameters.client_id = clientId;
1280
- }
1281
- if (resourceId) {
1282
- queryParameters.msi_res_id = resourceId;
1283
- }
1284
- const params = new URLSearchParams(queryParameters);
1285
- query = `?${params.toString()}`;
1286
- }
1287
- const url = new URL(imdsEndpointPath, (_a = process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) !== null && _a !== void 0 ? _a : imdsHost);
1288
- const rawHeaders = {
1289
- Accept: "application/json",
1290
- Metadata: "true",
1291
- };
1292
- // Remove the Metadata header to invoke a request error from some IMDS endpoints.
1293
- if (skipMetadataHeader) {
1294
- delete rawHeaders.Metadata;
1295
- }
1296
- return {
1297
- // In this case, the `?` should be added in the "query" variable `skipQuery` is not set.
1298
- url: `${url}${query}`,
1299
- method: "GET",
1300
- headers: coreRestPipeline.createHttpHeaders(rawHeaders),
1301
- };
1302
- }
1303
- /**
1304
- * Defines how to determine whether the Azure IMDS MSI is available, and also how to retrieve a token from the Azure IMDS MSI.
1305
- */
1306
- const imdsMsi = {
1307
- name: "imdsMsi",
1308
- async isAvailable({ scopes, identityClient, clientId, resourceId, getTokenOptions = {}, }) {
1309
- const resource = mapScopesToResource(scopes);
1310
- if (!resource) {
1311
- logger$i.info(`${msiName$1}: Unavailable. Multiple scopes are not supported.`);
1312
- return false;
1313
- }
1314
- // if the PodIdentityEndpoint environment variable was set no need to probe the endpoint, it can be assumed to exist
1315
- if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
1316
- return true;
1317
- }
1318
- if (!identityClient) {
1319
- throw new Error("Missing IdentityClient");
1320
- }
1321
- const requestOptions = prepareRequestOptions(resource, clientId, resourceId, {
1322
- skipMetadataHeader: true,
1323
- skipQuery: true,
1324
- });
1325
- return tracingClient.withSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions, async (options) => {
1326
- var _a, _b;
1327
- requestOptions.tracingOptions = options.tracingOptions;
1328
- // Create a request with a timeout since we expect that
1329
- // not having a "Metadata" header should cause an error to be
1330
- // returned quickly from the endpoint, proving its availability.
1331
- const request = coreRestPipeline.createPipelineRequest(requestOptions);
1332
- // Default to 1000 if the default of 0 is used.
1333
- // Negative values can still be used to disable the timeout.
1334
- request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) || 1000;
1335
- // This MSI uses the imdsEndpoint to get the token, which only uses http://
1336
- request.allowInsecureConnection = true;
1337
- let response;
1338
- try {
1339
- logger$i.info(`${msiName$1}: Pinging the Azure IMDS endpoint`);
1340
- response = await identityClient.sendRequest(request);
1341
- }
1342
- catch (err) {
1343
- // If the request failed, or Node.js was unable to establish a connection,
1344
- // or the host was down, we'll assume the IMDS endpoint isn't available.
1345
- if (coreUtil.isError(err)) {
1346
- logger$i.verbose(`${msiName$1}: Caught error ${err.name}: ${err.message}`);
1347
- }
1348
- // This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network" or "A socket operation was attempted to an unreachable host"
1349
- // rather than just timing out, as expected.
1350
- logger$i.info(`${msiName$1}: The Azure IMDS endpoint is unavailable`);
1351
- return false;
1352
- }
1353
- if (response.status === 403) {
1354
- if ((_b = response.bodyAsText) === null || _b === void 0 ? void 0 : _b.includes("unreachable")) {
1355
- logger$i.info(`${msiName$1}: The Azure IMDS endpoint is unavailable`);
1356
- logger$i.info(`${msiName$1}: ${response.bodyAsText}`);
1357
- return false;
1358
- }
1359
- }
1360
- // If we received any response, the endpoint is available
1361
- logger$i.info(`${msiName$1}: The Azure IMDS endpoint is available`);
1362
- return true;
1363
- });
1364
- },
1365
- async getToken(configuration, getTokenOptions = {}) {
1366
- const { identityClient, scopes, clientId, resourceId } = configuration;
1367
- if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
1368
- logger$i.info(`${msiName$1}: Using the Azure IMDS endpoint coming from the environment variable AZURE_POD_IDENTITY_AUTHORITY_HOST=${process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST}.`);
1369
- }
1370
- else {
1371
- logger$i.info(`${msiName$1}: Using the default Azure IMDS endpoint ${imdsHost}.`);
1372
- }
1373
- let nextDelayInMs = configuration.retryConfig.startDelayInMs;
1374
- for (let retries = 0; retries < configuration.retryConfig.maxRetries; retries++) {
1375
- try {
1376
- const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions(scopes, clientId, resourceId)), { allowInsecureConnection: true }));
1377
- const tokenResponse = await identityClient.sendTokenRequest(request);
1378
- return (tokenResponse && tokenResponse.accessToken) || null;
1379
- }
1380
- catch (error) {
1381
- if (error.statusCode === 404) {
1382
- await coreUtil.delay(nextDelayInMs);
1383
- nextDelayInMs *= configuration.retryConfig.intervalIncrement;
1384
- continue;
1385
- }
1386
- throw error;
1387
- }
1388
- }
1389
- throw new AuthenticationError(404, `${msiName$1}: Failed to retrieve IMDS token after ${configuration.retryConfig.maxRetries} retries.`);
1390
- },
1391
- };
1392
-
1393
- // Copyright (c) Microsoft Corporation.
1394
- // Licensed under the MIT License.
1395
- // Matches the default retry configuration in expontentialRetryStrategy.ts
1396
- const DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;
1397
- /**
1398
- * An additional policy that retries on 404 errors. The default retry policy does not retry on
1399
- * 404s, but the IMDS endpoint can return 404s when the token is not yet available. This policy
1400
- * will retry on 404s with an exponential backoff.
1401
- *
1402
- * @param msiRetryConfig - The retry configuration for the MSI credential.
1403
- * @returns - The policy that will retry on 404s.
1404
- */
1405
- function imdsRetryPolicy(msiRetryConfig) {
1406
- return coreRestPipeline.retryPolicy([
1407
- {
1408
- name: "imdsRetryPolicy",
1409
- retry: ({ retryCount, response }) => {
1410
- if ((response === null || response === void 0 ? void 0 : response.status) !== 404) {
1411
- return { skipStrategy: true };
1412
- }
1413
- return coreUtil.calculateRetryDelay(retryCount, {
1414
- retryDelayInMs: msiRetryConfig.startDelayInMs,
1415
- maxRetryDelayInMs: DEFAULT_CLIENT_MAX_RETRY_INTERVAL,
1416
- });
1417
- },
1418
- },
1419
- ], {
1420
- maxRetries: msiRetryConfig.maxRetries,
1421
- });
1422
- }
1423
-
1424
- // Copyright (c) Microsoft Corporation.
1425
- // Licensed under the MIT License.
1426
- /**
1427
- * Helps specify a regional authority, or "AutoDiscoverRegion" to auto-detect the region.
1428
- */
1429
- var RegionalAuthority;
1430
- (function (RegionalAuthority) {
1431
- /** Instructs MSAL to attempt to discover the region */
1432
- RegionalAuthority["AutoDiscoverRegion"] = "AutoDiscoverRegion";
1433
- /** Uses the {@link RegionalAuthority} for the Azure 'westus' region. */
1434
- RegionalAuthority["USWest"] = "westus";
1435
- /** Uses the {@link RegionalAuthority} for the Azure 'westus2' region. */
1436
- RegionalAuthority["USWest2"] = "westus2";
1437
- /** Uses the {@link RegionalAuthority} for the Azure 'centralus' region. */
1438
- RegionalAuthority["USCentral"] = "centralus";
1439
- /** Uses the {@link RegionalAuthority} for the Azure 'eastus' region. */
1440
- RegionalAuthority["USEast"] = "eastus";
1441
- /** Uses the {@link RegionalAuthority} for the Azure 'eastus2' region. */
1442
- RegionalAuthority["USEast2"] = "eastus2";
1443
- /** Uses the {@link RegionalAuthority} for the Azure 'northcentralus' region. */
1444
- RegionalAuthority["USNorthCentral"] = "northcentralus";
1445
- /** Uses the {@link RegionalAuthority} for the Azure 'southcentralus' region. */
1446
- RegionalAuthority["USSouthCentral"] = "southcentralus";
1447
- /** Uses the {@link RegionalAuthority} for the Azure 'westcentralus' region. */
1448
- RegionalAuthority["USWestCentral"] = "westcentralus";
1449
- /** Uses the {@link RegionalAuthority} for the Azure 'canadacentral' region. */
1450
- RegionalAuthority["CanadaCentral"] = "canadacentral";
1451
- /** Uses the {@link RegionalAuthority} for the Azure 'canadaeast' region. */
1452
- RegionalAuthority["CanadaEast"] = "canadaeast";
1453
- /** Uses the {@link RegionalAuthority} for the Azure 'brazilsouth' region. */
1454
- RegionalAuthority["BrazilSouth"] = "brazilsouth";
1455
- /** Uses the {@link RegionalAuthority} for the Azure 'northeurope' region. */
1456
- RegionalAuthority["EuropeNorth"] = "northeurope";
1457
- /** Uses the {@link RegionalAuthority} for the Azure 'westeurope' region. */
1458
- RegionalAuthority["EuropeWest"] = "westeurope";
1459
- /** Uses the {@link RegionalAuthority} for the Azure 'uksouth' region. */
1460
- RegionalAuthority["UKSouth"] = "uksouth";
1461
- /** Uses the {@link RegionalAuthority} for the Azure 'ukwest' region. */
1462
- RegionalAuthority["UKWest"] = "ukwest";
1463
- /** Uses the {@link RegionalAuthority} for the Azure 'francecentral' region. */
1464
- RegionalAuthority["FranceCentral"] = "francecentral";
1465
- /** Uses the {@link RegionalAuthority} for the Azure 'francesouth' region. */
1466
- RegionalAuthority["FranceSouth"] = "francesouth";
1467
- /** Uses the {@link RegionalAuthority} for the Azure 'switzerlandnorth' region. */
1468
- RegionalAuthority["SwitzerlandNorth"] = "switzerlandnorth";
1469
- /** Uses the {@link RegionalAuthority} for the Azure 'switzerlandwest' region. */
1470
- RegionalAuthority["SwitzerlandWest"] = "switzerlandwest";
1471
- /** Uses the {@link RegionalAuthority} for the Azure 'germanynorth' region. */
1472
- RegionalAuthority["GermanyNorth"] = "germanynorth";
1473
- /** Uses the {@link RegionalAuthority} for the Azure 'germanywestcentral' region. */
1474
- RegionalAuthority["GermanyWestCentral"] = "germanywestcentral";
1475
- /** Uses the {@link RegionalAuthority} for the Azure 'norwaywest' region. */
1476
- RegionalAuthority["NorwayWest"] = "norwaywest";
1477
- /** Uses the {@link RegionalAuthority} for the Azure 'norwayeast' region. */
1478
- RegionalAuthority["NorwayEast"] = "norwayeast";
1479
- /** Uses the {@link RegionalAuthority} for the Azure 'eastasia' region. */
1480
- RegionalAuthority["AsiaEast"] = "eastasia";
1481
- /** Uses the {@link RegionalAuthority} for the Azure 'southeastasia' region. */
1482
- RegionalAuthority["AsiaSouthEast"] = "southeastasia";
1483
- /** Uses the {@link RegionalAuthority} for the Azure 'japaneast' region. */
1484
- RegionalAuthority["JapanEast"] = "japaneast";
1485
- /** Uses the {@link RegionalAuthority} for the Azure 'japanwest' region. */
1486
- RegionalAuthority["JapanWest"] = "japanwest";
1487
- /** Uses the {@link RegionalAuthority} for the Azure 'australiaeast' region. */
1488
- RegionalAuthority["AustraliaEast"] = "australiaeast";
1489
- /** Uses the {@link RegionalAuthority} for the Azure 'australiasoutheast' region. */
1490
- RegionalAuthority["AustraliaSouthEast"] = "australiasoutheast";
1491
- /** Uses the {@link RegionalAuthority} for the Azure 'australiacentral' region. */
1492
- RegionalAuthority["AustraliaCentral"] = "australiacentral";
1493
- /** Uses the {@link RegionalAuthority} for the Azure 'australiacentral2' region. */
1494
- RegionalAuthority["AustraliaCentral2"] = "australiacentral2";
1495
- /** Uses the {@link RegionalAuthority} for the Azure 'centralindia' region. */
1496
- RegionalAuthority["IndiaCentral"] = "centralindia";
1497
- /** Uses the {@link RegionalAuthority} for the Azure 'southindia' region. */
1498
- RegionalAuthority["IndiaSouth"] = "southindia";
1499
- /** Uses the {@link RegionalAuthority} for the Azure 'westindia' region. */
1500
- RegionalAuthority["IndiaWest"] = "westindia";
1501
- /** Uses the {@link RegionalAuthority} for the Azure 'koreasouth' region. */
1502
- RegionalAuthority["KoreaSouth"] = "koreasouth";
1503
- /** Uses the {@link RegionalAuthority} for the Azure 'koreacentral' region. */
1504
- RegionalAuthority["KoreaCentral"] = "koreacentral";
1505
- /** Uses the {@link RegionalAuthority} for the Azure 'uaecentral' region. */
1506
- RegionalAuthority["UAECentral"] = "uaecentral";
1507
- /** Uses the {@link RegionalAuthority} for the Azure 'uaenorth' region. */
1508
- RegionalAuthority["UAENorth"] = "uaenorth";
1509
- /** Uses the {@link RegionalAuthority} for the Azure 'southafricanorth' region. */
1510
- RegionalAuthority["SouthAfricaNorth"] = "southafricanorth";
1511
- /** Uses the {@link RegionalAuthority} for the Azure 'southafricawest' region. */
1512
- RegionalAuthority["SouthAfricaWest"] = "southafricawest";
1513
- /** Uses the {@link RegionalAuthority} for the Azure 'chinanorth' region. */
1514
- RegionalAuthority["ChinaNorth"] = "chinanorth";
1515
- /** Uses the {@link RegionalAuthority} for the Azure 'chinaeast' region. */
1516
- RegionalAuthority["ChinaEast"] = "chinaeast";
1517
- /** Uses the {@link RegionalAuthority} for the Azure 'chinanorth2' region. */
1518
- RegionalAuthority["ChinaNorth2"] = "chinanorth2";
1519
- /** Uses the {@link RegionalAuthority} for the Azure 'chinaeast2' region. */
1520
- RegionalAuthority["ChinaEast2"] = "chinaeast2";
1521
- /** Uses the {@link RegionalAuthority} for the Azure 'germanycentral' region. */
1522
- RegionalAuthority["GermanyCentral"] = "germanycentral";
1523
- /** Uses the {@link RegionalAuthority} for the Azure 'germanynortheast' region. */
1524
- RegionalAuthority["GermanyNorthEast"] = "germanynortheast";
1525
- /** Uses the {@link RegionalAuthority} for the Azure 'usgovvirginia' region. */
1526
- RegionalAuthority["GovernmentUSVirginia"] = "usgovvirginia";
1527
- /** Uses the {@link RegionalAuthority} for the Azure 'usgoviowa' region. */
1528
- RegionalAuthority["GovernmentUSIowa"] = "usgoviowa";
1529
- /** Uses the {@link RegionalAuthority} for the Azure 'usgovarizona' region. */
1530
- RegionalAuthority["GovernmentUSArizona"] = "usgovarizona";
1531
- /** Uses the {@link RegionalAuthority} for the Azure 'usgovtexas' region. */
1532
- RegionalAuthority["GovernmentUSTexas"] = "usgovtexas";
1533
- /** Uses the {@link RegionalAuthority} for the Azure 'usdodeast' region. */
1534
- RegionalAuthority["GovernmentUSDodEast"] = "usdodeast";
1535
- /** Uses the {@link RegionalAuthority} for the Azure 'usdodcentral' region. */
1536
- RegionalAuthority["GovernmentUSDodCentral"] = "usdodcentral";
1537
- })(RegionalAuthority || (RegionalAuthority = {}));
1538
- /**
1539
- * Calculates the correct regional authority based on the supplied value
1540
- * and the AZURE_REGIONAL_AUTHORITY_NAME environment variable.
1541
- *
1542
- * Values will be returned verbatim, except for {@link RegionalAuthority.AutoDiscoverRegion}
1543
- * which is mapped to a value MSAL can understand.
1544
- *
1545
- * @internal
1546
- */
1547
- function calculateRegionalAuthority(regionalAuthority) {
1548
- // Note: as of today only 3 credentials support regional authority, and the parameter
1549
- // is not exposed via the public API. Regional Authority is _only_ supported
1550
- // via the AZURE_REGIONAL_AUTHORITY_NAME env var and _only_ for: ClientSecretCredential, ClientCertificateCredential, and ClientAssertionCredential.
1551
- var _a, _b;
1552
- // Accepting the regionalAuthority parameter will allow us to support it in the future.
1553
- let azureRegion = regionalAuthority;
1554
- if (azureRegion === undefined &&
1555
- ((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.AZURE_REGIONAL_AUTHORITY_NAME) !== undefined) {
1556
- azureRegion = process.env.AZURE_REGIONAL_AUTHORITY_NAME;
1557
- }
1558
- if (azureRegion === RegionalAuthority.AutoDiscoverRegion) {
1559
- return "AUTO_DISCOVER";
1560
- }
1561
- return azureRegion;
1562
- }
1563
-
1564
- // Copyright (c) Microsoft Corporation.
1565
- // Licensed under the MIT License.
1566
- /**
1567
- * The default logger used if no logger was passed in by the credential.
1568
- */
1569
- const msalLogger = credentialLogger("MsalClient");
1570
- /**
1571
- * A call to open(), but mockable
1572
- * @internal
1573
- */
1574
- const interactiveBrowserMockable = {
1575
- open,
1576
- };
1577
- /**
1578
- * Generates the configuration for MSAL (Microsoft Authentication Library).
1579
- *
1580
- * @param clientId - The client ID of the application.
1581
- * @param tenantId - The tenant ID of the Azure Active Directory.
1582
- * @param msalClientOptions - Optional. Additional options for creating the MSAL client.
1583
- * @returns The MSAL configuration object.
1584
- */
1585
- function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
1586
- var _a, _b, _c;
1587
- const resolvedTenant = resolveTenantId((_a = msalClientOptions.logger) !== null && _a !== void 0 ? _a : msalLogger, tenantId, clientId);
1588
- // TODO: move and reuse getIdentityClientAuthorityHost
1589
- const authority = getAuthority(resolvedTenant, getAuthorityHost(msalClientOptions));
1590
- const httpClient = new IdentityClient(Object.assign(Object.assign({}, msalClientOptions.tokenCredentialOptions), { authorityHost: authority, loggingOptions: msalClientOptions.loggingOptions }));
1591
- const msalConfig = {
1592
- auth: {
1593
- clientId,
1594
- authority,
1595
- knownAuthorities: getKnownAuthorities(resolvedTenant, authority, msalClientOptions.disableInstanceDiscovery),
1596
- },
1597
- system: {
1598
- networkClient: httpClient,
1599
- loggerOptions: {
1600
- loggerCallback: defaultLoggerCallback((_b = msalClientOptions.logger) !== null && _b !== void 0 ? _b : msalLogger),
1601
- logLevel: getMSALLogLevel(logger$m.getLogLevel()),
1602
- piiLoggingEnabled: (_c = msalClientOptions.loggingOptions) === null || _c === void 0 ? void 0 : _c.enableUnsafeSupportLogging,
1603
- },
1604
- },
1605
- };
1606
- return msalConfig;
1607
- }
1608
- /**
1609
- * Creates an instance of the MSAL (Microsoft Authentication Library) client.
1610
- *
1611
- * @param clientId - The client ID of the application.
1612
- * @param tenantId - The tenant ID of the Azure Active Directory.
1613
- * @param createMsalClientOptions - Optional. Additional options for creating the MSAL client.
1614
- * @returns An instance of the MSAL client.
1615
- *
1616
- * @public
1617
- */
1618
- function createMsalClient(clientId, tenantId, createMsalClientOptions = {}) {
1619
- var _a;
1620
- const state = {
1621
- msalConfig: generateMsalConfiguration(clientId, tenantId, createMsalClientOptions),
1622
- cachedAccount: createMsalClientOptions.authenticationRecord
1623
- ? publicToMsal(createMsalClientOptions.authenticationRecord)
1624
- : null,
1625
- pluginConfiguration: msalPlugins.generatePluginConfiguration(createMsalClientOptions),
1626
- logger: (_a = createMsalClientOptions.logger) !== null && _a !== void 0 ? _a : msalLogger,
1627
- };
1628
- const publicApps = new Map();
1629
- async function getPublicApp(options = {}) {
1630
- const appKey = options.enableCae ? "CAE" : "default";
1631
- let publicClientApp = publicApps.get(appKey);
1632
- if (publicClientApp) {
1633
- state.logger.getToken.info("Existing PublicClientApplication found in cache, returning it.");
1634
- return publicClientApp;
1635
- }
1636
- // Initialize a new app and cache it
1637
- state.logger.getToken.info(`Creating new PublicClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`);
1638
- const cachePlugin = options.enableCae
1639
- ? state.pluginConfiguration.cache.cachePluginCae
1640
- : state.pluginConfiguration.cache.cachePlugin;
1641
- state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : undefined;
1642
- publicClientApp = new msalCommon__namespace.PublicClientApplication(Object.assign(Object.assign({}, state.msalConfig), { broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin }, cache: { cachePlugin: await cachePlugin } }));
1643
- publicApps.set(appKey, publicClientApp);
1644
- return publicClientApp;
1645
- }
1646
- const confidentialApps = new Map();
1647
- async function getConfidentialApp(options = {}) {
1648
- const appKey = options.enableCae ? "CAE" : "default";
1649
- let confidentialClientApp = confidentialApps.get(appKey);
1650
- if (confidentialClientApp) {
1651
- state.logger.getToken.info("Existing ConfidentialClientApplication found in cache, returning it.");
1652
- return confidentialClientApp;
1653
- }
1654
- // Initialize a new app and cache it
1655
- state.logger.getToken.info(`Creating new ConfidentialClientApplication with CAE ${options.enableCae ? "enabled" : "disabled"}.`);
1656
- const cachePlugin = options.enableCae
1657
- ? state.pluginConfiguration.cache.cachePluginCae
1658
- : state.pluginConfiguration.cache.cachePlugin;
1659
- state.msalConfig.auth.clientCapabilities = options.enableCae ? ["cp1"] : undefined;
1660
- confidentialClientApp = new msalCommon__namespace.ConfidentialClientApplication(Object.assign(Object.assign({}, state.msalConfig), { broker: { nativeBrokerPlugin: state.pluginConfiguration.broker.nativeBrokerPlugin }, cache: { cachePlugin: await cachePlugin } }));
1661
- confidentialApps.set(appKey, confidentialClientApp);
1662
- return confidentialClientApp;
1663
- }
1664
- async function getTokenSilent(app, scopes, options = {}) {
1665
- if (state.cachedAccount === null) {
1666
- state.logger.getToken.info("No cached account found in local state, attempting to load it from MSAL cache.");
1667
- const cache = app.getTokenCache();
1668
- const accounts = await cache.getAllAccounts();
1669
- if (accounts === undefined || accounts.length === 0) {
1670
- throw new AuthenticationRequiredError({ scopes });
1671
- }
1672
- if (accounts.length > 1) {
1673
- state.logger
1674
- .info(`More than one account was found authenticated for this Client ID and Tenant ID.
1675
- However, no "authenticationRecord" has been provided for this credential,
1676
- therefore we're unable to pick between these accounts.
1677
- A new login attempt will be requested, to ensure the correct account is picked.
1678
- To work with multiple accounts for the same Client ID and Tenant ID, please provide an "authenticationRecord" when initializing a credential to prevent this from happening.`);
1679
- throw new AuthenticationRequiredError({ scopes });
1680
- }
1681
- state.cachedAccount = accounts[0];
1682
- }
1683
- // Keep track and reuse the claims we received across challenges
1684
- if (options.claims) {
1685
- state.cachedClaims = options.claims;
1686
- }
1687
- const silentRequest = {
1688
- account: state.cachedAccount,
1689
- scopes,
1690
- claims: state.cachedClaims,
1691
- };
1692
- if (state.pluginConfiguration.broker.isEnabled) {
1693
- silentRequest.tokenQueryParameters || (silentRequest.tokenQueryParameters = {});
1694
- if (state.pluginConfiguration.broker.enableMsaPassthrough) {
1695
- silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
1696
- }
1697
- }
1698
- if (options.proofOfPossessionOptions) {
1699
- silentRequest.shrNonce = options.proofOfPossessionOptions.nonce;
1700
- silentRequest.authenticationScheme = "pop";
1701
- silentRequest.resourceRequestMethod = options.proofOfPossessionOptions.resourceRequestMethod;
1702
- silentRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
1703
- }
1704
- state.logger.getToken.info("Attempting to acquire token silently");
1705
- return app.acquireTokenSilent(silentRequest);
1706
- }
1707
- /**
1708
- * Builds an authority URL for the given request. The authority may be different than the one used when creating the MSAL client
1709
- * if the user is creating cross-tenant requests
1710
- */
1711
- function calculateRequestAuthority(options) {
1712
- if (options === null || options === void 0 ? void 0 : options.tenantId) {
1713
- return getAuthority(options.tenantId, getAuthorityHost(createMsalClientOptions));
1714
- }
1715
- return state.msalConfig.auth.authority;
1716
- }
1717
- /**
1718
- * Performs silent authentication using MSAL to acquire an access token.
1719
- * If silent authentication fails, falls back to interactive authentication.
1720
- *
1721
- * @param msalApp - The MSAL application instance.
1722
- * @param scopes - The scopes for which to acquire the access token.
1723
- * @param options - The options for acquiring the access token.
1724
- * @param onAuthenticationRequired - A callback function to handle interactive authentication when silent authentication fails.
1725
- * @returns A promise that resolves to an AccessToken object containing the access token and its expiration timestamp.
1726
- */
1727
- async function withSilentAuthentication(msalApp, scopes, options, onAuthenticationRequired) {
1728
- var _a, _b;
1729
- let response = null;
1730
- try {
1731
- response = await getTokenSilent(msalApp, scopes, options);
1732
- }
1733
- catch (e) {
1734
- if (e.name !== "AuthenticationRequiredError") {
1735
- throw e;
1736
- }
1737
- if (options.disableAutomaticAuthentication) {
1738
- throw new AuthenticationRequiredError({
1739
- scopes,
1740
- getTokenOptions: options,
1741
- message: "Automatic authentication has been disabled. You may call the authentication() method.",
1742
- });
1743
- }
1744
- }
1745
- // Silent authentication failed
1746
- if (response === null) {
1747
- try {
1748
- response = await onAuthenticationRequired();
1749
- }
1750
- catch (err) {
1751
- throw handleMsalError(scopes, err, options);
1752
- }
1753
- }
1754
- // At this point we should have a token, process it
1755
- ensureValidMsalToken(scopes, response, options);
1756
- state.cachedAccount = (_a = response === null || response === void 0 ? void 0 : response.account) !== null && _a !== void 0 ? _a : null;
1757
- state.logger.getToken.info(formatSuccess(scopes));
1758
- return {
1759
- token: response.accessToken,
1760
- expiresOnTimestamp: response.expiresOn.getTime(),
1761
- refreshAfterTimestamp: (_b = response.refreshOn) === null || _b === void 0 ? void 0 : _b.getTime(),
1762
- tokenType: response.tokenType,
1763
- };
1764
- }
1765
- async function getTokenByClientSecret(scopes, clientSecret, options = {}) {
1766
- var _a;
1767
- state.logger.getToken.info(`Attempting to acquire token using client secret`);
1768
- state.msalConfig.auth.clientSecret = clientSecret;
1769
- const msalApp = await getConfidentialApp(options);
1770
- try {
1771
- const response = await msalApp.acquireTokenByClientCredential({
1772
- scopes,
1773
- authority: calculateRequestAuthority(options),
1774
- azureRegion: calculateRegionalAuthority(),
1775
- claims: options === null || options === void 0 ? void 0 : options.claims,
1776
- });
1777
- ensureValidMsalToken(scopes, response, options);
1778
- state.logger.getToken.info(formatSuccess(scopes));
1779
- return {
1780
- token: response.accessToken,
1781
- expiresOnTimestamp: response.expiresOn.getTime(),
1782
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
1783
- tokenType: response.tokenType,
1784
- };
1785
- }
1786
- catch (err) {
1787
- throw handleMsalError(scopes, err, options);
1788
- }
1789
- }
1790
- async function getTokenByClientAssertion(scopes, clientAssertion, options = {}) {
1791
- var _a;
1792
- state.logger.getToken.info(`Attempting to acquire token using client assertion`);
1793
- state.msalConfig.auth.clientAssertion = clientAssertion;
1794
- const msalApp = await getConfidentialApp(options);
1795
- try {
1796
- const response = await msalApp.acquireTokenByClientCredential({
1797
- scopes,
1798
- authority: calculateRequestAuthority(options),
1799
- azureRegion: calculateRegionalAuthority(),
1800
- claims: options === null || options === void 0 ? void 0 : options.claims,
1801
- clientAssertion,
1802
- });
1803
- ensureValidMsalToken(scopes, response, options);
1804
- state.logger.getToken.info(formatSuccess(scopes));
1805
- return {
1806
- token: response.accessToken,
1807
- expiresOnTimestamp: response.expiresOn.getTime(),
1808
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
1809
- tokenType: response.tokenType,
1810
- };
1811
- }
1812
- catch (err) {
1813
- throw handleMsalError(scopes, err, options);
1814
- }
1815
- }
1816
- async function getTokenByClientCertificate(scopes, certificate, options = {}) {
1817
- var _a;
1818
- state.logger.getToken.info(`Attempting to acquire token using client certificate`);
1819
- state.msalConfig.auth.clientCertificate = certificate;
1820
- const msalApp = await getConfidentialApp(options);
1821
- try {
1822
- const response = await msalApp.acquireTokenByClientCredential({
1823
- scopes,
1824
- authority: calculateRequestAuthority(options),
1825
- azureRegion: calculateRegionalAuthority(),
1826
- claims: options === null || options === void 0 ? void 0 : options.claims,
1827
- });
1828
- ensureValidMsalToken(scopes, response, options);
1829
- state.logger.getToken.info(formatSuccess(scopes));
1830
- return {
1831
- token: response.accessToken,
1832
- expiresOnTimestamp: response.expiresOn.getTime(),
1833
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
1834
- tokenType: response.tokenType,
1835
- };
1836
- }
1837
- catch (err) {
1838
- throw handleMsalError(scopes, err, options);
1839
- }
1840
- }
1841
- async function getTokenByDeviceCode(scopes, deviceCodeCallback, options = {}) {
1842
- state.logger.getToken.info(`Attempting to acquire token using device code`);
1843
- const msalApp = await getPublicApp(options);
1844
- return withSilentAuthentication(msalApp, scopes, options, () => {
1845
- var _a, _b;
1846
- const requestOptions = {
1847
- scopes,
1848
- 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,
1849
- deviceCodeCallback,
1850
- authority: calculateRequestAuthority(options),
1851
- claims: options === null || options === void 0 ? void 0 : options.claims,
1852
- };
1853
- const deviceCodeRequest = msalApp.acquireTokenByDeviceCode(requestOptions);
1854
- if (options.abortSignal) {
1855
- options.abortSignal.addEventListener("abort", () => {
1856
- requestOptions.cancel = true;
1857
- });
1858
- }
1859
- return deviceCodeRequest;
1860
- });
1861
- }
1862
- async function getTokenByUsernamePassword(scopes, username, password, options = {}) {
1863
- state.logger.getToken.info(`Attempting to acquire token using username and password`);
1864
- const msalApp = await getPublicApp(options);
1865
- return withSilentAuthentication(msalApp, scopes, options, () => {
1866
- const requestOptions = {
1867
- scopes,
1868
- username,
1869
- password,
1870
- authority: calculateRequestAuthority(options),
1871
- claims: options === null || options === void 0 ? void 0 : options.claims,
1872
- };
1873
- return msalApp.acquireTokenByUsernamePassword(requestOptions);
1874
- });
1875
- }
1876
- function getActiveAccount() {
1877
- if (!state.cachedAccount) {
1878
- return undefined;
1879
- }
1880
- return msalToPublic(clientId, state.cachedAccount);
1881
- }
1882
- async function getTokenByAuthorizationCode(scopes, redirectUri, authorizationCode, clientSecret, options = {}) {
1883
- state.logger.getToken.info(`Attempting to acquire token using authorization code`);
1884
- let msalApp;
1885
- if (clientSecret) {
1886
- // If a client secret is provided, we need to use a confidential client application
1887
- // See https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow#request-an-access-token-with-a-client_secret
1888
- state.msalConfig.auth.clientSecret = clientSecret;
1889
- msalApp = await getConfidentialApp(options);
1890
- }
1891
- else {
1892
- msalApp = await getPublicApp(options);
1893
- }
1894
- return withSilentAuthentication(msalApp, scopes, options, () => {
1895
- return msalApp.acquireTokenByCode({
1896
- scopes,
1897
- redirectUri,
1898
- code: authorizationCode,
1899
- authority: calculateRequestAuthority(options),
1900
- claims: options === null || options === void 0 ? void 0 : options.claims,
1901
- });
1902
- });
1903
- }
1904
- async function getTokenOnBehalfOf(scopes, userAssertionToken, clientCredentials, options = {}) {
1905
- var _a;
1906
- msalLogger.getToken.info(`Attempting to acquire token on behalf of another user`);
1907
- if (typeof clientCredentials === "string") {
1908
- // Client secret
1909
- msalLogger.getToken.info(`Using client secret for on behalf of flow`);
1910
- state.msalConfig.auth.clientSecret = clientCredentials;
1911
- }
1912
- else if (typeof clientCredentials === "function") {
1913
- // Client Assertion
1914
- msalLogger.getToken.info(`Using client assertion callback for on behalf of flow`);
1915
- state.msalConfig.auth.clientAssertion = clientCredentials;
1916
- }
1917
- else {
1918
- // Client certificate
1919
- msalLogger.getToken.info(`Using client certificate for on behalf of flow`);
1920
- state.msalConfig.auth.clientCertificate = clientCredentials;
1921
- }
1922
- const msalApp = await getConfidentialApp(options);
1923
- try {
1924
- const response = await msalApp.acquireTokenOnBehalfOf({
1925
- scopes,
1926
- authority: calculateRequestAuthority(options),
1927
- claims: options.claims,
1928
- oboAssertion: userAssertionToken,
1929
- });
1930
- ensureValidMsalToken(scopes, response, options);
1931
- msalLogger.getToken.info(formatSuccess(scopes));
1932
- return {
1933
- token: response.accessToken,
1934
- expiresOnTimestamp: response.expiresOn.getTime(),
1935
- refreshAfterTimestamp: (_a = response.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
1936
- tokenType: response.tokenType,
1937
- };
1938
- }
1939
- catch (err) {
1940
- throw handleMsalError(scopes, err, options);
1941
- }
1942
- }
1943
- async function getTokenByInteractiveRequest(scopes, options = {}) {
1944
- msalLogger.getToken.info(`Attempting to acquire token interactively`);
1945
- const app = await getPublicApp(options);
1946
- /**
1947
- * A helper function that supports brokered authentication through the MSAL's public application.
1948
- *
1949
- * When options.useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.
1950
- * If the default broker account is not available, the method will fall back to interactive authentication.
1951
- */
1952
- async function getBrokeredToken(useDefaultBrokerAccount) {
1953
- var _a;
1954
- msalLogger.verbose("Authentication will resume through the broker");
1955
- const interactiveRequest = createBaseInteractiveRequest();
1956
- if (state.pluginConfiguration.broker.parentWindowHandle) {
1957
- interactiveRequest.windowHandle = Buffer.from(state.pluginConfiguration.broker.parentWindowHandle);
1958
- }
1959
- else {
1960
- // this is a bug, as the pluginConfiguration handler should validate this case.
1961
- msalLogger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
1962
- }
1963
- if (state.pluginConfiguration.broker.enableMsaPassthrough) {
1964
- ((_a = interactiveRequest.tokenQueryParameters) !== null && _a !== void 0 ? _a : (interactiveRequest.tokenQueryParameters = {}))["msal_request_type"] =
1965
- "consumer_passthrough";
1966
- }
1967
- if (useDefaultBrokerAccount) {
1968
- interactiveRequest.prompt = "none";
1969
- msalLogger.verbose("Attempting broker authentication using the default broker account");
1970
- }
1971
- else {
1972
- msalLogger.verbose("Attempting broker authentication without the default broker account");
1973
- }
1974
- if (options.proofOfPossessionOptions) {
1975
- interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
1976
- interactiveRequest.authenticationScheme = "pop";
1977
- interactiveRequest.resourceRequestMethod =
1978
- options.proofOfPossessionOptions.resourceRequestMethod;
1979
- interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
1980
- }
1981
- try {
1982
- return await app.acquireTokenInteractive(interactiveRequest);
1983
- }
1984
- catch (e) {
1985
- msalLogger.verbose(`Failed to authenticate through the broker: ${e.message}`);
1986
- // If we tried to use the default broker account and failed, fall back to interactive authentication
1987
- if (useDefaultBrokerAccount) {
1988
- return getBrokeredToken(/* useDefaultBrokerAccount: */ false);
1989
- }
1990
- else {
1991
- throw e;
1992
- }
1993
- }
1994
- }
1995
- function createBaseInteractiveRequest() {
1996
- var _a, _b;
1997
- return {
1998
- openBrowser: async (url) => {
1999
- await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
2000
- },
2001
- scopes,
2002
- authority: calculateRequestAuthority(options),
2003
- claims: options === null || options === void 0 ? void 0 : options.claims,
2004
- loginHint: options === null || options === void 0 ? void 0 : options.loginHint,
2005
- errorTemplate: (_a = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _a === void 0 ? void 0 : _a.errorMessage,
2006
- successTemplate: (_b = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _b === void 0 ? void 0 : _b.successMessage,
2007
- };
2008
- }
2009
- return withSilentAuthentication(app, scopes, options, async () => {
2010
- var _a;
2011
- const interactiveRequest = createBaseInteractiveRequest();
2012
- if (state.pluginConfiguration.broker.isEnabled) {
2013
- return getBrokeredToken((_a = state.pluginConfiguration.broker.useDefaultBrokerAccount) !== null && _a !== void 0 ? _a : false);
2014
- }
2015
- if (options.proofOfPossessionOptions) {
2016
- interactiveRequest.shrNonce = options.proofOfPossessionOptions.nonce;
2017
- interactiveRequest.authenticationScheme = "pop";
2018
- interactiveRequest.resourceRequestMethod =
2019
- options.proofOfPossessionOptions.resourceRequestMethod;
2020
- interactiveRequest.resourceRequestUri = options.proofOfPossessionOptions.resourceRequestUrl;
2021
- }
2022
- return app.acquireTokenInteractive(interactiveRequest);
2023
- });
2024
- }
2025
- return {
2026
- getActiveAccount,
2027
- getTokenByClientSecret,
2028
- getTokenByClientAssertion,
2029
- getTokenByClientCertificate,
2030
- getTokenByDeviceCode,
2031
- getTokenByUsernamePassword,
2032
- getTokenByAuthorizationCode,
2033
- getTokenOnBehalfOf,
2034
- getTokenByInteractiveRequest,
2035
- };
2036
- }
2037
-
2038
- // Copyright (c) Microsoft Corporation.
2039
- // Licensed under the MIT License.
2040
- const logger$h = credentialLogger("ClientAssertionCredential");
2041
- /**
2042
- * Authenticates a service principal with a JWT assertion.
2043
- */
2044
- class ClientAssertionCredential {
2045
- /**
2046
- * Creates an instance of the ClientAssertionCredential with the details
2047
- * needed to authenticate against Microsoft Entra ID with a client
2048
- * assertion provided by the developer through the `getAssertion` function parameter.
2049
- *
2050
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
2051
- * @param clientId - The client (application) ID of an App Registration in the tenant.
2052
- * @param getAssertion - A function that retrieves the assertion for the credential to use.
2053
- * @param options - Options for configuring the client which makes the authentication request.
2054
- */
2055
- constructor(tenantId, clientId, getAssertion, options = {}) {
2056
- if (!tenantId) {
2057
- throw new CredentialUnavailableError("ClientAssertionCredential: tenantId is a required parameter.");
2058
- }
2059
- if (!clientId) {
2060
- throw new CredentialUnavailableError("ClientAssertionCredential: clientId is a required parameter.");
2061
- }
2062
- if (!getAssertion) {
2063
- throw new CredentialUnavailableError("ClientAssertionCredential: clientAssertion is a required parameter.");
2064
- }
2065
- this.tenantId = tenantId;
2066
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
2067
- this.options = options;
2068
- this.getAssertion = getAssertion;
2069
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger: logger$h, tokenCredentialOptions: this.options }));
2070
- }
2071
- /**
2072
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
2073
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
2074
- *
2075
- * @param scopes - The list of scopes for which the token will have access.
2076
- * @param options - The options used to configure any requests this
2077
- * TokenCredential implementation might make.
2078
- */
2079
- async getToken(scopes, options = {}) {
2080
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
2081
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$h);
2082
- const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
2083
- return this.msalClient.getTokenByClientAssertion(arrayScopes, this.getAssertion, newOptions);
2084
- });
2085
- }
2086
- }
2087
-
2088
- // Copyright (c) Microsoft Corporation.
2089
- // Licensed under the MIT License.
2090
- const credentialName$4 = "WorkloadIdentityCredential";
2091
- /**
2092
- * Contains the list of all supported environment variable names so that an
2093
- * appropriate error message can be generated when no credentials can be
2094
- * configured.
2095
- *
2096
- * @internal
2097
- */
2098
- const SupportedWorkloadEnvironmentVariables = [
2099
- "AZURE_TENANT_ID",
2100
- "AZURE_CLIENT_ID",
2101
- "AZURE_FEDERATED_TOKEN_FILE",
2102
- ];
2103
- const logger$g = credentialLogger(credentialName$4);
2104
- /**
2105
- * Workload Identity authentication is a feature in Azure that allows applications running on virtual machines (VMs)
2106
- * to access other Azure resources without the need for a service principal or managed identity. With Workload Identity
2107
- * authentication, applications authenticate themselves using their own identity, rather than using a shared service
2108
- * principal or managed identity. Under the hood, Workload Identity authentication uses the concept of Service Account
2109
- * Credentials (SACs), which are automatically created by Azure and stored securely in the VM. By using Workload
2110
- * Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
2111
- * each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
2112
- * need to worry about storing and securing sensitive credentials themselves.
2113
- * The WorkloadIdentityCredential supports Microsoft Entra Workload ID authentication on Azure Kubernetes and acquires
2114
- * a token using the SACs available in the Azure Kubernetes environment.
2115
- * Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Microsoft Entra
2116
- * Workload ID</a> for more information.
2117
- */
2118
- class WorkloadIdentityCredential {
2119
- /**
2120
- * WorkloadIdentityCredential supports Microsoft Entra Workload ID on Kubernetes.
2121
- *
2122
- * @param options - The identity client options to use for authentication.
2123
- */
2124
- constructor(options) {
2125
- this.azureFederatedTokenFileContent = undefined;
2126
- this.cacheDate = undefined;
2127
- // Logging environment variables for error details
2128
- const assignedEnv = processEnvVars(SupportedWorkloadEnvironmentVariables).assigned.join(", ");
2129
- logger$g.info(`Found the following environment variables: ${assignedEnv}`);
2130
- const workloadIdentityCredentialOptions = options !== null && options !== void 0 ? options : {};
2131
- const tenantId = workloadIdentityCredentialOptions.tenantId || process.env.AZURE_TENANT_ID;
2132
- const clientId = workloadIdentityCredentialOptions.clientId || process.env.AZURE_CLIENT_ID;
2133
- this.federatedTokenFilePath =
2134
- workloadIdentityCredentialOptions.tokenFilePath || process.env.AZURE_FEDERATED_TOKEN_FILE;
2135
- if (tenantId) {
2136
- checkTenantId(logger$g, tenantId);
2137
- }
2138
- if (!clientId) {
2139
- throw new CredentialUnavailableError(`${credentialName$4}: is unavailable. clientId is a required parameter. In DefaultAzureCredential and ManagedIdentityCredential, this can be provided as an environment variable - "AZURE_CLIENT_ID".
2140
- See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/workloadidentitycredential/troubleshoot`);
2141
- }
2142
- if (!tenantId) {
2143
- throw new CredentialUnavailableError(`${credentialName$4}: is unavailable. tenantId is a required parameter. In DefaultAzureCredential and ManagedIdentityCredential, this can be provided as an environment variable - "AZURE_TENANT_ID".
2144
- See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/workloadidentitycredential/troubleshoot`);
2145
- }
2146
- if (!this.federatedTokenFilePath) {
2147
- throw new CredentialUnavailableError(`${credentialName$4}: is unavailable. federatedTokenFilePath is a required parameter. In DefaultAzureCredential and ManagedIdentityCredential, this can be provided as an environment variable - "AZURE_FEDERATED_TOKEN_FILE".
2148
- See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/workloadidentitycredential/troubleshoot`);
2149
- }
2150
- logger$g.info(`Invoking ClientAssertionCredential with tenant ID: ${tenantId}, clientId: ${workloadIdentityCredentialOptions.clientId} and federated token path: [REDACTED]`);
2151
- this.client = new ClientAssertionCredential(tenantId, clientId, this.readFileContents.bind(this), options);
2152
- }
2153
- /**
2154
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
2155
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
2156
- *
2157
- * @param scopes - The list of scopes for which the token will have access.
2158
- * @param options - The options used to configure any requests this
2159
- * TokenCredential implementation might make.
2160
- */
2161
- async getToken(scopes, options) {
2162
- if (!this.client) {
2163
- const errorMessage = `${credentialName$4}: is unavailable. tenantId, clientId, and federatedTokenFilePath are required parameters.
2164
- In DefaultAzureCredential and ManagedIdentityCredential, these can be provided as environment variables -
2165
- "AZURE_TENANT_ID",
2166
- "AZURE_CLIENT_ID",
2167
- "AZURE_FEDERATED_TOKEN_FILE". See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/workloadidentitycredential/troubleshoot`;
2168
- logger$g.info(errorMessage);
2169
- throw new CredentialUnavailableError(errorMessage);
2170
- }
2171
- logger$g.info("Invoking getToken() of Client Assertion Credential");
2172
- return this.client.getToken(scopes, options);
2173
- }
2174
- async readFileContents() {
2175
- // Cached assertions expire after 5 minutes
2176
- if (this.cacheDate !== undefined && Date.now() - this.cacheDate >= 1000 * 60 * 5) {
2177
- this.azureFederatedTokenFileContent = undefined;
2178
- }
2179
- if (!this.federatedTokenFilePath) {
2180
- throw new CredentialUnavailableError(`${credentialName$4}: is unavailable. Invalid file path provided ${this.federatedTokenFilePath}.`);
2181
- }
2182
- if (!this.azureFederatedTokenFileContent) {
2183
- const file = await promises.readFile(this.federatedTokenFilePath, "utf8");
2184
- const value = file.trim();
2185
- if (!value) {
2186
- throw new CredentialUnavailableError(`${credentialName$4}: is unavailable. No content on the file ${this.federatedTokenFilePath}.`);
2187
- }
2188
- else {
2189
- this.azureFederatedTokenFileContent = value;
2190
- this.cacheDate = Date.now();
2191
- }
2192
- }
2193
- return this.azureFederatedTokenFileContent;
2194
- }
2195
- }
2196
-
2197
- // Copyright (c) Microsoft Corporation.
2198
- // Licensed under the MIT License.
2199
- const msiName = "ManagedIdentityCredential - Token Exchange";
2200
- const logger$f = credentialLogger(msiName);
2201
- /**
2202
- * Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.
2203
- */
2204
- const tokenExchangeMsi = {
2205
- name: "tokenExchangeMsi",
2206
- async isAvailable({ clientId }) {
2207
- const env = process.env;
2208
- const result = Boolean((clientId || env.AZURE_CLIENT_ID) &&
2209
- env.AZURE_TENANT_ID &&
2210
- process.env.AZURE_FEDERATED_TOKEN_FILE);
2211
- if (!result) {
2212
- logger$f.info(`${msiName}: Unavailable. The environment variables needed are: AZURE_CLIENT_ID (or the client ID sent through the parameters), AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE`);
2213
- }
2214
- return result;
2215
- },
2216
- async getToken(configuration, getTokenOptions = {}) {
2217
- const { scopes, clientId } = configuration;
2218
- const identityClientTokenCredentialOptions = {};
2219
- const workloadIdentityCredential = new WorkloadIdentityCredential(Object.assign(Object.assign({ clientId, tenantId: process.env.AZURE_TENANT_ID, tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE }, identityClientTokenCredentialOptions), { disableInstanceDiscovery: true }));
2220
- return workloadIdentityCredential.getToken(scopes, getTokenOptions);
2221
- },
2222
- };
2223
-
2224
- // Copyright (c) Microsoft Corporation.
2225
- // Licensed under the MIT License.
2226
- const logger$e = credentialLogger("ManagedIdentityCredential(MSAL)");
2227
- class MsalMsiProvider {
2228
- constructor(clientIdOrOptions, options = {}) {
2229
- var _a, _b;
2230
- this.msiRetryConfig = {
2231
- maxRetries: 5,
2232
- startDelayInMs: 800,
2233
- intervalIncrement: 2,
2234
- };
2235
- let _options = {};
2236
- if (typeof clientIdOrOptions === "string") {
2237
- this.clientId = clientIdOrOptions;
2238
- _options = options;
2239
- }
2240
- else {
2241
- this.clientId = clientIdOrOptions === null || clientIdOrOptions === void 0 ? void 0 : clientIdOrOptions.clientId;
2242
- _options = clientIdOrOptions !== null && clientIdOrOptions !== void 0 ? clientIdOrOptions : {};
2243
- }
2244
- this.resourceId = _options === null || _options === void 0 ? void 0 : _options.resourceId;
2245
- this.objectId = _options === null || _options === void 0 ? void 0 : _options.objectId;
2246
- // For JavaScript users.
2247
- const providedIds = [this.clientId, this.resourceId, this.objectId].filter(Boolean);
2248
- if (providedIds.length > 1) {
2249
- throw new Error(`ManagedIdentityCredential: only one of 'clientId', 'resourceId', or 'objectId' can be provided. Received values: ${JSON.stringify({ clientId: this.clientId, resourceId: this.resourceId, objectId: this.objectId })}`);
2250
- }
2251
- // ManagedIdentity uses http for local requests
2252
- _options.allowInsecureConnection = true;
2253
- if (((_a = _options === null || _options === void 0 ? void 0 : _options.retryOptions) === null || _a === void 0 ? void 0 : _a.maxRetries) !== undefined) {
2254
- this.msiRetryConfig.maxRetries = _options.retryOptions.maxRetries;
2255
- }
2256
- this.identityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { additionalPolicies: [{ policy: imdsRetryPolicy(this.msiRetryConfig), position: "perCall" }] }));
2257
- this.managedIdentityApp = new msalCommon.ManagedIdentityApplication({
2258
- managedIdentityIdParams: {
2259
- userAssignedClientId: this.clientId,
2260
- userAssignedResourceId: this.resourceId,
2261
- userAssignedObjectId: this.objectId,
2262
- },
2263
- system: {
2264
- // todo: proxyUrl?
2265
- disableInternalRetries: true,
2266
- networkClient: this.identityClient,
2267
- loggerOptions: {
2268
- logLevel: getMSALLogLevel(logger$m.getLogLevel()),
2269
- piiLoggingEnabled: (_b = options.loggingOptions) === null || _b === void 0 ? void 0 : _b.enableUnsafeSupportLogging,
2270
- loggerCallback: defaultLoggerCallback(logger$e),
2271
- },
2272
- },
2273
- });
2274
- this.isAvailableIdentityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { retryOptions: {
2275
- maxRetries: 0,
2276
- } }));
2277
- // CloudShell MSI will ignore any user-assigned identity passed as parameters. To avoid confusion, we prevent this from happening as early as possible.
2278
- if (this.managedIdentityApp.getManagedIdentitySource() === "CloudShell") {
2279
- if (this.clientId || this.resourceId || this.objectId) {
2280
- logger$e.warning(`CloudShell MSI detected with user-provided IDs - throwing. Received values: ${JSON.stringify({
2281
- clientId: this.clientId,
2282
- resourceId: this.resourceId,
2283
- objectId: this.objectId,
2284
- })}.`);
2285
- throw new CredentialUnavailableError("ManagedIdentityCredential: Specifying a user-assigned managed identity is not supported for CloudShell at runtime. When using Managed Identity in CloudShell, omit the clientId, resourceId, and objectId parameters.");
2286
- }
2287
- }
2288
- }
2289
- /**
2290
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
2291
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
2292
- * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
2293
- *
2294
- * @param scopes - The list of scopes for which the token will have access.
2295
- * @param options - The options used to configure any requests this
2296
- * TokenCredential implementation might make.
2297
- */
2298
- async getToken(scopes, options = {}) {
2299
- logger$e.getToken.info("Using the MSAL provider for Managed Identity.");
2300
- const resource = mapScopesToResource(scopes);
2301
- if (!resource) {
2302
- throw new CredentialUnavailableError(`ManagedIdentityCredential: Multiple scopes are not supported. Scopes: ${JSON.stringify(scopes)}`);
2303
- }
2304
- return tracingClient.withSpan("ManagedIdentityCredential.getToken", options, async () => {
2305
- var _a;
2306
- try {
2307
- const isTokenExchangeMsi = await tokenExchangeMsi.isAvailable({
2308
- scopes,
2309
- clientId: this.clientId,
2310
- getTokenOptions: options,
2311
- identityClient: this.identityClient,
2312
- resourceId: this.resourceId,
2313
- });
2314
- // Most scenarios are handled by MSAL except for two:
2315
- // AKS pod identity - MSAL does not implement the token exchange flow.
2316
- // IMDS Endpoint probing - MSAL does not do any probing before trying to get a token.
2317
- // As a DefaultAzureCredential optimization we probe the IMDS endpoint with a short timeout and no retries before actually trying to get a token
2318
- // We will continue to implement these features in the Identity library.
2319
- const identitySource = this.managedIdentityApp.getManagedIdentitySource();
2320
- const isImdsMsi = identitySource === "DefaultToImds" || identitySource === "Imds"; // Neither actually checks that IMDS endpoint is available, just that it's the source the MSAL _would_ try to use.
2321
- logger$e.getToken.info(`MSAL Identity source: ${identitySource}`);
2322
- if (isTokenExchangeMsi) {
2323
- // In the AKS scenario we will use the existing tokenExchangeMsi indefinitely.
2324
- logger$e.getToken.info("Using the token exchange managed identity.");
2325
- const result = await tokenExchangeMsi.getToken({
2326
- scopes,
2327
- clientId: this.clientId,
2328
- identityClient: this.identityClient,
2329
- retryConfig: this.msiRetryConfig,
2330
- resourceId: this.resourceId,
2331
- });
2332
- if (result === null) {
2333
- throw new CredentialUnavailableError("Attempted to use the token exchange managed identity, but received a null response.");
2334
- }
2335
- return result;
2336
- }
2337
- else if (isImdsMsi) {
2338
- // In the IMDS scenario we will probe the IMDS endpoint to ensure it's available before trying to get a token.
2339
- // If the IMDS endpoint is not available and this is the source that MSAL will use, we will fail-fast with an error that tells DAC to move to the next credential.
2340
- logger$e.getToken.info("Using the IMDS endpoint to probe for availability.");
2341
- const isAvailable = await imdsMsi.isAvailable({
2342
- scopes,
2343
- clientId: this.clientId,
2344
- getTokenOptions: options,
2345
- identityClient: this.isAvailableIdentityClient,
2346
- resourceId: this.resourceId,
2347
- });
2348
- if (!isAvailable) {
2349
- throw new CredentialUnavailableError(`Attempted to use the IMDS endpoint, but it is not available.`);
2350
- }
2351
- }
2352
- // If we got this far, it means:
2353
- // - This is not a tokenExchangeMsi,
2354
- // - We already probed for IMDS endpoint availability and failed-fast if it's unreachable.
2355
- // We can proceed normally by calling MSAL for a token.
2356
- logger$e.getToken.info("Calling into MSAL for managed identity token.");
2357
- const token = await this.managedIdentityApp.acquireToken({
2358
- resource,
2359
- });
2360
- this.ensureValidMsalToken(scopes, token, options);
2361
- logger$e.getToken.info(formatSuccess(scopes));
2362
- return {
2363
- expiresOnTimestamp: token.expiresOn.getTime(),
2364
- token: token.accessToken,
2365
- refreshAfterTimestamp: (_a = token.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
2366
- tokenType: "Bearer",
2367
- };
2368
- }
2369
- catch (err) {
2370
- logger$e.getToken.error(formatError(scopes, err));
2371
- // AuthenticationRequiredError described as Error to enforce authentication after trying to retrieve a token silently.
2372
- // TODO: why would this _ever_ happen considering we're not trying the silent request in this flow?
2373
- if (err.name === "AuthenticationRequiredError") {
2374
- throw err;
2375
- }
2376
- if (isNetworkError(err)) {
2377
- throw new CredentialUnavailableError(`ManagedIdentityCredential: Network unreachable. Message: ${err.message}`, { cause: err });
2378
- }
2379
- throw new CredentialUnavailableError(`ManagedIdentityCredential: Authentication failed. Message ${err.message}`, { cause: err });
2380
- }
2381
- });
2382
- }
2383
- /**
2384
- * Ensures the validity of the MSAL token
2385
- */
2386
- ensureValidMsalToken(scopes, msalToken, getTokenOptions) {
2387
- const createError = (message) => {
2388
- logger$e.getToken.info(message);
2389
- return new AuthenticationRequiredError({
2390
- scopes: Array.isArray(scopes) ? scopes : [scopes],
2391
- getTokenOptions,
2392
- message,
2393
- });
2394
- };
2395
- if (!msalToken) {
2396
- throw createError("No response.");
2397
- }
2398
- if (!msalToken.expiresOn) {
2399
- throw createError(`Response had no "expiresOn" property.`);
2400
- }
2401
- if (!msalToken.accessToken) {
2402
- throw createError(`Response had no "accessToken" property.`);
2403
- }
2404
- }
2405
- }
2406
- function isNetworkError(err) {
2407
- // MSAL error
2408
- if (err.errorCode === "network_error") {
2409
- return true;
2410
- }
2411
- // Probe errors
2412
- if (err.code === "ENETUNREACH" || err.code === "EHOSTUNREACH") {
2413
- return true;
2414
- }
2415
- // This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network" or "A socket operation was attempted to an unreachable host"
2416
- // rather than just timing out, as expected.
2417
- if (err.statusCode === 403 || err.code === 403) {
2418
- if (err.message.includes("unreachable")) {
2419
- return true;
2420
- }
2421
- }
2422
- return false;
2423
- }
2424
-
2425
- // Copyright (c) Microsoft Corporation.
2426
- // Licensed under the MIT License.
2427
- /**
2428
- * Attempts authentication using a managed identity available at the deployment environment.
2429
- * This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
2430
- * Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
2431
- *
2432
- * More information about configuring managed identities can be found here:
2433
- * https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
2434
- */
2435
- class ManagedIdentityCredential {
2436
- /**
2437
- * @internal
2438
- * @hidden
2439
- */
2440
- constructor(clientIdOrOptions, options) {
2441
- // https://github.com/Azure/azure-sdk-for-js/issues/30189
2442
- // If needed, you may release a hotfix to quickly rollback to the legacy implementation by changing the following line to:
2443
- // this.implProvider = new LegacyMsiProvider(clientIdOrOptions, options);
2444
- // Once stabilized, you can remove the legacy implementation and inline the msalMsiProvider code here as a drop-in replacement.
2445
- this.implProvider = new MsalMsiProvider(clientIdOrOptions, options);
2446
- }
2447
- /**
2448
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
2449
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
2450
- * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
2451
- *
2452
- * @param scopes - The list of scopes for which the token will have access.
2453
- * @param options - The options used to configure any requests this
2454
- * TokenCredential implementation might make.
2455
- */
2456
- async getToken(scopes, options) {
2457
- return this.implProvider.getToken(scopes, options);
2458
- }
2459
- }
2460
-
2461
- // Copyright (c) Microsoft Corporation.
2462
- // Licensed under the MIT License.
2463
- /**
2464
- * Ensures the scopes value is an array.
2465
- * @internal
2466
- */
2467
- function ensureScopes(scopes) {
2468
- return Array.isArray(scopes) ? scopes : [scopes];
2469
- }
2470
- /**
2471
- * Throws if the received scope is not valid.
2472
- * @internal
2473
- */
2474
- function ensureValidScopeForDevTimeCreds(scope, logger) {
2475
- if (!scope.match(/^[0-9a-zA-Z-_.:/]+$/)) {
2476
- const error = new Error("Invalid scope was specified by the user or calling client");
2477
- logger.getToken.info(formatError(scope, error));
2478
- throw error;
2479
- }
2480
- }
2481
- /**
2482
- * Returns the resource out of a scope.
2483
- * @internal
2484
- */
2485
- function getScopeResource(scope) {
2486
- return scope.replace(/\/.default$/, "");
2487
- }
2488
-
2489
- // Copyright (c) Microsoft Corporation.
2490
- // Licensed under the MIT License.
2491
- /**
2492
- * Mockable reference to the CLI credential cliCredentialFunctions
2493
- * @internal
2494
- */
2495
- const cliCredentialInternals = {
2496
- /**
2497
- * @internal
2498
- */
2499
- getSafeWorkingDir() {
2500
- if (process.platform === "win32") {
2501
- if (!process.env.SystemRoot) {
2502
- throw new Error("Azure CLI credential expects a 'SystemRoot' environment variable");
2503
- }
2504
- return process.env.SystemRoot;
2505
- }
2506
- else {
2507
- return "/bin";
2508
- }
2509
- },
2510
- /**
2511
- * Gets the access token from Azure CLI
2512
- * @param resource - The resource to use when getting the token
2513
- * @internal
2514
- */
2515
- async getAzureCliAccessToken(resource, tenantId, timeout) {
2516
- let tenantSection = [];
2517
- if (tenantId) {
2518
- tenantSection = ["--tenant", tenantId];
2519
- }
2520
- return new Promise((resolve, reject) => {
2521
- try {
2522
- child_process.execFile("az", [
2523
- "account",
2524
- "get-access-token",
2525
- "--output",
2526
- "json",
2527
- "--resource",
2528
- resource,
2529
- ...tenantSection,
2530
- ], { cwd: cliCredentialInternals.getSafeWorkingDir(), shell: true, timeout }, (error, stdout, stderr) => {
2531
- resolve({ stdout: stdout, stderr: stderr, error });
2532
- });
2533
- }
2534
- catch (err) {
2535
- reject(err);
2536
- }
2537
- });
2538
- },
2539
- };
2540
- const logger$d = credentialLogger("AzureCliCredential");
2541
- /**
2542
- * This credential will use the currently logged-in user login information
2543
- * via the Azure CLI ('az') commandline tool.
2544
- * To do so, it will read the user access token and expire time
2545
- * with Azure CLI command "az account get-access-token".
2546
- */
2547
- class AzureCliCredential {
2548
- /**
2549
- * Creates an instance of the {@link AzureCliCredential}.
2550
- *
2551
- * To use this credential, ensure that you have already logged
2552
- * in via the 'az' tool using the command "az login" from the commandline.
2553
- *
2554
- * @param options - Options, to optionally allow multi-tenant requests.
2555
- */
2556
- constructor(options) {
2557
- if (options === null || options === void 0 ? void 0 : options.tenantId) {
2558
- checkTenantId(logger$d, options === null || options === void 0 ? void 0 : options.tenantId);
2559
- this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
2560
- }
2561
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
2562
- this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
2563
- }
2564
- /**
2565
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
2566
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
2567
- *
2568
- * @param scopes - The list of scopes for which the token will have access.
2569
- * @param options - The options used to configure any requests this
2570
- * TokenCredential implementation might make.
2571
- */
2572
- async getToken(scopes, options = {}) {
2573
- const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds);
2574
- if (tenantId) {
2575
- checkTenantId(logger$d, tenantId);
2576
- }
2577
- const scope = typeof scopes === "string" ? scopes : scopes[0];
2578
- logger$d.getToken.info(`Using the scope ${scope}`);
2579
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
2580
- var _a, _b, _c, _d;
2581
- try {
2582
- ensureValidScopeForDevTimeCreds(scope, logger$d);
2583
- const resource = getScopeResource(scope);
2584
- const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId, this.timeout);
2585
- const specificScope = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("(.*)az login --scope(.*)");
2586
- const isLoginError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("(.*)az login(.*)")) && !specificScope;
2587
- const isNotInstallError = ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.match("az:(.*)not found")) || ((_d = obj.stderr) === null || _d === void 0 ? void 0 : _d.startsWith("'az' is not recognized"));
2588
- if (isNotInstallError) {
2589
- const error = new CredentialUnavailableError("Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.");
2590
- logger$d.getToken.info(formatError(scopes, error));
2591
- throw error;
2592
- }
2593
- if (isLoginError) {
2594
- const error = new CredentialUnavailableError("Please run 'az login' from a command prompt to authenticate before using this credential.");
2595
- logger$d.getToken.info(formatError(scopes, error));
2596
- throw error;
2597
- }
2598
- try {
2599
- const responseData = obj.stdout;
2600
- const response = this.parseRawResponse(responseData);
2601
- logger$d.getToken.info(formatSuccess(scopes));
2602
- return response;
2603
- }
2604
- catch (e) {
2605
- if (obj.stderr) {
2606
- throw new CredentialUnavailableError(obj.stderr);
2607
- }
2608
- throw e;
2609
- }
2610
- }
2611
- catch (err) {
2612
- const error = err.name === "CredentialUnavailableError"
2613
- ? err
2614
- : new CredentialUnavailableError(err.message || "Unknown error while trying to retrieve the access token");
2615
- logger$d.getToken.info(formatError(scopes, error));
2616
- throw error;
2617
- }
2618
- });
2619
- }
2620
- /**
2621
- * Parses the raw JSON response from the Azure CLI into a usable AccessToken object
2622
- *
2623
- * @param rawResponse - The raw JSON response from the Azure CLI
2624
- * @returns An access token with the expiry time parsed from the raw response
2625
- *
2626
- * The expiryTime of the credential's access token, in milliseconds, is calculated as follows:
2627
- *
2628
- * When available, expires_on (introduced in Azure CLI v2.54.0) will be preferred. Otherwise falls back to expiresOn.
2629
- */
2630
- parseRawResponse(rawResponse) {
2631
- const response = JSON.parse(rawResponse);
2632
- const token = response.accessToken;
2633
- // if available, expires_on will be a number representing seconds since epoch.
2634
- // ensure it's a number or NaN
2635
- let expiresOnTimestamp = Number.parseInt(response.expires_on, 10) * 1000;
2636
- if (!isNaN(expiresOnTimestamp)) {
2637
- logger$d.getToken.info("expires_on is available and is valid, using it");
2638
- return {
2639
- token,
2640
- expiresOnTimestamp,
2641
- tokenType: "Bearer",
2642
- };
2643
- }
2644
- // fallback to the older expiresOn - an RFC3339 date string
2645
- expiresOnTimestamp = new Date(response.expiresOn).getTime();
2646
- // ensure expiresOn is well-formatted
2647
- if (isNaN(expiresOnTimestamp)) {
2648
- throw new CredentialUnavailableError(`Unexpected response from Azure CLI when getting token. Expected "expiresOn" to be a RFC3339 date string. Got: "${response.expiresOn}"`);
2649
- }
2650
- return {
2651
- token,
2652
- expiresOnTimestamp,
2653
- tokenType: "Bearer",
2654
- };
2655
- }
2656
- }
2657
-
2658
- // Copyright (c) Microsoft Corporation.
2659
- // Licensed under the MIT License.
2660
- /**
2661
- * Mockable reference to the Developer CLI credential cliCredentialFunctions
2662
- * @internal
2663
- */
2664
- const developerCliCredentialInternals = {
2665
- /**
2666
- * @internal
2667
- */
2668
- getSafeWorkingDir() {
2669
- if (process.platform === "win32") {
2670
- if (!process.env.SystemRoot) {
2671
- throw new Error("Azure Developer CLI credential expects a 'SystemRoot' environment variable");
2672
- }
2673
- return process.env.SystemRoot;
2674
- }
2675
- else {
2676
- return "/bin";
2677
- }
2678
- },
2679
- /**
2680
- * Gets the access token from Azure Developer CLI
2681
- * @param scopes - The scopes to use when getting the token
2682
- * @internal
2683
- */
2684
- async getAzdAccessToken(scopes, tenantId, timeout) {
2685
- let tenantSection = [];
2686
- if (tenantId) {
2687
- tenantSection = ["--tenant-id", tenantId];
2688
- }
2689
- return new Promise((resolve, reject) => {
2690
- try {
2691
- child_process.execFile("azd", [
2692
- "auth",
2693
- "token",
2694
- "--output",
2695
- "json",
2696
- ...scopes.reduce((previous, current) => previous.concat("--scope", current), []),
2697
- ...tenantSection,
2698
- ], {
2699
- cwd: developerCliCredentialInternals.getSafeWorkingDir(),
2700
- timeout,
2701
- }, (error, stdout, stderr) => {
2702
- resolve({ stdout, stderr, error });
2703
- });
2704
- }
2705
- catch (err) {
2706
- reject(err);
2707
- }
2708
- });
2709
- },
2710
- };
2711
- const logger$c = credentialLogger("AzureDeveloperCliCredential");
2712
- /**
2713
- * Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
2714
- * resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
2715
- * to Azure developers. It allows users to authenticate as a user and/or a service principal against
2716
- * <a href="https://learn.microsoft.com/entra/fundamentals/">Microsoft Entra ID</a>. The
2717
- * AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
2718
- * the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
2719
- * service principal and executes an Azure CLI command underneath to authenticate the application against
2720
- * Microsoft Entra ID.
2721
- *
2722
- * <h2> Configure AzureDeveloperCliCredential </h2>
2723
- *
2724
- * To use this credential, the developer needs to authenticate locally in Azure Developer CLI using one of the
2725
- * commands below:
2726
- *
2727
- * <ol>
2728
- * <li>Run "azd auth login" in Azure Developer CLI to authenticate interactively as a user.</li>
2729
- * <li>Run "azd auth login --client-id clientID --client-secret clientSecret
2730
- * --tenant-id tenantID" to authenticate as a service principal.</li>
2731
- * </ol>
2732
- *
2733
- * You may need to repeat this process after a certain time period, depending on the refresh token validity in your
2734
- * organization. Generally, the refresh token validity period is a few weeks to a few months.
2735
- * AzureDeveloperCliCredential will prompt you to sign in again.
2736
- */
2737
- class AzureDeveloperCliCredential {
2738
- /**
2739
- * Creates an instance of the {@link AzureDeveloperCliCredential}.
2740
- *
2741
- * To use this credential, ensure that you have already logged
2742
- * in via the 'azd' tool using the command "azd auth login" from the commandline.
2743
- *
2744
- * @param options - Options, to optionally allow multi-tenant requests.
2745
- */
2746
- constructor(options) {
2747
- if (options === null || options === void 0 ? void 0 : options.tenantId) {
2748
- checkTenantId(logger$c, options === null || options === void 0 ? void 0 : options.tenantId);
2749
- this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
2750
- }
2751
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
2752
- this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
2753
- }
2754
- /**
2755
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
2756
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
2757
- *
2758
- * @param scopes - The list of scopes for which the token will have access.
2759
- * @param options - The options used to configure any requests this
2760
- * TokenCredential implementation might make.
2761
- */
2762
- async getToken(scopes, options = {}) {
2763
- const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds);
2764
- if (tenantId) {
2765
- checkTenantId(logger$c, tenantId);
2766
- }
2767
- let scopeList;
2768
- if (typeof scopes === "string") {
2769
- scopeList = [scopes];
2770
- }
2771
- else {
2772
- scopeList = scopes;
2773
- }
2774
- logger$c.getToken.info(`Using the scopes ${scopes}`);
2775
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
2776
- var _a, _b, _c, _d;
2777
- try {
2778
- scopeList.forEach((scope) => {
2779
- ensureValidScopeForDevTimeCreds(scope, logger$c);
2780
- });
2781
- const obj = await developerCliCredentialInternals.getAzdAccessToken(scopeList, tenantId, this.timeout);
2782
- const isNotLoggedInError = ((_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("not logged in, run `azd login` to login")) ||
2783
- ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("not logged in, run `azd auth login` to login"));
2784
- const isNotInstallError = ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.match("azd:(.*)not found")) ||
2785
- ((_d = obj.stderr) === null || _d === void 0 ? void 0 : _d.startsWith("'azd' is not recognized"));
2786
- if (isNotInstallError || (obj.error && obj.error.code === "ENOENT")) {
2787
- const error = new CredentialUnavailableError("Azure Developer CLI couldn't be found. To mitigate this issue, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.");
2788
- logger$c.getToken.info(formatError(scopes, error));
2789
- throw error;
2790
- }
2791
- if (isNotLoggedInError) {
2792
- const error = new CredentialUnavailableError("Please run 'azd auth login' from a command prompt to authenticate before using this credential. For more information, see the troubleshooting guidelines at https://aka.ms/azsdk/js/identity/azdevclicredential/troubleshoot.");
2793
- logger$c.getToken.info(formatError(scopes, error));
2794
- throw error;
2795
- }
2796
- try {
2797
- const resp = JSON.parse(obj.stdout);
2798
- logger$c.getToken.info(formatSuccess(scopes));
2799
- return {
2800
- token: resp.token,
2801
- expiresOnTimestamp: new Date(resp.expiresOn).getTime(),
2802
- tokenType: "Bearer",
2803
- };
2804
- }
2805
- catch (e) {
2806
- if (obj.stderr) {
2807
- throw new CredentialUnavailableError(obj.stderr);
2808
- }
2809
- throw e;
2810
- }
2811
- }
2812
- catch (err) {
2813
- const error = err.name === "CredentialUnavailableError"
2814
- ? err
2815
- : new CredentialUnavailableError(err.message || "Unknown error while trying to retrieve the access token");
2816
- logger$c.getToken.info(formatError(scopes, error));
2817
- throw error;
2818
- }
2819
- });
2820
- }
2821
- }
2822
-
2823
- // Copyright (c) Microsoft Corporation.
2824
- // Licensed under the MIT License.
2825
- /**
2826
- * Easy to mock childProcess utils.
2827
- * @internal
2828
- */
2829
- const processUtils = {
2830
- /**
2831
- * Promisifying childProcess.execFile
2832
- * @internal
2833
- */
2834
- execFile(file, params, options) {
2835
- return new Promise((resolve, reject) => {
2836
- child_process__namespace.execFile(file, params, options, (error, stdout, stderr) => {
2837
- if (Buffer.isBuffer(stdout)) {
2838
- stdout = stdout.toString("utf8");
2839
- }
2840
- if (Buffer.isBuffer(stderr)) {
2841
- stderr = stderr.toString("utf8");
2842
- }
2843
- if (stderr || error) {
2844
- reject(stderr ? new Error(stderr) : error);
2845
- }
2846
- else {
2847
- resolve(stdout);
2848
- }
2849
- });
2850
- });
2851
- },
2852
- };
2853
-
2854
- // Copyright (c) Microsoft Corporation.
2855
- // Licensed under the MIT License.
2856
- const logger$b = credentialLogger("AzurePowerShellCredential");
2857
- const isWindows = process.platform === "win32";
2858
- /**
2859
- * Returns a platform-appropriate command name by appending ".exe" on Windows.
2860
- *
2861
- * @internal
2862
- */
2863
- function formatCommand(commandName) {
2864
- if (isWindows) {
2865
- return `${commandName}.exe`;
2866
- }
2867
- else {
2868
- return commandName;
2869
- }
2870
- }
2871
- /**
2872
- * Receives a list of commands to run, executes them, then returns the outputs.
2873
- * If anything fails, an error is thrown.
2874
- * @internal
2875
- */
2876
- async function runCommands(commands, timeout) {
2877
- const results = [];
2878
- for (const command of commands) {
2879
- const [file, ...parameters] = command;
2880
- const result = (await processUtils.execFile(file, parameters, {
2881
- encoding: "utf8",
2882
- timeout,
2883
- }));
2884
- results.push(result);
2885
- }
2886
- return results;
2887
- }
2888
- /**
2889
- * Known PowerShell errors
2890
- * @internal
2891
- */
2892
- const powerShellErrors = {
2893
- login: "Run Connect-AzAccount to login",
2894
- installed: "The specified module 'Az.Accounts' with version '2.2.0' was not loaded because no valid module file was found in any module directory",
2895
- };
2896
- /**
2897
- * Messages to use when throwing in this credential.
2898
- * @internal
2899
- */
2900
- const powerShellPublicErrorMessages = {
2901
- login: "Please run 'Connect-AzAccount' from PowerShell to authenticate before using this credential.",
2902
- installed: `The 'Az.Account' module >= 2.2.0 is not installed. Install the Azure Az PowerShell module with: "Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force".`,
2903
- troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot.`,
2904
- };
2905
- // PowerShell Azure User not logged in error check.
2906
- const isLoginError = (err) => err.message.match(`(.*)${powerShellErrors.login}(.*)`);
2907
- // Az Module not Installed in Azure PowerShell check.
2908
- const isNotInstalledError = (err) => err.message.match(powerShellErrors.installed);
2909
- /**
2910
- * The PowerShell commands to be tried, in order.
2911
- *
2912
- * @internal
2913
- */
2914
- const commandStack = [formatCommand("pwsh")];
2915
- if (isWindows) {
2916
- commandStack.push(formatCommand("powershell"));
2917
- }
2918
- /**
2919
- * This credential will use the currently logged-in user information from the
2920
- * Azure PowerShell module. To do so, it will read the user access token and
2921
- * expire time with Azure PowerShell command `Get-AzAccessToken -ResourceUrl {ResourceScope}`
2922
- */
2923
- class AzurePowerShellCredential {
2924
- /**
2925
- * Creates an instance of the {@link AzurePowerShellCredential}.
2926
- *
2927
- * To use this credential:
2928
- * - Install the Azure Az PowerShell module with:
2929
- * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.
2930
- * - You have already logged in to Azure PowerShell using the command
2931
- * `Connect-AzAccount` from the command line.
2932
- *
2933
- * @param options - Options, to optionally allow multi-tenant requests.
2934
- */
2935
- constructor(options) {
2936
- if (options === null || options === void 0 ? void 0 : options.tenantId) {
2937
- checkTenantId(logger$b, options === null || options === void 0 ? void 0 : options.tenantId);
2938
- this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
2939
- }
2940
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
2941
- this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
2942
- }
2943
- /**
2944
- * Gets the access token from Azure PowerShell
2945
- * @param resource - The resource to use when getting the token
2946
- */
2947
- async getAzurePowerShellAccessToken(resource, tenantId, timeout) {
2948
- // Clone the stack to avoid mutating it while iterating
2949
- for (const powerShellCommand of [...commandStack]) {
2950
- try {
2951
- await runCommands([[powerShellCommand, "/?"]], timeout);
2952
- }
2953
- catch (e) {
2954
- // Remove this credential from the original stack so that we don't try it again.
2955
- commandStack.shift();
2956
- continue;
2957
- }
2958
- const results = await runCommands([
2959
- [
2960
- powerShellCommand,
2961
- "-NoProfile",
2962
- "-NonInteractive",
2963
- "-Command",
2964
- `
2965
- $tenantId = "${tenantId !== null && tenantId !== void 0 ? tenantId : ""}"
2966
- $m = Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru
2967
- $useSecureString = $m.Version -ge [version]'2.17.0'
2968
-
2969
- $params = @{
2970
- ResourceUrl = "${resource}"
2971
- }
2972
-
2973
- if ($tenantId.Length -gt 0) {
2974
- $params["TenantId"] = $tenantId
2975
- }
2976
-
2977
- if ($useSecureString) {
2978
- $params["AsSecureString"] = $true
2979
- }
2980
-
2981
- $token = Get-AzAccessToken @params
2982
-
2983
- $result = New-Object -TypeName PSObject
2984
- $result | Add-Member -MemberType NoteProperty -Name ExpiresOn -Value $token.ExpiresOn
2985
- if ($useSecureString) {
2986
- $result | Add-Member -MemberType NoteProperty -Name Token -Value (ConvertFrom-SecureString -AsPlainText $token.Token)
2987
- } else {
2988
- $result | Add-Member -MemberType NoteProperty -Name Token -Value $token.Token
2989
- }
2990
-
2991
- Write-Output (ConvertTo-Json $result)
2992
- `,
2993
- ],
2994
- ]);
2995
- const result = results[0];
2996
- return parseJsonToken(result);
2997
- }
2998
- throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
2999
- }
3000
- /**
3001
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3002
- * If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
3003
- *
3004
- * @param scopes - The list of scopes for which the token will have access.
3005
- * @param options - The options used to configure any requests this TokenCredential implementation might make.
3006
- */
3007
- async getToken(scopes, options = {}) {
3008
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
3009
- const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds);
3010
- const scope = typeof scopes === "string" ? scopes : scopes[0];
3011
- if (tenantId) {
3012
- checkTenantId(logger$b, tenantId);
3013
- }
3014
- try {
3015
- ensureValidScopeForDevTimeCreds(scope, logger$b);
3016
- logger$b.getToken.info(`Using the scope ${scope}`);
3017
- const resource = getScopeResource(scope);
3018
- const response = await this.getAzurePowerShellAccessToken(resource, tenantId, this.timeout);
3019
- logger$b.getToken.info(formatSuccess(scopes));
3020
- return {
3021
- token: response.Token,
3022
- expiresOnTimestamp: new Date(response.ExpiresOn).getTime(),
3023
- tokenType: "Bearer",
3024
- };
3025
- }
3026
- catch (err) {
3027
- if (isNotInstalledError(err)) {
3028
- const error = new CredentialUnavailableError(powerShellPublicErrorMessages.installed);
3029
- logger$b.getToken.info(formatError(scope, error));
3030
- throw error;
3031
- }
3032
- else if (isLoginError(err)) {
3033
- const error = new CredentialUnavailableError(powerShellPublicErrorMessages.login);
3034
- logger$b.getToken.info(formatError(scope, error));
3035
- throw error;
3036
- }
3037
- const error = new CredentialUnavailableError(`${err}. ${powerShellPublicErrorMessages.troubleshoot}`);
3038
- logger$b.getToken.info(formatError(scope, error));
3039
- throw error;
3040
- }
3041
- });
3042
- }
3043
- }
3044
- /**
3045
- *
3046
- * @internal
3047
- */
3048
- async function parseJsonToken(result) {
3049
- const jsonRegex = /{[^{}]*}/g;
3050
- const matches = result.match(jsonRegex);
3051
- let resultWithoutToken = result;
3052
- if (matches) {
3053
- try {
3054
- for (const item of matches) {
3055
- try {
3056
- const jsonContent = JSON.parse(item);
3057
- if (jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.Token) {
3058
- resultWithoutToken = resultWithoutToken.replace(item, "");
3059
- if (resultWithoutToken) {
3060
- logger$b.getToken.warning(resultWithoutToken);
3061
- }
3062
- return jsonContent;
3063
- }
3064
- }
3065
- catch (e) {
3066
- continue;
3067
- }
3068
- }
3069
- }
3070
- catch (e) {
3071
- throw new Error(`Unable to parse the output of PowerShell. Received output: ${result}`);
3072
- }
3073
- }
3074
- throw new Error(`No access token found in the output. Received output: ${result}`);
3075
- }
3076
-
3077
- // Copyright (c) Microsoft Corporation.
3078
- // Licensed under the MIT License.
3079
- /**
3080
- * @internal
3081
- */
3082
- const logger$a = credentialLogger("ChainedTokenCredential");
3083
- /**
3084
- * Enables multiple `TokenCredential` implementations to be tried in order
3085
- * until one of the getToken methods returns an access token.
3086
- */
3087
- class ChainedTokenCredential {
3088
- /**
3089
- * Creates an instance of ChainedTokenCredential using the given credentials.
3090
- *
3091
- * @param sources - `TokenCredential` implementations to be tried in order.
3092
- *
3093
- * Example usage:
3094
- * ```ts snippet:chained_token_credential_example
3095
- * import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";
3096
- *
3097
- * const tenantId = "<tenant-id>";
3098
- * const clientId = "<client-id>";
3099
- * const clientSecret = "<client-secret>";
3100
- * const anotherClientId = "<another-client-id>";
3101
- * const anotherSecret = "<another-client-secret>";
3102
- * const firstCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
3103
- * const secondCredential = new ClientSecretCredential(tenantId, anotherClientId, anotherSecret);
3104
- * const credentialChain = new ChainedTokenCredential(firstCredential, secondCredential);
3105
- * ```
3106
- */
3107
- constructor(...sources) {
3108
- this._sources = [];
3109
- this._sources = sources;
3110
- }
3111
- /**
3112
- * Returns the first access token returned by one of the chained
3113
- * `TokenCredential` implementations. Throws an {@link AggregateAuthenticationError}
3114
- * when one or more credentials throws an {@link AuthenticationError} and
3115
- * no credentials have returned an access token.
3116
- *
3117
- * This method is called automatically by Azure SDK client libraries. You may call this method
3118
- * directly, but you must also handle token caching and token refreshing.
3119
- *
3120
- * @param scopes - The list of scopes for which the token will have access.
3121
- * @param options - The options used to configure any requests this
3122
- * `TokenCredential` implementation might make.
3123
- */
3124
- async getToken(scopes, options = {}) {
3125
- const { token } = await this.getTokenInternal(scopes, options);
3126
- return token;
3127
- }
3128
- async getTokenInternal(scopes, options = {}) {
3129
- let token = null;
3130
- let successfulCredential;
3131
- const errors = [];
3132
- return tracingClient.withSpan("ChainedTokenCredential.getToken", options, async (updatedOptions) => {
3133
- for (let i = 0; i < this._sources.length && token === null; i++) {
3134
- try {
3135
- token = await this._sources[i].getToken(scopes, updatedOptions);
3136
- successfulCredential = this._sources[i];
3137
- }
3138
- catch (err) {
3139
- if (err.name === "CredentialUnavailableError" ||
3140
- err.name === "AuthenticationRequiredError") {
3141
- errors.push(err);
3142
- }
3143
- else {
3144
- logger$a.getToken.info(formatError(scopes, err));
3145
- throw err;
3146
- }
3147
- }
3148
- }
3149
- if (!token && errors.length > 0) {
3150
- const err = new AggregateAuthenticationError(errors, "ChainedTokenCredential authentication failed.");
3151
- logger$a.getToken.info(formatError(scopes, err));
3152
- throw err;
3153
- }
3154
- logger$a.getToken.info(`Result for ${successfulCredential.constructor.name}: ${formatSuccess(scopes)}`);
3155
- if (token === null) {
3156
- throw new CredentialUnavailableError("Failed to retrieve a valid token");
3157
- }
3158
- return { token, successfulCredential };
3159
- });
3160
- }
3161
- }
3162
-
3163
- // Copyright (c) Microsoft Corporation.
3164
- // Licensed under the MIT License.
3165
- const credentialName$3 = "ClientCertificateCredential";
3166
- const logger$9 = credentialLogger(credentialName$3);
3167
- /**
3168
- * Enables authentication to Microsoft Entra ID using a PEM-encoded
3169
- * certificate that is assigned to an App Registration. More information
3170
- * on how to configure certificate authentication can be found here:
3171
- *
3172
- * https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad
3173
- *
3174
- */
3175
- class ClientCertificateCredential {
3176
- constructor(tenantId, clientId, certificatePathOrConfiguration, options = {}) {
3177
- if (!tenantId || !clientId) {
3178
- throw new Error(`${credentialName$3}: tenantId and clientId are required parameters.`);
3179
- }
3180
- this.tenantId = tenantId;
3181
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
3182
- this.sendCertificateChain = options.sendCertificateChain;
3183
- this.certificateConfiguration = Object.assign({}, (typeof certificatePathOrConfiguration === "string"
3184
- ? {
3185
- certificatePath: certificatePathOrConfiguration,
3186
- }
3187
- : certificatePathOrConfiguration));
3188
- const certificate = this.certificateConfiguration.certificate;
3189
- const certificatePath = this.certificateConfiguration.certificatePath;
3190
- if (!this.certificateConfiguration || !(certificate || certificatePath)) {
3191
- throw new Error(`${credentialName$3}: Provide either a PEM certificate in string form, or the path to that certificate in the filesystem. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
3192
- }
3193
- if (certificate && certificatePath) {
3194
- throw new Error(`${credentialName$3}: To avoid unexpected behaviors, providing both the contents of a PEM certificate and the path to a PEM certificate is forbidden. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
3195
- }
3196
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger: logger$9, tokenCredentialOptions: options }));
3197
- }
3198
- /**
3199
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3200
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3201
- *
3202
- * @param scopes - The list of scopes for which the token will have access.
3203
- * @param options - The options used to configure any requests this
3204
- * TokenCredential implementation might make.
3205
- */
3206
- async getToken(scopes, options = {}) {
3207
- return tracingClient.withSpan(`${credentialName$3}.getToken`, options, async (newOptions) => {
3208
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$9);
3209
- const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
3210
- const certificate = await this.buildClientCertificate();
3211
- return this.msalClient.getTokenByClientCertificate(arrayScopes, certificate, newOptions);
3212
- });
3213
- }
3214
- async buildClientCertificate() {
3215
- var _a;
3216
- const parts = await parseCertificate(this.certificateConfiguration, (_a = this.sendCertificateChain) !== null && _a !== void 0 ? _a : false);
3217
- let privateKey;
3218
- if (this.certificateConfiguration.certificatePassword !== undefined) {
3219
- privateKey = crypto.createPrivateKey({
3220
- key: parts.certificateContents,
3221
- passphrase: this.certificateConfiguration.certificatePassword,
3222
- format: "pem",
3223
- })
3224
- .export({
3225
- format: "pem",
3226
- type: "pkcs8",
3227
- })
3228
- .toString();
3229
- }
3230
- else {
3231
- privateKey = parts.certificateContents;
3232
- }
3233
- return {
3234
- thumbprint: parts.thumbprint,
3235
- privateKey,
3236
- x5c: parts.x5c,
3237
- };
3238
- }
3239
- }
3240
- /**
3241
- * Parses a certificate into its relevant parts
3242
- *
3243
- * @param certificateConfiguration - The certificate contents or path to the certificate
3244
- * @param sendCertificateChain - true if the entire certificate chain should be sent for SNI, false otherwise
3245
- * @returns The parsed certificate parts and the certificate contents
3246
- */
3247
- async function parseCertificate(certificateConfiguration, sendCertificateChain) {
3248
- const certificate = certificateConfiguration.certificate;
3249
- const certificatePath = certificateConfiguration.certificatePath;
3250
- const certificateContents = certificate || (await promises.readFile(certificatePath, "utf8"));
3251
- const x5c = sendCertificateChain ? certificateContents : undefined;
3252
- const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/g;
3253
- const publicKeys = [];
3254
- // Match all possible certificates, in the order they are in the file. These will form the chain that is used for x5c
3255
- let match;
3256
- do {
3257
- match = certificatePattern.exec(certificateContents);
3258
- if (match) {
3259
- publicKeys.push(match[3]);
3260
- }
3261
- } while (match);
3262
- if (publicKeys.length === 0) {
3263
- throw new Error("The file at the specified path does not contain a PEM-encoded certificate.");
3264
- }
3265
- const thumbprint = crypto.createHash("sha1")
3266
- .update(Buffer.from(publicKeys[0], "base64"))
3267
- .digest("hex")
3268
- .toUpperCase();
3269
- return {
3270
- certificateContents,
3271
- thumbprint,
3272
- x5c,
3273
- };
3274
- }
3275
-
3276
- // Copyright (c) Microsoft Corporation.
3277
- // Licensed under the MIT License.
3278
- const logger$8 = credentialLogger("ClientSecretCredential");
3279
- /**
3280
- * Enables authentication to Microsoft Entra ID using a client secret
3281
- * that was generated for an App Registration. More information on how
3282
- * to configure a client secret can be found here:
3283
- *
3284
- * https://learn.microsoft.com/entra/identity-platform/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
3285
- *
3286
- */
3287
- class ClientSecretCredential {
3288
- /**
3289
- * Creates an instance of the ClientSecretCredential with the details
3290
- * needed to authenticate against Microsoft Entra ID with a client
3291
- * secret.
3292
- *
3293
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
3294
- * @param clientId - The client (application) ID of an App Registration in the tenant.
3295
- * @param clientSecret - A client secret that was generated for the App Registration.
3296
- * @param options - Options for configuring the client which makes the authentication request.
3297
- */
3298
- constructor(tenantId, clientId, clientSecret, options = {}) {
3299
- if (!tenantId) {
3300
- throw new CredentialUnavailableError("ClientSecretCredential: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
3301
- }
3302
- if (!clientId) {
3303
- throw new CredentialUnavailableError("ClientSecretCredential: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
3304
- }
3305
- if (!clientSecret) {
3306
- throw new CredentialUnavailableError("ClientSecretCredential: clientSecret is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
3307
- }
3308
- this.clientSecret = clientSecret;
3309
- this.tenantId = tenantId;
3310
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
3311
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger: logger$8, tokenCredentialOptions: options }));
3312
- }
3313
- /**
3314
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3315
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3316
- *
3317
- * @param scopes - The list of scopes for which the token will have access.
3318
- * @param options - The options used to configure any requests this
3319
- * TokenCredential implementation might make.
3320
- */
3321
- async getToken(scopes, options = {}) {
3322
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
3323
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$8);
3324
- const arrayScopes = ensureScopes(scopes);
3325
- return this.msalClient.getTokenByClientSecret(arrayScopes, this.clientSecret, newOptions);
3326
- });
3327
- }
3328
- }
3329
-
3330
- // Copyright (c) Microsoft Corporation.
3331
- // Licensed under the MIT License.
3332
- const logger$7 = credentialLogger("UsernamePasswordCredential");
3333
- /**
3334
- * Enables authentication to Microsoft Entra ID with a user's
3335
- * username and password. This credential requires a high degree of
3336
- * trust so you should only use it when other, more secure credential
3337
- * types can't be used.
3338
- */
3339
- class UsernamePasswordCredential {
3340
- /**
3341
- * Creates an instance of the UsernamePasswordCredential with the details
3342
- * needed to authenticate against Microsoft Entra ID with a username
3343
- * and password.
3344
- *
3345
- * @param tenantId - The Microsoft Entra tenant (directory).
3346
- * @param clientId - The client (application) ID of an App Registration in the tenant.
3347
- * @param username - The user account's e-mail address (user name).
3348
- * @param password - The user account's account password
3349
- * @param options - Options for configuring the client which makes the authentication request.
3350
- */
3351
- constructor(tenantId, clientId, username, password, options = {}) {
3352
- if (!tenantId) {
3353
- throw new CredentialUnavailableError("UsernamePasswordCredential: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
3354
- }
3355
- if (!clientId) {
3356
- throw new CredentialUnavailableError("UsernamePasswordCredential: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
3357
- }
3358
- if (!username) {
3359
- throw new CredentialUnavailableError("UsernamePasswordCredential: username is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
3360
- }
3361
- if (!password) {
3362
- throw new CredentialUnavailableError("UsernamePasswordCredential: password is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
3363
- }
3364
- this.tenantId = tenantId;
3365
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
3366
- this.username = username;
3367
- this.password = password;
3368
- this.msalClient = createMsalClient(clientId, this.tenantId, Object.assign(Object.assign({}, options), { tokenCredentialOptions: options !== null && options !== void 0 ? options : {} }));
3369
- }
3370
- /**
3371
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3372
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3373
- *
3374
- * If the user provided the option `disableAutomaticAuthentication`,
3375
- * once the token can't be retrieved silently,
3376
- * this method won't attempt to request user interaction to retrieve the token.
3377
- *
3378
- * @param scopes - The list of scopes for which the token will have access.
3379
- * @param options - The options used to configure any requests this
3380
- * TokenCredential implementation might make.
3381
- */
3382
- async getToken(scopes, options = {}) {
3383
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
3384
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$7);
3385
- const arrayScopes = ensureScopes(scopes);
3386
- return this.msalClient.getTokenByUsernamePassword(arrayScopes, this.username, this.password, newOptions);
3387
- });
3388
- }
3389
- }
3390
-
3391
- // Copyright (c) Microsoft Corporation.
3392
- // Licensed under the MIT License.
3393
- /**
3394
- * Contains the list of all supported environment variable names so that an
3395
- * appropriate error message can be generated when no credentials can be
3396
- * configured.
3397
- *
3398
- * @internal
3399
- */
3400
- const AllSupportedEnvironmentVariables = [
3401
- "AZURE_TENANT_ID",
3402
- "AZURE_CLIENT_ID",
3403
- "AZURE_CLIENT_SECRET",
3404
- "AZURE_CLIENT_CERTIFICATE_PATH",
3405
- "AZURE_CLIENT_CERTIFICATE_PASSWORD",
3406
- "AZURE_USERNAME",
3407
- "AZURE_PASSWORD",
3408
- "AZURE_ADDITIONALLY_ALLOWED_TENANTS",
3409
- "AZURE_CLIENT_SEND_CERTIFICATE_CHAIN",
3410
- ];
3411
- function getAdditionallyAllowedTenants() {
3412
- var _a;
3413
- const additionallyAllowedValues = (_a = process.env.AZURE_ADDITIONALLY_ALLOWED_TENANTS) !== null && _a !== void 0 ? _a : "";
3414
- return additionallyAllowedValues.split(";");
3415
- }
3416
- const credentialName$2 = "EnvironmentCredential";
3417
- const logger$6 = credentialLogger(credentialName$2);
3418
- function getSendCertificateChain() {
3419
- var _a;
3420
- const sendCertificateChain = ((_a = process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN) !== null && _a !== void 0 ? _a : "").toLowerCase();
3421
- const result = sendCertificateChain === "true" || sendCertificateChain === "1";
3422
- logger$6.verbose(`AZURE_CLIENT_SEND_CERTIFICATE_CHAIN: ${process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN}; sendCertificateChain: ${result}`);
3423
- return result;
3424
- }
3425
- /**
3426
- * Enables authentication to Microsoft Entra ID using a client secret or certificate, or as a user
3427
- * with a username and password.
3428
- */
3429
- class EnvironmentCredential {
3430
- /**
3431
- * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
3432
- *
3433
- * Required environment variables:
3434
- * - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
3435
- * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
3436
- *
3437
- * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
3438
- * - `AZURE_ADDITIONALLY_ALLOWED_TENANTS`: For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens with a single semicolon delimited string. Use * to allow all tenants.
3439
- *
3440
- * Environment variables used for client credential authentication:
3441
- * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
3442
- * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
3443
- * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
3444
- * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.
3445
- *
3446
- * Alternatively, users can provide environment variables for username and password authentication:
3447
- * - `AZURE_USERNAME`: Username to authenticate with.
3448
- * - `AZURE_PASSWORD`: Password to authenticate with.
3449
- *
3450
- * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.
3451
- * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.
3452
- *
3453
- * @param options - Options for configuring the client which makes the authentication request.
3454
- */
3455
- constructor(options) {
3456
- // Keep track of any missing environment variables for error details
3457
- this._credential = undefined;
3458
- const assigned = processEnvVars(AllSupportedEnvironmentVariables).assigned.join(", ");
3459
- logger$6.info(`Found the following environment variables: ${assigned}`);
3460
- const tenantId = process.env.AZURE_TENANT_ID, clientId = process.env.AZURE_CLIENT_ID, clientSecret = process.env.AZURE_CLIENT_SECRET;
3461
- const additionallyAllowedTenantIds = getAdditionallyAllowedTenants();
3462
- const sendCertificateChain = getSendCertificateChain();
3463
- const newOptions = Object.assign(Object.assign({}, options), { additionallyAllowedTenantIds, sendCertificateChain });
3464
- if (tenantId) {
3465
- checkTenantId(logger$6, tenantId);
3466
- }
3467
- if (tenantId && clientId && clientSecret) {
3468
- logger$6.info(`Invoking ClientSecretCredential with tenant ID: ${tenantId}, clientId: ${clientId} and clientSecret: [REDACTED]`);
3469
- this._credential = new ClientSecretCredential(tenantId, clientId, clientSecret, newOptions);
3470
- return;
3471
- }
3472
- const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;
3473
- const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;
3474
- if (tenantId && clientId && certificatePath) {
3475
- logger$6.info(`Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`);
3476
- this._credential = new ClientCertificateCredential(tenantId, clientId, { certificatePath, certificatePassword }, newOptions);
3477
- return;
3478
- }
3479
- const username = process.env.AZURE_USERNAME;
3480
- const password = process.env.AZURE_PASSWORD;
3481
- if (tenantId && clientId && username && password) {
3482
- logger$6.info(`Invoking UsernamePasswordCredential with tenant ID: ${tenantId}, clientId: ${clientId} and username: ${username}`);
3483
- this._credential = new UsernamePasswordCredential(tenantId, clientId, username, password, newOptions);
3484
- }
3485
- }
3486
- /**
3487
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3488
- *
3489
- * @param scopes - The list of scopes for which the token will have access.
3490
- * @param options - Optional parameters. See {@link GetTokenOptions}.
3491
- */
3492
- async getToken(scopes, options = {}) {
3493
- return tracingClient.withSpan(`${credentialName$2}.getToken`, options, async (newOptions) => {
3494
- if (this._credential) {
3495
- try {
3496
- const result = await this._credential.getToken(scopes, newOptions);
3497
- logger$6.getToken.info(formatSuccess(scopes));
3498
- return result;
3499
- }
3500
- catch (err) {
3501
- const authenticationError = new AuthenticationError(400, {
3502
- error: `${credentialName$2} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,
3503
- error_description: err.message.toString().split("More details:").join(""),
3504
- });
3505
- logger$6.getToken.info(formatError(scopes, authenticationError));
3506
- throw authenticationError;
3507
- }
3508
- }
3509
- throw new CredentialUnavailableError(`${credentialName$2} is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`);
3510
- });
3511
- }
3512
- }
3513
-
3514
- // Copyright (c) Microsoft Corporation.
3515
- // Licensed under the MIT License.
3516
- const logger$5 = credentialLogger("DefaultAzureCredential");
3517
- /**
3518
- * Creates a {@link ManagedIdentityCredential} from the provided options.
3519
- * @param options - Options to configure the credential.
3520
- *
3521
- * @internal
3522
- */
3523
- function createDefaultManagedIdentityCredential(options = {}) {
3524
- var _a, _b, _c, _d;
3525
- (_a = options.retryOptions) !== null && _a !== void 0 ? _a : (options.retryOptions = {
3526
- maxRetries: 5,
3527
- retryDelayInMs: 800,
3528
- });
3529
- const managedIdentityClientId = (_b = options === null || options === void 0 ? void 0 : options.managedIdentityClientId) !== null && _b !== void 0 ? _b : process.env.AZURE_CLIENT_ID;
3530
- const workloadIdentityClientId = (_c = options === null || options === void 0 ? void 0 : options.workloadIdentityClientId) !== null && _c !== void 0 ? _c : managedIdentityClientId;
3531
- const managedResourceId = options === null || options === void 0 ? void 0 : options.managedIdentityResourceId;
3532
- const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
3533
- const tenantId = (_d = options === null || options === void 0 ? void 0 : options.tenantId) !== null && _d !== void 0 ? _d : process.env.AZURE_TENANT_ID;
3534
- if (managedResourceId) {
3535
- const managedIdentityResourceIdOptions = Object.assign(Object.assign({}, options), { resourceId: managedResourceId });
3536
- return new ManagedIdentityCredential(managedIdentityResourceIdOptions);
3537
- }
3538
- if (workloadFile && workloadIdentityClientId) {
3539
- const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId: tenantId });
3540
- return new ManagedIdentityCredential(workloadIdentityClientId, workloadIdentityCredentialOptions);
3541
- }
3542
- if (managedIdentityClientId) {
3543
- const managedIdentityClientOptions = Object.assign(Object.assign({}, options), { clientId: managedIdentityClientId });
3544
- return new ManagedIdentityCredential(managedIdentityClientOptions);
3545
- }
3546
- // We may be able to return a UnavailableCredential here, but that may be a breaking change
3547
- return new ManagedIdentityCredential(options);
3548
- }
3549
- /**
3550
- * Creates a {@link WorkloadIdentityCredential} from the provided options.
3551
- * @param options - Options to configure the credential.
3552
- *
3553
- * @internal
3554
- */
3555
- function createDefaultWorkloadIdentityCredential(options) {
3556
- var _a, _b, _c;
3557
- const managedIdentityClientId = (_a = options === null || options === void 0 ? void 0 : options.managedIdentityClientId) !== null && _a !== void 0 ? _a : process.env.AZURE_CLIENT_ID;
3558
- const workloadIdentityClientId = (_b = options === null || options === void 0 ? void 0 : options.workloadIdentityClientId) !== null && _b !== void 0 ? _b : managedIdentityClientId;
3559
- const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
3560
- const tenantId = (_c = options === null || options === void 0 ? void 0 : options.tenantId) !== null && _c !== void 0 ? _c : process.env.AZURE_TENANT_ID;
3561
- if (workloadFile && workloadIdentityClientId) {
3562
- const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId, clientId: workloadIdentityClientId, tokenFilePath: workloadFile });
3563
- return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);
3564
- }
3565
- if (tenantId) {
3566
- const workloadIdentityClientTenantOptions = Object.assign(Object.assign({}, options), { tenantId });
3567
- return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);
3568
- }
3569
- // We may be able to return a UnavailableCredential here, but that may be a breaking change
3570
- return new WorkloadIdentityCredential(options);
3571
- }
3572
- /**
3573
- * Creates a {@link AzureDeveloperCliCredential} from the provided options.
3574
- * @param options - Options to configure the credential.
3575
- *
3576
- * @internal
3577
- */
3578
- function createDefaultAzureDeveloperCliCredential(options = {}) {
3579
- const processTimeoutInMs = options.processTimeoutInMs;
3580
- return new AzureDeveloperCliCredential(Object.assign({ processTimeoutInMs }, options));
3581
- }
3582
- /**
3583
- * Creates a {@link AzureCliCredential} from the provided options.
3584
- * @param options - Options to configure the credential.
3585
- *
3586
- * @internal
3587
- */
3588
- function createDefaultAzureCliCredential(options = {}) {
3589
- const processTimeoutInMs = options.processTimeoutInMs;
3590
- return new AzureCliCredential(Object.assign({ processTimeoutInMs }, options));
3591
- }
3592
- /**
3593
- * Creates a {@link AzurePowerShellCredential} from the provided options.
3594
- * @param options - Options to configure the credential.
3595
- *
3596
- * @internal
3597
- */
3598
- function createDefaultAzurePowershellCredential(options = {}) {
3599
- const processTimeoutInMs = options.processTimeoutInMs;
3600
- return new AzurePowerShellCredential(Object.assign({ processTimeoutInMs }, options));
3601
- }
3602
- /**
3603
- * Creates an {@link EnvironmentCredential} from the provided options.
3604
- * @param options - Options to configure the credential.
3605
- *
3606
- * @internal
3607
- */
3608
- function createEnvironmentCredential(options = {}) {
3609
- return new EnvironmentCredential(options);
3610
- }
3611
- /**
3612
- * A no-op credential that logs the reason it was skipped if getToken is called.
3613
- * @internal
3614
- */
3615
- class UnavailableDefaultCredential {
3616
- constructor(credentialName, message) {
3617
- this.credentialName = credentialName;
3618
- this.credentialUnavailableErrorMessage = message;
3619
- }
3620
- getToken() {
3621
- logger$5.getToken.info(`Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`);
3622
- return Promise.resolve(null);
3623
- }
3624
- }
3625
- /**
3626
- * Provides a default {@link ChainedTokenCredential} configuration that should
3627
- * work for most applications that use the Azure SDK.
3628
- */
3629
- class DefaultAzureCredential extends ChainedTokenCredential {
3630
- constructor(options) {
3631
- const credentialFunctions = [
3632
- createEnvironmentCredential,
3633
- createDefaultWorkloadIdentityCredential,
3634
- createDefaultManagedIdentityCredential,
3635
- createDefaultAzureCliCredential,
3636
- createDefaultAzurePowershellCredential,
3637
- createDefaultAzureDeveloperCliCredential,
3638
- ];
3639
- // DefaultCredential constructors should not throw, instead throwing on getToken() which is handled by ChainedTokenCredential.
3640
- // When adding new credentials to the default chain, consider:
3641
- // 1. Making the constructor parameters required and explicit
3642
- // 2. Validating any required parameters in the factory function
3643
- // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason
3644
- const credentials = credentialFunctions.map((createCredentialFn) => {
3645
- try {
3646
- return createCredentialFn(options);
3647
- }
3648
- catch (err) {
3649
- logger$5.warning(`Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`);
3650
- return new UnavailableDefaultCredential(createCredentialFn.name, err.message);
3651
- }
3652
- });
3653
- super(...credentials);
3654
- }
3655
- }
3656
-
3657
- // Copyright (c) Microsoft Corporation.
3658
- // Licensed under the MIT License.
3659
- const logger$4 = credentialLogger("InteractiveBrowserCredential");
3660
- /**
3661
- * Enables authentication to Microsoft Entra ID inside of the web browser
3662
- * using the interactive login flow.
3663
- */
3664
- class InteractiveBrowserCredential {
3665
- /**
3666
- * Creates an instance of InteractiveBrowserCredential with the details needed.
3667
- *
3668
- * This credential uses the [Authorization Code Flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow).
3669
- * On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
3670
- * On browsers, it authenticates via popups. The `loginStyle` optional parameter can be set to `redirect` to authenticate by redirecting the user to an Azure secure login page, which then will redirect the user back to the web application where the authentication started.
3671
- *
3672
- * For Node.js, if a `clientId` is provided, the Microsoft Entra application will need to be configured to have a "Mobile and desktop applications" redirect endpoint.
3673
- * Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://learn.microsoft.com/entra/identity-platform/scenario-desktop-app-registration#redirect-uris).
3674
- *
3675
- * @param options - Options for configuring the client which makes the authentication requests.
3676
- */
3677
- constructor(options) {
3678
- var _a, _b, _c, _d, _e;
3679
- this.tenantId = resolveTenantId(logger$4, options.tenantId, options.clientId);
3680
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
3681
- const msalClientOptions = Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$4 });
3682
- const ibcNodeOptions = options;
3683
- this.browserCustomizationOptions = ibcNodeOptions.browserCustomizationOptions;
3684
- this.loginHint = ibcNodeOptions.loginHint;
3685
- if ((_a = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _a === void 0 ? void 0 : _a.enabled) {
3686
- if (!((_b = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _b === void 0 ? void 0 : _b.parentWindowHandle)) {
3687
- throw new Error("In order to do WAM authentication, `parentWindowHandle` under `brokerOptions` is a required parameter");
3688
- }
3689
- else {
3690
- msalClientOptions.brokerOptions = {
3691
- enabled: true,
3692
- parentWindowHandle: ibcNodeOptions.brokerOptions.parentWindowHandle,
3693
- legacyEnableMsaPassthrough: (_c = ibcNodeOptions.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough,
3694
- useDefaultBrokerAccount: (_d = ibcNodeOptions.brokerOptions) === null || _d === void 0 ? void 0 : _d.useDefaultBrokerAccount,
3695
- };
3696
- }
3697
- }
3698
- this.msalClient = createMsalClient((_e = options.clientId) !== null && _e !== void 0 ? _e : DeveloperSignOnClientId, this.tenantId, msalClientOptions);
3699
- this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
3700
- }
3701
- /**
3702
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3703
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3704
- *
3705
- * If the user provided the option `disableAutomaticAuthentication`,
3706
- * once the token can't be retrieved silently,
3707
- * this method won't attempt to request user interaction to retrieve the token.
3708
- *
3709
- * @param scopes - The list of scopes for which the token will have access.
3710
- * @param options - The options used to configure any requests this
3711
- * TokenCredential implementation might make.
3712
- */
3713
- async getToken(scopes, options = {}) {
3714
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
3715
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$4);
3716
- const arrayScopes = ensureScopes(scopes);
3717
- return this.msalClient.getTokenByInteractiveRequest(arrayScopes, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: this.disableAutomaticAuthentication, browserCustomizationOptions: this.browserCustomizationOptions, loginHint: this.loginHint }));
3718
- });
3719
- }
3720
- /**
3721
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3722
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3723
- *
3724
- * If the token can't be retrieved silently, this method will always generate a challenge for the user.
3725
- *
3726
- * On Node.js, this credential has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
3727
- * PKCE is a security feature that mitigates authentication code interception attacks.
3728
- *
3729
- * @param scopes - The list of scopes for which the token will have access.
3730
- * @param options - The options used to configure any requests this
3731
- * TokenCredential implementation might make.
3732
- */
3733
- async authenticate(scopes, options = {}) {
3734
- return tracingClient.withSpan(`${this.constructor.name}.authenticate`, options, async (newOptions) => {
3735
- const arrayScopes = ensureScopes(scopes);
3736
- await this.msalClient.getTokenByInteractiveRequest(arrayScopes, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: false, browserCustomizationOptions: this.browserCustomizationOptions, loginHint: this.loginHint }));
3737
- return this.msalClient.getActiveAccount();
3738
- });
3739
- }
3740
- }
3741
-
3742
- // Copyright (c) Microsoft Corporation.
3743
- // Licensed under the MIT License.
3744
- const logger$3 = credentialLogger("DeviceCodeCredential");
3745
- /**
3746
- * Method that logs the user code from the DeviceCodeCredential.
3747
- * @param deviceCodeInfo - The device code.
3748
- */
3749
- function defaultDeviceCodePromptCallback(deviceCodeInfo) {
3750
- console.log(deviceCodeInfo.message);
3751
- }
3752
- /**
3753
- * Enables authentication to Microsoft Entra ID using a device code
3754
- * that the user can enter into https://microsoft.com/devicelogin.
3755
- */
3756
- class DeviceCodeCredential {
3757
- /**
3758
- * Creates an instance of DeviceCodeCredential with the details needed
3759
- * to initiate the device code authorization flow with Microsoft Entra ID.
3760
- *
3761
- * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
3762
- *
3763
- * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
3764
- *
3765
- * ```ts snippet:device_code_credential_example
3766
- * import { DeviceCodeCredential } from "@azure/identity";
3767
- *
3768
- * const credential = new DeviceCodeCredential({
3769
- * tenantId: process.env.AZURE_TENANT_ID,
3770
- * clientId: process.env.AZURE_CLIENT_ID,
3771
- * userPromptCallback: (info) => {
3772
- * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
3773
- * },
3774
- * });
3775
- * ```
3776
- *
3777
- * @param options - Options for configuring the client which makes the authentication requests.
3778
- */
3779
- constructor(options) {
3780
- var _a, _b;
3781
- this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
3782
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
3783
- const clientId = (_a = options === null || options === void 0 ? void 0 : options.clientId) !== null && _a !== void 0 ? _a : DeveloperSignOnClientId;
3784
- const tenantId = resolveTenantId(logger$3, options === null || options === void 0 ? void 0 : options.tenantId, clientId);
3785
- this.userPromptCallback = (_b = options === null || options === void 0 ? void 0 : options.userPromptCallback) !== null && _b !== void 0 ? _b : defaultDeviceCodePromptCallback;
3786
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger: logger$3, tokenCredentialOptions: options || {} }));
3787
- this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
3788
- }
3789
- /**
3790
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3791
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3792
- *
3793
- * If the user provided the option `disableAutomaticAuthentication`,
3794
- * once the token can't be retrieved silently,
3795
- * this method won't attempt to request user interaction to retrieve the token.
3796
- *
3797
- * @param scopes - The list of scopes for which the token will have access.
3798
- * @param options - The options used to configure any requests this
3799
- * TokenCredential implementation might make.
3800
- */
3801
- async getToken(scopes, options = {}) {
3802
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
3803
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$3);
3804
- const arrayScopes = ensureScopes(scopes);
3805
- return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: this.disableAutomaticAuthentication }));
3806
- });
3807
- }
3808
- /**
3809
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3810
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
3811
- *
3812
- * If the token can't be retrieved silently, this method will always generate a challenge for the user.
3813
- *
3814
- * @param scopes - The list of scopes for which the token will have access.
3815
- * @param options - The options used to configure any requests this
3816
- * TokenCredential implementation might make.
3817
- */
3818
- async authenticate(scopes, options = {}) {
3819
- return tracingClient.withSpan(`${this.constructor.name}.authenticate`, options, async (newOptions) => {
3820
- const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
3821
- await this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: false }));
3822
- return this.msalClient.getActiveAccount();
3823
- });
3824
- }
3825
- }
3826
-
3827
- // Copyright (c) Microsoft Corporation.
3828
- // Licensed under the MIT License.
3829
- const credentialName$1 = "AzurePipelinesCredential";
3830
- const logger$2 = credentialLogger(credentialName$1);
3831
- const OIDC_API_VERSION = "7.1";
3832
- /**
3833
- * This credential is designed to be used in Azure Pipelines with service connections
3834
- * as a setup for workload identity federation.
3835
- */
3836
- class AzurePipelinesCredential {
3837
- /**
3838
- * AzurePipelinesCredential supports Federated Identity on Azure Pipelines through Service Connections.
3839
- * @param tenantId - tenantId associated with the service connection
3840
- * @param clientId - clientId associated with the service connection
3841
- * @param serviceConnectionId - Unique ID for the service connection, as found in the querystring's resourceId key
3842
- * @param systemAccessToken - The pipeline's <see href="https://learn.microsoft.com/azure/devops/pipelines/build/variables?view=azure-devops%26tabs=yaml#systemaccesstoken">System.AccessToken</see> value.
3843
- * @param options - The identity client options to use for authentication.
3844
- */
3845
- constructor(tenantId, clientId, serviceConnectionId, systemAccessToken, options = {}) {
3846
- var _a, _b;
3847
- if (!clientId) {
3848
- throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. clientId is a required parameter.`);
3849
- }
3850
- if (!tenantId) {
3851
- throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. tenantId is a required parameter.`);
3852
- }
3853
- if (!serviceConnectionId) {
3854
- throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. serviceConnectionId is a required parameter.`);
3855
- }
3856
- if (!systemAccessToken) {
3857
- throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. systemAccessToken is a required parameter.`);
3858
- }
3859
- // Allow these headers to be logged for troubleshooting by AzurePipelines.
3860
- options.loggingOptions = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.loggingOptions), { additionalAllowedHeaderNames: [
3861
- ...((_b = (_a = options.loggingOptions) === null || _a === void 0 ? void 0 : _a.additionalAllowedHeaderNames) !== null && _b !== void 0 ? _b : []),
3862
- "x-vss-e2eid",
3863
- "x-msedge-ref",
3864
- ] });
3865
- this.identityClient = new IdentityClient(options);
3866
- checkTenantId(logger$2, tenantId);
3867
- logger$2.info(`Invoking AzurePipelinesCredential with tenant ID: ${tenantId}, client ID: ${clientId}, and service connection ID: ${serviceConnectionId}`);
3868
- if (!process.env.SYSTEM_OIDCREQUESTURI) {
3869
- throw new CredentialUnavailableError(`${credentialName$1}: is unavailable. Ensure that you're running this task in an Azure Pipeline, so that following missing system variable(s) can be defined- "SYSTEM_OIDCREQUESTURI"`);
3870
- }
3871
- const oidcRequestUrl = `${process.env.SYSTEM_OIDCREQUESTURI}?api-version=${OIDC_API_VERSION}&serviceConnectionId=${serviceConnectionId}`;
3872
- logger$2.info(`Invoking ClientAssertionCredential with tenant ID: ${tenantId}, client ID: ${clientId} and service connection ID: ${serviceConnectionId}`);
3873
- this.clientAssertionCredential = new ClientAssertionCredential(tenantId, clientId, this.requestOidcToken.bind(this, oidcRequestUrl, systemAccessToken), options);
3874
- }
3875
- /**
3876
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
3877
- * If authentication fails, a {@link CredentialUnavailableError} or {@link AuthenticationError} will be thrown with the details of the failure.
3878
- *
3879
- * @param scopes - The list of scopes for which the token will have access.
3880
- * @param options - The options used to configure any requests this
3881
- * TokenCredential implementation might make.
3882
- */
3883
- async getToken(scopes, options) {
3884
- if (!this.clientAssertionCredential) {
3885
- const errorMessage = `${credentialName$1}: is unavailable. To use Federation Identity in Azure Pipelines, the following parameters are required -
3886
- tenantId,
3887
- clientId,
3888
- serviceConnectionId,
3889
- systemAccessToken,
3890
- "SYSTEM_OIDCREQUESTURI".
3891
- See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;
3892
- logger$2.error(errorMessage);
3893
- throw new CredentialUnavailableError(errorMessage);
3894
- }
3895
- logger$2.info("Invoking getToken() of Client Assertion Credential");
3896
- return this.clientAssertionCredential.getToken(scopes, options);
3897
- }
3898
- /**
3899
- *
3900
- * @param oidcRequestUrl - oidc request url
3901
- * @param systemAccessToken - system access token
3902
- * @returns OIDC token from Azure Pipelines
3903
- */
3904
- async requestOidcToken(oidcRequestUrl, systemAccessToken) {
3905
- logger$2.info("Requesting OIDC token from Azure Pipelines...");
3906
- logger$2.info(oidcRequestUrl);
3907
- const request = coreRestPipeline.createPipelineRequest({
3908
- url: oidcRequestUrl,
3909
- method: "POST",
3910
- headers: coreRestPipeline.createHttpHeaders({
3911
- "Content-Type": "application/json",
3912
- Authorization: `Bearer ${systemAccessToken}`,
3913
- // Prevents the service from responding with a redirect HTTP status code (useful for automation).
3914
- "X-TFS-FedAuthRedirect": "Suppress",
3915
- }),
3916
- });
3917
- const response = await this.identityClient.sendRequest(request);
3918
- return handleOidcResponse(response);
3919
- }
3920
- }
3921
- function handleOidcResponse(response) {
3922
- // OIDC token is present in `bodyAsText` field
3923
- const text = response.bodyAsText;
3924
- if (!text) {
3925
- logger$2.error(`${credentialName$1}: Authentication Failed. Received null token from OIDC request. Response status- ${response.status}. Complete response - ${JSON.stringify(response)}`);
3926
- throw new AuthenticationError(response.status, {
3927
- error: `${credentialName$1}: Authentication Failed. Received null token from OIDC request.`,
3928
- error_description: `${JSON.stringify(response)}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`,
3929
- });
3930
- }
3931
- try {
3932
- const result = JSON.parse(text);
3933
- if (result === null || result === void 0 ? void 0 : result.oidcToken) {
3934
- return result.oidcToken;
3935
- }
3936
- else {
3937
- const errorMessage = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
3938
- let errorDescription = ``;
3939
- if (response.status !== 200) {
3940
- errorDescription = `Response body = ${text}. Response Headers ["x-vss-e2eid"] = ${response.headers.get("x-vss-e2eid")} and ["x-msedge-ref"] = ${response.headers.get("x-msedge-ref")}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;
3941
- }
3942
- logger$2.error(errorMessage);
3943
- logger$2.error(errorDescription);
3944
- throw new AuthenticationError(response.status, {
3945
- error: errorMessage,
3946
- error_description: errorDescription,
3947
- });
3948
- }
3949
- }
3950
- catch (e) {
3951
- const errorDetails = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
3952
- logger$2.error(`Response from service = ${text}, Response Headers ["x-vss-e2eid"] = ${response.headers.get("x-vss-e2eid")}
3953
- and ["x-msedge-ref"] = ${response.headers.get("x-msedge-ref")}, error message = ${e.message}`);
3954
- logger$2.error(errorDetails);
3955
- throw new AuthenticationError(response.status, {
3956
- error: errorDetails,
3957
- error_description: `Response = ${text}. Response headers ["x-vss-e2eid"] = ${response.headers.get("x-vss-e2eid")} and ["x-msedge-ref"] = ${response.headers.get("x-msedge-ref")}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`,
3958
- });
3959
- }
3960
- }
3961
-
3962
- // Copyright (c) Microsoft Corporation.
3963
- // Licensed under the MIT License.
3964
- const logger$1 = credentialLogger("AuthorizationCodeCredential");
3965
- /**
3966
- * Enables authentication to Microsoft Entra ID using an authorization code
3967
- * that was obtained through the authorization code flow, described in more detail
3968
- * in the Microsoft Entra ID documentation:
3969
- *
3970
- * https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow
3971
- */
3972
- class AuthorizationCodeCredential {
3973
- /**
3974
- * @hidden
3975
- * @internal
3976
- */
3977
- constructor(tenantId, clientId, clientSecretOrAuthorizationCode, authorizationCodeOrRedirectUri, redirectUriOrOptions, options) {
3978
- checkTenantId(logger$1, tenantId);
3979
- this.clientSecret = clientSecretOrAuthorizationCode;
3980
- if (typeof redirectUriOrOptions === "string") {
3981
- // the clientId+clientSecret constructor
3982
- this.authorizationCode = authorizationCodeOrRedirectUri;
3983
- this.redirectUri = redirectUriOrOptions;
3984
- // in this case, options are good as they come
3985
- }
3986
- else {
3987
- // clientId only
3988
- this.authorizationCode = clientSecretOrAuthorizationCode;
3989
- this.redirectUri = authorizationCodeOrRedirectUri;
3990
- this.clientSecret = undefined;
3991
- options = redirectUriOrOptions;
3992
- }
3993
- // TODO: Validate tenant if provided
3994
- this.tenantId = tenantId;
3995
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
3996
- this.msalClient = createMsalClient(clientId, tenantId, Object.assign(Object.assign({}, options), { logger: logger$1, tokenCredentialOptions: options !== null && options !== void 0 ? options : {} }));
3997
- }
3998
- /**
3999
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
4000
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
4001
- *
4002
- * @param scopes - The list of scopes for which the token will have access.
4003
- * @param options - The options used to configure any requests this
4004
- * TokenCredential implementation might make.
4005
- */
4006
- async getToken(scopes, options = {}) {
4007
- return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
4008
- const tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds);
4009
- newOptions.tenantId = tenantId;
4010
- const arrayScopes = ensureScopes(scopes);
4011
- return this.msalClient.getTokenByAuthorizationCode(arrayScopes, this.redirectUri, this.authorizationCode, this.clientSecret, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: this.disableAutomaticAuthentication }));
4012
- });
4013
- }
4014
- }
4015
-
4016
- // Copyright (c) Microsoft Corporation.
4017
- // Licensed under the MIT License.
4018
- const credentialName = "OnBehalfOfCredential";
4019
- const logger = credentialLogger(credentialName);
4020
- /**
4021
- * Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-on-behalf-of-flow).
4022
- */
4023
- class OnBehalfOfCredential {
4024
- constructor(options) {
4025
- const { clientSecret } = options;
4026
- const { certificatePath, sendCertificateChain } = options;
4027
- const { getAssertion } = options;
4028
- const { tenantId, clientId, userAssertionToken, additionallyAllowedTenants: additionallyAllowedTenantIds, } = options;
4029
- if (!tenantId) {
4030
- throw new CredentialUnavailableError(`${credentialName}: tenantId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
4031
- }
4032
- if (!clientId) {
4033
- throw new CredentialUnavailableError(`${credentialName}: clientId is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
4034
- }
4035
- if (!clientSecret && !certificatePath && !getAssertion) {
4036
- throw new CredentialUnavailableError(`${credentialName}: You must provide one of clientSecret, certificatePath, or a getAssertion callback but none were provided. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
4037
- }
4038
- if (!userAssertionToken) {
4039
- throw new CredentialUnavailableError(`${credentialName}: userAssertionToken is a required parameter. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.`);
4040
- }
4041
- this.certificatePath = certificatePath;
4042
- this.clientSecret = clientSecret;
4043
- this.userAssertionToken = userAssertionToken;
4044
- this.sendCertificateChain = sendCertificateChain;
4045
- this.clientAssertion = getAssertion;
4046
- this.tenantId = tenantId;
4047
- this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(additionallyAllowedTenantIds);
4048
- this.msalClient = createMsalClient(clientId, this.tenantId, Object.assign(Object.assign({}, options), { logger, tokenCredentialOptions: options }));
4049
- }
4050
- /**
4051
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
4052
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
4053
- *
4054
- * @param scopes - The list of scopes for which the token will have access.
4055
- * @param options - The options used to configure the underlying network requests.
4056
- */
4057
- async getToken(scopes, options = {}) {
4058
- return tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {
4059
- newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger);
4060
- const arrayScopes = ensureScopes(scopes);
4061
- if (this.certificatePath) {
4062
- const clientCertificate = await this.buildClientCertificate(this.certificatePath);
4063
- return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, clientCertificate, newOptions);
4064
- }
4065
- else if (this.clientSecret) {
4066
- return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, this.clientSecret, options);
4067
- }
4068
- else if (this.clientAssertion) {
4069
- return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, this.clientAssertion, options);
4070
- }
4071
- else {
4072
- // this is an invalid scenario and is a bug, as the constructor should have thrown an error if neither clientSecret nor certificatePath nor clientAssertion were provided
4073
- throw new Error("Expected either clientSecret or certificatePath or clientAssertion to be defined.");
4074
- }
4075
- });
4076
- }
4077
- async buildClientCertificate(certificatePath) {
4078
- try {
4079
- const parts = await this.parseCertificate({ certificatePath }, this.sendCertificateChain);
4080
- return {
4081
- thumbprint: parts.thumbprint,
4082
- privateKey: parts.certificateContents,
4083
- x5c: parts.x5c,
4084
- };
4085
- }
4086
- catch (error) {
4087
- logger.info(formatError("", error));
4088
- throw error;
4089
- }
4090
- }
4091
- async parseCertificate(configuration, sendCertificateChain) {
4092
- const certificatePath = configuration.certificatePath;
4093
- const certificateContents = await promises$1.readFile(certificatePath, "utf8");
4094
- const x5c = sendCertificateChain ? certificateContents : undefined;
4095
- const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/g;
4096
- const publicKeys = [];
4097
- // Match all possible certificates, in the order they are in the file. These will form the chain that is used for x5c
4098
- let match;
4099
- do {
4100
- match = certificatePattern.exec(certificateContents);
4101
- if (match) {
4102
- publicKeys.push(match[3]);
4103
- }
4104
- } while (match);
4105
- if (publicKeys.length === 0) {
4106
- throw new Error("The file at the specified path does not contain a PEM-encoded certificate.");
4107
- }
4108
- const thumbprint = node_crypto.createHash("sha1")
4109
- .update(Buffer.from(publicKeys[0], "base64"))
4110
- .digest("hex")
4111
- .toUpperCase();
4112
- return {
4113
- certificateContents,
4114
- thumbprint,
4115
- x5c,
4116
- };
4117
- }
4118
- }
4119
-
4120
- // Copyright (c) Microsoft Corporation.
4121
- // Licensed under the MIT License.
4122
- /**
4123
- * Returns a callback that provides a bearer token.
4124
- * For example, the bearer token can be used to authenticate a request as follows:
4125
- * ```ts snippet:token_provider_example
4126
- * import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity";
4127
- * import { createPipelineRequest } from "@azure/core-rest-pipeline";
4128
- *
4129
- * const credential = new DefaultAzureCredential();
4130
- * const scope = "https://cognitiveservices.azure.com/.default";
4131
- * const getAccessToken = getBearerTokenProvider(credential, scope);
4132
- * const token = await getAccessToken();
4133
- * // usage
4134
- * const request = createPipelineRequest({ url: "https://example.com" });
4135
- * request.headers.set("Authorization", `Bearer ${token}`);
4136
- * ```
4137
- *
4138
- * @param credential - The credential used to authenticate the request.
4139
- * @param scopes - The scopes required for the bearer token.
4140
- * @param options - Options to configure the token provider.
4141
- * @returns a callback that provides a bearer token.
4142
- */
4143
- function getBearerTokenProvider(credential, scopes, options) {
4144
- const { abortSignal, tracingOptions } = options || {};
4145
- const pipeline = coreRestPipeline.createEmptyPipeline();
4146
- pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({ credential, scopes }));
4147
- async function getRefreshedToken() {
4148
- var _a;
4149
- // Create a pipeline with just the bearer token policy
4150
- // and run a dummy request through it to get the token
4151
- const res = await pipeline.sendRequest({
4152
- sendRequest: (request) => Promise.resolve({
4153
- request,
4154
- status: 200,
4155
- headers: request.headers,
4156
- }),
4157
- }, coreRestPipeline.createPipelineRequest({
4158
- url: "https://example.com",
4159
- abortSignal,
4160
- tracingOptions,
4161
- }));
4162
- const accessToken = (_a = res.headers.get("authorization")) === null || _a === void 0 ? void 0 : _a.split(" ")[1];
4163
- if (!accessToken) {
4164
- throw new Error("Failed to get access token");
4165
- }
4166
- return accessToken;
4167
- }
4168
- return getRefreshedToken;
4169
- }
4170
-
4171
- // Copyright (c) Microsoft Corporation.
4172
- // Licensed under the MIT License.
4173
- /**
4174
- * Returns a new instance of the {@link DefaultAzureCredential}.
4175
- */
4176
- function getDefaultAzureCredential() {
4177
- return new DefaultAzureCredential();
4178
- }
4179
-
4180
- exports.AggregateAuthenticationError = AggregateAuthenticationError;
4181
- exports.AggregateAuthenticationErrorName = AggregateAuthenticationErrorName;
4182
- exports.AuthenticationError = AuthenticationError;
4183
- exports.AuthenticationErrorName = AuthenticationErrorName;
4184
- exports.AuthenticationRequiredError = AuthenticationRequiredError;
4185
- exports.AuthorizationCodeCredential = AuthorizationCodeCredential;
4186
- exports.AzureCliCredential = AzureCliCredential;
4187
- exports.AzureDeveloperCliCredential = AzureDeveloperCliCredential;
4188
- exports.AzurePipelinesCredential = AzurePipelinesCredential;
4189
- exports.AzurePowerShellCredential = AzurePowerShellCredential;
4190
- exports.ChainedTokenCredential = ChainedTokenCredential;
4191
- exports.ClientAssertionCredential = ClientAssertionCredential;
4192
- exports.ClientCertificateCredential = ClientCertificateCredential;
4193
- exports.ClientSecretCredential = ClientSecretCredential;
4194
- exports.CredentialUnavailableError = CredentialUnavailableError;
4195
- exports.CredentialUnavailableErrorName = CredentialUnavailableErrorName;
4196
- exports.DefaultAzureCredential = DefaultAzureCredential;
4197
- exports.DeviceCodeCredential = DeviceCodeCredential;
4198
- exports.EnvironmentCredential = EnvironmentCredential;
4199
- exports.InteractiveBrowserCredential = InteractiveBrowserCredential;
4200
- exports.ManagedIdentityCredential = ManagedIdentityCredential;
4201
- exports.OnBehalfOfCredential = OnBehalfOfCredential;
4202
- exports.UsernamePasswordCredential = UsernamePasswordCredential;
4203
- exports.VisualStudioCodeCredential = VisualStudioCodeCredential;
4204
- exports.WorkloadIdentityCredential = WorkloadIdentityCredential;
4205
- exports.deserializeAuthenticationRecord = deserializeAuthenticationRecord;
4206
- exports.getBearerTokenProvider = getBearerTokenProvider;
4207
- exports.getDefaultAzureCredential = getDefaultAzureCredential;
4208
- exports.logger = logger$l;
4209
- exports.serializeAuthenticationRecord = serializeAuthenticationRecord;
4210
- exports.useIdentityPlugin = useIdentityPlugin;
4211
- //# sourceMappingURL=index.js.map