@azure/identity 4.8.1-alpha.20250410.1 → 4.9.1-alpha.20250416.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) 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/commonjs/constants.d.ts +1 -1
  5. package/dist/commonjs/constants.js +1 -1
  6. package/dist/commonjs/constants.js.map +1 -1
  7. package/dist/esm/constants.d.ts +1 -1
  8. package/dist/esm/constants.js +1 -1
  9. package/dist/esm/constants.js.map +1 -1
  10. package/dist/workerd/client/identityClient.d.ts +65 -0
  11. package/dist/workerd/client/identityClient.d.ts.map +1 -0
  12. package/dist/workerd/client/identityClient.js +248 -0
  13. package/dist/workerd/client/identityClient.js.map +1 -0
  14. package/dist/workerd/constants.d.ts +69 -0
  15. package/dist/workerd/constants.d.ts.map +1 -0
  16. package/dist/workerd/constants.js +75 -0
  17. package/dist/workerd/constants.js.map +1 -0
  18. package/dist/workerd/credentials/authorityValidationOptions.d.ts +16 -0
  19. package/dist/workerd/credentials/authorityValidationOptions.d.ts.map +1 -0
  20. package/dist/workerd/credentials/authorityValidationOptions.js +4 -0
  21. package/dist/workerd/credentials/authorityValidationOptions.js.map +1 -0
  22. package/dist/workerd/credentials/authorizationCodeCredential.d.ts +73 -0
  23. package/dist/workerd/credentials/authorizationCodeCredential.d.ts.map +1 -0
  24. package/dist/workerd/credentials/authorizationCodeCredential.js +60 -0
  25. package/dist/workerd/credentials/authorizationCodeCredential.js.map +1 -0
  26. package/dist/workerd/credentials/authorizationCodeCredentialOptions.d.ts +8 -0
  27. package/dist/workerd/credentials/authorizationCodeCredentialOptions.d.ts.map +1 -0
  28. package/dist/workerd/credentials/authorizationCodeCredentialOptions.js +4 -0
  29. package/dist/workerd/credentials/authorizationCodeCredentialOptions.js.map +1 -0
  30. package/dist/workerd/credentials/azureApplicationCredential.d.ts +24 -0
  31. package/dist/workerd/credentials/azureApplicationCredential.d.ts.map +1 -0
  32. package/dist/workerd/credentials/azureApplicationCredential.js +32 -0
  33. package/dist/workerd/credentials/azureApplicationCredential.js.map +1 -0
  34. package/dist/workerd/credentials/azureApplicationCredentialOptions.d.ts +13 -0
  35. package/dist/workerd/credentials/azureApplicationCredentialOptions.d.ts.map +1 -0
  36. package/dist/workerd/credentials/azureApplicationCredentialOptions.js +4 -0
  37. package/dist/workerd/credentials/azureApplicationCredentialOptions.js.map +1 -0
  38. package/dist/workerd/credentials/azureCliCredential.d.ts +64 -0
  39. package/dist/workerd/credentials/azureCliCredential.d.ts.map +1 -0
  40. package/dist/workerd/credentials/azureCliCredential.js +191 -0
  41. package/dist/workerd/credentials/azureCliCredential.js.map +1 -0
  42. package/dist/workerd/credentials/azureCliCredentialOptions.d.ts +20 -0
  43. package/dist/workerd/credentials/azureCliCredentialOptions.d.ts.map +1 -0
  44. package/dist/workerd/credentials/azureCliCredentialOptions.js +4 -0
  45. package/dist/workerd/credentials/azureCliCredentialOptions.js.map +1 -0
  46. package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts +71 -0
  47. package/dist/workerd/credentials/azureDeveloperCliCredential.d.ts.map +1 -0
  48. package/dist/workerd/credentials/azureDeveloperCliCredential.js +173 -0
  49. package/dist/workerd/credentials/azureDeveloperCliCredential.js.map +1 -0
  50. package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.d.ts +15 -0
  51. package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.d.ts.map +1 -0
  52. package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.js +4 -0
  53. package/dist/workerd/credentials/azureDeveloperCliCredentialOptions.js.map +1 -0
  54. package/dist/workerd/credentials/azurePipelinesCredential.d.ts +38 -0
  55. package/dist/workerd/credentials/azurePipelinesCredential.d.ts.map +1 -0
  56. package/dist/workerd/credentials/azurePipelinesCredential.js +141 -0
  57. package/dist/workerd/credentials/azurePipelinesCredential.js.map +1 -0
  58. package/dist/workerd/credentials/azurePipelinesCredentialOptions.d.ts +9 -0
  59. package/dist/workerd/credentials/azurePipelinesCredentialOptions.d.ts.map +1 -0
  60. package/dist/workerd/credentials/azurePipelinesCredentialOptions.js +4 -0
  61. package/dist/workerd/credentials/azurePipelinesCredentialOptions.js.map +1 -0
  62. package/dist/workerd/credentials/azurePowerShellCredential.d.ts +75 -0
  63. package/dist/workerd/credentials/azurePowerShellCredential.d.ts.map +1 -0
  64. package/dist/workerd/credentials/azurePowerShellCredential.js +229 -0
  65. package/dist/workerd/credentials/azurePowerShellCredential.js.map +1 -0
  66. package/dist/workerd/credentials/azurePowerShellCredentialOptions.d.ts +15 -0
  67. package/dist/workerd/credentials/azurePowerShellCredentialOptions.d.ts.map +1 -0
  68. package/dist/workerd/credentials/azurePowerShellCredentialOptions.js +4 -0
  69. package/dist/workerd/credentials/azurePowerShellCredentialOptions.js.map +1 -0
  70. package/dist/workerd/credentials/brokerAuthOptions.d.ts +13 -0
  71. package/dist/workerd/credentials/brokerAuthOptions.d.ts.map +1 -0
  72. package/dist/workerd/credentials/brokerAuthOptions.js +2 -0
  73. package/dist/workerd/credentials/brokerAuthOptions.js.map +1 -0
  74. package/dist/workerd/credentials/browserCustomizationOptions.d.ts +19 -0
  75. package/dist/workerd/credentials/browserCustomizationOptions.d.ts.map +1 -0
  76. package/dist/workerd/credentials/browserCustomizationOptions.js +4 -0
  77. package/dist/workerd/credentials/browserCustomizationOptions.js.map +1 -0
  78. package/dist/workerd/credentials/chainedTokenCredential.d.ts +51 -0
  79. package/dist/workerd/credentials/chainedTokenCredential.d.ts.map +1 -0
  80. package/dist/workerd/credentials/chainedTokenCredential.js +92 -0
  81. package/dist/workerd/credentials/chainedTokenCredential.js.map +1 -0
  82. package/dist/workerd/credentials/clientAssertionCredential.d.ts +33 -0
  83. package/dist/workerd/credentials/clientAssertionCredential.d.ts.map +1 -0
  84. package/dist/workerd/credentials/clientAssertionCredential.js +55 -0
  85. package/dist/workerd/credentials/clientAssertionCredential.js.map +1 -0
  86. package/dist/workerd/credentials/clientAssertionCredentialOptions.d.ts +9 -0
  87. package/dist/workerd/credentials/clientAssertionCredentialOptions.d.ts.map +1 -0
  88. package/dist/workerd/credentials/clientAssertionCredentialOptions.js +4 -0
  89. package/dist/workerd/credentials/clientAssertionCredentialOptions.js.map +1 -0
  90. package/dist/workerd/credentials/clientCertificateCredential.d.ts +72 -0
  91. package/dist/workerd/credentials/clientCertificateCredential.d.ts.map +1 -0
  92. package/dist/workerd/credentials/clientCertificateCredential.js +122 -0
  93. package/dist/workerd/credentials/clientCertificateCredential.js.map +1 -0
  94. package/dist/workerd/credentials/clientCertificateCredentialModels.d.ts +31 -0
  95. package/dist/workerd/credentials/clientCertificateCredentialModels.d.ts.map +1 -0
  96. package/dist/workerd/credentials/clientCertificateCredentialModels.js +4 -0
  97. package/dist/workerd/credentials/clientCertificateCredentialModels.js.map +1 -0
  98. package/dist/workerd/credentials/clientCertificateCredentialOptions.d.ts +14 -0
  99. package/dist/workerd/credentials/clientCertificateCredentialOptions.d.ts.map +1 -0
  100. package/dist/workerd/credentials/clientCertificateCredentialOptions.js +4 -0
  101. package/dist/workerd/credentials/clientCertificateCredentialOptions.js.map +1 -0
  102. package/dist/workerd/credentials/clientSecretCredential.d.ts +37 -0
  103. package/dist/workerd/credentials/clientSecretCredential.d.ts.map +1 -0
  104. package/dist/workerd/credentials/clientSecretCredential.js +60 -0
  105. package/dist/workerd/credentials/clientSecretCredential.js.map +1 -0
  106. package/dist/workerd/credentials/clientSecretCredentialOptions.d.ts +9 -0
  107. package/dist/workerd/credentials/clientSecretCredentialOptions.d.ts.map +1 -0
  108. package/dist/workerd/credentials/clientSecretCredentialOptions.js +4 -0
  109. package/dist/workerd/credentials/clientSecretCredentialOptions.js.map +1 -0
  110. package/dist/workerd/credentials/credentialPersistenceOptions.d.ts +30 -0
  111. package/dist/workerd/credentials/credentialPersistenceOptions.d.ts.map +1 -0
  112. package/dist/workerd/credentials/credentialPersistenceOptions.js +4 -0
  113. package/dist/workerd/credentials/credentialPersistenceOptions.js.map +1 -0
  114. package/dist/workerd/credentials/defaultAzureCredential.d.ts +65 -0
  115. package/dist/workerd/credentials/defaultAzureCredential.d.ts.map +1 -0
  116. package/dist/workerd/credentials/defaultAzureCredential.js +164 -0
  117. package/dist/workerd/credentials/defaultAzureCredential.js.map +1 -0
  118. package/dist/workerd/credentials/defaultAzureCredentialOptions.d.ts +49 -0
  119. package/dist/workerd/credentials/defaultAzureCredentialOptions.d.ts.map +1 -0
  120. package/dist/workerd/credentials/defaultAzureCredentialOptions.js +4 -0
  121. package/dist/workerd/credentials/defaultAzureCredentialOptions.js.map +1 -0
  122. package/dist/workerd/credentials/deviceCodeCredential.d.ts +67 -0
  123. package/dist/workerd/credentials/deviceCodeCredential.d.ts.map +1 -0
  124. package/dist/workerd/credentials/deviceCodeCredential.js +91 -0
  125. package/dist/workerd/credentials/deviceCodeCredential.js.map +1 -0
  126. package/dist/workerd/credentials/deviceCodeCredentialOptions.d.ts +53 -0
  127. package/dist/workerd/credentials/deviceCodeCredentialOptions.d.ts.map +1 -0
  128. package/dist/workerd/credentials/deviceCodeCredentialOptions.js +4 -0
  129. package/dist/workerd/credentials/deviceCodeCredentialOptions.js.map +1 -0
  130. package/dist/workerd/credentials/environmentCredential.d.ts +52 -0
  131. package/dist/workerd/credentials/environmentCredential.d.ts.map +1 -0
  132. package/dist/workerd/credentials/environmentCredential.js +130 -0
  133. package/dist/workerd/credentials/environmentCredential.js.map +1 -0
  134. package/dist/workerd/credentials/environmentCredentialOptions.d.ts +9 -0
  135. package/dist/workerd/credentials/environmentCredentialOptions.d.ts.map +1 -0
  136. package/dist/workerd/credentials/environmentCredentialOptions.js +4 -0
  137. package/dist/workerd/credentials/environmentCredentialOptions.js.map +1 -0
  138. package/dist/workerd/credentials/interactiveBrowserCredential.d.ts +56 -0
  139. package/dist/workerd/credentials/interactiveBrowserCredential.d.ts.map +1 -0
  140. package/dist/workerd/credentials/interactiveBrowserCredential.js +91 -0
  141. package/dist/workerd/credentials/interactiveBrowserCredential.js.map +1 -0
  142. package/dist/workerd/credentials/interactiveBrowserCredentialOptions.d.ts +77 -0
  143. package/dist/workerd/credentials/interactiveBrowserCredentialOptions.d.ts.map +1 -0
  144. package/dist/workerd/credentials/interactiveBrowserCredentialOptions.js +4 -0
  145. package/dist/workerd/credentials/interactiveBrowserCredentialOptions.js.map +1 -0
  146. package/dist/workerd/credentials/interactiveCredentialOptions.d.ts +25 -0
  147. package/dist/workerd/credentials/interactiveCredentialOptions.d.ts.map +1 -0
  148. package/dist/workerd/credentials/interactiveCredentialOptions.js +4 -0
  149. package/dist/workerd/credentials/interactiveCredentialOptions.js.map +1 -0
  150. package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.d.ts +18 -0
  151. package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.d.ts.map +1 -0
  152. package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.js +99 -0
  153. package/dist/workerd/credentials/managedIdentityCredential/imdsMsi.js.map +1 -0
  154. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts +12 -0
  155. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.d.ts.map +1 -0
  156. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.js +33 -0
  157. package/dist/workerd/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -0
  158. package/dist/workerd/credentials/managedIdentityCredential/index.d.ts +61 -0
  159. package/dist/workerd/credentials/managedIdentityCredential/index.d.ts.map +1 -0
  160. package/dist/workerd/credentials/managedIdentityCredential/index.js +239 -0
  161. package/dist/workerd/credentials/managedIdentityCredential/index.js.map +1 -0
  162. package/dist/workerd/credentials/managedIdentityCredential/models.d.ts +24 -0
  163. package/dist/workerd/credentials/managedIdentityCredential/models.d.ts.map +1 -0
  164. package/dist/workerd/credentials/managedIdentityCredential/models.js +4 -0
  165. package/dist/workerd/credentials/managedIdentityCredential/models.js.map +1 -0
  166. package/dist/workerd/credentials/managedIdentityCredential/options.d.ts +37 -0
  167. package/dist/workerd/credentials/managedIdentityCredential/options.d.ts.map +1 -0
  168. package/dist/workerd/credentials/managedIdentityCredential/options.js +4 -0
  169. package/dist/workerd/credentials/managedIdentityCredential/options.js.map +1 -0
  170. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts +14 -0
  171. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.d.ts.map +1 -0
  172. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js +32 -0
  173. package/dist/workerd/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
  174. package/dist/workerd/credentials/managedIdentityCredential/utils.d.ts +37 -0
  175. package/dist/workerd/credentials/managedIdentityCredential/utils.d.ts.map +1 -0
  176. package/dist/workerd/credentials/managedIdentityCredential/utils.js +81 -0
  177. package/dist/workerd/credentials/managedIdentityCredential/utils.js.map +1 -0
  178. package/dist/workerd/credentials/multiTenantTokenCredentialOptions.d.ts +12 -0
  179. package/dist/workerd/credentials/multiTenantTokenCredentialOptions.d.ts.map +1 -0
  180. package/dist/workerd/credentials/multiTenantTokenCredentialOptions.js +4 -0
  181. package/dist/workerd/credentials/multiTenantTokenCredentialOptions.js.map +1 -0
  182. package/dist/workerd/credentials/onBehalfOfCredential.d.ts +105 -0
  183. package/dist/workerd/credentials/onBehalfOfCredential.d.ts.map +1 -0
  184. package/dist/workerd/credentials/onBehalfOfCredential.js +112 -0
  185. package/dist/workerd/credentials/onBehalfOfCredential.js.map +1 -0
  186. package/dist/workerd/credentials/onBehalfOfCredentialOptions.d.ts +76 -0
  187. package/dist/workerd/credentials/onBehalfOfCredentialOptions.d.ts.map +1 -0
  188. package/dist/workerd/credentials/onBehalfOfCredentialOptions.js +4 -0
  189. package/dist/workerd/credentials/onBehalfOfCredentialOptions.js.map +1 -0
  190. package/dist/workerd/credentials/usernamePasswordCredential.d.ts +42 -0
  191. package/dist/workerd/credentials/usernamePasswordCredential.d.ts.map +1 -0
  192. package/dist/workerd/credentials/usernamePasswordCredential.js +68 -0
  193. package/dist/workerd/credentials/usernamePasswordCredential.js.map +1 -0
  194. package/dist/workerd/credentials/usernamePasswordCredentialOptions.d.ts +10 -0
  195. package/dist/workerd/credentials/usernamePasswordCredentialOptions.d.ts.map +1 -0
  196. package/dist/workerd/credentials/usernamePasswordCredentialOptions.js +4 -0
  197. package/dist/workerd/credentials/usernamePasswordCredentialOptions.js.map +1 -0
  198. package/dist/workerd/credentials/visualStudioCodeCredential.d.ts +66 -0
  199. package/dist/workerd/credentials/visualStudioCodeCredential.d.ts.map +1 -0
  200. package/dist/workerd/credentials/visualStudioCodeCredential.js +196 -0
  201. package/dist/workerd/credentials/visualStudioCodeCredential.js.map +1 -0
  202. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.d.ts +16 -0
  203. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.d.ts.map +1 -0
  204. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.js +4 -0
  205. package/dist/workerd/credentials/visualStudioCodeCredentialOptions.js.map +1 -0
  206. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts +16 -0
  207. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.d.ts.map +1 -0
  208. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js +4 -0
  209. package/dist/workerd/credentials/visualStudioCodeCredentialPlugin.js.map +1 -0
  210. package/dist/workerd/credentials/workloadIdentityCredential.d.ts +47 -0
  211. package/dist/workerd/credentials/workloadIdentityCredential.d.ts.map +1 -0
  212. package/dist/workerd/credentials/workloadIdentityCredential.js +114 -0
  213. package/dist/workerd/credentials/workloadIdentityCredential.js.map +1 -0
  214. package/dist/workerd/credentials/workloadIdentityCredentialOptions.d.ts +20 -0
  215. package/dist/workerd/credentials/workloadIdentityCredentialOptions.d.ts.map +1 -0
  216. package/dist/workerd/credentials/workloadIdentityCredentialOptions.js +4 -0
  217. package/dist/workerd/credentials/workloadIdentityCredentialOptions.js.map +1 -0
  218. package/dist/workerd/errors.d.ts +139 -0
  219. package/dist/workerd/errors.d.ts.map +1 -0
  220. package/dist/workerd/errors.js +123 -0
  221. package/dist/workerd/errors.js.map +1 -0
  222. package/dist/workerd/index.d.ts +61 -0
  223. package/dist/workerd/index.d.ts.map +1 -0
  224. package/dist/workerd/index.js +34 -0
  225. package/dist/workerd/index.js.map +1 -0
  226. package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts +19 -0
  227. package/dist/workerd/msal/browserFlows/msalBrowserCommon.d.ts.map +1 -0
  228. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js +291 -0
  229. package/dist/workerd/msal/browserFlows/msalBrowserCommon.js.map +1 -0
  230. package/dist/workerd/msal/browserFlows/msalBrowserOptions.d.ts +87 -0
  231. package/dist/workerd/msal/browserFlows/msalBrowserOptions.d.ts.map +1 -0
  232. package/dist/workerd/msal/browserFlows/msalBrowserOptions.js +4 -0
  233. package/dist/workerd/msal/browserFlows/msalBrowserOptions.js.map +1 -0
  234. package/dist/workerd/msal/credentials.d.ts +52 -0
  235. package/dist/workerd/msal/credentials.d.ts.map +1 -0
  236. package/dist/workerd/msal/credentials.js +4 -0
  237. package/dist/workerd/msal/credentials.js.map +1 -0
  238. package/dist/workerd/msal/msal.d.ts +3 -0
  239. package/dist/workerd/msal/msal.d.ts.map +1 -0
  240. package/dist/workerd/msal/msal.js +5 -0
  241. package/dist/workerd/msal/msal.js.map +1 -0
  242. package/dist/workerd/msal/nodeFlows/brokerOptions.d.ts +44 -0
  243. package/dist/workerd/msal/nodeFlows/brokerOptions.d.ts.map +1 -0
  244. package/dist/workerd/msal/nodeFlows/brokerOptions.js +2 -0
  245. package/dist/workerd/msal/nodeFlows/brokerOptions.js.map +1 -0
  246. package/dist/workerd/msal/nodeFlows/msalClient.d.ts +186 -0
  247. package/dist/workerd/msal/nodeFlows/msalClient.d.ts.map +1 -0
  248. package/dist/workerd/msal/nodeFlows/msalClient.js +469 -0
  249. package/dist/workerd/msal/nodeFlows/msalClient.js.map +1 -0
  250. package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts +91 -0
  251. package/dist/workerd/msal/nodeFlows/msalPlugins.d.ts.map +1 -0
  252. package/dist/workerd/msal/nodeFlows/msalPlugins.js +87 -0
  253. package/dist/workerd/msal/nodeFlows/msalPlugins.js.map +1 -0
  254. package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.d.ts +24 -0
  255. package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.d.ts.map +1 -0
  256. package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.js +4 -0
  257. package/dist/workerd/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -0
  258. package/dist/workerd/msal/types.d.ts +87 -0
  259. package/dist/workerd/msal/types.d.ts.map +1 -0
  260. package/dist/workerd/msal/types.js +4 -0
  261. package/dist/workerd/msal/types.js.map +1 -0
  262. package/dist/workerd/msal/utils.d.ts +95 -0
  263. package/dist/workerd/msal/utils.d.ts.map +1 -0
  264. package/dist/workerd/msal/utils.js +238 -0
  265. package/dist/workerd/msal/utils.js.map +1 -0
  266. package/dist/workerd/package.json +3 -0
  267. package/dist/workerd/plugins/consumer.d.ts +28 -0
  268. package/dist/workerd/plugins/consumer.d.ts.map +1 -0
  269. package/dist/workerd/plugins/consumer.js +43 -0
  270. package/dist/workerd/plugins/consumer.js.map +1 -0
  271. package/dist/workerd/plugins/provider.d.ts +36 -0
  272. package/dist/workerd/plugins/provider.d.ts.map +1 -0
  273. package/dist/workerd/plugins/provider.js +4 -0
  274. package/dist/workerd/plugins/provider.js.map +1 -0
  275. package/dist/workerd/regionalAuthority.d.ts +122 -0
  276. package/dist/workerd/regionalAuthority.d.ts.map +1 -0
  277. package/dist/workerd/regionalAuthority.js +140 -0
  278. package/dist/workerd/regionalAuthority.js.map +1 -0
  279. package/dist/workerd/tokenCredentialOptions.d.ts +28 -0
  280. package/dist/workerd/tokenCredentialOptions.d.ts.map +1 -0
  281. package/dist/workerd/tokenCredentialOptions.js +4 -0
  282. package/dist/workerd/tokenCredentialOptions.js.map +1 -0
  283. package/dist/workerd/tokenProvider.d.ts +39 -0
  284. package/dist/workerd/tokenProvider.d.ts.map +1 -0
  285. package/dist/workerd/tokenProvider.js +53 -0
  286. package/dist/workerd/tokenProvider.js.map +1 -0
  287. package/dist/workerd/util/authHostEnv-browser.d.mts +4 -0
  288. package/dist/workerd/util/authHostEnv-browser.d.mts.map +1 -0
  289. package/dist/workerd/util/authHostEnv-browser.mjs +7 -0
  290. package/dist/workerd/util/authHostEnv-browser.mjs.map +1 -0
  291. package/dist/workerd/util/identityTokenEndpoint.d.ts +2 -0
  292. package/dist/workerd/util/identityTokenEndpoint.d.ts.map +1 -0
  293. package/dist/workerd/util/identityTokenEndpoint.js +11 -0
  294. package/dist/workerd/util/identityTokenEndpoint.js.map +1 -0
  295. package/dist/workerd/util/logging.d.ts +70 -0
  296. package/dist/workerd/util/logging.d.ts.map +1 -0
  297. package/dist/workerd/util/logging.js +94 -0
  298. package/dist/workerd/util/logging.js.map +1 -0
  299. package/dist/workerd/util/processMultiTenantRequest.d.ts +10 -0
  300. package/dist/workerd/util/processMultiTenantRequest.d.ts.map +1 -0
  301. package/dist/workerd/util/processMultiTenantRequest.js +35 -0
  302. package/dist/workerd/util/processMultiTenantRequest.js.map +1 -0
  303. package/dist/workerd/util/processUtils.d.ts +13 -0
  304. package/dist/workerd/util/processUtils.d.ts.map +1 -0
  305. package/dist/workerd/util/processUtils.js +32 -0
  306. package/dist/workerd/util/processUtils.js.map +1 -0
  307. package/dist/workerd/util/scopeUtils.d.ts +17 -0
  308. package/dist/workerd/util/scopeUtils.d.ts.map +1 -0
  309. package/dist/workerd/util/scopeUtils.js +29 -0
  310. package/dist/workerd/util/scopeUtils.js.map +1 -0
  311. package/dist/workerd/util/subscriptionUtils.d.ts +6 -0
  312. package/dist/workerd/util/subscriptionUtils.d.ts.map +1 -0
  313. package/dist/workerd/util/subscriptionUtils.js +14 -0
  314. package/dist/workerd/util/subscriptionUtils.js.map +1 -0
  315. package/dist/workerd/util/tenantIdUtils.d.ts +15 -0
  316. package/dist/workerd/util/tenantIdUtils.d.ts.map +1 -0
  317. package/dist/workerd/util/tenantIdUtils.js +44 -0
  318. package/dist/workerd/util/tenantIdUtils.js.map +1 -0
  319. package/dist/workerd/util/tracing.d.ts +6 -0
  320. package/dist/workerd/util/tracing.d.ts.map +1 -0
  321. package/dist/workerd/util/tracing.js +14 -0
  322. package/dist/workerd/util/tracing.js.map +1 -0
  323. package/package.json +9 -3
@@ -0,0 +1,99 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { createHttpHeaders, createPipelineRequest } from "@azure/core-rest-pipeline";
4
+ import { isError } from "@azure/core-util";
5
+ import { credentialLogger } from "../../util/logging.js";
6
+ import { mapScopesToResource } from "./utils.js";
7
+ import { tracingClient } from "../../util/tracing.js";
8
+ const msiName = "ManagedIdentityCredential - IMDS";
9
+ const logger = credentialLogger(msiName);
10
+ const imdsHost = "http://169.254.169.254";
11
+ const imdsEndpointPath = "/metadata/identity/oauth2/token";
12
+ /**
13
+ * Generates an invalid request options to get a response quickly from IMDS endpoint.
14
+ * The response indicates the availability of IMSD service; otherwise the request would time out.
15
+ */
16
+ function prepareInvalidRequestOptions(scopes) {
17
+ var _a;
18
+ const resource = mapScopesToResource(scopes);
19
+ if (!resource) {
20
+ throw new Error(`${msiName}: Multiple scopes are not supported.`);
21
+ }
22
+ // Pod Identity will try to process this request even if the Metadata header is missing.
23
+ // We can exclude the request query to ensure no IMDS endpoint tries to process the ping request.
24
+ const url = new URL(imdsEndpointPath, (_a = process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) !== null && _a !== void 0 ? _a : imdsHost);
25
+ const rawHeaders = {
26
+ Accept: "application/json",
27
+ // intentionally leave out the Metadata header to invoke an error from IMDS endpoint.
28
+ };
29
+ return {
30
+ // intentionally not including any query
31
+ url: `${url}`,
32
+ method: "GET",
33
+ headers: createHttpHeaders(rawHeaders),
34
+ };
35
+ }
36
+ /**
37
+ * Defines how to determine whether the Azure IMDS MSI is available.
38
+ *
39
+ * Actually getting the token once we determine IMDS is available is handled by MSAL.
40
+ */
41
+ export const imdsMsi = {
42
+ name: "imdsMsi",
43
+ async isAvailable(options) {
44
+ const { scopes, identityClient, getTokenOptions } = options;
45
+ const resource = mapScopesToResource(scopes);
46
+ if (!resource) {
47
+ logger.info(`${msiName}: Unavailable. Multiple scopes are not supported.`);
48
+ return false;
49
+ }
50
+ // if the PodIdentityEndpoint environment variable was set no need to probe the endpoint, it can be assumed to exist
51
+ if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
52
+ return true;
53
+ }
54
+ if (!identityClient) {
55
+ throw new Error("Missing IdentityClient");
56
+ }
57
+ const requestOptions = prepareInvalidRequestOptions(resource);
58
+ return tracingClient.withSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions !== null && getTokenOptions !== void 0 ? getTokenOptions : {}, async (updatedOptions) => {
59
+ var _a, _b;
60
+ requestOptions.tracingOptions = updatedOptions.tracingOptions;
61
+ // Create a request with a timeout since we expect that
62
+ // not having a "Metadata" header should cause an error to be
63
+ // returned quickly from the endpoint, proving its availability.
64
+ const request = createPipelineRequest(requestOptions);
65
+ // Default to 1000 if the default of 0 is used.
66
+ // Negative values can still be used to disable the timeout.
67
+ request.timeout = ((_a = updatedOptions.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) || 1000;
68
+ // This MSI uses the imdsEndpoint to get the token, which only uses http://
69
+ request.allowInsecureConnection = true;
70
+ let response;
71
+ try {
72
+ logger.info(`${msiName}: Pinging the Azure IMDS endpoint`);
73
+ response = await identityClient.sendRequest(request);
74
+ }
75
+ catch (err) {
76
+ // If the request failed, or Node.js was unable to establish a connection,
77
+ // or the host was down, we'll assume the IMDS endpoint isn't available.
78
+ if (isError(err)) {
79
+ logger.verbose(`${msiName}: Caught error ${err.name}: ${err.message}`);
80
+ }
81
+ // This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network" or "A socket operation was attempted to an unreachable host"
82
+ // rather than just timing out, as expected.
83
+ logger.info(`${msiName}: The Azure IMDS endpoint is unavailable`);
84
+ return false;
85
+ }
86
+ if (response.status === 403) {
87
+ if ((_b = response.bodyAsText) === null || _b === void 0 ? void 0 : _b.includes("unreachable")) {
88
+ logger.info(`${msiName}: The Azure IMDS endpoint is unavailable`);
89
+ logger.info(`${msiName}: ${response.bodyAsText}`);
90
+ return false;
91
+ }
92
+ }
93
+ // If we received any response, the endpoint is available
94
+ logger.info(`${msiName}: The Azure IMDS endpoint is available`);
95
+ return true;
96
+ });
97
+ },
98
+ };
99
+ //# sourceMappingURL=imdsMsi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imdsMsi.js","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/imdsMsi.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,MAAM,OAAO,GAAG,kCAAkC,CAAC;AACnD,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAEzC,MAAM,QAAQ,GAAG,wBAAwB,CAAC;AAC1C,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAE3D;;;GAGG;AACH,SAAS,4BAA4B,CAAC,MAAyB;;IAC7D,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAA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M,CAAC,IAAI,CAAC,GAAG,OAAO,wCAAwC,CAAC,CAAC;YAChE,OAAO,IAAI,CAAC;QACd,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequestOptions, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { createHttpHeaders, createPipelineRequest } from \"@azure/core-rest-pipeline\";\nimport { isError } from \"@azure/core-util\";\n\nimport type { GetTokenOptions } from \"@azure/core-auth\";\nimport { credentialLogger } from \"../../util/logging.js\";\nimport { mapScopesToResource } from \"./utils.js\";\nimport { tracingClient } from \"../../util/tracing.js\";\nimport type { IdentityClient } from \"../../client/identityClient.js\";\n\nconst msiName = \"ManagedIdentityCredential - IMDS\";\nconst logger = credentialLogger(msiName);\n\nconst imdsHost = \"http://169.254.169.254\";\nconst imdsEndpointPath = \"/metadata/identity/oauth2/token\";\n\n/**\n * Generates an invalid request options to get a response quickly from IMDS endpoint.\n * The response indicates the availability of IMSD service; otherwise the request would time out.\n */\nfunction prepareInvalidRequestOptions(scopes: string | string[]): PipelineRequestOptions {\n const resource = mapScopesToResource(scopes);\n if (!resource) {\n throw new Error(`${msiName}: Multiple scopes are not supported.`);\n }\n\n // Pod Identity will try to process this request even if the Metadata header is missing.\n // We can exclude the request query to ensure no IMDS endpoint tries to process the ping request.\n const url = new URL(imdsEndpointPath, process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST ?? imdsHost);\n\n const rawHeaders: Record<string, string> = {\n Accept: \"application/json\",\n // intentionally leave out the Metadata header to invoke an error from IMDS endpoint.\n };\n\n return {\n // intentionally not including any query\n url: `${url}`,\n method: \"GET\",\n headers: createHttpHeaders(rawHeaders),\n };\n}\n\n/**\n * Defines how to determine whether the Azure IMDS MSI is available.\n *\n * Actually getting the token once we determine IMDS is available is handled by MSAL.\n */\nexport const imdsMsi = {\n name: \"imdsMsi\",\n async isAvailable(options: {\n scopes: string | string[];\n identityClient?: IdentityClient;\n clientId?: string;\n resourceId?: string;\n getTokenOptions?: GetTokenOptions;\n }): Promise<boolean> {\n const { scopes, identityClient, getTokenOptions } = options;\n const resource = mapScopesToResource(scopes);\n if (!resource) {\n logger.info(`${msiName}: Unavailable. Multiple scopes are not supported.`);\n return false;\n }\n\n // if the PodIdentityEndpoint environment variable was set no need to probe the endpoint, it can be assumed to exist\n if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {\n return true;\n }\n\n if (!identityClient) {\n throw new Error(\"Missing IdentityClient\");\n }\n\n const requestOptions = prepareInvalidRequestOptions(resource);\n\n return tracingClient.withSpan(\n \"ManagedIdentityCredential-pingImdsEndpoint\",\n getTokenOptions ?? {},\n async (updatedOptions) => {\n requestOptions.tracingOptions = updatedOptions.tracingOptions;\n\n // Create a request with a timeout since we expect that\n // not having a \"Metadata\" header should cause an error to be\n // returned quickly from the endpoint, proving its availability.\n const request = createPipelineRequest(requestOptions);\n\n // Default to 1000 if the default of 0 is used.\n // Negative values can still be used to disable the timeout.\n request.timeout = updatedOptions.requestOptions?.timeout || 1000;\n\n // This MSI uses the imdsEndpoint to get the token, which only uses http://\n request.allowInsecureConnection = true;\n let response: PipelineResponse;\n try {\n logger.info(`${msiName}: Pinging the Azure IMDS endpoint`);\n response = await identityClient.sendRequest(request);\n } catch (err: unknown) {\n // If the request failed, or Node.js was unable to establish a connection,\n // or the host was down, we'll assume the IMDS endpoint isn't available.\n if (isError(err)) {\n logger.verbose(`${msiName}: Caught error ${err.name}: ${err.message}`);\n }\n // This is a special case for Docker Desktop which responds with a 403 with a message that contains \"A socket operation was attempted to an unreachable network\" or \"A socket operation was attempted to an unreachable host\"\n // rather than just timing out, as expected.\n logger.info(`${msiName}: The Azure IMDS endpoint is unavailable`);\n return false;\n }\n if (response.status === 403) {\n if (response.bodyAsText?.includes(\"unreachable\")) {\n logger.info(`${msiName}: The Azure IMDS endpoint is unavailable`);\n logger.info(`${msiName}: ${response.bodyAsText}`);\n return false;\n }\n }\n // If we received any response, the endpoint is available\n logger.info(`${msiName}: The Azure IMDS endpoint is available`);\n return true;\n },\n );\n },\n};\n"]}
@@ -0,0 +1,12 @@
1
+ import type { PipelinePolicy } from "@azure/core-rest-pipeline";
2
+ import type { MSIConfiguration } from "./models.js";
3
+ /**
4
+ * An additional policy that retries on 404 errors. The default retry policy does not retry on
5
+ * 404s, but the IMDS endpoint can return 404s when the token is not yet available. This policy
6
+ * will retry on 404s with an exponential backoff.
7
+ *
8
+ * @param msiRetryConfig - The retry configuration for the MSI credential.
9
+ * @returns - The policy that will retry on 404s.
10
+ */
11
+ export declare function imdsRetryPolicy(msiRetryConfig: MSIConfiguration["retryConfig"]): PipelinePolicy;
12
+ //# sourceMappingURL=imdsRetryPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imdsRetryPolicy.d.ts","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/imdsRetryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAMpD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,gBAAgB,CAAC,aAAa,CAAC,GAAG,cAAc,CAqB/F"}
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { retryPolicy } from "@azure/core-rest-pipeline";
4
+ import { calculateRetryDelay } from "@azure/core-util";
5
+ // Matches the default retry configuration in expontentialRetryStrategy.ts
6
+ const DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;
7
+ /**
8
+ * An additional policy that retries on 404 errors. The default retry policy does not retry on
9
+ * 404s, but the IMDS endpoint can return 404s when the token is not yet available. This policy
10
+ * will retry on 404s with an exponential backoff.
11
+ *
12
+ * @param msiRetryConfig - The retry configuration for the MSI credential.
13
+ * @returns - The policy that will retry on 404s.
14
+ */
15
+ export function imdsRetryPolicy(msiRetryConfig) {
16
+ return retryPolicy([
17
+ {
18
+ name: "imdsRetryPolicy",
19
+ retry: ({ retryCount, response }) => {
20
+ if ((response === null || response === void 0 ? void 0 : response.status) !== 404) {
21
+ return { skipStrategy: true };
22
+ }
23
+ return calculateRetryDelay(retryCount, {
24
+ retryDelayInMs: msiRetryConfig.startDelayInMs,
25
+ maxRetryDelayInMs: DEFAULT_CLIENT_MAX_RETRY_INTERVAL,
26
+ });
27
+ },
28
+ },
29
+ ], {
30
+ maxRetries: msiRetryConfig.maxRetries,
31
+ });
32
+ }
33
+ //# sourceMappingURL=imdsRetryPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imdsRetryPolicy.js","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/imdsRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,0EAA0E;AAC1E,MAAM,iCAAiC,GAAG,IAAI,GAAG,EAAE,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,cAA+C;IAC7E,OAAO,WAAW,CAChB;QACE;YACE,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;gBAClC,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,MAAK,GAAG,EAAE,CAAC;oBAC7B,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;gBAChC,CAAC;gBAED,OAAO,mBAAmB,CAAC,UAAU,EAAE;oBACrC,cAAc,EAAE,cAAc,CAAC,cAAc;oBAC7C,iBAAiB,EAAE,iCAAiC;iBACrD,CAAC,CAAC;YACL,CAAC;SACF;KACF,EACD;QACE,UAAU,EAAE,cAAc,CAAC,UAAU;KACtC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport { retryPolicy } from \"@azure/core-rest-pipeline\";\n\nimport type { MSIConfiguration } from \"./models.js\";\nimport { calculateRetryDelay } from \"@azure/core-util\";\n\n// Matches the default retry configuration in expontentialRetryStrategy.ts\nconst DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;\n\n/**\n * An additional policy that retries on 404 errors. The default retry policy does not retry on\n * 404s, but the IMDS endpoint can return 404s when the token is not yet available. This policy\n * will retry on 404s with an exponential backoff.\n *\n * @param msiRetryConfig - The retry configuration for the MSI credential.\n * @returns - The policy that will retry on 404s.\n */\nexport function imdsRetryPolicy(msiRetryConfig: MSIConfiguration[\"retryConfig\"]): PipelinePolicy {\n return retryPolicy(\n [\n {\n name: \"imdsRetryPolicy\",\n retry: ({ retryCount, response }) => {\n if (response?.status !== 404) {\n return { skipStrategy: true };\n }\n\n return calculateRetryDelay(retryCount, {\n retryDelayInMs: msiRetryConfig.startDelayInMs,\n maxRetryDelayInMs: DEFAULT_CLIENT_MAX_RETRY_INTERVAL,\n });\n },\n },\n ],\n {\n maxRetries: msiRetryConfig.maxRetries,\n },\n );\n}\n"]}
@@ -0,0 +1,61 @@
1
+ import type { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth";
2
+ import type { TokenCredentialOptions } from "../../tokenCredentialOptions.js";
3
+ import type { ManagedIdentityCredentialClientIdOptions, ManagedIdentityCredentialObjectIdOptions, ManagedIdentityCredentialResourceIdOptions } from "./options.js";
4
+ /**
5
+ * Attempts authentication using a managed identity available at the deployment environment.
6
+ * This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
7
+ * Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
8
+ *
9
+ * More information about configuring managed identities can be found here:
10
+ * https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
11
+ */
12
+ export declare class ManagedIdentityCredential implements TokenCredential {
13
+ private managedIdentityApp;
14
+ private identityClient;
15
+ private clientId?;
16
+ private resourceId?;
17
+ private objectId?;
18
+ private msiRetryConfig;
19
+ private isAvailableIdentityClient;
20
+ /**
21
+ * Creates an instance of ManagedIdentityCredential with the client ID of a
22
+ * user-assigned identity, or app registration (when working with AKS pod-identity).
23
+ *
24
+ * @param clientId - The client ID of the user-assigned identity, or app registration (when working with AKS pod-identity).
25
+ * @param options - Options for configuring the client which makes the access token request.
26
+ */
27
+ constructor(clientId: string, options?: TokenCredentialOptions);
28
+ /**
29
+ * Creates an instance of ManagedIdentityCredential with a client ID
30
+ *
31
+ * @param options - Options for configuring the client which makes the access token request.
32
+ */
33
+ constructor(options?: ManagedIdentityCredentialClientIdOptions);
34
+ /**
35
+ * Creates an instance of ManagedIdentityCredential with a resource ID
36
+ *
37
+ * @param options - Options for configuring the resource which makes the access token request.
38
+ */
39
+ constructor(options?: ManagedIdentityCredentialResourceIdOptions);
40
+ /**
41
+ * Creates an instance of ManagedIdentityCredential with an object ID
42
+ *
43
+ * @param options - Options for configuring the resource which makes the access token request.
44
+ */
45
+ constructor(options?: ManagedIdentityCredentialObjectIdOptions);
46
+ /**
47
+ * Authenticates with Microsoft Entra ID and returns an access token if successful.
48
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
49
+ * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
50
+ *
51
+ * @param scopes - The list of scopes for which the token will have access.
52
+ * @param options - The options used to configure any requests this
53
+ * TokenCredential implementation might make.
54
+ */
55
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
56
+ /**
57
+ * Ensures the validity of the MSAL token
58
+ */
59
+ private ensureValidMsalToken;
60
+ }
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEtF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAc9E,OAAO,KAAK,EACV,wCAAwC,EACxC,wCAAwC,EACxC,0CAA0C,EAC3C,MAAM,cAAc,CAAC;AAItB;;;;;;;GAOG;AACH,qBAAa,yBAA0B,YAAW,eAAe;IAC/D,OAAO,CAAC,kBAAkB,CAA6B;IACvD,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,cAAc,CAIpB;IACF,OAAO,CAAC,yBAAyB,CAAiB;IAElD;;;;;;OAMG;gBACS,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB;IAC9D;;;;OAIG;gBACS,OAAO,CAAC,EAAE,wCAAwC;IAC9D;;;;OAIG;gBACS,OAAO,CAAC,EAAE,0CAA0C;IAChE;;;;OAIG;gBACS,OAAO,CAAC,EAAE,wCAAwC;IAwH9D;;;;;;;;OAQG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EACzB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,WAAW,CAAC;IAyGvB;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAuB7B"}
@@ -0,0 +1,239 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { getLogLevel } from "@azure/logger";
4
+ import { ManagedIdentityApplication } from "@azure/msal-node";
5
+ import { IdentityClient } from "../../client/identityClient.js";
6
+ import { AuthenticationRequiredError, CredentialUnavailableError } from "../../errors.js";
7
+ import { getMSALLogLevel, defaultLoggerCallback } from "../../msal/utils.js";
8
+ import { imdsRetryPolicy } from "./imdsRetryPolicy.js";
9
+ import { formatSuccess, formatError, credentialLogger } from "../../util/logging.js";
10
+ import { tracingClient } from "../../util/tracing.js";
11
+ import { imdsMsi } from "./imdsMsi.js";
12
+ import { tokenExchangeMsi } from "./tokenExchangeMsi.js";
13
+ import { mapScopesToResource, serviceFabricErrorMessage } from "./utils.js";
14
+ const logger = credentialLogger("ManagedIdentityCredential");
15
+ /**
16
+ * Attempts authentication using a managed identity available at the deployment environment.
17
+ * This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
18
+ * Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
19
+ *
20
+ * More information about configuring managed identities can be found here:
21
+ * https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
22
+ */
23
+ export class ManagedIdentityCredential {
24
+ /**
25
+ * @internal
26
+ * @hidden
27
+ */
28
+ constructor(clientIdOrOptions, options) {
29
+ var _a, _b;
30
+ this.msiRetryConfig = {
31
+ maxRetries: 5,
32
+ startDelayInMs: 800,
33
+ intervalIncrement: 2,
34
+ };
35
+ let _options;
36
+ if (typeof clientIdOrOptions === "string") {
37
+ this.clientId = clientIdOrOptions;
38
+ _options = options !== null && options !== void 0 ? options : {};
39
+ }
40
+ else {
41
+ this.clientId = clientIdOrOptions === null || clientIdOrOptions === void 0 ? void 0 : clientIdOrOptions.clientId;
42
+ _options = clientIdOrOptions !== null && clientIdOrOptions !== void 0 ? clientIdOrOptions : {};
43
+ }
44
+ this.resourceId = _options === null || _options === void 0 ? void 0 : _options.resourceId;
45
+ this.objectId = _options === null || _options === void 0 ? void 0 : _options.objectId;
46
+ // For JavaScript users.
47
+ const providedIds = [
48
+ { key: "clientId", value: this.clientId },
49
+ { key: "resourceId", value: this.resourceId },
50
+ { key: "objectId", value: this.objectId },
51
+ ].filter((id) => id.value);
52
+ if (providedIds.length > 1) {
53
+ throw new Error(`ManagedIdentityCredential: only one of 'clientId', 'resourceId', or 'objectId' can be provided. Received values: ${JSON.stringify({ clientId: this.clientId, resourceId: this.resourceId, objectId: this.objectId })}`);
54
+ }
55
+ // ManagedIdentity uses http for local requests
56
+ _options.allowInsecureConnection = true;
57
+ if (((_a = _options.retryOptions) === null || _a === void 0 ? void 0 : _a.maxRetries) !== undefined) {
58
+ this.msiRetryConfig.maxRetries = _options.retryOptions.maxRetries;
59
+ }
60
+ this.identityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { additionalPolicies: [{ policy: imdsRetryPolicy(this.msiRetryConfig), position: "perCall" }] }));
61
+ this.managedIdentityApp = new ManagedIdentityApplication({
62
+ managedIdentityIdParams: {
63
+ userAssignedClientId: this.clientId,
64
+ userAssignedResourceId: this.resourceId,
65
+ userAssignedObjectId: this.objectId,
66
+ },
67
+ system: {
68
+ disableInternalRetries: true,
69
+ networkClient: this.identityClient,
70
+ loggerOptions: {
71
+ logLevel: getMSALLogLevel(getLogLevel()),
72
+ piiLoggingEnabled: (_b = _options.loggingOptions) === null || _b === void 0 ? void 0 : _b.enableUnsafeSupportLogging,
73
+ loggerCallback: defaultLoggerCallback(logger),
74
+ },
75
+ },
76
+ });
77
+ this.isAvailableIdentityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { retryOptions: {
78
+ maxRetries: 0,
79
+ } }));
80
+ const managedIdentitySource = this.managedIdentityApp.getManagedIdentitySource();
81
+ // CloudShell MSI will ignore any user-assigned identity passed as parameters. To avoid confusion, we prevent this from happening as early as possible.
82
+ if (managedIdentitySource === "CloudShell") {
83
+ if (this.clientId || this.resourceId || this.objectId) {
84
+ logger.warning(`CloudShell MSI detected with user-provided IDs - throwing. Received values: ${JSON.stringify({
85
+ clientId: this.clientId,
86
+ resourceId: this.resourceId,
87
+ objectId: this.objectId,
88
+ })}.`);
89
+ throw new CredentialUnavailableError("ManagedIdentityCredential: Specifying a user-assigned managed identity is not supported for CloudShell at runtime. When using Managed Identity in CloudShell, omit the clientId, resourceId, and objectId parameters.");
90
+ }
91
+ }
92
+ // ServiceFabric does not support specifying user-assigned managed identity by client ID or resource ID. The managed identity selected is based on the resource configuration.
93
+ if (managedIdentitySource === "ServiceFabric") {
94
+ if (this.clientId || this.resourceId || this.objectId) {
95
+ logger.warning(`Service Fabric detected with user-provided IDs - throwing. Received values: ${JSON.stringify({
96
+ clientId: this.clientId,
97
+ resourceId: this.resourceId,
98
+ objectId: this.objectId,
99
+ })}.`);
100
+ throw new CredentialUnavailableError(`ManagedIdentityCredential: ${serviceFabricErrorMessage}`);
101
+ }
102
+ }
103
+ logger.info(`Using ${managedIdentitySource} managed identity.`);
104
+ // Check if either clientId, resourceId or objectId was provided and log the value used
105
+ if (providedIds.length === 1) {
106
+ const { key, value } = providedIds[0];
107
+ logger.info(`${managedIdentitySource} with ${key}: ${value}`);
108
+ }
109
+ }
110
+ /**
111
+ * Authenticates with Microsoft Entra ID and returns an access token if successful.
112
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
113
+ * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
114
+ *
115
+ * @param scopes - The list of scopes for which the token will have access.
116
+ * @param options - The options used to configure any requests this
117
+ * TokenCredential implementation might make.
118
+ */
119
+ async getToken(scopes, options = {}) {
120
+ logger.getToken.info("Using the MSAL provider for Managed Identity.");
121
+ const resource = mapScopesToResource(scopes);
122
+ if (!resource) {
123
+ throw new CredentialUnavailableError(`ManagedIdentityCredential: Multiple scopes are not supported. Scopes: ${JSON.stringify(scopes)}`);
124
+ }
125
+ return tracingClient.withSpan("ManagedIdentityCredential.getToken", options, async () => {
126
+ var _a;
127
+ try {
128
+ const isTokenExchangeMsi = await tokenExchangeMsi.isAvailable(this.clientId);
129
+ // Most scenarios are handled by MSAL except for two:
130
+ // AKS pod identity - MSAL does not implement the token exchange flow.
131
+ // IMDS Endpoint probing - MSAL does not do any probing before trying to get a token.
132
+ // As a DefaultAzureCredential optimization we probe the IMDS endpoint with a short timeout and no retries before actually trying to get a token
133
+ // We will continue to implement these features in the Identity library.
134
+ const identitySource = this.managedIdentityApp.getManagedIdentitySource();
135
+ const isImdsMsi = identitySource === "DefaultToImds" || identitySource === "Imds"; // Neither actually checks that IMDS endpoint is available, just that it's the source the MSAL _would_ try to use.
136
+ logger.getToken.info(`MSAL Identity source: ${identitySource}`);
137
+ if (isTokenExchangeMsi) {
138
+ // In the AKS scenario we will use the existing tokenExchangeMsi indefinitely.
139
+ logger.getToken.info("Using the token exchange managed identity.");
140
+ const result = await tokenExchangeMsi.getToken({
141
+ scopes,
142
+ clientId: this.clientId,
143
+ identityClient: this.identityClient,
144
+ retryConfig: this.msiRetryConfig,
145
+ resourceId: this.resourceId,
146
+ });
147
+ if (result === null) {
148
+ throw new CredentialUnavailableError("Attempted to use the token exchange managed identity, but received a null response.");
149
+ }
150
+ return result;
151
+ }
152
+ else if (isImdsMsi) {
153
+ // In the IMDS scenario we will probe the IMDS endpoint to ensure it's available before trying to get a token.
154
+ // If the IMDS endpoint is not available and this is the source that MSAL will use, we will fail-fast with an error that tells DAC to move to the next credential.
155
+ logger.getToken.info("Using the IMDS endpoint to probe for availability.");
156
+ const isAvailable = await imdsMsi.isAvailable({
157
+ scopes,
158
+ clientId: this.clientId,
159
+ getTokenOptions: options,
160
+ identityClient: this.isAvailableIdentityClient,
161
+ resourceId: this.resourceId,
162
+ });
163
+ if (!isAvailable) {
164
+ throw new CredentialUnavailableError(`Attempted to use the IMDS endpoint, but it is not available.`);
165
+ }
166
+ }
167
+ // If we got this far, it means:
168
+ // - This is not a tokenExchangeMsi,
169
+ // - We already probed for IMDS endpoint availability and failed-fast if it's unreachable.
170
+ // We can proceed normally by calling MSAL for a token.
171
+ logger.getToken.info("Calling into MSAL for managed identity token.");
172
+ const token = await this.managedIdentityApp.acquireToken({
173
+ resource,
174
+ });
175
+ this.ensureValidMsalToken(scopes, token, options);
176
+ logger.getToken.info(formatSuccess(scopes));
177
+ return {
178
+ expiresOnTimestamp: token.expiresOn.getTime(),
179
+ token: token.accessToken,
180
+ refreshAfterTimestamp: (_a = token.refreshOn) === null || _a === void 0 ? void 0 : _a.getTime(),
181
+ tokenType: "Bearer",
182
+ };
183
+ }
184
+ catch (err) {
185
+ logger.getToken.error(formatError(scopes, err));
186
+ // AuthenticationRequiredError described as Error to enforce authentication after trying to retrieve a token silently.
187
+ // TODO: why would this _ever_ happen considering we're not trying the silent request in this flow?
188
+ if (err.name === "AuthenticationRequiredError") {
189
+ throw err;
190
+ }
191
+ if (isNetworkError(err)) {
192
+ throw new CredentialUnavailableError(`ManagedIdentityCredential: Network unreachable. Message: ${err.message}`, { cause: err });
193
+ }
194
+ throw new CredentialUnavailableError(`ManagedIdentityCredential: Authentication failed. Message ${err.message}`, { cause: err });
195
+ }
196
+ });
197
+ }
198
+ /**
199
+ * Ensures the validity of the MSAL token
200
+ */
201
+ ensureValidMsalToken(scopes, msalToken, getTokenOptions) {
202
+ const createError = (message) => {
203
+ logger.getToken.info(message);
204
+ return new AuthenticationRequiredError({
205
+ scopes: Array.isArray(scopes) ? scopes : [scopes],
206
+ getTokenOptions,
207
+ message,
208
+ });
209
+ };
210
+ if (!msalToken) {
211
+ throw createError("No response.");
212
+ }
213
+ if (!msalToken.expiresOn) {
214
+ throw createError(`Response had no "expiresOn" property.`);
215
+ }
216
+ if (!msalToken.accessToken) {
217
+ throw createError(`Response had no "accessToken" property.`);
218
+ }
219
+ }
220
+ }
221
+ function isNetworkError(err) {
222
+ // MSAL error
223
+ if (err.errorCode === "network_error") {
224
+ return true;
225
+ }
226
+ // Probe errors
227
+ if (err.code === "ENETUNREACH" || err.code === "EHOSTUNREACH") {
228
+ return true;
229
+ }
230
+ // This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network" or "A socket operation was attempted to an unreachable host"
231
+ // rather than just timing out, as expected.
232
+ if (err.statusCode === 403 || err.code === 403) {
233
+ if (err.message.includes("unreachable")) {
234
+ return true;
235
+ }
236
+ }
237
+ return false;
238
+ }
239
+ //# sourceMappingURL=index.js.map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G,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;QAC/C,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\n\nimport type { TokenCredentialOptions } from \"../../tokenCredentialOptions.js\";\nimport { getLogLevel } from \"@azure/logger\";\nimport { ManagedIdentityApplication } from \"@azure/msal-node\";\nimport { IdentityClient } from \"../../client/identityClient.js\";\nimport { AuthenticationRequiredError, CredentialUnavailableError } from \"../../errors.js\";\nimport { getMSALLogLevel, defaultLoggerCallback } from \"../../msal/utils.js\";\nimport { imdsRetryPolicy } from \"./imdsRetryPolicy.js\";\nimport type { MSIConfiguration } from \"./models.js\";\nimport { formatSuccess, formatError, credentialLogger } from \"../../util/logging.js\";\nimport { tracingClient } from \"../../util/tracing.js\";\nimport { imdsMsi } from \"./imdsMsi.js\";\nimport { tokenExchangeMsi } from \"./tokenExchangeMsi.js\";\nimport { mapScopesToResource, serviceFabricErrorMessage } from \"./utils.js\";\nimport type { MsalToken, ValidMsalToken } from \"../../msal/types.js\";\nimport type {\n ManagedIdentityCredentialClientIdOptions,\n ManagedIdentityCredentialObjectIdOptions,\n ManagedIdentityCredentialResourceIdOptions,\n} from \"./options.js\";\n\nconst logger = credentialLogger(\"ManagedIdentityCredential\");\n\n/**\n * Attempts authentication using a managed identity available at the deployment environment.\n * This authentication type works in Azure VMs, App Service instances, Azure Functions applications,\n * Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.\n *\n * More information about configuring managed identities can be found here:\n * https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview\n */\nexport class ManagedIdentityCredential implements TokenCredential {\n private managedIdentityApp: ManagedIdentityApplication;\n private identityClient: IdentityClient;\n private clientId?: string;\n private resourceId?: string;\n private objectId?: string;\n private msiRetryConfig: MSIConfiguration[\"retryConfig\"] = {\n maxRetries: 5,\n startDelayInMs: 800,\n intervalIncrement: 2,\n };\n private isAvailableIdentityClient: IdentityClient;\n\n /**\n * Creates an instance of ManagedIdentityCredential with the client ID of a\n * user-assigned identity, or app registration (when working with AKS pod-identity).\n *\n * @param clientId - The client ID of the user-assigned identity, or app registration (when working with AKS pod-identity).\n * @param options - Options for configuring the client which makes the access token request.\n */\n constructor(clientId: string, options?: TokenCredentialOptions);\n /**\n * Creates an instance of ManagedIdentityCredential with a client ID\n *\n * @param options - Options for configuring the client which makes the access token request.\n */\n constructor(options?: ManagedIdentityCredentialClientIdOptions);\n /**\n * Creates an instance of ManagedIdentityCredential with a resource ID\n *\n * @param options - Options for configuring the resource which makes the access token request.\n */\n constructor(options?: ManagedIdentityCredentialResourceIdOptions);\n /**\n * Creates an instance of ManagedIdentityCredential with an object ID\n *\n * @param options - Options for configuring the resource which makes the access token request.\n */\n constructor(options?: ManagedIdentityCredentialObjectIdOptions);\n /**\n * @internal\n * @hidden\n */\n constructor(\n clientIdOrOptions?:\n | string\n | ManagedIdentityCredentialClientIdOptions\n | ManagedIdentityCredentialResourceIdOptions\n | ManagedIdentityCredentialObjectIdOptions,\n options?: TokenCredentialOptions,\n ) {\n let _options: TokenCredentialOptions;\n if (typeof clientIdOrOptions === \"string\") {\n this.clientId = clientIdOrOptions;\n _options = options ?? {};\n } else {\n this.clientId = (clientIdOrOptions as ManagedIdentityCredentialClientIdOptions)?.clientId;\n _options = clientIdOrOptions ?? {};\n }\n this.resourceId = (_options as ManagedIdentityCredentialResourceIdOptions)?.resourceId;\n this.objectId = (_options as ManagedIdentityCredentialObjectIdOptions)?.objectId;\n\n // For JavaScript users.\n const providedIds = [\n { key: \"clientId\", value: this.clientId },\n { key: \"resourceId\", value: this.resourceId },\n { key: \"objectId\", value: this.objectId },\n ].filter((id) => id.value);\n if (providedIds.length > 1) {\n throw new Error(\n `ManagedIdentityCredential: only one of 'clientId', 'resourceId', or 'objectId' can be provided. Received values: ${JSON.stringify(\n { clientId: this.clientId, resourceId: this.resourceId, objectId: this.objectId },\n )}`,\n );\n }\n\n // ManagedIdentity uses http for local requests\n _options.allowInsecureConnection = true;\n\n if (_options.retryOptions?.maxRetries !== undefined) {\n this.msiRetryConfig.maxRetries = _options.retryOptions.maxRetries;\n }\n\n this.identityClient = new IdentityClient({\n ..._options,\n additionalPolicies: [{ policy: imdsRetryPolicy(this.msiRetryConfig), position: \"perCall\" }],\n });\n\n this.managedIdentityApp = new ManagedIdentityApplication({\n managedIdentityIdParams: {\n userAssignedClientId: this.clientId,\n userAssignedResourceId: this.resourceId,\n userAssignedObjectId: this.objectId,\n },\n system: {\n disableInternalRetries: true,\n networkClient: this.identityClient,\n loggerOptions: {\n logLevel: getMSALLogLevel(getLogLevel()),\n piiLoggingEnabled: _options.loggingOptions?.enableUnsafeSupportLogging,\n loggerCallback: defaultLoggerCallback(logger),\n },\n },\n });\n\n this.isAvailableIdentityClient = new IdentityClient({\n ..._options,\n retryOptions: {\n maxRetries: 0,\n },\n });\n\n const managedIdentitySource = this.managedIdentityApp.getManagedIdentitySource();\n // CloudShell MSI will ignore any user-assigned identity passed as parameters. To avoid confusion, we prevent this from happening as early as possible.\n if (managedIdentitySource === \"CloudShell\") {\n if (this.clientId || this.resourceId || this.objectId) {\n logger.warning(\n `CloudShell MSI detected with user-provided IDs - throwing. Received values: ${JSON.stringify(\n {\n clientId: this.clientId,\n resourceId: this.resourceId,\n objectId: this.objectId,\n },\n )}.`,\n );\n throw new CredentialUnavailableError(\n \"ManagedIdentityCredential: Specifying a user-assigned managed identity is not supported for CloudShell at runtime. When using Managed Identity in CloudShell, omit the clientId, resourceId, and objectId parameters.\",\n );\n }\n }\n\n // ServiceFabric does not support specifying user-assigned managed identity by client ID or resource ID. The managed identity selected is based on the resource configuration.\n if (managedIdentitySource === \"ServiceFabric\") {\n if (this.clientId || this.resourceId || this.objectId) {\n logger.warning(\n `Service Fabric detected with user-provided IDs - throwing. Received values: ${JSON.stringify(\n {\n clientId: this.clientId,\n resourceId: this.resourceId,\n objectId: this.objectId,\n },\n )}.`,\n );\n throw new CredentialUnavailableError(\n `ManagedIdentityCredential: ${serviceFabricErrorMessage}`,\n );\n }\n }\n\n logger.info(`Using ${managedIdentitySource} managed identity.`);\n\n // Check if either clientId, resourceId or objectId was provided and log the value used\n if (providedIds.length === 1) {\n const { key, value } = providedIds[0];\n logger.info(`${managedIdentitySource} with ${key}: ${value}`);\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 * If an unexpected error occurs, an {@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 logger.getToken.info(\"Using the MSAL provider for Managed Identity.\");\n const resource = mapScopesToResource(scopes);\n if (!resource) {\n throw new CredentialUnavailableError(\n `ManagedIdentityCredential: Multiple scopes are not supported. Scopes: ${JSON.stringify(\n scopes,\n )}`,\n );\n }\n\n return tracingClient.withSpan(\"ManagedIdentityCredential.getToken\", options, async () => {\n try {\n const isTokenExchangeMsi = await tokenExchangeMsi.isAvailable(this.clientId);\n\n // Most scenarios are handled by MSAL except for two:\n // AKS pod identity - MSAL does not implement the token exchange flow.\n // IMDS Endpoint probing - MSAL does not do any probing before trying to get a token.\n // As a DefaultAzureCredential optimization we probe the IMDS endpoint with a short timeout and no retries before actually trying to get a token\n // We will continue to implement these features in the Identity library.\n\n const identitySource = this.managedIdentityApp.getManagedIdentitySource();\n const isImdsMsi = identitySource === \"DefaultToImds\" || identitySource === \"Imds\"; // Neither actually checks that IMDS endpoint is available, just that it's the source the MSAL _would_ try to use.\n\n logger.getToken.info(`MSAL Identity source: ${identitySource}`);\n\n if (isTokenExchangeMsi) {\n // In the AKS scenario we will use the existing tokenExchangeMsi indefinitely.\n logger.getToken.info(\"Using the token exchange managed identity.\");\n const result = await tokenExchangeMsi.getToken({\n scopes,\n clientId: this.clientId,\n identityClient: this.identityClient,\n retryConfig: this.msiRetryConfig,\n resourceId: this.resourceId,\n });\n\n if (result === null) {\n throw new CredentialUnavailableError(\n \"Attempted to use the token exchange managed identity, but received a null response.\",\n );\n }\n\n return result;\n } else if (isImdsMsi) {\n // In the IMDS scenario we will probe the IMDS endpoint to ensure it's available before trying to get a token.\n // If the IMDS endpoint is not available and this is the source that MSAL will use, we will fail-fast with an error that tells DAC to move to the next credential.\n logger.getToken.info(\"Using the IMDS endpoint to probe for availability.\");\n const isAvailable = await imdsMsi.isAvailable({\n scopes,\n clientId: this.clientId,\n getTokenOptions: options,\n identityClient: this.isAvailableIdentityClient,\n resourceId: this.resourceId,\n });\n\n if (!isAvailable) {\n throw new CredentialUnavailableError(\n `Attempted to use the IMDS endpoint, but it is not available.`,\n );\n }\n }\n\n // If we got this far, it means:\n // - This is not a tokenExchangeMsi,\n // - We already probed for IMDS endpoint availability and failed-fast if it's unreachable.\n // We can proceed normally by calling MSAL for a token.\n logger.getToken.info(\"Calling into MSAL for managed identity token.\");\n const token = await this.managedIdentityApp.acquireToken({\n resource,\n });\n\n this.ensureValidMsalToken(scopes, token, options);\n logger.getToken.info(formatSuccess(scopes));\n\n return {\n expiresOnTimestamp: token.expiresOn.getTime(),\n token: token.accessToken,\n refreshAfterTimestamp: token.refreshOn?.getTime(),\n tokenType: \"Bearer\",\n } as AccessToken;\n } catch (err: any) {\n logger.getToken.error(formatError(scopes, err));\n\n // AuthenticationRequiredError described as Error to enforce authentication after trying to retrieve a token silently.\n // TODO: why would this _ever_ happen considering we're not trying the silent request in this flow?\n if (err.name === \"AuthenticationRequiredError\") {\n throw err;\n }\n\n if (isNetworkError(err)) {\n throw new CredentialUnavailableError(\n `ManagedIdentityCredential: Network unreachable. Message: ${err.message}`,\n { cause: err },\n );\n }\n\n throw new CredentialUnavailableError(\n `ManagedIdentityCredential: Authentication failed. Message ${err.message}`,\n { cause: err },\n );\n }\n });\n }\n\n /**\n * Ensures the validity of the MSAL token\n */\n private ensureValidMsalToken(\n scopes: string | string[],\n msalToken?: MsalToken,\n getTokenOptions?: GetTokenOptions,\n ): asserts msalToken is ValidMsalToken {\n const createError = (message: string): Error => {\n logger.getToken.info(message);\n return new AuthenticationRequiredError({\n scopes: Array.isArray(scopes) ? scopes : [scopes],\n getTokenOptions,\n message,\n });\n };\n if (!msalToken) {\n throw createError(\"No response.\");\n }\n if (!msalToken.expiresOn) {\n throw createError(`Response had no \"expiresOn\" property.`);\n }\n if (!msalToken.accessToken) {\n throw createError(`Response had no \"accessToken\" property.`);\n }\n }\n}\n\nfunction isNetworkError(err: any): boolean {\n // MSAL error\n if (err.errorCode === \"network_error\") {\n return true;\n }\n\n // Probe errors\n if (err.code === \"ENETUNREACH\" || err.code === \"EHOSTUNREACH\") {\n return true;\n }\n\n // This is a special case for Docker Desktop which responds with a 403 with a message that contains \"A socket operation was attempted to an unreachable network\" or \"A socket operation was attempted to an unreachable host\"\n // rather than just timing out, as expected.\n if (err.statusCode === 403 || err.code === 403) {\n if (err.message.includes(\"unreachable\")) {\n return true;\n }\n }\n\n return false;\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { AccessToken } from "@azure/core-auth";
2
+ import type { IdentityClient } from "../../client/identityClient.js";
3
+ /**
4
+ * @internal
5
+ */
6
+ export interface MSIConfiguration {
7
+ retryConfig: {
8
+ maxRetries: number;
9
+ startDelayInMs: number;
10
+ intervalIncrement: number;
11
+ };
12
+ identityClient: IdentityClient;
13
+ scopes: string | string[];
14
+ clientId?: string;
15
+ resourceId?: string;
16
+ }
17
+ /**
18
+ * @internal
19
+ * Represents an access token for {@link ManagedIdentity} for internal usage,
20
+ * with an expiration time and the time in which token should refresh.
21
+ */
22
+ export declare interface MSIToken extends AccessToken {
23
+ }
24
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/models.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,WAAW,QAAS,SAAQ,WAAW;CAAG"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AccessToken } from \"@azure/core-auth\";\n\nimport type { IdentityClient } from \"../../client/identityClient.js\";\n\n/**\n * @internal\n */\nexport interface MSIConfiguration {\n retryConfig: {\n maxRetries: number;\n startDelayInMs: number;\n intervalIncrement: number;\n };\n identityClient: IdentityClient;\n scopes: string | string[];\n clientId?: string;\n resourceId?: string;\n}\n\n/**\n * @internal\n * Represents an access token for {@link ManagedIdentity} for internal usage,\n * with an expiration time and the time in which token should refresh.\n */\nexport declare interface MSIToken extends AccessToken {}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { TokenCredentialOptions } from "../../tokenCredentialOptions.js";
2
+ /**
3
+ * Options to send on the {@link ManagedIdentityCredential} constructor.
4
+ * This variation supports `clientId` and not `resourceId`, since only one of both is supported.
5
+ */
6
+ export interface ManagedIdentityCredentialClientIdOptions extends TokenCredentialOptions {
7
+ /**
8
+ * The client ID of the user - assigned identity, or app registration(when working with AKS pod - identity).
9
+ */
10
+ clientId?: string;
11
+ }
12
+ /**
13
+ * Options to send on the {@link ManagedIdentityCredential} constructor.
14
+ * This variation supports `resourceId` and not `clientId`, since only one of both is supported.
15
+ */
16
+ export interface ManagedIdentityCredentialResourceIdOptions extends TokenCredentialOptions {
17
+ /**
18
+ * Allows specifying a custom resource Id.
19
+ * In scenarios such as when user assigned identities are created using an ARM template,
20
+ * where the resource Id of the identity is known but the client Id can't be known ahead of time,
21
+ * this parameter allows programs to use these user assigned identities
22
+ * without having to first determine the client Id of the created identity.
23
+ */
24
+ resourceId: string;
25
+ }
26
+ /**
27
+ * Options to send on the {@link ManagedIdentityCredential} constructor.
28
+ * This variation supports `objectId` as a constructor argument.
29
+ */
30
+ export interface ManagedIdentityCredentialObjectIdOptions extends TokenCredentialOptions {
31
+ /**
32
+ * Allows specifying the object ID of the underlying service principal used to authenticate a user-assigned managed identity.
33
+ * This is an alternative to providing a client ID or resource ID and is not required for system-assigned managed identities.
34
+ */
35
+ objectId: string;
36
+ }
37
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/options.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;;GAGG;AACH,MAAM,WAAW,wCAAyC,SAAQ,sBAAsB;IACtF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,0CAA2C,SAAQ,sBAAsB;IACxF;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,wCAAyC,SAAQ,sBAAsB;IACtF;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
4
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/credentials/managedIdentityCredential/options.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { TokenCredentialOptions } from \"../../tokenCredentialOptions.js\";\n\n/**\n * Options to send on the {@link ManagedIdentityCredential} constructor.\n * This variation supports `clientId` and not `resourceId`, since only one of both is supported.\n */\nexport interface ManagedIdentityCredentialClientIdOptions extends TokenCredentialOptions {\n /**\n * The client ID of the user - assigned identity, or app registration(when working with AKS pod - identity).\n */\n clientId?: string;\n}\n\n/**\n * Options to send on the {@link ManagedIdentityCredential} constructor.\n * This variation supports `resourceId` and not `clientId`, since only one of both is supported.\n */\nexport interface ManagedIdentityCredentialResourceIdOptions extends TokenCredentialOptions {\n /**\n * Allows specifying a custom resource Id.\n * In scenarios such as when user assigned identities are created using an ARM template,\n * where the resource Id of the identity is known but the client Id can't be known ahead of time,\n * this parameter allows programs to use these user assigned identities\n * without having to first determine the client Id of the created identity.\n */\n resourceId: string;\n}\n\n/**\n * Options to send on the {@link ManagedIdentityCredential} constructor.\n * This variation supports `objectId` as a constructor argument.\n */\nexport interface ManagedIdentityCredentialObjectIdOptions extends TokenCredentialOptions {\n /**\n * Allows specifying the object ID of the underlying service principal used to authenticate a user-assigned managed identity.\n * This is an alternative to providing a client ID or resource ID and is not required for system-assigned managed identities.\n */\n objectId: string;\n}\n"]}