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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/dist/browser/client/identityClient.d.ts.map +1 -1
  2. package/dist/browser/client/identityClient.js +2 -1
  3. package/dist/browser/client/identityClient.js.map +1 -1
  4. package/dist/browser/constants.d.ts +1 -1
  5. package/dist/browser/constants.js +1 -1
  6. package/dist/browser/constants.js.map +1 -1
  7. package/dist/browser/credentials/{authorizationCodeCredential.d.ts → authorizationCodeCredential-browser.d.mts} +1 -1
  8. package/dist/browser/credentials/authorizationCodeCredential-browser.d.mts.map +1 -0
  9. package/dist/browser/credentials/{authorizationCodeCredential.js → authorizationCodeCredential-browser.mjs} +1 -1
  10. package/dist/browser/credentials/authorizationCodeCredential-browser.mjs.map +1 -0
  11. package/dist/browser/credentials/{azureCliCredential.d.ts → azureCliCredential-browser.d.mts} +1 -1
  12. package/dist/browser/credentials/azureCliCredential-browser.d.mts.map +1 -0
  13. package/dist/browser/credentials/{azureCliCredential.js → azureCliCredential-browser.mjs} +1 -1
  14. package/dist/browser/credentials/azureCliCredential-browser.mjs.map +1 -0
  15. package/dist/browser/credentials/{azureDeveloperCliCredential.d.ts → azureDeveloperCliCredential-browser.d.mts} +1 -1
  16. package/dist/browser/credentials/azureDeveloperCliCredential-browser.d.mts.map +1 -0
  17. package/dist/browser/credentials/{azureDeveloperCliCredential.js → azureDeveloperCliCredential-browser.mjs} +1 -1
  18. package/dist/browser/credentials/azureDeveloperCliCredential-browser.mjs.map +1 -0
  19. package/dist/browser/credentials/{azurePipelinesCredential.d.ts → azurePipelinesCredential-browser.d.mts} +1 -1
  20. package/dist/browser/credentials/azurePipelinesCredential-browser.d.mts.map +1 -0
  21. package/dist/browser/credentials/{azurePipelinesCredential.js → azurePipelinesCredential-browser.mjs} +1 -1
  22. package/dist/browser/credentials/azurePipelinesCredential-browser.mjs.map +1 -0
  23. package/dist/browser/credentials/{azurePowerShellCredential.d.ts → azurePowerShellCredential-browser.d.mts} +1 -1
  24. package/dist/browser/credentials/azurePowerShellCredential-browser.d.mts.map +1 -0
  25. package/dist/browser/credentials/{azurePowerShellCredential.js → azurePowerShellCredential-browser.mjs} +1 -1
  26. package/dist/browser/credentials/azurePowerShellCredential-browser.mjs.map +1 -0
  27. package/dist/browser/credentials/{clientAssertionCredential.d.ts → clientAssertionCredential-browser.d.mts} +1 -1
  28. package/dist/browser/credentials/clientAssertionCredential-browser.d.mts.map +1 -0
  29. package/dist/browser/credentials/{clientAssertionCredential.js → clientAssertionCredential-browser.mjs} +1 -1
  30. package/dist/browser/credentials/clientAssertionCredential-browser.mjs.map +1 -0
  31. package/dist/browser/credentials/{clientCertificateCredential.d.ts → clientCertificateCredential-browser.d.mts} +1 -1
  32. package/dist/browser/credentials/clientCertificateCredential-browser.d.mts.map +1 -0
  33. package/dist/browser/credentials/{clientCertificateCredential.js → clientCertificateCredential-browser.mjs} +1 -1
  34. package/dist/browser/credentials/clientCertificateCredential-browser.mjs.map +1 -0
  35. package/dist/browser/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  36. package/dist/browser/credentials/clientCertificateCredentialModels.js.map +1 -1
  37. package/dist/browser/credentials/{clientSecretCredential.d.ts → clientSecretCredential-browser.d.mts} +1 -1
  38. package/dist/browser/credentials/clientSecretCredential-browser.d.mts.map +1 -0
  39. package/dist/browser/credentials/{clientSecretCredential.js → clientSecretCredential-browser.mjs} +1 -1
  40. package/dist/browser/credentials/clientSecretCredential-browser.mjs.map +1 -0
  41. package/dist/browser/credentials/{defaultAzureCredential.d.ts → defaultAzureCredential-browser.d.mts} +1 -1
  42. package/dist/browser/credentials/defaultAzureCredential-browser.d.mts.map +1 -0
  43. package/dist/browser/credentials/{defaultAzureCredential.js → defaultAzureCredential-browser.mjs} +1 -1
  44. package/dist/browser/credentials/defaultAzureCredential-browser.mjs.map +1 -0
  45. package/dist/browser/credentials/{deviceCodeCredential.d.ts → deviceCodeCredential-browser.d.mts} +1 -1
  46. package/dist/browser/credentials/deviceCodeCredential-browser.d.mts.map +1 -0
  47. package/dist/browser/credentials/{deviceCodeCredential.js → deviceCodeCredential-browser.mjs} +1 -1
  48. package/dist/browser/credentials/deviceCodeCredential-browser.mjs.map +1 -0
  49. package/dist/browser/credentials/{environmentCredential.d.ts → environmentCredential-browser.d.mts} +1 -1
  50. package/dist/browser/credentials/environmentCredential-browser.d.mts.map +1 -0
  51. package/dist/browser/credentials/{environmentCredential.js → environmentCredential-browser.mjs} +1 -1
  52. package/dist/browser/credentials/environmentCredential-browser.mjs.map +1 -0
  53. package/dist/browser/credentials/{interactiveBrowserCredential.d.ts → interactiveBrowserCredential-browser.d.mts} +1 -1
  54. package/dist/browser/credentials/interactiveBrowserCredential-browser.d.mts.map +1 -0
  55. package/dist/browser/credentials/{interactiveBrowserCredential.js → interactiveBrowserCredential-browser.mjs} +1 -1
  56. package/dist/browser/credentials/interactiveBrowserCredential-browser.mjs.map +1 -0
  57. package/dist/browser/credentials/managedIdentityCredential/{index.d.ts → index-browser.d.mts} +1 -1
  58. package/dist/browser/credentials/managedIdentityCredential/index-browser.d.mts.map +1 -0
  59. package/dist/browser/credentials/managedIdentityCredential/{index.js → index-browser.mjs} +1 -1
  60. package/dist/browser/credentials/managedIdentityCredential/index-browser.mjs.map +1 -0
  61. package/dist/browser/credentials/{onBehalfOfCredential.d.ts → onBehalfOfCredential-browser.d.mts} +1 -1
  62. package/dist/browser/credentials/onBehalfOfCredential-browser.d.mts.map +1 -0
  63. package/dist/browser/credentials/{onBehalfOfCredential.js → onBehalfOfCredential-browser.mjs} +1 -1
  64. package/dist/browser/credentials/onBehalfOfCredential-browser.mjs.map +1 -0
  65. package/dist/browser/credentials/{usernamePasswordCredential.d.ts → usernamePasswordCredential-browser.d.mts} +1 -1
  66. package/dist/browser/credentials/usernamePasswordCredential-browser.d.mts.map +1 -0
  67. package/dist/browser/credentials/{usernamePasswordCredential.js → usernamePasswordCredential-browser.mjs} +1 -1
  68. package/dist/browser/credentials/usernamePasswordCredential-browser.mjs.map +1 -0
  69. package/dist/browser/credentials/{visualStudioCodeCredential.d.ts → visualStudioCodeCredential-browser.d.mts} +1 -1
  70. package/dist/browser/credentials/visualStudioCodeCredential-browser.d.mts.map +1 -0
  71. package/dist/browser/credentials/{visualStudioCodeCredential.js → visualStudioCodeCredential-browser.mjs} +1 -1
  72. package/dist/browser/credentials/visualStudioCodeCredential-browser.mjs.map +1 -0
  73. package/dist/browser/credentials/{workloadIdentityCredential.d.ts → workloadIdentityCredential-browser.d.mts} +1 -1
  74. package/dist/browser/credentials/workloadIdentityCredential-browser.d.mts.map +1 -0
  75. package/dist/browser/credentials/{workloadIdentityCredential.js → workloadIdentityCredential-browser.mjs} +1 -1
  76. package/dist/browser/credentials/workloadIdentityCredential-browser.mjs.map +1 -0
  77. package/dist/browser/index.d.ts +18 -18
  78. package/dist/browser/index.d.ts.map +1 -1
  79. package/dist/browser/index.js +19 -19
  80. package/dist/browser/index.js.map +1 -1
  81. package/dist/browser/msal/{msal.d.ts → msal-browser.d.mts} +1 -1
  82. package/dist/browser/msal/msal-browser.d.mts.map +1 -0
  83. package/dist/browser/msal/{msal.js → msal-browser.mjs} +1 -1
  84. package/dist/browser/msal/msal-browser.mjs.map +1 -0
  85. package/dist/browser/msal/utils.d.ts +2 -2
  86. package/dist/browser/msal/utils.d.ts.map +1 -1
  87. package/dist/browser/msal/utils.js +7 -2
  88. package/dist/browser/msal/utils.js.map +1 -1
  89. package/dist/browser/plugins/{consumer.d.ts → consumer-browser.d.mts} +1 -1
  90. package/dist/browser/plugins/consumer-browser.d.mts.map +1 -0
  91. package/dist/browser/plugins/{consumer.js → consumer-browser.mjs} +1 -1
  92. package/dist/browser/plugins/consumer-browser.mjs.map +1 -0
  93. package/dist/browser/util/{processMultiTenantRequest.d.ts → processMultiTenantRequest-browser.d.mts} +1 -1
  94. package/dist/browser/util/processMultiTenantRequest-browser.d.mts.map +1 -0
  95. package/dist/browser/util/{processMultiTenantRequest.js → processMultiTenantRequest-browser.mjs} +1 -1
  96. package/dist/browser/util/processMultiTenantRequest-browser.mjs.map +1 -0
  97. package/dist/browser/util/tenantIdUtils.d.ts +1 -1
  98. package/dist/browser/util/tenantIdUtils.d.ts.map +1 -1
  99. package/dist/browser/util/tenantIdUtils.js +1 -1
  100. package/dist/browser/util/tenantIdUtils.js.map +1 -1
  101. package/dist/commonjs/client/identityClient.d.ts.map +1 -1
  102. package/dist/commonjs/client/identityClient.js +2 -1
  103. package/dist/commonjs/client/identityClient.js.map +2 -2
  104. package/dist/commonjs/constants.d.ts +1 -1
  105. package/dist/commonjs/constants.js +1 -1
  106. package/dist/commonjs/constants.js.map +1 -1
  107. package/dist/commonjs/credentials/azureCliCredential.d.ts.map +1 -1
  108. package/dist/commonjs/credentials/azureCliCredential.js +21 -37
  109. package/dist/commonjs/credentials/azureCliCredential.js.map +3 -3
  110. package/dist/commonjs/credentials/azureDeveloperCliCredential.d.ts +12 -4
  111. package/dist/commonjs/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  112. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +54 -52
  113. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +3 -3
  114. package/dist/commonjs/credentials/azurePipelinesCredential.js.map +1 -1
  115. package/dist/commonjs/credentials/azurePowerShellCredential.d.ts +10 -0
  116. package/dist/commonjs/credentials/azurePowerShellCredential.d.ts.map +1 -1
  117. package/dist/commonjs/credentials/azurePowerShellCredential.js +41 -12
  118. package/dist/commonjs/credentials/azurePowerShellCredential.js.map +2 -2
  119. package/dist/commonjs/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  120. package/dist/commonjs/credentials/clientCertificateCredentialModels.js.map +1 -1
  121. package/dist/commonjs/credentials/defaultAzureCredential.js.map +1 -1
  122. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js.map +1 -1
  123. package/dist/commonjs/credentials/environmentCredential.d.ts.map +1 -1
  124. package/dist/commonjs/credentials/environmentCredential.js.map +2 -2
  125. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  126. package/dist/commonjs/credentials/workloadIdentityCredential.js.map +1 -1
  127. package/dist/commonjs/index.d.ts.map +1 -1
  128. package/dist/commonjs/index.js.map +2 -2
  129. package/dist/commonjs/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  130. package/dist/commonjs/msal/nodeFlows/msalPlugins.js.map +2 -2
  131. package/dist/commonjs/msal/utils.d.ts.map +1 -1
  132. package/dist/commonjs/msal/utils.js +6 -1
  133. package/dist/commonjs/msal/utils.js.map +2 -2
  134. package/dist/commonjs/tsdoc-metadata.json +1 -1
  135. package/dist/commonjs/util/processUtils.d.ts +14 -3
  136. package/dist/commonjs/util/processUtils.d.ts.map +1 -1
  137. package/dist/commonjs/util/processUtils.js +35 -28
  138. package/dist/commonjs/util/processUtils.js.map +3 -3
  139. package/dist/commonjs/util/tenantIdUtils.d.ts.map +1 -1
  140. package/dist/commonjs/util/tenantIdUtils.js.map +1 -1
  141. package/dist/esm/client/identityClient.d.ts.map +1 -1
  142. package/dist/esm/client/identityClient.js +2 -1
  143. package/dist/esm/client/identityClient.js.map +1 -1
  144. package/dist/esm/constants.d.ts +1 -1
  145. package/dist/esm/constants.js +1 -1
  146. package/dist/esm/constants.js.map +1 -1
  147. package/dist/esm/credentials/azureCliCredential.d.ts.map +1 -1
  148. package/dist/esm/credentials/azureCliCredential.js +23 -25
  149. package/dist/esm/credentials/azureCliCredential.js.map +1 -1
  150. package/dist/esm/credentials/azureDeveloperCliCredential.d.ts +12 -4
  151. package/dist/esm/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  152. package/dist/esm/credentials/azureDeveloperCliCredential.js +56 -38
  153. package/dist/esm/credentials/azureDeveloperCliCredential.js.map +1 -1
  154. package/dist/esm/credentials/azurePipelinesCredential.js.map +1 -1
  155. package/dist/esm/credentials/azurePowerShellCredential.d.ts +10 -0
  156. package/dist/esm/credentials/azurePowerShellCredential.d.ts.map +1 -1
  157. package/dist/esm/credentials/azurePowerShellCredential.js +28 -7
  158. package/dist/esm/credentials/azurePowerShellCredential.js.map +1 -1
  159. package/dist/esm/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  160. package/dist/esm/credentials/clientCertificateCredentialModels.js.map +1 -1
  161. package/dist/esm/credentials/defaultAzureCredential.js.map +1 -1
  162. package/dist/esm/credentials/defaultAzureCredentialFunctions.js.map +1 -1
  163. package/dist/esm/credentials/environmentCredential.d.ts.map +1 -1
  164. package/dist/esm/credentials/environmentCredential.js.map +1 -1
  165. package/dist/esm/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  166. package/dist/esm/credentials/workloadIdentityCredential.js.map +1 -1
  167. package/dist/esm/index.d.ts.map +1 -1
  168. package/dist/esm/index.js.map +1 -1
  169. package/dist/esm/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  170. package/dist/esm/msal/nodeFlows/msalPlugins.js.map +1 -1
  171. package/dist/esm/msal/utils.d.ts.map +1 -1
  172. package/dist/esm/msal/utils.js +6 -1
  173. package/dist/esm/msal/utils.js.map +1 -1
  174. package/dist/esm/util/processUtils.d.ts +14 -3
  175. package/dist/esm/util/processUtils.d.ts.map +1 -1
  176. package/dist/esm/util/processUtils.js +36 -19
  177. package/dist/esm/util/processUtils.js.map +1 -1
  178. package/dist/esm/util/tenantIdUtils.d.ts.map +1 -1
  179. package/dist/esm/util/tenantIdUtils.js.map +1 -1
  180. package/dist/workerd/client/identityClient.d.ts.map +1 -1
  181. package/dist/workerd/client/identityClient.js +2 -1
  182. package/dist/workerd/client/identityClient.js.map +1 -1
  183. package/dist/workerd/constants.d.ts +1 -1
  184. package/dist/workerd/constants.js +1 -1
  185. package/dist/workerd/constants.js.map +1 -1
  186. package/dist/workerd/credentials/azureCliCredential.d.ts.map +1 -1
  187. package/dist/workerd/credentials/azureCliCredential.js +23 -25
  188. package/dist/workerd/credentials/azureCliCredential.js.map +1 -1
  189. package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts +12 -4
  190. package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts.map +1 -1
  191. package/dist/workerd/credentials/azureDeveloperCliCredential.js +56 -38
  192. package/dist/workerd/credentials/azureDeveloperCliCredential.js.map +1 -1
  193. package/dist/workerd/credentials/azurePipelinesCredential.js.map +1 -1
  194. package/dist/workerd/credentials/azurePowerShellCredential.d.ts +10 -0
  195. package/dist/workerd/credentials/azurePowerShellCredential.d.ts.map +1 -1
  196. package/dist/workerd/credentials/azurePowerShellCredential.js +28 -7
  197. package/dist/workerd/credentials/azurePowerShellCredential.js.map +1 -1
  198. package/dist/workerd/credentials/clientCertificateCredentialModels.d.ts.map +1 -1
  199. package/dist/workerd/credentials/clientCertificateCredentialModels.js.map +1 -1
  200. package/dist/workerd/credentials/defaultAzureCredential.js.map +1 -1
  201. package/dist/workerd/credentials/defaultAzureCredentialFunctions.js.map +1 -1
  202. package/dist/workerd/credentials/environmentCredential.d.ts.map +1 -1
  203. package/dist/workerd/credentials/environmentCredential.js.map +1 -1
  204. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  205. package/dist/workerd/credentials/workloadIdentityCredential.js.map +1 -1
  206. package/dist/workerd/index.d.ts.map +1 -1
  207. package/dist/workerd/index.js.map +1 -1
  208. package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts.map +1 -1
  209. package/dist/workerd/msal/nodeFlows/msalPlugins.js.map +1 -1
  210. package/dist/workerd/msal/utils.d.ts.map +1 -1
  211. package/dist/workerd/msal/utils.js +6 -1
  212. package/dist/workerd/msal/utils.js.map +1 -1
  213. package/dist/workerd/util/processUtils.d.ts +14 -3
  214. package/dist/workerd/util/processUtils.d.ts.map +1 -1
  215. package/dist/workerd/util/processUtils.js +36 -19
  216. package/dist/workerd/util/processUtils.js.map +1 -1
  217. package/dist/workerd/util/tenantIdUtils.d.ts.map +1 -1
  218. package/dist/workerd/util/tenantIdUtils.js.map +1 -1
  219. package/package.json +28 -17
  220. package/dist/browser/credentials/authorizationCodeCredential.d.ts.map +0 -1
  221. package/dist/browser/credentials/authorizationCodeCredential.js.map +0 -1
  222. package/dist/browser/credentials/azureCliCredential.d.ts.map +0 -1
  223. package/dist/browser/credentials/azureCliCredential.js.map +0 -1
  224. package/dist/browser/credentials/azureDeveloperCliCredential.d.ts.map +0 -1
  225. package/dist/browser/credentials/azureDeveloperCliCredential.js.map +0 -1
  226. package/dist/browser/credentials/azurePipelinesCredential.d.ts.map +0 -1
  227. package/dist/browser/credentials/azurePipelinesCredential.js.map +0 -1
  228. package/dist/browser/credentials/azurePowerShellCredential.d.ts.map +0 -1
  229. package/dist/browser/credentials/azurePowerShellCredential.js.map +0 -1
  230. package/dist/browser/credentials/brokerCredential.d.ts +0 -35
  231. package/dist/browser/credentials/brokerCredential.d.ts.map +0 -1
  232. package/dist/browser/credentials/brokerCredential.js +0 -68
  233. package/dist/browser/credentials/brokerCredential.js.map +0 -1
  234. package/dist/browser/credentials/clientAssertionCredential.d.ts.map +0 -1
  235. package/dist/browser/credentials/clientAssertionCredential.js.map +0 -1
  236. package/dist/browser/credentials/clientCertificateCredential.d.ts.map +0 -1
  237. package/dist/browser/credentials/clientCertificateCredential.js.map +0 -1
  238. package/dist/browser/credentials/clientSecretCredential.d.ts.map +0 -1
  239. package/dist/browser/credentials/clientSecretCredential.js.map +0 -1
  240. package/dist/browser/credentials/defaultAzureCredential.d.ts.map +0 -1
  241. package/dist/browser/credentials/defaultAzureCredential.js.map +0 -1
  242. package/dist/browser/credentials/defaultAzureCredentialFunctions.d.ts +0 -64
  243. package/dist/browser/credentials/defaultAzureCredentialFunctions.d.ts.map +0 -1
  244. package/dist/browser/credentials/defaultAzureCredentialFunctions.js +0 -147
  245. package/dist/browser/credentials/defaultAzureCredentialFunctions.js.map +0 -1
  246. package/dist/browser/credentials/deviceCodeCredential.d.ts.map +0 -1
  247. package/dist/browser/credentials/deviceCodeCredential.js.map +0 -1
  248. package/dist/browser/credentials/environmentCredential.d.ts.map +0 -1
  249. package/dist/browser/credentials/environmentCredential.js.map +0 -1
  250. package/dist/browser/credentials/interactiveBrowserCredential.d.ts.map +0 -1
  251. package/dist/browser/credentials/interactiveBrowserCredential.js.map +0 -1
  252. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.d.ts +0 -18
  253. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.d.ts.map +0 -1
  254. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.js +0 -97
  255. package/dist/browser/credentials/managedIdentityCredential/imdsMsi.js.map +0 -1
  256. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +0 -13
  257. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +0 -1
  258. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.js +0 -43
  259. package/dist/browser/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +0 -1
  260. package/dist/browser/credentials/managedIdentityCredential/index.d.ts.map +0 -1
  261. package/dist/browser/credentials/managedIdentityCredential/index.js.map +0 -1
  262. package/dist/browser/credentials/managedIdentityCredential/models.d.ts +0 -24
  263. package/dist/browser/credentials/managedIdentityCredential/models.d.ts.map +0 -1
  264. package/dist/browser/credentials/managedIdentityCredential/models.js +0 -4
  265. package/dist/browser/credentials/managedIdentityCredential/models.js.map +0 -1
  266. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts +0 -14
  267. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts.map +0 -1
  268. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.js +0 -38
  269. package/dist/browser/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +0 -1
  270. package/dist/browser/credentials/onBehalfOfCredential.d.ts.map +0 -1
  271. package/dist/browser/credentials/onBehalfOfCredential.js.map +0 -1
  272. package/dist/browser/credentials/usernamePasswordCredential.d.ts.map +0 -1
  273. package/dist/browser/credentials/usernamePasswordCredential.js.map +0 -1
  274. package/dist/browser/credentials/visualStudioCodeCredential.d.ts.map +0 -1
  275. package/dist/browser/credentials/visualStudioCodeCredential.js.map +0 -1
  276. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -12
  277. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.d.ts.map +0 -1
  278. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.js +0 -4
  279. package/dist/browser/credentials/visualStudioCodeCredentialPlugin.js.map +0 -1
  280. package/dist/browser/credentials/workloadIdentityCredential.d.ts.map +0 -1
  281. package/dist/browser/credentials/workloadIdentityCredential.js.map +0 -1
  282. package/dist/browser/msal/msal.d.ts.map +0 -1
  283. package/dist/browser/msal/msal.js.map +0 -1
  284. package/dist/browser/msal/nodeFlows/msalClient.d.ts +0 -205
  285. package/dist/browser/msal/nodeFlows/msalClient.d.ts.map +0 -1
  286. package/dist/browser/msal/nodeFlows/msalClient.js +0 -499
  287. package/dist/browser/msal/nodeFlows/msalClient.js.map +0 -1
  288. package/dist/browser/msal/nodeFlows/msalPlugins.d.ts +0 -109
  289. package/dist/browser/msal/nodeFlows/msalPlugins.d.ts.map +0 -1
  290. package/dist/browser/msal/nodeFlows/msalPlugins.js +0 -160
  291. package/dist/browser/msal/nodeFlows/msalPlugins.js.map +0 -1
  292. package/dist/browser/plugins/consumer.d.ts.map +0 -1
  293. package/dist/browser/plugins/consumer.js.map +0 -1
  294. package/dist/browser/regionalAuthority.d.ts +0 -122
  295. package/dist/browser/regionalAuthority.d.ts.map +0 -1
  296. package/dist/browser/regionalAuthority.js +0 -139
  297. package/dist/browser/regionalAuthority.js.map +0 -1
  298. package/dist/browser/util/certificatesUtils.d.ts +0 -13
  299. package/dist/browser/util/certificatesUtils.d.ts.map +0 -1
  300. package/dist/browser/util/certificatesUtils.js +0 -47
  301. package/dist/browser/util/certificatesUtils.js.map +0 -1
  302. package/dist/browser/util/processMultiTenantRequest.d.ts.map +0 -1
  303. package/dist/browser/util/processMultiTenantRequest.js.map +0 -1
  304. package/dist/browser/util/processUtils.d.ts +0 -13
  305. package/dist/browser/util/processUtils.d.ts.map +0 -1
  306. package/dist/browser/util/processUtils.js +0 -32
  307. package/dist/browser/util/processUtils.js.map +0 -1
  308. package/dist/browser/util/subscriptionUtils.d.ts +0 -6
  309. package/dist/browser/util/subscriptionUtils.d.ts.map +0 -1
  310. package/dist/browser/util/subscriptionUtils.js +0 -16
  311. package/dist/browser/util/subscriptionUtils.js.map +0 -1
  312. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -12
  313. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.d.ts.map +0 -1
  314. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js +0 -16
  315. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js.map +0 -7
  316. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts +0 -19
  317. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts.map +0 -1
  318. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js +0 -242
  319. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js.map +0 -7
  320. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.d.ts +0 -87
  321. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.d.ts.map +0 -1
  322. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js +0 -16
  323. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js.map +0 -7
  324. package/dist/commonjs/msal/credentials.d.ts +0 -52
  325. package/dist/commonjs/msal/credentials.d.ts.map +0 -1
  326. package/dist/commonjs/msal/credentials.js +0 -16
  327. package/dist/commonjs/msal/credentials.js.map +0 -7
  328. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -12
  329. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.d.ts.map +0 -1
  330. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.js +0 -4
  331. package/dist/esm/credentials/visualStudioCodeCredentialPlugin.js.map +0 -1
  332. package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts +0 -19
  333. package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts.map +0 -1
  334. package/dist/esm/msal/browserFlows/msalBrowserCommon.js +0 -260
  335. package/dist/esm/msal/browserFlows/msalBrowserCommon.js.map +0 -1
  336. package/dist/esm/msal/browserFlows/msalBrowserOptions.d.ts +0 -87
  337. package/dist/esm/msal/browserFlows/msalBrowserOptions.d.ts.map +0 -1
  338. package/dist/esm/msal/browserFlows/msalBrowserOptions.js +0 -4
  339. package/dist/esm/msal/browserFlows/msalBrowserOptions.js.map +0 -1
  340. package/dist/esm/msal/credentials.d.ts +0 -52
  341. package/dist/esm/msal/credentials.d.ts.map +0 -1
  342. package/dist/esm/msal/credentials.js +0 -4
  343. package/dist/esm/msal/credentials.js.map +0 -1
  344. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts +0 -12
  345. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts.map +0 -1
  346. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js +0 -4
  347. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js.map +0 -1
  348. package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts +0 -19
  349. package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts.map +0 -1
  350. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js +0 -260
  351. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js.map +0 -1
  352. package/dist/workerd/msal/browserFlows/msalBrowserOptions.d.ts +0 -87
  353. package/dist/workerd/msal/browserFlows/msalBrowserOptions.d.ts.map +0 -1
  354. package/dist/workerd/msal/browserFlows/msalBrowserOptions.js +0 -4
  355. package/dist/workerd/msal/browserFlows/msalBrowserOptions.js.map +0 -1
  356. package/dist/workerd/msal/credentials.d.ts +0 -52
  357. package/dist/workerd/msal/credentials.d.ts.map +0 -1
  358. package/dist/workerd/msal/credentials.js +0 -4
  359. package/dist/workerd/msal/credentials.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/azurePipelinesCredential.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { AuthenticationError, CredentialUnavailableError } from \"../errors.js\";\nimport { createHttpHeaders, createPipelineRequest } from \"@azure/core-rest-pipeline\";\n\nimport type { AzurePipelinesCredentialOptions } from \"./azurePipelinesCredentialOptions.js\";\nimport { ClientAssertionCredential } from \"./clientAssertionCredential.js\";\nimport { IdentityClient } from \"../client/identityClient.js\";\nimport type { PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { checkTenantId } from \"../util/tenantIdUtils.js\";\nimport { credentialLogger } from \"../util/logging.js\";\n\nconst credentialName = \"AzurePipelinesCredential\";\nconst logger = credentialLogger(credentialName);\nconst OIDC_API_VERSION = \"7.1\";\n\n/**\n * This credential is designed to be used in Azure Pipelines with service connections\n * as a setup for workload identity federation.\n */\nexport class AzurePipelinesCredential implements TokenCredential {\n private clientAssertionCredential: ClientAssertionCredential | undefined;\n private identityClient: IdentityClient;\n\n /**\n * AzurePipelinesCredential supports Federated Identity on Azure Pipelines through Service Connections.\n * @param tenantId - tenantId associated with the service connection\n * @param clientId - clientId associated with the service connection\n * @param serviceConnectionId - Unique ID for the service connection, as found in the querystring's resourceId key\n * @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.\n * @param options - The identity client options to use for authentication.\n */\n constructor(\n tenantId: string,\n clientId: string,\n serviceConnectionId: string,\n systemAccessToken: string,\n options: AzurePipelinesCredentialOptions = {},\n ) {\n if (!clientId) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. clientId is a required parameter.`,\n );\n }\n if (!tenantId) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. tenantId is a required parameter.`,\n );\n }\n if (!serviceConnectionId) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. serviceConnectionId is a required parameter.`,\n );\n }\n if (!systemAccessToken) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. systemAccessToken is a required parameter.`,\n );\n }\n\n // Allow these headers to be logged for troubleshooting by AzurePipelines.\n options.loggingOptions = {\n ...options?.loggingOptions,\n additionalAllowedHeaderNames: [\n ...(options.loggingOptions?.additionalAllowedHeaderNames ?? []),\n \"x-vss-e2eid\",\n \"x-msedge-ref\",\n ],\n };\n\n this.identityClient = new IdentityClient(options);\n checkTenantId(logger, tenantId);\n logger.info(\n `Invoking AzurePipelinesCredential with tenant ID: ${tenantId}, client ID: ${clientId}, and service connection ID: ${serviceConnectionId}`,\n );\n if (!process.env.SYSTEM_OIDCREQUESTURI) {\n throw new CredentialUnavailableError(\n `${credentialName}: 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\"`,\n );\n }\n\n const oidcRequestUrl = `${process.env.SYSTEM_OIDCREQUESTURI}?api-version=${OIDC_API_VERSION}&serviceConnectionId=${serviceConnectionId}`;\n logger.info(\n `Invoking ClientAssertionCredential with tenant ID: ${tenantId}, client ID: ${clientId} and service connection ID: ${serviceConnectionId}`,\n );\n this.clientAssertionCredential = new ClientAssertionCredential(\n tenantId,\n clientId,\n this.requestOidcToken.bind(this, oidcRequestUrl, systemAccessToken),\n options,\n );\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} or {@link AuthenticationError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options?: GetTokenOptions,\n ): Promise<AccessToken> {\n if (!this.clientAssertionCredential) {\n const errorMessage = `${credentialName}: is unavailable. To use Federation Identity in Azure Pipelines, the following parameters are required - \n tenantId,\n clientId,\n serviceConnectionId,\n systemAccessToken,\n \"SYSTEM_OIDCREQUESTURI\". \n See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;\n logger.error(errorMessage);\n throw new CredentialUnavailableError(errorMessage);\n }\n logger.info(\"Invoking getToken() of Client Assertion Credential\");\n return this.clientAssertionCredential.getToken(scopes, options);\n }\n\n /**\n *\n * @param oidcRequestUrl - oidc request url\n * @param systemAccessToken - system access token\n * @returns OIDC token from Azure Pipelines\n */\n private async requestOidcToken(\n oidcRequestUrl: string,\n systemAccessToken: string,\n ): Promise<string> {\n logger.info(\"Requesting OIDC token from Azure Pipelines...\");\n logger.info(oidcRequestUrl);\n const request = createPipelineRequest({\n url: oidcRequestUrl,\n method: \"POST\",\n headers: createHttpHeaders({\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${systemAccessToken}`,\n // Prevents the service from responding with a redirect HTTP status code (useful for automation).\n \"X-TFS-FedAuthRedirect\": \"Suppress\",\n }),\n });\n const response = await this.identityClient.sendRequest(request);\n return handleOidcResponse(response);\n }\n}\n\nexport function handleOidcResponse(response: PipelineResponse): string {\n // OIDC token is present in `bodyAsText` field\n const text = response.bodyAsText;\n if (!text) {\n logger.error(\n `${credentialName}: Authentication Failed. Received null token from OIDC request. Response status- ${\n response.status\n }. Complete response - ${JSON.stringify(response)}`,\n );\n throw new AuthenticationError(response.status, {\n error: `${credentialName}: Authentication Failed. Received null token from OIDC request.`,\n error_description: `${JSON.stringify(\n response,\n )}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`,\n });\n }\n try {\n const result = JSON.parse(text);\n if (result?.oidcToken) {\n return result.oidcToken;\n } else {\n const errorMessage = `${credentialName}: Authentication Failed. oidcToken field not detected in the response.`;\n let errorDescription = ``;\n if (response.status !== 200) {\n 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`;\n }\n logger.error(errorMessage);\n logger.error(errorDescription);\n throw new AuthenticationError(response.status, {\n error: errorMessage,\n error_description: errorDescription,\n });\n }\n } catch (e: any) {\n const errorDetails = `${credentialName}: Authentication Failed. oidcToken field not detected in the response.`;\n logger.error(\n `Response from service = ${text}, Response Headers [\"x-vss-e2eid\"] = ${response.headers.get(\"x-vss-e2eid\")} \n and [\"x-msedge-ref\"] = ${response.headers.get(\"x-msedge-ref\")}, error message = ${e.message}`,\n );\n logger.error(errorDetails);\n throw new AuthenticationError(response.status, {\n error: errorDetails,\n 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`,\n });\n }\n}\n"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { AuthenticationError, CredentialUnavailableError } from \"../errors.js\";\nimport { createHttpHeaders, createPipelineRequest } from \"@azure/core-rest-pipeline\";\n\nimport type { AzurePipelinesCredentialOptions } from \"./azurePipelinesCredentialOptions.js\";\nimport { ClientAssertionCredential } from \"#platform/credentials/clientAssertionCredential\";\nimport { IdentityClient } from \"../client/identityClient.js\";\nimport type { PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { checkTenantId } from \"../util/tenantIdUtils.js\";\nimport { credentialLogger } from \"../util/logging.js\";\n\nconst credentialName = \"AzurePipelinesCredential\";\nconst logger = credentialLogger(credentialName);\nconst OIDC_API_VERSION = \"7.1\";\n\n/**\n * This credential is designed to be used in Azure Pipelines with service connections\n * as a setup for workload identity federation.\n */\nexport class AzurePipelinesCredential implements TokenCredential {\n private clientAssertionCredential: ClientAssertionCredential | undefined;\n private identityClient: IdentityClient;\n\n /**\n * AzurePipelinesCredential supports Federated Identity on Azure Pipelines through Service Connections.\n * @param tenantId - tenantId associated with the service connection\n * @param clientId - clientId associated with the service connection\n * @param serviceConnectionId - Unique ID for the service connection, as found in the querystring's resourceId key\n * @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.\n * @param options - The identity client options to use for authentication.\n */\n constructor(\n tenantId: string,\n clientId: string,\n serviceConnectionId: string,\n systemAccessToken: string,\n options: AzurePipelinesCredentialOptions = {},\n ) {\n if (!clientId) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. clientId is a required parameter.`,\n );\n }\n if (!tenantId) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. tenantId is a required parameter.`,\n );\n }\n if (!serviceConnectionId) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. serviceConnectionId is a required parameter.`,\n );\n }\n if (!systemAccessToken) {\n throw new CredentialUnavailableError(\n `${credentialName}: is unavailable. systemAccessToken is a required parameter.`,\n );\n }\n\n // Allow these headers to be logged for troubleshooting by AzurePipelines.\n options.loggingOptions = {\n ...options?.loggingOptions,\n additionalAllowedHeaderNames: [\n ...(options.loggingOptions?.additionalAllowedHeaderNames ?? []),\n \"x-vss-e2eid\",\n \"x-msedge-ref\",\n ],\n };\n\n this.identityClient = new IdentityClient(options);\n checkTenantId(logger, tenantId);\n logger.info(\n `Invoking AzurePipelinesCredential with tenant ID: ${tenantId}, client ID: ${clientId}, and service connection ID: ${serviceConnectionId}`,\n );\n if (!process.env.SYSTEM_OIDCREQUESTURI) {\n throw new CredentialUnavailableError(\n `${credentialName}: 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\"`,\n );\n }\n\n const oidcRequestUrl = `${process.env.SYSTEM_OIDCREQUESTURI}?api-version=${OIDC_API_VERSION}&serviceConnectionId=${serviceConnectionId}`;\n logger.info(\n `Invoking ClientAssertionCredential with tenant ID: ${tenantId}, client ID: ${clientId} and service connection ID: ${serviceConnectionId}`,\n );\n this.clientAssertionCredential = new ClientAssertionCredential(\n tenantId,\n clientId,\n this.requestOidcToken.bind(this, oidcRequestUrl, systemAccessToken),\n options,\n );\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} or {@link AuthenticationError} will be thrown with the details of the failure.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options?: GetTokenOptions,\n ): Promise<AccessToken> {\n if (!this.clientAssertionCredential) {\n const errorMessage = `${credentialName}: is unavailable. To use Federation Identity in Azure Pipelines, the following parameters are required - \n tenantId,\n clientId,\n serviceConnectionId,\n systemAccessToken,\n \"SYSTEM_OIDCREQUESTURI\". \n See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;\n logger.error(errorMessage);\n throw new CredentialUnavailableError(errorMessage);\n }\n logger.info(\"Invoking getToken() of Client Assertion Credential\");\n return this.clientAssertionCredential.getToken(scopes, options);\n }\n\n /**\n *\n * @param oidcRequestUrl - oidc request url\n * @param systemAccessToken - system access token\n * @returns OIDC token from Azure Pipelines\n */\n private async requestOidcToken(\n oidcRequestUrl: string,\n systemAccessToken: string,\n ): Promise<string> {\n logger.info(\"Requesting OIDC token from Azure Pipelines...\");\n logger.info(oidcRequestUrl);\n const request = createPipelineRequest({\n url: oidcRequestUrl,\n method: \"POST\",\n headers: createHttpHeaders({\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${systemAccessToken}`,\n // Prevents the service from responding with a redirect HTTP status code (useful for automation).\n \"X-TFS-FedAuthRedirect\": \"Suppress\",\n }),\n });\n const response = await this.identityClient.sendRequest(request);\n return handleOidcResponse(response);\n }\n}\n\nexport function handleOidcResponse(response: PipelineResponse): string {\n // OIDC token is present in `bodyAsText` field\n const text = response.bodyAsText;\n if (!text) {\n logger.error(\n `${credentialName}: Authentication Failed. Received null token from OIDC request. Response status- ${\n response.status\n }. Complete response - ${JSON.stringify(response)}`,\n );\n throw new AuthenticationError(response.status, {\n error: `${credentialName}: Authentication Failed. Received null token from OIDC request.`,\n error_description: `${JSON.stringify(\n response,\n )}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`,\n });\n }\n try {\n const result = JSON.parse(text);\n if (result?.oidcToken) {\n return result.oidcToken;\n } else {\n const errorMessage = `${credentialName}: Authentication Failed. oidcToken field not detected in the response.`;\n let errorDescription = ``;\n if (response.status !== 200) {\n 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`;\n }\n logger.error(errorMessage);\n logger.error(errorDescription);\n throw new AuthenticationError(response.status, {\n error: errorMessage,\n error_description: errorDescription,\n });\n }\n } catch (e: any) {\n const errorDetails = `${credentialName}: Authentication Failed. oidcToken field not detected in the response.`;\n logger.error(\n `Response from service = ${text}, Response Headers [\"x-vss-e2eid\"] = ${response.headers.get(\"x-vss-e2eid\")} \n and [\"x-msedge-ref\"] = ${response.headers.get(\"x-msedge-ref\")}, error message = ${e.message}`,\n );\n logger.error(errorDetails);\n throw new AuthenticationError(response.status, {\n error: errorDetails,\n 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/azurepipelinesc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7C,OAAO,GAAG,cAAc;AAAA,MACxB,mBAAmB,GAAG,KAAK;AAAA,QACzB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACA,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,QAAI,QAAQ,WAAW;AACrB,aAAO,OAAO;AAAA,IAChB,OAAO;AACL,YAAM,eAAe,GAAG,cAAc;AACtC,UAAI,mBAAmB;AACvB,UAAI,SAAS,WAAW,KAAK;AAC3B,2BAAmB,mBAAmB,IAAI,wCAAwC,SAAS,QAAQ,IAAI,aAAa,CAAC,2BAA2B,SAAS,QAAQ,IAAI,cAAc,CAAC;AAAA,MACtL;AACA,aAAO,MAAM,YAAY;AACzB,aAAO,MAAM,gBAAgB;AAC7B,YAAM,IAAI,kCAAoB,SAAS,QAAQ;AAAA,QAC7C,OAAO;AAAA,QACP,mBAAmB;AAAA,MACrB,CAAC;AAAA,IACH;AAAA,EACF,SAAS,GAAQ;AACf,UAAM,eAAe,GAAG,cAAc;AACtC,WAAO;AAAA,MACL,2BAA2B,IAAI,wCAAwC,SAAS,QAAQ,IAAI,aAAa,CAAC;AAAA,+BACjF,SAAS,QAAQ,IAAI,cAAc,CAAC,qBAAqB,EAAE,OAAO;AAAA,IAC7F;AACA,WAAO,MAAM,YAAY;AACzB,UAAM,IAAI,kCAAoB,SAAS,QAAQ;AAAA,MAC7C,OAAO;AAAA,MACP,mBAAmB,cAAc,IAAI,wCAAwC,SAAS,QAAQ,IAAI,aAAa,CAAC,4BAA4B,SAAS,QAAQ,IAAI,cAAc,CAAC;AAAA,IAClL,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,15 @@
1
1
  import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
2
2
  import type { AzurePowerShellCredentialOptions } from "./azurePowerShellCredentialOptions.js";
3
+ /**
4
+ * Creates the child environment used to pass private values to PowerShell.
5
+ *
6
+ * @param resource - The resource passed to PowerShell.
7
+ * @param tenantId - The optional tenant ID passed to PowerShell.
8
+ * @param environment - The environment to copy.
9
+ * @returns A child environment containing canonical private variable names.
10
+ * @internal
11
+ */
12
+ export declare function createPowerShellEnvironment(resource: string, tenantId: string | undefined, environment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
3
13
  /**
4
14
  * Returns a platform-appropriate command name by appending ".exe" on Windows.
5
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"azurePowerShellCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/azurePowerShellCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAStF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AAS9F;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMzD;AAuBD;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;CAI5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;CAOzC,CAAC;AAUF;;;;GAIG;AACH,eAAO,MAAM,YAAY,UAA0B,CAAC;AAMpD;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAC/D,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,4BAA4B,CAAW;IAC/C,OAAO,CAAC,OAAO,CAAC,CAAS;IAEzB;;;;;;;;;;OAUG;gBACS,OAAO,CAAC,EAAE,gCAAgC;IAWtD;;;OAGG;YACW,6BAA6B;IAwE3C;;;;;;OAMG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC;CA0DxB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,S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B/C"}
@@ -19,6 +19,7 @@ var azurePowerShellCredential_exports = {};
19
19
  __export(azurePowerShellCredential_exports, {
20
20
  AzurePowerShellCredential: () => AzurePowerShellCredential,
21
21
  commandStack: () => commandStack,
22
+ createPowerShellEnvironment: () => createPowerShellEnvironment,
22
23
  formatCommand: () => formatCommand,
23
24
  parseJsonToken: () => parseJsonToken,
24
25
  powerShellErrors: () => powerShellErrors,
@@ -31,8 +32,26 @@ var import_scopeUtils = require("../util/scopeUtils.js");
31
32
  var import_errors = require("../errors.js");
32
33
  var import_processUtils = require("../util/processUtils.js");
33
34
  var import_tracing = require("../util/tracing.js");
35
+ var import_core_util = require("@azure/core-util");
34
36
  const logger = (0, import_logging.credentialLogger)("AzurePowerShellCredential");
35
37
  const isWindows = process.platform === "win32";
38
+ const powerShellResourceEnvironmentVariable = "AZURE_IDENTITY_POWERSHELL_RESOURCE";
39
+ const powerShellTenantEnvironmentVariable = "AZURE_IDENTITY_POWERSHELL_TENANT_ID";
40
+ const powerShellPrivateEnvironmentVariables = new Set(
41
+ [powerShellResourceEnvironmentVariable, powerShellTenantEnvironmentVariable].map(
42
+ (name) => name.toLowerCase()
43
+ )
44
+ );
45
+ function createPowerShellEnvironment(resource, tenantId, environment = process.env) {
46
+ const childEnvironment = Object.fromEntries(
47
+ Object.entries(environment).filter(
48
+ ([name]) => !powerShellPrivateEnvironmentVariables.has(name.toLowerCase())
49
+ )
50
+ );
51
+ childEnvironment[powerShellResourceEnvironmentVariable] = resource;
52
+ childEnvironment[powerShellTenantEnvironmentVariable] = tenantId ?? "";
53
+ return childEnvironment;
54
+ }
36
55
  function formatCommand(commandName) {
37
56
  if (isWindows) {
38
57
  return `${commandName}.exe`;
@@ -40,12 +59,13 @@ function formatCommand(commandName) {
40
59
  return commandName;
41
60
  }
42
61
  }
43
- async function runCommands(commands, timeout) {
62
+ async function runCommands(commands, timeout, env) {
44
63
  const results = [];
45
64
  for (const command of commands) {
46
65
  const [file, ...parameters] = command;
47
66
  const result = await import_processUtils.processUtils.execFile(file, parameters, {
48
67
  encoding: "utf8",
68
+ env,
49
69
  timeout
50
70
  });
51
71
  results.push(result);
@@ -105,19 +125,21 @@ class AzurePowerShellCredential {
105
125
  commandStack.shift();
106
126
  continue;
107
127
  }
108
- const results = await runCommands([
128
+ const results = await runCommands(
109
129
  [
110
- powerShellCommand,
111
- "-NoProfile",
112
- "-NonInteractive",
113
- "-Command",
114
- `
115
- $tenantId = "${tenantId ?? ""}"
130
+ [
131
+ powerShellCommand,
132
+ "-NoProfile",
133
+ "-NonInteractive",
134
+ "-Command",
135
+ `
136
+ $tenantId = $env:${powerShellTenantEnvironmentVariable}
137
+ $resource = $env:${powerShellResourceEnvironmentVariable}
116
138
  $m = Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru
117
139
  $useSecureString = $m.Version -ge [version]'2.17.0' -and $m.Version -lt [version]'5.0.0'
118
140
 
119
141
  $params = @{
120
- ResourceUrl = "${resource}"
142
+ ResourceUrl = $resource
121
143
  }
122
144
 
123
145
  if ($tenantId.Length -gt 0) {
@@ -153,8 +175,11 @@ class AzurePowerShellCredential {
153
175
 
154
176
  Write-Output (ConvertTo-Json $result)
155
177
  `
156
- ]
157
- ]);
178
+ ]
179
+ ],
180
+ timeout,
181
+ createPowerShellEnvironment(resource, tenantId)
182
+ );
158
183
  const result = results[0];
159
184
  return parseJsonToken(result);
160
185
  }
@@ -172,7 +197,10 @@ class AzurePowerShellCredential {
172
197
  const scope = typeof scopes === "string" ? scopes : scopes[0];
173
198
  const claimsValue = options.claims;
174
199
  if (claimsValue && claimsValue.trim()) {
175
- const encodedClaims = btoa(claimsValue);
200
+ const encodedClaims = (0, import_core_util.uint8ArrayToString)(
201
+ (0, import_core_util.stringToUint8Array)(claimsValue, "utf-8"),
202
+ "base64"
203
+ );
176
204
  let loginCmd = `Connect-AzAccount -ClaimsChallenge ${encodedClaims}`;
177
205
  const tenantIdFromOptions = options.tenantId;
178
206
  if (tenantIdFromOptions) {
@@ -252,6 +280,7 @@ async function parseJsonToken(result) {
252
280
  0 && (module.exports = {
253
281
  AzurePowerShellCredential,
254
282
  commandStack,
283
+ createPowerShellEnvironment,
255
284
  formatCommand,
256
285
  parseJsonToken,
257
286
  powerShellErrors,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/azurePowerShellCredential.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport {\n checkTenantId,\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\nimport { credentialLogger, formatError, formatSuccess } from \"../util/logging.js\";\nimport { ensureValidScopeForDevTimeCreds, getScopeResource } from \"../util/scopeUtils.js\";\n\nimport type { AzurePowerShellCredentialOptions } from \"./azurePowerShellCredentialOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport { processUtils } from \"../util/processUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\n\nconst logger = credentialLogger(\"AzurePowerShellCredential\");\n\nconst isWindows = process.platform === \"win32\";\n\n/**\n * Returns a platform-appropriate command name by appending \".exe\" on Windows.\n *\n * @internal\n */\nexport function formatCommand(commandName: string): string {\n if (isWindows) {\n return `${commandName}.exe`;\n } else {\n return commandName;\n }\n}\n\n/**\n * Receives a list of commands to run, executes them, then returns the outputs.\n * If anything fails, an error is thrown.\n * @internal\n */\nasync function runCommands(commands: string[][], timeout?: number): Promise<string[]> {\n const results: string[] = [];\n\n for (const command of commands) {\n const [file, ...parameters] = command;\n const result = (await processUtils.execFile(file, parameters, {\n encoding: \"utf8\",\n timeout,\n })) as string;\n\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Known PowerShell errors\n * @internal\n */\nexport const powerShellErrors = {\n login: \"Run Connect-AzAccount to login\",\n installed:\n \"The specified module 'Az.Accounts' with version '2.2.0' was not loaded because no valid module file was found in any module directory\",\n};\n\n/**\n * Messages to use when throwing in this credential.\n * @internal\n */\nexport const powerShellPublicErrorMessages = {\n login:\n \"Please run 'Connect-AzAccount' from PowerShell to authenticate before using this credential.\",\n 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\".`,\n claim:\n \"This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:\",\n troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot.`,\n};\n\n// PowerShell Azure User not logged in error check.\nconst isLoginError: (err: Error) => RegExpMatchArray | null = (err: Error) =>\n err.message.match(`(.*)${powerShellErrors.login}(.*)`);\n\n// Az Module not Installed in Azure PowerShell check.\nconst isNotInstalledError: (err: Error) => RegExpMatchArray | null = (err: Error) =>\n err.message.match(powerShellErrors.installed);\n\n/**\n * The PowerShell commands to be tried, in order.\n *\n * @internal\n */\nexport const commandStack = [formatCommand(\"pwsh\")];\n\nif (isWindows) {\n commandStack.push(formatCommand(\"powershell\"));\n}\n\n/**\n * This credential will use the currently logged-in user information from the\n * Azure PowerShell module. To do so, it will read the user access token and\n * expire time with Azure PowerShell command `Get-AzAccessToken -ResourceUrl {ResourceScope}`\n */\nexport class AzurePowerShellCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private timeout?: number;\n\n /**\n * Creates an instance of the {@link AzurePowerShellCredential}.\n *\n * To use this credential:\n * - Install the Azure Az PowerShell module with:\n * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.\n * - You have already logged in to Azure PowerShell using the command\n * `Connect-AzAccount` from the command line.\n *\n * @param options - Options, to optionally allow multi-tenant requests.\n */\n constructor(options?: AzurePowerShellCredentialOptions) {\n if (options?.tenantId) {\n checkTenantId(logger, options?.tenantId);\n this.tenantId = options?.tenantId;\n }\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n this.timeout = options?.processTimeoutInMs;\n }\n\n /**\n * Gets the access token from Azure PowerShell\n * @param resource - The resource to use when getting the token\n */\n private async getAzurePowerShellAccessToken(\n resource: string,\n tenantId?: string,\n timeout?: number,\n ): Promise<{ Token: string; ExpiresOn: string }> {\n // Clone the stack to avoid mutating it while iterating\n for (const powerShellCommand of [...commandStack]) {\n try {\n await runCommands([[powerShellCommand, \"/?\"]], timeout);\n } catch (e: any) {\n // Remove this credential from the original stack so that we don't try it again.\n commandStack.shift();\n continue;\n }\n\n const results = await runCommands([\n [\n powerShellCommand,\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n `\n $tenantId = \"${tenantId ?? \"\"}\"\n $m = Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru\n $useSecureString = $m.Version -ge [version]'2.17.0' -and $m.Version -lt [version]'5.0.0'\n\n $params = @{\n ResourceUrl = \"${resource}\"\n }\n\n if ($tenantId.Length -gt 0) {\n $params[\"TenantId\"] = $tenantId\n }\n\n if ($useSecureString) {\n $params[\"AsSecureString\"] = $true\n }\n\n $token = Get-AzAccessToken @params\n\n $result = New-Object -TypeName PSObject\n $result | Add-Member -MemberType NoteProperty -Name ExpiresOn -Value $token.ExpiresOn\n\n if ($token.Token -is [System.Security.SecureString]) {\n if ($PSVersionTable.PSVersion.Major -lt 7) {\n $ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($token.Token)\n try {\n $result | Add-Member -MemberType NoteProperty -Name Token -Value ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr))\n }\n finally {\n [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr)\n }\n }\n else {\n $result | Add-Member -MemberType NoteProperty -Name Token -Value ($token.Token | ConvertFrom-SecureString -AsPlainText)\n }\n }\n else {\n $result | Add-Member -MemberType NoteProperty -Name Token -Value $token.Token\n }\n\n Write-Output (ConvertTo-Json $result)\n `,\n ],\n ]);\n\n const result = results[0];\n return parseJsonToken(result);\n }\n throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AccessToken> {\n return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {\n const scope = typeof scopes === \"string\" ? scopes : scopes[0];\n\n const claimsValue = options.claims;\n if (claimsValue && claimsValue.trim()) {\n const encodedClaims = btoa(claimsValue);\n let loginCmd = `Connect-AzAccount -ClaimsChallenge ${encodedClaims}`;\n\n const tenantIdFromOptions = options.tenantId;\n if (tenantIdFromOptions) {\n loginCmd += ` -Tenant ${tenantIdFromOptions}`;\n }\n const error = new CredentialUnavailableError(\n `${powerShellPublicErrorMessages.claim} ${loginCmd}`,\n );\n\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n\n const tenantId = processMultiTenantRequest(\n this.tenantId,\n options,\n this.additionallyAllowedTenantIds,\n );\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n try {\n ensureValidScopeForDevTimeCreds(scope, logger);\n logger.getToken.info(`Using the scope ${scope}`);\n const resource = getScopeResource(scope);\n const response = await this.getAzurePowerShellAccessToken(resource, tenantId, this.timeout);\n logger.getToken.info(formatSuccess(scopes));\n return {\n token: response.Token,\n expiresOnTimestamp: new Date(response.ExpiresOn).getTime(),\n tokenType: \"Bearer\",\n } as AccessToken;\n } catch (err: any) {\n if (isNotInstalledError(err)) {\n const error = new CredentialUnavailableError(powerShellPublicErrorMessages.installed);\n logger.getToken.info(formatError(scope, error));\n throw error;\n } else if (isLoginError(err)) {\n const error = new CredentialUnavailableError(powerShellPublicErrorMessages.login);\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n const error = new CredentialUnavailableError(\n `${err}. ${powerShellPublicErrorMessages.troubleshoot}`,\n );\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n });\n }\n}\n\n/**\n *\n * @internal\n */\nexport async function parseJsonToken(\n result: string,\n): Promise<{ Token: string; ExpiresOn: string }> {\n const jsonRegex = /{[^{}]*}/g;\n const matches = result.match(jsonRegex);\n let resultWithoutToken = result;\n if (matches) {\n try {\n for (const item of matches) {\n try {\n const jsonContent = JSON.parse(item);\n if (jsonContent?.Token) {\n resultWithoutToken = resultWithoutToken.replace(item, \"\");\n if (resultWithoutToken) {\n logger.getToken.warning(resultWithoutToken);\n }\n return jsonContent;\n }\n } catch (e) {\n continue;\n }\n }\n } catch (e: any) {\n throw new Error(`Unable to parse the output of PowerShell. Received output: ${result}`);\n }\n }\n throw new Error(`No access token found in the output. Received output: ${result}`);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAIO;AACP,qBAA6D;AAC7D,wBAAkE;AAGlE,oBAA2C;AAC3C,0BAA6B;AAC7B,qBAA8B;AAE9B,MAAM,aAAS,iCAAiB,2BAA2B;AAE3D,MAAM,YAAY,QAAQ,aAAa;AAOhC,SAAS,cAAc,aAA6B;AACzD,MAAI,WAAW;AACb,WAAO,GAAG,WAAW;AAAA,EACvB,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAOA,eAAe,YAAY,UAAsB,SAAqC;AACpF,QAAM,UAAoB,CAAC;AAE3B,aAAW,WAAW,UAAU;AAC9B,UAAM,CAAC,MAAM,GAAG,UAAU,IAAI;AAC9B,UAAM,SAAU,MAAM,iCAAa,SAAS,MAAM,YAAY;AAAA,MAC5D,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAED,YAAQ,KAAK,MAAM;AAAA,EACrB;AAEA,SAAO;AACT;AAMO,MAAM,mBAAmB;AAAA,EAC9B,OAAO;AAAA,EACP,WACE;AACJ;AAMO,MAAM,gCAA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AAA,QACb;AAAA,MACF,SAAS,KAAU;AACjB,YAAI,oBAAoB,GAAG,GAAG;AAC5B,gBAAMA,SAAQ,IAAI,yCAA2B,8BAA8B,SAAS;AACpF,iBAAO,SAAS,SAAK,4BAAY,OAAOA,MAAK,CAAC;AAC9C,gBAAMA;AAAA,QACR,WAAW,aAAa,GAAG,GAAG;AAC5B,gBAAMA,SAAQ,IAAI,yCAA2B,8BAA8B,KAAK;AAChF,iBAAO,SAAS,SAAK,4BAAY,OAAOA,MAAK,CAAC;AAC9C,gBAAMA;AAAA,QACR;AACA,cAAM,QAAQ,IAAI;AAAA,UAChB,GAAG,GAAG,KAAK,8BAA8B,YAAY;AAAA,QACvD;AACA,eAAO,SAAS,SAAK,4BAAY,OAAO,KAAK,CAAC;AAC9C,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAMA,eAAsB,eACpB,QAC+C;AAC/C,QAAM,YAAY;AAClB,QAAM,UAAU,OAAO,MAAM,SAAS;AACtC,MAAI,qBAAqB;AACzB,MAAI,SAAS;AACX,QAAI;AACF,iBAAW,QAAQ,SAAS;AAC1B,YAAI;AACF,gBAAM,cAAc,KAAK,MAAM,IAAI;AACnC,cAAI,aAAa,OAAO;AACtB,iCAAqB,mBAAmB,QAAQ,MAAM,EAAE;AACxD,gBAAI,oBAAoB;AACtB,qBAAO,SAAS,QAAQ,kBAAkB;AAAA,YAC5C;AACA,mBAAO;AAAA,UACT;AAAA,QACF,SAAS,GAAG;AACV;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,GAAQ;AACf,YAAM,IAAI,MAAM,8DAA8D,MAAM,EAAE;AAAA,IACxF;AAAA,EACF;AACA,QAAM,IAAI,MAAM,yDAAyD,MAAM,EAAE;AACnF;",
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport {\n checkTenantId,\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n} from \"../util/tenantIdUtils.js\";\nimport { credentialLogger, formatError, formatSuccess } from \"../util/logging.js\";\nimport { ensureValidScopeForDevTimeCreds, getScopeResource } from \"../util/scopeUtils.js\";\n\nimport type { AzurePowerShellCredentialOptions } from \"./azurePowerShellCredentialOptions.js\";\nimport { CredentialUnavailableError } from \"../errors.js\";\nimport { processUtils } from \"../util/processUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport { uint8ArrayToString, stringToUint8Array } from \"@azure/core-util\";\n\nconst logger = credentialLogger(\"AzurePowerShellCredential\");\n\nconst isWindows = process.platform === \"win32\";\nconst powerShellResourceEnvironmentVariable = \"AZURE_IDENTITY_POWERSHELL_RESOURCE\";\nconst powerShellTenantEnvironmentVariable = \"AZURE_IDENTITY_POWERSHELL_TENANT_ID\";\nconst powerShellPrivateEnvironmentVariables = new Set(\n [powerShellResourceEnvironmentVariable, powerShellTenantEnvironmentVariable].map((name) =>\n name.toLowerCase(),\n ),\n);\n\n/**\n * Creates the child environment used to pass private values to PowerShell.\n *\n * @param resource - The resource passed to PowerShell.\n * @param tenantId - The optional tenant ID passed to PowerShell.\n * @param environment - The environment to copy.\n * @returns A child environment containing canonical private variable names.\n * @internal\n */\nexport function createPowerShellEnvironment(\n resource: string,\n tenantId: string | undefined,\n environment: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n const childEnvironment = Object.fromEntries(\n Object.entries(environment).filter(\n ([name]) => !powerShellPrivateEnvironmentVariables.has(name.toLowerCase()),\n ),\n );\n childEnvironment[powerShellResourceEnvironmentVariable] = resource;\n childEnvironment[powerShellTenantEnvironmentVariable] = tenantId ?? \"\";\n return childEnvironment;\n}\n\n/**\n * Returns a platform-appropriate command name by appending \".exe\" on Windows.\n *\n * @internal\n */\nexport function formatCommand(commandName: string): string {\n if (isWindows) {\n return `${commandName}.exe`;\n } else {\n return commandName;\n }\n}\n\n/**\n * Receives a list of commands to run, executes them, then returns the outputs.\n * If anything fails, an error is thrown.\n * @internal\n */\nasync function runCommands(\n commands: string[][],\n timeout?: number,\n env?: NodeJS.ProcessEnv,\n): Promise<string[]> {\n const results: string[] = [];\n\n for (const command of commands) {\n const [file, ...parameters] = command;\n const result = await processUtils.execFile(file, parameters, {\n encoding: \"utf8\",\n env,\n timeout,\n });\n\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Known PowerShell errors\n * @internal\n */\nexport const powerShellErrors = {\n login: \"Run Connect-AzAccount to login\",\n installed:\n \"The specified module 'Az.Accounts' with version '2.2.0' was not loaded because no valid module file was found in any module directory\",\n};\n\n/**\n * Messages to use when throwing in this credential.\n * @internal\n */\nexport const powerShellPublicErrorMessages = {\n login:\n \"Please run 'Connect-AzAccount' from PowerShell to authenticate before using this credential.\",\n 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\".`,\n claim:\n \"This credential doesn't support claims challenges. To authenticate with the required claims, please run the following command:\",\n troubleshoot: `To troubleshoot, visit https://aka.ms/azsdk/js/identity/powershellcredential/troubleshoot.`,\n};\n\n// PowerShell Azure User not logged in error check.\nconst isLoginError: (err: Error) => RegExpMatchArray | null = (err: Error) =>\n err.message.match(`(.*)${powerShellErrors.login}(.*)`);\n\n// Az Module not Installed in Azure PowerShell check.\nconst isNotInstalledError: (err: Error) => RegExpMatchArray | null = (err: Error) =>\n err.message.match(powerShellErrors.installed);\n\n/**\n * The PowerShell commands to be tried, in order.\n *\n * @internal\n */\nexport const commandStack = [formatCommand(\"pwsh\")];\n\nif (isWindows) {\n commandStack.push(formatCommand(\"powershell\"));\n}\n\n/**\n * This credential will use the currently logged-in user information from the\n * Azure PowerShell module. To do so, it will read the user access token and\n * expire time with Azure PowerShell command `Get-AzAccessToken -ResourceUrl {ResourceScope}`\n */\nexport class AzurePowerShellCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private timeout?: number;\n\n /**\n * Creates an instance of the {@link AzurePowerShellCredential}.\n *\n * To use this credential:\n * - Install the Azure Az PowerShell module with:\n * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.\n * - You have already logged in to Azure PowerShell using the command\n * `Connect-AzAccount` from the command line.\n *\n * @param options - Options, to optionally allow multi-tenant requests.\n */\n constructor(options?: AzurePowerShellCredentialOptions) {\n if (options?.tenantId) {\n checkTenantId(logger, options?.tenantId);\n this.tenantId = options?.tenantId;\n }\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n this.timeout = options?.processTimeoutInMs;\n }\n\n /**\n * Gets the access token from Azure PowerShell\n * @param resource - The resource to use when getting the token\n */\n private async getAzurePowerShellAccessToken(\n resource: string,\n tenantId?: string,\n timeout?: number,\n ): Promise<{ Token: string; ExpiresOn: string }> {\n // Clone the stack to avoid mutating it while iterating\n for (const powerShellCommand of [...commandStack]) {\n try {\n await runCommands([[powerShellCommand, \"/?\"]], timeout);\n } catch (e: any) {\n // Remove this credential from the original stack so that we don't try it again.\n commandStack.shift();\n continue;\n }\n\n const results = await runCommands(\n [\n [\n powerShellCommand,\n \"-NoProfile\",\n \"-NonInteractive\",\n \"-Command\",\n `\n $tenantId = $env:${powerShellTenantEnvironmentVariable}\n $resource = $env:${powerShellResourceEnvironmentVariable}\n $m = Import-Module Az.Accounts -MinimumVersion 2.2.0 -PassThru\n $useSecureString = $m.Version -ge [version]'2.17.0' -and $m.Version -lt [version]'5.0.0'\n\n $params = @{\n ResourceUrl = $resource\n }\n\n if ($tenantId.Length -gt 0) {\n $params[\"TenantId\"] = $tenantId\n }\n\n if ($useSecureString) {\n $params[\"AsSecureString\"] = $true\n }\n\n $token = Get-AzAccessToken @params\n\n $result = New-Object -TypeName PSObject\n $result | Add-Member -MemberType NoteProperty -Name ExpiresOn -Value $token.ExpiresOn\n\n if ($token.Token -is [System.Security.SecureString]) {\n if ($PSVersionTable.PSVersion.Major -lt 7) {\n $ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($token.Token)\n try {\n $result | Add-Member -MemberType NoteProperty -Name Token -Value ([System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr))\n }\n finally {\n [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr)\n }\n }\n else {\n $result | Add-Member -MemberType NoteProperty -Name Token -Value ($token.Token | ConvertFrom-SecureString -AsPlainText)\n }\n }\n else {\n $result | Add-Member -MemberType NoteProperty -Name Token -Value $token.Token\n }\n\n Write-Output (ConvertTo-Json $result)\n `,\n ],\n ],\n timeout,\n createPowerShellEnvironment(resource, tenantId),\n );\n\n const result = results[0];\n return parseJsonToken(result);\n }\n throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this TokenCredential implementation might make.\n */\n public async getToken(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AccessToken> {\n return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {\n const scope = typeof scopes === \"string\" ? scopes : scopes[0];\n\n const claimsValue = options.claims;\n if (claimsValue && claimsValue.trim()) {\n const encodedClaims = uint8ArrayToString(\n stringToUint8Array(claimsValue, \"utf-8\"),\n \"base64\",\n );\n let loginCmd = `Connect-AzAccount -ClaimsChallenge ${encodedClaims}`;\n\n const tenantIdFromOptions = options.tenantId;\n if (tenantIdFromOptions) {\n loginCmd += ` -Tenant ${tenantIdFromOptions}`;\n }\n const error = new CredentialUnavailableError(\n `${powerShellPublicErrorMessages.claim} ${loginCmd}`,\n );\n\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n\n const tenantId = processMultiTenantRequest(\n this.tenantId,\n options,\n this.additionallyAllowedTenantIds,\n );\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n try {\n ensureValidScopeForDevTimeCreds(scope, logger);\n logger.getToken.info(`Using the scope ${scope}`);\n const resource = getScopeResource(scope);\n const response = await this.getAzurePowerShellAccessToken(resource, tenantId, this.timeout);\n logger.getToken.info(formatSuccess(scopes));\n return {\n token: response.Token,\n expiresOnTimestamp: new Date(response.ExpiresOn).getTime(),\n tokenType: \"Bearer\",\n } as AccessToken;\n } catch (err: any) {\n if (isNotInstalledError(err)) {\n const error = new CredentialUnavailableError(powerShellPublicErrorMessages.installed);\n logger.getToken.info(formatError(scope, error));\n throw error;\n } else if (isLoginError(err)) {\n const error = new CredentialUnavailableError(powerShellPublicErrorMessages.login);\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n const error = new CredentialUnavailableError(\n `${err}. ${powerShellPublicErrorMessages.troubleshoot}`,\n );\n logger.getToken.info(formatError(scope, error));\n throw error;\n }\n });\n }\n}\n\n/**\n *\n * @internal\n */\nexport async function parseJsonToken(\n result: string,\n): Promise<{ Token: string; ExpiresOn: string }> {\n const jsonRegex = /{[^{}]*}/g;\n const matches = result.match(jsonRegex);\n let resultWithoutToken = result;\n if (matches) {\n try {\n for (const item of matches) {\n try {\n const jsonContent = JSON.parse(item);\n if (jsonContent?.Token) {\n resultWithoutToken = resultWithoutToken.replace(item, \"\");\n if (resultWithoutToken) {\n logger.getToken.warning(resultWithoutToken);\n }\n return jsonContent;\n }\n } catch (e) {\n continue;\n }\n }\n } catch (e: any) {\n throw new Error(`Unable to parse the output of PowerShell. Received output: ${result}`);\n }\n }\n throw new Error(`No access token found in the output. Received output: ${result}`);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAIO;AACP,qBAA6D;AAC7D,wBAAkE;AAGlE,oBAA2C;AAC3C,0BAA6B;AAC7B,qBAA8B;AAC9B,uBAAuD;AAEvD,MAAM,aAAS,iCAAiB,2BAA2B;A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AC;AAC9C,gBAAMA;AAAA,QACR,WAAW,aAAa,GAAG,GAAG;AAC5B,gBAAMA,SAAQ,IAAI,yCAA2B,8BAA8B,KAAK;AAChF,iBAAO,SAAS,SAAK,4BAAY,OAAOA,MAAK,CAAC;AAC9C,gBAAMA;AAAA,QACR;AACA,cAAM,QAAQ,IAAI;AAAA,UAChB,GAAG,GAAG,KAAK,8BAA8B,YAAY;AAAA,QACvD;AACA,eAAO,SAAS,SAAK,4BAAY,OAAO,KAAK,CAAC;AAC9C,cAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAMA,eAAsB,eACpB,QAC+C;AAC/C,QAAM,YAAY;AAClB,QAAM,UAAU,OAAO,MAAM,SAAS;AACtC,MAAI,qBAAqB;AACzB,MAAI,SAAS;AACX,QAAI;AACF,iBAAW,QAAQ,SAAS;AAC1B,YAAI;AACF,gBAAM,cAAc,KAAK,MAAM,IAAI;AACnC,cAAI,aAAa,OAAO;AACtB,iCAAqB,mBAAmB,QAAQ,MAAM,EAAE;AACxD,gBAAI,oBAAoB;AACtB,qBAAO,SAAS,QAAQ,kBAAkB;AAAA,YAC5C;AACA,mBAAO;AAAA,UACT;AAAA,QACF,SAAS,GAAG;AACV;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,GAAQ;AACf,YAAM,IAAI,MAAM,8DAA8D,MAAM,EAAE;AAAA,IACxF;AAAA,EACF;AACA,QAAM,IAAI,MAAM,yDAAyD,MAAM,EAAE;AACnF;",
6
6
  "names": ["error"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clientCertificateCredentialModels.d.ts","sourceRoot":"","sources":["../../../src/credentials/clientCertificateCredentialModels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACnD,+BAA+B,GAC/B,mCAAmC,CAAC"}
1
+ {"version":3,"file":"clientCertificateCredentialModels.d.ts","sourceRoot":"","sources":["../../../src/credentials/clientCertificateCredentialModels.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AACD;;GAEG;AACH,MAAM,MAAM,2CAA2C,GACrD,+BAA+B,GAAG,mCAAmC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/clientCertificateCredentialModels.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate\n */\nexport interface ClientCertificatePEMCertificate {\n /**\n * The PEM-encoded public/private key certificate on the filesystem.\n * Ensure that certificate is in PEM format and contains both the public and private keys.\n */\n certificate: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.\n */\nexport interface ClientCertificatePEMCertificatePath {\n /**\n * The path to the PEM-encoded public/private key certificate on the filesystem.\n */\n certificatePath: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.\n */\nexport type ClientCertificateCredentialPEMConfiguration =\n | ClientCertificatePEMCertificate\n | ClientCertificatePEMCertificatePath;\n"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate\n */\nexport interface ClientCertificatePEMCertificate {\n /**\n * The PEM-encoded public/private key certificate on the filesystem.\n * Ensure that certificate is in PEM format and contains both the public and private keys.\n */\n certificate: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.\n */\nexport interface ClientCertificatePEMCertificatePath {\n /**\n * The path to the PEM-encoded public/private key certificate on the filesystem.\n */\n certificatePath: string;\n\n /**\n * The password for the certificate file.\n */\n certificatePassword?: string;\n}\n/**\n * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.\n */\nexport type ClientCertificateCredentialPEMConfiguration =\n ClientCertificatePEMCertificate | ClientCertificatePEMCertificatePath;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/defaultAzureCredential.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\n\nimport { ManagedIdentityCredential } from \"./managedIdentityCredential/index.js\";\nimport { VisualStudioCodeCredential } from \"./visualStudioCodeCredential.js\";\nimport { AzureCliCredential } from \"./azureCliCredential.js\";\nimport { AzureDeveloperCliCredential } from \"./azureDeveloperCliCredential.js\";\nimport { AzurePowerShellCredential } from \"./azurePowerShellCredential.js\";\nimport { ChainedTokenCredential } from \"./chainedTokenCredential.js\";\nimport { EnvironmentCredential } from \"./environmentCredential.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { WorkloadIdentityCredential } from \"./workloadIdentityCredential.js\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport {\n createDefaultAzureCliCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultBrokerCredential,\n createDefaultManagedIdentityCredential,\n createDefaultVisualStudioCodeCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultEnvironmentCredential,\n} from \"./defaultAzureCredentialFunctions.js\";\n\nconst logger = credentialLogger(\"DefaultAzureCredential\");\n\n/**\n * A no-op credential that logs the reason it was skipped if getToken is called.\n * @internal\n */\nexport class UnavailableDefaultCredential implements TokenCredential {\n credentialUnavailableErrorMessage: string;\n credentialName: string;\n\n constructor(credentialName: string, message: string) {\n this.credentialName = credentialName;\n this.credentialUnavailableErrorMessage = message;\n }\n\n getToken(): Promise<null> {\n logger.getToken.info(\n `Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`,\n );\n return Promise.resolve(null);\n }\n}\n\n/**\n * Provides a default {@link ChainedTokenCredential} configuration that works for most\n * applications that use Azure SDK client libraries. For more information, see\n * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#defaultazurecredential-overview).\n *\n * The following credential types will be tried, in order:\n *\n * - {@link EnvironmentCredential}\n * - {@link WorkloadIdentityCredential}\n * - {@link ManagedIdentityCredential}\n * - {@link VisualStudioCodeCredential}\n * - {@link AzureCliCredential}\n * - {@link AzurePowerShellCredential}\n * - {@link AzureDeveloperCliCredential}\n * - BrokerCredential (a broker-enabled credential that requires \\@azure/identity-broker is installed)\n *\n * Consult the documentation of these credential types for more information\n * on how they attempt authentication.\n *\n * The following example demonstrates how to use the `requiredEnvVars` option to ensure that certain environment variables are set before the `DefaultAzureCredential` is instantiated.\n * If any of the specified environment variables are missing or empty, an error will be thrown, preventing the application from continuing execution without the necessary configuration.\n * It also demonstrates how to set the `AZURE_TOKEN_CREDENTIALS` environment variable to control which credentials are included in the chain.\n \n * ```ts snippet:defaultazurecredential_requiredEnvVars\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential({\n * requiredEnvVars: [\n * \"AZURE_CLIENT_ID\",\n * \"AZURE_TENANT_ID\",\n * \"AZURE_CLIENT_SECRET\",\n * \"AZURE_TOKEN_CREDENTIALS\",\n * ],\n * });\n * ```\n */\nexport class DefaultAzureCredential extends ChainedTokenCredential {\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialClientIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialResourceIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialResourceIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialResourceIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.\n */\n constructor(options?: DefaultAzureCredentialOptions);\n\n constructor(options?: DefaultAzureCredentialOptions) {\n validateRequiredEnvVars(options);\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n const azureTokenCredentials = process.env.AZURE_TOKEN_CREDENTIALS\n ? process.env.AZURE_TOKEN_CREDENTIALS.trim().toLowerCase()\n : undefined;\n const devCredentialFunctions = [\n createDefaultVisualStudioCodeCredential,\n createDefaultAzureCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultBrokerCredential,\n ];\n const prodCredentialFunctions = [\n createDefaultEnvironmentCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultManagedIdentityCredential,\n ];\n let credentialFunctions = [];\n const validCredentialNames =\n \"EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential\";\n // If AZURE_TOKEN_CREDENTIALS is set, use it to determine which credentials to use.\n // The value of AZURE_TOKEN_CREDENTIALS should be either \"dev\" or \"prod\" or any one of these credentials - {validCredentialNames}.\n if (azureTokenCredentials) {\n switch (azureTokenCredentials) {\n case \"dev\":\n credentialFunctions = devCredentialFunctions;\n break;\n case \"prod\":\n credentialFunctions = prodCredentialFunctions;\n break;\n case \"environmentcredential\":\n credentialFunctions = [createDefaultEnvironmentCredential];\n break;\n case \"workloadidentitycredential\":\n credentialFunctions = [createDefaultWorkloadIdentityCredential];\n break;\n case \"managedidentitycredential\":\n // Setting `sendProbeRequest` to false to ensure ManagedIdentityCredential behavior\n // is consistent when used standalone in DAC chain or used directly.\n credentialFunctions = [\n () => createDefaultManagedIdentityCredential({ sendProbeRequest: false }),\n ];\n break;\n case \"visualstudiocodecredential\":\n credentialFunctions = [createDefaultVisualStudioCodeCredential];\n break;\n case \"azureclicredential\":\n credentialFunctions = [createDefaultAzureCliCredential];\n break;\n case \"azurepowershellcredential\":\n credentialFunctions = [createDefaultAzurePowershellCredential];\n break;\n case \"azuredeveloperclicredential\":\n credentialFunctions = [createDefaultAzureDeveloperCliCredential];\n break;\n default: {\n // If AZURE_TOKEN_CREDENTIALS is set to an unsupported value, throw an error.\n // This will prevent the creation of the DefaultAzureCredential.\n const errorMessage = `Invalid value for AZURE_TOKEN_CREDENTIALS = ${process.env.AZURE_TOKEN_CREDENTIALS}. Valid values are 'prod' or 'dev' or any of these credentials - ${validCredentialNames}.`;\n logger.warning(errorMessage);\n throw new Error(errorMessage);\n }\n }\n } else {\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n credentialFunctions = [...prodCredentialFunctions, ...devCredentialFunctions];\n }\n\n // Errors from individual credentials should not be thrown in the DefaultAzureCredential constructor, instead throwing on getToken() which is handled by ChainedTokenCredential.\n // When adding new credentials to the default chain, consider:\n // 1. Making the constructor parameters required and explicit\n // 2. Validating any required parameters in the factory function\n // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason\n const credentials: TokenCredential[] = credentialFunctions.map((createCredentialFn) => {\n try {\n return createCredentialFn(options ?? {});\n } catch (err: any) {\n logger.warning(\n `Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`,\n );\n return new UnavailableDefaultCredential(createCredentialFn.name, err.message);\n }\n });\n\n super(...credentials);\n }\n}\n\n/**\n * This function checks that all environment variables in `options.requiredEnvVars` are set and non-empty.\n * If any are missing or empty, it throws an error.\n */\nfunction validateRequiredEnvVars(options?: DefaultAzureCredentialOptions) {\n if (options?.requiredEnvVars) {\n const requiredVars = Array.isArray(options.requiredEnvVars)\n ? options.requiredEnvVars\n : [options.requiredEnvVars];\n const missing = requiredVars.filter((envVar) => !process.env[envVar]);\n if (missing.length > 0) {\n const errorMessage = `Required environment ${missing.length === 1 ? \"variable\" : \"variables\"} '${missing.join(\", \")}' for DefaultAzureCredential ${missing.length === 1 ? \"is\" : \"are\"} not set or empty.`;\n logger.warning(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\n\nimport { ManagedIdentityCredential } from \"#platform/credentials/managedIdentityCredential/index\";\nimport { VisualStudioCodeCredential } from \"#platform/credentials/visualStudioCodeCredential\";\nimport { AzureCliCredential } from \"#platform/credentials/azureCliCredential\";\nimport { AzureDeveloperCliCredential } from \"#platform/credentials/azureDeveloperCliCredential\";\nimport { AzurePowerShellCredential } from \"#platform/credentials/azurePowerShellCredential\";\nimport { ChainedTokenCredential } from \"./chainedTokenCredential.js\";\nimport { EnvironmentCredential } from \"#platform/credentials/environmentCredential\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport { WorkloadIdentityCredential } from \"#platform/credentials/workloadIdentityCredential\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport {\n createDefaultAzureCliCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultBrokerCredential,\n createDefaultManagedIdentityCredential,\n createDefaultVisualStudioCodeCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultEnvironmentCredential,\n} from \"./defaultAzureCredentialFunctions.js\";\n\nconst logger = credentialLogger(\"DefaultAzureCredential\");\n\n/**\n * A no-op credential that logs the reason it was skipped if getToken is called.\n * @internal\n */\nexport class UnavailableDefaultCredential implements TokenCredential {\n credentialUnavailableErrorMessage: string;\n credentialName: string;\n\n constructor(credentialName: string, message: string) {\n this.credentialName = credentialName;\n this.credentialUnavailableErrorMessage = message;\n }\n\n getToken(): Promise<null> {\n logger.getToken.info(\n `Skipping ${this.credentialName}, reason: ${this.credentialUnavailableErrorMessage}`,\n );\n return Promise.resolve(null);\n }\n}\n\n/**\n * Provides a default {@link ChainedTokenCredential} configuration that works for most\n * applications that use Azure SDK client libraries. For more information, see\n * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#defaultazurecredential-overview).\n *\n * The following credential types will be tried, in order:\n *\n * - {@link EnvironmentCredential}\n * - {@link WorkloadIdentityCredential}\n * - {@link ManagedIdentityCredential}\n * - {@link VisualStudioCodeCredential}\n * - {@link AzureCliCredential}\n * - {@link AzurePowerShellCredential}\n * - {@link AzureDeveloperCliCredential}\n * - BrokerCredential (a broker-enabled credential that requires \\@azure/identity-broker is installed)\n *\n * Consult the documentation of these credential types for more information\n * on how they attempt authentication.\n *\n * The following example demonstrates how to use the `requiredEnvVars` option to ensure that certain environment variables are set before the `DefaultAzureCredential` is instantiated.\n * If any of the specified environment variables are missing or empty, an error will be thrown, preventing the application from continuing execution without the necessary configuration.\n * It also demonstrates how to set the `AZURE_TOKEN_CREDENTIALS` environment variable to control which credentials are included in the chain.\n \n * ```ts snippet:defaultazurecredential_requiredEnvVars\n * import { DefaultAzureCredential } from \"@azure/identity\";\n *\n * const credential = new DefaultAzureCredential({\n * requiredEnvVars: [\n * \"AZURE_CLIENT_ID\",\n * \"AZURE_TENANT_ID\",\n * \"AZURE_CLIENT_SECRET\",\n * \"AZURE_TOKEN_CREDENTIALS\",\n * ],\n * });\n * ```\n */\nexport class DefaultAzureCredential extends ChainedTokenCredential {\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialClientIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialResourceIdOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialResourceIdOptions}.\n */\n constructor(options?: DefaultAzureCredentialResourceIdOptions);\n\n /**\n * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialOptions}.\n *\n * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.\n */\n constructor(options?: DefaultAzureCredentialOptions);\n\n constructor(options?: DefaultAzureCredentialOptions) {\n validateRequiredEnvVars(options);\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n const azureTokenCredentials = process.env.AZURE_TOKEN_CREDENTIALS\n ? process.env.AZURE_TOKEN_CREDENTIALS.trim().toLowerCase()\n : undefined;\n const devCredentialFunctions = [\n createDefaultVisualStudioCodeCredential,\n createDefaultAzureCliCredential,\n createDefaultAzurePowershellCredential,\n createDefaultAzureDeveloperCliCredential,\n createDefaultBrokerCredential,\n ];\n const prodCredentialFunctions = [\n createDefaultEnvironmentCredential,\n createDefaultWorkloadIdentityCredential,\n createDefaultManagedIdentityCredential,\n ];\n let credentialFunctions = [];\n const validCredentialNames =\n \"EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowerShellCredential, AzureDeveloperCliCredential\";\n // If AZURE_TOKEN_CREDENTIALS is set, use it to determine which credentials to use.\n // The value of AZURE_TOKEN_CREDENTIALS should be either \"dev\" or \"prod\" or any one of these credentials - {validCredentialNames}.\n if (azureTokenCredentials) {\n switch (azureTokenCredentials) {\n case \"dev\":\n credentialFunctions = devCredentialFunctions;\n break;\n case \"prod\":\n credentialFunctions = prodCredentialFunctions;\n break;\n case \"environmentcredential\":\n credentialFunctions = [createDefaultEnvironmentCredential];\n break;\n case \"workloadidentitycredential\":\n credentialFunctions = [createDefaultWorkloadIdentityCredential];\n break;\n case \"managedidentitycredential\":\n // Setting `sendProbeRequest` to false to ensure ManagedIdentityCredential behavior\n // is consistent when used standalone in DAC chain or used directly.\n credentialFunctions = [\n () => createDefaultManagedIdentityCredential({ sendProbeRequest: false }),\n ];\n break;\n case \"visualstudiocodecredential\":\n credentialFunctions = [createDefaultVisualStudioCodeCredential];\n break;\n case \"azureclicredential\":\n credentialFunctions = [createDefaultAzureCliCredential];\n break;\n case \"azurepowershellcredential\":\n credentialFunctions = [createDefaultAzurePowershellCredential];\n break;\n case \"azuredeveloperclicredential\":\n credentialFunctions = [createDefaultAzureDeveloperCliCredential];\n break;\n default: {\n // If AZURE_TOKEN_CREDENTIALS is set to an unsupported value, throw an error.\n // This will prevent the creation of the DefaultAzureCredential.\n const errorMessage = `Invalid value for AZURE_TOKEN_CREDENTIALS = ${process.env.AZURE_TOKEN_CREDENTIALS}. Valid values are 'prod' or 'dev' or any of these credentials - ${validCredentialNames}.`;\n logger.warning(errorMessage);\n throw new Error(errorMessage);\n }\n }\n } else {\n // If AZURE_TOKEN_CREDENTIALS is not set, use the default credential chain.\n credentialFunctions = [...prodCredentialFunctions, ...devCredentialFunctions];\n }\n\n // Errors from individual credentials should not be thrown in the DefaultAzureCredential constructor, instead throwing on getToken() which is handled by ChainedTokenCredential.\n // When adding new credentials to the default chain, consider:\n // 1. Making the constructor parameters required and explicit\n // 2. Validating any required parameters in the factory function\n // 3. Returning a UnavailableDefaultCredential from the factory function if a credential is unavailable for any reason\n const credentials: TokenCredential[] = credentialFunctions.map((createCredentialFn) => {\n try {\n return createCredentialFn(options ?? {});\n } catch (err: any) {\n logger.warning(\n `Skipped ${createCredentialFn.name} because of an error creating the credential: ${err}`,\n );\n return new UnavailableDefaultCredential(createCredentialFn.name, err.message);\n }\n });\n\n super(...credentials);\n }\n}\n\n/**\n * This function checks that all environment variables in `options.requiredEnvVars` are set and non-empty.\n * If any are missing or empty, it throws an error.\n */\nfunction validateRequiredEnvVars(options?: DefaultAzureCredentialOptions) {\n if (options?.requiredEnvVars) {\n const requiredVars = Array.isArray(options.requiredEnvVars)\n ? options.requiredEnvVars\n : [options.requiredEnvVars];\n const missing = requiredVars.filter((envVar) => !process.env[envVar]);\n if (missing.length > 0) {\n const errorMessage = `Required environment ${missing.length === 1 ? \"variable\" : \"variables\"} '${missing.join(\", \")}' for DefaultAzureCredential ${missing.length === 1 ? \"is\" : \"are\"} not set or empty.`;\n logger.warning(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,oCAAuC;AAIvC,qBAAiC;AACjC,6CASO;AAEP,MAAM,aAAS,iCAAiB,wBAAwB;AAMjD,MAAM,6BAAwD;AAAA,EACnE;AAAA,EACA;AAAA,EAEA,YAAY,gBAAwB,SAAiB;AACnD,SAAK,iBAAiB;AACtB,SAAK,oCAAoC;AAAA,EAC3C;AAAA,EAEA,WAA0B;AACxB,WAAO,SAAS;AAAA,MACd,YAAY,KAAK,cAAc,aAAa,KAAK,iCAAiC;AAAA,IACpF;AACA,WAAO,QAAQ,QAAQ,IAAI;AAAA,EAC7B;AACF;AAsCO,MAAM,+BAA+B,qDAAuB;AAAA,EAsBjE,YAAY,SAAyC;AACnD,4BAAwB,OAAO;AAE/B,UAAM,wBAAwB,QAAQ,IAAI,0BACtC,QAAQ,IAAI,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AM,IAAI,OAAO;AAAA,MAC9E;AAAA,IACF,CAAC;AAED,UAAM,GAAG,WAAW;AAAA,EACtB;AACF;AAMA,SAAS,wBAAwB,SAAyC;AACxE,MAAI,SAAS,iBAAiB;AAC5B,UAAM,eAAe,MAAM,QAAQ,QAAQ,eAAe,IACtD,QAAQ,kBACR,CAAC,QAAQ,eAAe;AAC5B,UAAM,UAAU,aAAa,OAAO,CAAC,WAAW,CAAC,QAAQ,IAAI,MAAM,CAAC;AACpE,QAAI,QAAQ,SAAS,GAAG;AACtB,YAAM,eAAe,wBAAwB,QAAQ,WAAW,IAAI,aAAa,WAAW,KAAK,QAAQ,KAAK,IAAI,CAAC,gCAAgC,QAAQ,WAAW,IAAI,OAAO,KAAK;AACtL,aAAO,QAAQ,YAAY;AAC3B,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/defaultAzureCredentialFunctions.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\nimport { EnvironmentCredential } from \"./environmentCredential.js\";\nimport type {\n ManagedIdentityCredentialClientIdOptions,\n ManagedIdentityCredentialResourceIdOptions,\n} from \"./managedIdentityCredential/options.js\";\nimport { ManagedIdentityCredential } from \"./managedIdentityCredential/index.js\";\nimport { WorkloadIdentityCredential } from \"./workloadIdentityCredential.js\";\nimport { AzureDeveloperCliCredential } from \"./azureDeveloperCliCredential.js\";\nimport { AzureCliCredential } from \"./azureCliCredential.js\";\nimport { AzurePowerShellCredential } from \"./azurePowerShellCredential.js\";\nimport type { WorkloadIdentityCredentialOptions } from \"./workloadIdentityCredentialOptions.js\";\nimport { VisualStudioCodeCredential } from \"./visualStudioCodeCredential.js\";\nimport { BrokerCredential } from \"./brokerCredential.js\";\n\n/**\n * Creates a {@link BrokerCredential} instance with the provided options.\n * This credential uses the Windows Authentication Manager (WAM) broker for authentication.\n * It will only attempt to authenticate silently using the default broker account\n *\n * @param options - Options for configuring the credential.\n *\n * @internal\n */\nexport function createDefaultBrokerCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new BrokerCredential(options);\n}\n\n/**\n * Creates a {@link VisualStudioCodeCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultVisualStudioCodeCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new VisualStudioCodeCredential(options);\n}\n\n/**\n * Creates a {@link ManagedIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultManagedIdentityCredential(\n options: (\n | DefaultAzureCredentialOptions\n | DefaultAzureCredentialResourceIdOptions\n | DefaultAzureCredentialClientIdOptions\n ) & { sendProbeRequest?: boolean } = {},\n): TokenCredential {\n options.retryOptions ??= {\n maxRetries: 5,\n retryDelayInMs: 800,\n };\n // ManagedIdentityCredential inside DAC chain should send a probe request by default.\n // This is different from standalone ManagedIdentityCredential behavior\n // or when AZURE_TOKEN_CREDENTIALS is set to only ManagedIdentityCredential.\n options.sendProbeRequest ??= true;\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const managedResourceId = (options as DefaultAzureCredentialResourceIdOptions)\n ?.managedIdentityResourceId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (managedResourceId) {\n const managedIdentityResourceIdOptions: ManagedIdentityCredentialResourceIdOptions = {\n ...options,\n resourceId: managedResourceId,\n };\n return new ManagedIdentityCredential(managedIdentityResourceIdOptions);\n }\n\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: DefaultAzureCredentialOptions = {\n ...options,\n tenantId: tenantId,\n };\n\n return new ManagedIdentityCredential(\n workloadIdentityClientId,\n workloadIdentityCredentialOptions,\n );\n }\n\n if (managedIdentityClientId) {\n const managedIdentityClientOptions: ManagedIdentityCredentialClientIdOptions = {\n ...options,\n clientId: managedIdentityClientId,\n };\n\n return new ManagedIdentityCredential(managedIdentityClientOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new ManagedIdentityCredential(options);\n}\n\n/**\n * Creates a {@link WorkloadIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultWorkloadIdentityCredential(\n options?: DefaultAzureCredentialOptions | DefaultAzureCredentialClientIdOptions,\n): TokenCredential {\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n clientId: workloadIdentityClientId,\n tokenFilePath: workloadFile,\n };\n return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);\n }\n if (tenantId) {\n const workloadIdentityClientTenantOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n };\n return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new WorkloadIdentityCredential(options);\n}\n\n/**\n * Creates a {@link AzureDeveloperCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzureDeveloperCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzureDeveloperCliCredential(options);\n}\n\n/**\n * Creates a {@link AzureCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzureCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzureCliCredential(options);\n}\n\n/**\n * Creates a {@link AzurePowerShellCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzurePowershellCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzurePowerShellCredential(options);\n}\n\n/**\n * Creates an {@link EnvironmentCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultEnvironmentCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new EnvironmentCredential(options);\n}\n"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type {\n DefaultAzureCredentialClientIdOptions,\n DefaultAzureCredentialOptions,\n DefaultAzureCredentialResourceIdOptions,\n} from \"./defaultAzureCredentialOptions.js\";\nimport { EnvironmentCredential } from \"#platform/credentials/environmentCredential\";\nimport type {\n ManagedIdentityCredentialClientIdOptions,\n ManagedIdentityCredentialResourceIdOptions,\n} from \"./managedIdentityCredential/options.js\";\nimport { ManagedIdentityCredential } from \"#platform/credentials/managedIdentityCredential/index\";\nimport { WorkloadIdentityCredential } from \"#platform/credentials/workloadIdentityCredential\";\nimport { AzureDeveloperCliCredential } from \"#platform/credentials/azureDeveloperCliCredential\";\nimport { AzureCliCredential } from \"#platform/credentials/azureCliCredential\";\nimport { AzurePowerShellCredential } from \"#platform/credentials/azurePowerShellCredential\";\nimport type { WorkloadIdentityCredentialOptions } from \"./workloadIdentityCredentialOptions.js\";\nimport { VisualStudioCodeCredential } from \"#platform/credentials/visualStudioCodeCredential\";\nimport { BrokerCredential } from \"./brokerCredential.js\";\n\n/**\n * Creates a {@link BrokerCredential} instance with the provided options.\n * This credential uses the Windows Authentication Manager (WAM) broker for authentication.\n * It will only attempt to authenticate silently using the default broker account\n *\n * @param options - Options for configuring the credential.\n *\n * @internal\n */\nexport function createDefaultBrokerCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new BrokerCredential(options);\n}\n\n/**\n * Creates a {@link VisualStudioCodeCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultVisualStudioCodeCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new VisualStudioCodeCredential(options);\n}\n\n/**\n * Creates a {@link ManagedIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultManagedIdentityCredential(\n options: (\n | DefaultAzureCredentialOptions\n | DefaultAzureCredentialResourceIdOptions\n | DefaultAzureCredentialClientIdOptions\n ) & { sendProbeRequest?: boolean } = {},\n): TokenCredential {\n options.retryOptions ??= {\n maxRetries: 5,\n retryDelayInMs: 800,\n };\n // ManagedIdentityCredential inside DAC chain should send a probe request by default.\n // This is different from standalone ManagedIdentityCredential behavior\n // or when AZURE_TOKEN_CREDENTIALS is set to only ManagedIdentityCredential.\n options.sendProbeRequest ??= true;\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const managedResourceId = (options as DefaultAzureCredentialResourceIdOptions)\n ?.managedIdentityResourceId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (managedResourceId) {\n const managedIdentityResourceIdOptions: ManagedIdentityCredentialResourceIdOptions = {\n ...options,\n resourceId: managedResourceId,\n };\n return new ManagedIdentityCredential(managedIdentityResourceIdOptions);\n }\n\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: DefaultAzureCredentialOptions = {\n ...options,\n tenantId: tenantId,\n };\n\n return new ManagedIdentityCredential(\n workloadIdentityClientId,\n workloadIdentityCredentialOptions,\n );\n }\n\n if (managedIdentityClientId) {\n const managedIdentityClientOptions: ManagedIdentityCredentialClientIdOptions = {\n ...options,\n clientId: managedIdentityClientId,\n };\n\n return new ManagedIdentityCredential(managedIdentityClientOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new ManagedIdentityCredential(options);\n}\n\n/**\n * Creates a {@link WorkloadIdentityCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultWorkloadIdentityCredential(\n options?: DefaultAzureCredentialOptions | DefaultAzureCredentialClientIdOptions,\n): TokenCredential {\n const managedIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.managedIdentityClientId ??\n process.env.AZURE_CLIENT_ID;\n const workloadIdentityClientId =\n (options as DefaultAzureCredentialClientIdOptions)?.workloadIdentityClientId ??\n managedIdentityClientId;\n const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;\n const tenantId = options?.tenantId ?? process.env.AZURE_TENANT_ID;\n if (workloadFile && workloadIdentityClientId) {\n const workloadIdentityCredentialOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n clientId: workloadIdentityClientId,\n tokenFilePath: workloadFile,\n };\n return new WorkloadIdentityCredential(workloadIdentityCredentialOptions);\n }\n if (tenantId) {\n const workloadIdentityClientTenantOptions: WorkloadIdentityCredentialOptions = {\n ...options,\n tenantId,\n };\n return new WorkloadIdentityCredential(workloadIdentityClientTenantOptions);\n }\n\n // We may be able to return a UnavailableCredential here, but that may be a breaking change\n return new WorkloadIdentityCredential(options);\n}\n\n/**\n * Creates a {@link AzureDeveloperCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzureDeveloperCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzureDeveloperCliCredential(options);\n}\n\n/**\n * Creates a {@link AzureCliCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzureCliCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzureCliCredential(options);\n}\n\n/**\n * Creates a {@link AzurePowerShellCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultAzurePowershellCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new AzurePowerShellCredential(options);\n}\n\n/**\n * Creates an {@link EnvironmentCredential} from the provided options.\n * @param options - Options to configure the credential.\n *\n * @internal\n */\nexport function createDefaultEnvironmentCredential(\n options: DefaultAzureCredentialOptions = {},\n): TokenCredential {\n return new EnvironmentCredential(options);\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mCAAsC;AAKtC,uCAA0C;AAC1C,wCAA2C;AAC3C,yCAA4C;AAC5C,gCAAmC;AACnC,uCAA0C;AAE1C,wCAA2C;AAC3C,8BAAiC;AAW1B,SAAS,8BACd,UAAyC,CAAC,GACzB;AACjB,SAAO,IAAI,yCAAiB,OAAO;AACrC;AAQO,SAAS,wCACd,UAAyC,CAAC,GACzB;AACjB,SAAO,IAAI,6DAA2B,OAAO;AAC/C;AAQO,SAAS,uCACd,UAIqC,CAAC,GACrB;AACjB,UAAQ,iBAAiB;AAAA,IACvB,YAAY;AAAA,IACZ,gBAAgB;AAAA,EAClB;AAIA,UAAQ,qBAAqB;AAC7B,QAAM,0BACH,SAAmD,2BACpD,QAAQ,IAAI;AACd,QAAM,2BACH,SAAmD,4BACpD;AACF,QAAM,oBAAqB,SACvB;AACJ,Q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B,SAAO,IAAI,2DAA0B,OAAO;AAC9C;AAQO,SAAS,mCACd,UAAyC,CAAC,GACzB;AACjB,SAAO,IAAI,mDAAsB,OAAO;AAC1C;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"environmentCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMtF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAKtF;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,UAU5C,CAAC;AAUF,wBAAgB,uBAAuB,IAAI,OAAO,CASjD;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,WAAW,CAAC,CAGuB;IAC3C;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;gBACS,OAAO,CAAC,EAAE,4BAA4B;IA6DlD;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAqB/F"}
1
+ {"version":3,"file":"environmentCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/environmentCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMtF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAKtF;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,UAU5C,CAAC;AAUF,wBAAgB,uBAAuB,IAAI,OAAO,CASjD;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,WAAW,CAAC,CAC4E;IAChG;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;gBACS,OAAO,CAAC,EAAE,4BAA4B;IA6DlD;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;CAqB/F"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/credentials/environmentCredential.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { AuthenticationError, CredentialUnavailableError } from \"../errors.js\";\nimport { credentialLogger, formatError, formatSuccess, processEnvVars } from \"../util/logging.js\";\n\nimport { ClientCertificateCredential } from \"./clientCertificateCredential.js\";\nimport { ClientSecretCredential } from \"./clientSecretCredential.js\";\nimport type { EnvironmentCredentialOptions } from \"./environmentCredentialOptions.js\";\nimport { UsernamePasswordCredential } from \"./usernamePasswordCredential.js\";\nimport { checkTenantId } from \"../util/tenantIdUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\n\n/**\n * Contains the list of all supported environment variable names so that an\n * appropriate error message can be generated when no credentials can be\n * configured.\n *\n * @internal\n */\nexport const AllSupportedEnvironmentVariables = [\n \"AZURE_TENANT_ID\",\n \"AZURE_CLIENT_ID\",\n \"AZURE_CLIENT_SECRET\",\n \"AZURE_CLIENT_CERTIFICATE_PATH\",\n \"AZURE_CLIENT_CERTIFICATE_PASSWORD\",\n \"AZURE_USERNAME\",\n \"AZURE_PASSWORD\",\n \"AZURE_ADDITIONALLY_ALLOWED_TENANTS\",\n \"AZURE_CLIENT_SEND_CERTIFICATE_CHAIN\",\n];\n\nfunction getAdditionallyAllowedTenants(): string[] {\n const additionallyAllowedValues = process.env.AZURE_ADDITIONALLY_ALLOWED_TENANTS ?? \"\";\n return additionallyAllowedValues.split(\";\");\n}\n\nconst credentialName = \"EnvironmentCredential\";\nconst logger = credentialLogger(credentialName);\n\nexport function getSendCertificateChain(): boolean {\n const sendCertificateChain = (\n process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN ?? \"\"\n ).toLowerCase();\n const result = sendCertificateChain === \"true\" || sendCertificateChain === \"1\";\n logger.verbose(\n `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN: ${process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN}; sendCertificateChain: ${result}`,\n );\n return result;\n}\n\n/**\n * Enables authentication to Microsoft Entra ID using a client secret or certificate.\n */\nexport class EnvironmentCredential implements TokenCredential {\n private _credential?:\n | ClientSecretCredential\n | ClientCertificateCredential\n | UsernamePasswordCredential = undefined;\n /**\n * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.\n *\n * Required environment variables:\n * - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.\n * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.\n *\n * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants\n * - `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.\n *\n * Environment variables used for client credential authentication:\n * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.\n * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.\n * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.\n * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.\n *\n * Username and password authentication is deprecated, since it doesn't support multifactor authentication (MFA). See https://aka.ms/azsdk/identity/mfa for more details. Users can still provide environment variables for this authentication method:\n * - `AZURE_USERNAME`: Username to authenticate with.\n * - `AZURE_PASSWORD`: Password to authenticate with.\n *\n * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.\n * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.\n *\n * @param options - Options for configuring the client which makes the authentication request.\n */\n constructor(options?: EnvironmentCredentialOptions) {\n // Keep track of any missing environment variables for error details\n\n const assigned = processEnvVars(AllSupportedEnvironmentVariables).assigned.join(\", \");\n logger.info(`Found the following environment variables: ${assigned}`);\n\n const tenantId = process.env.AZURE_TENANT_ID,\n clientId = process.env.AZURE_CLIENT_ID,\n clientSecret = process.env.AZURE_CLIENT_SECRET;\n\n const additionallyAllowedTenantIds = getAdditionallyAllowedTenants();\n const sendCertificateChain = getSendCertificateChain();\n const newOptions = { ...options, additionallyAllowedTenantIds, sendCertificateChain };\n\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n\n if (tenantId && clientId && clientSecret) {\n logger.info(\n `Invoking ClientSecretCredential with tenant ID: ${tenantId}, clientId: ${clientId} and clientSecret: [REDACTED]`,\n );\n this._credential = new ClientSecretCredential(tenantId, clientId, clientSecret, newOptions);\n return;\n }\n\n const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;\n const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;\n if (tenantId && clientId && certificatePath) {\n logger.info(\n `Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`,\n );\n this._credential = new ClientCertificateCredential(\n tenantId,\n clientId,\n { certificatePath, certificatePassword },\n newOptions,\n );\n return;\n }\n\n const username = process.env.AZURE_USERNAME;\n const password = process.env.AZURE_PASSWORD;\n if (tenantId && clientId && username && password) {\n logger.info(\n `Invoking UsernamePasswordCredential with tenant ID: ${tenantId}, clientId: ${clientId} and username: ${username}`,\n );\n\n logger.warning(\n \"Environment is configured to use username and password authentication. This authentication method is deprecated, as it doesn't support multifactor authentication (MFA). Use a more secure credential. For more details, see https://aka.ms/azsdk/identity/mfa.\",\n );\n this._credential = new UsernamePasswordCredential(\n tenantId,\n clientId,\n username,\n password,\n newOptions,\n );\n }\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - Optional parameters. See {@link GetTokenOptions}.\n */\n async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {\n if (this._credential) {\n try {\n const result = await this._credential.getToken(scopes, newOptions);\n logger.getToken.info(formatSuccess(scopes));\n return result;\n } catch (err: any) {\n const authenticationError = new AuthenticationError(400, {\n error: `${credentialName} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,\n error_description: err.message.toString().split(\"More details:\").join(\"\"),\n });\n logger.getToken.info(formatError(scopes, authenticationError));\n throw authenticationError;\n }\n }\n throw new CredentialUnavailableError(\n `${credentialName} is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,\n );\n });\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAgE;AAChE,qBAA6E;AAE7E,yCAA4C;AAC5C,oCAAuC;AAEvC,wCAA2C;AAC3C,2BAA8B;AAC9B,qBAA8B;AASvB,MAAM,mCAAmC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,gCAA0C;AACjD,QAAM,4BAA4B,QAAQ,IAAI,sCAAsC;AACpF,SAAO,0BAA0B,MAAM,GAAG;AAC5C;AAEA,MAAM,iBAAiB;AACvB,MAAM,aAAS,iCAAiB,cAAc;AAEvC,SAAS,0BAAmC;AACjD,QAAM,wBACJ,QAAQ,IAAI,uCAAuC,IACnD,YAAY;AACd,QAAM,SAAS,yBAAyB,UAAU,yBAAyB;AAC3E,SAAO;AAAA,IACL,wCAAwC,QAAQ,IAAI,mCAAmC,2BAA2B,MAAM;AAAA,EAC1H;AACA,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EA,aAAO;AAAA,QACL;AAAA,MACF;AACA,WAAK,cAAc,IAAI;AAAA,QACrB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS,QAA2B,UAA2B,CAAC,GAAyB;AAC7F,WAAO,6BAAc,SAAS,GAAG,cAAc,aAAa,SAAS,OAAO,eAAe;AACzF,UAAI,KAAK,aAAa;AACpB,YAAI;AACF,gBAAM,SAAS,MAAM,KAAK,YAAY,SAAS,QAAQ,UAAU;AACjE,iBAAO,SAAS,SAAK,8BAAc,MAAM,CAAC;AAC1C,iBAAO;AAAA,QACT,SAAS,KAAU;AACjB,gBAAM,sBAAsB,IAAI,kCAAoB,KAAK;AAAA,YACvD,OAAO,GAAG,cAAc;AAAA,YACxB,mBAAmB,IAAI,QAAQ,SAAS,EAAE,MAAM,eAAe,EAAE,KAAK,EAAE;AAAA,UAC1E,CAAC;AACD,iBAAO,SAAS,SAAK,4BAAY,QAAQ,mBAAmB,CAAC;AAC7D,gBAAM;AAAA,QACR;AAAA,MACF;AACA,YAAM,IAAI;AAAA,QACR,GAAG,cAAc;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport { AuthenticationError, CredentialUnavailableError } from \"../errors.js\";\nimport { credentialLogger, formatError, formatSuccess, processEnvVars } from \"../util/logging.js\";\n\nimport { ClientCertificateCredential } from \"#platform/credentials/clientCertificateCredential\";\nimport { ClientSecretCredential } from \"#platform/credentials/clientSecretCredential\";\nimport type { EnvironmentCredentialOptions } from \"./environmentCredentialOptions.js\";\nimport { UsernamePasswordCredential } from \"#platform/credentials/usernamePasswordCredential\";\nimport { checkTenantId } from \"../util/tenantIdUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\n\n/**\n * Contains the list of all supported environment variable names so that an\n * appropriate error message can be generated when no credentials can be\n * configured.\n *\n * @internal\n */\nexport const AllSupportedEnvironmentVariables = [\n \"AZURE_TENANT_ID\",\n \"AZURE_CLIENT_ID\",\n \"AZURE_CLIENT_SECRET\",\n \"AZURE_CLIENT_CERTIFICATE_PATH\",\n \"AZURE_CLIENT_CERTIFICATE_PASSWORD\",\n \"AZURE_USERNAME\",\n \"AZURE_PASSWORD\",\n \"AZURE_ADDITIONALLY_ALLOWED_TENANTS\",\n \"AZURE_CLIENT_SEND_CERTIFICATE_CHAIN\",\n];\n\nfunction getAdditionallyAllowedTenants(): string[] {\n const additionallyAllowedValues = process.env.AZURE_ADDITIONALLY_ALLOWED_TENANTS ?? \"\";\n return additionallyAllowedValues.split(\";\");\n}\n\nconst credentialName = \"EnvironmentCredential\";\nconst logger = credentialLogger(credentialName);\n\nexport function getSendCertificateChain(): boolean {\n const sendCertificateChain = (\n process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN ?? \"\"\n ).toLowerCase();\n const result = sendCertificateChain === \"true\" || sendCertificateChain === \"1\";\n logger.verbose(\n `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN: ${process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN}; sendCertificateChain: ${result}`,\n );\n return result;\n}\n\n/**\n * Enables authentication to Microsoft Entra ID using a client secret or certificate.\n */\nexport class EnvironmentCredential implements TokenCredential {\n private _credential?:\n ClientSecretCredential | ClientCertificateCredential | UsernamePasswordCredential = undefined;\n /**\n * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.\n *\n * Required environment variables:\n * - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.\n * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.\n *\n * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants\n * - `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.\n *\n * Environment variables used for client credential authentication:\n * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.\n * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.\n * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.\n * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.\n *\n * Username and password authentication is deprecated, since it doesn't support multifactor authentication (MFA). See https://aka.ms/azsdk/identity/mfa for more details. Users can still provide environment variables for this authentication method:\n * - `AZURE_USERNAME`: Username to authenticate with.\n * - `AZURE_PASSWORD`: Password to authenticate with.\n *\n * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.\n * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.\n *\n * @param options - Options for configuring the client which makes the authentication request.\n */\n constructor(options?: EnvironmentCredentialOptions) {\n // Keep track of any missing environment variables for error details\n\n const assigned = processEnvVars(AllSupportedEnvironmentVariables).assigned.join(\", \");\n logger.info(`Found the following environment variables: ${assigned}`);\n\n const tenantId = process.env.AZURE_TENANT_ID,\n clientId = process.env.AZURE_CLIENT_ID,\n clientSecret = process.env.AZURE_CLIENT_SECRET;\n\n const additionallyAllowedTenantIds = getAdditionallyAllowedTenants();\n const sendCertificateChain = getSendCertificateChain();\n const newOptions = { ...options, additionallyAllowedTenantIds, sendCertificateChain };\n\n if (tenantId) {\n checkTenantId(logger, tenantId);\n }\n\n if (tenantId && clientId && clientSecret) {\n logger.info(\n `Invoking ClientSecretCredential with tenant ID: ${tenantId}, clientId: ${clientId} and clientSecret: [REDACTED]`,\n );\n this._credential = new ClientSecretCredential(tenantId, clientId, clientSecret, newOptions);\n return;\n }\n\n const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;\n const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;\n if (tenantId && clientId && certificatePath) {\n logger.info(\n `Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`,\n );\n this._credential = new ClientCertificateCredential(\n tenantId,\n clientId,\n { certificatePath, certificatePassword },\n newOptions,\n );\n return;\n }\n\n const username = process.env.AZURE_USERNAME;\n const password = process.env.AZURE_PASSWORD;\n if (tenantId && clientId && username && password) {\n logger.info(\n `Invoking UsernamePasswordCredential with tenant ID: ${tenantId}, clientId: ${clientId} and username: ${username}`,\n );\n\n logger.warning(\n \"Environment is configured to use username and password authentication. This authentication method is deprecated, as it doesn't support multifactor authentication (MFA). Use a more secure credential. For more details, see https://aka.ms/azsdk/identity/mfa.\",\n );\n this._credential = new UsernamePasswordCredential(\n tenantId,\n clientId,\n username,\n password,\n newOptions,\n );\n }\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - Optional parameters. See {@link GetTokenOptions}.\n */\n async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {\n if (this._credential) {\n try {\n const result = await this._credential.getToken(scopes, newOptions);\n logger.getToken.info(formatSuccess(scopes));\n return result;\n } catch (err: any) {\n const authenticationError = new AuthenticationError(400, {\n error: `${credentialName} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,\n error_description: err.message.toString().split(\"More details:\").join(\"\"),\n });\n logger.getToken.info(formatError(scopes, authenticationError));\n throw authenticationError;\n }\n }\n throw new CredentialUnavailableError(\n `${credentialName} is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,\n );\n });\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAI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AS,SAAK,4BAAY,QAAQ,mBAAmB,CAAC;AAC7D,gBAAM;AAAA,QACR;AAAA,MACF;AACA,YAAM,IAAI;AAAA,QACR,GAAG,cAAc;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/credentials/managedIdentityCredential/tokenExchangeMsi.ts"],
4
- "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions } from \"@azure/core-auth\";\nimport type { MSIConfiguration } from \"./models.js\";\nimport { WorkloadIdentityCredential } from \"../workloadIdentityCredential.js\";\nimport { credentialLogger } from \"../../util/logging.js\";\nimport type { WorkloadIdentityCredentialOptions } from \"../workloadIdentityCredentialOptions.js\";\n\nconst msiName = \"ManagedIdentityCredential - Token Exchange\";\nconst logger = credentialLogger(msiName);\n\n/**\n * Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.\n *\n * Token exchange MSI (used by AKS) is the only MSI implementation handled entirely by Azure Identity.\n * The rest have been migrated to MSAL.\n */\nexport const tokenExchangeMsi = {\n name: \"tokenExchangeMsi\",\n async isAvailable(clientId?: string): Promise<boolean> {\n const env = process.env;\n const result = Boolean(\n (clientId || env.AZURE_CLIENT_ID) &&\n env.AZURE_TENANT_ID &&\n process.env.AZURE_FEDERATED_TOKEN_FILE,\n );\n if (!result) {\n logger.info(\n `${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`,\n );\n }\n return result;\n },\n async getToken(\n configuration: MSIConfiguration,\n getTokenOptions: GetTokenOptions = {},\n ): Promise<AccessToken | null> {\n const { scopes, clientId } = configuration;\n const identityClientTokenCredentialOptions = {};\n const workloadIdentityCredential = new WorkloadIdentityCredential({\n clientId,\n tenantId: process.env.AZURE_TENANT_ID,\n tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE,\n ...identityClientTokenCredentialOptions,\n disableInstanceDiscovery: true,\n } as WorkloadIdentityCredentialOptions);\n return workloadIdentityCredential.getToken(scopes, getTokenOptions);\n },\n};\n"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions } from \"@azure/core-auth\";\nimport type { MSIConfiguration } from \"./models.js\";\nimport { WorkloadIdentityCredential } from \"#platform/credentials/workloadIdentityCredential\";\nimport { credentialLogger } from \"../../util/logging.js\";\nimport type { WorkloadIdentityCredentialOptions } from \"../workloadIdentityCredentialOptions.js\";\n\nconst msiName = \"ManagedIdentityCredential - Token Exchange\";\nconst logger = credentialLogger(msiName);\n\n/**\n * Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.\n *\n * Token exchange MSI (used by AKS) is the only MSI implementation handled entirely by Azure Identity.\n * The rest have been migrated to MSAL.\n */\nexport const tokenExchangeMsi = {\n name: \"tokenExchangeMsi\",\n async isAvailable(clientId?: string): Promise<boolean> {\n const env = process.env;\n const result = Boolean(\n (clientId || env.AZURE_CLIENT_ID) &&\n env.AZURE_TENANT_ID &&\n process.env.AZURE_FEDERATED_TOKEN_FILE,\n );\n if (!result) {\n logger.info(\n `${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`,\n );\n }\n return result;\n },\n async getToken(\n configuration: MSIConfiguration,\n getTokenOptions: GetTokenOptions = {},\n ): Promise<AccessToken | null> {\n const { scopes, clientId } = configuration;\n const identityClientTokenCredentialOptions = {};\n const workloadIdentityCredential = new WorkloadIdentityCredential({\n clientId,\n tenantId: process.env.AZURE_TENANT_ID,\n tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE,\n ...identityClientTokenCredentialOptions,\n disableInstanceDiscovery: true,\n } as WorkloadIdentityCredentialOptions);\n return workloadIdentityCredential.getToken(scopes, getTokenOptions);\n },\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,wCAA2C;AAC3C,qBAAiC;AAGjC,MAAM,UAAU;AAChB,MAAM,aAAS,iCAAiB,OAAO;AAQhC,MAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,YAAY,UAAqC;AACrD,UAAM,MAAM,QAAQ;AACpB,UAAM,SAAS;AAAA,OACZ,YAAY,IAAI,oBACjB,IAAI,mBACJ,QAAQ,IAAI;AAAA,IACd;AACA,QAAI,CAAC,QAAQ;AACX,aAAO;AAAA,QACL,GAAG,OAAO;AAAA,MACZ;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA,EACA,MAAM,SACJ,eACA,kBAAmC,CAAC,GACP;AAC7B,UAAM,EAAE,QAAQ,SAAS,IAAI;AAC7B,UAAM,uCAAuC,CAAC;AAC9C,UAAM,6BAA6B,IAAI,6DAA2B;AAAA,MAChE;AAAA,MACA,UAAU,QAAQ,IAAI;AAAA,MACtB,eAAe,QAAQ,IAAI;AAAA,MAC3B,GAAG;AAAA,MACH,0BAA0B;AAAA,IAC5B,CAAsC;AACtC,WAAO,2BAA2B,SAAS,QAAQ,eAAe;AAAA,EACpE;AACF;",
6
6
  "names": []
7
7
  }