1 | import { AccessToken } from '@azure/core-auth';
|
2 | import { AzureLogger } from '@azure/logger';
|
3 | import { CommonClientOptions } from '@azure/core-client';
|
4 | import { GetTokenOptions } from '@azure/core-auth';
|
5 | import { LogPolicyOptions } from '@azure/core-rest-pipeline';
|
6 | import { TokenCredential } from '@azure/core-auth';
|
7 |
|
8 | export { AccessToken }
|
9 |
|
10 | /**
|
11 | * Provides an `errors` array containing {@link AuthenticationError} instance
|
12 | * for authentication failures from credentials in a {@link ChainedTokenCredential}.
|
13 | */
|
14 | export declare class AggregateAuthenticationError extends Error {
|
15 | /**
|
16 | * The array of error objects that were thrown while trying to authenticate
|
17 | * with the credentials in a {@link ChainedTokenCredential}.
|
18 | */
|
19 | errors: any[];
|
20 | constructor(errors: any[], errorMessage?: string);
|
21 | }
|
22 |
|
23 | /**
|
24 | * The Error.name value of an AggregateAuthenticationError
|
25 | */
|
26 | export declare const AggregateAuthenticationErrorName = "AggregateAuthenticationError";
|
27 |
|
28 | /**
|
29 | * Provides details about a failure to authenticate with Azure Active
|
30 | * Directory. The `errorResponse` field contains more details about
|
31 | * the specific failure.
|
32 | */
|
33 | export declare class AuthenticationError extends Error {
|
34 | /**
|
35 | * The HTTP status code returned from the authentication request.
|
36 | */
|
37 | readonly statusCode: number;
|
38 | /**
|
39 | * The error response details.
|
40 | */
|
41 | readonly errorResponse: ErrorResponse;
|
42 | constructor(statusCode: number, errorBody: object | string | undefined | null);
|
43 | }
|
44 |
|
45 | /**
|
46 | * The Error.name value of an AuthenticationError
|
47 | */
|
48 | export declare const AuthenticationErrorName = "AuthenticationError";
|
49 |
|
50 | /**
|
51 | * The record to use to find the cached tokens in the cache.
|
52 | */
|
53 | export declare interface AuthenticationRecord {
|
54 | /**
|
55 | * The associated authority, if used.
|
56 | */
|
57 | authority: string;
|
58 | /**
|
59 | * The home account Id.
|
60 | */
|
61 | homeAccountId: string;
|
62 | /**
|
63 | * The associated client ID.
|
64 | */
|
65 | clientId: string;
|
66 | /**
|
67 | * The associated tenant ID.
|
68 | */
|
69 | tenantId: string;
|
70 | /**
|
71 | * The username of the logged in account.
|
72 | */
|
73 | username: string;
|
74 | }
|
75 |
|
76 | /**
|
77 | * Error used to enforce authentication after trying to retrieve a token silently.
|
78 | */
|
79 | export declare class AuthenticationRequiredError extends Error {
|
80 | /**
|
81 | * The list of scopes for which the token will have access.
|
82 | */
|
83 | scopes: string[];
|
84 | /**
|
85 | * The options passed to the getToken request.
|
86 | */
|
87 | getTokenOptions?: GetTokenOptions;
|
88 | constructor(
|
89 | /**
|
90 | * 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.
|
91 | */
|
92 | options: AuthenticationRequiredErrorOptions);
|
93 | }
|
94 |
|
95 | /**
|
96 | * Optional parameters to the { AuthenticationRequiredError}
|
97 | */
|
98 | export declare interface AuthenticationRequiredErrorOptions {
|
99 | /**
|
100 | * The list of scopes for which the token will have access.
|
101 | */
|
102 | scopes: string[];
|
103 | /**
|
104 | * The options passed to the getToken request.
|
105 | */
|
106 | getTokenOptions?: GetTokenOptions;
|
107 | /**
|
108 | * The message of the error.
|
109 | */
|
110 | message?: string;
|
111 | }
|
112 |
|
113 | /**
|
114 | * Enables authentication to Azure Active Directory using an authorization code
|
115 | * that was obtained through the authorization code flow, described in more detail
|
116 | * in the Azure Active Directory documentation:
|
117 | *
|
118 | * https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
119 | */
|
120 | export declare class AuthorizationCodeCredential implements TokenCredential {
|
121 | private msalFlow;
|
122 | private disableAutomaticAuthentication?;
|
123 | private authorizationCode;
|
124 | private redirectUri;
|
125 | /**
|
126 | * Creates an instance of AuthorizationCodeCredential with the details needed
|
127 | * to request an access token using an authentication that was obtained
|
128 | * from Azure Active Directory.
|
129 | *
|
130 | * It is currently necessary for the user of this credential to initiate
|
131 | * the authorization code flow to obtain an authorization code to be used
|
132 | * with this credential. A full example of this flow is provided here:
|
133 | *
|
134 | * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts
|
135 | *
|
136 | * @param tenantId - The Azure Active Directory tenant (directory) ID or name.
|
137 | * 'common' may be used when dealing with multi-tenant scenarios.
|
138 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
139 | * @param clientSecret - A client secret that was generated for the App Registration
|
140 | * @param authorizationCode - An authorization code that was received from following the
|
141 | authorization code flow. This authorization code must not
|
142 | have already been used to obtain an access token.
|
143 | * @param redirectUri - The redirect URI that was used to request the authorization code.
|
144 | Must be the same URI that is configured for the App Registration.
|
145 | * @param options - Options for configuring the client which makes the access token request.
|
146 | */
|
147 | constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
|
148 | /**
|
149 | * Creates an instance of AuthorizationCodeCredential with the details needed
|
150 | * to request an access token using an authentication that was obtained
|
151 | * from Azure Active Directory.
|
152 | *
|
153 | * It is currently necessary for the user of this credential to initiate
|
154 | * the authorization code flow to obtain an authorization code to be used
|
155 | * with this credential. A full example of this flow is provided here:
|
156 | *
|
157 | * https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2/manual/authorizationCodeSample.ts
|
158 | *
|
159 | * @param tenantId - The Azure Active Directory tenant (directory) ID or name.
|
160 | * 'common' may be used when dealing with multi-tenant scenarios.
|
161 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
162 | * @param authorizationCode - An authorization code that was received from following the
|
163 | authorization code flow. This authorization code must not
|
164 | have already been used to obtain an access token.
|
165 | * @param redirectUri - The redirect URI that was used to request the authorization code.
|
166 | Must be the same URI that is configured for the App Registration.
|
167 | * @param options - Options for configuring the client which makes the access token request.
|
168 | */
|
169 | constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
|
170 | /**
|
171 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
172 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
173 | *
|
174 | * @param scopes - The list of scopes for which the token will have access.
|
175 | * @param options - The options used to configure any requests this
|
176 | * TokenCredential implementation might make.
|
177 | */
|
178 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
179 | }
|
180 |
|
181 | /**
|
182 | * A list of known Azure authority hosts
|
183 | */
|
184 | export declare enum AzureAuthorityHosts {
|
185 | /**
|
186 | * China-based Azure Authority Host
|
187 | */
|
188 | AzureChina = "https://login.chinacloudapi.cn",
|
189 | /**
|
190 | * Germany-based Azure Authority Host
|
191 | */
|
192 | AzureGermany = "https://login.microsoftonline.de",
|
193 | /**
|
194 | * US Government Azure Authority Host
|
195 | */
|
196 | AzureGovernment = "https://login.microsoftonline.us",
|
197 | /**
|
198 | * Public Cloud Azure Authority Host
|
199 | */
|
200 | AzurePublicCloud = "https://login.microsoftonline.com"
|
201 | }
|
202 |
|
203 | /**
|
204 | * This credential will use the currently logged-in user login information
|
205 | * via the Azure CLI ('az') commandline tool.
|
206 | * To do so, it will read the user access token and expire time
|
207 | * with Azure CLI command "az account get-access-token".
|
208 | */
|
209 | export declare class AzureCliCredential implements TokenCredential {
|
210 | private tenantId?;
|
211 | /**
|
212 | * Creates an instance of the {@link AzureCliCredential}.
|
213 | *
|
214 | * To use this credential, ensure that you have already logged
|
215 | * in via the 'az' tool using the command "az login" from the commandline.
|
216 | *
|
217 | * @param options - Options, to optionally allow multi-tenant requests.
|
218 | */
|
219 | constructor(options?: AzureCliCredentialOptions);
|
220 | /**
|
221 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
222 | * If authentication fails, a {with the details of the failure.
CredentialUnavailableError} will be thrown |
223 | *
|
224 | * for which the token will have access.
scopes - The list of scopes |
225 | * any requests this
options - The options used to configure |
226 | * TokenCredential implementation might make.
|
227 | */
|
228 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
229 | }
|
230 |
|
231 | /**
|
232 | * Options for the {@link AzureCliCredential}
|
233 | */
|
234 | export declare interface AzureCliCredentialOptions extends TokenCredentialOptions {
|
235 | /**
|
236 | * Allows specifying a tenant ID
|
237 | */
|
238 | tenantId?: string;
|
239 | }
|
240 |
|
241 | /**
|
242 | * This credential will use the currently logged-in user information from the
|
243 | * Azure PowerShell module. To do so, it will read the user access token and
|
244 | * expire time with Azure PowerShell command `Get-AzAccessToken -ResourceUrl {ResourceScope}`
|
245 | */
|
246 | export declare class AzurePowerShellCredential implements TokenCredential {
|
247 | private tenantId?;
|
248 | /**
|
249 | * Creates an instance of the {@link AzurePowerShellCredential}.
|
250 | *
|
251 | * To use this credential:
|
252 | * - Install the Azure Az PowerShell module with:
|
253 | * `Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force`.
|
254 | * - You have already logged in to Azure PowerShell using the command
|
255 | * `Connect-AzAccount` from the command line.
|
256 | *
|
257 | * @param options - Options, to optionally allow multi-tenant requests.
|
258 | */
|
259 | constructor(options?: AzurePowerShellCredentialOptions);
|
260 | /**
|
261 | * Gets the access token from Azure PowerShell
|
262 | * @param resource - The resource to use when getting the token
|
263 | */
|
264 | private getAzurePowerShellAccessToken;
|
265 | /**
|
266 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
267 | * If the authentication cannot be performed through PowerShell, a { CredentialUnavailableError} will be thrown.
|
268 | *
|
269 | * for which the token will have access.
scopes - The list of scopes |
270 | * any requests this TokenCredential implementation might make.
options - The options used to configure |
271 | */
|
272 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
273 | }
|
274 |
|
275 | /**
|
276 | * Options for the {@link AzurePowerShellCredential}
|
277 | */
|
278 | export declare interface AzurePowerShellCredentialOptions extends TokenCredentialOptions {
|
279 | /**
|
280 | * Allows specifying a tenant ID
|
281 | */
|
282 | tenantId?: string;
|
283 | }
|
284 |
|
285 | /**
|
286 | * (Browser-only feature)
|
287 | * The "login style" to use in the authentication flow:
|
288 | * - "redirect" redirects the user to the authentication page and then
|
289 | * redirects them back to the page once authentication is completed.
|
290 | * - "popup" opens a new browser window through with the redirect flow
|
291 | * is initiated. The user's existing browser window does not leave
|
292 | * the current page
|
293 | */
|
294 | export declare type BrowserLoginStyle = "redirect" | "popup";
|
295 |
|
296 | /**
|
297 | * Enables multiple `TokenCredential` implementations to be tried in order
|
298 | * until one of the getToken methods returns an access token.
|
299 | */
|
300 | export declare class ChainedTokenCredential implements TokenCredential {
|
301 | /**
|
302 | * The message to use when the chained token fails to get a token
|
303 | */
|
304 | protected UnavailableMessage: string;
|
305 | private _sources;
|
306 | /**
|
307 | * Creates an instance of ChainedTokenCredential using the given credentials.
|
308 | *
|
309 | * @param sources - `TokenCredential` implementations to be tried in order.
|
310 | *
|
311 | * Example usage:
|
312 | * ```javascript
|
313 | * const firstCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
|
314 | * const secondCredential = new ClientSecretCredential(tenantId, anotherClientId, anotherSecret);
|
315 | * const credentialChain = new ChainedTokenCredential(firstCredential, secondCredential);
|
316 | * ```
|
317 | */
|
318 | constructor(...sources: TokenCredential[]);
|
319 | /**
|
320 | * Returns the first access token returned by one of the chained
|
321 | * `TokenCredential` implementations. Throws an { AggregateAuthenticationError}
|
322 | * when one or more credentials throws an { AuthenticationError} and
|
323 | * no credentials have returned an access token.
|
324 | *
|
325 | * This method is called automatically by Azure SDK client libraries. You may call this method
|
326 | * directly, but you must also handle token caching and token refreshing.
|
327 | *
|
328 | * for which the token will have access.
scopes - The list of scopes |
329 | * any requests this
options - The options used to configure |
330 | * `TokenCredential` implementation might make.
|
331 | */
|
332 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
333 | }
|
334 |
|
335 | /**
|
336 | * Authenticates a service principal with a JWT assertion.
|
337 | */
|
338 | export declare class ClientAssertionCredential implements TokenCredential {
|
339 | private msalFlow;
|
340 | private tenantId;
|
341 | private clientId;
|
342 | private options;
|
343 | /**
|
344 | * Creates an instance of the ClientAssertionCredential with the details
|
345 | * needed to authenticate against Azure Active Directory with a client
|
346 | * assertion provided by the developer through the `getAssertion` function parameter.
|
347 | *
|
348 | * @param tenantId - The Azure Active Directory tenant (directory) ID.
|
349 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
350 | * @param getAssertion - A function that retrieves the assertion for the credential to use.
|
351 | * @param options - Options for configuring the client which makes the authentication request.
|
352 | */
|
353 | constructor(tenantId: string, clientId: string, getAssertion: () => Promise<string>, options?: TokenCredentialOptions);
|
354 | /**
|
355 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
356 | * If authentication fails, a {with the details of the failure.
CredentialUnavailableError} will be thrown |
357 | *
|
358 | * for which the token will have access.
scopes - The list of scopes |
359 | * any requests this
options - The options used to configure |
360 | * TokenCredential implementation might make.
|
361 | */
|
362 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
363 | }
|
364 |
|
365 | /**
|
366 | * Enables authentication to Azure Active Directory using a PEM-encoded
|
367 | * certificate that is assigned to an App Registration. More information
|
368 | * on how to configure certificate authentication can be found here:
|
369 | *
|
370 | * https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad
|
371 | *
|
372 | */
|
373 | export declare class ClientCertificateCredential implements TokenCredential {
|
374 | private msalFlow;
|
375 | /**
|
376 | * Creates an instance of the ClientCertificateCredential with the details
|
377 | * needed to authenticate against Azure Active Directory with a certificate.
|
378 | *
|
379 | * @param tenantId - The Azure Active Directory tenant (directory) ID.
|
380 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
381 | * @param certificatePath - The path to a PEM-encoded public/private key certificate on the filesystem.
|
382 | * @param options - Options for configuring the client which makes the authentication request.
|
383 | */
|
384 | constructor(tenantId: string, clientId: string, certificatePath: string, options?: ClientCertificateCredentialOptions);
|
385 | /**
|
386 | * Creates an instance of the ClientCertificateCredential with the details
|
387 | * needed to authenticate against Azure Active Directory with a certificate.
|
388 | *
|
389 | * @param tenantId - The Azure Active Directory tenant (directory) ID.
|
390 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
391 | * @param configuration - Other parameters required, including the path of the certificate on the filesystem.
|
392 | * If the type is ignored, we will throw the value of the path to a PEM certificate.
|
393 | * @param options - Options for configuring the client which makes the authentication request.
|
394 | */
|
395 | constructor(tenantId: string, clientId: string, configuration: ClientCertificatePEMCertificatePath, options?: ClientCertificateCredentialOptions);
|
396 | /**
|
397 | * Creates an instance of the ClientCertificateCredential with the details
|
398 | * needed to authenticate against Azure Active Directory with a certificate.
|
399 | *
|
400 | * @param tenantId - The Azure Active Directory tenant (directory) ID.
|
401 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
402 | * @param configuration - Other parameters required, including the PEM-encoded certificate as a string.
|
403 | * If the type is ignored, we will throw the value of the PEM-encoded certificate.
|
404 | * @param options - Options for configuring the client which makes the authentication request.
|
405 | */
|
406 | constructor(tenantId: string, clientId: string, configuration: ClientCertificatePEMCertificate, options?: ClientCertificateCredentialOptions);
|
407 | /**
|
408 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
409 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
410 | *
|
411 | * @param scopes - The list of scopes for which the token will have access.
|
412 | * @param options - The options used to configure any requests this
|
413 | * TokenCredential implementation might make.
|
414 | */
|
415 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
416 | }
|
417 |
|
418 | /**
|
419 | * Optional parameters for the {@link ClientCertificateCredential} class.
|
420 | */
|
421 | export declare interface ClientCertificateCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
|
422 | /**
|
423 | * Option to include x5c header for SubjectName and Issuer name authorization.
|
424 | * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
|
425 | */
|
426 | sendCertificateChain?: boolean;
|
427 | }
|
428 |
|
429 | /**
|
430 | * Required configuration options for the {@link ClientCertificateCredential}, with either the string contents of a PEM certificate, or the path to a PEM certificate.
|
431 | */
|
432 | export declare type ClientCertificateCredentialPEMConfiguration = ClientCertificatePEMCertificate | ClientCertificatePEMCertificatePath;
|
433 |
|
434 | /**
|
435 | * Required configuration options for the {@link ClientCertificateCredential}, with the string contents of a PEM certificate
|
436 | */
|
437 | export declare interface ClientCertificatePEMCertificate {
|
438 | /**
|
439 | * The PEM-encoded public/private key certificate on the filesystem.
|
440 | */
|
441 | certificate: string;
|
442 | }
|
443 |
|
444 | /**
|
445 | * Required configuration options for the {@link ClientCertificateCredential}, with the path to a PEM certificate.
|
446 | */
|
447 | export declare interface ClientCertificatePEMCertificatePath {
|
448 | /**
|
449 | * The path to the PEM-encoded public/private key certificate on the filesystem.
|
450 | */
|
451 | certificatePath: string;
|
452 | }
|
453 |
|
454 | /**
|
455 | * Enables authentication to Azure Active Directory using a client secret
|
456 | * that was generated for an App Registration. More information on how
|
457 | * to configure a client secret can be found here:
|
458 | *
|
459 | * https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
|
460 | *
|
461 | */
|
462 | export declare class ClientSecretCredential implements TokenCredential {
|
463 | private msalFlow;
|
464 | /**
|
465 | * Creates an instance of the ClientSecretCredential with the details
|
466 | * needed to authenticate against Azure Active Directory with a client
|
467 | * secret.
|
468 | *
|
469 | * @param tenantId - The Azure Active Directory tenant (directory) ID.
|
470 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
471 | * @param clientSecret - A client secret that was generated for the App Registration.
|
472 | * @param options - Options for configuring the client which makes the authentication request.
|
473 | */
|
474 | constructor(tenantId: string, clientId: string, clientSecret: string, options?: ClientSecretCredentialOptions);
|
475 | /**
|
476 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
477 | * If authentication fails, a {with the details of the failure.
CredentialUnavailableError} will be thrown |
478 | *
|
479 | * for which the token will have access.
scopes - The list of scopes |
480 | * any requests this
options - The options used to configure |
481 | * TokenCredential implementation might make.
|
482 | */
|
483 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
484 | }
|
485 |
|
486 | /**
|
487 | * Optional parameters for the {@link ClientSecretCredential} class.
|
488 | */
|
489 | export declare interface ClientSecretCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
|
490 | }
|
491 |
|
492 | /**
|
493 | * Shared configuration options for credentials that support persistent token
|
494 | * caching.
|
495 | */
|
496 | export declare interface CredentialPersistenceOptions {
|
497 | /**
|
498 | * Options to provide to the persistence layer (if one is available) when
|
499 | * storing credentials.
|
500 | *
|
501 | * You must first register a persistence provider plugin. See the
|
502 | * `@azure/identity-cache-persistence` package on NPM.
|
503 | *
|
504 | * Example:
|
505 | *
|
506 | * ```javascript
|
507 | * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
|
508 | * import { useIdentityPlugin, DeviceCodeCredential } from "@azure/identity";
|
509 | *
|
510 | * useIdentityPlugin(cachePersistencePlugin);
|
511 | *
|
512 | * async function main() {
|
513 | * const credential = new DeviceCodeCredential({
|
514 | * tokenCachePersistenceOptions: {
|
515 | * enabled: true
|
516 | * }
|
517 | * });
|
518 | * }
|
519 | *
|
520 | * main().catch((error) => {
|
521 | * console.error("An error occurred:", error);
|
522 | * process.exit(1);
|
523 | * });
|
524 | * ```
|
525 | */
|
526 | tokenCachePersistenceOptions?: TokenCachePersistenceOptions;
|
527 | }
|
528 |
|
529 | /**
|
530 | * This signifies that the credential that was tried in a chained credential
|
531 | * was not available to be used as the credential. Rather than treating this as
|
532 | * an error that should halt the chain, it's caught and the chain continues
|
533 | */
|
534 | export declare class CredentialUnavailableError extends Error {
|
535 | constructor(message?: string);
|
536 | }
|
537 |
|
538 | /**
|
539 | * The Error.name value of an CredentialUnavailable
|
540 | */
|
541 | export declare const CredentialUnavailableErrorName = "CredentialUnavailableError";
|
542 |
|
543 | /**
|
544 | * Provides a default { ChainedTokenCredential} configuration that should
|
545 | * work for most applications that use the Azure SDK.
|
546 | */
|
547 | export declare class DefaultAzureCredential extends ChainedTokenCredential {
|
548 | /**
|
549 | * Creates an instance of the DefaultAzureCredential class with {@link DefaultAzureCredentialClientIdOptions}
|
550 | *
|
551 | * This credential provides a default {@link ChainedTokenCredential} configuration that should
|
552 | * work for most applications that use the Azure SDK.
|
553 | *
|
554 | * The following credential types will be tried, in order:
|
555 | *
|
556 | * - {@link EnvironmentCredential}
|
557 | * - {@link ManagedIdentityCredential}
|
558 | * - {@link VisualStudioCodeCredential}
|
559 | * - {@link AzureCliCredential}
|
560 | * - {@link AzurePowerShellCredential}
|
561 | *
|
562 | * Consult the documentation of these credential types for more information
|
563 | * on how they attempt authentication.
|
564 | *
|
565 | * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
|
566 | * `@azure/identity-vscode`. If this package is not installed and registered
|
567 | * using the plugin API (`useIdentityPlugin`), then authentication using
|
568 | * `VisualStudioCodeCredential` will not be available.
|
569 | * @param options - Optional parameters. See {@link DefaultAzureCredentialClientIdOptions}.
|
570 | */
|
571 | constructor(options?: DefaultAzureCredentialClientIdOptions);
|
572 | /**
|
573 | * Creates an instance of the DefaultAzureCredential class with { DefaultAzureCredentialResourceIdOptions}
|
574 | *
|
575 | * This credential provides a default { ChainedTokenCredential} configuration that should
|
576 | * work for most applications that use the Azure SDK.
|
577 | *
|
578 | * The following credential types will be tried, in order:
|
579 | *
|
580 | * - { EnvironmentCredential}
|
581 | * - { ManagedIdentityCredential}
|
582 | * - { VisualStudioCodeCredential}
|
583 | * - { AzureCliCredential}
|
584 | * - { AzurePowerShellCredential}
|
585 | *
|
586 | * Consult the documentation of these credential types for more information
|
587 | * on how they attempt authentication.
|
588 | *
|
589 | * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
|
590 | * `@azure/identity-vscode`. If this package is not installed and registered
|
591 | * using the plugin API (`useIdentityPlugin`), then authentication using
|
592 | * `VisualStudioCodeCredential` will not be available.
|
593 | * options - Optional parameters. See { DefaultAzureCredentialResourceIdOptions}.
|
594 | */
|
595 | constructor(options?: DefaultAzureCredentialResourceIdOptions);
|
596 | /**
|
597 | * Creates an instance of the DefaultAzureCredential class with { DefaultAzureCredentialOptions}
|
598 | *
|
599 | * This credential provides a default { ChainedTokenCredential} configuration that should
|
600 | * work for most applications that use the Azure SDK.
|
601 | *
|
602 | * The following credential types will be tried, in order:
|
603 | *
|
604 | * - { EnvironmentCredential}
|
605 | * - { ManagedIdentityCredential}
|
606 | * - { VisualStudioCodeCredential}
|
607 | * - { AzureCliCredential}
|
608 | * - { AzurePowerShellCredential}
|
609 | *
|
610 | * Consult the documentation of these credential types for more information
|
611 | * on how they attempt authentication.
|
612 | *
|
613 | * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
|
614 | * `@azure/identity-vscode`. If this package is not installed and registered
|
615 | * using the plugin API (`useIdentityPlugin`), then authentication using
|
616 | * `VisualStudioCodeCredential` will not be available.
|
617 | *
|
618 | * options - Optional parameters. See { DefaultAzureCredentialOptions}.
|
619 | */
|
620 | constructor(options?: DefaultAzureCredentialOptions);
|
621 | }
|
622 |
|
623 | /**
|
624 | * Provides options to configure the {class.
DefaultAzureCredential} |
625 | * This variation supports `managedIdentityClientId` and not `managedIdentityResourceId`, since only one of both is supported.
|
626 | */
|
627 | export declare interface DefaultAzureCredentialClientIdOptions extends DefaultAzureCredentialOptions {
|
628 | /**
|
629 | * Optionally pass in a user assigned client ID to be used by the {@link ManagedIdentityCredential}.
|
630 | * This client ID can also be passed through to the {@link ManagedIdentityCredential} through the environment variable: AZURE_CLIENT_ID.
|
631 | */
|
632 | managedIdentityClientId?: string;
|
633 | }
|
634 |
|
635 | /**
|
636 | * Provides options to configure the {@link DefaultAzureCredential} class.
|
637 | */
|
638 | export declare interface DefaultAzureCredentialOptions extends TokenCredentialOptions {
|
639 | /**
|
640 | * Optionally pass in a Tenant ID to be used as part of the credential.
|
641 | * By default it may use a generic tenant ID depending on the underlying credential.
|
642 | */
|
643 | tenantId?: string;
|
644 | }
|
645 |
|
646 | /**
|
647 | * Provides options to configure the {@link DefaultAzureCredential} class.
|
648 | * This variation supports `managedIdentityResourceId` and not `managedIdentityClientId`, since only one of both is supported.
|
649 | */
|
650 | export declare interface DefaultAzureCredentialResourceIdOptions extends DefaultAzureCredentialOptions {
|
651 | /**
|
652 | * Optionally pass in a resource ID to be used by the {@link ManagedIdentityCredential}.
|
653 | * In scenarios such as when user assigned identities are created using an ARM template,
|
654 | * where the resource Id of the identity is known but the client Id can't be known ahead of time,
|
655 | * this parameter allows programs to use these user assigned identities
|
656 | * without having to first determine the client Id of the created identity.
|
657 | */
|
658 | managedIdentityResourceId: string;
|
659 | }
|
660 |
|
661 | /**
|
662 | * Deserializes a previously serialized authentication record from a string into an object.
|
663 | *
|
664 | * The input string must contain the following properties:
|
665 | *
|
666 | * - "authority"
|
667 | * - "homeAccountId"
|
668 | * - "clientId"
|
669 | * - "tenantId"
|
670 | * - "username"
|
671 | * - "version"
|
672 | *
|
673 | * If the version we receive is unsupported, an error will be thrown.
|
674 | *
|
675 | * At the moment, the only available version is: "1.0", which is always set when the authentication record is serialized.
|
676 | *
|
677 | * @param serializedRecord - Authentication record previously serialized into string.
|
678 | * @returns AuthenticationRecord.
|
679 | */
|
680 | export declare function deserializeAuthenticationRecord(serializedRecord: string): AuthenticationRecord;
|
681 |
|
682 | /**
|
683 | * Enables authentication to Azure Active Directory using a device code
|
684 | * that the user can enter into https://microsoft.com/devicelogin.
|
685 | */
|
686 | export declare class DeviceCodeCredential implements TokenCredential {
|
687 | private msalFlow;
|
688 | private disableAutomaticAuthentication?;
|
689 | /**
|
690 | * Creates an instance of DeviceCodeCredential with the details needed
|
691 | * to initiate the device code authorization flow with Azure Active Directory.
|
692 | *
|
693 | * A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
|
694 | *
|
695 | * Developers can configure how this message is shown by passing a custom `userPromptCallback`:
|
696 | *
|
697 | * ```js
|
698 | * const credential = new DeviceCodeCredential({
|
699 | * tenantId: env.AZURE_TENANT_ID,
|
700 | * clientId: env.AZURE_CLIENT_ID,
|
701 | * userPromptCallback: (info) => {
|
702 | * console.log("CUSTOMIZED PROMPT CALLBACK", info.message);
|
703 | * }
|
704 | * });
|
705 | * ```
|
706 | *
|
707 | * @param options - Options for configuring the client which makes the authentication requests.
|
708 | */
|
709 | constructor(options?: DeviceCodeCredentialOptions);
|
710 | /**
|
711 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
712 | * If authentication fails, a {with the details of the failure.
CredentialUnavailableError} will be thrown |
713 | *
|
714 | * If the user provided the option `disableAutomaticAuthentication`,
|
715 | * once the token can't be retrieved silently,
|
716 | * this method won't attempt to request user interaction to retrieve the token.
|
717 | *
|
718 | * for which the token will have access.
scopes - The list of scopes |
719 | * any requests this
options - The options used to configure |
720 | * TokenCredential implementation might make.
|
721 | */
|
722 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
723 | /**
|
724 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
725 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
726 | *
|
727 | * If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
728 | *
|
729 | * @param scopes - The list of scopes for which the token will have access.
|
730 | * @param options - The options used to configure any requests this
|
731 | * TokenCredential implementation might make.
|
732 | */
|
733 | authenticate(scopes: string | string[], options?: GetTokenOptions): Promise<AuthenticationRecord | undefined>;
|
734 | }
|
735 |
|
736 | /**
|
737 | * Defines options for the InteractiveBrowserCredential class for Node.js.
|
738 | */
|
739 | export declare interface DeviceCodeCredentialOptions extends InteractiveCredentialOptions, CredentialPersistenceOptions {
|
740 | /**
|
741 | * The Azure Active Directory tenant (directory) ID.
|
742 | */
|
743 | tenantId?: string;
|
744 | /**
|
745 | * The client (application) ID of an App Registration in the tenant.
|
746 | */
|
747 | clientId?: string;
|
748 | /**
|
749 | * A callback function that will be invoked to show {@link DeviceCodeInfo} to the user.
|
750 | * If left unassigned, we will automatically log the device code information
|
751 | * and the authentication instructions in the console.
|
752 | */
|
753 | userPromptCallback?: DeviceCodePromptCallback;
|
754 | }
|
755 |
|
756 | /**
|
757 | * Provides the user code and verification URI where the code must be
|
758 | * entered. Also provides a message to display to the user which
|
759 | * contains an instruction with these details.
|
760 | */
|
761 | export declare interface DeviceCodeInfo {
|
762 | /**
|
763 | * The device code that the user must enter into the verification page.
|
764 | */
|
765 | userCode: string;
|
766 | /**
|
767 | * The verification URI to which the user must navigate to enter the device
|
768 | * code.
|
769 | */
|
770 | verificationUri: string;
|
771 | /**
|
772 | * A message that may be shown to the user to instruct them on how to enter
|
773 | * the device code in the page specified by the verification URI.
|
774 | */
|
775 | message: string;
|
776 | }
|
777 |
|
778 | /**
|
779 | * Defines the signature of a callback which will be passed to
|
780 | * DeviceCodeCredential for the purpose of displaying authentication
|
781 | * details to the user.
|
782 | */
|
783 | export declare type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo) => void;
|
784 |
|
785 | /**
|
786 | * Enables authentication to Azure Active Directory using client secret
|
787 | * details configured in environment variables
|
788 | */
|
789 | export declare class EnvironmentCredential implements TokenCredential {
|
790 | private _credential?;
|
791 | /**
|
792 | * Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
|
793 | *
|
794 | * Required environment variables:
|
795 | * - `AZURE_TENANT_ID`: The Azure Active Directory tenant (directory) ID.
|
796 | * - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
|
797 | *
|
798 | * Environment variables used for client credential authentication:
|
799 | * - `AZURE_CLIENT_SECRET`: A client secret that was generated for the App Registration.
|
800 | * - `AZURE_CLIENT_CERTIFICATE_PATH`: The path to a PEM certificate to use during the authentication, instead of the client secret.
|
801 | *
|
802 | * Alternatively, users can provide environment variables for username and password authentication:
|
803 | * - `AZURE_USERNAME`: Username to authenticate with.
|
804 | * - `AZURE_PASSWORD`: Password to authenticate with.
|
805 | *
|
806 | * If the environment variables required to perform the authentication are missing, a {@link CredentialUnavailableError} will be thrown.
|
807 | * If the authentication fails, or if there's an unknown error, an {@link AuthenticationError} will be thrown.
|
808 | *
|
809 | * @param options - Options for configuring the client which makes the authentication request.
|
810 | */
|
811 | constructor(options?: EnvironmentCredentialOptions);
|
812 | /**
|
813 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
814 | *
|
815 | * @param scopes - The list of scopes for which the token will have access.
|
816 | * @param options - Optional parameters. See { GetTokenOptions}.
|
817 | */
|
818 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
819 | }
|
820 |
|
821 | /**
|
822 | * Enables authentication to Azure Active Directory depending on the available environment variables.
|
823 | * Defines options for the EnvironmentCredential class.
|
824 | */
|
825 | export declare interface EnvironmentCredentialOptions extends TokenCredentialOptions {
|
826 | }
|
827 |
|
828 | /**
|
829 | * See the official documentation for more details:
|
830 | *
|
831 | * https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-oauth-code#error-response-1
|
832 | *
|
833 | * NOTE: This documentation is for v1 OAuth support but the same error
|
834 | * response details still apply to v2.
|
835 | */
|
836 | export declare interface ErrorResponse {
|
837 | /**
|
838 | * The string identifier for the error.
|
839 | */
|
840 | error: string;
|
841 | /**
|
842 | * The error's description.
|
843 | */
|
844 | errorDescription: string;
|
845 | /**
|
846 | * An array of codes pertaining to the error(s) that occurred.
|
847 | */
|
848 | errorCodes?: number[];
|
849 | /**
|
850 | * The timestamp at which the error occurred.
|
851 | */
|
852 | timestamp?: string;
|
853 | /**
|
854 | * The trace identifier for this error occurrence.
|
855 | */
|
856 | traceId?: string;
|
857 | /**
|
858 | * The correlation ID to be used for tracking the source of the error.
|
859 | */
|
860 | correlationId?: string;
|
861 | }
|
862 |
|
863 | /**
|
864 | * Returns a new instance of the {@link DefaultAzureCredential}.
|
865 | */
|
866 | export declare function getDefaultAzureCredential(): TokenCredential;
|
867 |
|
868 | export { GetTokenOptions }
|
869 |
|
870 | /**
|
871 | * The type of an Azure Identity plugin, a function accepting a plugin
|
872 | * context.
|
873 | */
|
874 | export declare type IdentityPlugin = (context: unknown) => void;
|
875 |
|
876 | /**
|
877 | * Enables authentication to Azure Active Directory inside of the web browser
|
878 | * using the interactive login flow.
|
879 | */
|
880 | export declare class InteractiveBrowserCredential implements TokenCredential {
|
881 | private msalFlow;
|
882 | private disableAutomaticAuthentication?;
|
883 | /**
|
884 | * Creates an instance of InteractiveBrowserCredential with the details needed.
|
885 | *
|
886 | * This credential uses the [Authorization Code Flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
887 | * On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
|
888 | * 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.
|
889 | *
|
890 | * 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.
|
891 | * 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).
|
892 | *
|
893 | * @param options - Options for configuring the client which makes the authentication requests.
|
894 | */
|
895 | constructor(options?: InteractiveBrowserCredentialNodeOptions | InteractiveBrowserCredentialInBrowserOptions);
|
896 | /**
|
897 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
898 | * If authentication fails, a {with the details of the failure.
CredentialUnavailableError} will be thrown |
899 | *
|
900 | * If the user provided the option `disableAutomaticAuthentication`,
|
901 | * once the token can't be retrieved silently,
|
902 | * this method won't attempt to request user interaction to retrieve the token.
|
903 | *
|
904 | * for which the token will have access.
scopes - The list of scopes |
905 | * any requests this
options - The options used to configure |
906 | * TokenCredential implementation might make.
|
907 | */
|
908 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
909 | /**
|
910 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
911 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
912 | *
|
913 | * If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
914 | *
|
915 | * On Node.js, this credential has [Proof Key for Code Exchange (PKCE)](https://datatracker.ietf.org/doc/html/rfc7636) enabled by default.
|
916 | * PKCE is a security feature that mitigates authentication code interception attacks.
|
917 | *
|
918 | * @param scopes - The list of scopes for which the token will have access.
|
919 | * @param options - The options used to configure any requests this
|
920 | * TokenCredential implementation might make.
|
921 | */
|
922 | authenticate(scopes: string | string[], options?: GetTokenOptions): Promise<AuthenticationRecord | undefined>;
|
923 | }
|
924 |
|
925 | /**
|
926 | * Defines the common options for the InteractiveBrowserCredential class.
|
927 | */
|
928 | export declare interface InteractiveBrowserCredentialInBrowserOptions extends InteractiveCredentialOptions {
|
929 | /**
|
930 | * Gets the redirect URI of the application. This should be same as the value
|
931 | * in the application registration portal. Defaults to `window.location.href`.
|
932 | */
|
933 | redirectUri?: string | (() => string);
|
934 | /**
|
935 | * The Azure Active Directory tenant (directory) ID.
|
936 | */
|
937 | tenantId?: string;
|
938 | /**
|
939 | * The client (application) ID of an App Registration in the tenant.
|
940 | * This parameter is required on the browser.
|
941 | */
|
942 | clientId: string;
|
943 | /**
|
944 | * Specifies whether a redirect or a popup window should be used to
|
945 | * initiate the user authentication flow. Possible values are "redirect"
|
946 | * or "popup" (default) for browser and "popup" (default) for node.
|
947 | *
|
948 | */
|
949 | loginStyle?: BrowserLoginStyle;
|
950 | /**
|
951 | * loginHint allows a user name to be pre-selected for interactive logins.
|
952 | * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.
|
953 | */
|
954 | loginHint?: string;
|
955 | }
|
956 |
|
957 | /**
|
958 | * Defines the common options for the InteractiveBrowserCredential class.
|
959 | */
|
960 | export declare interface InteractiveBrowserCredentialNodeOptions extends InteractiveCredentialOptions, CredentialPersistenceOptions {
|
961 | /**
|
962 | * Gets the redirect URI of the application. This should be same as the value
|
963 | * in the application registration portal. Defaults to `window.location.href`.
|
964 | */
|
965 | redirectUri?: string | (() => string);
|
966 | /**
|
967 | * The Azure Active Directory tenant (directory) ID.
|
968 | */
|
969 | tenantId?: string;
|
970 | /**
|
971 | * The client (application) ID of an App Registration in the tenant.
|
972 | */
|
973 | clientId?: string;
|
974 | /**
|
975 | * loginHint allows a user name to be pre-selected for interactive logins.
|
976 | * Setting this option skips the account selection prompt and immediately attempts to login with the specified account.
|
977 | */
|
978 | loginHint?: string;
|
979 | }
|
980 |
|
981 | /**
|
982 | * Common constructor options for the Identity credentials that requires user interaction.
|
983 | */
|
984 | export declare interface InteractiveCredentialOptions extends TokenCredentialOptions {
|
985 | /**
|
986 | * Result of a previous authentication that can be used to retrieve the cached credentials of each individual account.
|
987 | * This is necessary to provide in case the application wants to work with more than one account per
|
988 | * Client ID and Tenant ID pair.
|
989 | *
|
990 | * This record can be retrieved by calling to the credential's `authenticate()` method, as follows:
|
991 | *
|
992 | * const authenticationRecord = await credential.authenticate();
|
993 | *
|
994 | */
|
995 | authenticationRecord?: AuthenticationRecord;
|
996 | /**
|
997 | * Makes getToken throw if a manual authentication is necessary.
|
998 | * Developers will need to call to `authenticate()` to control when to manually authenticate.
|
999 | */
|
1000 | disableAutomaticAuthentication?: boolean;
|
1001 | }
|
1002 |
|
1003 | /**
|
1004 | * The AzureLogger used for all clients within the identity package
|
1005 | */
|
1006 | export declare const logger: AzureLogger;
|
1007 |
|
1008 | /**
|
1009 | * Attempts authentication using a managed identity available at the deployment environment.
|
1010 | * This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
|
1011 | * Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
|
1012 | *
|
1013 | * More information about configuring managed identities can be found here:
|
1014 | * https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
|
1015 | */
|
1016 | export declare class ManagedIdentityCredential implements TokenCredential {
|
1017 | private identityClient;
|
1018 | private clientId;
|
1019 | private resourceId;
|
1020 | private isEndpointUnavailable;
|
1021 | private isAvailableIdentityClient;
|
1022 | /**
|
1023 | * Creates an instance of ManagedIdentityCredential with the client ID of a
|
1024 | * user-assigned identity, or app registration (when working with AKS pod-identity).
|
1025 | *
|
1026 | * @param clientId - The client ID of the user-assigned identity, or app registration (when working with AKS pod-identity).
|
1027 | * @param options - Options for configuring the client which makes the access token request.
|
1028 | */
|
1029 | constructor(clientId: string, options?: TokenCredentialOptions);
|
1030 | /**
|
1031 | * Creates an instance of ManagedIdentityCredential with clientId
|
1032 | *
|
1033 | * @param options - Options for configuring the client which makes the access token request.
|
1034 | */
|
1035 | constructor(options?: ManagedIdentityCredentialClientIdOptions);
|
1036 | /**
|
1037 | * Creates an instance of ManagedIdentityCredential with Resource Id
|
1038 | *
|
1039 | * @param options - Options for configuring the resource which makes the access token request.
|
1040 | */
|
1041 | constructor(options?: ManagedIdentityCredentialResourceIdOptions);
|
1042 | private cachedMSI;
|
1043 | private cachedAvailableMSI;
|
1044 | private authenticateManagedIdentity;
|
1045 | /**
|
1046 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
1047 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
1048 | * If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
|
1049 | *
|
1050 | * @param scopes - The list of scopes for which the token will have access.
|
1051 | * @param options - The options used to configure any requests this
|
1052 | * TokenCredential implementation might make.
|
1053 | */
|
1054 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
1055 | }
|
1056 |
|
1057 | /**
|
1058 | * Options to send on the {@link ManagedIdentityCredential} constructor.
|
1059 | * This variation supports `clientId` and not `resourceId`, since only one of both is supported.
|
1060 | */
|
1061 | export declare interface ManagedIdentityCredentialClientIdOptions extends TokenCredentialOptions {
|
1062 | /**
|
1063 | * The client ID of the user - assigned identity, or app registration(when working with AKS pod - identity).
|
1064 | */
|
1065 | clientId?: string;
|
1066 | }
|
1067 |
|
1068 | /**
|
1069 | * Options to send on the {@link ManagedIdentityCredential} constructor.
|
1070 | * This variation supports `resourceId` and not `clientId`, since only one of both is supported.
|
1071 | */
|
1072 | export declare interface ManagedIdentityCredentialResourceIdOptions extends TokenCredentialOptions {
|
1073 | /**
|
1074 | * Allows specifying a custom resource Id.
|
1075 | * In scenarios such as when user assigned identities are created using an ARM template,
|
1076 | * where the resource Id of the identity is known but the client Id can't be known ahead of time,
|
1077 | * this parameter allows programs to use these user assigned identities
|
1078 | * without having to first determine the client Id of the created identity.
|
1079 | */
|
1080 | resourceId: string;
|
1081 | }
|
1082 |
|
1083 | /**
|
1084 | * 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).
|
1085 | */
|
1086 | export declare class OnBehalfOfCredential implements TokenCredential {
|
1087 | private options;
|
1088 | private msalFlow;
|
1089 | /**
|
1090 | * Creates an instance of the {@link OnBehalfOfCredential} with the details
|
1091 | * needed to authenticate against Azure Active Directory with path to a PEM certificate,
|
1092 | * and an user assertion.
|
1093 | *
|
1094 | * Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
1095 | *
|
1096 | * ```ts
|
1097 | * const tokenCredential = new OnBehalfOfCredential({
|
1098 | * tenantId,
|
1099 | * clientId,
|
1100 | * certificatePath: "/path/to/certificate.pem",
|
1101 | * userAssertionToken: "access-token"
|
1102 | * });
|
1103 | * const client = new KeyClient("vault-url", tokenCredential);
|
1104 | *
|
1105 | * await client.getKey("key-name");
|
1106 | * ```
|
1107 | *
|
1108 | * @param options - Optional parameters, generally common across credentials.
|
1109 | */
|
1110 | constructor(options: OnBehalfOfCredentialCertificateOptions & TokenCredentialOptions & CredentialPersistenceOptions);
|
1111 | /**
|
1112 | * Creates an instance of the {@link OnBehalfOfCredential} with the details
|
1113 | * needed to authenticate against Azure Active Directory with a client
|
1114 | * secret and an user assertion.
|
1115 | *
|
1116 | * Example using the `KeyClient` from [\@azure/keyvault-keys](https://www.npmjs.com/package/\@azure/keyvault-keys):
|
1117 | *
|
1118 | * ```ts
|
1119 | * const tokenCredential = new OnBehalfOfCredential({
|
1120 | * tenantId,
|
1121 | * clientId,
|
1122 | * clientSecret,
|
1123 | * userAssertionToken: "access-token"
|
1124 | * });
|
1125 | * const client = new KeyClient("vault-url", tokenCredential);
|
1126 | *
|
1127 | * await client.getKey("key-name");
|
1128 | * ```
|
1129 | *
|
1130 | * @param options - Optional parameters, generally common across credentials.
|
1131 | */
|
1132 | constructor(options: OnBehalfOfCredentialSecretOptions & TokenCredentialOptions & CredentialPersistenceOptions);
|
1133 | /**
|
1134 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
1135 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
1136 | *
|
1137 | * @param scopes - The list of scopes for which the token will have access.
|
1138 | * @param options - The options used to configure the underlying network requests.
|
1139 | */
|
1140 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
1141 | }
|
1142 |
|
1143 | /**
|
1144 | * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a certificate.
|
1145 | */
|
1146 | export declare interface OnBehalfOfCredentialCertificateOptions {
|
1147 | /**
|
1148 | * The Azure Active Directory tenant (directory) ID.
|
1149 | */
|
1150 | tenantId: string;
|
1151 | /**
|
1152 | * The client (application) ID of an App Registration in the tenant.
|
1153 | */
|
1154 | clientId: string;
|
1155 | /**
|
1156 | * The path to a PEM-encoded public/private key certificate on the filesystem.
|
1157 | */
|
1158 | certificatePath: string;
|
1159 | /**
|
1160 | * The user assertion for the On-Behalf-Of flow.
|
1161 | */
|
1162 | userAssertionToken: string;
|
1163 | /**
|
1164 | * Option to include x5c header for SubjectName and Issuer name authorization.
|
1165 | * Set this option to send base64 encoded public certificate in the client assertion header as an x5c claim
|
1166 | */
|
1167 | sendCertificateChain?: boolean;
|
1168 | }
|
1169 |
|
1170 | /**
|
1171 | * Optional parameters for the {@link OnBehalfOfCredential} class.
|
1172 | */
|
1173 | export declare type OnBehalfOfCredentialOptions = (OnBehalfOfCredentialSecretOptions | OnBehalfOfCredentialCertificateOptions) & TokenCredentialOptions & CredentialPersistenceOptions;
|
1174 |
|
1175 | /**
|
1176 | * Defines the parameters to authenticate the {@link OnBehalfOfCredential} with a secret.
|
1177 | */
|
1178 | export declare interface OnBehalfOfCredentialSecretOptions {
|
1179 | /**
|
1180 | * The Azure Active Directory tenant (directory) ID.
|
1181 | */
|
1182 | tenantId: string;
|
1183 | /**
|
1184 | * The client (application) ID of an App Registration in the tenant.
|
1185 | */
|
1186 | clientId: string;
|
1187 | /**
|
1188 | * A client secret that was generated for the App Registration.
|
1189 | */
|
1190 | clientSecret: string;
|
1191 | /**
|
1192 | * The user assertion for the On-Behalf-Of flow.
|
1193 | */
|
1194 | userAssertionToken: string;
|
1195 | }
|
1196 |
|
1197 | /**
|
1198 | * Serializes an `AuthenticationRecord` into a string.
|
1199 | *
|
1200 | * The output of a serialized authentication record will contain the following properties:
|
1201 | *
|
1202 | * - "authority"
|
1203 | * - "homeAccountId"
|
1204 | * - "clientId"
|
1205 | * - "tenantId"
|
1206 | * - "username"
|
1207 | * - "version"
|
1208 | *
|
1209 | * To later convert this string to a serialized `AuthenticationRecord`, please use the exported function `deserializeAuthenticationRecord()`.
|
1210 | */
|
1211 | export declare function serializeAuthenticationRecord(record: AuthenticationRecord): string;
|
1212 |
|
1213 | /**
|
1214 | * Parameters that enable token cache persistence in the Identity credentials.
|
1215 | */
|
1216 | export declare interface TokenCachePersistenceOptions {
|
1217 | /**
|
1218 | * If set to true, persistent token caching will be enabled for this credential instance.
|
1219 | */
|
1220 | enabled: boolean;
|
1221 | /**
|
1222 | * Unique identifier for the persistent token cache.
|
1223 | *
|
1224 | * Based on this identifier, the persistence file will be located in any of the following places:
|
1225 | * - Darwin: '/Users/user/.IdentityService/<name>'
|
1226 | * - Windows 8+: 'C:\\Users\\user\\AppData\\Local\\.IdentityService\\<name>'
|
1227 | * - Linux: '/home/user/.IdentityService/<name>'
|
1228 | */
|
1229 | name?: string;
|
1230 | /**
|
1231 | * If set to true, the cache will be stored without encryption if no OS level user encryption is available.
|
1232 | * When set to false, the PersistentTokenCache will throw an error if no OS level user encryption is available.
|
1233 | */
|
1234 | unsafeAllowUnencryptedStorage?: boolean;
|
1235 | }
|
1236 |
|
1237 | export { TokenCredential }
|
1238 |
|
1239 | /**
|
1240 | * Provides options to configure how the Identity library makes authentication
|
1241 | * requests to Azure Active Directory.
|
1242 | */
|
1243 | export declare interface TokenCredentialOptions extends CommonClientOptions {
|
1244 | /**
|
1245 | * The authority host to use for authentication requests.
|
1246 | * Possible values are available through {@link AzureAuthorityHosts}.
|
1247 | * The default is "https://login.microsoftonline.com".
|
1248 | */
|
1249 | authorityHost?: string;
|
1250 | /**
|
1251 | * Allows logging account information once the authentication flow succeeds.
|
1252 | */
|
1253 | loggingOptions?: LogPolicyOptions & {
|
1254 | allowLoggingAccountIdentifiers?: boolean;
|
1255 | };
|
1256 | }
|
1257 |
|
1258 | /**
|
1259 | * Extend Azure Identity with additional functionality. Pass a plugin from
|
1260 | * a plugin package, such as:
|
1261 | *
|
1262 | * - `@azure/identity-cache-persistence`: provides persistent token caching
|
1263 | * - `@azure/identity-vscode`: provides the dependencies of
|
1264 | * `VisualStudioCodeCredential` and enables it
|
1265 | *
|
1266 | * Example:
|
1267 | *
|
1268 | * ```javascript
|
1269 | * import { cachePersistencePlugin } from "@azure/identity-cache-persistence";
|
1270 | *
|
1271 | * import { useIdentityPlugin, DefaultAzureCredential } from "@azure/identity";
|
1272 | * useIdentityPlugin(cachePersistencePlugin);
|
1273 | *
|
1274 | * // The plugin has the capability to extend `DefaultAzureCredential` and to
|
1275 | * // add middleware to the underlying credentials, such as persistence.
|
1276 | * const credential = new DefaultAzureCredential({
|
1277 | * tokenCachePersistenceOptions: {
|
1278 | * enabled: true
|
1279 | * }
|
1280 | * });
|
1281 | * ```
|
1282 | *
|
1283 | * @param plugin - the plugin to register
|
1284 | */
|
1285 | export declare function useIdentityPlugin(plugin: IdentityPlugin): void;
|
1286 |
|
1287 | /**
|
1288 | * Enables authentication to Azure Active Directory with a user's
|
1289 | * username and password. This credential requires a high degree of
|
1290 | * trust so you should only use it when other, more secure credential
|
1291 | * types can't be used.
|
1292 | */
|
1293 | export declare class UsernamePasswordCredential implements TokenCredential {
|
1294 | private msalFlow;
|
1295 | /**
|
1296 | * Creates an instance of the UsernamePasswordCredential with the details
|
1297 | * needed to authenticate against Azure Active Directory with a username
|
1298 | * and password.
|
1299 | *
|
1300 | * @param tenantId - The Azure Active Directory tenant (directory).
|
1301 | * @param clientId - The client (application) ID of an App Registration in the tenant.
|
1302 | * @param username - The user account's e-mail address (user name).
|
1303 | * @param password - The user account's account password
|
1304 | * @param options - Options for configuring the client which makes the authentication request.
|
1305 | */
|
1306 | constructor(tenantId: string, clientId: string, username: string, password: string, options?: UsernamePasswordCredentialOptions);
|
1307 | /**
|
1308 | * Authenticates with Azure Active Directory and returns an access token if successful.
|
1309 | * If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
1310 | *
|
1311 | * If the user provided the option `disableAutomaticAuthentication`,
|
1312 | * once the token can't be retrieved silently,
|
1313 | * this method won't attempt to request user interaction to retrieve the token.
|
1314 | *
|
1315 | * @param scopes - The list of scopes for which the token will have access.
|
1316 | * @param options - The options used to configure any requests this
|
1317 | * TokenCredential implementation might make.
|
1318 | */
|
1319 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
1320 | }
|
1321 |
|
1322 | /**
|
1323 | * Defines options for the {@link UsernamePasswordCredential} class.
|
1324 | */
|
1325 | export declare interface UsernamePasswordCredentialOptions extends TokenCredentialOptions, CredentialPersistenceOptions {
|
1326 | }
|
1327 |
|
1328 | /**
|
1329 | * Connects to Azure using the credential provided by the VSCode extension 'Azure Account'.
|
1330 | * Once the user has logged in via the extension, this credential can share the same refresh token
|
1331 | * that is cached by the extension.
|
1332 | */
|
1333 | export declare class VisualStudioCodeCredential implements TokenCredential {
|
1334 | private identityClient;
|
1335 | private tenantId;
|
1336 | private cloudName;
|
1337 | /**
|
1338 | * Creates an instance of VisualStudioCodeCredential to use for automatically authenticating via VSCode.
|
1339 | *
|
1340 | * **Note**: `VisualStudioCodeCredential` is provided by a plugin package:
|
1341 | * `@azure/identity-vscode`. If this package is not installed and registered
|
1342 | * using the plugin API (`useIdentityPlugin`), then authentication using
|
1343 | * `VisualStudioCodeCredential` will not be available.
|
1344 | *
|
1345 | * @param options - Options for configuring the client which makes the authentication request.
|
1346 | */
|
1347 | constructor(options?: VisualStudioCodeCredentialOptions);
|
1348 | /**
|
1349 | * Runs preparations for any further getToken request.
|
1350 | */
|
1351 | private prepare;
|
1352 | /**
|
1353 | * The promise of the single preparation that will be executed at the first getToken request for an instance of this class.
|
1354 | */
|
1355 | private preparePromise;
|
1356 | /**
|
1357 | * Runs preparations for any further getToken, but only once.
|
1358 | */
|
1359 | private prepareOnce;
|
1360 | /**
|
1361 | * Returns the token found by searching VSCode's authentication cache or
|
1362 | * returns null if no token could be found.
|
1363 | *
|
1364 | * @param scopes - The list of scopes for which the token will have access.
|
1365 | * @param options - The options used to configure any requests this
|
1366 | * `TokenCredential` implementation might make.
|
1367 | */
|
1368 | getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>;
|
1369 | }
|
1370 |
|
1371 | /**
|
1372 | * Provides options to configure the Visual Studio Code credential.
|
1373 | */
|
1374 | export declare interface VisualStudioCodeCredentialOptions extends TokenCredentialOptions {
|
1375 | /**
|
1376 | * Optionally pass in a Tenant ID to be used as part of the credential
|
1377 | */
|
1378 | tenantId?: string;
|
1379 | }
|
1380 |
|
1381 | export { }
|
1382 |
|
\ | No newline at end of file |