@azure/identity 4.5.0-beta.2 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. package/README.md +65 -74
  2. package/dist/index.js +190 -81
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/client/identityClient.js +4 -2
  5. package/dist-esm/src/client/identityClient.js.map +1 -1
  6. package/dist-esm/src/constants.js +2 -2
  7. package/dist-esm/src/constants.js.map +1 -1
  8. package/dist-esm/src/credentials/authorityValidationOptions.js +1 -1
  9. package/dist-esm/src/credentials/authorityValidationOptions.js.map +1 -1
  10. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js +1 -1
  11. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
  12. package/dist-esm/src/credentials/authorizationCodeCredential.js +1 -1
  13. package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
  14. package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js +1 -1
  15. package/dist-esm/src/credentials/authorizationCodeCredentialOptions.js.map +1 -1
  16. package/dist-esm/src/credentials/azureApplicationCredential.browser.js +1 -1
  17. package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -1
  18. package/dist-esm/src/credentials/azureApplicationCredential.js +1 -1
  19. package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -1
  20. package/dist-esm/src/credentials/azureApplicationCredentialOptions.js +1 -1
  21. package/dist-esm/src/credentials/azureApplicationCredentialOptions.js.map +1 -1
  22. package/dist-esm/src/credentials/azureCliCredential.browser.js +1 -1
  23. package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
  24. package/dist-esm/src/credentials/azureCliCredential.js +3 -1
  25. package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
  26. package/dist-esm/src/credentials/azureCliCredentialOptions.js +1 -1
  27. package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -1
  28. package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js +1 -1
  29. package/dist-esm/src/credentials/azureDeveloperCliCredential.browser.js.map +1 -1
  30. package/dist-esm/src/credentials/azureDeveloperCliCredential.js +2 -1
  31. package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
  32. package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js +1 -1
  33. package/dist-esm/src/credentials/azureDeveloperCliCredentialOptions.js.map +1 -1
  34. package/dist-esm/src/credentials/azurePipelinesCredential.browser.js +1 -1
  35. package/dist-esm/src/credentials/azurePipelinesCredential.browser.js.map +1 -1
  36. package/dist-esm/src/credentials/azurePipelinesCredential.js +16 -5
  37. package/dist-esm/src/credentials/azurePipelinesCredential.js.map +1 -1
  38. package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js +1 -1
  39. package/dist-esm/src/credentials/azurePipelinesCredentialOptions.js.map +1 -1
  40. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +1 -1
  41. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -1
  42. package/dist-esm/src/credentials/azurePowerShellCredential.js +2 -1
  43. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
  44. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js +1 -1
  45. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -1
  46. package/dist-esm/src/credentials/brokerAuthOptions.js.map +1 -1
  47. package/dist-esm/src/credentials/browserCustomizationOptions.js +1 -1
  48. package/dist-esm/src/credentials/browserCustomizationOptions.js.map +1 -1
  49. package/dist-esm/src/credentials/chainedTokenCredential.js +9 -2
  50. package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
  51. package/dist-esm/src/credentials/clientAssertionCredential.browser.js +1 -1
  52. package/dist-esm/src/credentials/clientAssertionCredential.browser.js.map +1 -1
  53. package/dist-esm/src/credentials/clientAssertionCredential.js +1 -1
  54. package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
  55. package/dist-esm/src/credentials/clientAssertionCredentialOptions.js +1 -1
  56. package/dist-esm/src/credentials/clientAssertionCredentialOptions.js.map +1 -1
  57. package/dist-esm/src/credentials/clientCertificateCredential.browser.js +1 -1
  58. package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
  59. package/dist-esm/src/credentials/clientCertificateCredential.js +1 -1
  60. package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
  61. package/dist-esm/src/credentials/clientCertificateCredentialOptions.js +1 -1
  62. package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
  63. package/dist-esm/src/credentials/clientSecretCredential.browser.js +1 -1
  64. package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
  65. package/dist-esm/src/credentials/clientSecretCredential.js +1 -1
  66. package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
  67. package/dist-esm/src/credentials/clientSecretCredentialOptions.js +1 -1
  68. package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
  69. package/dist-esm/src/credentials/credentialPersistenceOptions.js +1 -1
  70. package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -1
  71. package/dist-esm/src/credentials/defaultAzureCredential.browser.js +1 -1
  72. package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
  73. package/dist-esm/src/credentials/defaultAzureCredential.js +1 -1
  74. package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
  75. package/dist-esm/src/credentials/defaultAzureCredentialOptions.js +1 -1
  76. package/dist-esm/src/credentials/defaultAzureCredentialOptions.js.map +1 -1
  77. package/dist-esm/src/credentials/deviceCodeCredential.browser.js +1 -1
  78. package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
  79. package/dist-esm/src/credentials/deviceCodeCredential.js +7 -5
  80. package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
  81. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js +1 -1
  82. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
  83. package/dist-esm/src/credentials/environmentCredential.browser.js +1 -1
  84. package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
  85. package/dist-esm/src/credentials/environmentCredential.js +1 -1
  86. package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
  87. package/dist-esm/src/credentials/environmentCredentialOptions.js +1 -1
  88. package/dist-esm/src/credentials/environmentCredentialOptions.js.map +1 -1
  89. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +1 -1
  90. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
  91. package/dist-esm/src/credentials/interactiveBrowserCredential.js +1 -1
  92. package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
  93. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js +1 -1
  94. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
  95. package/dist-esm/src/credentials/interactiveCredentialOptions.js +1 -1
  96. package/dist-esm/src/credentials/interactiveCredentialOptions.js.map +1 -1
  97. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +1 -1
  98. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
  99. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js +1 -1
  100. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2019.js.map +1 -1
  101. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +1 -1
  102. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
  103. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +1 -1
  104. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
  105. package/dist-esm/src/credentials/managedIdentityCredential/constants.js +1 -1
  106. package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +1 -1
  107. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +1 -1
  108. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
  109. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +1 -1
  110. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  111. package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js +6 -10
  112. package/dist-esm/src/credentials/managedIdentityCredential/imdsRetryPolicy.js.map +1 -1
  113. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js +1 -1
  114. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +1 -1
  115. package/dist-esm/src/credentials/managedIdentityCredential/index.js +1 -1
  116. package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
  117. package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js +8 -1
  118. package/dist-esm/src/credentials/managedIdentityCredential/legacyMsiProvider.js.map +1 -1
  119. package/dist-esm/src/credentials/managedIdentityCredential/models.js +1 -1
  120. package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
  121. package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js +21 -4
  122. package/dist-esm/src/credentials/managedIdentityCredential/msalMsiProvider.js.map +1 -1
  123. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +1 -1
  124. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
  125. package/dist-esm/src/credentials/managedIdentityCredential/utils.js +26 -1
  126. package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
  127. package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js +1 -1
  128. package/dist-esm/src/credentials/multiTenantTokenCredentialOptions.js.map +1 -1
  129. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +1 -1
  130. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -1
  131. package/dist-esm/src/credentials/onBehalfOfCredential.js +1 -1
  132. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
  133. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js +1 -1
  134. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
  135. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +1 -1
  136. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
  137. package/dist-esm/src/credentials/usernamePasswordCredential.js +1 -1
  138. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
  139. package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js +1 -1
  140. package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
  141. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +1 -1
  142. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -1
  143. package/dist-esm/src/credentials/visualStudioCodeCredential.js +1 -1
  144. package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
  145. package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js +1 -1
  146. package/dist-esm/src/credentials/visualStudioCodeCredentialOptions.js.map +1 -1
  147. package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js +1 -1
  148. package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js.map +1 -1
  149. package/dist-esm/src/credentials/workloadIdentityCredential.browser.js +1 -1
  150. package/dist-esm/src/credentials/workloadIdentityCredential.browser.js.map +1 -1
  151. package/dist-esm/src/credentials/workloadIdentityCredential.js +1 -1
  152. package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
  153. package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js +1 -1
  154. package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js.map +1 -1
  155. package/dist-esm/src/errors.js +1 -2
  156. package/dist-esm/src/errors.js.map +1 -1
  157. package/dist-esm/src/index.js +1 -1
  158. package/dist-esm/src/index.js.map +1 -1
  159. package/dist-esm/src/msal/browserFlows/flows.js +1 -1
  160. package/dist-esm/src/msal/browserFlows/flows.js.map +1 -1
  161. package/dist-esm/src/msal/browserFlows/msalAuthCode.js +2 -2
  162. package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
  163. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +4 -1
  164. package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
  165. package/dist-esm/src/msal/credentials.js +1 -1
  166. package/dist-esm/src/msal/credentials.js.map +1 -1
  167. package/dist-esm/src/msal/msal.browser.js +1 -1
  168. package/dist-esm/src/msal/msal.browser.js.map +1 -1
  169. package/dist-esm/src/msal/msal.js +1 -1
  170. package/dist-esm/src/msal/msal.js.map +1 -1
  171. package/dist-esm/src/msal/nodeFlows/brokerOptions.js.map +1 -1
  172. package/dist-esm/src/msal/nodeFlows/msalClient.js +42 -8
  173. package/dist-esm/src/msal/nodeFlows/msalClient.js.map +1 -1
  174. package/dist-esm/src/msal/nodeFlows/msalPlugins.js +1 -1
  175. package/dist-esm/src/msal/nodeFlows/msalPlugins.js.map +1 -1
  176. package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js +1 -1
  177. package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -1
  178. package/dist-esm/src/msal/types.js +1 -1
  179. package/dist-esm/src/msal/types.js.map +1 -1
  180. package/dist-esm/src/msal/utils.js +17 -3
  181. package/dist-esm/src/msal/utils.js.map +1 -1
  182. package/dist-esm/src/plugins/consumer.browser.js +1 -1
  183. package/dist-esm/src/plugins/consumer.browser.js.map +1 -1
  184. package/dist-esm/src/plugins/consumer.js +7 -9
  185. package/dist-esm/src/plugins/consumer.js.map +1 -1
  186. package/dist-esm/src/plugins/provider.js +1 -1
  187. package/dist-esm/src/plugins/provider.js.map +1 -1
  188. package/dist-esm/src/regionalAuthority.js +1 -1
  189. package/dist-esm/src/regionalAuthority.js.map +1 -1
  190. package/dist-esm/src/tokenCredentialOptions.js +1 -1
  191. package/dist-esm/src/tokenCredentialOptions.js.map +1 -1
  192. package/dist-esm/src/tokenProvider.js +4 -4
  193. package/dist-esm/src/tokenProvider.js.map +1 -1
  194. package/dist-esm/src/util/authHostEnv.browser.js +1 -1
  195. package/dist-esm/src/util/authHostEnv.browser.js.map +1 -1
  196. package/dist-esm/src/util/identityTokenEndpoint.js +1 -1
  197. package/dist-esm/src/util/identityTokenEndpoint.js.map +1 -1
  198. package/dist-esm/src/util/logging.js +1 -1
  199. package/dist-esm/src/util/logging.js.map +1 -1
  200. package/dist-esm/src/util/processMultiTenantRequest.browser.js +1 -1
  201. package/dist-esm/src/util/processMultiTenantRequest.browser.js.map +1 -1
  202. package/dist-esm/src/util/processMultiTenantRequest.js +1 -1
  203. package/dist-esm/src/util/processMultiTenantRequest.js.map +1 -1
  204. package/dist-esm/src/util/processUtils.js +1 -1
  205. package/dist-esm/src/util/processUtils.js.map +1 -1
  206. package/dist-esm/src/util/scopeUtils.js +1 -1
  207. package/dist-esm/src/util/scopeUtils.js.map +1 -1
  208. package/dist-esm/src/util/tenantIdUtils.js +1 -1
  209. package/dist-esm/src/util/tenantIdUtils.js.map +1 -1
  210. package/dist-esm/src/util/tracing.js +1 -1
  211. package/dist-esm/src/util/tracing.js.map +1 -1
  212. package/package.json +20 -19
  213. package/types/identity.d.ts +74 -50
package/README.md CHANGED
@@ -17,11 +17,10 @@ Key links:
17
17
  ### Currently supported environments
18
18
 
19
19
  - [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
20
- - **Note:** If your application runs on Node.js v8 or lower and you cannot upgrade your Node.js version to latest stable version, then pin your `@azure/identity` dependency to version 1.1.0.
21
20
  - Latest versions of Safari, Chrome, Edge, and Firefox.
22
- - **Note**: Among the different credentials exported in this library, `InteractiveBrowserCredential` is the only one that is supported in the browser.
21
+ - **Note**: Among the different credentials exported in this library, `InteractiveBrowserCredential` is the only one supported in the browser.
23
22
 
24
- See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
23
+ For more information, see our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md).
25
24
 
26
25
  ### Install the package
27
26
 
@@ -46,9 +45,14 @@ Most of the credential types offered by `@azure/identity` use the [Microsoft Aut
46
45
 
47
46
  #### When to use something else
48
47
 
49
- The `@azure/identity` credential types are implementations of [@azure/core-auth](https://www.npmjs.com/package/@azure/core-auth)'s `TokenCredential` class. In principle, any object with a `getToken` method that satisfies `getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>` will work as a `TokenCredential`. This means developers can write their own credential types to support authentication cases not covered by `@azure/identity`. To learn more, see [Custom Credentials](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#custom-credentials).
48
+ The `@azure/identity` credential types are implementations of [@azure/core-auth](https://www.npmjs.com/package/@azure/core-auth)'s `TokenCredential` class. In principle, any object with a `getToken` method that satisfies `getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>` works as a `TokenCredential`. This means developers can write their own credential types to support authentication cases not covered by `@azure/identity`. To learn more, see [Custom Credentials](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#custom-credentials).
50
49
 
51
- Though our credential types support many advanced cases, developers may want full control of the authentication protocol. For that use case, we recommend using [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) directly. You can read more through the following links:
50
+ Though our credential types support many advanced scenarios, developers may want to use [Microsoft Authentication Library for JavaScript (MSAL.js)](https://github.com/AzureAD/microsoft-authentication-library-for-js) directly instead. Consider using MSAL.js in the following scenarios:
51
+
52
+ - Developers who want full control of the authentication protocol and its configuration.
53
+ - Our credential types are designed to be used with Azure SDK clients with intelligent caching and token refreshing handled at the core HTTP layer. If you find yourself having to use `getToken` directly, you may benefit from using MSAL.js for more control over the authentication flow and token caching.
54
+
55
+ You can read more through the following links:
52
56
 
53
57
  - We portray some advanced use cases of `@azure/identity` on the [Azure Identity Examples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md) page.
54
58
  - There, we specifically have an [Advanced Examples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#advanced-examples) section.
@@ -58,25 +62,25 @@ For advanced authentication workflows in the browser, we have a section where we
58
62
 
59
63
  ### Authenticate the client in development environment
60
64
 
61
- While we recommend using managed identity in your Azure-hosted application, it is typical for a developer to use their own account for authenticating calls to Azure services when debugging and executing code locally. There are several developer tools which can be used to perform this authentication in your development environment.
65
+ While we recommend using managed identity in your Azure-hosted application, it's typical for a developer to use their own account for authenticating calls to Azure services when debugging and executing code locally. There are several developer tools that can be used to perform this authentication in your development environment.
62
66
 
63
67
  #### Authenticate via the Azure Developer CLI
64
68
 
65
69
  Developers coding outside of an IDE can also use the [Azure Developer CLI][azure_developer_cli] to authenticate. Applications using the `DefaultAzureCredential` or the `AzureDeveloperCliCredential` can then use this account to authenticate calls in their application when running locally.
66
70
 
67
- To authenticate with the [Azure Developer CLI][azure_developer_cli], users can run the command `azd auth login`. For users running on a system with a default web browser, the Azure Developer CLI will launch the browser to authenticate the user.
71
+ To authenticate with the [Azure Developer CLI][azure_developer_cli], users can run the command `azd auth login`. For users running on a system with a default web browser, the Azure Developer CLI launches the browser to authenticate the user.
68
72
 
69
- For systems without a default web browser, the `azd auth login --use-device-code` command will use the device code authentication flow.
73
+ For systems without a default web browser, the `azd auth login --use-device-code` command uses the device code authentication flow.
70
74
 
71
75
  #### Authenticate via the Azure CLI
72
76
 
73
77
  Applications using the `AzureCliCredential`, whether directly or via the `DefaultAzureCredential`, can use the Azure CLI account to authenticate calls in the application when running locally.
74
78
 
75
- To authenticate with the [Azure CLI][azure_cli] users can run the command `az login`. For users running on a system with a default web browser the Azure cli will launch the browser to authenticate the user.
79
+ To authenticate with the [Azure CLI][azure_cli], run the command `az login`. For users running on a system with a default web browser, the Azure CLI launches the browser to authenticate the user.
76
80
 
77
81
  ![Azure CLI Account Sign In][azureclilogin_image]
78
82
 
79
- For systems without a default web browser, the `az login` command will use the device code authentication flow. The user can also force the Azure CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
83
+ For systems without a default web browser, the `az login` command uses the device code authentication flow. The user can also force the Azure CLI to use the device code flow rather than launching a browser by specifying the `--use-device-code` argument.
80
84
 
81
85
  ![Azure CLI Account Device Code Sign In][azureclilogindevicecode_image]
82
86
 
@@ -84,11 +88,11 @@ For systems without a default web browser, the `az login` command will use the d
84
88
 
85
89
  Applications using the `AzurePowerShellCredential`, whether directly or via the `DefaultAzureCredential`, can use the account connected to Azure PowerShell to authenticate calls in the application when running locally.
86
90
 
87
- To authenticate with [Azure PowerShell][azure_powershell] users can run the `Connect-AzAccount` cmdlet. By default, like the Azure CLI, `Connect-AzAccount` will launch the default web browser to authenticate a user account.
91
+ To authenticate with [Azure PowerShell][azure_powershell], run the `Connect-AzAccount` cmdlet. By default, like the Azure CLI, `Connect-AzAccount` launches the default web browser to authenticate a user account.
88
92
 
89
93
  ![Azure PowerShell Account Sign In][azurepowershelllogin_image]
90
94
 
91
- If interactive authentication cannot be supported in the session, then the `-UseDeviceAuthentication` argument will force the cmdlet to use a device code authentication flow instead, similar to the corresponding option in the Azure CLI credential.
95
+ If interactive authentication can't be supported in the session, then the `-UseDeviceAuthentication` argument forces the cmdlet to use a device code authentication flow instead, similar to the corresponding option in the Azure CLI credential.
92
96
 
93
97
  #### Authenticate via Visual Studio Code
94
98
 
@@ -110,32 +114,19 @@ If this is your first time using `@azure/identity` or Microsoft Entra ID, read [
110
114
 
111
115
  ### Credentials
112
116
 
113
- A credential is a class which contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept credentials when they're constructed. Service clients use those credentials to authenticate requests to the service.
117
+ A credential is a class that contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept credentials when they're constructed. Service clients use those credentials to authenticate requests to the service.
114
118
 
115
- The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers a variety of credential classes capable of acquiring a Microsoft Entra token to authenticate service requests. All of the credential classes in this library are implementations of the [TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-auth/src/tokenCredential.ts) abstract class, and any of them can be used by to construct service clients capable of authenticating with a TokenCredential.
119
+ The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers various credential classes capable of acquiring a Microsoft Entra token to authenticate service requests. All of the credential classes in this library are implementations of the [TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-auth/src/tokenCredential.ts) abstract class, and any of them can be used by to construct service clients capable of authenticating with a `TokenCredential`.
116
120
 
117
121
  See [Credential Classes](#credential-classes).
118
122
 
119
123
  ### DefaultAzureCredential
120
124
 
121
- The `DefaultAzureCredential` is appropriate for most scenarios where the application is intended to ultimately be run in Azure. This is because the `DefaultAzureCredential` combines credentials commonly used to authenticate when deployed with credentials used to authenticate in a development environment.
122
-
123
- > Note: `DefaultAzureCredential` is intended to simplify getting started with the SDK by handling common scenarios with reasonable default behaviors. Developers who want more control or whose scenario isn't served by the default settings should use other credential types.
124
-
125
- If used from Node.js, the `DefaultAzureCredential` will attempt to authenticate via the following mechanisms in order:
126
-
127
- ![DefaultAzureCredential authentication flow][defaultauthflow_image]
128
-
129
- 1. **Environment** - The `DefaultAzureCredential` will read account information specified via [environment variables](#environment-variables) and use it to authenticate.
130
- 1. **Workload Identity** - If the application is deployed to Azure Kubernetes Service with Managed Identity enabled, `DefaultAzureCredential` will authenticate with it.
131
- 1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled, the `DefaultAzureCredential` will authenticate with that account.
132
- 1. **Azure CLI** - If the developer has authenticated an account via the Azure CLI `az login` command, the `DefaultAzureCredential` will authenticate with that account.
133
- 1. **Azure PowerShell** - If the developer has authenticated using the Azure PowerShell module `Connect-AzAccount` command, the `DefaultAzureCredential` will authenticate with that account.
134
- 1. **Azure Developer CLI** - If the developer has authenticated an account via the Azure Developer CLI `azd auth login` command, the `DefaultAzureCredential` will authenticate with that account.
125
+ `DefaultAzureCredential` simplifies authentication while developing apps that deploy to Azure by combining credentials used in Azure hosting environments with credentials used in local development. For more information, see [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-defaultazurecredential-for-flexibility).
135
126
 
136
127
  #### Continuation policy
137
128
 
138
- As of version 3.3.0, `DefaultAzureCredential` will attempt to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so `DefaultAzureCredential` will continue to the next credential in the flow. Deployed service credentials will stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one.
129
+ As of version 3.3.0, `DefaultAzureCredential` attempts to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so `DefaultAzureCredential` continues to the next credential in the flow. Deployed service credentials stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one.
139
130
 
140
131
  This allows for trying all of the developer credentials on your machine while having predictable deployed behavior.
141
132
 
@@ -148,52 +139,53 @@ Due to a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500),
148
139
  Azure Identity for JavaScript provides a plugin API that allows us to provide certain functionality through separate _plugin packages_. The `@azure/identity` package exports a top-level function (`useIdentityPlugin`) that can be used to enable a plugin. We provide two plugin packages:
149
140
 
150
141
  - [`@azure/identity-broker`](https://www.npmjs.com/package/@azure/identity-broker), which provides brokered authentication support through a native broker, such as Web Account Manager.
151
- - [`@azure/identity-cache-persistence`](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching in Node.js using a native secure storage system provided by your operating system. This plugin allows cached `access_token` values to persist across sessions, meaning that an interactive login flow does not need to be repeated as long as a cached token is available.
142
+ - [`@azure/identity-cache-persistence`](https://www.npmjs.com/package/@azure/identity-cache-persistence), which provides persistent token caching in Node.js using a native secure storage system provided by your operating system. This plugin allows cached `access_token` values to persist across sessions, meaning that an interactive login flow doesn't need to be repeated as long as a cached token is available.
152
143
 
153
144
  ## Examples
154
145
 
155
146
  You can find more examples of using various credentials in [Azure Identity Examples Page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md)
156
147
 
157
- ### Authenticate with the `DefaultAzureCredential`
148
+ ### Authenticate with `DefaultAzureCredential`
158
149
 
159
- This example demonstrates authenticating the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) client library using the `DefaultAzureCredential`.
150
+ This example demonstrates authenticating the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys) client library using `DefaultAzureCredential`.
160
151
 
161
- ```javascript
162
- // The default credential first checks environment variables for configuration as described above.
163
- // If environment configuration is incomplete, it will try managed identity.
164
-
165
- // Azure Key Vault service to use
166
- import { KeyClient } from "@azure/keyvault-keys";
167
-
168
- // Azure authentication library to access Azure Key Vault
152
+ ```ts snippet:defaultazurecredential_authenticate
169
153
  import { DefaultAzureCredential } from "@azure/identity";
154
+ import { KeyClient } from "@azure/keyvault-keys";
170
155
 
156
+ // Configure vault URL
157
+ const vaultUrl = "https://<your-unique-keyvault-name>.vault.azure.net";
171
158
  // Azure SDK clients accept the credential as a parameter
172
159
  const credential = new DefaultAzureCredential();
173
-
174
160
  // Create authenticated client
175
161
  const client = new KeyClient(vaultUrl, credential);
176
162
  ```
177
163
 
178
- ### Specify a user-assigned managed identity with the `DefaultAzureCredential`
164
+ ### Specify a user-assigned managed identity with `DefaultAzureCredential`
179
165
 
180
166
  A relatively common scenario involves authenticating using a user-assigned managed identity for an Azure resource. Explore the [example on Authenticating a user-assigned managed identity with DefaultAzureCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-user-assigned-managed-identity-with-defaultazurecredential) to see how this is made a relatively straightforward task that can be configured using environment variables or in code.
181
167
 
182
- ### Define a custom authentication flow with the `ChainedTokenCredential`
168
+ ### Define a custom authentication flow with `ChainedTokenCredential`
183
169
 
184
- While the `DefaultAzureCredential` is generally the quickest way to get started developing applications for Azure, more advanced users may want to customize the credentials considered when authenticating. The `ChainedTokenCredential` enables users to combine multiple credential instances to define a customized chain of credentials. This example demonstrates creating a `ChainedTokenCredential` which will attempt to authenticate using two differently configured instances of `ClientSecretCredential`, to then authenticate the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys):
170
+ While `DefaultAzureCredential` is generally the quickest way to get started developing applications for Azure, more advanced users may want to customize the credentials considered when authenticating. The `ChainedTokenCredential` enables users to combine multiple credential instances to define a customized chain of credentials. This example demonstrates creating a `ChainedTokenCredential` that attempts to authenticate using two differently configured instances of `ClientSecretCredential`, to then authenticate the `KeyClient` from the [@azure/keyvault-keys](https://www.npmjs.com/package/@azure/keyvault-keys):
185
171
 
186
- ```typescript
172
+ ```ts snippet:chaintedtokencredential_authenticate
187
173
  import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";
174
+ import { KeyClient } from "@azure/keyvault-keys";
188
175
 
176
+ // Configure variables
177
+ const vaultUrl = "https://<your-unique-keyvault-name>.vault.azure.net";
178
+ const tenantId = "<tenant-id>";
179
+ const clientId = "<client-id>";
180
+ const clientSecret = "<client-secret>";
181
+ const anotherClientId = "<another-client-id>";
182
+ const anotherSecret = "<another-client-secret>";
189
183
  // When an access token is requested, the chain will try each
190
184
  // credential in order, stopping when one provides a token
191
185
  const firstCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
192
186
  const secondCredential = new ClientSecretCredential(tenantId, anotherClientId, anotherSecret);
193
187
  const credentialChain = new ChainedTokenCredential(firstCredential, secondCredential);
194
-
195
188
  // The chain can be used anywhere a credential is required
196
- import { KeyClient } from "@azure/keyvault-keys";
197
189
  const client = new KeyClient(vaultUrl, credentialChain);
198
190
  ```
199
191
 
@@ -215,15 +207,16 @@ For examples of how to use managed identity for authentication, see [the example
215
207
 
216
208
  Credentials default to authenticating to the Microsoft Entra endpoint for Azure Public Cloud. To access resources in other clouds, such as Azure Government or a private cloud, configure credentials with the `authorityHost` argument in the constructor. The [`AzureAuthorityHosts`][authority_hosts] enum defines authorities for well-known clouds. For the US Government cloud, you could instantiate a credential this way:
217
209
 
218
- ```typescript
219
- import { AzureAuthorityHosts, ClientSecretCredential } from "@azure/identity";
210
+ ```ts snippet:cloudconfiguration_authenticate
211
+ import { ClientSecretCredential, AzureAuthorityHosts } from "@azure/identity";
212
+
220
213
  const credential = new ClientSecretCredential(
221
214
  "<YOUR_TENANT_ID>",
222
215
  "<YOUR_CLIENT_ID>",
223
216
  "<YOUR_CLIENT_SECRET>",
224
217
  {
225
218
  authorityHost: AzureAuthorityHosts.AzureGovernment,
226
- }
219
+ },
227
220
  );
228
221
  ```
229
222
 
@@ -235,15 +228,16 @@ AZURE_AUTHORITY_HOST=https://login.partner.microsoftonline.cn
235
228
 
236
229
  The `AzureAuthorityHosts` enum defines authorities for well-known clouds for your convenience; however, if the authority for your cloud isn't listed in `AzureAuthorityHosts`, you may pass any valid authority URL as a string argument. For example:
237
230
 
238
- ```typescript
239
- import { AzureAuthorityHosts, ClientSecretCredential } from "@azure/identity";
231
+ ```ts snippet:cloudconfiguration_authorityhost
232
+ import { ClientSecretCredential } from "@azure/identity";
233
+
240
234
  const credential = new ClientSecretCredential(
241
235
  "<YOUR_TENANT_ID>",
242
236
  "<YOUR_CLIENT_ID>",
243
237
  "<YOUR_CLIENT_SECRET>",
244
238
  {
245
239
  authorityHost: "https://login.partner.microsoftonline.cn",
246
- }
240
+ },
247
241
  );
248
242
  ```
249
243
 
@@ -251,12 +245,17 @@ Not all credentials require this configuration. Credentials that authenticate th
251
245
 
252
246
  ## Credential classes
253
247
 
254
- ### Authenticate Azure-hosted applications
248
+ ### Credential chains
255
249
 
256
250
  | Credential | Usage | Example |
257
251
  | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
258
252
  | [`DefaultAzureCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/defaultazurecredential?view=azure-node-latest) | Provides a simplified authentication experience to quickly start developing applications run in Azure. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-defaultazurecredential) |
259
253
  | [`ChainedTokenCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/chainedtokencredential?view=azure-node-latest) | Allows users to define custom authentication flows composing multiple credentials. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#chaining-credentials) |
254
+
255
+ ### Authenticate Azure-hosted applications
256
+
257
+ | Credential | Usage | Example |
258
+ | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
260
259
  | [`EnvironmentCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/environmentcredential?view=azure-node-latest) | Authenticates a service principal or user via credential information specified in environment variables. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-service-principal-with-environment-credentials) |
261
260
  | [`ManagedIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/managedidentitycredential?view=azure-node-latest) | Authenticates the managed identity of an Azure resource. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-managed-identity) |
262
261
  | [`WorkloadIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/workloadidentitycredential?view=azure-node-latest) | Supports [Microsoft Entra Workload ID](https://learn.microsoft.com/azure/aks/workload-identity-overview) on Kubernetes. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-workload-identity) |
@@ -305,12 +304,13 @@ Not all credentials require this configuration. Credentials that authenticate th
305
304
 
306
305
  #### Service principal with certificate
307
306
 
308
- | Variable name | Value |
309
- | ----------------------------------- | ------------------------------------------------------------ |
310
- | `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
311
- | `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
312
- | `AZURE_CLIENT_CERTIFICATE_PATH` | path to a PEM-encoded certificate file including private key |
313
- | `AZURE_CLIENT_CERTIFICATE_PASSWORD` | password of the certificate file, if any |
307
+ | Variable name | Value |
308
+ |---------------------------------------|--------------------------------------------------------------|
309
+ | `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
310
+ | `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
311
+ | `AZURE_CLIENT_CERTIFICATE_PATH` | path to a PEM-encoded certificate file including private key |
312
+ | `AZURE_CLIENT_CERTIFICATE_PASSWORD` | (optional) password of the certificate file, if any |
313
+ | `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN` | (optional) send certificate chain in x5c header to support subject name / issuer-based authentication |
314
314
 
315
315
  #### Username and password
316
316
 
@@ -321,7 +321,7 @@ Not all credentials require this configuration. Credentials that authenticate th
321
321
  | `AZURE_USERNAME` | a username (usually an email address) |
322
322
  | `AZURE_PASSWORD` | that user's password |
323
323
 
324
- Configuration is attempted in the above order. For example, if values for a client secret and certificate are both present, the client secret will be used.
324
+ Configuration is attempted in the preceding order. For example, if values for a client secret and certificate are both present, the client secret is used.
325
325
 
326
326
  ## Continuous Access Evaluation
327
327
 
@@ -335,7 +335,7 @@ Token caching is a feature provided by the Azure Identity library that allows ap
335
335
  - Improve resilience and performance.
336
336
  - Reduce the number of requests made to Microsoft Entra ID to obtain access tokens.
337
337
 
338
- The Azure Identity library offers both in-memory and persistent disk caching. For more details, see the [token caching documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TOKEN_CACHING.md).
338
+ The Azure Identity library offers both in-memory and persistent disk caching. For more information, see the [token caching documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TOKEN_CACHING.md).
339
339
 
340
340
  ## Brokered authentication
341
341
 
@@ -365,21 +365,12 @@ For other open issues, see the library's [GitHub repository](https://github.com/
365
365
 
366
366
  ### Provide feedback
367
367
 
368
- If you encounter bugs or have suggestions, please [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).
368
+ If you encounter bugs or have suggestions, [open an issue](https://github.com/Azure/azure-sdk-for-js/issues).
369
369
 
370
370
  ## Contributing
371
371
 
372
- If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
373
-
374
- [1]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/defaultazurecredential.html
375
- [2]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/managedidentitycredential.html
376
- [3]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/environmentcredential.html
377
- [4]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/clientsecretcredential.html
378
- [5]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/clientcertificatecredential.html
379
- [6]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/devicecodecredential.html
380
- [7]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/authorizationcodecredential.html
381
- [8]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/interactivebrowsercredential.html
382
- [9]: https://azuresdkdocs.blob.core.windows.net/$web/javascript/azure-identity/1.0.0/classes/usernamepasswordcredential.html
372
+ To contribute to this library, read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
373
+
383
374
  [azure_cli]: https://learn.microsoft.com/cli/azure
384
375
  [azure_developer_cli]: https://learn.microsoft.com/azure/developer/azure-developer-cli
385
376
  [azure_powershell]: https://learn.microsoft.com/powershell/azure/