@azure/identity 2.0.0-beta.3 → 2.0.0

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.

Potentially problematic release.


This version of @azure/identity might be problematic. Click here for more details.

Files changed (149) hide show
  1. package/CHANGELOG.md +232 -6
  2. package/README.md +124 -39
  3. package/dist/index.js +2317 -1596
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/client/identityClient.js +147 -133
  6. package/dist-esm/src/client/identityClient.js.map +1 -1
  7. package/dist-esm/src/constants.js +1 -1
  8. package/dist-esm/src/constants.js.map +1 -1
  9. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js +1 -1
  10. package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
  11. package/dist-esm/src/credentials/authorizationCodeCredential.js +13 -76
  12. package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
  13. package/dist-esm/src/credentials/azureApplicationCredential.browser.js +34 -0
  14. package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -0
  15. package/dist-esm/src/credentials/azureApplicationCredential.js +36 -0
  16. package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -0
  17. package/dist-esm/src/credentials/azureCliCredential.browser.js +7 -0
  18. package/dist-esm/src/credentials/azureCliCredential.browser.js.map +1 -1
  19. package/dist-esm/src/credentials/azureCliCredential.js +110 -83
  20. package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
  21. package/dist-esm/src/credentials/azureCliCredentialOptions.js +4 -0
  22. package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -0
  23. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js +3 -1
  24. package/dist-esm/src/credentials/azurePowerShellCredential.browser.js.map +1 -1
  25. package/dist-esm/src/credentials/azurePowerShellCredential.js +93 -83
  26. package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
  27. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js +4 -0
  28. package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -0
  29. package/dist-esm/src/credentials/chainedTokenCredential.js +34 -37
  30. package/dist-esm/src/credentials/chainedTokenCredential.js.map +1 -1
  31. package/dist-esm/src/credentials/clientCertificateCredential.browser.js +7 -0
  32. package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
  33. package/dist-esm/src/credentials/clientCertificateCredential.js +24 -23
  34. package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
  35. package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
  36. package/dist-esm/src/credentials/clientSecretCredential.browser.js +39 -44
  37. package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
  38. package/dist-esm/src/credentials/clientSecretCredential.js +9 -11
  39. package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
  40. package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
  41. package/dist-esm/src/credentials/credentialPersistenceOptions.js +4 -0
  42. package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -0
  43. package/dist-esm/src/credentials/defaultAzureCredential.browser.js +1 -1
  44. package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
  45. package/dist-esm/src/credentials/defaultAzureCredential.js +50 -27
  46. package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
  47. package/dist-esm/src/credentials/deviceCodeCredential.browser.js +7 -0
  48. package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
  49. package/dist-esm/src/credentials/deviceCodeCredential.js +27 -22
  50. package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
  51. package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
  52. package/dist-esm/src/credentials/environmentCredential.browser.js +7 -0
  53. package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
  54. package/dist-esm/src/credentials/environmentCredential.js +39 -38
  55. package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
  56. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +20 -29
  57. package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
  58. package/dist-esm/src/credentials/interactiveBrowserCredential.js +23 -29
  59. package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
  60. package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
  61. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +36 -22
  62. package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
  63. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +62 -47
  64. package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
  65. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +33 -22
  66. package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
  67. package/dist-esm/src/credentials/managedIdentityCredential/constants.js +2 -1
  68. package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +1 -1
  69. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +42 -27
  70. package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
  71. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +115 -91
  72. package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
  73. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js +3 -6
  74. package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +1 -1
  75. package/dist-esm/src/credentials/managedIdentityCredential/index.js +120 -125
  76. package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
  77. package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
  78. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +82 -0
  79. package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -0
  80. package/dist-esm/src/credentials/managedIdentityCredential/utils.js +14 -8
  81. package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
  82. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +23 -0
  83. package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -0
  84. package/dist-esm/src/credentials/onBehalfOfCredential.js +57 -0
  85. package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -0
  86. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js +4 -0
  87. package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -0
  88. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +41 -46
  89. package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
  90. package/dist-esm/src/credentials/usernamePasswordCredential.js +9 -13
  91. package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
  92. package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
  93. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js +27 -0
  94. package/dist-esm/src/credentials/visualStudioCodeCredential.browser.js.map +1 -0
  95. package/dist-esm/src/credentials/visualStudioCodeCredential.js +183 -0
  96. package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -0
  97. package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js +4 -0
  98. package/dist-esm/src/credentials/visualStudioCodeCredentialPlugin.js.map +1 -0
  99. package/dist-esm/src/{client/errors.js → errors.js} +16 -1
  100. package/dist-esm/src/errors.js.map +1 -0
  101. package/dist-esm/src/index.js +4 -2
  102. package/dist-esm/src/index.js.map +1 -1
  103. package/dist-esm/src/msal/browserFlows/browserCommon.js +33 -31
  104. package/dist-esm/src/msal/browserFlows/browserCommon.js.map +1 -1
  105. package/dist-esm/src/msal/browserFlows/msalAuthCode.js +113 -115
  106. package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
  107. package/dist-esm/src/msal/credentials.js.map +1 -1
  108. package/dist-esm/src/msal/flows.js.map +1 -1
  109. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +41 -0
  110. package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -0
  111. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +65 -46
  112. package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
  113. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +15 -16
  114. package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
  115. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +20 -22
  116. package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
  117. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +56 -0
  118. package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -0
  119. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +44 -33
  120. package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
  121. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +15 -17
  122. package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
  123. package/dist-esm/src/msal/nodeFlows/nodeCommon.js +141 -98
  124. package/dist-esm/src/msal/nodeFlows/nodeCommon.js.map +1 -1
  125. package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js +4 -0
  126. package/dist-esm/src/msal/nodeFlows/tokenCachePersistenceOptions.js.map +1 -0
  127. package/dist-esm/src/msal/utils.js +23 -15
  128. package/dist-esm/src/msal/utils.js.map +1 -1
  129. package/dist-esm/src/plugins/consumer.browser.js +7 -0
  130. package/dist-esm/src/plugins/consumer.browser.js.map +1 -0
  131. package/dist-esm/src/plugins/consumer.js +44 -0
  132. package/dist-esm/src/plugins/consumer.js.map +1 -0
  133. package/dist-esm/src/plugins/provider.js +4 -0
  134. package/dist-esm/src/plugins/provider.js.map +1 -0
  135. package/dist-esm/src/regionalAuthority.js +115 -0
  136. package/dist-esm/src/regionalAuthority.js.map +1 -0
  137. package/dist-esm/src/util/tracing.js +24 -27
  138. package/dist-esm/src/util/tracing.js.map +1 -1
  139. package/dist-esm/src/util/validateMultiTenant.browser.js +22 -0
  140. package/dist-esm/src/util/validateMultiTenant.browser.js.map +1 -0
  141. package/dist-esm/src/util/validateMultiTenant.js +29 -0
  142. package/dist-esm/src/util/validateMultiTenant.js.map +1 -0
  143. package/package.json +44 -28
  144. package/types/identity.d.ts +482 -126
  145. package/dist-esm/src/client/errors.js.map +0 -1
  146. package/dist-esm/src/msal/errors.js +0 -22
  147. package/dist-esm/src/msal/errors.js.map +0 -1
  148. package/dist-esm/src/util/authHostEnv.js +0 -13
  149. package/dist-esm/src/util/authHostEnv.js.map +0 -1
@@ -1,8 +1,9 @@
1
- import { AccessToken } from '@azure/core-http';
1
+ import { AccessToken } from '@azure/core-auth';
2
2
  import { AzureLogger } from '@azure/logger';
3
- import { GetTokenOptions } from '@azure/core-http';
4
- import { PipelineOptions } from '@azure/core-http';
5
- import { TokenCredential } from '@azure/core-http';
3
+ import { CommonClientOptions } from '@azure/core-client';
4
+ import { GetTokenOptions } from '@azure/core-auth';
5
+ import { TokenCredential } from '@azure/core-auth';
6
+
6
7
  export { AccessToken }
7
8
 
8
9
  /**
@@ -80,18 +81,32 @@ export declare class AuthenticationRequiredError extends Error {
80
81
  */
81
82
  scopes: string[];
82
83
  /**
83
- * The options used to configure the getToken request.
84
+ * The options passed to the getToken request.
84
85
  */
85
- getTokenOptions: GetTokenOptions;
86
+ getTokenOptions?: GetTokenOptions;
86
87
  constructor(
88
+ /**
89
+ * Optional parameters. A message can be specified. The {@link GetTokenOptions} of the request can also be specified to more easily associate the error with the received parameters.
90
+ */
91
+ options: AuthenticationRequiredErrorOptions);
92
+ }
93
+
94
+ /**
95
+ * Optional parameters to the {@link AuthenticationRequiredError}
96
+ */
97
+ export declare interface AuthenticationRequiredErrorOptions {
87
98
  /**
88
99
  * The list of scopes for which the token will have access.
89
100
  */
90
- scopes: string[],
101
+ scopes: string[];
91
102
  /**
92
- * The options used to configure the getToken request.
103
+ * The options passed to the getToken request.
93
104
  */
94
- getTokenOptions?: GetTokenOptions, message?: string);
105
+ getTokenOptions?: GetTokenOptions;
106
+ /**
107
+ * The message of the error.
108
+ */
109
+ message?: string;
95
110
  }
96
111
 
97
112
  /**
@@ -102,13 +117,10 @@ export declare class AuthenticationRequiredError extends Error {
102
117
  * https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
103
118
  */
104
119
  export declare class AuthorizationCodeCredential implements TokenCredential {
105
- private identityClient;
106
- private tenantId;
107
- private clientId;
108
- private clientSecret;
120
+ private msalFlow;
121
+ private disableAutomaticAuthentication?;
109
122
  private authorizationCode;
110
123
  private redirectUri;
111
- private lastTokenResponse;
112
124
  /**
113
125
  * Creates an instance of CodeFlowCredential with the details needed
114
126
  * to request an access token using an authentication that was obtained
@@ -118,17 +130,17 @@ export declare class AuthorizationCodeCredential implements TokenCredential {
118
130
  * the authorization code flow to obtain an authorization code to be used
119
131
  * with this credential. A full example of this flow is provided here:
120
132
  *
121
- * https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/manual/authorizationCodeSample.ts
133
+ * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/manual/authorizationCodeSample.ts
122
134
  *
123
135
  * @param tenantId - The Azure Active Directory tenant (directory) ID or name.
124
136
  * 'common' may be used when dealing with multi-tenant scenarios.
125
137
  * @param clientId - The client (application) ID of an App Registration in the tenant.
126
138
  * @param clientSecret - A client secret that was generated for the App Registration
127
139
  * @param authorizationCode - An authorization code that was received from following the
128
- authorization code flow. This authorization code must not
129
- have already been used to obtain an access token.
140
+ authorization code flow. This authorization code must not
141
+ have already been used to obtain an access token.
130
142
  * @param redirectUri - The redirect URI that was used to request the authorization code.
131
- Must be the same URI that is configured for the App Registration.
143
+ Must be the same URI that is configured for the App Registration.
132
144
  * @param options - Options for configuring the client which makes the access token request.
133
145
  */
134
146
  constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
@@ -141,24 +153,22 @@ export declare class AuthorizationCodeCredential implements TokenCredential {
141
153
  * the authorization code flow to obtain an authorization code to be used
142
154
  * with this credential. A full example of this flow is provided here:
143
155
  *
144
- * https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/manual/authorizationCodeSample.ts
156
+ * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/manual/authorizationCodeSample.ts
145
157
  *
146
158
  * @param tenantId - The Azure Active Directory tenant (directory) ID or name.
147
159
  * 'common' may be used when dealing with multi-tenant scenarios.
148
160
  * @param clientId - The client (application) ID of an App Registration in the tenant.
149
161
  * @param authorizationCode - An authorization code that was received from following the
150
- authorization code flow. This authorization code must not
151
- have already been used to obtain an access token.
162
+ authorization code flow. This authorization code must not
163
+ have already been used to obtain an access token.
152
164
  * @param redirectUri - The redirect URI that was used to request the authorization code.
153
- Must be the same URI that is configured for the App Registration.
165
+ Must be the same URI that is configured for the App Registration.
154
166
  * @param options - Options for configuring the client which makes the access token request.
155
167
  */
156
168
  constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
157
169
  /**
158
- * Authenticates with Azure Active Directory and returns an access token if
159
- * successful. If authentication cannot be performed at this time, this method may
160
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
161
- * containing failure details will be thrown.
170
+ * Authenticates with Azure Active Directory and returns an access token if successful.
171
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
162
172
  *
163
173
  * @param scopes - The list of scopes for which the token will have access.
164
174
  * @param options - The options used to configure any requests this
@@ -194,24 +204,21 @@ export declare enum AzureAuthorityHosts {
194
204
  * via the Azure CLI ('az') commandline tool.
195
205
  * To do so, it will read the user access token and expire time
196
206
  * with Azure CLI command "az account get-access-token".
197
- * To be able to use this credential, ensure that you have already logged
198
- * in via the 'az' tool using the command "az login" from the commandline.
199
207
  */
200
208
  export declare class AzureCliCredential implements TokenCredential {
209
+ private tenantId?;
201
210
  /**
202
- * Gets the access token from Azure CLI
203
- * @param resource - The resource to use when getting the token
211
+ * Creates an instance of the {@link AzureCliCredential}.
212
+ *
213
+ * To use this credential, ensure that you have already logged
214
+ * in via the 'az' tool using the command "az login" from the commandline.
215
+ *
216
+ * @param options - Options, to optionally allow multi-tenant requests.
204
217
  */
205
- protected getAzureCliAccessToken(resource: string): Promise<{
206
- stdout: string;
207
- stderr: string;
208
- error: Error | null;
209
- }>;
218
+ constructor(options?: AzureCliCredentialOptions);
210
219
  /**
211
- * Authenticates with Azure Active Directory and returns an access token if
212
- * successful. If authentication cannot be performed at this time, this method may
213
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
214
- * containing failure details will be thrown.
220
+ * Authenticates with Azure Active Directory and returns an access token if successful.
221
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
215
222
  *
216
223
  * @param scopes - The list of scopes for which the token will have access.
217
224
  * @param options - The options used to configure any requests this
@@ -220,33 +227,58 @@ export declare class AzureCliCredential implements TokenCredential {
220
227
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
221
228
  }
222
229
 
230
+ /**
231
+ * Options for the {@link AzureCliCredential}
232
+ */
233
+ export declare interface AzureCliCredentialOptions extends TokenCredentialOptions {
234
+ /**
235
+ * Allows specifying a tenant ID
236
+ */
237
+ tenantId?: string;
238
+ }
239
+
223
240
  /**
224
241
  * This credential will use the currently logged-in user information from the
225
242
  * Azure PowerShell module. To do so, it will read the user access token and
226
243
  * expire time with Azure PowerShell command `Get-AzAccessToken -ResourceUrl {ResourceScope}`
227
- *
228
- * To be able to use this credential:
229
- * - Install the Azure Az PowerShell module with:
230
- * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.
231
- * - You have already logged in to Azure PowerShell using the command
232
- * `Connect-AzAccount` from the command line.
233
244
  */
234
245
  export declare class AzurePowerShellCredential implements TokenCredential {
246
+ private tenantId?;
247
+ /**
248
+ * Creates an instance of the {@link AzurePowerShellCredential}.
249
+ *
250
+ * To use this credential:
251
+ * - Install the Azure Az PowerShell module with:
252
+ * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.
253
+ * - You have already logged in to Azure PowerShell using the command
254
+ * `Connect-AzAccount` from the command line.
255
+ *
256
+ * @param options - Options, to optionally allow multi-tenant requests.
257
+ */
258
+ constructor(options?: AzurePowerShellCredentialOptions);
235
259
  /**
236
260
  * Gets the access token from Azure PowerShell
237
261
  * @param resource - The resource to use when getting the token
238
262
  */
239
263
  private getAzurePowerShellAccessToken;
240
264
  /**
241
- * Authenticates with Azure Active Directory and returns an access token if
242
- * successful. If authentication cannot be performed at this time, this method may
243
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
244
- * containing failure details will be thrown.
265
+ * Authenticates with Azure Active Directory and returns an access token if successful.
266
+ * If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
245
267
  *
246
268
  * @param scopes - The list of scopes for which the token will have access.
247
269
  * @param options - The options used to configure any requests this TokenCredential implementation might make.
248
270
  */
249
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
271
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
272
+ }
273
+
274
+ /**
275
+ * Options for the {@link AzurePowerShellCredential}
276
+ */
277
+ export declare interface AzurePowerShellCredentialOptions extends TokenCredentialOptions {
278
+ /**
279
+ * Allows specifying a tenant ID
280
+ */
281
+ tenantId?: string;
250
282
  }
251
283
 
252
284
  /**
@@ -320,10 +352,19 @@ export declare class ClientCertificateCredential implements TokenCredential {
320
352
  */
321
353
  constructor(tenantId: string, clientId: string, certificatePath: string, options?: ClientCertificateCredentialOptions);
322
354
  /**
323
- * Authenticates with Azure Active Directory and returns an access token if
324
- * successful. If authentication cannot be performed at this time, this method may
325
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
326
- * containing failure details will be thrown.
355
+ * Creates an instance of the ClientCertificateCredential with the details
356
+ * needed to authenticate against Azure Active Directory with a certificate.
357
+ *
358
+ * @param tenantId - The Azure Active Directory tenant (directory) ID.
359
+ * @param clientId - The client (application) ID of an App Registration in the tenant.
360
+ * @param configuration - Other parameters required, including the PEM-encoded certificate as a string, or as a path on the filesystem.
361
+ * If the type is ignored, we will throw if both the value of the PEM certificate and the path to a PEM certificate are provided at the same time.
362
+ * @param options - Options for configuring the client which makes the authentication request.
363
+ */
364
+ constructor(tenantId: string, clientId: string, configuration: ClientCertificateCredentialPEMConfiguration, options?: ClientCertificateCredentialOptions);
365
+ /**
366
+ * Authenticates with Azure Active Directory and returns an access token if successful.
367
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
327
368
  *
328
369
  * @param scopes - The list of scopes for which the token will have access.
329
370
  * @param options - The options used to configure any requests this
@@ -335,7 +376,7 @@ export declare class ClientCertificateCredential implements TokenCredential {
335
376
  /**
336
377
  * Optional parameters for the {@link ClientCertificateCredential} class.
337
378
  */
338
- export declare interface ClientCertificateCredentialOptions extends TokenCredentialOptions {
379
+ export declare interface ClientCertificateCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
339
380
  /**
340
381
  * Option to include x5c header for SubjectName and Issuer name authorization.
341
382
  * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
@@ -343,6 +384,29 @@ export declare interface ClientCertificateCredentialOptions extends TokenCredent
343
384
  sendCertificateChain?: boolean;
344
385
  }
345
386
 
387
+ /**
388
+ * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.
389
+ */
390
+ export declare type ClientCertificateCredentialPEMConfiguration = {
391
+ /**
392
+ * The PEM-encoded public/private key certificate on the filesystem.
393
+ */
394
+ certificate: string;
395
+ /**
396
+ * The PEM-encoded public/private key certificate on the filesystem should not be provided if `certificate` is provided.
397
+ */
398
+ certificatePath?: never;
399
+ } | {
400
+ /**
401
+ * The PEM-encoded public/private key certificate on the filesystem should not be provided if `certificatePath` is provided.
402
+ */
403
+ certificate?: never;
404
+ /**
405
+ * The path to the PEM-encoded public/private key certificate on the filesystem.
406
+ */
407
+ certificatePath: string;
408
+ };
409
+
346
410
  /**
347
411
  * Enables authentication to Azure Active Directory using a client secret
348
412
  * that was generated for an App Registration. More information on how
@@ -365,10 +429,8 @@ export declare class ClientSecretCredential implements TokenCredential {
365
429
  */
366
430
  constructor(tenantId: string, clientId: string, clientSecret: string, options?: ClientSecretCredentialOptions);
367
431
  /**
368
- * Authenticates with Azure Active Directory and returns an access token if
369
- * successful. If authentication cannot be performed at this time, this method may
370
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
371
- * containing failure details will be thrown.
432
+ * Authenticates with Azure Active Directory and returns an access token if successful.
433
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
372
434
  *
373
435
  * @param scopes - The list of scopes for which the token will have access.
374
436
  * @param options - The options used to configure any requests this
@@ -380,7 +442,44 @@ export declare class ClientSecretCredential implements TokenCredential {
380
442
  /**
381
443
  * Optional parameters for the {@link ClientSecretCredential} class.
382
444
  */
383
- export declare interface ClientSecretCredentialOptions extends TokenCredentialOptions {
445
+ export declare interface ClientSecretCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
446
+ }
447
+
448
+ /**
449
+ * Shared configuration options for credentials that support persistent token
450
+ * caching.
451
+ */
452
+ export declare interface CredentialPersistenceOptions {
453
+ /**
454
+ * Options to provide to the persistence layer (if one is available) when
455
+ * storing credentials.
456
+ *
457
+ * You must first register a persistence provider plugin. See the
458
+ * `@azure/identity-cache-persistence` package on NPM.
459
+ *
460
+ * Example:
461
+ *
462
+ * ```javascript
463
+ * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
464
+ * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
465
+ *
466
+ * useIdentityPlugin(cachePersistencePlugin);
467
+ *
468
+ * async function main() {
469
+ * const credential = new DeviceCodeCredential({
470
+ * tokenCachePersistenceOptions: {
471
+ * enabled: true
472
+ * }
473
+ * });
474
+ * }
475
+ *
476
+ * main().catch((error) => {
477
+ * console.error("An error occured:", error);
478
+ * process.exit(1);
479
+ * });
480
+ * ```
481
+ */
482
+ tokenCachePersistenceOptions?: TokenCachePersistenceOptions;
384
483
  }
385
484
 
386
485
  /**
@@ -398,21 +497,32 @@ export declare class CredentialUnavailableError extends Error {
398
497
  export declare const CredentialUnavailableErrorName = "CredentialUnavailableError";
399
498
 
400
499
  /**
401
- * Provides a default {@link ChainedTokenCredential} configuration that should work for most applications that use the Azure SDK.
402
- * The following credential types will be tried, in order:
403
- *
404
- * - {@link EnvironmentCredential}
405
- * - {@link ManagedIdentityCredential}
406
- * - {@link AzureCliCredential}
407
- * - {@link AzurePowerShellCredential}
408
- *
409
- * Consult the documentation of these credential types for more information
410
- * on how they attempt authentication.
500
+ * Provides a default {@link ChainedTokenCredential} configuration that should
501
+ * work for most applications that use the Azure SDK.
411
502
  */
412
503
  export declare class DefaultAzureCredential extends ChainedTokenCredential {
413
504
  /**
414
505
  * Creates an instance of the DefaultAzureCredential class.
415
506
  *
507
+ * This credential provides a default {@link ChainedTokenCredential} configuration that should
508
+ * work for most applications that use the Azure SDK.
509
+ *
510
+ * The following credential types will be tried, in order:
511
+ *
512
+ * - {@link EnvironmentCredential}
513
+ * - {@link ManagedIdentityCredential}
514
+ * - {@link VisualStudioCodeCredential}
515
+ * - {@link AzureCliCredential}
516
+ * - {@link AzurePowerShellCredential}
517
+ *
518
+ * Consult the documentation of these credential types for more information
519
+ * on how they attempt authentication.
520
+ *
521
+ * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
522
+ * `@azure/identity-vscode`. If this package is not installed and registered
523
+ * using the plugin API (`useIdentityPlugin`), then authentication using
524
+ * `VisualStudioCodeCredential` will not be available.
525
+ *
416
526
  * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.
417
527
  */
418
528
  constructor(options?: DefaultAzureCredentialOptions);
@@ -466,14 +576,26 @@ export declare class DeviceCodeCredential implements TokenCredential {
466
576
  * Creates an instance of DeviceCodeCredential with the details needed
467
577
  * to initiate the device code authorization flow with Azure Active Directory.
468
578
  *
579
+ * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
580
+ *
581
+ * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
582
+ *
583
+ * ```js
584
+ * const credential = new DeviceCodeCredential({
585
+ * tenantId: env.AZURE_TENANT_ID,
586
+ * clientId: env.AZURE_CLIENT_ID,
587
+ * userPromptCallback: (info) => {
588
+ * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
589
+ * }
590
+ * });
591
+ * ```
592
+ *
469
593
  * @param options - Options for configuring the client which makes the authentication requests.
470
594
  */
471
595
  constructor(options?: DeviceCodeCredentialOptions);
472
596
  /**
473
- * Authenticates with Azure Active Directory and returns an access token if
474
- * successful. If authentication cannot be performed at this time, this method may
475
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
476
- * containing failure details will be thrown.
597
+ * Authenticates with Azure Active Directory and returns an access token if successful.
598
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
477
599
  *
478
600
  * If the user provided the option `disableAutomaticAuthentication`,
479
601
  * once the token can't be retrieved silently,
@@ -485,10 +607,8 @@ export declare class DeviceCodeCredential implements TokenCredential {
485
607
  */
486
608
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
487
609
  /**
488
- * Authenticates with Azure Active Directory and returns an access token if
489
- * successful. If authentication cannot be performed at this time, this method may
490
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
491
- * containing failure details will be thrown.
610
+ * Authenticates with Azure Active Directory and returns an access token if successful.
611
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
492
612
  *
493
613
  * If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
494
614
  *
@@ -500,9 +620,9 @@ export declare class DeviceCodeCredential implements TokenCredential {
500
620
  }
501
621
 
502
622
  /**
503
- * Defines options for the InteractiveBrowserCredential class for NodeJS.
623
+ * Defines options for the InteractiveBrowserCredential class for Node.js.
504
624
  */
505
- export declare interface DeviceCodeCredentialOptions extends InteractiveCredentialOptions {
625
+ export declare interface DeviceCodeCredentialOptions extends InteractiveCredentialOptions, CredentialPersistenceOptions {
506
626
  /**
507
627
  * The Azure Active Directory tenant (directory) ID.
508
628
  */
@@ -550,27 +670,31 @@ export declare type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo)
550
670
 
551
671
  /**
552
672
  * Enables authentication to Azure Active Directory using client secret
553
- * details configured in the following environment variables:
554
- *
555
- * - AZURE_TENANT_ID: The Azure Active Directory tenant (directory) ID.
556
- * - AZURE_CLIENT_ID: The client (application) ID of an App Registration in the tenant.
557
- * - AZURE_CLIENT_SECRET: A client secret that was generated for the App Registration.
558
- *
559
- * This credential ultimately uses a {@link ClientSecretCredential} to
560
- * perform the authentication using these details. Please consult the
561
- * documentation of that class for more details.
673
+ * details configured in environment variables
562
674
  */
563
675
  export declare class EnvironmentCredential implements TokenCredential {
564
676
  private _credential?;
565
677
  /**
566
- * Creates an instance of the EnvironmentCredential class and reads
567
- * client secret details from environment variables. If the expected
568
- * environment variables are not found at this time, the getToken method
569
- * will return null when invoked.
678
+ * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
679
+ *
680
+ * Required environment variables:
681
+ * - `AZURE_TENANT_ID`: The Azure Active Directory tenant (directory) ID.
682
+ * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
683
+ *
684
+ * Environment variables used for client credential authentication:
685
+ * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
686
+ * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
687
+ *
688
+ * Alternatively, users can provide environment variables for username and password authentication:
689
+ * - `AZURE_USERNAME`: Username to authenticate with.
690
+ * - `AZURE_PASSWORD`: Password to authenticate with.
691
+ *
692
+ * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.
693
+ * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.
570
694
  *
571
695
  * @param options - Options for configuring the client which makes the authentication request.
572
696
  */
573
- constructor(options?: TokenCredentialOptions);
697
+ constructor(options?: EnvironmentCredentialOptions);
574
698
  /**
575
699
  * Authenticates with Azure Active Directory and returns an access token if successful.
576
700
  *
@@ -580,6 +704,13 @@ export declare class EnvironmentCredential implements TokenCredential {
580
704
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
581
705
  }
582
706
 
707
+ /**
708
+ * Enables authentication to Azure Active Directory depending on the available environment variables.
709
+ * Defines options for the EnvironmentCredential class.
710
+ */
711
+ export declare interface EnvironmentCredentialOptions extends TokenCredentialOptions {
712
+ }
713
+
583
714
  /**
584
715
  * See the official documentation for more details:
585
716
  *
@@ -619,18 +750,18 @@ export declare interface ErrorResponse {
619
750
  * Returns a new instance of the {@link DefaultAzureCredential}.
620
751
  */
621
752
  export declare function getDefaultAzureCredential(): TokenCredential;
753
+
622
754
  export { GetTokenOptions }
623
755
 
756
+ /**
757
+ * The type of an Azure Identity plugin, a function accepting a plugin
758
+ * context.
759
+ */
760
+ export declare type IdentityPlugin = (context: unknown) => void;
761
+
624
762
  /**
625
763
  * Enables authentication to Azure Active Directory inside of the web browser
626
764
  * using the interactive login flow.
627
- *
628
- * This credential uses the [Authorization Code Flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
629
- * On NodeJS, it will open a browser window while it listens for a redirect response from the authentication service.
630
- * On browsers, it authenticates via popups. The `loginStyle` optional parameter can be set to `redirect` to authenticate by redirecting the user to an Azure secure login page, which then will redirect the user back to the web application where the authentication started.
631
- *
632
- * For Node.js, if a `clientId` is provided, the Azure Active Directory application will need to be configured to have a "Mobile and desktop applications" redirect endpoint.
633
- * Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://docs.microsoft.com/azure/active-directory/develop/scenario-desktop-app-registration#redirect-uris).
634
765
  */
635
766
  export declare class InteractiveBrowserCredential implements TokenCredential {
636
767
  private msalFlow;
@@ -638,14 +769,19 @@ export declare class InteractiveBrowserCredential implements TokenCredential {
638
769
  /**
639
770
  * Creates an instance of InteractiveBrowserCredential with the details needed.
640
771
  *
772
+ * This credential uses the [Authorization Code Flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
773
+ * On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
774
+ * On browsers, it authenticates via popups. The `loginStyle` optional parameter can be set to `redirect` to authenticate by redirecting the user to an Azure secure login page, which then will redirect the user back to the web application where the authentication started.
775
+ *
776
+ * For Node.js, if a `clientId` is provided, the Azure Active Directory application will need to be configured to have a "Mobile and desktop applications" redirect endpoint.
777
+ * Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://docs.microsoft.com/azure/active-directory/develop/scenario-desktop-app-registration#redirect-uris).
778
+ *
641
779
  * @param options - Options for configuring the client which makes the authentication requests.
642
780
  */
643
- constructor(options?: InteractiveBrowserCredentialOptions | InteractiveBrowserCredentialBrowserOptions);
781
+ constructor(options?: InteractiveBrowserCredentialNodeOptions | InteractiveBrowserCredentialInBrowserOptions);
644
782
  /**
645
- * Authenticates with Azure Active Directory and returns an access token if
646
- * successful. If authentication cannot be performed at this time, this method may
647
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
648
- * containing failure details will be thrown.
783
+ * Authenticates with Azure Active Directory and returns an access token if successful.
784
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
649
785
  *
650
786
  * If the user provided the option `disableAutomaticAuthentication`,
651
787
  * once the token can't be retrieved silently,
@@ -657,13 +793,14 @@ export declare class InteractiveBrowserCredential implements TokenCredential {
657
793
  */
658
794
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
659
795
  /**
660
- * Authenticates with Azure Active Directory and returns an access token if
661
- * successful. If authentication cannot be performed at this time, this method may
662
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
663
- * containing failure details will be thrown.
796
+ * Authenticates with Azure Active Directory and returns an access token if successful.
797
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
664
798
  *
665
799
  * If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
666
800
  *
801
+ * On Node.js, this credential has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
802
+ * PKCE is a security feature that mitigates authentication code interception attacks.
803
+ *
667
804
  * @param scopes - The list of scopes for which the token will have access.
668
805
  * @param options - The options used to configure any requests this
669
806
  * TokenCredential implementation might make.
@@ -674,7 +811,7 @@ export declare class InteractiveBrowserCredential implements TokenCredential {
674
811
  /**
675
812
  * Defines the common options for the InteractiveBrowserCredential class.
676
813
  */
677
- export declare type InteractiveBrowserCredentialBrowserOptions = TokenCredentialOptions & InteractiveCredentialOptions & {
814
+ export declare interface InteractiveBrowserCredentialInBrowserOptions extends InteractiveCredentialOptions {
678
815
  /**
679
816
  * Gets the redirect URI of the application. This should be same as the value
680
817
  * in the application registration portal. Defaults to `window.location.href`.
@@ -696,12 +833,17 @@ export declare type InteractiveBrowserCredentialBrowserOptions = TokenCredential
696
833
  *
697
834
  */
698
835
  loginStyle?: BrowserLoginStyle;
699
- };
836
+ /**
837
+ * loginHint allows a user name to be pre-selected for interactive logins.
838
+ * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.
839
+ */
840
+ loginHint?: string;
841
+ }
700
842
 
701
843
  /**
702
844
  * Defines the common options for the InteractiveBrowserCredential class.
703
845
  */
704
- export declare type InteractiveBrowserCredentialOptions = TokenCredentialOptions & InteractiveCredentialOptions & {
846
+ export declare interface InteractiveBrowserCredentialNodeOptions extends InteractiveCredentialOptions, CredentialPersistenceOptions {
705
847
  /**
706
848
  * Gets the redirect URI of the application. This should be same as the value
707
849
  * in the application registration portal. Defaults to `window.location.href`.
@@ -715,7 +857,12 @@ export declare type InteractiveBrowserCredentialOptions = TokenCredentialOptions
715
857
  * The client (application) ID of an App Registration in the tenant.
716
858
  */
717
859
  clientId?: string;
718
- };
860
+ /**
861
+ * loginHint allows a user name to be pre-selected for interactive logins.
862
+ * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.
863
+ */
864
+ loginHint?: string;
865
+ }
719
866
 
720
867
  /**
721
868
  * Common constructor options for the Identity credentials that requires user interaction.
@@ -759,9 +906,9 @@ export declare class ManagedIdentityCredential implements TokenCredential {
759
906
  private isEndpointUnavailable;
760
907
  /**
761
908
  * Creates an instance of ManagedIdentityCredential with the client ID of a
762
- * user-assigned identity.
909
+ * user-assigned identity, or app registration (when working with AKS pod-identity).
763
910
  *
764
- * @param clientId - The client ID of the user-assigned identity.
911
+ * @param clientId - The client ID of the user-assigned identity, or app registration (when working with AKS pod-identity).
765
912
  * @param options - Options for configuring the client which makes the access token request.
766
913
  */
767
914
  constructor(clientId: string, options?: TokenCredentialOptions);
@@ -775,10 +922,9 @@ export declare class ManagedIdentityCredential implements TokenCredential {
775
922
  private cachedAvailableMSI;
776
923
  private authenticateManagedIdentity;
777
924
  /**
778
- * Authenticates with Azure Active Directory and returns an access token if
779
- * successful. If authentication cannot be performed at this time, this method may
780
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
781
- * containing failure details will be thrown.
925
+ * Authenticates with Azure Active Directory and returns an access token if successful.
926
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
927
+ * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
782
928
  *
783
929
  * @param scopes - The list of scopes for which the token will have access.
784
930
  * @param options - The options used to configure any requests this
@@ -787,6 +933,110 @@ export declare class ManagedIdentityCredential implements TokenCredential {
787
933
  getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
788
934
  }
789
935
 
936
+ /**
937
+ * Enables authentication to Azure Active Directory using the [On Behalf Of flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
938
+ */
939
+ export declare class OnBehalfOfCredential implements TokenCredential {
940
+ private options;
941
+ private msalFlow;
942
+ /**
943
+ * Creates an instance of the {@link OnBehalfOfCredential} with the details
944
+ * needed to authenticate against Azure Active Directory with a client
945
+ * secret or a path to a PEM certificate, and an user assertion.
946
+ *
947
+ * Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
948
+ *
949
+ * ```ts
950
+ * const tokenCredential = new OnBehalfOfCredential({
951
+ * tenantId,
952
+ * clientId,
953
+ * clientSecret, // or `certificatePath: "/path/to/certificate.pem"
954
+ * userAssertionToken: "access-token"
955
+ * });
956
+ * const client = new KeyClient("vault-url", tokenCredential);
957
+ *
958
+ * await client.getKey("key-name");
959
+ * ```
960
+ *
961
+ * @param options - Optional parameters, generally common across credentials.
962
+ */
963
+ constructor(options: OnBehalfOfCredentialOptions);
964
+ /**
965
+ * Authenticates with Azure Active Directory and returns an access token if successful.
966
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
967
+ *
968
+ * @param scopes - The list of scopes for which the token will have access.
969
+ * @param options - The options used to configure the underlying network requests.
970
+ */
971
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
972
+ }
973
+
974
+ /**
975
+ * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a certificate.
976
+ */
977
+ export declare interface OnBehalfOfCredentialCertificateOptions {
978
+ /**
979
+ * The Azure Active Directory tenant (directory) ID.
980
+ */
981
+ tenantId: string;
982
+ /**
983
+ * The client (application) ID of an App Registration in the tenant.
984
+ */
985
+ clientId: string;
986
+ /**
987
+ * The path to a PEM-encoded public/private key certificate on the filesystem.
988
+ */
989
+ certificatePath: string;
990
+ /**
991
+ * Option to include x5c header for SubjectName and Issuer name authorization.
992
+ * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
993
+ */
994
+ sendCertificateChain?: boolean;
995
+ /**
996
+ * The user assertion for the On-Behalf-Of flow.
997
+ */
998
+ userAssertionToken: string;
999
+ /**
1000
+ * Client secret should not be provided when certificate options are provided.
1001
+ */
1002
+ clientSecret?: never;
1003
+ }
1004
+
1005
+ /**
1006
+ * Optional parameters for the {@link OnBehalfOfCredential} class.
1007
+ */
1008
+ export declare type OnBehalfOfCredentialOptions = (OnBehalfOfCredentialSecretOptions | OnBehalfOfCredentialCertificateOptions) & TokenCredentialOptions & CredentialPersistenceOptions;
1009
+
1010
+ /**
1011
+ * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a secret.
1012
+ */
1013
+ export declare interface OnBehalfOfCredentialSecretOptions {
1014
+ /**
1015
+ * The Azure Active Directory tenant (directory) ID.
1016
+ */
1017
+ tenantId: string;
1018
+ /**
1019
+ * The client (application) ID of an App Registration in the tenant.
1020
+ */
1021
+ clientId: string;
1022
+ /**
1023
+ * A client secret that was generated for the App Registration.
1024
+ */
1025
+ clientSecret: string;
1026
+ /**
1027
+ * The user assertion for the On-Behalf-Of flow.
1028
+ */
1029
+ userAssertionToken: string;
1030
+ /**
1031
+ * The path to a PEM-encoded certificate should not be provided when the secret options are provided.
1032
+ */
1033
+ certificatePath?: never;
1034
+ /**
1035
+ * Option to include x5c header should not be provided when the secret options are provided.
1036
+ */
1037
+ sendCertificateChain?: never;
1038
+ }
1039
+
790
1040
  /**
791
1041
  * Serializes an `AuthenticationRecord` into a string.
792
1042
  *
@@ -802,20 +1052,75 @@ export declare class ManagedIdentityCredential implements TokenCredential {
802
1052
  * To later convert this string to a serialized `AuthenticationRecord`, please use the exported function `deserializeAuthenticationRecord()`.
803
1053
  */
804
1054
  export declare function serializeAuthenticationRecord(record: AuthenticationRecord): string;
1055
+
1056
+ /**
1057
+ * Parameters that enable token cache persistence in the Identity credentials.
1058
+ */
1059
+ export declare interface TokenCachePersistenceOptions {
1060
+ /**
1061
+ * If set to true, persistent token caching will be enabled for this credential instance.
1062
+ */
1063
+ enabled: boolean;
1064
+ /**
1065
+ * Unique identifier for the persistent token cache.
1066
+ *
1067
+ * Based on this identifier, the persistence file will be located in any of the following places:
1068
+ * - Darwin: '/Users/user/.IdentityService/<name>'
1069
+ * - Windows 8+: 'C:\\Users\\user\\AppData\\Local\\.IdentityService\\<name>'
1070
+ * - Linux: '/home/user/.IdentityService/<name>'
1071
+ */
1072
+ name?: string;
1073
+ /**
1074
+ * If set to true, the cache will be stored without encryption if no OS level user encryption is available.
1075
+ * When set to false, the PersistentTokenCache will throw an error if no OS level user encryption is available.
1076
+ */
1077
+ unsafeAllowUnencryptedStorage?: boolean;
1078
+ }
1079
+
805
1080
  export { TokenCredential }
806
1081
 
807
1082
  /**
808
1083
  * Provides options to configure how the Identity library makes authentication
809
1084
  * requests to Azure Active Directory.
810
1085
  */
811
- export declare interface TokenCredentialOptions extends PipelineOptions {
1086
+ export declare interface TokenCredentialOptions extends CommonClientOptions {
812
1087
  /**
813
1088
  * The authority host to use for authentication requests.
1089
+ * Possible values are available through {@link AzureAuthorityHosts}.
814
1090
  * The default is "https://login.microsoftonline.com".
815
1091
  */
816
1092
  authorityHost?: string;
817
1093
  }
818
1094
 
1095
+ /**
1096
+ * Extend Azure Identity with additional functionality. Pass a plugin from
1097
+ * a plugin package, such as:
1098
+ *
1099
+ * - `@azure/identity-cache-persistence`: provides persistent token caching
1100
+ * - `@azure/identity-vscode`: provides the dependencies of
1101
+ * `VisualStudioCodeCredential` and enables it
1102
+ *
1103
+ * Example:
1104
+ *
1105
+ * ```javascript
1106
+ * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
1107
+ *
1108
+ * import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity";
1109
+ * useIdentityPlugin(cachePersistencePlugin);
1110
+ *
1111
+ * // The plugin has the capability to extend `DefaultAzureCredential` and to
1112
+ * // add middleware to the underlying credentials, such as persistence.
1113
+ * const credential = new DefaultAzureCredential({
1114
+ * tokenCachePersistenceOptions: {
1115
+ * enabled: true
1116
+ * }
1117
+ * });
1118
+ * ```
1119
+ *
1120
+ * @param plugin - the plugin to register
1121
+ */
1122
+ export declare function useIdentityPlugin(plugin: IdentityPlugin): void;
1123
+
819
1124
  /**
820
1125
  * Enables authentication to Azure Active Directory with a user's
821
1126
  * username and password. This credential requires a high degree of
@@ -837,10 +1142,8 @@ export declare class UsernamePasswordCredential implements TokenCredential {
837
1142
  */
838
1143
  constructor(tenantId: string, clientId: string, username: string, password: string, options?: UsernamePasswordCredentialOptions);
839
1144
  /**
840
- * Authenticates with Azure Active Directory and returns an access token if
841
- * successful. If authentication cannot be performed at this time, this method may
842
- * return null. If an error occurs during authentication, an {@link AuthenticationError}
843
- * containing failure details will be thrown.
1145
+ * Authenticates with Azure Active Directory and returns an access token if successful.
1146
+ * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
844
1147
  *
845
1148
  * If the user provided the option `disableAutomaticAuthentication`,
846
1149
  * once the token can't be retrieved silently,
@@ -856,7 +1159,60 @@ export declare class UsernamePasswordCredential implements TokenCredential {
856
1159
  /**
857
1160
  * Defines options for the {@link UsernamePasswordCredential} class.
858
1161
  */
859
- export declare interface UsernamePasswordCredentialOptions extends TokenCredentialOptions {
1162
+ export declare interface UsernamePasswordCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
1163
+ }
1164
+
1165
+ /**
1166
+ * Connects to Azure using the credential provided by the VSCode extension 'Azure Account'.
1167
+ * Once the user has logged in via the extension, this credential can share the same refresh token
1168
+ * that is cached by the extension.
1169
+ */
1170
+ export declare class VisualStudioCodeCredential implements TokenCredential {
1171
+ private identityClient;
1172
+ private tenantId;
1173
+ private cloudName;
1174
+ /**
1175
+ * Creates an instance of VisualStudioCodeCredential to use for automatically authenticating via VSCode.
1176
+ *
1177
+ * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
1178
+ * `@azure/identity-vscode`. If this package is not installed and registered
1179
+ * using the plugin API (`useIdentityPlugin`), then authentication using
1180
+ * `VisualStudioCodeCredential` will not be available.
1181
+ *
1182
+ * @param options - Options for configuring the client which makes the authentication request.
1183
+ */
1184
+ constructor(options?: VisualStudioCodeCredentialOptions);
1185
+ /**
1186
+ * Runs preparations for any further getToken request.
1187
+ */
1188
+ private prepare;
1189
+ /**
1190
+ * The promise of the single preparation that will be executed at the first getToken request for an instance of this class.
1191
+ */
1192
+ private preparePromise;
1193
+ /**
1194
+ * Runs preparations for any further getToken, but only once.
1195
+ */
1196
+ private prepareOnce;
1197
+ /**
1198
+ * Returns the token found by searching VSCode's authentication cache or
1199
+ * returns null if no token could be found.
1200
+ *
1201
+ * @param scopes - The list of scopes for which the token will have access.
1202
+ * @param options - The options used to configure any requests this
1203
+ * `TokenCredential` implementation might make.
1204
+ */
1205
+ getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1206
+ }
1207
+
1208
+ /**
1209
+ * Provides options to configure the Visual Studio Code credential.
1210
+ */
1211
+ export declare interface VisualStudioCodeCredentialOptions extends TokenCredentialOptions {
1212
+ /**
1213
+ * Optionally pass in a Tenant ID to be used as part of the credential
1214
+ */
1215
+ tenantId?: string;
860
1216
  }
861
1217
 
862
1218
  export { }