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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) hide show
  1. package/dist/browser/constants.d.ts +1 -1
  2. package/dist/browser/constants.js +1 -1
  3. package/dist/browser/constants.js.map +1 -1
  4. package/dist/browser/credentials/authorizationCodeCredential.d.ts +3 -3
  5. package/dist/browser/credentials/authorizationCodeCredential.d.ts.map +1 -0
  6. package/dist/browser/credentials/authorizationCodeCredential.js +2 -2
  7. package/dist/browser/credentials/authorizationCodeCredential.js.map +1 -0
  8. package/dist/browser/credentials/azureCliCredential.d.ts +5 -4
  9. package/dist/browser/credentials/azureCliCredential.d.ts.map +1 -0
  10. package/dist/browser/credentials/azureCliCredential.js +3 -3
  11. package/dist/browser/credentials/azureCliCredential.js.map +1 -0
  12. package/dist/browser/credentials/azureDeveloperCliCredential.d.ts +5 -4
  13. package/dist/browser/credentials/azureDeveloperCliCredential.d.ts.map +1 -0
  14. package/dist/browser/credentials/azureDeveloperCliCredential.js +3 -3
  15. package/dist/browser/credentials/azureDeveloperCliCredential.js.map +1 -0
  16. package/dist/browser/credentials/azurePipelinesCredential.d.ts +5 -4
  17. package/dist/browser/credentials/azurePipelinesCredential.d.ts.map +1 -0
  18. package/dist/browser/credentials/azurePipelinesCredential.js +3 -3
  19. package/dist/browser/credentials/azurePipelinesCredential.js.map +1 -0
  20. package/dist/browser/credentials/azurePowerShellCredential.d.ts +5 -4
  21. package/dist/browser/credentials/azurePowerShellCredential.d.ts.map +1 -0
  22. package/dist/browser/credentials/azurePowerShellCredential.js +3 -3
  23. package/dist/browser/credentials/azurePowerShellCredential.js.map +1 -0
  24. package/dist/browser/credentials/clientAssertionCredential.d.ts +5 -4
  25. package/dist/browser/credentials/clientAssertionCredential.d.ts.map +1 -0
  26. package/dist/browser/credentials/clientAssertionCredential.js +3 -3
  27. package/dist/browser/credentials/clientAssertionCredential.js.map +1 -0
  28. package/dist/browser/credentials/clientCertificateCredential.d.ts +6 -4
  29. package/dist/browser/credentials/clientCertificateCredential.d.ts.map +1 -0
  30. package/dist/browser/credentials/clientCertificateCredential.js +3 -3
  31. package/dist/browser/credentials/clientCertificateCredential.js.map +1 -0
  32. package/dist/browser/credentials/clientSecretCredential.d.ts +1 -1
  33. package/dist/browser/credentials/clientSecretCredential.d.ts.map +1 -0
  34. package/dist/browser/credentials/clientSecretCredential.js +1 -1
  35. package/dist/browser/credentials/clientSecretCredential.js.map +1 -0
  36. package/dist/browser/credentials/defaultAzureCredential.d.ts +3 -3
  37. package/dist/browser/credentials/defaultAzureCredential.d.ts.map +1 -0
  38. package/dist/browser/credentials/defaultAzureCredential.js +2 -2
  39. package/dist/browser/credentials/defaultAzureCredential.js.map +1 -0
  40. package/dist/browser/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  41. package/dist/browser/credentials/defaultAzureCredentialOptions.js.map +1 -1
  42. package/dist/browser/credentials/deviceCodeCredential.d.ts +5 -4
  43. package/dist/browser/credentials/deviceCodeCredential.d.ts.map +1 -0
  44. package/dist/browser/credentials/deviceCodeCredential.js +3 -3
  45. package/dist/browser/credentials/deviceCodeCredential.js.map +1 -0
  46. package/dist/browser/credentials/environmentCredential.d.ts +5 -4
  47. package/dist/browser/credentials/environmentCredential.d.ts.map +1 -0
  48. package/dist/browser/credentials/environmentCredential.js +3 -3
  49. package/dist/browser/credentials/environmentCredential.js.map +1 -0
  50. package/dist/browser/credentials/interactiveBrowserCredential.d.ts +1 -1
  51. package/dist/browser/credentials/interactiveBrowserCredential.d.ts.map +1 -0
  52. package/dist/browser/credentials/interactiveBrowserCredential.js +1 -1
  53. package/dist/browser/credentials/interactiveBrowserCredential.js.map +1 -0
  54. package/dist/browser/credentials/managedIdentityCredential/index.d.ts +9 -4
  55. package/dist/browser/credentials/managedIdentityCredential/index.d.ts.map +1 -0
  56. package/dist/browser/credentials/managedIdentityCredential/index.js +3 -3
  57. package/dist/browser/credentials/managedIdentityCredential/index.js.map +1 -0
  58. package/dist/browser/credentials/onBehalfOfCredential.d.ts +5 -4
  59. package/dist/browser/credentials/onBehalfOfCredential.d.ts.map +1 -0
  60. package/dist/browser/credentials/onBehalfOfCredential.js +3 -3
  61. package/dist/browser/credentials/onBehalfOfCredential.js.map +1 -0
  62. package/dist/browser/credentials/usernamePasswordCredential.d.ts +1 -1
  63. package/dist/browser/credentials/usernamePasswordCredential.d.ts.map +1 -0
  64. package/dist/browser/credentials/usernamePasswordCredential.js +1 -1
  65. package/dist/browser/credentials/usernamePasswordCredential.js.map +1 -0
  66. package/dist/browser/credentials/visualStudioCodeCredential.d.ts +5 -4
  67. package/dist/browser/credentials/visualStudioCodeCredential.d.ts.map +1 -0
  68. package/dist/browser/credentials/visualStudioCodeCredential.js +3 -3
  69. package/dist/browser/credentials/visualStudioCodeCredential.js.map +1 -0
  70. package/dist/browser/credentials/workloadIdentityCredential.d.ts +5 -4
  71. package/dist/browser/credentials/workloadIdentityCredential.d.ts.map +1 -0
  72. package/dist/browser/credentials/workloadIdentityCredential.js +3 -3
  73. package/dist/browser/credentials/workloadIdentityCredential.js.map +1 -0
  74. package/dist/browser/index.d.ts +33 -33
  75. package/dist/browser/index.d.ts.map +1 -1
  76. package/dist/browser/index.js.map +1 -1
  77. package/dist/browser/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  78. package/dist/browser/msal/browserFlows/msalBrowserCommon.js +2 -3
  79. package/dist/browser/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  80. package/dist/browser/msal/msal.d.ts +2 -3
  81. package/dist/browser/msal/msal.d.ts.map +1 -0
  82. package/dist/browser/msal/msal.js +2 -3
  83. package/dist/browser/msal/msal.js.map +1 -0
  84. package/dist/browser/msal/nodeFlows/msalClient.d.ts +2 -2
  85. package/dist/browser/msal/nodeFlows/msalClient.d.ts.map +1 -1
  86. package/dist/browser/msal/nodeFlows/msalClient.js +3 -3
  87. package/dist/browser/msal/nodeFlows/msalClient.js.map +1 -1
  88. package/dist/browser/msal/utils.d.ts +5 -4
  89. package/dist/browser/msal/utils.d.ts.map +1 -1
  90. package/dist/browser/msal/utils.js +10 -10
  91. package/dist/browser/msal/utils.js.map +1 -1
  92. package/dist/browser/plugins/consumer.d.ts +1 -1
  93. package/dist/browser/plugins/consumer.d.ts.map +1 -0
  94. package/dist/browser/plugins/consumer.js +1 -1
  95. package/dist/browser/plugins/consumer.js.map +1 -0
  96. package/dist/browser/util/processMultiTenantRequest.d.ts +3 -2
  97. package/dist/browser/util/processMultiTenantRequest.d.ts.map +1 -0
  98. package/dist/browser/util/processMultiTenantRequest.js +2 -2
  99. package/dist/browser/util/processMultiTenantRequest.js.map +1 -0
  100. package/dist/commonjs/client/identityClient.js +294 -288
  101. package/dist/commonjs/client/identityClient.js.map +7 -1
  102. package/dist/commonjs/constants.d.ts +1 -1
  103. package/dist/commonjs/constants.js +61 -78
  104. package/dist/commonjs/constants.js.map +7 -1
  105. package/dist/commonjs/credentials/authorityValidationOptions.js +16 -5
  106. package/dist/commonjs/credentials/authorityValidationOptions.js.map +7 -1
  107. package/dist/commonjs/credentials/authorizationCodeCredential.js +98 -74
  108. package/dist/commonjs/credentials/authorizationCodeCredential.js.map +7 -1
  109. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.js +16 -5
  110. package/dist/commonjs/credentials/authorizationCodeCredentialOptions.js.map +7 -1
  111. package/dist/commonjs/credentials/azureCliCredential.js +245 -214
  112. package/dist/commonjs/credentials/azureCliCredential.js.map +7 -1
  113. package/dist/commonjs/credentials/azureCliCredentialOptions.js +16 -5
  114. package/dist/commonjs/credentials/azureCliCredentialOptions.js.map +7 -1
  115. package/dist/commonjs/credentials/azureDeveloperCliCredential.js +237 -225
  116. package/dist/commonjs/credentials/azureDeveloperCliCredential.js.map +7 -1
  117. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.js +16 -5
  118. package/dist/commonjs/credentials/azureDeveloperCliCredentialOptions.js.map +7 -1
  119. package/dist/commonjs/credentials/azurePipelinesCredential.js +173 -135
  120. package/dist/commonjs/credentials/azurePipelinesCredential.js.map +7 -1
  121. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.js +16 -5
  122. package/dist/commonjs/credentials/azurePipelinesCredentialOptions.js.map +7 -1
  123. package/dist/commonjs/credentials/azurePowerShellCredential.js +201 -205
  124. package/dist/commonjs/credentials/azurePowerShellCredential.js.map +7 -1
  125. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.js +16 -5
  126. package/dist/commonjs/credentials/azurePowerShellCredentialOptions.js.map +7 -1
  127. package/dist/commonjs/credentials/brokerAuthOptions.js +16 -3
  128. package/dist/commonjs/credentials/brokerAuthOptions.js.map +7 -1
  129. package/dist/commonjs/credentials/brokerCredential.js +103 -70
  130. package/dist/commonjs/credentials/brokerCredential.js.map +7 -1
  131. package/dist/commonjs/credentials/browserCustomizationOptions.js +16 -5
  132. package/dist/commonjs/credentials/browserCustomizationOptions.js.map +7 -1
  133. package/dist/commonjs/credentials/chainedTokenCredential.js +113 -93
  134. package/dist/commonjs/credentials/chainedTokenCredential.js.map +7 -1
  135. package/dist/commonjs/credentials/clientAssertionCredential.js +101 -63
  136. package/dist/commonjs/credentials/clientAssertionCredential.js.map +7 -1
  137. package/dist/commonjs/credentials/clientAssertionCredentialOptions.js +16 -5
  138. package/dist/commonjs/credentials/clientAssertionCredentialOptions.js.map +7 -1
  139. package/dist/commonjs/credentials/clientCertificateCredential.js +129 -123
  140. package/dist/commonjs/credentials/clientCertificateCredential.js.map +7 -1
  141. package/dist/commonjs/credentials/clientCertificateCredentialModels.js +16 -5
  142. package/dist/commonjs/credentials/clientCertificateCredentialModels.js.map +7 -1
  143. package/dist/commonjs/credentials/clientCertificateCredentialOptions.js +16 -5
  144. package/dist/commonjs/credentials/clientCertificateCredentialOptions.js.map +7 -1
  145. package/dist/commonjs/credentials/clientSecretCredential.js +96 -67
  146. package/dist/commonjs/credentials/clientSecretCredential.js.map +7 -1
  147. package/dist/commonjs/credentials/clientSecretCredentialOptions.js +16 -5
  148. package/dist/commonjs/credentials/clientSecretCredentialOptions.js.map +7 -1
  149. package/dist/commonjs/credentials/credentialPersistenceOptions.js +16 -5
  150. package/dist/commonjs/credentials/credentialPersistenceOptions.js.map +7 -1
  151. package/dist/commonjs/credentials/defaultAzureCredential.js +121 -159
  152. package/dist/commonjs/credentials/defaultAzureCredential.js.map +7 -1
  153. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js +110 -140
  154. package/dist/commonjs/credentials/defaultAzureCredentialFunctions.js.map +7 -1
  155. package/dist/commonjs/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  156. package/dist/commonjs/credentials/defaultAzureCredentialOptions.js +16 -5
  157. package/dist/commonjs/credentials/defaultAzureCredentialOptions.js.map +7 -1
  158. package/dist/commonjs/credentials/deviceCodeCredential.js +132 -103
  159. package/dist/commonjs/credentials/deviceCodeCredential.js.map +7 -1
  160. package/dist/commonjs/credentials/deviceCodeCredentialOptions.js +16 -5
  161. package/dist/commonjs/credentials/deviceCodeCredentialOptions.js.map +7 -1
  162. package/dist/commonjs/credentials/environmentCredential.js +157 -123
  163. package/dist/commonjs/credentials/environmentCredential.js.map +7 -1
  164. package/dist/commonjs/credentials/environmentCredentialOptions.js +16 -5
  165. package/dist/commonjs/credentials/environmentCredentialOptions.js.map +7 -1
  166. package/dist/commonjs/credentials/interactiveBrowserCredential.js +144 -107
  167. package/dist/commonjs/credentials/interactiveBrowserCredential.js.map +7 -1
  168. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.js +16 -5
  169. package/dist/commonjs/credentials/interactiveBrowserCredentialOptions.js.map +7 -1
  170. package/dist/commonjs/credentials/interactiveCredentialOptions.js +16 -5
  171. package/dist/commonjs/credentials/interactiveCredentialOptions.js.map +7 -1
  172. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js +92 -91
  173. package/dist/commonjs/credentials/managedIdentityCredential/imdsMsi.js.map +7 -1
  174. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js +51 -44
  175. package/dist/commonjs/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +7 -1
  176. package/dist/commonjs/credentials/managedIdentityCredential/index.js +256 -242
  177. package/dist/commonjs/credentials/managedIdentityCredential/index.js.map +7 -1
  178. package/dist/commonjs/credentials/managedIdentityCredential/models.js +16 -5
  179. package/dist/commonjs/credentials/managedIdentityCredential/models.js.map +7 -1
  180. package/dist/commonjs/credentials/managedIdentityCredential/options.js +16 -5
  181. package/dist/commonjs/credentials/managedIdentityCredential/options.js.map +7 -1
  182. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js +56 -39
  183. package/dist/commonjs/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +7 -1
  184. package/dist/commonjs/credentials/managedIdentityCredential/utils.js +79 -75
  185. package/dist/commonjs/credentials/managedIdentityCredential/utils.js.map +7 -1
  186. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.js +16 -5
  187. package/dist/commonjs/credentials/multiTenantTokenCredentialOptions.js.map +7 -1
  188. package/dist/commonjs/credentials/onBehalfOfCredential.js +168 -126
  189. package/dist/commonjs/credentials/onBehalfOfCredential.js.map +7 -1
  190. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.js +16 -5
  191. package/dist/commonjs/credentials/onBehalfOfCredentialOptions.js.map +7 -1
  192. package/dist/commonjs/credentials/usernamePasswordCredential.js +112 -75
  193. package/dist/commonjs/credentials/usernamePasswordCredential.js.map +7 -1
  194. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.js +16 -5
  195. package/dist/commonjs/credentials/usernamePasswordCredentialOptions.js.map +7 -1
  196. package/dist/commonjs/credentials/visualStudioCodeCredential.js +144 -132
  197. package/dist/commonjs/credentials/visualStudioCodeCredential.js.map +7 -1
  198. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js +16 -5
  199. package/dist/commonjs/credentials/visualStudioCodeCredentialOptions.js.map +7 -1
  200. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js +16 -5
  201. package/dist/commonjs/credentials/visualStudioCodeCredentialPlugin.js.map +7 -1
  202. package/dist/commonjs/credentials/workloadIdentityCredential.js +284 -274
  203. package/dist/commonjs/credentials/workloadIdentityCredential.js.map +7 -1
  204. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.js +16 -5
  205. package/dist/commonjs/credentials/workloadIdentityCredentialOptions.js.map +7 -1
  206. package/dist/commonjs/errors.js +131 -132
  207. package/dist/commonjs/errors.js.map +7 -1
  208. package/dist/commonjs/index.d.ts +33 -33
  209. package/dist/commonjs/index.d.ts.map +1 -1
  210. package/dist/commonjs/index.js +115 -67
  211. package/dist/commonjs/index.js.map +7 -1
  212. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  213. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js +226 -249
  214. package/dist/commonjs/msal/browserFlows/msalBrowserCommon.js.map +7 -1
  215. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js +16 -5
  216. package/dist/commonjs/msal/browserFlows/msalBrowserOptions.js.map +7 -1
  217. package/dist/commonjs/msal/credentials.js +16 -5
  218. package/dist/commonjs/msal/credentials.js.map +7 -1
  219. package/dist/commonjs/msal/msal.d.ts +1 -2
  220. package/dist/commonjs/msal/msal.d.ts.map +1 -1
  221. package/dist/commonjs/msal/msal.js +30 -9
  222. package/dist/commonjs/msal/msal.js.map +7 -1
  223. package/dist/commonjs/msal/nodeFlows/brokerOptions.js +16 -3
  224. package/dist/commonjs/msal/nodeFlows/brokerOptions.js.map +7 -1
  225. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts +2 -2
  226. package/dist/commonjs/msal/nodeFlows/msalClient.d.ts.map +1 -1
  227. package/dist/commonjs/msal/nodeFlows/msalClient.js +450 -478
  228. package/dist/commonjs/msal/nodeFlows/msalClient.js.map +7 -1
  229. package/dist/commonjs/msal/nodeFlows/msalPlugins.js +140 -147
  230. package/dist/commonjs/msal/nodeFlows/msalPlugins.js.map +7 -1
  231. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.js +16 -5
  232. package/dist/commonjs/msal/nodeFlows/tokenCachePersistenceOptions.js.map +7 -1
  233. package/dist/commonjs/msal/types.js +16 -5
  234. package/dist/commonjs/msal/types.js.map +7 -1
  235. package/dist/commonjs/msal/utils.d.ts +5 -4
  236. package/dist/commonjs/msal/utils.d.ts.map +1 -1
  237. package/dist/commonjs/msal/utils.js +171 -211
  238. package/dist/commonjs/msal/utils.js.map +7 -1
  239. package/dist/commonjs/plugins/consumer.js +32 -40
  240. package/dist/commonjs/plugins/consumer.js.map +7 -1
  241. package/dist/commonjs/plugins/provider.js +16 -5
  242. package/dist/commonjs/plugins/provider.js.map +7 -1
  243. package/dist/commonjs/regionalAuthority.js +93 -141
  244. package/dist/commonjs/regionalAuthority.js.map +7 -1
  245. package/dist/commonjs/tokenCredentialOptions.js +16 -5
  246. package/dist/commonjs/tokenCredentialOptions.js.map +7 -1
  247. package/dist/commonjs/tokenProvider.js +52 -52
  248. package/dist/commonjs/tokenProvider.js.map +7 -1
  249. package/dist/commonjs/tsdoc-metadata.json +1 -1
  250. package/dist/commonjs/util/authorityHost.js +34 -19
  251. package/dist/commonjs/util/authorityHost.js.map +7 -1
  252. package/dist/commonjs/util/certificatesUtils.js +54 -45
  253. package/dist/commonjs/util/certificatesUtils.js.map +7 -1
  254. package/dist/commonjs/util/identityTokenEndpoint.js +32 -12
  255. package/dist/commonjs/util/identityTokenEndpoint.js.map +7 -1
  256. package/dist/commonjs/util/logging.js +91 -97
  257. package/dist/commonjs/util/logging.js.map +7 -1
  258. package/dist/commonjs/util/processMultiTenantRequest.js +43 -33
  259. package/dist/commonjs/util/processMultiTenantRequest.js.map +7 -1
  260. package/dist/commonjs/util/processUtils.js +60 -35
  261. package/dist/commonjs/util/processUtils.js.map +7 -1
  262. package/dist/commonjs/util/scopeUtils.js +39 -28
  263. package/dist/commonjs/util/scopeUtils.js.map +7 -1
  264. package/dist/commonjs/util/subscriptionUtils.js +35 -17
  265. package/dist/commonjs/util/subscriptionUtils.js.map +7 -1
  266. package/dist/commonjs/util/tenantIdUtils.js +61 -45
  267. package/dist/commonjs/util/tenantIdUtils.js.map +7 -1
  268. package/dist/commonjs/util/tracing.js +33 -16
  269. package/dist/commonjs/util/tracing.js.map +7 -1
  270. package/dist/esm/constants.d.ts +1 -1
  271. package/dist/esm/constants.js +1 -1
  272. package/dist/esm/constants.js.map +1 -1
  273. package/dist/esm/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  274. package/dist/esm/credentials/defaultAzureCredentialOptions.js.map +1 -1
  275. package/dist/esm/index.d.ts +33 -33
  276. package/dist/esm/index.d.ts.map +1 -1
  277. package/dist/esm/index.js.map +1 -1
  278. package/dist/esm/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  279. package/dist/esm/msal/browserFlows/msalBrowserCommon.js +2 -3
  280. package/dist/esm/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  281. package/dist/esm/msal/msal.d.ts +1 -2
  282. package/dist/esm/msal/msal.d.ts.map +1 -1
  283. package/dist/esm/msal/msal.js +1 -2
  284. package/dist/esm/msal/msal.js.map +1 -1
  285. package/dist/esm/msal/nodeFlows/msalClient.d.ts +2 -2
  286. package/dist/esm/msal/nodeFlows/msalClient.d.ts.map +1 -1
  287. package/dist/esm/msal/nodeFlows/msalClient.js +3 -3
  288. package/dist/esm/msal/nodeFlows/msalClient.js.map +1 -1
  289. package/dist/esm/msal/utils.d.ts +5 -4
  290. package/dist/esm/msal/utils.d.ts.map +1 -1
  291. package/dist/esm/msal/utils.js +10 -10
  292. package/dist/esm/msal/utils.js.map +1 -1
  293. package/dist/workerd/constants.d.ts +1 -1
  294. package/dist/workerd/constants.js +1 -1
  295. package/dist/workerd/constants.js.map +1 -1
  296. package/dist/workerd/credentials/defaultAzureCredentialOptions.d.ts +2 -2
  297. package/dist/workerd/credentials/defaultAzureCredentialOptions.js.map +1 -1
  298. package/dist/workerd/index.d.ts +33 -33
  299. package/dist/workerd/index.d.ts.map +1 -1
  300. package/dist/workerd/index.js.map +1 -1
  301. package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -1
  302. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js +2 -3
  303. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  304. package/dist/workerd/msal/msal.d.ts +1 -2
  305. package/dist/workerd/msal/msal.d.ts.map +1 -1
  306. package/dist/workerd/msal/msal.js +1 -2
  307. package/dist/workerd/msal/msal.js.map +1 -1
  308. package/dist/workerd/msal/nodeFlows/msalClient.d.ts +2 -2
  309. package/dist/workerd/msal/nodeFlows/msalClient.d.ts.map +1 -1
  310. package/dist/workerd/msal/nodeFlows/msalClient.js +3 -3
  311. package/dist/workerd/msal/nodeFlows/msalClient.js.map +1 -1
  312. package/dist/workerd/msal/utils.d.ts +5 -4
  313. package/dist/workerd/msal/utils.d.ts.map +1 -1
  314. package/dist/workerd/msal/utils.js +10 -10
  315. package/dist/workerd/msal/utils.js.map +1 -1
  316. package/package.json +10 -27
  317. package/dist/browser/credentials/authorizationCodeCredential-browser.d.mts.map +0 -1
  318. package/dist/browser/credentials/authorizationCodeCredential-browser.mjs.map +0 -1
  319. package/dist/browser/credentials/azureCliCredential-browser.d.mts.map +0 -1
  320. package/dist/browser/credentials/azureCliCredential-browser.mjs.map +0 -1
  321. package/dist/browser/credentials/azureDeveloperCliCredential-browser.d.mts.map +0 -1
  322. package/dist/browser/credentials/azureDeveloperCliCredential-browser.mjs.map +0 -1
  323. package/dist/browser/credentials/azurePipelinesCredential-browser.d.mts.map +0 -1
  324. package/dist/browser/credentials/azurePipelinesCredential-browser.mjs.map +0 -1
  325. package/dist/browser/credentials/azurePowerShellCredential-browser.d.mts.map +0 -1
  326. package/dist/browser/credentials/azurePowerShellCredential-browser.mjs.map +0 -1
  327. package/dist/browser/credentials/clientAssertionCredential-browser.d.mts.map +0 -1
  328. package/dist/browser/credentials/clientAssertionCredential-browser.mjs.map +0 -1
  329. package/dist/browser/credentials/clientCertificateCredential-browser.d.mts.map +0 -1
  330. package/dist/browser/credentials/clientCertificateCredential-browser.mjs.map +0 -1
  331. package/dist/browser/credentials/clientSecretCredential-browser.d.mts.map +0 -1
  332. package/dist/browser/credentials/clientSecretCredential-browser.mjs.map +0 -1
  333. package/dist/browser/credentials/defaultAzureCredential-browser.d.mts.map +0 -1
  334. package/dist/browser/credentials/defaultAzureCredential-browser.mjs.map +0 -1
  335. package/dist/browser/credentials/deviceCodeCredential-browser.d.mts.map +0 -1
  336. package/dist/browser/credentials/deviceCodeCredential-browser.mjs.map +0 -1
  337. package/dist/browser/credentials/environmentCredential-browser.d.mts.map +0 -1
  338. package/dist/browser/credentials/environmentCredential-browser.mjs.map +0 -1
  339. package/dist/browser/credentials/interactiveBrowserCredential-browser.d.mts.map +0 -1
  340. package/dist/browser/credentials/interactiveBrowserCredential-browser.mjs.map +0 -1
  341. package/dist/browser/credentials/managedIdentityCredential/index-browser.d.mts.map +0 -1
  342. package/dist/browser/credentials/managedIdentityCredential/index-browser.mjs.map +0 -1
  343. package/dist/browser/credentials/onBehalfOfCredential-browser.d.mts.map +0 -1
  344. package/dist/browser/credentials/onBehalfOfCredential-browser.mjs.map +0 -1
  345. package/dist/browser/credentials/usernamePasswordCredential-browser.d.mts.map +0 -1
  346. package/dist/browser/credentials/usernamePasswordCredential-browser.mjs.map +0 -1
  347. package/dist/browser/credentials/visualStudioCodeCredential-browser.d.mts.map +0 -1
  348. package/dist/browser/credentials/visualStudioCodeCredential-browser.mjs.map +0 -1
  349. package/dist/browser/credentials/workloadIdentityCredential-browser.d.mts.map +0 -1
  350. package/dist/browser/credentials/workloadIdentityCredential-browser.mjs.map +0 -1
  351. package/dist/browser/msal/msal-browser.d.mts.map +0 -1
  352. package/dist/browser/msal/msal-browser.mjs.map +0 -1
  353. package/dist/browser/plugins/consumer-browser.d.mts.map +0 -1
  354. package/dist/browser/plugins/consumer-browser.mjs.map +0 -1
  355. package/dist/browser/util/authHostEnv-browser.d.mts +0 -4
  356. package/dist/browser/util/authHostEnv-browser.d.mts.map +0 -1
  357. package/dist/browser/util/authHostEnv-browser.mjs +0 -7
  358. package/dist/browser/util/authHostEnv-browser.mjs.map +0 -1
  359. package/dist/browser/util/processMultiTenantRequest-browser.d.mts.map +0 -1
  360. package/dist/browser/util/processMultiTenantRequest-browser.mjs.map +0 -1
  361. package/dist/esm/util/authHostEnv-browser.d.mts +0 -4
  362. package/dist/esm/util/authHostEnv-browser.d.mts.map +0 -1
  363. package/dist/esm/util/authHostEnv-browser.mjs +0 -7
  364. package/dist/esm/util/authHostEnv-browser.mjs.map +0 -1
  365. package/dist/workerd/util/authHostEnv-browser.d.mts +0 -4
  366. package/dist/workerd/util/authHostEnv-browser.d.mts.map +0 -1
  367. package/dist/workerd/util/authHostEnv-browser.mjs +0 -7
  368. package/dist/workerd/util/authHostEnv-browser.mjs.map +0 -1
@@ -1,109 +1,138 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.DeviceCodeCredential = void 0;
6
- exports.defaultDeviceCodePromptCallback = defaultDeviceCodePromptCallback;
7
- const tenantIdUtils_js_1 = require("../util/tenantIdUtils.js");
8
- const logging_js_1 = require("../util/logging.js");
9
- const scopeUtils_js_1 = require("../util/scopeUtils.js");
10
- const tracing_js_1 = require("../util/tracing.js");
11
- const msalClient_js_1 = require("../msal/nodeFlows/msalClient.js");
12
- const constants_js_1 = require("../constants.js");
13
- const logger = (0, logging_js_1.credentialLogger)("DeviceCodeCredential");
14
- /**
15
- * Method that logs the user code from the DeviceCodeCredential.
16
- * @param deviceCodeInfo - The device code.
17
- */
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var deviceCodeCredential_exports = {};
19
+ __export(deviceCodeCredential_exports, {
20
+ DeviceCodeCredential: () => DeviceCodeCredential,
21
+ defaultDeviceCodePromptCallback: () => defaultDeviceCodePromptCallback
22
+ });
23
+ module.exports = __toCommonJS(deviceCodeCredential_exports);
24
+ var import_tenantIdUtils = require("../util/tenantIdUtils.js");
25
+ var import_logging = require("../util/logging.js");
26
+ var import_scopeUtils = require("../util/scopeUtils.js");
27
+ var import_tracing = require("../util/tracing.js");
28
+ var import_msalClient = require("../msal/nodeFlows/msalClient.js");
29
+ var import_constants = require("../constants.js");
30
+ const logger = (0, import_logging.credentialLogger)("DeviceCodeCredential");
18
31
  function defaultDeviceCodePromptCallback(deviceCodeInfo) {
19
- console.log(deviceCodeInfo.message);
32
+ console.log(deviceCodeInfo.message);
20
33
  }
21
- /**
22
- * Enables authentication to Microsoft Entra ID using a device code
23
- * that the user can enter into https://microsoft.com/devicelogin.
24
- */
25
34
  class DeviceCodeCredential {
26
- tenantId;
27
- additionallyAllowedTenantIds;
28
- disableAutomaticAuthentication;
29
- msalClient;
30
- userPromptCallback;
31
- /**
32
- * Creates an instance of DeviceCodeCredential with the details needed
33
- * to initiate the device code authorization flow with Microsoft Entra ID.
34
- *
35
- * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
36
- *
37
- * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
38
- *
39
- * ```ts snippet:device_code_credential_example
40
- * import { DeviceCodeCredential } from "@azure/identity";
41
- *
42
- * const credential = new DeviceCodeCredential({
43
- * tenantId: process.env.AZURE_TENANT_ID,
44
- * clientId: process.env.AZURE_CLIENT_ID,
45
- * userPromptCallback: (info) => {
46
- * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
47
- * },
48
- * });
49
- * ```
50
- *
51
- * @param options - Options for configuring the client which makes the authentication requests.
52
- */
53
- constructor(options) {
54
- this.tenantId = options?.tenantId;
55
- this.additionallyAllowedTenantIds = (0, tenantIdUtils_js_1.resolveAdditionallyAllowedTenantIds)(options?.additionallyAllowedTenants);
56
- const clientId = options?.clientId ?? constants_js_1.DeveloperSignOnClientId;
57
- const tenantId = (0, tenantIdUtils_js_1.resolveTenantId)(logger, options?.tenantId, clientId);
58
- this.userPromptCallback = options?.userPromptCallback ?? defaultDeviceCodePromptCallback;
59
- this.msalClient = (0, msalClient_js_1.createMsalClient)(clientId, tenantId, {
60
- ...options,
61
- logger,
35
+ tenantId;
36
+ additionallyAllowedTenantIds;
37
+ disableAutomaticAuthentication;
38
+ msalClient;
39
+ userPromptCallback;
40
+ /**
41
+ * Creates an instance of DeviceCodeCredential with the details needed
42
+ * to initiate the device code authorization flow with Microsoft Entra ID.
43
+ *
44
+ * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
45
+ *
46
+ * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
47
+ *
48
+ * ```ts snippet:device_code_credential_example
49
+ * import { DeviceCodeCredential } from "@azure/identity";
50
+ *
51
+ * const credential = new DeviceCodeCredential({
52
+ * tenantId: process.env.AZURE_TENANT_ID,
53
+ * clientId: process.env.AZURE_CLIENT_ID,
54
+ * userPromptCallback: (info) => {
55
+ * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
56
+ * },
57
+ * });
58
+ * ```
59
+ *
60
+ * @param options - Options for configuring the client which makes the authentication requests.
61
+ */
62
+ constructor(options) {
63
+ this.tenantId = options?.tenantId;
64
+ this.additionallyAllowedTenantIds = (0, import_tenantIdUtils.resolveAdditionallyAllowedTenantIds)(
65
+ options?.additionallyAllowedTenants
66
+ );
67
+ const clientId = options?.clientId ?? import_constants.DeveloperSignOnClientId;
68
+ const tenantId = (0, import_tenantIdUtils.resolveTenantId)(logger, options?.tenantId, clientId);
69
+ this.userPromptCallback = options?.userPromptCallback ?? defaultDeviceCodePromptCallback;
70
+ this.msalClient = (0, import_msalClient.createMsalClient)(clientId, tenantId, {
71
+ ...options,
72
+ logger
73
+ });
74
+ this.disableAutomaticAuthentication = options?.disableAutomaticAuthentication;
75
+ }
76
+ /**
77
+ * Authenticates with Microsoft Entra ID and returns an access token if successful.
78
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
79
+ *
80
+ * If the user provided the option `disableAutomaticAuthentication`,
81
+ * once the token can't be retrieved silently,
82
+ * this method won't attempt to request user interaction to retrieve the token.
83
+ *
84
+ * @param scopes - The list of scopes for which the token will have access.
85
+ * @param options - The options used to configure any requests this
86
+ * TokenCredential implementation might make.
87
+ */
88
+ async getToken(scopes, options = {}) {
89
+ return import_tracing.tracingClient.withSpan(
90
+ `${this.constructor.name}.getToken`,
91
+ options,
92
+ async (newOptions) => {
93
+ newOptions.tenantId = (0, import_tenantIdUtils.processMultiTenantRequest)(
94
+ this.tenantId,
95
+ newOptions,
96
+ this.additionallyAllowedTenantIds,
97
+ logger
98
+ );
99
+ const arrayScopes = (0, import_scopeUtils.ensureScopes)(scopes);
100
+ return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {
101
+ ...newOptions,
102
+ disableAutomaticAuthentication: this.disableAutomaticAuthentication
62
103
  });
63
- this.disableAutomaticAuthentication = options?.disableAutomaticAuthentication;
64
- }
65
- /**
66
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
67
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
68
- *
69
- * If the user provided the option `disableAutomaticAuthentication`,
70
- * once the token can't be retrieved silently,
71
- * this method won't attempt to request user interaction to retrieve the token.
72
- *
73
- * @param scopes - The list of scopes for which the token will have access.
74
- * @param options - The options used to configure any requests this
75
- * TokenCredential implementation might make.
76
- */
77
- async getToken(scopes, options = {}) {
78
- return tracing_js_1.tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
79
- newOptions.tenantId = (0, tenantIdUtils_js_1.processMultiTenantRequest)(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger);
80
- const arrayScopes = (0, scopeUtils_js_1.ensureScopes)(scopes);
81
- return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {
82
- ...newOptions,
83
- disableAutomaticAuthentication: this.disableAutomaticAuthentication,
84
- });
104
+ }
105
+ );
106
+ }
107
+ /**
108
+ * Authenticates with Microsoft Entra ID and returns an access token if successful.
109
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
110
+ *
111
+ * If the token can't be retrieved silently, this method will always generate a challenge for the user.
112
+ *
113
+ * @param scopes - The list of scopes for which the token will have access.
114
+ * @param options - The options used to configure any requests this
115
+ * TokenCredential implementation might make.
116
+ */
117
+ async authenticate(scopes, options = {}) {
118
+ return import_tracing.tracingClient.withSpan(
119
+ `${this.constructor.name}.authenticate`,
120
+ options,
121
+ async (newOptions) => {
122
+ const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
123
+ await this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {
124
+ ...newOptions,
125
+ disableAutomaticAuthentication: false
126
+ // this method should always allow user interaction
85
127
  });
86
- }
87
- /**
88
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
89
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
90
- *
91
- * If the token can't be retrieved silently, this method will always generate a challenge for the user.
92
- *
93
- * @param scopes - The list of scopes for which the token will have access.
94
- * @param options - The options used to configure any requests this
95
- * TokenCredential implementation might make.
96
- */
97
- async authenticate(scopes, options = {}) {
98
- return tracing_js_1.tracingClient.withSpan(`${this.constructor.name}.authenticate`, options, async (newOptions) => {
99
- const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
100
- await this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {
101
- ...newOptions,
102
- disableAutomaticAuthentication: false, // this method should always allow user interaction
103
- });
104
- return this.msalClient.getActiveAccount();
105
- });
106
- }
128
+ return this.msalClient.getActiveAccount();
129
+ }
130
+ );
131
+ }
107
132
  }
108
- exports.DeviceCodeCredential = DeviceCodeCredential;
109
- //# sourceMappingURL=deviceCodeCredential.js.map
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ DeviceCodeCredential,
136
+ defaultDeviceCodePromptCallback
137
+ });
138
+ //# sourceMappingURL=deviceCodeCredential.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"deviceCodeCredential.js","sourceRoot":"","sources":["../../../src/credentials/deviceCodeCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA2BlC,0EAEC;AA1BD,+DAIkC;AAOlC,mDAAsD;AACtD,yDAAqD;AACrD,mDAAmD;AAEnD,mEAAmE;AACnE,kDAA0D;AAE1D,MAAM,MAAM,GAAG,IAAA,6BAAgB,EAAC,sBAAsB,CAAC,CAAC;AAExD;;;GAGG;AACH,SAAgB,+BAA+B,CAAC,cAA8B;IAC5E,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAa,oBAAoB;IACvB,QAAQ,CAAU;IAClB,4BAA4B,CAAW;IACvC,8BAA8B,CAAW;IACzC,UAAU,CAAa;IACvB,kBAAkB,CAA2B;IAErD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,OAAqC;QAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,4BAA4B,GAAG,IAAA,sDAAmC,EACrE,OAAO,EAAE,0BAA0B,CACpC,CAAC;QACF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,sCAAuB,CAAC;QAC9D,MAAM,QAAQ,GAAG,IAAA,kCAAe,EAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACtE,IAAI,CAAC,kBAAkB,GAAG,OAAO,EAAE,kBAAkB,IAAI,+BAA+B,CAAC;QACzF,IAAI,CAAC,UAAU,GAAG,IAAA,gCAAgB,EAAC,QAAQ,EAAE,QAAQ,EAAE;YACrD,GAAG,OAAO;YACV,MAAM;SACP,CAAC,CAAC;QACH,IAAI,CAAC,8BAA8B,GAAG,OAAO,EAAE,8BAA8B,CAAC;IAChF,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAyB,EAAE,UAA2B,EAAE;QACrE,OAAO,0BAAa,CAAC,QAAQ,CAC3B,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,WAAW,EACnC,OAAO,EACP,KAAK,EAAE,UAAU,EAAE,EAAE;YACnB,UAAU,CAAC,QAAQ,GAAG,IAAA,4CAAyB,EAC7C,IAAI,CAAC,QAAQ,EACb,UAAU,EACV,IAAI,CAAC,4BAA4B,EACjC,MAAM,CACP,CAAC;YAEF,MAAM,WAAW,GAAG,IAAA,4BAAY,EAAC,MAAM,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE;gBAChF,GAAG,UAAU;gBACb,8BAA8B,EAAE,IAAI,CAAC,8BAA8B;aACpE,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,YAAY,CAChB,MAAyB,EACzB,UAA2B,EAAE;QAE7B,OAAO,0BAAa,CAAC,QAAQ,CAC3B,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,eAAe,EACvC,OAAO,EACP,KAAK,EAAE,UAAU,EAAE,EAAE;YACnB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YAC9D,MAAM,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,kBAAkB,EAAE;gBAC/E,GAAG,UAAU;gBACb,8BAA8B,EAAE,KAAK,EAAE,mDAAmD;aAC3F,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;QAC5C,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAxGD,oDAwGC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\nimport {\n processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n resolveTenantId,\n} from \"../util/tenantIdUtils.js\";\nimport type {\n DeviceCodeCredentialOptions,\n DeviceCodeInfo,\n DeviceCodePromptCallback,\n} from \"./deviceCodeCredentialOptions.js\";\nimport type { AuthenticationRecord } from \"../msal/types.js\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport { ensureScopes } from \"../util/scopeUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport type { MsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport { DeveloperSignOnClientId } from \"../constants.js\";\n\nconst logger = credentialLogger(\"DeviceCodeCredential\");\n\n/**\n * Method that logs the user code from the DeviceCodeCredential.\n * @param deviceCodeInfo - The device code.\n */\nexport function defaultDeviceCodePromptCallback(deviceCodeInfo: DeviceCodeInfo): void {\n console.log(deviceCodeInfo.message);\n}\n\n/**\n * Enables authentication to Microsoft Entra ID using a device code\n * that the user can enter into https://microsoft.com/devicelogin.\n */\nexport class DeviceCodeCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private disableAutomaticAuthentication?: boolean;\n private msalClient: MsalClient;\n private userPromptCallback: DeviceCodePromptCallback;\n\n /**\n * Creates an instance of DeviceCodeCredential with the details needed\n * to initiate the device code authorization flow with Microsoft Entra ID.\n *\n * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin\n *\n * Developers can configure how this message is shown by passing a custom `userPromptCallback`:\n *\n * ```ts snippet:device_code_credential_example\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tenantId: process.env.AZURE_TENANT_ID,\n * clientId: process.env.AZURE_CLIENT_ID,\n * userPromptCallback: (info) => {\n * console.log(\"CUSTOMIZED PROMPT CALLBACK\", info.message);\n * },\n * });\n * ```\n *\n * @param options - Options for configuring the client which makes the authentication requests.\n */\n constructor(options?: DeviceCodeCredentialOptions) {\n this.tenantId = options?.tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n const clientId = options?.clientId ?? DeveloperSignOnClientId;\n const tenantId = resolveTenantId(logger, options?.tenantId, clientId);\n this.userPromptCallback = options?.userPromptCallback ?? defaultDeviceCodePromptCallback;\n this.msalClient = createMsalClient(clientId, tenantId, {\n ...options,\n logger,\n });\n this.disableAutomaticAuthentication = options?.disableAutomaticAuthentication;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the user provided the option `disableAutomaticAuthentication`,\n * once the token can't be retrieved silently,\n * this method won't attempt to request user interaction to retrieve the token.\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 async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(\n `${this.constructor.name}.getToken`,\n options,\n async (newOptions) => {\n newOptions.tenantId = processMultiTenantRequest(\n this.tenantId,\n newOptions,\n this.additionallyAllowedTenantIds,\n logger,\n );\n\n const arrayScopes = ensureScopes(scopes);\n return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {\n ...newOptions,\n disableAutomaticAuthentication: this.disableAutomaticAuthentication,\n });\n },\n );\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the token can't be retrieved silently, this method will always generate a challenge for the user.\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 async authenticate(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AuthenticationRecord | undefined> {\n return tracingClient.withSpan(\n `${this.constructor.name}.authenticate`,\n options,\n async (newOptions) => {\n const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];\n await this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {\n ...newOptions,\n disableAutomaticAuthentication: false, // this method should always allow user interaction\n });\n return this.msalClient.getActiveAccount();\n },\n );\n }\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/credentials/deviceCodeCredential.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 processMultiTenantRequest,\n resolveAdditionallyAllowedTenantIds,\n resolveTenantId,\n} from \"../util/tenantIdUtils.js\";\nimport type {\n DeviceCodeCredentialOptions,\n DeviceCodeInfo,\n DeviceCodePromptCallback,\n} from \"./deviceCodeCredentialOptions.js\";\nimport type { AuthenticationRecord } from \"../msal/types.js\";\nimport { credentialLogger } from \"../util/logging.js\";\nimport { ensureScopes } from \"../util/scopeUtils.js\";\nimport { tracingClient } from \"../util/tracing.js\";\nimport type { MsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport { createMsalClient } from \"../msal/nodeFlows/msalClient.js\";\nimport { DeveloperSignOnClientId } from \"../constants.js\";\n\nconst logger = credentialLogger(\"DeviceCodeCredential\");\n\n/**\n * Method that logs the user code from the DeviceCodeCredential.\n * @param deviceCodeInfo - The device code.\n */\nexport function defaultDeviceCodePromptCallback(deviceCodeInfo: DeviceCodeInfo): void {\n console.log(deviceCodeInfo.message);\n}\n\n/**\n * Enables authentication to Microsoft Entra ID using a device code\n * that the user can enter into https://microsoft.com/devicelogin.\n */\nexport class DeviceCodeCredential implements TokenCredential {\n private tenantId?: string;\n private additionallyAllowedTenantIds: string[];\n private disableAutomaticAuthentication?: boolean;\n private msalClient: MsalClient;\n private userPromptCallback: DeviceCodePromptCallback;\n\n /**\n * Creates an instance of DeviceCodeCredential with the details needed\n * to initiate the device code authorization flow with Microsoft Entra ID.\n *\n * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin\n *\n * Developers can configure how this message is shown by passing a custom `userPromptCallback`:\n *\n * ```ts snippet:device_code_credential_example\n * import { DeviceCodeCredential } from \"@azure/identity\";\n *\n * const credential = new DeviceCodeCredential({\n * tenantId: process.env.AZURE_TENANT_ID,\n * clientId: process.env.AZURE_CLIENT_ID,\n * userPromptCallback: (info) => {\n * console.log(\"CUSTOMIZED PROMPT CALLBACK\", info.message);\n * },\n * });\n * ```\n *\n * @param options - Options for configuring the client which makes the authentication requests.\n */\n constructor(options?: DeviceCodeCredentialOptions) {\n this.tenantId = options?.tenantId;\n this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(\n options?.additionallyAllowedTenants,\n );\n const clientId = options?.clientId ?? DeveloperSignOnClientId;\n const tenantId = resolveTenantId(logger, options?.tenantId, clientId);\n this.userPromptCallback = options?.userPromptCallback ?? defaultDeviceCodePromptCallback;\n this.msalClient = createMsalClient(clientId, tenantId, {\n ...options,\n logger,\n });\n this.disableAutomaticAuthentication = options?.disableAutomaticAuthentication;\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the user provided the option `disableAutomaticAuthentication`,\n * once the token can't be retrieved silently,\n * this method won't attempt to request user interaction to retrieve the token.\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 async getToken(scopes: string | string[], options: GetTokenOptions = {}): Promise<AccessToken> {\n return tracingClient.withSpan(\n `${this.constructor.name}.getToken`,\n options,\n async (newOptions) => {\n newOptions.tenantId = processMultiTenantRequest(\n this.tenantId,\n newOptions,\n this.additionallyAllowedTenantIds,\n logger,\n );\n\n const arrayScopes = ensureScopes(scopes);\n return this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {\n ...newOptions,\n disableAutomaticAuthentication: this.disableAutomaticAuthentication,\n });\n },\n );\n }\n\n /**\n * Authenticates with Microsoft Entra ID and returns an access token if successful.\n * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.\n *\n * If the token can't be retrieved silently, this method will always generate a challenge for the user.\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 async authenticate(\n scopes: string | string[],\n options: GetTokenOptions = {},\n ): Promise<AuthenticationRecord | undefined> {\n return tracingClient.withSpan(\n `${this.constructor.name}.authenticate`,\n options,\n async (newOptions) => {\n const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];\n await this.msalClient.getTokenByDeviceCode(arrayScopes, this.userPromptCallback, {\n ...newOptions,\n disableAutomaticAuthentication: false, // this method should always allow user interaction\n });\n return this.msalClient.getActiveAccount();\n },\n );\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,2BAIO;AAOP,qBAAiC;AACjC,wBAA6B;AAC7B,qBAA8B;AAE9B,wBAAiC;AACjC,uBAAwC;AAExC,MAAM,aAAS,iCAAiB,sBAAsB;AAM/C,SAAS,gCAAgC,gBAAsC;AACpF,UAAQ,IAAI,eAAe,OAAO;AACpC;AAMO,MAAM,qBAAgD;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwBR,YAAY,SAAuC;AACjD,SAAK,WAAW,SAAS;AACzB,SAAK,mCAA+B;AAAA,MAClC,SAAS;AAAA,IACX;AACA,UAAM,WAAW,SAAS,YAAY;AACtC,UAAM,eAAW,sCAAgB,QAAQ,SAAS,UAAU,QAAQ;AACpE,SAAK,qBAAqB,SAAS,sBAAsB;AACzD,SAAK,iBAAa,oCAAiB,UAAU,UAAU;AAAA,MACrD,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AACD,SAAK,iCAAiC,SAAS;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,SAAS,QAA2B,UAA2B,CAAC,GAAyB;AAC7F,WAAO,6BAAc;AAAA,MACnB,GAAG,KAAK,YAAY,IAAI;AAAA,MACxB;AAAA,MACA,OAAO,eAAe;AACpB,mBAAW,eAAW;AAAA,UACpB,KAAK;AAAA,UACL;AAAA,UACA,KAAK;AAAA,UACL;AAAA,QACF;AAEA,cAAM,kBAAc,gCAAa,MAAM;AACvC,eAAO,KAAK,WAAW,qBAAqB,aAAa,KAAK,oBAAoB;AAAA,UAChF,GAAG;AAAA,UACH,gCAAgC,KAAK;AAAA,QACvC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,MAAM,aACJ,QACA,UAA2B,CAAC,GACe;AAC3C,WAAO,6BAAc;AAAA,MACnB,GAAG,KAAK,YAAY,IAAI;AAAA,MACxB;AAAA,MACA,OAAO,eAAe;AACpB,cAAM,cAAc,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AAC5D,cAAM,KAAK,WAAW,qBAAqB,aAAa,KAAK,oBAAoB;AAAA,UAC/E,GAAG;AAAA,UACH,gCAAgC;AAAA;AAAA,QAClC,CAAC;AACD,eAAO,KAAK,WAAW,iBAAiB;AAAA,MAC1C;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,5 +1,16 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- //# sourceMappingURL=deviceCodeCredentialOptions.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var deviceCodeCredentialOptions_exports = {};
15
+ module.exports = __toCommonJS(deviceCodeCredentialOptions_exports);
16
+ //# sourceMappingURL=deviceCodeCredentialOptions.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"deviceCodeCredentialOptions.js","sourceRoot":"","sources":["../../../src/credentials/deviceCodeCredentialOptions.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions.js\";\nimport type { InteractiveCredentialOptions } from \"./interactiveCredentialOptions.js\";\n\n/**\n * Provides the user code and verification URI where the code must be\n * entered. Also provides a message to display to the user which\n * contains an instruction with these details.\n */\nexport interface DeviceCodeInfo {\n /**\n * The device code that the user must enter into the verification page.\n */\n userCode: string;\n\n /**\n * The verification URI to which the user must navigate to enter the device\n * code.\n */\n verificationUri: string;\n\n /**\n * A message that may be shown to the user to instruct them on how to enter\n * the device code in the page specified by the verification URI.\n */\n message: string;\n}\n\n/**\n * Defines the signature of a callback which will be passed to\n * DeviceCodeCredential for the purpose of displaying authentication\n * details to the user.\n */\nexport type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo) => void;\n\n/**\n * Defines options for the InteractiveBrowserCredential class for Node.js.\n */\nexport interface DeviceCodeCredentialOptions\n extends InteractiveCredentialOptions, CredentialPersistenceOptions {\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId?: string;\n /**\n * Client ID of the Microsoft Entra application that users will sign into.\n * It is recommended that developers register their applications and assign appropriate roles.\n * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.\n * If not specified, users will authenticate to an Azure development application,\n * which is not recommended for production scenarios.\n */\n clientId?: string;\n /**\n * A callback function that will be invoked to show {@link DeviceCodeInfo} to the user.\n * If left unassigned, we will automatically log the device code information\n * and the authentication instructions in the console.\n */\n userPromptCallback?: DeviceCodePromptCallback;\n}\n"]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/credentials/deviceCodeCredentialOptions.ts"],
4
+ "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { CredentialPersistenceOptions } from \"./credentialPersistenceOptions.js\";\nimport type { InteractiveCredentialOptions } from \"./interactiveCredentialOptions.js\";\n\n/**\n * Provides the user code and verification URI where the code must be\n * entered. Also provides a message to display to the user which\n * contains an instruction with these details.\n */\nexport interface DeviceCodeInfo {\n /**\n * The device code that the user must enter into the verification page.\n */\n userCode: string;\n\n /**\n * The verification URI to which the user must navigate to enter the device\n * code.\n */\n verificationUri: string;\n\n /**\n * A message that may be shown to the user to instruct them on how to enter\n * the device code in the page specified by the verification URI.\n */\n message: string;\n}\n\n/**\n * Defines the signature of a callback which will be passed to\n * DeviceCodeCredential for the purpose of displaying authentication\n * details to the user.\n */\nexport type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo) => void;\n\n/**\n * Defines options for the InteractiveBrowserCredential class for Node.js.\n */\nexport interface DeviceCodeCredentialOptions\n extends InteractiveCredentialOptions, CredentialPersistenceOptions {\n /**\n * The Microsoft Entra tenant (directory) ID.\n */\n tenantId?: string;\n /**\n * Client ID of the Microsoft Entra application that users will sign into.\n * It is recommended that developers register their applications and assign appropriate roles.\n * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.\n * If not specified, users will authenticate to an Azure development application,\n * which is not recommended for production scenarios.\n */\n clientId?: string;\n /**\n * A callback function that will be invoked to show {@link DeviceCodeInfo} to the user.\n * If left unassigned, we will automatically log the device code information\n * and the authentication instructions in the console.\n */\n userPromptCallback?: DeviceCodePromptCallback;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,133 +1,167 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.EnvironmentCredential = exports.AllSupportedEnvironmentVariables = void 0;
6
- exports.getSendCertificateChain = getSendCertificateChain;
7
- const errors_js_1 = require("../errors.js");
8
- const logging_js_1 = require("../util/logging.js");
9
- const clientCertificateCredential_js_1 = require("./clientCertificateCredential.js");
10
- const clientSecretCredential_js_1 = require("./clientSecretCredential.js");
11
- const usernamePasswordCredential_js_1 = require("./usernamePasswordCredential.js");
12
- const tenantIdUtils_js_1 = require("../util/tenantIdUtils.js");
13
- const tracing_js_1 = require("../util/tracing.js");
14
- /**
15
- * Contains the list of all supported environment variable names so that an
16
- * appropriate error message can be generated when no credentials can be
17
- * configured.
18
- *
19
- * @internal
20
- */
21
- exports.AllSupportedEnvironmentVariables = [
22
- "AZURE_TENANT_ID",
23
- "AZURE_CLIENT_ID",
24
- "AZURE_CLIENT_SECRET",
25
- "AZURE_CLIENT_CERTIFICATE_PATH",
26
- "AZURE_CLIENT_CERTIFICATE_PASSWORD",
27
- "AZURE_USERNAME",
28
- "AZURE_PASSWORD",
29
- "AZURE_ADDITIONALLY_ALLOWED_TENANTS",
30
- "AZURE_CLIENT_SEND_CERTIFICATE_CHAIN",
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var environmentCredential_exports = {};
19
+ __export(environmentCredential_exports, {
20
+ AllSupportedEnvironmentVariables: () => AllSupportedEnvironmentVariables,
21
+ EnvironmentCredential: () => EnvironmentCredential,
22
+ getSendCertificateChain: () => getSendCertificateChain
23
+ });
24
+ module.exports = __toCommonJS(environmentCredential_exports);
25
+ var import_errors = require("../errors.js");
26
+ var import_logging = require("../util/logging.js");
27
+ var import_clientCertificateCredential = require("./clientCertificateCredential.js");
28
+ var import_clientSecretCredential = require("./clientSecretCredential.js");
29
+ var import_usernamePasswordCredential = require("./usernamePasswordCredential.js");
30
+ var import_tenantIdUtils = require("../util/tenantIdUtils.js");
31
+ var import_tracing = require("../util/tracing.js");
32
+ const AllSupportedEnvironmentVariables = [
33
+ "AZURE_TENANT_ID",
34
+ "AZURE_CLIENT_ID",
35
+ "AZURE_CLIENT_SECRET",
36
+ "AZURE_CLIENT_CERTIFICATE_PATH",
37
+ "AZURE_CLIENT_CERTIFICATE_PASSWORD",
38
+ "AZURE_USERNAME",
39
+ "AZURE_PASSWORD",
40
+ "AZURE_ADDITIONALLY_ALLOWED_TENANTS",
41
+ "AZURE_CLIENT_SEND_CERTIFICATE_CHAIN"
31
42
  ];
32
43
  function getAdditionallyAllowedTenants() {
33
- const additionallyAllowedValues = process.env.AZURE_ADDITIONALLY_ALLOWED_TENANTS ?? "";
34
- return additionallyAllowedValues.split(";");
44
+ const additionallyAllowedValues = process.env.AZURE_ADDITIONALLY_ALLOWED_TENANTS ?? "";
45
+ return additionallyAllowedValues.split(";");
35
46
  }
36
47
  const credentialName = "EnvironmentCredential";
37
- const logger = (0, logging_js_1.credentialLogger)(credentialName);
48
+ const logger = (0, import_logging.credentialLogger)(credentialName);
38
49
  function getSendCertificateChain() {
39
- const sendCertificateChain = (process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN ?? "").toLowerCase();
40
- const result = sendCertificateChain === "true" || sendCertificateChain === "1";
41
- logger.verbose(`AZURE_CLIENT_SEND_CERTIFICATE_CHAIN: ${process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN}; sendCertificateChain: ${result}`);
42
- return result;
50
+ const sendCertificateChain = (process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN ?? "").toLowerCase();
51
+ const result = sendCertificateChain === "true" || sendCertificateChain === "1";
52
+ logger.verbose(
53
+ `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN: ${process.env.AZURE_CLIENT_SEND_CERTIFICATE_CHAIN}; sendCertificateChain: ${result}`
54
+ );
55
+ return result;
43
56
  }
44
- /**
45
- * Enables authentication to Microsoft Entra ID using a client secret or certificate.
46
- */
47
57
  class EnvironmentCredential {
48
- _credential = undefined;
49
- /**
50
- * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
51
- *
52
- * Required environment variables:
53
- * - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
54
- * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
55
- *
56
- * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
57
- * - `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.
58
- *
59
- * Environment variables used for client credential authentication:
60
- * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
61
- * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
62
- * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
63
- * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.
64
- *
65
- * 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:
66
- * - `AZURE_USERNAME`: Username to authenticate with.
67
- * - `AZURE_PASSWORD`: Password to authenticate with.
68
- *
69
- * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.
70
- * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.
71
- *
72
- * @param options - Options for configuring the client which makes the authentication request.
73
- */
74
- constructor(options) {
75
- // Keep track of any missing environment variables for error details
76
- const assigned = (0, logging_js_1.processEnvVars)(exports.AllSupportedEnvironmentVariables).assigned.join(", ");
77
- logger.info(`Found the following environment variables: ${assigned}`);
78
- const tenantId = process.env.AZURE_TENANT_ID, clientId = process.env.AZURE_CLIENT_ID, clientSecret = process.env.AZURE_CLIENT_SECRET;
79
- const additionallyAllowedTenantIds = getAdditionallyAllowedTenants();
80
- const sendCertificateChain = getSendCertificateChain();
81
- const newOptions = { ...options, additionallyAllowedTenantIds, sendCertificateChain };
82
- if (tenantId) {
83
- (0, tenantIdUtils_js_1.checkTenantId)(logger, tenantId);
84
- }
85
- if (tenantId && clientId && clientSecret) {
86
- logger.info(`Invoking ClientSecretCredential with tenant ID: ${tenantId}, clientId: ${clientId} and clientSecret: [REDACTED]`);
87
- this._credential = new clientSecretCredential_js_1.ClientSecretCredential(tenantId, clientId, clientSecret, newOptions);
88
- return;
89
- }
90
- const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;
91
- const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;
92
- if (tenantId && clientId && certificatePath) {
93
- logger.info(`Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`);
94
- this._credential = new clientCertificateCredential_js_1.ClientCertificateCredential(tenantId, clientId, { certificatePath, certificatePassword }, newOptions);
95
- return;
96
- }
97
- const username = process.env.AZURE_USERNAME;
98
- const password = process.env.AZURE_PASSWORD;
99
- if (tenantId && clientId && username && password) {
100
- logger.info(`Invoking UsernamePasswordCredential with tenant ID: ${tenantId}, clientId: ${clientId} and username: ${username}`);
101
- logger.warning("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.");
102
- this._credential = new usernamePasswordCredential_js_1.UsernamePasswordCredential(tenantId, clientId, username, password, newOptions);
103
- }
58
+ _credential = void 0;
59
+ /**
60
+ * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
61
+ *
62
+ * Required environment variables:
63
+ * - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
64
+ * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
65
+ *
66
+ * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
67
+ * - `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.
68
+ *
69
+ * Environment variables used for client credential authentication:
70
+ * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
71
+ * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
72
+ * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
73
+ * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.
74
+ *
75
+ * 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:
76
+ * - `AZURE_USERNAME`: Username to authenticate with.
77
+ * - `AZURE_PASSWORD`: Password to authenticate with.
78
+ *
79
+ * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.
80
+ * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.
81
+ *
82
+ * @param options - Options for configuring the client which makes the authentication request.
83
+ */
84
+ constructor(options) {
85
+ const assigned = (0, import_logging.processEnvVars)(AllSupportedEnvironmentVariables).assigned.join(", ");
86
+ logger.info(`Found the following environment variables: ${assigned}`);
87
+ const tenantId = process.env.AZURE_TENANT_ID, clientId = process.env.AZURE_CLIENT_ID, clientSecret = process.env.AZURE_CLIENT_SECRET;
88
+ const additionallyAllowedTenantIds = getAdditionallyAllowedTenants();
89
+ const sendCertificateChain = getSendCertificateChain();
90
+ const newOptions = { ...options, additionallyAllowedTenantIds, sendCertificateChain };
91
+ if (tenantId) {
92
+ (0, import_tenantIdUtils.checkTenantId)(logger, tenantId);
104
93
  }
105
- /**
106
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
107
- *
108
- * @param scopes - The list of scopes for which the token will have access.
109
- * @param options - Optional parameters. See {@link GetTokenOptions}.
110
- */
111
- async getToken(scopes, options = {}) {
112
- return tracing_js_1.tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {
113
- if (this._credential) {
114
- try {
115
- const result = await this._credential.getToken(scopes, newOptions);
116
- logger.getToken.info((0, logging_js_1.formatSuccess)(scopes));
117
- return result;
118
- }
119
- catch (err) {
120
- const authenticationError = new errors_js_1.AuthenticationError(400, {
121
- error: `${credentialName} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,
122
- error_description: err.message.toString().split("More details:").join(""),
123
- });
124
- logger.getToken.info((0, logging_js_1.formatError)(scopes, authenticationError));
125
- throw authenticationError;
126
- }
127
- }
128
- throw new errors_js_1.CredentialUnavailableError(`${credentialName} is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`);
129
- });
94
+ if (tenantId && clientId && clientSecret) {
95
+ logger.info(
96
+ `Invoking ClientSecretCredential with tenant ID: ${tenantId}, clientId: ${clientId} and clientSecret: [REDACTED]`
97
+ );
98
+ this._credential = new import_clientSecretCredential.ClientSecretCredential(tenantId, clientId, clientSecret, newOptions);
99
+ return;
130
100
  }
101
+ const certificatePath = process.env.AZURE_CLIENT_CERTIFICATE_PATH;
102
+ const certificatePassword = process.env.AZURE_CLIENT_CERTIFICATE_PASSWORD;
103
+ if (tenantId && clientId && certificatePath) {
104
+ logger.info(
105
+ `Invoking ClientCertificateCredential with tenant ID: ${tenantId}, clientId: ${clientId} and certificatePath: ${certificatePath}`
106
+ );
107
+ this._credential = new import_clientCertificateCredential.ClientCertificateCredential(
108
+ tenantId,
109
+ clientId,
110
+ { certificatePath, certificatePassword },
111
+ newOptions
112
+ );
113
+ return;
114
+ }
115
+ const username = process.env.AZURE_USERNAME;
116
+ const password = process.env.AZURE_PASSWORD;
117
+ if (tenantId && clientId && username && password) {
118
+ logger.info(
119
+ `Invoking UsernamePasswordCredential with tenant ID: ${tenantId}, clientId: ${clientId} and username: ${username}`
120
+ );
121
+ logger.warning(
122
+ "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."
123
+ );
124
+ this._credential = new import_usernamePasswordCredential.UsernamePasswordCredential(
125
+ tenantId,
126
+ clientId,
127
+ username,
128
+ password,
129
+ newOptions
130
+ );
131
+ }
132
+ }
133
+ /**
134
+ * Authenticates with Microsoft Entra ID and returns an access token if successful.
135
+ *
136
+ * @param scopes - The list of scopes for which the token will have access.
137
+ * @param options - Optional parameters. See {@link GetTokenOptions}.
138
+ */
139
+ async getToken(scopes, options = {}) {
140
+ return import_tracing.tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {
141
+ if (this._credential) {
142
+ try {
143
+ const result = await this._credential.getToken(scopes, newOptions);
144
+ logger.getToken.info((0, import_logging.formatSuccess)(scopes));
145
+ return result;
146
+ } catch (err) {
147
+ const authenticationError = new import_errors.AuthenticationError(400, {
148
+ error: `${credentialName} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,
149
+ error_description: err.message.toString().split("More details:").join("")
150
+ });
151
+ logger.getToken.info((0, import_logging.formatError)(scopes, authenticationError));
152
+ throw authenticationError;
153
+ }
154
+ }
155
+ throw new import_errors.CredentialUnavailableError(
156
+ `${credentialName} is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`
157
+ );
158
+ });
159
+ }
131
160
  }
132
- exports.EnvironmentCredential = EnvironmentCredential;
133
- //# sourceMappingURL=environmentCredential.js.map
161
+ // Annotate the CommonJS export names for ESM import in node:
162
+ 0 && (module.exports = {
163
+ AllSupportedEnvironmentVariables,
164
+ EnvironmentCredential,
165
+ getSendCertificateChain
166
+ });
167
+ //# sourceMappingURL=environmentCredential.js.map