@azure/identity 3.3.2-alpha.20231013.2 → 3.3.2-alpha.20231017.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/README.md +14 -14
- package/dist/index.js +87 -68
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/authorityValidationOptions.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +6 -6
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +3 -3
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +6 -6
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +3 -3
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.js +5 -5
- package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +5 -5
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js +7 -7
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js +7 -7
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js +6 -6
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js +1 -1
- package/dist-esm/src/credentials/environmentCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +3 -3
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +9 -9
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +8 -8
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +14 -4
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +11 -2
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js +4 -4
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +6 -6
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.js +6 -6
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +2 -2
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js +2 -2
- package/dist-esm/src/credentials/workloadIdentityCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredential.js +5 -5
- package/dist-esm/src/credentials/workloadIdentityCredential.js.map +1 -1
- package/dist-esm/src/credentials/workloadIdentityCredentialOptions.js.map +1 -1
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +2 -2
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +2 -2
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/tokenCredentialOptions.js.map +1 -1
- package/dist-esm/src/util/scopeUtils.js +1 -1
- package/dist-esm/src/util/scopeUtils.js.map +1 -1
- package/dist-esm/src/util/tenantIdUtils.js +3 -3
- package/dist-esm/src/util/tenantIdUtils.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +70 -70
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Azure Identity client library for JavaScript
|
|
2
2
|
|
|
3
|
-
The Azure Identity library provides [
|
|
3
|
+
The Azure Identity library provides [Microsoft Entra ID](https://learn.microsoft.com/azure/active-directory/fundamentals/active-directory-whatis) ([formerly Azure Active Directory](https://learn.microsoft.com/azure/active-directory/fundamentals/new-name)) token authentication through a set of convenient [TokenCredential](https://learn.microsoft.com/javascript/api/@azure/core-auth/tokencredential) implementations.
|
|
4
4
|
|
|
5
5
|
For examples of various credentials, see the [Azure Identity examples page](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md).
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ Key links:
|
|
|
9
9
|
- [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity)
|
|
10
10
|
- [Package (npm)](https://www.npmjs.com/package/@azure/identity)
|
|
11
11
|
- [API Reference Documentation](https://learn.microsoft.com/javascript/api/@azure/identity)
|
|
12
|
-
- [
|
|
12
|
+
- [Microsoft Entra ID documentation](https://azure.microsoft.com/services/active-directory/)
|
|
13
13
|
- [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2)
|
|
14
14
|
|
|
15
15
|
## Getting started
|
|
@@ -110,13 +110,13 @@ To authenticate Azure SDK clients within web browsers, we offer the `Interactive
|
|
|
110
110
|
|
|
111
111
|
## Key concepts
|
|
112
112
|
|
|
113
|
-
If this is your first time using `@azure/identity` or
|
|
113
|
+
If this is your first time using `@azure/identity` or Microsoft Entra ID, read [Using `@azure/identity` with Microsoft Entra ID](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/using-azure-identity.md) first. This document provides a deeper understanding of the platform and how to configure your Azure account correctly.
|
|
114
114
|
|
|
115
115
|
### Credentials
|
|
116
116
|
|
|
117
117
|
A credential is a class which contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept credentials when they're constructed. Service clients use those credentials to authenticate requests to the service.
|
|
118
118
|
|
|
119
|
-
The Azure Identity library focuses on OAuth authentication with
|
|
119
|
+
The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID, and it offers a variety of credential classes capable of acquiring a Microsoft Entra token to authenticate service requests. All of the credential classes in this library are implementations of the [TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-auth/src/tokenCredential.ts) abstract class, and any of them can be used by to construct service clients capable of authenticating with a TokenCredential.
|
|
120
120
|
|
|
121
121
|
See [Credential Classes](#credential-classes).
|
|
122
122
|
|
|
@@ -217,7 +217,7 @@ For examples of how to use managed identity for authentication, see [the example
|
|
|
217
217
|
|
|
218
218
|
## Cloud configuration
|
|
219
219
|
|
|
220
|
-
Credentials default to authenticating to the
|
|
220
|
+
Credentials default to authenticating to the Microsoft Entra endpoint for Azure Public Cloud. To access resources in other clouds, such as Azure Government or a private cloud, configure credentials with the `authorityHost` argument in the constructor. The `AzureAuthorityHosts` interface defines authorities for well-known clouds. For the US Government cloud, you could instantiate a credential this way:
|
|
221
221
|
|
|
222
222
|
```typescript
|
|
223
223
|
import { AzureAuthorityHosts, ClientSecretCredential } from "@azure/identity";
|
|
@@ -243,7 +243,7 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
|
243
243
|
| [`ChainedTokenCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/chainedtokencredential?view=azure-node-latest) | Allows users to define custom authentication flows composing multiple credentials. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#chaining-credentials) |
|
|
244
244
|
| [`EnvironmentCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/environmentcredential?view=azure-node-latest) | Authenticates a service principal or user via credential information specified in environment variables. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-a-service-principal-with-environment-credentials) |
|
|
245
245
|
| [`ManagedIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/managedidentitycredential?view=azure-node-latest) | Authenticates the managed identity of an Azure resource. | [example](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-in-azure-with-managed-identity) |
|
|
246
|
-
| [`WorkloadIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/workloadidentitycredential?view=azure-node-latest)| Supports [
|
|
246
|
+
| [`WorkloadIdentityCredential`](https://learn.microsoft.com/javascript/api/@azure/identity/workloadidentitycredential?view=azure-node-latest)| Supports [Microsoft Entra Workload ID](https://learn.microsoft.com/azure/aks/workload-identity-overview) on Kubernetes. | |
|
|
247
247
|
|
|
248
248
|
### Authenticate service principals
|
|
249
249
|
|
|
@@ -280,16 +280,16 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
|
280
280
|
|
|
281
281
|
| Variable name | Value |
|
|
282
282
|
| --------------------- | --------------------------------------- |
|
|
283
|
-
| `AZURE_CLIENT_ID` | ID of
|
|
284
|
-
| `AZURE_TENANT_ID` | ID of the application's
|
|
283
|
+
| `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
|
|
284
|
+
| `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
|
|
285
285
|
| `AZURE_CLIENT_SECRET` | one of the application's client secrets |
|
|
286
286
|
|
|
287
287
|
#### Service principal with certificate
|
|
288
288
|
|
|
289
289
|
| Variable name | Value |
|
|
290
290
|
| ----------------------------------- | ------------------------------------------------------------ |
|
|
291
|
-
| `AZURE_CLIENT_ID` | ID of
|
|
292
|
-
| `AZURE_TENANT_ID` | ID of the application's
|
|
291
|
+
| `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
|
|
292
|
+
| `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
|
|
293
293
|
| `AZURE_CLIENT_CERTIFICATE_PATH` | path to a PEM-encoded certificate file including private key |
|
|
294
294
|
| `AZURE_CLIENT_CERTIFICATE_PASSWORD` | password of the certificate file, if any |
|
|
295
295
|
|
|
@@ -297,8 +297,8 @@ Not all credentials require this configuration. Credentials that authenticate th
|
|
|
297
297
|
|
|
298
298
|
| Variable name | Value |
|
|
299
299
|
| ----------------- | --------------------------------------- |
|
|
300
|
-
| `AZURE_CLIENT_ID` | ID of
|
|
301
|
-
| `AZURE_TENANT_ID` | ID of the application's
|
|
300
|
+
| `AZURE_CLIENT_ID` | ID of a Microsoft Entra application |
|
|
301
|
+
| `AZURE_TENANT_ID` | ID of the application's Microsoft Entra tenant |
|
|
302
302
|
| `AZURE_USERNAME` | a username (usually an email address) |
|
|
303
303
|
| `AZURE_PASSWORD` | that user's password |
|
|
304
304
|
|
|
@@ -314,7 +314,7 @@ Token caching is a feature provided by the Azure Identity library that allows ap
|
|
|
314
314
|
|
|
315
315
|
- Cache tokens in memory (default) and on disk (opt-in).
|
|
316
316
|
- Improve resilience and performance.
|
|
317
|
-
- Reduce the number of requests made to
|
|
317
|
+
- Reduce the number of requests made to Microsoft Entra ID to obtain access tokens.
|
|
318
318
|
|
|
319
319
|
The Azure Identity library offers both in-memory and persistent disk caching. For more details, see the [token caching documentation](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/TOKEN_CACHING.md).
|
|
320
320
|
|
|
@@ -330,7 +330,7 @@ API documentation for this library can be found on our [documentation site](http
|
|
|
330
330
|
|
|
331
331
|
### Client library support
|
|
332
332
|
|
|
333
|
-
Client and management libraries listed on the [Azure SDK releases page](https://azure.github.io/azure-sdk/releases/latest/js.html) that support
|
|
333
|
+
Client and management libraries listed on the [Azure SDK releases page](https://azure.github.io/azure-sdk/releases/latest/js.html) that support Microsoft Entra authentication accept credentials from this library. Learn more about using these libraries in their documentation, which is linked from the releases page.
|
|
334
334
|
|
|
335
335
|
### Known issues
|
|
336
336
|
|
package/dist/index.js
CHANGED
|
@@ -557,8 +557,8 @@ function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowe
|
|
|
557
557
|
* @internal
|
|
558
558
|
*/
|
|
559
559
|
function checkTenantId(logger, tenantId) {
|
|
560
|
-
if (!tenantId.match(/^[0-9a-zA-Z
|
|
561
|
-
const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://
|
|
560
|
+
if (!tenantId.match(/^[0-9a-zA-Z-.]+$/)) {
|
|
561
|
+
const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://learn.microsoft.com/partner-center/find-ids-and-domain-names.");
|
|
562
562
|
logger.info(formatError("", error));
|
|
563
563
|
throw error;
|
|
564
564
|
}
|
|
@@ -582,7 +582,7 @@ function resolveTenantId(logger, tenantId, clientId) {
|
|
|
582
582
|
/**
|
|
583
583
|
* @internal
|
|
584
584
|
*/
|
|
585
|
-
function
|
|
585
|
+
function resolveAdditionallyAllowedTenantIds(additionallyAllowedTenants) {
|
|
586
586
|
if (!additionallyAllowedTenants || additionallyAllowedTenants.length === 0) {
|
|
587
587
|
return [];
|
|
588
588
|
}
|
|
@@ -1058,7 +1058,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1058
1058
|
this.requiresConfidential = false;
|
|
1059
1059
|
this.msalConfig = this.defaultNodeMsalConfig(options);
|
|
1060
1060
|
this.tenantId = resolveTenantId(options.logger, options.tenantId, options.clientId);
|
|
1061
|
-
this.additionallyAllowedTenantIds =
|
|
1061
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds((_a = options === null || options === void 0 ? void 0 : options.tokenCredentialOptions) === null || _a === void 0 ? void 0 : _a.additionallyAllowedTenants);
|
|
1062
1062
|
this.clientId = this.msalConfig.auth.clientId;
|
|
1063
1063
|
if (options === null || options === void 0 ? void 0 : options.getAssertion) {
|
|
1064
1064
|
this.getAssertion = options.getAssertion;
|
|
@@ -1398,7 +1398,7 @@ class VisualStudioCodeCredential {
|
|
|
1398
1398
|
else {
|
|
1399
1399
|
this.tenantId = CommonTenantId;
|
|
1400
1400
|
}
|
|
1401
|
-
this.additionallyAllowedTenantIds =
|
|
1401
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
1402
1402
|
checkUnsupportedTenant(this.tenantId);
|
|
1403
1403
|
}
|
|
1404
1404
|
/**
|
|
@@ -1741,20 +1741,21 @@ const imdsMsi = {
|
|
|
1741
1741
|
skipQuery: true,
|
|
1742
1742
|
});
|
|
1743
1743
|
return tracingClient.withSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions, async (options) => {
|
|
1744
|
-
var _a;
|
|
1744
|
+
var _a, _b;
|
|
1745
1745
|
requestOptions.tracingOptions = options.tracingOptions;
|
|
1746
1746
|
// Create a request with a timeout since we expect that
|
|
1747
1747
|
// not having a "Metadata" header should cause an error to be
|
|
1748
1748
|
// returned quickly from the endpoint, proving its availability.
|
|
1749
1749
|
const request = coreRestPipeline.createPipelineRequest(requestOptions);
|
|
1750
|
-
// Default to
|
|
1750
|
+
// Default to 1000 if the default of 0 is used.
|
|
1751
1751
|
// Negative values can still be used to disable the timeout.
|
|
1752
|
-
request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) ||
|
|
1752
|
+
request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) || 1000;
|
|
1753
1753
|
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
1754
1754
|
request.allowInsecureConnection = true;
|
|
1755
|
+
let response;
|
|
1755
1756
|
try {
|
|
1756
1757
|
logger$j.info(`${msiName$4}: Pinging the Azure IMDS endpoint`);
|
|
1757
|
-
await identityClient.sendRequest(request);
|
|
1758
|
+
response = await identityClient.sendRequest(request);
|
|
1758
1759
|
}
|
|
1759
1760
|
catch (err) {
|
|
1760
1761
|
// If the request failed, or Node.js was unable to establish a connection,
|
|
@@ -1762,9 +1763,18 @@ const imdsMsi = {
|
|
|
1762
1763
|
if (coreUtil.isError(err)) {
|
|
1763
1764
|
logger$j.verbose(`${msiName$4}: Caught error ${err.name}: ${err.message}`);
|
|
1764
1765
|
}
|
|
1766
|
+
// This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network"
|
|
1767
|
+
// rather than just timing out, as expected.
|
|
1765
1768
|
logger$j.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
1766
1769
|
return false;
|
|
1767
1770
|
}
|
|
1771
|
+
if (response.status === 403) {
|
|
1772
|
+
if ((_b = response.bodyAsText) === null || _b === void 0 ? void 0 : _b.includes("A socket operation was attempted to an unreachable network")) {
|
|
1773
|
+
logger$j.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
1774
|
+
logger$j.info(`${msiName$4}: ${response.bodyAsText}`);
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1768
1778
|
// If we received any response, the endpoint is available
|
|
1769
1779
|
logger$j.info(`${msiName$4}: The Azure IMDS endpoint is available`);
|
|
1770
1780
|
return true;
|
|
@@ -1958,10 +1968,10 @@ const logger$h = credentialLogger("ClientAssertionCredential");
|
|
|
1958
1968
|
class ClientAssertionCredential {
|
|
1959
1969
|
/**
|
|
1960
1970
|
* Creates an instance of the ClientAssertionCredential with the details
|
|
1961
|
-
* needed to authenticate against
|
|
1971
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
1962
1972
|
* assertion provided by the developer through the `getAssertion` function parameter.
|
|
1963
1973
|
*
|
|
1964
|
-
* @param tenantId - The
|
|
1974
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
1965
1975
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
1966
1976
|
* @param getAssertion - A function that retrieves the assertion for the credential to use.
|
|
1967
1977
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -1971,13 +1981,13 @@ class ClientAssertionCredential {
|
|
|
1971
1981
|
throw new Error("ClientAssertionCredential: tenantId, clientId, and clientAssertion are required parameters.");
|
|
1972
1982
|
}
|
|
1973
1983
|
this.tenantId = tenantId;
|
|
1974
|
-
this.additionallyAllowedTenantIds =
|
|
1984
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
1975
1985
|
this.clientId = clientId;
|
|
1976
1986
|
this.options = options;
|
|
1977
1987
|
this.msalFlow = new MsalClientAssertion(Object.assign(Object.assign({}, options), { logger: logger$h, clientId: this.clientId, tenantId: this.tenantId, tokenCredentialOptions: this.options, getAssertion }));
|
|
1978
1988
|
}
|
|
1979
1989
|
/**
|
|
1980
|
-
* Authenticates with
|
|
1990
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
1981
1991
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
1982
1992
|
*
|
|
1983
1993
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2018,14 +2028,14 @@ const logger$g = credentialLogger(credentialName$3);
|
|
|
2018
2028
|
* Identity authentication, you can avoid the need to manage and rotate service principals or managed identities for
|
|
2019
2029
|
* each application on each VM. Additionally, because SACs are created automatically and managed by Azure, you don't
|
|
2020
2030
|
* need to worry about storing and securing sensitive credentials themselves.
|
|
2021
|
-
* The WorkloadIdentityCredential supports
|
|
2031
|
+
* The WorkloadIdentityCredential supports Microsoft Entra Workload ID authentication on Azure Kubernetes and acquires
|
|
2022
2032
|
* a token using the SACs available in the Azure Kubernetes environment.
|
|
2023
|
-
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">
|
|
2024
|
-
* Workload
|
|
2033
|
+
* Refer to <a href="https://learn.microsoft.com/azure/aks/workload-identity-overview">Microsoft Entra
|
|
2034
|
+
* Workload ID</a> for more information.
|
|
2025
2035
|
*/
|
|
2026
2036
|
class WorkloadIdentityCredential {
|
|
2027
2037
|
/**
|
|
2028
|
-
* WorkloadIdentityCredential supports
|
|
2038
|
+
* WorkloadIdentityCredential supports Microsoft Entra Workload ID on Kubernetes.
|
|
2029
2039
|
*
|
|
2030
2040
|
* @param options - The identity client options to use for authentication.
|
|
2031
2041
|
*/
|
|
@@ -2049,7 +2059,7 @@ class WorkloadIdentityCredential {
|
|
|
2049
2059
|
}
|
|
2050
2060
|
}
|
|
2051
2061
|
/**
|
|
2052
|
-
* Authenticates with
|
|
2062
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2053
2063
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2054
2064
|
*
|
|
2055
2065
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2289,7 +2299,7 @@ const logger$c = credentialLogger("ManagedIdentityCredential");
|
|
|
2289
2299
|
* Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
|
|
2290
2300
|
*
|
|
2291
2301
|
* More information about configuring managed identities can be found here:
|
|
2292
|
-
* https://
|
|
2302
|
+
* https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
|
|
2293
2303
|
*/
|
|
2294
2304
|
class ManagedIdentityCredential {
|
|
2295
2305
|
/**
|
|
@@ -2388,7 +2398,7 @@ class ManagedIdentityCredential {
|
|
|
2388
2398
|
}
|
|
2389
2399
|
}
|
|
2390
2400
|
/**
|
|
2391
|
-
* Authenticates with
|
|
2401
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2392
2402
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2393
2403
|
* If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
|
|
2394
2404
|
*
|
|
@@ -2480,6 +2490,15 @@ class ManagedIdentityCredential {
|
|
|
2480
2490
|
if (err.statusCode === 400) {
|
|
2481
2491
|
throw new CredentialUnavailableError(`${ManagedIdentityCredential.name}: The managed identity endpoint is indicating there's no available identity. Message: ${err.message}`);
|
|
2482
2492
|
}
|
|
2493
|
+
// This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network"
|
|
2494
|
+
// rather than just timing out, as expected.
|
|
2495
|
+
if (err.statusCode === 403 || err.code === 403) {
|
|
2496
|
+
if (err.message.includes("A socket operation was attempted to an unreachable network")) {
|
|
2497
|
+
const error = new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Unavailable. Network unreachable. Message: ${err.message}`);
|
|
2498
|
+
logger$c.getToken.info(formatError(scopes, error));
|
|
2499
|
+
throw error;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2483
2502
|
// If the error has no status code, we can assume there was no available identity.
|
|
2484
2503
|
// This will throw silently during any ChainedTokenCredential.
|
|
2485
2504
|
if (err.statusCode === undefined) {
|
|
@@ -2576,7 +2595,7 @@ function ensureScopes(scopes) {
|
|
|
2576
2595
|
* @internal
|
|
2577
2596
|
*/
|
|
2578
2597
|
function ensureValidScopeForDevTimeCreds(scope, logger) {
|
|
2579
|
-
if (!scope.match(/^[0-9a-zA-Z
|
|
2598
|
+
if (!scope.match(/^[0-9a-zA-Z-_.:/]+$/)) {
|
|
2580
2599
|
const error = new Error("Invalid scope was specified by the user or calling client");
|
|
2581
2600
|
logger.getToken.info(formatError(scope, error));
|
|
2582
2601
|
throw error;
|
|
@@ -2662,11 +2681,11 @@ class AzureCliCredential {
|
|
|
2662
2681
|
checkTenantId(logger$b, options === null || options === void 0 ? void 0 : options.tenantId);
|
|
2663
2682
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
2664
2683
|
}
|
|
2665
|
-
this.additionallyAllowedTenantIds =
|
|
2684
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
2666
2685
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2667
2686
|
}
|
|
2668
2687
|
/**
|
|
2669
|
-
* Authenticates with
|
|
2688
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2670
2689
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
2671
2690
|
*
|
|
2672
2691
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -2844,7 +2863,7 @@ class AzurePowerShellCredential {
|
|
|
2844
2863
|
checkTenantId(logger$a, options === null || options === void 0 ? void 0 : options.tenantId);
|
|
2845
2864
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
2846
2865
|
}
|
|
2847
|
-
this.additionallyAllowedTenantIds =
|
|
2866
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
2848
2867
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2849
2868
|
}
|
|
2850
2869
|
/**
|
|
@@ -2893,7 +2912,7 @@ class AzurePowerShellCredential {
|
|
|
2893
2912
|
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
|
|
2894
2913
|
}
|
|
2895
2914
|
/**
|
|
2896
|
-
* Authenticates with
|
|
2915
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
2897
2916
|
* If the authentication cannot be performed through PowerShell, a {@link CredentialUnavailableError} will be thrown.
|
|
2898
2917
|
*
|
|
2899
2918
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3126,11 +3145,11 @@ class MsalClientCertificate extends MsalNode {
|
|
|
3126
3145
|
const credentialName$2 = "ClientCertificateCredential";
|
|
3127
3146
|
const logger$8 = credentialLogger(credentialName$2);
|
|
3128
3147
|
/**
|
|
3129
|
-
* Enables authentication to
|
|
3148
|
+
* Enables authentication to Microsoft Entra ID using a PEM-encoded
|
|
3130
3149
|
* certificate that is assigned to an App Registration. More information
|
|
3131
3150
|
* on how to configure certificate authentication can be found here:
|
|
3132
3151
|
*
|
|
3133
|
-
* https://
|
|
3152
|
+
* https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad
|
|
3134
3153
|
*
|
|
3135
3154
|
*/
|
|
3136
3155
|
class ClientCertificateCredential {
|
|
@@ -3139,7 +3158,7 @@ class ClientCertificateCredential {
|
|
|
3139
3158
|
throw new Error(`${credentialName$2}: tenantId and clientId are required parameters.`);
|
|
3140
3159
|
}
|
|
3141
3160
|
this.tenantId = tenantId;
|
|
3142
|
-
this.additionallyAllowedTenantIds =
|
|
3161
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3143
3162
|
const configuration = Object.assign({}, (typeof certificatePathOrConfiguration === "string"
|
|
3144
3163
|
? {
|
|
3145
3164
|
certificatePath: certificatePathOrConfiguration,
|
|
@@ -3160,7 +3179,7 @@ class ClientCertificateCredential {
|
|
|
3160
3179
|
tenantId, sendCertificateChain: options.sendCertificateChain, tokenCredentialOptions: options }));
|
|
3161
3180
|
}
|
|
3162
3181
|
/**
|
|
3163
|
-
* Authenticates with
|
|
3182
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3164
3183
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3165
3184
|
*
|
|
3166
3185
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3211,20 +3230,20 @@ class MsalClientSecret extends MsalNode {
|
|
|
3211
3230
|
// Licensed under the MIT license.
|
|
3212
3231
|
const logger$7 = credentialLogger("ClientSecretCredential");
|
|
3213
3232
|
/**
|
|
3214
|
-
* Enables authentication to
|
|
3233
|
+
* Enables authentication to Microsoft Entra ID using a client secret
|
|
3215
3234
|
* that was generated for an App Registration. More information on how
|
|
3216
3235
|
* to configure a client secret can be found here:
|
|
3217
3236
|
*
|
|
3218
|
-
* https://
|
|
3237
|
+
* https://learn.microsoft.com/azure/active-directory/develop/quickstart-configure-app-access-web-apis#add-credentials-to-your-web-application
|
|
3219
3238
|
*
|
|
3220
3239
|
*/
|
|
3221
3240
|
class ClientSecretCredential {
|
|
3222
3241
|
/**
|
|
3223
3242
|
* Creates an instance of the ClientSecretCredential with the details
|
|
3224
|
-
* needed to authenticate against
|
|
3243
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
3225
3244
|
* secret.
|
|
3226
3245
|
*
|
|
3227
|
-
* @param tenantId - The
|
|
3246
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
3228
3247
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3229
3248
|
* @param clientSecret - A client secret that was generated for the App Registration.
|
|
3230
3249
|
* @param options - Options for configuring the client which makes the authentication request.
|
|
@@ -3234,14 +3253,14 @@ class ClientSecretCredential {
|
|
|
3234
3253
|
throw new Error("ClientSecretCredential: tenantId, clientId, and clientSecret are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
|
|
3235
3254
|
}
|
|
3236
3255
|
this.tenantId = tenantId;
|
|
3237
|
-
this.additionallyAllowedTenantIds =
|
|
3256
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3238
3257
|
this.msalFlow = new MsalClientSecret(Object.assign(Object.assign({}, options), { logger: logger$7,
|
|
3239
3258
|
clientId,
|
|
3240
3259
|
tenantId,
|
|
3241
3260
|
clientSecret, tokenCredentialOptions: options }));
|
|
3242
3261
|
}
|
|
3243
3262
|
/**
|
|
3244
|
-
* Authenticates with
|
|
3263
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3245
3264
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3246
3265
|
*
|
|
3247
3266
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3292,7 +3311,7 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
3292
3311
|
// Licensed under the MIT license.
|
|
3293
3312
|
const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
3294
3313
|
/**
|
|
3295
|
-
* Enables authentication to
|
|
3314
|
+
* Enables authentication to Microsoft Entra ID with a user's
|
|
3296
3315
|
* username and password. This credential requires a high degree of
|
|
3297
3316
|
* trust so you should only use it when other, more secure credential
|
|
3298
3317
|
* types can't be used.
|
|
@@ -3300,10 +3319,10 @@ const logger$6 = credentialLogger("UsernamePasswordCredential");
|
|
|
3300
3319
|
class UsernamePasswordCredential {
|
|
3301
3320
|
/**
|
|
3302
3321
|
* Creates an instance of the UsernamePasswordCredential with the details
|
|
3303
|
-
* needed to authenticate against
|
|
3322
|
+
* needed to authenticate against Microsoft Entra ID with a username
|
|
3304
3323
|
* and password.
|
|
3305
3324
|
*
|
|
3306
|
-
* @param tenantId - The
|
|
3325
|
+
* @param tenantId - The Microsoft Entra tenant (directory).
|
|
3307
3326
|
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
3308
3327
|
* @param username - The user account's e-mail address (user name).
|
|
3309
3328
|
* @param password - The user account's account password
|
|
@@ -3314,7 +3333,7 @@ class UsernamePasswordCredential {
|
|
|
3314
3333
|
throw new Error("UsernamePasswordCredential: tenantId, clientId, username and password are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
|
|
3315
3334
|
}
|
|
3316
3335
|
this.tenantId = tenantId;
|
|
3317
|
-
this.additionallyAllowedTenantIds =
|
|
3336
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3318
3337
|
this.msalFlow = new MsalUsernamePassword(Object.assign(Object.assign({}, options), { logger: logger$6,
|
|
3319
3338
|
clientId,
|
|
3320
3339
|
tenantId,
|
|
@@ -3322,7 +3341,7 @@ class UsernamePasswordCredential {
|
|
|
3322
3341
|
password, tokenCredentialOptions: options || {} }));
|
|
3323
3342
|
}
|
|
3324
3343
|
/**
|
|
3325
|
-
* Authenticates with
|
|
3344
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3326
3345
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3327
3346
|
*
|
|
3328
3347
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3369,7 +3388,7 @@ function getAdditionallyAllowedTenants() {
|
|
|
3369
3388
|
const credentialName$1 = "EnvironmentCredential";
|
|
3370
3389
|
const logger$5 = credentialLogger(credentialName$1);
|
|
3371
3390
|
/**
|
|
3372
|
-
* Enables authentication to
|
|
3391
|
+
* Enables authentication to Microsoft Entra ID using a client secret or certificate, or as a user
|
|
3373
3392
|
* with a username and password.
|
|
3374
3393
|
*/
|
|
3375
3394
|
class EnvironmentCredential {
|
|
@@ -3377,7 +3396,7 @@ class EnvironmentCredential {
|
|
|
3377
3396
|
* Creates an instance of the EnvironmentCredential class and decides what credential to use depending on the available environment variables.
|
|
3378
3397
|
*
|
|
3379
3398
|
* Required environment variables:
|
|
3380
|
-
* - `AZURE_TENANT_ID`: The
|
|
3399
|
+
* - `AZURE_TENANT_ID`: The Microsoft Entra tenant (directory) ID.
|
|
3381
3400
|
* - `AZURE_CLIENT_ID`: The client (application) ID of an App Registration in the tenant.
|
|
3382
3401
|
*
|
|
3383
3402
|
* If setting the AZURE_TENANT_ID, then you can also set the additionally allowed tenants
|
|
@@ -3428,7 +3447,7 @@ class EnvironmentCredential {
|
|
|
3428
3447
|
}
|
|
3429
3448
|
}
|
|
3430
3449
|
/**
|
|
3431
|
-
* Authenticates with
|
|
3450
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3432
3451
|
*
|
|
3433
3452
|
* @param scopes - The list of scopes for which the token will have access.
|
|
3434
3453
|
* @param options - Optional parameters. See {@link GetTokenOptions}.
|
|
@@ -3513,11 +3532,11 @@ const logger$4 = credentialLogger("AzureDeveloperCliCredential");
|
|
|
3513
3532
|
* Azure Developer CLI is a command-line interface tool that allows developers to create, manage, and deploy
|
|
3514
3533
|
* resources in Azure. It's built on top of the Azure CLI and provides additional functionality specific
|
|
3515
3534
|
* to Azure developers. It allows users to authenticate as a user and/or a service principal against
|
|
3516
|
-
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">
|
|
3517
|
-
*
|
|
3535
|
+
* <a href="https://learn.microsoft.com/azure/active-directory/fundamentals/">Microsoft Entra ID</a>. The
|
|
3536
|
+
* AzureDeveloperCliCredential authenticates in a development environment and acquires a token on behalf of
|
|
3518
3537
|
* the logged-in user or service principal in the Azure Developer CLI. It acts as the Azure Developer CLI logged in user or
|
|
3519
3538
|
* service principal and executes an Azure CLI command underneath to authenticate the application against
|
|
3520
|
-
*
|
|
3539
|
+
* Microsoft Entra ID.
|
|
3521
3540
|
*
|
|
3522
3541
|
* <h2> Configure AzureDeveloperCliCredential </h2>
|
|
3523
3542
|
*
|
|
@@ -3548,11 +3567,11 @@ class AzureDeveloperCliCredential {
|
|
|
3548
3567
|
checkTenantId(logger$4, options === null || options === void 0 ? void 0 : options.tenantId);
|
|
3549
3568
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3550
3569
|
}
|
|
3551
|
-
this.additionallyAllowedTenantIds =
|
|
3570
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3552
3571
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
3553
3572
|
}
|
|
3554
3573
|
/**
|
|
3555
|
-
* Authenticates with
|
|
3574
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3556
3575
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3557
3576
|
*
|
|
3558
3577
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -3760,19 +3779,19 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3760
3779
|
// Licensed under the MIT license.
|
|
3761
3780
|
const logger$3 = credentialLogger("InteractiveBrowserCredential");
|
|
3762
3781
|
/**
|
|
3763
|
-
* Enables authentication to
|
|
3782
|
+
* Enables authentication to Microsoft Entra ID inside of the web browser
|
|
3764
3783
|
* using the interactive login flow.
|
|
3765
3784
|
*/
|
|
3766
3785
|
class InteractiveBrowserCredential {
|
|
3767
3786
|
/**
|
|
3768
3787
|
* Creates an instance of InteractiveBrowserCredential with the details needed.
|
|
3769
3788
|
*
|
|
3770
|
-
* This credential uses the [Authorization Code Flow](https://
|
|
3789
|
+
* This credential uses the [Authorization Code Flow](https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
|
|
3771
3790
|
* On Node.js, it will open a browser window while it listens for a redirect response from the authentication service.
|
|
3772
3791
|
* 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.
|
|
3773
3792
|
*
|
|
3774
|
-
* For Node.js, if a `clientId` is provided, the
|
|
3775
|
-
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://
|
|
3793
|
+
* 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.
|
|
3794
|
+
* Follow our guide on [setting up Redirect URIs for Desktop apps that calls to web APIs](https://learn.microsoft.com/azure/active-directory/develop/scenario-desktop-app-registration#redirect-uris).
|
|
3776
3795
|
*
|
|
3777
3796
|
* @param options - Options for configuring the client which makes the authentication requests.
|
|
3778
3797
|
*/
|
|
@@ -3781,13 +3800,13 @@ class InteractiveBrowserCredential {
|
|
|
3781
3800
|
? options.redirectUri()
|
|
3782
3801
|
: options.redirectUri || "http://localhost";
|
|
3783
3802
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3784
|
-
this.additionallyAllowedTenantIds =
|
|
3803
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3785
3804
|
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$3,
|
|
3786
3805
|
redirectUri }));
|
|
3787
3806
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3788
3807
|
}
|
|
3789
3808
|
/**
|
|
3790
|
-
* Authenticates with
|
|
3809
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3791
3810
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3792
3811
|
*
|
|
3793
3812
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3806,7 +3825,7 @@ class InteractiveBrowserCredential {
|
|
|
3806
3825
|
});
|
|
3807
3826
|
}
|
|
3808
3827
|
/**
|
|
3809
|
-
* Authenticates with
|
|
3828
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3810
3829
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3811
3830
|
*
|
|
3812
3831
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -3871,13 +3890,13 @@ function defaultDeviceCodePromptCallback(deviceCodeInfo) {
|
|
|
3871
3890
|
console.log(deviceCodeInfo.message);
|
|
3872
3891
|
}
|
|
3873
3892
|
/**
|
|
3874
|
-
* Enables authentication to
|
|
3893
|
+
* Enables authentication to Microsoft Entra ID using a device code
|
|
3875
3894
|
* that the user can enter into https://microsoft.com/devicelogin.
|
|
3876
3895
|
*/
|
|
3877
3896
|
class DeviceCodeCredential {
|
|
3878
3897
|
/**
|
|
3879
3898
|
* Creates an instance of DeviceCodeCredential with the details needed
|
|
3880
|
-
* to initiate the device code authorization flow with
|
|
3899
|
+
* to initiate the device code authorization flow with Microsoft Entra ID.
|
|
3881
3900
|
*
|
|
3882
3901
|
* A message will be logged, giving users a code that they can use to authenticate once they go to https://microsoft.com/devicelogin
|
|
3883
3902
|
*
|
|
@@ -3897,12 +3916,12 @@ class DeviceCodeCredential {
|
|
|
3897
3916
|
*/
|
|
3898
3917
|
constructor(options) {
|
|
3899
3918
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3900
|
-
this.additionallyAllowedTenantIds =
|
|
3919
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3901
3920
|
this.msalFlow = new MsalDeviceCode(Object.assign(Object.assign({}, options), { logger: logger$2, userPromptCallback: (options === null || options === void 0 ? void 0 : options.userPromptCallback) || defaultDeviceCodePromptCallback, tokenCredentialOptions: options || {} }));
|
|
3902
3921
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3903
3922
|
}
|
|
3904
3923
|
/**
|
|
3905
|
-
* Authenticates with
|
|
3924
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3906
3925
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3907
3926
|
*
|
|
3908
3927
|
* If the user provided the option `disableAutomaticAuthentication`,
|
|
@@ -3921,7 +3940,7 @@ class DeviceCodeCredential {
|
|
|
3921
3940
|
});
|
|
3922
3941
|
}
|
|
3923
3942
|
/**
|
|
3924
|
-
* Authenticates with
|
|
3943
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
3925
3944
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
3926
3945
|
*
|
|
3927
3946
|
* If the token can't be retrieved silently, this method will require user interaction to retrieve the token.
|
|
@@ -3987,11 +4006,11 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3987
4006
|
// Licensed under the MIT license.
|
|
3988
4007
|
const logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
3989
4008
|
/**
|
|
3990
|
-
* Enables authentication to
|
|
4009
|
+
* Enables authentication to Microsoft Entra ID using an authorization code
|
|
3991
4010
|
* that was obtained through the authorization code flow, described in more detail
|
|
3992
|
-
* in the
|
|
4011
|
+
* in the Microsoft Entra ID documentation:
|
|
3993
4012
|
*
|
|
3994
|
-
* https://
|
|
4013
|
+
* https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow
|
|
3995
4014
|
*/
|
|
3996
4015
|
class AuthorizationCodeCredential {
|
|
3997
4016
|
/**
|
|
@@ -4016,13 +4035,13 @@ class AuthorizationCodeCredential {
|
|
|
4016
4035
|
}
|
|
4017
4036
|
// TODO: Validate tenant if provided
|
|
4018
4037
|
this.tenantId = tenantId;
|
|
4019
|
-
this.additionallyAllowedTenantIds =
|
|
4038
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
4020
4039
|
this.msalFlow = new MsalAuthorizationCode(Object.assign(Object.assign({}, options), { clientSecret,
|
|
4021
4040
|
clientId,
|
|
4022
4041
|
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
4023
4042
|
}
|
|
4024
4043
|
/**
|
|
4025
|
-
* Authenticates with
|
|
4044
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4026
4045
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4027
4046
|
*
|
|
4028
4047
|
* @param scopes - The list of scopes for which the token will have access.
|
|
@@ -4098,7 +4117,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4098
4117
|
const credentialName = "OnBehalfOfCredential";
|
|
4099
4118
|
const logger = credentialLogger(credentialName);
|
|
4100
4119
|
/**
|
|
4101
|
-
* Enables authentication to
|
|
4120
|
+
* Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
|
|
4102
4121
|
*/
|
|
4103
4122
|
class OnBehalfOfCredential {
|
|
4104
4123
|
constructor(options) {
|
|
@@ -4110,11 +4129,11 @@ class OnBehalfOfCredential {
|
|
|
4110
4129
|
throw new Error(`${credentialName}: tenantId, clientId, clientSecret (or certificatePath) and userAssertionToken are required parameters.`);
|
|
4111
4130
|
}
|
|
4112
4131
|
this.tenantId = tenantId;
|
|
4113
|
-
this.additionallyAllowedTenantIds =
|
|
4132
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(additionallyAllowedTenantIds);
|
|
4114
4133
|
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
4115
4134
|
}
|
|
4116
4135
|
/**
|
|
4117
|
-
* Authenticates with
|
|
4136
|
+
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
4118
4137
|
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
4119
4138
|
*
|
|
4120
4139
|
* @param scopes - The list of scopes for which the token will have access.
|