@azure/identity 4.5.1-alpha.20241125.1 → 4.5.1-alpha.20241126.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/dist/identity.d.ts +0 -1841
@@ -1,1841 +0,0 @@
1
- import { AccessToken } from '@azure/core-auth';
2
- import type { AzureLogger } from '@azure/logger';
3
- import type { CommonClientOptions } from '@azure/core-client';
4
- import { GetTokenOptions } from '@azure/core-auth';
5
- import type { LogPolicyOptions } from '@azure/core-rest-pipeline';
6
- import { TokenCredential } from '@azure/core-auth';
7
- import type { TracingContext } from '@azure/core-auth';
8
-
9
- export { AccessToken }
10
-
11
- /**
12
- * Provides an `errors` array containing {@link AuthenticationError} instance
13
- * for authentication failures from credentials in a {@link ChainedTokenCredential}.
14
- */
15
- export declare class AggregateAuthenticationError extends Error {
16
- /**
17
- * The array of error objects that were thrown while trying to authenticate
18
- * with the credentials in a {@link ChainedTokenCredential}.
19
- */
20
- errors: any[];
21
- constructor(errors: any[], errorMessage?: string);
22
- }
23
-
24
- /**
25
- * The Error.name value of an AggregateAuthenticationError
26
- */
27
- export declare const AggregateAuthenticationErrorName = "AggregateAuthenticationError";
28
-
29
- /**
30
- * Provides details about a failure to authenticate with Azure Active
31
- * Directory. The `errorResponse` field contains more details about
32
- * the specific failure.
33
- */
34
- export declare class AuthenticationError extends Error {
35
- /**
36
- * The HTTP status code returned from the authentication request.
37
- */
38
- readonly statusCode: number;
39
- /**
40
- * The error response details.
41
- */
42
- readonly errorResponse: ErrorResponse;
43
- constructor(statusCode: number, errorBody: object | string | undefined | null, options?: {
44
- cause?: unknown;
45
- });
46
- }
47
-
48
- /**
49
- * The Error.name value of an AuthenticationError
50
- */
51
- export declare const AuthenticationErrorName = "AuthenticationError";
52
-
53
- /**
54
- * The record to use to find the cached tokens in the cache.
55
- */
56
- export declare interface AuthenticationRecord {
57
- /**
58
- * The associated authority, if used.
59
- */
60
- authority: string;
61
- /**
62
- * The home account Id.
63
- */
64
- homeAccountId: string;
65
- /**
66
- * The associated client ID.
67
- */
68
- clientId: string;
69
- /**
70
- * The associated tenant ID.
71
- */
72
- tenantId: string;
73
- /**
74
- * The username of the logged in account.
75
- */
76
- username: string;
77
- }
78
-
79
- /**
80
- * Error used to enforce authentication after trying to retrieve a token silently.
81
- */
82
- export declare class AuthenticationRequiredError extends Error {
83
- /**
84
- * The list of scopes for which the token will have access.
85
- */
86
- scopes: string[];
87
- /**
88
- * The options passed to the getToken request.
89
- */
90
- getTokenOptions?: GetTokenOptions;
91
- constructor(
92
- /**
93
- * 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.
94
- */
95
- options: AuthenticationRequiredErrorOptions);
96
- }
97
-
98
- /**
99
- * Optional parameters to the {@link AuthenticationRequiredError}
100
- */
101
- export declare interface AuthenticationRequiredErrorOptions {
102
- /**
103
- * The list of scopes for which the token will have access.
104
- */
105
- scopes: string[];
106
- /**
107
- * The options passed to the getToken request.
108
- */
109
- getTokenOptions?: GetTokenOptions;
110
- /**
111
- * The message of the error.
112
- */
113
- message?: string;
114
- /**
115
- * The underlying cause, if any, that caused the authentication to fail.
116
- */
117
- cause?: unknown;
118
- }
119
-
120
- /**
121
- * Provides options to configure how the Identity library
122
- * does authority validation during authentication requests
123
- * to Microsoft Entra ID.
124
- */
125
- export declare interface AuthorityValidationOptions {
126
- /**
127
- * The field determines whether instance discovery is performed when attempting to authenticate.
128
- * Setting this to `true` will completely disable both instance discovery and authority validation.
129
- * As a result, it's crucial to ensure that the configured authority host is valid and trustworthy.
130
- * This functionality is intended for use in scenarios where the metadata endpoint cannot be reached, such as in private clouds or Azure Stack.
131
- * The process of instance discovery entails retrieving authority metadata from https://login.microsoft.com/ to validate the authority.
132
- */
133
- disableInstanceDiscovery?: boolean;
134
- }
135
-
136
- /**
137
- * Enables authentication to Microsoft Entra ID using an authorization code
138
- * that was obtained through the authorization code flow, described in more detail
139
- * in the Microsoft Entra ID documentation:
140
- *
141
- * https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow
142
- */
143
- export declare class AuthorizationCodeCredential implements TokenCredential {
144
- private msalClient;
145
- private disableAutomaticAuthentication?;
146
- private authorizationCode;
147
- private redirectUri;
148
- private tenantId?;
149
- private additionallyAllowedTenantIds;
150
- private clientSecret?;
151
- /**
152
- * Creates an instance of AuthorizationCodeCredential with the details needed
153
- * to request an access token using an authentication that was obtained
154
- * from Microsoft Entra ID.
155
- *
156
- * It is currently necessary for the user of this credential to initiate
157
- * the authorization code flow to obtain an authorization code to be used
158
- * with this credential. A full example of this flow is provided here:
159
- *
160
- * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts
161
- *
162
- * @param tenantId - The Microsoft Entra tenant (directory) ID or name.
163
- * 'common' may be used when dealing with multi-tenant scenarios.
164
- * @param clientId - The client (application) ID of an App Registration in the tenant.
165
- * @param clientSecret - A client secret that was generated for the App Registration
166
- * @param authorizationCode - An authorization code that was received from following the
167
- authorization code flow. This authorization code must not
168
- have already been used to obtain an access token.
169
- * @param redirectUri - The redirect URI that was used to request the authorization code.
170
- Must be the same URI that is configured for the App Registration.
171
- * @param options - Options for configuring the client which makes the access token request.
172
- */
173
- constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: AuthorizationCodeCredentialOptions);
174
- /**
175
- * Creates an instance of AuthorizationCodeCredential with the details needed
176
- * to request an access token using an authentication that was obtained
177
- * from Microsoft Entra ID.
178
- *
179
- * It is currently necessary for the user of this credential to initiate
180
- * the authorization code flow to obtain an authorization code to be used
181
- * with this credential. A full example of this flow is provided here:
182
- *
183
- * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts
184
- *
185
- * @param tenantId - The Microsoft Entra tenant (directory) ID or name.
186
- * 'common' may be used when dealing with multi-tenant scenarios.
187
- * @param clientId - The client (application) ID of an App Registration in the tenant.
188
- * @param authorizationCode - An authorization code that was received from following the
189
- authorization code flow. This authorization code must not
190
- have already been used to obtain an access token.
191
- * @param redirectUri - The redirect URI that was used to request the authorization code.
192
- Must be the same URI that is configured for the App Registration.
193
- * @param options - Options for configuring the client which makes the access token request.
194
- */
195
- constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: AuthorizationCodeCredentialOptions);
196
- /**
197
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
198
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
199
- *
200
- * @param scopes - The list of scopes for which the token will have access.
201
- * @param options - The options used to configure any requests this
202
- * TokenCredential implementation might make.
203
- */
204
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
205
- }
206
-
207
- /**
208
- * Options for the {@link AuthorizationCodeCredential}
209
- */
210
- export declare interface AuthorizationCodeCredentialOptions extends MultiTenantTokenCredentialOptions, AuthorityValidationOptions {
211
- }
212
-
213
- /**
214
- * A list of known Azure authority hosts
215
- */
216
- export declare enum AzureAuthorityHosts {
217
- /**
218
- * China-based Azure Authority Host
219
- */
220
- AzureChina = "https://login.chinacloudapi.cn",
221
- /**
222
- * Germany-based Azure Authority Host
223
- *
224
- * @deprecated Microsoft Cloud Germany was closed on October 29th, 2021.
225
- *
226
- * */
227
- AzureGermany = "https://login.microsoftonline.de",
228
- /**
229
- * US Government Azure Authority Host
230
- */
231
- AzureGovernment = "https://login.microsoftonline.us",
232
- /**
233
- * Public Cloud Azure Authority Host
234
- */
235
- AzurePublicCloud = "https://login.microsoftonline.com"
236
- }
237
-
238
- /**
239
- * This credential will use the currently logged-in user login information
240
- * via the Azure CLI ('az') commandline tool.
241
- * To do so, it will read the user access token and expire time
242
- * with Azure CLI command "az account get-access-token".
243
- */
244
- export declare class AzureCliCredential implements TokenCredential {
245
- private tenantId?;
246
- private additionallyAllowedTenantIds;
247
- private timeout?;
248
- private subscription?;
249
- /**
250
- * Creates an instance of the {@link AzureCliCredential}.
251
- *
252
- * To use this credential, ensure that you have already logged
253
- * in via the 'az' tool using the command "az login" from the commandline.
254
- *
255
- * @param options - Options, to optionally allow multi-tenant requests.
256
- */
257
- constructor(options?: AzureCliCredentialOptions);
258
- /**
259
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
260
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
261
- *
262
- * @param scopes - The list of scopes for which the token will have access.
263
- * @param options - The options used to configure any requests this
264
- * TokenCredential implementation might make.
265
- */
266
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
267
- /**
268
- * Parses the raw JSON response from the Azure CLI into a usable AccessToken object
269
- *
270
- * @param rawResponse - The raw JSON response from the Azure CLI
271
- * @returns An access token with the expiry time parsed from the raw response
272
- *
273
- * The expiryTime of the credential's access token, in milliseconds, is calculated as follows:
274
- *
275
- * When available, expires_on (introduced in Azure CLI v2.54.0) will be preferred. Otherwise falls back to expiresOn.
276
- */
277
- private parseRawResponse;
278
- }
279
-
280
- /**
281
- * Options for the {@link AzureCliCredential}
282
- */
283
- export declare interface AzureCliCredentialOptions extends MultiTenantTokenCredentialOptions {
284
- /**
285
- * Allows specifying a tenant ID
286
- */
287
- tenantId?: string;
288
- /**
289
- * Process timeout configurable for making token requests, provided in milliseconds
290
- */
291
- processTimeoutInMs?: number;
292
- /**
293
- * Subscription is the name or ID of a subscription. Set this to acquire tokens for an account other
294
- * than the Azure CLI's current account.
295
- */
296
- subscription?: string;
297
- }
298
-
299
- /**
300
- * Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
301
- * resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
302
- * to Azure developers. It allows users to authenticate as a user and/or a service principal against
303
- * <a href="https://learn.microsoft.com/entra/fundamentals/">Microsoft Entra ID</a>. The
304
- * AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
305
- * the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
306
- * service principal and executes an Azure CLI command underneath to authenticate the application against
307
- * Microsoft Entra ID.
308
- *
309
- * <h2> Configure AzureDeveloperCliCredential </h2>
310
- *
311
- * To use this credential, the developer needs to authenticate locally in Azure Developer CLI using one of the
312
- * commands below:
313
- *
314
- * <ol>
315
- * <li>Run "azd auth login" in Azure Developer CLI to authenticate interactively as a user.</li>
316
- * <li>Run "azd auth login --client-id clientID --client-secret clientSecret
317
- * --tenant-id tenantID" to authenticate as a service principal.</li>
318
- * </ol>
319
- *
320
- * You may need to repeat this process after a certain time period, depending on the refresh token validity in your
321
- * organization. Generally, the refresh token validity period is a few weeks to a few months.
322
- * AzureDeveloperCliCredential will prompt you to sign in again.
323
- */
324
- export declare class AzureDeveloperCliCredential implements TokenCredential {
325
- private tenantId?;
326
- private additionallyAllowedTenantIds;
327
- private timeout?;
328
- /**
329
- * Creates an instance of the {@link AzureDeveloperCliCredential}.
330
- *
331
- * To use this credential, ensure that you have already logged
332
- * in via the 'azd' tool using the command "azd auth login" from the commandline.
333
- *
334
- * @param options - Options, to optionally allow multi-tenant requests.
335
- */
336
- constructor(options?: AzureDeveloperCliCredentialOptions);
337
- /**
338
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
339
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
340
- *
341
- * @param scopes - The list of scopes for which the token will have access.
342
- * @param options - The options used to configure any requests this
343
- * TokenCredential implementation might make.
344
- */
345
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
346
- }
347
-
348
- /**
349
- * Options for the {@link AzureDeveloperCliCredential}
350
- */
351
- export declare interface AzureDeveloperCliCredentialOptions extends MultiTenantTokenCredentialOptions {
352
- /**
353
- * Allows specifying a tenant ID
354
- */
355
- tenantId?: string;
356
- /**
357
- * Process timeout configurable for making token requests, provided in milliseconds
358
- */
359
- processTimeoutInMs?: number;
360
- }
361
-
362
- /**
363
- * This credential is designed to be used in Azure Pipelines with service connections
364
- * as a setup for workload identity federation.
365
- */
366
- export declare class AzurePipelinesCredential implements TokenCredential {
367
- private clientAssertionCredential;
368
- private identityClient;
369
- /**
370
- * AzurePipelinesCredential supports Federated Identity on Azure Pipelines through Service Connections.
371
- * @param tenantId - tenantId associated with the service connection
372
- * @param clientId - clientId associated with the service connection
373
- * @param serviceConnectionId - Unique ID for the service connection, as found in the querystring's resourceId key
374
- * @param systemAccessToken - The pipeline's <see href="https://learn.microsoft.com/azure/devops/pipelines/build/variables?view=azure-devops%26tabs=yaml#systemaccesstoken">System.AccessToken</see> value.
375
- * @param options - The identity client options to use for authentication.
376
- */
377
- constructor(tenantId: string, clientId: string, serviceConnectionId: string, systemAccessToken: string, options?: AzurePipelinesCredentialOptions);
378
- /**
379
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
380
- * If authentication fails, a {@link CredentialUnavailableError} or {@link AuthenticationError} will be thrown with the details of the failure.
381
- *
382
- * @param scopes - The list of scopes for which the token will have access.
383
- * @param options - The options used to configure any requests this
384
- * TokenCredential implementation might make.
385
- */
386
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
387
- /**
388
- *
389
- * @param oidcRequestUrl - oidc request url
390
- * @param systemAccessToken - system access token
391
- * @returns OIDC token from Azure Pipelines
392
- */
393
- private requestOidcToken;
394
- }
395
-
396
- /**
397
- * Optional parameters for the {@link AzurePipelinesCredential} class.
398
- */
399
- export declare interface AzurePipelinesCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions, AuthorityValidationOptions {
400
- }
401
-
402
- /**
403
- * This credential will use the currently logged-in user information from the
404
- * Azure PowerShell module. To do so, it will read the user access token and
405
- * expire time with Azure PowerShell command `Get-AzAccessToken -ResourceUrl {ResourceScope}`
406
- */
407
- export declare class AzurePowerShellCredential implements TokenCredential {
408
- private tenantId?;
409
- private additionallyAllowedTenantIds;
410
- private timeout?;
411
- /**
412
- * Creates an instance of the {@link AzurePowerShellCredential}.
413
- *
414
- * To use this credential:
415
- * - Install the Azure Az PowerShell module with:
416
- * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.
417
- * - You have already logged in to Azure PowerShell using the command
418
- * `Connect-AzAccount` from the command line.
419
- *
420
- * @param options - Options, to optionally allow multi-tenant requests.
421
- */
422
- constructor(options?: AzurePowerShellCredentialOptions);
423
- /**
424
- * Gets the access token from Azure PowerShell
425
- * @param resource - The resource to use when getting the token
426
- */
427
- private getAzurePowerShellAccessToken;
428
- /**
429
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
430
- * If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
431
- *
432
- * @param scopes - The list of scopes for which the token will have access.
433
- * @param options - The options used to configure any requests this TokenCredential implementation might make.
434
- */
435
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
436
- }
437
-
438
- /**
439
- * Options for the {@link AzurePowerShellCredential}
440
- */
441
- export declare interface AzurePowerShellCredentialOptions extends MultiTenantTokenCredentialOptions {
442
- /**
443
- * Allows specifying a tenant ID
444
- */
445
- tenantId?: string;
446
- /**
447
- * Process timeout configurable for making token requests, provided in milliseconds
448
- */
449
- processTimeoutInMs?: number;
450
- }
451
-
452
- /**
453
- * Configuration options for InteractiveBrowserCredential
454
- * to support WAM Broker Authentication.
455
- */
456
- export declare interface BrokerAuthOptions {
457
- /**
458
- * Options to allow broker authentication when using InteractiveBrowserCredential
459
- *
460
- */
461
- brokerOptions?: BrokerOptions;
462
- }
463
-
464
- /**
465
- * Parameters when WAM broker authentication is disabled.
466
- */
467
- export declare interface BrokerDisabledOptions {
468
- /**
469
- * If set to true, broker will be enabled for WAM support on Windows.
470
- */
471
- enabled: false;
472
- /**
473
- * If set to true, MSA account will be passed through, required for WAM authentication.
474
- */
475
- legacyEnableMsaPassthrough?: undefined;
476
- /**
477
- * Window handle for parent window, required for WAM authentication.
478
- */
479
- parentWindowHandle: undefined;
480
- }
481
-
482
- /**
483
- * Parameters when WAM broker authentication is enabled.
484
- */
485
- export declare interface BrokerEnabledOptions {
486
- /**
487
- * If set to true, broker will be enabled for WAM support on Windows.
488
- */
489
- enabled: true;
490
- /**
491
- * If set to true, MSA account will be passed through, required for WAM authentication.
492
- */
493
- legacyEnableMsaPassthrough?: boolean;
494
- /**
495
- * Window handle for parent window, required for WAM authentication.
496
- */
497
- parentWindowHandle: Uint8Array;
498
- /**
499
- * If set to true, the credential will attempt to use the default broker account for authentication before falling back to interactive authentication.
500
- * Default is set to false.
501
- */
502
- useDefaultBrokerAccount?: boolean;
503
- }
504
-
505
- /**
506
- * Parameters that enable WAM broker authentication in the InteractiveBrowserCredential.
507
- */
508
- export declare type BrokerOptions = BrokerEnabledOptions | BrokerDisabledOptions;
509
-
510
- /**
511
- * Shared configuration options for browser customization
512
- */
513
- export declare interface BrowserCustomizationOptions {
514
- /**
515
- * Shared configuration options for browser customization
516
- */
517
- browserCustomizationOptions?: {
518
- /**
519
- * Format for error messages for display in browser
520
- */
521
- errorMessage?: string;
522
- /**
523
- * Format for success messages for display in browser
524
- */
525
- successMessage?: string;
526
- };
527
- }
528
-
529
- /**
530
- * (Browser-only feature)
531
- * The "login style" to use in the authentication flow:
532
- * - "redirect" redirects the user to the authentication page and then
533
- * redirects them back to the page once authentication is completed.
534
- * - "popup" opens a new browser window through with the redirect flow
535
- * is initiated. The user's existing browser window does not leave
536
- * the current page
537
- */
538
- export declare type BrowserLoginStyle = "redirect" | "popup";
539
-
540
- /**
541
- * Enables multiple `TokenCredential` implementations to be tried in order until
542
- * one of the getToken methods returns an access token. For more information, see
543
- * [ChainedTokenCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-chainedtokencredential-for-granularity).
544
- */
545
- export declare class ChainedTokenCredential implements TokenCredential {
546
- private _sources;
547
- /**
548
- * Creates an instance of ChainedTokenCredential using the given credentials.
549
- *
550
- * @param sources - `TokenCredential` implementations to be tried in order.
551
- *
552
- * Example usage:
553
- * ```ts snippet:chained_token_credential_example
554
- * import { ClientSecretCredential, ChainedTokenCredential } from "@azure/identity";
555
- *
556
- * const tenantId = "<tenant-id>";
557
- * const clientId = "<client-id>";
558
- * const clientSecret = "<client-secret>";
559
- * const anotherClientId = "<another-client-id>";
560
- * const anotherSecret = "<another-client-secret>";
561
- * const firstCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
562
- * const secondCredential = new ClientSecretCredential(tenantId, anotherClientId, anotherSecret);
563
- * const credentialChain = new ChainedTokenCredential(firstCredential, secondCredential);
564
- * ```
565
- */
566
- constructor(...sources: TokenCredential[]);
567
- /**
568
- * Returns the first access token returned by one of the chained
569
- * `TokenCredential` implementations. Throws an {@link AggregateAuthenticationError}
570
- * when one or more credentials throws an {@link AuthenticationError} and
571
- * no credentials have returned an access token.
572
- *
573
- * This method is called automatically by Azure SDK client libraries. You may call this method
574
- * directly, but you must also handle token caching and token refreshing.
575
- *
576
- * @param scopes - The list of scopes for which the token will have access.
577
- * @param options - The options used to configure any requests this
578
- * `TokenCredential` implementation might make.
579
- */
580
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
581
- private getTokenInternal;
582
- }
583
-
584
- /**
585
- * Authenticates a service principal with a JWT assertion.
586
- */
587
- export declare class ClientAssertionCredential implements TokenCredential {
588
- private msalClient;
589
- private tenantId;
590
- private additionallyAllowedTenantIds;
591
- private getAssertion;
592
- private options;
593
- /**
594
- * Creates an instance of the ClientAssertionCredential with the details
595
- * needed to authenticate against Microsoft Entra ID with a client
596
- * assertion provided by the developer through the `getAssertion` function parameter.
597
- *
598
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
599
- * @param clientId - The client (application) ID of an App Registration in the tenant.
600
- * @param getAssertion - A function that retrieves the assertion for the credential to use.
601
- * @param options - Options for configuring the client which makes the authentication request.
602
- */
603
- constructor(tenantId: string, clientId: string, getAssertion: () => Promise<string>, options?: ClientAssertionCredentialOptions);
604
- /**
605
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
606
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
607
- *
608
- * @param scopes - The list of scopes for which the token will have access.
609
- * @param options - The options used to configure any requests this
610
- * TokenCredential implementation might make.
611
- */
612
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
613
- }
614
-
615
- /**
616
- * Options for the {@link ClientAssertionCredential}
617
- */
618
- export declare interface ClientAssertionCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions, AuthorityValidationOptions {
619
- }
620
-
621
- /**
622
- * Enables authentication to Microsoft Entra ID using a PEM-encoded
623
- * certificate that is assigned to an App Registration. More information
624
- * on how to configure certificate authentication can be found here:
625
- *
626
- * https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad
627
- *
628
- */
629
- export declare class ClientCertificateCredential implements TokenCredential {
630
- private tenantId;
631
- private additionallyAllowedTenantIds;
632
- private certificateConfiguration;
633
- private sendCertificateChain?;
634
- private msalClient;
635
- /**
636
- * Creates an instance of the ClientCertificateCredential with the details
637
- * needed to authenticate against Microsoft Entra ID with a certificate.
638
- *
639
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
640
- * @param clientId - The client (application) ID of an App Registration in the tenant.
641
- * @param certificatePath - The path to a PEM-encoded public/private key certificate on the filesystem.
642
- * @param options - Options for configuring the client which makes the authentication request.
643
- */
644
- constructor(tenantId: string, clientId: string, certificatePath: string, options?: ClientCertificateCredentialOptions);
645
- /**
646
- * Creates an instance of the ClientCertificateCredential with the details
647
- * needed to authenticate against Microsoft Entra ID with a certificate.
648
- *
649
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
650
- * @param clientId - The client (application) ID of an App Registration in the tenant.
651
- * @param configuration - Other parameters required, including the path of the certificate on the filesystem.
652
- * If the type is ignored, we will throw the value of the path to a PEM certificate.
653
- * @param options - Options for configuring the client which makes the authentication request.
654
- */
655
- constructor(tenantId: string, clientId: string, configuration: ClientCertificatePEMCertificatePath, options?: ClientCertificateCredentialOptions);
656
- /**
657
- * Creates an instance of the ClientCertificateCredential with the details
658
- * needed to authenticate against Microsoft Entra ID with a certificate.
659
- *
660
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
661
- * @param clientId - The client (application) ID of an App Registration in the tenant.
662
- * @param configuration - Other parameters required, including the PEM-encoded certificate as a string.
663
- * If the type is ignored, we will throw the value of the PEM-encoded certificate.
664
- * @param options - Options for configuring the client which makes the authentication request.
665
- */
666
- constructor(tenantId: string, clientId: string, configuration: ClientCertificatePEMCertificate, options?: ClientCertificateCredentialOptions);
667
- /**
668
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
669
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
670
- *
671
- * @param scopes - The list of scopes for which the token will have access.
672
- * @param options - The options used to configure any requests this
673
- * TokenCredential implementation might make.
674
- */
675
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
676
- private buildClientCertificate;
677
- }
678
-
679
- /**
680
- * Optional parameters for the {@link ClientCertificateCredential} class.
681
- */
682
- export declare interface ClientCertificateCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions, AuthorityValidationOptions {
683
- /**
684
- * Option to include x5c header for SubjectName and Issuer name authorization.
685
- * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
686
- */
687
- sendCertificateChain?: boolean;
688
- }
689
-
690
- /**
691
- * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.
692
- */
693
- export declare type ClientCertificateCredentialPEMConfiguration = ClientCertificatePEMCertificate | ClientCertificatePEMCertificatePath;
694
-
695
- /**
696
- * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate
697
- */
698
- export declare interface ClientCertificatePEMCertificate {
699
- /**
700
- * The PEM-encoded public/private key certificate on the filesystem.
701
- */
702
- certificate: string;
703
- /**
704
- * The password for the certificate file.
705
- */
706
- certificatePassword?: string;
707
- }
708
-
709
- /**
710
- * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.
711
- */
712
- export declare interface ClientCertificatePEMCertificatePath {
713
- /**
714
- * The path to the PEM-encoded public/private key certificate on the filesystem.
715
- */
716
- certificatePath: string;
717
- /**
718
- * The password for the certificate file.
719
- */
720
- certificatePassword?: string;
721
- }
722
-
723
- /**
724
- * Enables authentication to Microsoft Entra ID using a client secret
725
- * that was generated for an App Registration. More information on how
726
- * to configure a client secret can be found here:
727
- *
728
- * https://learn.microsoft.com/entra/identity-platform/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
729
- *
730
- */
731
- export declare class ClientSecretCredential implements TokenCredential {
732
- private tenantId;
733
- private additionallyAllowedTenantIds;
734
- private msalClient;
735
- private clientSecret;
736
- /**
737
- * Creates an instance of the ClientSecretCredential with the details
738
- * needed to authenticate against Microsoft Entra ID with a client
739
- * secret.
740
- *
741
- * @param tenantId - The Microsoft Entra tenant (directory) ID.
742
- * @param clientId - The client (application) ID of an App Registration in the tenant.
743
- * @param clientSecret - A client secret that was generated for the App Registration.
744
- * @param options - Options for configuring the client which makes the authentication request.
745
- */
746
- constructor(tenantId: string, clientId: string, clientSecret: string, options?: ClientSecretCredentialOptions);
747
- /**
748
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
749
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
750
- *
751
- * @param scopes - The list of scopes for which the token will have access.
752
- * @param options - The options used to configure any requests this
753
- * TokenCredential implementation might make.
754
- */
755
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
756
- }
757
-
758
- /**
759
- * Optional parameters for the {@link ClientSecretCredential} class.
760
- */
761
- export declare interface ClientSecretCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions, AuthorityValidationOptions {
762
- }
763
-
764
- /**
765
- * Shared configuration options for credentials that support persistent token
766
- * caching.
767
- */
768
- export declare interface CredentialPersistenceOptions {
769
- /**
770
- * Options to provide to the persistence layer (if one is available) when
771
- * storing credentials.
772
- *
773
- * You must first register a persistence provider plugin. See the
774
- * `@azure/identity-cache-persistence` package on NPM.
775
- *
776
- * Example:
777
- *
778
- * ```ts snippet:credential_persistence_options_example
779
- * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
780
- *
781
- * useIdentityPlugin(cachePersistencePlugin);
782
- * const credential = new DeviceCodeCredential({
783
- * tokenCachePersistenceOptions: {
784
- * enabled: true,
785
- * },
786
- * });
787
- * ```
788
- */
789
- tokenCachePersistenceOptions?: TokenCachePersistenceOptions;
790
- }
791
-
792
- /**
793
- * This signifies that the credential that was tried in a chained credential
794
- * was not available to be used as the credential. Rather than treating this as
795
- * an error that should halt the chain, it's caught and the chain continues
796
- */
797
- export declare class CredentialUnavailableError extends Error {
798
- constructor(message?: string, options?: {
799
- cause?: unknown;
800
- });
801
- }
802
-
803
- /**
804
- * The Error.name value of an CredentialUnavailable
805
- */
806
- export declare const CredentialUnavailableErrorName = "CredentialUnavailableError";
807
-
808
- /**
809
- * Provides a default {@link ChainedTokenCredential} configuration that works for most
810
- * applications that use Azure SDK client libraries. For more information, see
811
- * [DefaultAzureCredential overview](https://aka.ms/azsdk/js/identity/credential-chains#use-defaultazurecredential-for-flexibility).
812
- *
813
- * The following credential types will be tried, in order:
814
- *
815
- * - {@link EnvironmentCredential}
816
- * - {@link WorkloadIdentityCredential}
817
- * - {@link ManagedIdentityCredential}
818
- * - {@link AzureCliCredential}
819
- * - {@link AzurePowerShellCredential}
820
- * - {@link AzureDeveloperCliCredential}
821
- *
822
- * Consult the documentation of these credential types for more information
823
- * on how they attempt authentication.
824
- */
825
- export declare class DefaultAzureCredential extends ChainedTokenCredential {
826
- /**
827
- * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}.
828
- *
829
- * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.
830
- */
831
- constructor(options?: DefaultAzureCredentialClientIdOptions);
832
- /**
833
- * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialResourceIdOptions}.
834
- *
835
- * @param options - Optional parameters. See {@link DefaultAzureCredentialResourceIdOptions}.
836
- */
837
- constructor(options?: DefaultAzureCredentialResourceIdOptions);
838
- /**
839
- * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialOptions}.
840
- *
841
- * @param options - Optional parameters. See {@link DefaultAzureCredentialOptions}.
842
- */
843
- constructor(options?: DefaultAzureCredentialOptions);
844
- }
845
-
846
- /**
847
- * Provides options to configure the {@link DefaultAzureCredential} class.
848
- * This variation supports `managedIdentityClientId` and not `managedIdentityResourceId`, since only one of both is supported.
849
- */
850
- export declare interface DefaultAzureCredentialClientIdOptions extends DefaultAzureCredentialOptions {
851
- /**
852
- * Optionally pass in a user assigned client ID to be used by the {@link ManagedIdentityCredential}.
853
- * This client ID can also be passed through to the {@link ManagedIdentityCredential} through the environment variable: AZURE_CLIENT_ID.
854
- */
855
- managedIdentityClientId?: string;
856
- /**
857
- * Optionally pass in a user assigned client ID to be used by the {@link WorkloadIdentityCredential}.
858
- * This client ID can also be passed through to the {@link WorkloadIdentityCredential} through the environment variable: AZURE_CLIENT_ID.
859
- */
860
- workloadIdentityClientId?: string;
861
- }
862
-
863
- /**
864
- * Provides options to configure the {@link DefaultAzureCredential} class.
865
- */
866
- export declare interface DefaultAzureCredentialOptions extends MultiTenantTokenCredentialOptions, AuthorityValidationOptions {
867
- /**
868
- * Optionally pass in a Tenant ID to be used as part of the credential.
869
- * By default it may use a generic tenant ID depending on the underlying credential.
870
- */
871
- tenantId?: string;
872
- /**
873
- * Timeout configurable for making token requests for developer credentials, namely, {@link AzurePowershellCredential},
874
- * {@link AzureDeveloperCliCredential} and {@link AzureCliCredential}.
875
- * Process timeout for credentials should be provided in milliseconds.
876
- */
877
- processTimeoutInMs?: number;
878
- }
879
-
880
- /**
881
- * Provides options to configure the {@link DefaultAzureCredential} class.
882
- * This variation supports `managedIdentityResourceId` and not `managedIdentityClientId`, since only one of both is supported.
883
- */
884
- export declare interface DefaultAzureCredentialResourceIdOptions extends DefaultAzureCredentialOptions {
885
- /**
886
- * Optionally pass in a resource ID to be used by the {@link ManagedIdentityCredential}.
887
- * In scenarios such as when user assigned identities are created using an ARM template,
888
- * where the resource Id of the identity is known but the client Id can't be known ahead of time,
889
- * this parameter allows programs to use these user assigned identities
890
- * without having to first determine the client Id of the created identity.
891
- */
892
- managedIdentityResourceId: string;
893
- }
894
-
895
- /**
896
- * Deserializes a previously serialized authentication record from a string into an object.
897
- *
898
- * The input string must contain the following properties:
899
- *
900
- * - "authority"
901
- * - "homeAccountId"
902
- * - "clientId"
903
- * - "tenantId"
904
- * - "username"
905
- * - "version"
906
- *
907
- * If the version we receive is unsupported, an error will be thrown.
908
- *
909
- * At the moment, the only available version is: "1.0", which is always set when the authentication record is serialized.
910
- *
911
- * @param serializedRecord - Authentication record previously serialized into string.
912
- * @returns AuthenticationRecord.
913
- */
914
- export declare function deserializeAuthenticationRecord(serializedRecord: string): AuthenticationRecord;
915
-
916
- /**
917
- * Enables authentication to Microsoft Entra ID using a device code
918
- * that the user can enter into https://microsoft.com/devicelogin.
919
- */
920
- export declare class DeviceCodeCredential implements TokenCredential {
921
- private tenantId?;
922
- private additionallyAllowedTenantIds;
923
- private disableAutomaticAuthentication?;
924
- private msalClient;
925
- private userPromptCallback;
926
- /**
927
- * Creates an instance of DeviceCodeCredential with the details needed
928
- * to initiate the device code authorization flow with Microsoft Entra ID.
929
- *
930
- * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
931
- *
932
- * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
933
- *
934
- * ```ts snippet:device_code_credential_example
935
- * import { DeviceCodeCredential } from "@azure/identity";
936
- *
937
- * const credential = new DeviceCodeCredential({
938
- * tenantId: process.env.AZURE_TENANT_ID,
939
- * clientId: process.env.AZURE_CLIENT_ID,
940
- * userPromptCallback: (info) => {
941
- * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
942
- * },
943
- * });
944
- * ```
945
- *
946
- * @param options - Options for configuring the client which makes the authentication requests.
947
- */
948
- constructor(options?: DeviceCodeCredentialOptions);
949
- /**
950
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
951
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
952
- *
953
- * If the user provided the option `disableAutomaticAuthentication`,
954
- * once the token can't be retrieved silently,
955
- * this method won't attempt to request user interaction to retrieve the token.
956
- *
957
- * @param scopes - The list of scopes for which the token will have access.
958
- * @param options - The options used to configure any requests this
959
- * TokenCredential implementation might make.
960
- */
961
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
962
- /**
963
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
964
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
965
- *
966
- * If the token can't be retrieved silently, this method will always generate a challenge for the user.
967
- *
968
- * @param scopes - The list of scopes for which the token will have access.
969
- * @param options - The options used to configure any requests this
970
- * TokenCredential implementation might make.
971
- */
972
- authenticate(scopes: string | string[], options?: GetTokenOptions): Promise<AuthenticationRecord | undefined>;
973
- }
974
-
975
- /**
976
- * Defines options for the InteractiveBrowserCredential class for Node.js.
977
- */
978
- export declare interface DeviceCodeCredentialOptions extends InteractiveCredentialOptions, CredentialPersistenceOptions {
979
- /**
980
- * The Microsoft Entra tenant (directory) ID.
981
- */
982
- tenantId?: string;
983
- /**
984
- * Client ID of the Microsoft Entra application that users will sign into.
985
- * It is recommended that developers register their applications and assign appropriate roles.
986
- * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.
987
- * If not specified, users will authenticate to an Azure development application,
988
- * which is not recommended for production scenarios.
989
- */
990
- clientId?: string;
991
- /**
992
- * A callback function that will be invoked to show {@link DeviceCodeInfo} to the user.
993
- * If left unassigned, we will automatically log the device code information
994
- * and the authentication instructions in the console.
995
- */
996
- userPromptCallback?: DeviceCodePromptCallback;
997
- }
998
-
999
- /**
1000
- * Provides the user code and verification URI where the code must be
1001
- * entered. Also provides a message to display to the user which
1002
- * contains an instruction with these details.
1003
- */
1004
- export declare interface DeviceCodeInfo {
1005
- /**
1006
- * The device code that the user must enter into the verification page.
1007
- */
1008
- userCode: string;
1009
- /**
1010
- * The verification URI to which the user must navigate to enter the device
1011
- * code.
1012
- */
1013
- verificationUri: string;
1014
- /**
1015
- * A message that may be shown to the user to instruct them on how to enter
1016
- * the device code in the page specified by the verification URI.
1017
- */
1018
- message: string;
1019
- }
1020
-
1021
- /**
1022
- * Defines the signature of a callback which will be passed to
1023
- * DeviceCodeCredential for the purpose of displaying authentication
1024
- * details to the user.
1025
- */
1026
- export declare type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo) => void;
1027
-
1028
- /**
1029
- * Enables authentication to Microsoft Entra ID using a client secret or certificate, or as a user
1030
- * with a username and password.
1031
- */
1032
- export declare class EnvironmentCredential implements TokenCredential {
1033
- private _credential?;
1034
- /**
1035
- * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
1036
- *
1037
- * Required environment variables:
1038
- * - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
1039
- * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
1040
- *
1041
- * If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
1042
- * - `AZURE_ADDITIONALLY_ALLOWED_TENANTS`: For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens with a single semicolon delimited string. Use * to allow all tenants.
1043
- *
1044
- * Environment variables used for client credential authentication:
1045
- * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
1046
- * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
1047
- * - `AZURE_CLIENT_CERTIFICATE_PASSWORD`: (optional) password for the certificate file.
1048
- * - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN`: (optional) indicates that the certificate chain should be set in x5c header to support subject name / issuer based authentication.
1049
- *
1050
- * Alternatively, users can provide environment variables for username and password authentication:
1051
- * - `AZURE_USERNAME`: Username to authenticate with.
1052
- * - `AZURE_PASSWORD`: Password to authenticate with.
1053
- *
1054
- * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.
1055
- * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.
1056
- *
1057
- * @param options - Options for configuring the client which makes the authentication request.
1058
- */
1059
- constructor(options?: EnvironmentCredentialOptions);
1060
- /**
1061
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1062
- *
1063
- * @param scopes - The list of scopes for which the token will have access.
1064
- * @param options - Optional parameters. See {@link GetTokenOptions}.
1065
- */
1066
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1067
- }
1068
-
1069
- /**
1070
- * Enables authentication to Microsoft Entra ID depending on the available environment variables.
1071
- * Defines options for the EnvironmentCredential class.
1072
- */
1073
- export declare interface EnvironmentCredentialOptions extends MultiTenantTokenCredentialOptions, AuthorityValidationOptions {
1074
- }
1075
-
1076
- /**
1077
- * See the official documentation for more details:
1078
- *
1079
- * https://learn.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-oauth-code#error-response-1
1080
- *
1081
- * NOTE: This documentation is for v1 OAuth support but the same error
1082
- * response details still apply to v2.
1083
- */
1084
- export declare interface ErrorResponse {
1085
- /**
1086
- * The string identifier for the error.
1087
- */
1088
- error: string;
1089
- /**
1090
- * The error's description.
1091
- */
1092
- errorDescription: string;
1093
- /**
1094
- * An array of codes pertaining to the error(s) that occurred.
1095
- */
1096
- errorCodes?: number[];
1097
- /**
1098
- * The timestamp at which the error occurred.
1099
- */
1100
- timestamp?: string;
1101
- /**
1102
- * The trace identifier for this error occurrence.
1103
- */
1104
- traceId?: string;
1105
- /**
1106
- * The correlation ID to be used for tracking the source of the error.
1107
- */
1108
- correlationId?: string;
1109
- }
1110
-
1111
- /**
1112
- * Returns a callback that provides a bearer token.
1113
- * For example, the bearer token can be used to authenticate a request as follows:
1114
- * ```ts snippet:token_provider_example
1115
- * import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity";
1116
- * import { createPipelineRequest } from "@azure/core-rest-pipeline";
1117
- *
1118
- * const credential = new DefaultAzureCredential();
1119
- * const scope = "https://cognitiveservices.azure.com/.default";
1120
- * const getAccessToken = getBearerTokenProvider(credential, scope);
1121
- * const token = await getAccessToken();
1122
- * // usage
1123
- * const request = createPipelineRequest({ url: "https://example.com" });
1124
- * request.headers.set("Authorization", `Bearer ${token}`);
1125
- * ```
1126
- *
1127
- * @param credential - The credential used to authenticate the request.
1128
- * @param scopes - The scopes required for the bearer token.
1129
- * @param options - Options to configure the token provider.
1130
- * @returns a callback that provides a bearer token.
1131
- */
1132
- export declare function getBearerTokenProvider(credential: TokenCredential, scopes: string | string[], options?: GetBearerTokenProviderOptions): () => Promise<string>;
1133
-
1134
- /**
1135
- * The options to configure the token provider.
1136
- */
1137
- export declare interface GetBearerTokenProviderOptions {
1138
- /** The abort signal to abort requests to get tokens */
1139
- abortSignal?: AbortSignal;
1140
- /** The tracing options for the requests to get tokens */
1141
- tracingOptions?: {
1142
- /**
1143
- * Tracing Context for the current request to get a token.
1144
- */
1145
- tracingContext?: TracingContext;
1146
- };
1147
- }
1148
-
1149
- /**
1150
- * Returns a new instance of the {@link DefaultAzureCredential}.
1151
- */
1152
- export declare function getDefaultAzureCredential(): TokenCredential;
1153
-
1154
- export { GetTokenOptions }
1155
-
1156
- /**
1157
- * The type of an Azure Identity plugin, a function accepting a plugin
1158
- * context.
1159
- */
1160
- export declare type IdentityPlugin = (context: unknown) => void;
1161
-
1162
- /**
1163
- * Enables authentication to Microsoft Entra ID inside of the web browser
1164
- * using the interactive login flow.
1165
- */
1166
- export declare class InteractiveBrowserCredential implements TokenCredential {
1167
- private tenantId?;
1168
- private additionallyAllowedTenantIds;
1169
- private msalClient;
1170
- private disableAutomaticAuthentication?;
1171
- private browserCustomizationOptions;
1172
- private loginHint?;
1173
- /**
1174
- * Creates an instance of InteractiveBrowserCredential with the details needed.
1175
- *
1176
- * This credential uses the [Authorization Code Flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow).
1177
- * On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
1178
- * 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.
1179
- *
1180
- * For Node.js, if a `clientId` is provided, the Microsoft Entra application will need to be configured to have a "Mobile and desktop applications" redirect endpoint.
1181
- * Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://learn.microsoft.com/entra/identity-platform/scenario-desktop-app-registration#redirect-uris).
1182
- *
1183
- * @param options - Options for configuring the client which makes the authentication requests.
1184
- */
1185
- constructor(options: InteractiveBrowserCredentialNodeOptions | InteractiveBrowserCredentialInBrowserOptions);
1186
- /**
1187
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1188
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1189
- *
1190
- * If the user provided the option `disableAutomaticAuthentication`,
1191
- * once the token can't be retrieved silently,
1192
- * this method won't attempt to request user interaction to retrieve the token.
1193
- *
1194
- * @param scopes - The list of scopes for which the token will have access.
1195
- * @param options - The options used to configure any requests this
1196
- * TokenCredential implementation might make.
1197
- */
1198
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1199
- /**
1200
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1201
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1202
- *
1203
- * If the token can't be retrieved silently, this method will always generate a challenge for the user.
1204
- *
1205
- * On Node.js, this credential has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
1206
- * PKCE is a security feature that mitigates authentication code interception attacks.
1207
- *
1208
- * @param scopes - The list of scopes for which the token will have access.
1209
- * @param options - The options used to configure any requests this
1210
- * TokenCredential implementation might make.
1211
- */
1212
- authenticate(scopes: string | string[], options?: GetTokenOptions): Promise<AuthenticationRecord | undefined>;
1213
- }
1214
-
1215
- /**
1216
- * Defines the common options for the InteractiveBrowserCredential class.
1217
- */
1218
- export declare interface InteractiveBrowserCredentialInBrowserOptions extends InteractiveCredentialOptions {
1219
- /**
1220
- * Gets the redirect URI of the application. This should be same as the value
1221
- * in the application registration portal. Defaults to `window.location.href`.
1222
- * This field is no longer required for Node.js.
1223
- */
1224
- redirectUri?: string | (() => string);
1225
- /**
1226
- * The Microsoft Entra tenant (directory) ID.
1227
- */
1228
- tenantId?: string;
1229
- /**
1230
- * The Client ID of the Microsoft Entra application that users will sign into.
1231
- * This parameter is required on the browser.
1232
- * Developers need to register their applications and assign appropriate roles.
1233
- * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.
1234
- */
1235
- clientId: string;
1236
- /**
1237
- * Specifies whether a redirect or a popup window should be used to
1238
- * initiate the user authentication flow. Possible values are "redirect"
1239
- * or "popup" (default) for browser and "popup" (default) for node.
1240
- *
1241
- */
1242
- loginStyle?: BrowserLoginStyle;
1243
- /**
1244
- * loginHint allows a user name to be pre-selected for interactive logins.
1245
- * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.
1246
- */
1247
- loginHint?: string;
1248
- }
1249
-
1250
- /**
1251
- * Defines the common options for the InteractiveBrowserCredential class.
1252
- */
1253
- export declare interface InteractiveBrowserCredentialNodeOptions extends InteractiveCredentialOptions, CredentialPersistenceOptions, BrowserCustomizationOptions, BrokerAuthOptions {
1254
- /**
1255
- * Gets the redirect URI of the application. This should be same as the value
1256
- * in the application registration portal. Defaults to `window.location.href`.
1257
- * This field is no longer required for Node.js.
1258
- */
1259
- redirectUri?: string | (() => string);
1260
- /**
1261
- * The Microsoft Entra tenant (directory) ID.
1262
- */
1263
- tenantId?: string;
1264
- /**
1265
- * The Client ID of the Microsoft Entra application that users will sign into.
1266
- * It is recommended that developers register their applications and assign appropriate roles.
1267
- * For more information, visit https://aka.ms/identity/AppRegistrationAndRoleAssignment.
1268
- * If not specified, users will authenticate to an Azure development application,
1269
- * which is not recommended for production scenarios.
1270
- */
1271
- clientId?: string;
1272
- /**
1273
- * loginHint allows a user name to be pre-selected for interactive logins.
1274
- * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.
1275
- */
1276
- loginHint?: string;
1277
- }
1278
-
1279
- /**
1280
- * Common constructor options for the Identity credentials that requires user interaction.
1281
- */
1282
- export declare interface InteractiveCredentialOptions extends MultiTenantTokenCredentialOptions, AuthorityValidationOptions {
1283
- /**
1284
- * Result of a previous authentication that can be used to retrieve the cached credentials of each individual account.
1285
- * This is necessary to provide in case the application wants to work with more than one account per
1286
- * Client ID and Tenant ID pair.
1287
- *
1288
- * This record can be retrieved by calling to the credential's `authenticate()` method, as follows:
1289
- *
1290
- * const authenticationRecord = await credential.authenticate();
1291
- *
1292
- */
1293
- authenticationRecord?: AuthenticationRecord;
1294
- /**
1295
- * Makes getToken throw if a manual authentication is necessary.
1296
- * Developers will need to call to `authenticate()` to control when to manually authenticate.
1297
- */
1298
- disableAutomaticAuthentication?: boolean;
1299
- }
1300
-
1301
- /**
1302
- * The AzureLogger used for all clients within the identity package
1303
- */
1304
- export declare const logger: AzureLogger;
1305
-
1306
- /**
1307
- * Attempts authentication using a managed identity available at the deployment environment.
1308
- * This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
1309
- * Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
1310
- *
1311
- * More information about configuring managed identities can be found here:
1312
- * https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
1313
- */
1314
- export declare class ManagedIdentityCredential implements TokenCredential {
1315
- private managedIdentityApp;
1316
- private identityClient;
1317
- private clientId?;
1318
- private resourceId?;
1319
- private objectId?;
1320
- private msiRetryConfig;
1321
- private isAvailableIdentityClient;
1322
- /**
1323
- * Creates an instance of ManagedIdentityCredential with the client ID of a
1324
- * user-assigned identity, or app registration (when working with AKS pod-identity).
1325
- *
1326
- * @param clientId - The client ID of the user-assigned identity, or app registration (when working with AKS pod-identity).
1327
- * @param options - Options for configuring the client which makes the access token request.
1328
- */
1329
- constructor(clientId: string, options?: TokenCredentialOptions);
1330
- /**
1331
- * Creates an instance of ManagedIdentityCredential with a client ID
1332
- *
1333
- * @param options - Options for configuring the client which makes the access token request.
1334
- */
1335
- constructor(options?: ManagedIdentityCredentialClientIdOptions);
1336
- /**
1337
- * Creates an instance of ManagedIdentityCredential with a resource ID
1338
- *
1339
- * @param options - Options for configuring the resource which makes the access token request.
1340
- */
1341
- constructor(options?: ManagedIdentityCredentialResourceIdOptions);
1342
- /**
1343
- * Creates an instance of ManagedIdentityCredential with an object ID
1344
- *
1345
- * @param options - Options for configuring the resource which makes the access token request.
1346
- */
1347
- constructor(options?: ManagedIdentityCredentialObjectIdOptions);
1348
- /**
1349
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1350
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1351
- * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
1352
- *
1353
- * @param scopes - The list of scopes for which the token will have access.
1354
- * @param options - The options used to configure any requests this
1355
- * TokenCredential implementation might make.
1356
- */
1357
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1358
- /**
1359
- * Ensures the validity of the MSAL token
1360
- */
1361
- private ensureValidMsalToken;
1362
- }
1363
-
1364
- /**
1365
- * Options to send on the {@link ManagedIdentityCredential} constructor.
1366
- * This variation supports `clientId` and not `resourceId`, since only one of both is supported.
1367
- */
1368
- export declare interface ManagedIdentityCredentialClientIdOptions extends TokenCredentialOptions {
1369
- /**
1370
- * The client ID of the user - assigned identity, or app registration(when working with AKS pod - identity).
1371
- */
1372
- clientId?: string;
1373
- }
1374
-
1375
- /**
1376
- * Options to send on the {@link ManagedIdentityCredential} constructor.
1377
- * This variation supports `objectId` as a constructor argument.
1378
- */
1379
- export declare interface ManagedIdentityCredentialObjectIdOptions extends TokenCredentialOptions {
1380
- /**
1381
- * Allows specifying the object ID of the underlying service principal used to authenticate a user-assigned managed identity.
1382
- * This is an alternative to providing a client ID or resource ID and is not required for system-assigned managed identities.
1383
- */
1384
- objectId: string;
1385
- }
1386
-
1387
- /**
1388
- * Options to send on the {@link ManagedIdentityCredential} constructor.
1389
- * This variation supports `resourceId` and not `clientId`, since only one of both is supported.
1390
- */
1391
- export declare interface ManagedIdentityCredentialResourceIdOptions extends TokenCredentialOptions {
1392
- /**
1393
- * Allows specifying a custom resource Id.
1394
- * In scenarios such as when user assigned identities are created using an ARM template,
1395
- * where the resource Id of the identity is known but the client Id can't be known ahead of time,
1396
- * this parameter allows programs to use these user assigned identities
1397
- * without having to first determine the client Id of the created identity.
1398
- */
1399
- resourceId: string;
1400
- }
1401
-
1402
- /**
1403
- * Options for multi-tenant applications which allows for additionally allowed tenants.
1404
- */
1405
- export declare interface MultiTenantTokenCredentialOptions extends TokenCredentialOptions {
1406
- /**
1407
- * For multi-tenant applications, specifies additional tenants for which the credential may acquire tokens.
1408
- * Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the application is installed.
1409
- */
1410
- additionallyAllowedTenants?: string[];
1411
- }
1412
-
1413
- /**
1414
- * Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-on-behalf-of-flow).
1415
- */
1416
- export declare class OnBehalfOfCredential implements TokenCredential {
1417
- private tenantId;
1418
- private additionallyAllowedTenantIds;
1419
- private msalClient;
1420
- private sendCertificateChain?;
1421
- private certificatePath?;
1422
- private clientSecret?;
1423
- private userAssertionToken;
1424
- private clientAssertion?;
1425
- /**
1426
- * Creates an instance of the {@link OnBehalfOfCredential} with the details
1427
- * needed to authenticate against Microsoft Entra ID with path to a PEM certificate,
1428
- * and an user assertion.
1429
- *
1430
- * Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
1431
- *
1432
- * ```ts snippet:on_behalf_of_credential_pem_example
1433
- * import { OnBehalfOfCredential } from "@azure/identity";
1434
- * import { KeyClient } from "@azure/keyvault-keys";
1435
- *
1436
- * const tokenCredential = new OnBehalfOfCredential({
1437
- * tenantId: "tenant-id",
1438
- * clientId: "client-id",
1439
- * certificatePath: "/path/to/certificate.pem",
1440
- * userAssertionToken: "access-token",
1441
- * });
1442
- * const client = new KeyClient("vault-url", tokenCredential);
1443
- * await client.getKey("key-name");
1444
- * ```
1445
- *
1446
- * @param options - Optional parameters, generally common across credentials.
1447
- */
1448
- constructor(options: OnBehalfOfCredentialCertificateOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
1449
- /**
1450
- * Creates an instance of the {@link OnBehalfOfCredential} with the details
1451
- * needed to authenticate against Microsoft Entra ID with a client
1452
- * secret and an user assertion.
1453
- *
1454
- * Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
1455
- *
1456
- * ```ts snippet:on_behalf_of_credential_secret_example
1457
- * import { OnBehalfOfCredential } from "@azure/identity";
1458
- * import { KeyClient } from "@azure/keyvault-keys";
1459
- *
1460
- * const tokenCredential = new OnBehalfOfCredential({
1461
- * tenantId: "tenant-id",
1462
- * clientId: "client-id",
1463
- * clientSecret: "client-secret",
1464
- * userAssertionToken: "access-token",
1465
- * });
1466
- * const client = new KeyClient("vault-url", tokenCredential);
1467
- * await client.getKey("key-name");
1468
- * ```
1469
- *
1470
- * @param options - Optional parameters, generally common across credentials.
1471
- */
1472
- constructor(options: OnBehalfOfCredentialSecretOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
1473
- /**
1474
- * Creates an instance of the {@link OnBehalfOfCredential} with the details
1475
- * needed to authenticate against Microsoft Entra ID with a client `getAssertion`
1476
- * and an user assertion.
1477
- *
1478
- * Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
1479
- *
1480
- * ```ts snippet:on_behalf_of_credential_assertion_example
1481
- * import { OnBehalfOfCredential } from "@azure/identity";
1482
- * import { KeyClient } from "@azure/keyvault-keys";
1483
- *
1484
- * const tokenCredential = new OnBehalfOfCredential({
1485
- * tenantId: "tenant-id",
1486
- * clientId: "client-id",
1487
- * getAssertion: () => {
1488
- * return Promise.resolve("my-jwt");
1489
- * },
1490
- * userAssertionToken: "access-token",
1491
- * });
1492
- * const client = new KeyClient("vault-url", tokenCredential);
1493
- * await client.getKey("key-name");
1494
- * ```
1495
- *
1496
- * @param options - Optional parameters, generally common across credentials.
1497
- */
1498
- constructor(options: OnBehalfOfCredentialAssertionOptions & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions);
1499
- /**
1500
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1501
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1502
- *
1503
- * @param scopes - The list of scopes for which the token will have access.
1504
- * @param options - The options used to configure the underlying network requests.
1505
- */
1506
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1507
- private buildClientCertificate;
1508
- private parseCertificate;
1509
- }
1510
-
1511
- /**
1512
- * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with an assertion.
1513
- */
1514
- export declare interface OnBehalfOfCredentialAssertionOptions {
1515
- /**
1516
- * The Microsoft Entra tenant (directory) ID.
1517
- */
1518
- tenantId: string;
1519
- /**
1520
- * The client (application) ID of an App Registration in the tenant.
1521
- */
1522
- clientId: string;
1523
- /**
1524
- * A function that retrieves the client assertion for the credential to use
1525
- */
1526
- getAssertion: () => Promise<string>;
1527
- /**
1528
- * The user assertion for the On-Behalf-Of flow.
1529
- */
1530
- userAssertionToken: string;
1531
- }
1532
-
1533
- /**
1534
- * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a certificate.
1535
- */
1536
- export declare interface OnBehalfOfCredentialCertificateOptions {
1537
- /**
1538
- * The Microsoft Entra tenant (directory) ID.
1539
- */
1540
- tenantId: string;
1541
- /**
1542
- * The client (application) ID of an App Registration in the tenant.
1543
- */
1544
- clientId: string;
1545
- /**
1546
- * The path to a PEM-encoded public/private key certificate on the filesystem.
1547
- */
1548
- certificatePath: string;
1549
- /**
1550
- * The user assertion for the On-Behalf-Of flow.
1551
- */
1552
- userAssertionToken: string;
1553
- /**
1554
- * Option to include x5c header for SubjectName and Issuer name authorization.
1555
- * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
1556
- */
1557
- sendCertificateChain?: boolean;
1558
- }
1559
-
1560
- /**
1561
- * Optional parameters for the {@link OnBehalfOfCredential} class.
1562
- */
1563
- export declare type OnBehalfOfCredentialOptions = (OnBehalfOfCredentialSecretOptions | OnBehalfOfCredentialCertificateOptions | OnBehalfOfCredentialAssertionOptions) & MultiTenantTokenCredentialOptions & CredentialPersistenceOptions & AuthorityValidationOptions;
1564
-
1565
- /**
1566
- * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a secret.
1567
- */
1568
- export declare interface OnBehalfOfCredentialSecretOptions {
1569
- /**
1570
- * The Microsoft Entra tenant (directory) ID.
1571
- */
1572
- tenantId: string;
1573
- /**
1574
- * The client (application) ID of an App Registration in the tenant.
1575
- */
1576
- clientId: string;
1577
- /**
1578
- * A client secret that was generated for the App Registration.
1579
- */
1580
- clientSecret: string;
1581
- /**
1582
- * The user assertion for the On-Behalf-Of flow.
1583
- */
1584
- userAssertionToken: string;
1585
- }
1586
-
1587
- /**
1588
- * Serializes an `AuthenticationRecord` into a string.
1589
- *
1590
- * The output of a serialized authentication record will contain the following properties:
1591
- *
1592
- * - "authority"
1593
- * - "homeAccountId"
1594
- * - "clientId"
1595
- * - "tenantId"
1596
- * - "username"
1597
- * - "version"
1598
- *
1599
- * To later convert this string to a serialized `AuthenticationRecord`, please use the exported function `deserializeAuthenticationRecord()`.
1600
- */
1601
- export declare function serializeAuthenticationRecord(record: AuthenticationRecord): string;
1602
-
1603
- /**
1604
- * Parameters that enable token cache persistence in the Identity credentials.
1605
- */
1606
- export declare interface TokenCachePersistenceOptions {
1607
- /**
1608
- * If set to true, persistent token caching will be enabled for this credential instance.
1609
- */
1610
- enabled: boolean;
1611
- /**
1612
- * Unique identifier for the persistent token cache.
1613
- *
1614
- * Based on this identifier, the persistence file will be located in any of the following places:
1615
- * - Darwin: '/Users/user/.IdentityService/<name>'
1616
- * - Windows 8+: 'C:\\Users\\user\\AppData\\Local\\.IdentityService\\<name>'
1617
- * - Linux: '/home/user/.IdentityService/<name>'
1618
- */
1619
- name?: string;
1620
- /**
1621
- * If set to true, the cache will be stored without encryption if no OS level user encryption is available.
1622
- * When set to false, the PersistentTokenCache will throw an error if no OS level user encryption is available.
1623
- */
1624
- unsafeAllowUnencryptedStorage?: boolean;
1625
- }
1626
-
1627
- export { TokenCredential }
1628
-
1629
- /**
1630
- * Provides options to configure how the Identity library makes authentication
1631
- * requests to Microsoft Entra ID.
1632
- */
1633
- export declare interface TokenCredentialOptions extends CommonClientOptions {
1634
- /**
1635
- * The authority host to use for authentication requests.
1636
- * Possible values are available through {@link AzureAuthorityHosts}.
1637
- * The default is "https://login.microsoftonline.com".
1638
- */
1639
- authorityHost?: string;
1640
- /**
1641
- * Allows users to configure settings for logging policy options, allow logging account information and personally identifiable information for customer support.
1642
- */
1643
- loggingOptions?: LogPolicyOptions & {
1644
- /**
1645
- * Allows logging account information once the authentication flow succeeds.
1646
- */
1647
- allowLoggingAccountIdentifiers?: boolean;
1648
- /**
1649
- * Allows logging personally identifiable information for customer support.
1650
- */
1651
- enableUnsafeSupportLogging?: boolean;
1652
- };
1653
- }
1654
-
1655
- /**
1656
- * Extend Azure Identity with additional functionality. Pass a plugin from
1657
- * a plugin package, such as:
1658
- *
1659
- * - `@azure/identity-cache-persistence`: provides persistent token caching
1660
- * - `@azure/identity-vscode`: provides the dependencies of
1661
- * `VisualStudioCodeCredential` and enables it
1662
- *
1663
- * Example:
1664
- *
1665
- * ```ts snippet:consumer_example
1666
- * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
1667
- *
1668
- * useIdentityPlugin(cachePersistencePlugin);
1669
- * // The plugin has the capability to extend `DeviceCodeCredential` and to
1670
- * // add middleware to the underlying credentials, such as persistence.
1671
- * const credential = new DeviceCodeCredential({
1672
- * tokenCachePersistenceOptions: {
1673
- * enabled: true,
1674
- * },
1675
- * });
1676
- * ```
1677
- *
1678
- * @param plugin - the plugin to register
1679
- */
1680
- export declare function useIdentityPlugin(plugin: IdentityPlugin): void;
1681
-
1682
- /**
1683
- * Enables authentication to Microsoft Entra ID with a user's
1684
- * username and password. This credential requires a high degree of
1685
- * trust so you should only use it when other, more secure credential
1686
- * types can't be used.
1687
- */
1688
- export declare class UsernamePasswordCredential implements TokenCredential {
1689
- private tenantId;
1690
- private additionallyAllowedTenantIds;
1691
- private msalClient;
1692
- private username;
1693
- private password;
1694
- /**
1695
- * Creates an instance of the UsernamePasswordCredential with the details
1696
- * needed to authenticate against Microsoft Entra ID with a username
1697
- * and password.
1698
- *
1699
- * @param tenantId - The Microsoft Entra tenant (directory).
1700
- * @param clientId - The client (application) ID of an App Registration in the tenant.
1701
- * @param username - The user account's e-mail address (user name).
1702
- * @param password - The user account's account password
1703
- * @param options - Options for configuring the client which makes the authentication request.
1704
- */
1705
- constructor(tenantId: string, clientId: string, username: string, password: string, options?: UsernamePasswordCredentialOptions);
1706
- /**
1707
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1708
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1709
- *
1710
- * If the user provided the option `disableAutomaticAuthentication`,
1711
- * once the token can't be retrieved silently,
1712
- * this method won't attempt to request user interaction to retrieve the token.
1713
- *
1714
- * @param scopes - The list of scopes for which the token will have access.
1715
- * @param options - The options used to configure any requests this
1716
- * TokenCredential implementation might make.
1717
- */
1718
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1719
- }
1720
-
1721
- /**
1722
- * Defines options for the {@link UsernamePasswordCredential} class.
1723
- */
1724
- export declare interface UsernamePasswordCredentialOptions extends MultiTenantTokenCredentialOptions, CredentialPersistenceOptions, AuthorityValidationOptions {
1725
- }
1726
-
1727
- /**
1728
- * Connects to Azure using the credential provided by the VSCode extension 'Azure Account'.
1729
- * Once the user has logged in via the extension, this credential can share the same refresh token
1730
- * that is cached by the extension.
1731
- *
1732
- * It's a [known issue](https://github.com/Azure/azure-sdk-for-js/issues/20500) that this credential doesn't
1733
- * work with [Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account)
1734
- * versions newer than **0.9.11**. A long-term fix to this problem is in progress. In the meantime, consider
1735
- * authenticating with {@link AzureCliCredential}.
1736
- */
1737
- export declare class VisualStudioCodeCredential implements TokenCredential {
1738
- private identityClient;
1739
- private tenantId;
1740
- private additionallyAllowedTenantIds;
1741
- private cloudName;
1742
- /**
1743
- * Creates an instance of VisualStudioCodeCredential to use for automatically authenticating via VSCode.
1744
- *
1745
- * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
1746
- * `@azure/identity-vscode`. If this package is not installed and registered
1747
- * using the plugin API (`useIdentityPlugin`), then authentication using
1748
- * `VisualStudioCodeCredential` will not be available.
1749
- *
1750
- * @param options - Options for configuring the client which makes the authentication request.
1751
- */
1752
- constructor(options?: VisualStudioCodeCredentialOptions);
1753
- /**
1754
- * Runs preparations for any further getToken request.
1755
- */
1756
- private prepare;
1757
- /**
1758
- * The promise of the single preparation that will be executed at the first getToken request for an instance of this class.
1759
- */
1760
- private preparePromise;
1761
- /**
1762
- * Runs preparations for any further getToken, but only once.
1763
- */
1764
- private prepareOnce;
1765
- /**
1766
- * Returns the token found by searching VSCode's authentication cache or
1767
- * returns null if no token could be found.
1768
- *
1769
- * @param scopes - The list of scopes for which the token will have access.
1770
- * @param options - The options used to configure any requests this
1771
- * `TokenCredential` implementation might make.
1772
- */
1773
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
1774
- }
1775
-
1776
- /**
1777
- * Provides options to configure the Visual Studio Code credential.
1778
- */
1779
- export declare interface VisualStudioCodeCredentialOptions extends MultiTenantTokenCredentialOptions {
1780
- /**
1781
- * Optionally pass in a Tenant ID to be used as part of the credential
1782
- */
1783
- tenantId?: string;
1784
- }
1785
-
1786
- /**
1787
- * Workload Identity authentication is a feature in Azure that allows applications running on virtual machines (VMs)
1788
- * to access other Azure resources without the need for a service principal or managed identity. With Workload Identity
1789
- * authentication, applications authenticate themselves using their own identity, rather than using a shared service
1790
- * principal or managed identity. Under the hood, Workload Identity authentication uses the concept of Service Account
1791
- * Credentials (SACs), which are automatically created by Azure and stored securely in the VM. By using Workload
1792
- * Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
1793
- * each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
1794
- * need to worry about storing and securing sensitive credentials themselves.
1795
- * The WorkloadIdentityCredential supports Microsoft Entra Workload ID authentication on Azure Kubernetes and acquires
1796
- * a token using the SACs available in the Azure Kubernetes environment.
1797
- * Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Microsoft Entra
1798
- * Workload ID</a> for more information.
1799
- */
1800
- export declare class WorkloadIdentityCredential implements TokenCredential {
1801
- private client;
1802
- private azureFederatedTokenFileContent;
1803
- private cacheDate;
1804
- private federatedTokenFilePath;
1805
- /**
1806
- * WorkloadIdentityCredential supports Microsoft Entra Workload ID on Kubernetes.
1807
- *
1808
- * @param options - The identity client options to use for authentication.
1809
- */
1810
- constructor(options?: WorkloadIdentityCredentialOptions);
1811
- /**
1812
- * Authenticates with Microsoft Entra ID and returns an access token if successful.
1813
- * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
1814
- *
1815
- * @param scopes - The list of scopes for which the token will have access.
1816
- * @param options - The options used to configure any requests this
1817
- * TokenCredential implementation might make.
1818
- */
1819
- getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
1820
- private readFileContents;
1821
- }
1822
-
1823
- /**
1824
- * Options for the {@link WorkloadIdentityCredential}
1825
- */
1826
- export declare interface WorkloadIdentityCredentialOptions extends MultiTenantTokenCredentialOptions, AuthorityValidationOptions {
1827
- /**
1828
- * ID of the application's Microsoft Entra tenant. Also called its directory ID.
1829
- */
1830
- tenantId?: string;
1831
- /**
1832
- * The client ID of a Microsoft Entra app registration.
1833
- */
1834
- clientId?: string;
1835
- /**
1836
- * The path to a file containing a Kubernetes service account token that authenticates the identity.
1837
- */
1838
- tokenFilePath?: string;
1839
- }
1840
-
1841
- export { }