@azure/identity 2.0.2-alpha.20211028.2 → 2.0.2-alpha.20211123.3
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/CHANGELOG.md +4 -0
- package/dist/index.js +200 -109
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js +1 -1
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/azureApplicationCredential.js +1 -2
- package/dist-esm/src/credentials/azureApplicationCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/credentialPersistenceOptions.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/defaultAzureCredential.js.map +1 -1
- package/dist-esm/src/credentials/environmentCredential.js +5 -4
- package/dist-esm/src/credentials/environmentCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js +18 -6
- package/dist-esm/src/credentials/managedIdentityCredential/appServiceMsi2017.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js +20 -6
- package/dist-esm/src/credentials/managedIdentityCredential/arcMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js +13 -5
- package/dist-esm/src/credentials/managedIdentityCredential/cloudShellMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/constants.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js +32 -17
- package/dist-esm/src/credentials/managedIdentityCredential/fabricMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +16 -5
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.browser.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +11 -12
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/models.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js +17 -5
- package/dist-esm/src/credentials/managedIdentityCredential/tokenExchangeMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/utils.js +2 -10
- package/dist-esm/src/credentials/managedIdentityCredential/utils.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +3 -3
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +3 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/{browserCommon.js → msalBrowserCommon.js} +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -0
- package/dist-esm/src/msal/credentials.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js +5 -2
- package/dist-esm/src/msal/nodeFlows/msalAuthorizationCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js +3 -2
- package/dist-esm/src/msal/nodeFlows/msalClientCertificate.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js +3 -2
- package/dist-esm/src/msal/nodeFlows/msalClientSecret.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js +3 -2
- package/dist-esm/src/msal/nodeFlows/msalDeviceCode.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/{nodeCommon.js → msalNodeCommon.js} +5 -4
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -0
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js +2 -1
- package/dist-esm/src/msal/nodeFlows/msalOnBehalfOf.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +18 -2
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js +3 -2
- package/dist-esm/src/msal/nodeFlows/msalUsernamePassword.js.map +1 -1
- package/dist-esm/src/plugins/consumer.js +1 -1
- package/dist-esm/src/plugins/consumer.js.map +1 -1
- package/dist-esm/src/tokenCredentialOptions.js +4 -0
- package/dist-esm/src/tokenCredentialOptions.js.map +1 -0
- package/package.json +2 -2
- package/types/identity.d.ts +4 -5
- package/dist-esm/src/msal/browserFlows/browserCommon.js.map +0 -1
- package/dist-esm/src/msal/nodeFlows/nodeCommon.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var msalNode = require('@azure/msal-node');
|
|
8
|
-
var coreClient = require('@azure/core-client');
|
|
9
8
|
var coreTracing = require('@azure/core-tracing');
|
|
9
|
+
var coreClient = require('@azure/core-client');
|
|
10
10
|
var coreUtil = require('@azure/core-util');
|
|
11
11
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
12
12
|
var abortController = require('@azure/abort-controller');
|
|
@@ -26,44 +26,6 @@ var http = _interopDefault(require('http'));
|
|
|
26
26
|
var open = _interopDefault(require('open'));
|
|
27
27
|
var stoppable = _interopDefault(require('stoppable'));
|
|
28
28
|
|
|
29
|
-
// Copyright (c) Microsoft Corporation.
|
|
30
|
-
// Licensed under the MIT license.
|
|
31
|
-
/**
|
|
32
|
-
* The default client ID for authentication
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
// TODO: temporary - this is the Azure CLI clientID - we'll replace it when
|
|
36
|
-
// Developer Sign On application is available
|
|
37
|
-
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9
|
|
38
|
-
const DeveloperSignOnClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
|
|
39
|
-
/**
|
|
40
|
-
* The default tenant for authentication
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
const DefaultTenantId = "common";
|
|
44
|
-
(function (AzureAuthorityHosts) {
|
|
45
|
-
/**
|
|
46
|
-
* China-based Azure Authority Host
|
|
47
|
-
*/
|
|
48
|
-
AzureAuthorityHosts["AzureChina"] = "https://login.chinacloudapi.cn";
|
|
49
|
-
/**
|
|
50
|
-
* Germany-based Azure Authority Host
|
|
51
|
-
*/
|
|
52
|
-
AzureAuthorityHosts["AzureGermany"] = "https://login.microsoftonline.de";
|
|
53
|
-
/**
|
|
54
|
-
* US Government Azure Authority Host
|
|
55
|
-
*/
|
|
56
|
-
AzureAuthorityHosts["AzureGovernment"] = "https://login.microsoftonline.us";
|
|
57
|
-
/**
|
|
58
|
-
* Public Cloud Azure Authority Host
|
|
59
|
-
*/
|
|
60
|
-
AzureAuthorityHosts["AzurePublicCloud"] = "https://login.microsoftonline.com";
|
|
61
|
-
})(exports.AzureAuthorityHosts || (exports.AzureAuthorityHosts = {}));
|
|
62
|
-
/**
|
|
63
|
-
* The default authority host.
|
|
64
|
-
*/
|
|
65
|
-
const DefaultAuthorityHost = exports.AzureAuthorityHosts.AzurePublicCloud;
|
|
66
|
-
|
|
67
29
|
// Copyright (c) Microsoft Corporation.
|
|
68
30
|
// Licensed under the MIT license.
|
|
69
31
|
function isErrorResponse(errorResponse) {
|
|
@@ -194,6 +156,44 @@ function getIdentityTokenEndpointSuffix(tenantId) {
|
|
|
194
156
|
}
|
|
195
157
|
}
|
|
196
158
|
|
|
159
|
+
// Copyright (c) Microsoft Corporation.
|
|
160
|
+
// Licensed under the MIT license.
|
|
161
|
+
/**
|
|
162
|
+
* The default client ID for authentication
|
|
163
|
+
* @internal
|
|
164
|
+
*/
|
|
165
|
+
// TODO: temporary - this is the Azure CLI clientID - we'll replace it when
|
|
166
|
+
// Developer Sign On application is available
|
|
167
|
+
// https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/Constants.cs#L9
|
|
168
|
+
const DeveloperSignOnClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
|
|
169
|
+
/**
|
|
170
|
+
* The default tenant for authentication
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
const DefaultTenantId = "common";
|
|
174
|
+
(function (AzureAuthorityHosts) {
|
|
175
|
+
/**
|
|
176
|
+
* China-based Azure Authority Host
|
|
177
|
+
*/
|
|
178
|
+
AzureAuthorityHosts["AzureChina"] = "https://login.chinacloudapi.cn";
|
|
179
|
+
/**
|
|
180
|
+
* Germany-based Azure Authority Host
|
|
181
|
+
*/
|
|
182
|
+
AzureAuthorityHosts["AzureGermany"] = "https://login.microsoftonline.de";
|
|
183
|
+
/**
|
|
184
|
+
* US Government Azure Authority Host
|
|
185
|
+
*/
|
|
186
|
+
AzureAuthorityHosts["AzureGovernment"] = "https://login.microsoftonline.us";
|
|
187
|
+
/**
|
|
188
|
+
* Public Cloud Azure Authority Host
|
|
189
|
+
*/
|
|
190
|
+
AzureAuthorityHosts["AzurePublicCloud"] = "https://login.microsoftonline.com";
|
|
191
|
+
})(exports.AzureAuthorityHosts || (exports.AzureAuthorityHosts = {}));
|
|
192
|
+
/**
|
|
193
|
+
* The default authority host.
|
|
194
|
+
*/
|
|
195
|
+
const DefaultAuthorityHost = exports.AzureAuthorityHosts.AzurePublicCloud;
|
|
196
|
+
|
|
197
197
|
// Copyright (c) Microsoft Corporation.
|
|
198
198
|
/**
|
|
199
199
|
* Creates a span using the global tracer.
|
|
@@ -938,7 +938,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
938
938
|
this.authorityHost = options.authorityHost || process.env.AZURE_AUTHORITY_HOST;
|
|
939
939
|
const authority = getAuthority(tenantId, this.authorityHost);
|
|
940
940
|
this.identityClient = new IdentityClient(Object.assign(Object.assign({}, options.tokenCredentialOptions), { authorityHost: authority }));
|
|
941
|
-
let clientCapabilities = ["
|
|
941
|
+
let clientCapabilities = ["cp1"];
|
|
942
942
|
if (process.env.AZURE_IDENTITY_DISABLE_CP1) {
|
|
943
943
|
clientCapabilities = [];
|
|
944
944
|
}
|
|
@@ -1052,7 +1052,8 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
1052
1052
|
account: publicToMsal(this.account),
|
|
1053
1053
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
1054
1054
|
scopes,
|
|
1055
|
-
authority: options === null || options === void 0 ? void 0 : options.authority
|
|
1055
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1056
|
+
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
1056
1057
|
};
|
|
1057
1058
|
try {
|
|
1058
1059
|
this.logger.info("Attempting to acquire token silently");
|
|
@@ -1495,7 +1496,7 @@ class AzureCliCredential {
|
|
|
1495
1496
|
ensureValidScope(scope, logger$3);
|
|
1496
1497
|
const resource = getScopeResource(scope);
|
|
1497
1498
|
let responseData = "";
|
|
1498
|
-
const { span } = createSpan(
|
|
1499
|
+
const { span } = createSpan(`${this.constructor.name}.getToken`, options);
|
|
1499
1500
|
try {
|
|
1500
1501
|
const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId);
|
|
1501
1502
|
if (obj.stderr) {
|
|
@@ -1750,7 +1751,8 @@ class MsalClientSecret extends MsalNode {
|
|
|
1750
1751
|
scopes,
|
|
1751
1752
|
correlationId: options.correlationId,
|
|
1752
1753
|
azureRegion: this.azureRegion,
|
|
1753
|
-
authority: options.authority
|
|
1754
|
+
authority: options.authority,
|
|
1755
|
+
claims: options.claims
|
|
1754
1756
|
});
|
|
1755
1757
|
// The Client Credential flow does not return an account,
|
|
1756
1758
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -1877,7 +1879,8 @@ class MsalClientCertificate extends MsalNode {
|
|
|
1877
1879
|
scopes,
|
|
1878
1880
|
correlationId: options.correlationId,
|
|
1879
1881
|
azureRegion: this.azureRegion,
|
|
1880
|
-
authority: options.authority
|
|
1882
|
+
authority: options.authority,
|
|
1883
|
+
claims: options.claims
|
|
1881
1884
|
});
|
|
1882
1885
|
// Even though we're providing the same default in memory persistence cache that we use for DeviceCodeCredential,
|
|
1883
1886
|
// The Client Credential flow does not return the account information from the authentication service,
|
|
@@ -1956,7 +1959,8 @@ class MsalUsernamePassword extends MsalNode {
|
|
|
1956
1959
|
username: this.username,
|
|
1957
1960
|
password: this.password,
|
|
1958
1961
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
1959
|
-
authority: options === null || options === void 0 ? void 0 : options.authority
|
|
1962
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
1963
|
+
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
1960
1964
|
};
|
|
1961
1965
|
const result = await this.publicApp.acquireTokenByUsernamePassword(requestOptions);
|
|
1962
1966
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
@@ -2033,7 +2037,8 @@ const AllSupportedEnvironmentVariables = [
|
|
|
2033
2037
|
"AZURE_USERNAME",
|
|
2034
2038
|
"AZURE_PASSWORD"
|
|
2035
2039
|
];
|
|
2036
|
-
const
|
|
2040
|
+
const credentialName$1 = "EnvironmentCredential";
|
|
2041
|
+
const logger$8 = credentialLogger(credentialName$1);
|
|
2037
2042
|
/**
|
|
2038
2043
|
* Enables authentication to Azure Active Directory using client secret
|
|
2039
2044
|
* details configured in environment variables
|
|
@@ -2093,7 +2098,7 @@ class EnvironmentCredential {
|
|
|
2093
2098
|
* @param options - Optional parameters. See {@link GetTokenOptions}.
|
|
2094
2099
|
*/
|
|
2095
2100
|
async getToken(scopes, options = {}) {
|
|
2096
|
-
return trace(
|
|
2101
|
+
return trace(`${credentialName$1}.getToken`, options, async (newOptions) => {
|
|
2097
2102
|
if (this._credential) {
|
|
2098
2103
|
try {
|
|
2099
2104
|
const result = await this._credential.getToken(scopes, newOptions);
|
|
@@ -2102,7 +2107,7 @@ class EnvironmentCredential {
|
|
|
2102
2107
|
}
|
|
2103
2108
|
catch (err) {
|
|
2104
2109
|
const authenticationError = new AuthenticationError(400, {
|
|
2105
|
-
error:
|
|
2110
|
+
error: `${credentialName$1} authentication failed. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`,
|
|
2106
2111
|
error_description: err.message
|
|
2107
2112
|
.toString()
|
|
2108
2113
|
.split("More details:")
|
|
@@ -2112,7 +2117,7 @@ class EnvironmentCredential {
|
|
|
2112
2117
|
throw authenticationError;
|
|
2113
2118
|
}
|
|
2114
2119
|
}
|
|
2115
|
-
throw new CredentialUnavailableError(
|
|
2120
|
+
throw new CredentialUnavailableError(`${credentialName$1} is unavailable. No underlying credential could be used. To troubleshoot, visit https://aka.ms/azsdk/js/identity/environmentcredential/troubleshoot.`);
|
|
2116
2121
|
});
|
|
2117
2122
|
}
|
|
2118
2123
|
}
|
|
@@ -2128,7 +2133,8 @@ const azureFabricVersion = "2019-07-01-preview";
|
|
|
2128
2133
|
|
|
2129
2134
|
// Copyright (c) Microsoft Corporation.
|
|
2130
2135
|
/**
|
|
2131
|
-
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
|
2136
|
+
* Most MSIs send requests to the IMDS endpoint, or a similar endpoint.
|
|
2137
|
+
* These are GET requests that require sending a `resource` parameter on the query.
|
|
2132
2138
|
* This resource can be derived from the scopes received through the getToken call, as long as only one scope is received.
|
|
2133
2139
|
* Multiple scopes assume that the resulting token will have access to multiple resources, which won't be the case.
|
|
2134
2140
|
*
|
|
@@ -2151,23 +2157,20 @@ function mapScopesToResource(scopes) {
|
|
|
2151
2157
|
}
|
|
2152
2158
|
return scope.substr(0, scope.lastIndexOf(DefaultScopeSuffix));
|
|
2153
2159
|
}
|
|
2154
|
-
async function msiGenericGetToken(identityClient, requestOptions, expiresInParser, getTokenOptions = {}, agent) {
|
|
2155
|
-
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, requestOptions), { allowInsecureConnection: true }));
|
|
2156
|
-
if (agent) {
|
|
2157
|
-
request.agent = agent;
|
|
2158
|
-
}
|
|
2159
|
-
const tokenResponse = await identityClient.sendTokenRequest(request, expiresInParser);
|
|
2160
|
-
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2161
|
-
}
|
|
2162
2160
|
|
|
2163
2161
|
// Copyright (c) Microsoft Corporation.
|
|
2164
2162
|
const msiName = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
2165
2163
|
const logger$9 = credentialLogger(msiName);
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2164
|
+
/**
|
|
2165
|
+
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2166
|
+
*/
|
|
2167
|
+
function expiresOnParser(requestBody) {
|
|
2168
|
+
// App Service always returns string expires_on values.
|
|
2169
2169
|
return Date.parse(requestBody.expires_on);
|
|
2170
2170
|
}
|
|
2171
|
+
/**
|
|
2172
|
+
* Generates the options used on the request for an access token.
|
|
2173
|
+
*/
|
|
2171
2174
|
function prepareRequestOptions(scopes, clientId) {
|
|
2172
2175
|
const resource = mapScopesToResource(scopes);
|
|
2173
2176
|
if (!resource) {
|
|
@@ -2197,6 +2200,9 @@ function prepareRequestOptions(scopes, clientId) {
|
|
|
2197
2200
|
})
|
|
2198
2201
|
};
|
|
2199
2202
|
}
|
|
2203
|
+
/**
|
|
2204
|
+
* Defines how to determine whether the Azure App Service MSI is available, and also how to retrieve a token from the Azure App Service MSI.
|
|
2205
|
+
*/
|
|
2200
2206
|
const appServiceMsi2017 = {
|
|
2201
2207
|
async isAvailable(scopes) {
|
|
2202
2208
|
const resource = mapScopesToResource(scopes);
|
|
@@ -2214,15 +2220,20 @@ const appServiceMsi2017 = {
|
|
|
2214
2220
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2215
2221
|
const { identityClient, scopes, clientId } = configuration;
|
|
2216
2222
|
logger$9.info(`${msiName}: Using the endpoint and the secret coming form the environment variables: MSI_ENDPOINT=${process.env.MSI_ENDPOINT} and MSI_SECRET=[REDACTED].`);
|
|
2217
|
-
|
|
2223
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions(scopes, clientId)), {
|
|
2224
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2225
|
+
allowInsecureConnection: true }));
|
|
2226
|
+
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser);
|
|
2227
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2218
2228
|
}
|
|
2219
2229
|
};
|
|
2220
2230
|
|
|
2221
2231
|
// Copyright (c) Microsoft Corporation.
|
|
2222
2232
|
const msiName$1 = "ManagedIdentityCredential - CloudShellMSI";
|
|
2223
2233
|
const logger$a = credentialLogger(msiName$1);
|
|
2224
|
-
|
|
2225
|
-
|
|
2234
|
+
/**
|
|
2235
|
+
* Generates the options used on the request for an access token.
|
|
2236
|
+
*/
|
|
2226
2237
|
function prepareRequestOptions$1(scopes, clientId) {
|
|
2227
2238
|
const resource = mapScopesToResource(scopes);
|
|
2228
2239
|
if (!resource) {
|
|
@@ -2250,6 +2261,9 @@ function prepareRequestOptions$1(scopes, clientId) {
|
|
|
2250
2261
|
})
|
|
2251
2262
|
};
|
|
2252
2263
|
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Defines how to determine whether the Azure Cloud Shell MSI is available, and also how to retrieve a token from the Azure Cloud Shell MSI.
|
|
2266
|
+
*/
|
|
2253
2267
|
const cloudShellMsi = {
|
|
2254
2268
|
async isAvailable(scopes) {
|
|
2255
2269
|
const resource = mapScopesToResource(scopes);
|
|
@@ -2266,14 +2280,21 @@ const cloudShellMsi = {
|
|
|
2266
2280
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2267
2281
|
const { identityClient, scopes, clientId } = configuration;
|
|
2268
2282
|
logger$a.info(`${msiName$1}: Using the endpoint coming form the environment variable MSI_ENDPOINT = ${process.env.MSI_ENDPOINT}.`);
|
|
2269
|
-
|
|
2283
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$1(scopes, clientId)), {
|
|
2284
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2285
|
+
allowInsecureConnection: true }));
|
|
2286
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2287
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2270
2288
|
}
|
|
2271
2289
|
};
|
|
2272
2290
|
|
|
2273
2291
|
// Copyright (c) Microsoft Corporation.
|
|
2274
2292
|
const msiName$2 = "ManagedIdentityCredential - IMDS";
|
|
2275
2293
|
const logger$b = credentialLogger(msiName$2);
|
|
2276
|
-
|
|
2294
|
+
/**
|
|
2295
|
+
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2296
|
+
*/
|
|
2297
|
+
function expiresOnParser$1(requestBody) {
|
|
2277
2298
|
if (requestBody.expires_on) {
|
|
2278
2299
|
// Use the expires_on timestamp if it's available
|
|
2279
2300
|
const expires = +requestBody.expires_on * 1000;
|
|
@@ -2287,6 +2308,9 @@ function expiresInParser$2(requestBody) {
|
|
|
2287
2308
|
return expires;
|
|
2288
2309
|
}
|
|
2289
2310
|
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Generates the options used on the request for an access token.
|
|
2313
|
+
*/
|
|
2290
2314
|
function prepareRequestOptions$2(scopes, clientId, options) {
|
|
2291
2315
|
var _a;
|
|
2292
2316
|
const resource = mapScopesToResource(scopes);
|
|
@@ -2330,6 +2354,9 @@ const imdsMsiRetryConfig = {
|
|
|
2330
2354
|
startDelayInMs: 800,
|
|
2331
2355
|
intervalIncrement: 2
|
|
2332
2356
|
};
|
|
2357
|
+
/**
|
|
2358
|
+
* Defines how to determine whether the Azure IMDS MSI is available, and also how to retrieve a token from the Azure IMDS MSI.
|
|
2359
|
+
*/
|
|
2333
2360
|
const imdsMsi = {
|
|
2334
2361
|
async isAvailable(scopes, identityClient, clientId, getTokenOptions) {
|
|
2335
2362
|
var _a, _b;
|
|
@@ -2339,7 +2366,7 @@ const imdsMsi = {
|
|
|
2339
2366
|
return false;
|
|
2340
2367
|
}
|
|
2341
2368
|
const { span, updatedOptions: options } = createSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions);
|
|
2342
|
-
// if the
|
|
2369
|
+
// if the PodIdentityEndpoint environment variable was set no need to probe the endpoint, it can be assumed to exist
|
|
2343
2370
|
if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
|
|
2344
2371
|
return true;
|
|
2345
2372
|
}
|
|
@@ -2401,7 +2428,9 @@ const imdsMsi = {
|
|
|
2401
2428
|
let nextDelayInMs = imdsMsiRetryConfig.startDelayInMs;
|
|
2402
2429
|
for (let retries = 0; retries < imdsMsiRetryConfig.maxRetries; retries++) {
|
|
2403
2430
|
try {
|
|
2404
|
-
|
|
2431
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$2(scopes, clientId)), { allowInsecureConnection: true }));
|
|
2432
|
+
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser$1);
|
|
2433
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2405
2434
|
}
|
|
2406
2435
|
catch (error) {
|
|
2407
2436
|
if (error.statusCode === 404) {
|
|
@@ -2419,8 +2448,9 @@ const imdsMsi = {
|
|
|
2419
2448
|
// Copyright (c) Microsoft Corporation.
|
|
2420
2449
|
const msiName$3 = "ManagedIdentityCredential - Azure Arc MSI";
|
|
2421
2450
|
const logger$c = credentialLogger(msiName$3);
|
|
2422
|
-
|
|
2423
|
-
|
|
2451
|
+
/**
|
|
2452
|
+
* Generates the options used on the request for an access token.
|
|
2453
|
+
*/
|
|
2424
2454
|
function prepareRequestOptions$3(scopes) {
|
|
2425
2455
|
const resource = mapScopesToResource(scopes);
|
|
2426
2456
|
if (!resource) {
|
|
@@ -2445,7 +2475,10 @@ function prepareRequestOptions$3(scopes) {
|
|
|
2445
2475
|
})
|
|
2446
2476
|
});
|
|
2447
2477
|
}
|
|
2448
|
-
|
|
2478
|
+
/**
|
|
2479
|
+
* Retrieves the file contents at the given path using promises.
|
|
2480
|
+
* Useful since `fs`'s readFileSync locks the thread, and to avoid extra dependencies.
|
|
2481
|
+
*/
|
|
2449
2482
|
function readFileAsync$1(path, options) {
|
|
2450
2483
|
return new Promise((resolve, reject) => fs.readFile(path, options, (err, data) => {
|
|
2451
2484
|
if (err) {
|
|
@@ -2454,6 +2487,9 @@ function readFileAsync$1(path, options) {
|
|
|
2454
2487
|
resolve(data);
|
|
2455
2488
|
}));
|
|
2456
2489
|
}
|
|
2490
|
+
/**
|
|
2491
|
+
* Does a request to the authentication provider that results in a file path.
|
|
2492
|
+
*/
|
|
2457
2493
|
async function filePathRequest(identityClient, requestPrepareOptions) {
|
|
2458
2494
|
const response = await identityClient.sendRequest(coreRestPipeline.createPipelineRequest(requestPrepareOptions));
|
|
2459
2495
|
if (response.status !== 401) {
|
|
@@ -2471,6 +2507,9 @@ async function filePathRequest(identityClient, requestPrepareOptions) {
|
|
|
2471
2507
|
throw Error(`Invalid www-authenticate header format: ${authHeader}`);
|
|
2472
2508
|
}
|
|
2473
2509
|
}
|
|
2510
|
+
/**
|
|
2511
|
+
* Defines how to determine whether the Azure Arc MSI is available, and also how to retrieve a token from the Azure Arc MSI.
|
|
2512
|
+
*/
|
|
2474
2513
|
const arcMsi = {
|
|
2475
2514
|
async isAvailable(scopes) {
|
|
2476
2515
|
const resource = mapScopesToResource(scopes);
|
|
@@ -2498,7 +2537,11 @@ const arcMsi = {
|
|
|
2498
2537
|
}
|
|
2499
2538
|
const key = await readFileAsync$1(filePath, { encoding: "utf-8" });
|
|
2500
2539
|
(_a = requestOptions.headers) === null || _a === void 0 ? void 0 : _a.set("Authorization", `Basic ${key}`);
|
|
2501
|
-
|
|
2540
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({}, requestOptions), {
|
|
2541
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2542
|
+
allowInsecureConnection: true }));
|
|
2543
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
2544
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2502
2545
|
}
|
|
2503
2546
|
};
|
|
2504
2547
|
|
|
@@ -2506,10 +2549,16 @@ const arcMsi = {
|
|
|
2506
2549
|
const msiName$4 = "ManagedIdentityCredential - Token Exchange";
|
|
2507
2550
|
const logger$d = credentialLogger(msiName$4);
|
|
2508
2551
|
const readFileAsync$2 = util.promisify(fs__default.readFile);
|
|
2509
|
-
|
|
2552
|
+
/**
|
|
2553
|
+
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2554
|
+
*/
|
|
2555
|
+
function expiresOnParser$2(requestBody) {
|
|
2510
2556
|
// Parses a string representation of the seconds since epoch into a number value
|
|
2511
2557
|
return Number(requestBody.expires_on);
|
|
2512
2558
|
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Generates the options used on the request for an access token.
|
|
2561
|
+
*/
|
|
2513
2562
|
function prepareRequestOptions$4(scopes, clientAssertion, clientId) {
|
|
2514
2563
|
var _a;
|
|
2515
2564
|
const bodyParams = {
|
|
@@ -2530,6 +2579,9 @@ function prepareRequestOptions$4(scopes, clientAssertion, clientId) {
|
|
|
2530
2579
|
})
|
|
2531
2580
|
};
|
|
2532
2581
|
}
|
|
2582
|
+
/**
|
|
2583
|
+
* Defines how to determine whether the token exchange MSI is available, and also how to retrieve a token from the token exchange MSI.
|
|
2584
|
+
*/
|
|
2533
2585
|
function tokenExchangeMsi() {
|
|
2534
2586
|
const azureFederatedTokenFilePath = process.env.AZURE_FEDERATED_TOKEN_FILE;
|
|
2535
2587
|
let azureFederatedTokenFileContent = undefined;
|
|
@@ -2572,18 +2624,38 @@ function tokenExchangeMsi() {
|
|
|
2572
2624
|
catch (err) {
|
|
2573
2625
|
throw new Error(`${msiName$4}: Failed to read ${azureFederatedTokenFilePath}, indicated by the environment variable AZURE_FEDERATED_TOKEN_FILE`);
|
|
2574
2626
|
}
|
|
2575
|
-
|
|
2627
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$4(scopes, assertion, clientId || process.env.AZURE_CLIENT_ID)), {
|
|
2628
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
2629
|
+
allowInsecureConnection: true }));
|
|
2630
|
+
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser$2);
|
|
2631
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2576
2632
|
}
|
|
2577
2633
|
};
|
|
2578
2634
|
}
|
|
2579
2635
|
|
|
2580
2636
|
// Copyright (c) Microsoft Corporation.
|
|
2637
|
+
// This MSI can be easily tested by deploying a container to Azure Service Fabric with the Dockerfile:
|
|
2638
|
+
//
|
|
2639
|
+
// FROM node:12
|
|
2640
|
+
// RUN wget https://host.any/path/bash.sh
|
|
2641
|
+
// CMD ["bash", "bash.sh"]
|
|
2642
|
+
//
|
|
2643
|
+
// Where the bash script contains:
|
|
2644
|
+
//
|
|
2645
|
+
// curl --insecure $IDENTITY_ENDPOINT'?api-version=2019-07-01-preview&resource=https://vault.azure.net/' -H "Secret: $IDENTITY_HEADER"
|
|
2646
|
+
//
|
|
2581
2647
|
const msiName$5 = "ManagedIdentityCredential - Fabric MSI";
|
|
2582
2648
|
const logger$e = credentialLogger(msiName$5);
|
|
2583
|
-
|
|
2584
|
-
|
|
2649
|
+
/**
|
|
2650
|
+
* Formats the expiration date of the received token into the number of milliseconds between that date and midnight, January 1, 1970.
|
|
2651
|
+
*/
|
|
2652
|
+
function expiresOnParser$3(requestBody) {
|
|
2653
|
+
// Parses a string representation of the milliseconds since epoch into a number value
|
|
2585
2654
|
return Number(requestBody.expires_on);
|
|
2586
2655
|
}
|
|
2656
|
+
/**
|
|
2657
|
+
* Generates the options used on the request for an access token.
|
|
2658
|
+
*/
|
|
2587
2659
|
function prepareRequestOptions$5(scopes, clientId) {
|
|
2588
2660
|
const resource = mapScopesToResource(scopes);
|
|
2589
2661
|
if (!resource) {
|
|
@@ -2609,20 +2681,13 @@ function prepareRequestOptions$5(scopes, clientId) {
|
|
|
2609
2681
|
method: "GET",
|
|
2610
2682
|
headers: coreRestPipeline.createHttpHeaders({
|
|
2611
2683
|
Accept: "application/json",
|
|
2612
|
-
|
|
2684
|
+
secret: process.env.IDENTITY_HEADER
|
|
2613
2685
|
})
|
|
2614
2686
|
};
|
|
2615
2687
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
// RUN wget https://host.any/path/bash.sh
|
|
2620
|
-
// CMD ["bash", "bash.sh"]
|
|
2621
|
-
//
|
|
2622
|
-
// Where the bash script contains:
|
|
2623
|
-
//
|
|
2624
|
-
// curl --insecure $IDENTITY_ENDPOINT'?api-version=2019-07-01-preview&resource=https://vault.azure.net/' -H "Secret: $IDENTITY_HEADER"
|
|
2625
|
-
//
|
|
2688
|
+
/**
|
|
2689
|
+
* Defines how to determine whether the Azure Service Fabric MSI is available, and also how to retrieve a token from the Azure Service Fabric MSI.
|
|
2690
|
+
*/
|
|
2626
2691
|
const fabricMsi = {
|
|
2627
2692
|
async isAvailable(scopes) {
|
|
2628
2693
|
const resource = mapScopesToResource(scopes);
|
|
@@ -2646,23 +2711,28 @@ const fabricMsi = {
|
|
|
2646
2711
|
"IDENTITY_HEADER=[REDACTED] and",
|
|
2647
2712
|
"IDENTITY_SERVER_THUMBPRINT=[REDACTED]."
|
|
2648
2713
|
].join(" "));
|
|
2649
|
-
|
|
2714
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$5(scopes, clientId)
|
|
2715
|
+
// The service fabric MSI endpoint will be HTTPS (however, the certificate will be self-signed).
|
|
2716
|
+
// allowInsecureConnection: true
|
|
2717
|
+
));
|
|
2718
|
+
request.agent = new https.Agent({
|
|
2650
2719
|
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
2651
2720
|
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
2652
2721
|
rejectUnauthorized: false
|
|
2653
|
-
})
|
|
2722
|
+
});
|
|
2723
|
+
const tokenResponse = await identityClient.sendTokenRequest(request, expiresOnParser$3);
|
|
2724
|
+
return (tokenResponse && tokenResponse.accessToken) || null;
|
|
2654
2725
|
}
|
|
2655
2726
|
};
|
|
2656
2727
|
|
|
2657
2728
|
// Copyright (c) Microsoft Corporation.
|
|
2658
2729
|
const logger$f = credentialLogger("ManagedIdentityCredential");
|
|
2659
2730
|
/**
|
|
2660
|
-
* Attempts authentication using a managed identity
|
|
2661
|
-
*
|
|
2662
|
-
*
|
|
2731
|
+
* Attempts authentication using a managed identity available at the deployment environment.
|
|
2732
|
+
* This authentication type works in Azure VMs, App Service instances, Azure Functions applications,
|
|
2733
|
+
* Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
|
|
2663
2734
|
*
|
|
2664
2735
|
* More information about configuring managed identities can be found here:
|
|
2665
|
-
*
|
|
2666
2736
|
* https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
|
|
2667
2737
|
*/
|
|
2668
2738
|
class ManagedIdentityCredential {
|
|
@@ -2693,10 +2763,10 @@ class ManagedIdentityCredential {
|
|
|
2693
2763
|
return msi;
|
|
2694
2764
|
}
|
|
2695
2765
|
}
|
|
2696
|
-
throw new CredentialUnavailableError(
|
|
2766
|
+
throw new CredentialUnavailableError(`${ManagedIdentityCredential.name} - No MSI credential available`);
|
|
2697
2767
|
}
|
|
2698
2768
|
async authenticateManagedIdentity(scopes, clientId, getTokenOptions) {
|
|
2699
|
-
const { span, updatedOptions } = createSpan(
|
|
2769
|
+
const { span, updatedOptions } = createSpan(`${ManagedIdentityCredential.name}.authenticateManagedIdentity`, getTokenOptions);
|
|
2700
2770
|
try {
|
|
2701
2771
|
// Determining the available MSI, and avoiding checking for other MSIs while the program is running.
|
|
2702
2772
|
const availableMSI = await this.cachedAvailableMSI(scopes, clientId, updatedOptions);
|
|
@@ -2728,7 +2798,7 @@ class ManagedIdentityCredential {
|
|
|
2728
2798
|
*/
|
|
2729
2799
|
async getToken(scopes, options) {
|
|
2730
2800
|
let result = null;
|
|
2731
|
-
const { span, updatedOptions } = createSpan(
|
|
2801
|
+
const { span, updatedOptions } = createSpan(`${ManagedIdentityCredential.name}.getToken`, options);
|
|
2732
2802
|
try {
|
|
2733
2803
|
// isEndpointAvailable can be true, false, or null,
|
|
2734
2804
|
// If it's null, it means we don't yet know whether
|
|
@@ -2779,30 +2849,30 @@ class ManagedIdentityCredential {
|
|
|
2779
2849
|
// If either the network is unreachable,
|
|
2780
2850
|
// we can safely assume the credential is unavailable.
|
|
2781
2851
|
if (err.code === "ENETUNREACH") {
|
|
2782
|
-
const error = new CredentialUnavailableError(
|
|
2852
|
+
const error = new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Unavailable. Network unreachable. Message: ${err.message}`);
|
|
2783
2853
|
logger$f.getToken.info(formatError(scopes, error));
|
|
2784
2854
|
throw error;
|
|
2785
2855
|
}
|
|
2786
2856
|
// If either the host was unreachable,
|
|
2787
2857
|
// we can safely assume the credential is unavailable.
|
|
2788
2858
|
if (err.code === "EHOSTUNREACH") {
|
|
2789
|
-
const error = new CredentialUnavailableError(
|
|
2859
|
+
const error = new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Unavailable. No managed identity endpoint found. Message: ${err.message}`);
|
|
2790
2860
|
logger$f.getToken.info(formatError(scopes, error));
|
|
2791
2861
|
throw error;
|
|
2792
2862
|
}
|
|
2793
2863
|
// If err.statusCode has a value of 400, it comes from sendTokenRequest,
|
|
2794
2864
|
// and it means that the endpoint is working, but that no identity is available.
|
|
2795
2865
|
if (err.statusCode === 400) {
|
|
2796
|
-
throw new CredentialUnavailableError(
|
|
2866
|
+
throw new CredentialUnavailableError(`${ManagedIdentityCredential.name}: The managed identity endpoint is indicating there's no available identity. Message: ${err.message}`);
|
|
2797
2867
|
}
|
|
2798
2868
|
// If the error has no status code, we can assume there was no available identity.
|
|
2799
2869
|
// This will throw silently during any ChainedTokenCredential.
|
|
2800
2870
|
if (err.statusCode === undefined) {
|
|
2801
|
-
throw new CredentialUnavailableError(
|
|
2871
|
+
throw new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Authentication failed. Message ${err.message}`);
|
|
2802
2872
|
}
|
|
2803
2873
|
// Any other error should break the chain.
|
|
2804
2874
|
throw new AuthenticationError(err.statusCode, {
|
|
2805
|
-
error:
|
|
2875
|
+
error: `${ManagedIdentityCredential.name} authentication failed.`,
|
|
2806
2876
|
error_description: err.message
|
|
2807
2877
|
});
|
|
2808
2878
|
}
|
|
@@ -2979,6 +3049,20 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
2979
3049
|
}
|
|
2980
3050
|
}
|
|
2981
3051
|
app.on("connection", (socket) => socketToDestroy.push(socket));
|
|
3052
|
+
app.on("error", (err) => {
|
|
3053
|
+
cleanup();
|
|
3054
|
+
const code = err.code;
|
|
3055
|
+
if (code === "EACCES" || code === "EADDRINUSE") {
|
|
3056
|
+
reject(new CredentialUnavailableError([
|
|
3057
|
+
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3058
|
+
`Try sending a redirect URI with a different port, as follows:`,
|
|
3059
|
+
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`'
|
|
3060
|
+
].join(" ")));
|
|
3061
|
+
}
|
|
3062
|
+
else {
|
|
3063
|
+
reject(new CredentialUnavailableError(`InteractiveBrowserCredential: Failed to start the necessary web server. Error: ${err.message}`));
|
|
3064
|
+
}
|
|
3065
|
+
});
|
|
2982
3066
|
app.on("listening", () => {
|
|
2983
3067
|
const openPromise = this.openAuthCodeUrl(scopes, options);
|
|
2984
3068
|
const abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal;
|
|
@@ -3002,8 +3086,10 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3002
3086
|
this.pkceCodes = await cryptoProvider.generatePkceCodes();
|
|
3003
3087
|
const authCodeUrlParameters = {
|
|
3004
3088
|
scopes: scopeArray,
|
|
3089
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3005
3090
|
redirectUri: this.redirectUri,
|
|
3006
3091
|
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3092
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3007
3093
|
loginHint: this.loginHint,
|
|
3008
3094
|
codeChallenge: this.pkceCodes.challenge,
|
|
3009
3095
|
codeChallengeMethod: "S256" // Use SHA256 Algorithm
|
|
@@ -3013,7 +3099,7 @@ class MsalOpenBrowser extends MsalNode {
|
|
|
3013
3099
|
await interactiveBrowserMockable.open(response, { wait: true });
|
|
3014
3100
|
}
|
|
3015
3101
|
catch (e) {
|
|
3016
|
-
throw new CredentialUnavailableError(`Could not open a browser window. Error: ${e.message}`);
|
|
3102
|
+
throw new CredentialUnavailableError(`InteractiveBrowserCredential: Could not open a browser window. Error: ${e.message}`);
|
|
3017
3103
|
}
|
|
3018
3104
|
}
|
|
3019
3105
|
}
|
|
@@ -3102,7 +3188,8 @@ class MsalDeviceCode extends MsalNode {
|
|
|
3102
3188
|
scopes,
|
|
3103
3189
|
cancel: false,
|
|
3104
3190
|
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3105
|
-
authority: options === null || options === void 0 ? void 0 : options.authority
|
|
3191
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3192
|
+
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
3106
3193
|
};
|
|
3107
3194
|
const promise = this.publicApp.acquireTokenByDeviceCode(requestOptions);
|
|
3108
3195
|
// TODO:
|
|
@@ -3219,7 +3306,10 @@ class MsalAuthorizationCode extends MsalNode {
|
|
|
3219
3306
|
const result = await ((_a = this.confidentialApp) === null || _a === void 0 ? void 0 : _a.acquireTokenByCode({
|
|
3220
3307
|
scopes,
|
|
3221
3308
|
redirectUri: this.redirectUri,
|
|
3222
|
-
code: this.authorizationCode
|
|
3309
|
+
code: this.authorizationCode,
|
|
3310
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3311
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3312
|
+
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
3223
3313
|
}));
|
|
3224
3314
|
// The Client Credential flow does not return an account,
|
|
3225
3315
|
// so each time getToken gets called, we will have to acquire a new token through the service.
|
|
@@ -3252,7 +3342,7 @@ class AuthorizationCodeCredential {
|
|
|
3252
3342
|
// the clientId+clientSecret constructor
|
|
3253
3343
|
this.authorizationCode = authorizationCodeOrRedirectUri;
|
|
3254
3344
|
this.redirectUri = redirectUriOrOptions;
|
|
3255
|
-
// options
|
|
3345
|
+
// in this case, options are good as they come
|
|
3256
3346
|
}
|
|
3257
3347
|
else {
|
|
3258
3348
|
// clientId only
|
|
@@ -3322,6 +3412,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3322
3412
|
scopes,
|
|
3323
3413
|
correlationId: options.correlationId,
|
|
3324
3414
|
authority: options.authority,
|
|
3415
|
+
claims: options.claims,
|
|
3325
3416
|
oboAssertion: this.userAssertionToken
|
|
3326
3417
|
});
|
|
3327
3418
|
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
@@ -3333,8 +3424,8 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
3333
3424
|
}
|
|
3334
3425
|
|
|
3335
3426
|
// Copyright (c) Microsoft Corporation.
|
|
3336
|
-
const credentialName$
|
|
3337
|
-
const logger$j = credentialLogger(credentialName$
|
|
3427
|
+
const credentialName$2 = "OnBehalfOfCredential";
|
|
3428
|
+
const logger$j = credentialLogger(credentialName$2);
|
|
3338
3429
|
/**
|
|
3339
3430
|
* 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).
|
|
3340
3431
|
*/
|
|
@@ -3366,7 +3457,7 @@ class OnBehalfOfCredential {
|
|
|
3366
3457
|
const { certificatePath } = options;
|
|
3367
3458
|
const { tenantId, clientId, userAssertionToken } = options;
|
|
3368
3459
|
if (!tenantId || !clientId || !(clientSecret || certificatePath) || !userAssertionToken) {
|
|
3369
|
-
throw new Error(`${credentialName$
|
|
3460
|
+
throw new Error(`${credentialName$2}: tenantId, clientId, clientSecret (or certificatePath) and userAssertionToken are required parameters.`);
|
|
3370
3461
|
}
|
|
3371
3462
|
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger: logger$j, tokenCredentialOptions: this.options }));
|
|
3372
3463
|
}
|
|
@@ -3378,7 +3469,7 @@ class OnBehalfOfCredential {
|
|
|
3378
3469
|
* @param options - The options used to configure the underlying network requests.
|
|
3379
3470
|
*/
|
|
3380
3471
|
async getToken(scopes, options = {}) {
|
|
3381
|
-
return trace(`${credentialName$
|
|
3472
|
+
return trace(`${credentialName$2}.getToken`, options, async (newOptions) => {
|
|
3382
3473
|
const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
|
|
3383
3474
|
return this.msalFlow.getToken(arrayScopes, newOptions);
|
|
3384
3475
|
});
|