@azure/identity 3.3.1-alpha.20231009.1 → 3.3.1-alpha.20231012.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/dist/index.js +24 -149
- package/dist/index.js.map +1 -1
- package/dist-esm/src/client/identityClient.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredentialOptions.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +2 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js +16 -142
- package/dist-esm/src/msal/nodeFlows/msalOpenBrowser.js.map +1 -1
- package/dist-esm/src/msal/utils.browser.js +236 -0
- package/dist-esm/src/msal/utils.browser.js.map +1 -0
- package/dist-esm/src/msal/utils.js +3 -4
- package/dist-esm/src/msal/utils.js.map +1 -1
- package/dist-esm/src/plugins/provider.js.map +1 -1
- package/package.json +6 -8
- package/types/identity.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var msalCommon = require('@azure/msal-node');
|
|
4
4
|
var logger$o = require('@azure/logger');
|
|
5
|
-
var msalCommon = require('@azure/msal-common');
|
|
6
5
|
var abortController = require('@azure/abort-controller');
|
|
7
6
|
var coreUtil = require('@azure/core-util');
|
|
8
|
-
var uuid = require('uuid');
|
|
9
7
|
var coreClient = require('@azure/core-client');
|
|
10
8
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
11
9
|
var coreTracing = require('@azure/core-tracing');
|
|
@@ -17,9 +15,7 @@ var https = require('https');
|
|
|
17
15
|
var child_process = require('child_process');
|
|
18
16
|
var crypto = require('crypto');
|
|
19
17
|
var util = require('util');
|
|
20
|
-
var http = require('http');
|
|
21
18
|
var open = require('open');
|
|
22
|
-
var stoppable = require('stoppable');
|
|
23
19
|
|
|
24
20
|
function _interopNamespaceDefault(e) {
|
|
25
21
|
var n = Object.create(null);
|
|
@@ -38,7 +34,6 @@ function _interopNamespaceDefault(e) {
|
|
|
38
34
|
return Object.freeze(n);
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
var msalNode__namespace = /*#__PURE__*/_interopNamespaceDefault(msalNode);
|
|
42
37
|
var msalCommon__namespace = /*#__PURE__*/_interopNamespaceDefault(msalCommon);
|
|
43
38
|
var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_process);
|
|
44
39
|
|
|
@@ -412,7 +407,7 @@ class MsalBaseUtilities {
|
|
|
412
407
|
* Generates a UUID
|
|
413
408
|
*/
|
|
414
409
|
generateUuid() {
|
|
415
|
-
return
|
|
410
|
+
return coreUtil.randomUUID();
|
|
416
411
|
}
|
|
417
412
|
/**
|
|
418
413
|
* Handles the MSAL authentication result.
|
|
@@ -1161,10 +1156,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1161
1156
|
};
|
|
1162
1157
|
}
|
|
1163
1158
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1164
|
-
this.caeApp.public = new
|
|
1159
|
+
this.caeApp.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
1165
1160
|
}
|
|
1166
1161
|
else {
|
|
1167
|
-
this.app.public = new
|
|
1162
|
+
this.app.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
1168
1163
|
}
|
|
1169
1164
|
if (this.getAssertion) {
|
|
1170
1165
|
this.msalConfig.auth.clientAssertion = await this.getAssertion();
|
|
@@ -1174,10 +1169,10 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1174
1169
|
this.msalConfig.auth.clientAssertion ||
|
|
1175
1170
|
this.msalConfig.auth.clientCertificate) {
|
|
1176
1171
|
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
1177
|
-
this.caeApp.confidential = new
|
|
1172
|
+
this.caeApp.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1178
1173
|
}
|
|
1179
1174
|
else {
|
|
1180
|
-
this.app.confidential = new
|
|
1175
|
+
this.app.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
1181
1176
|
}
|
|
1182
1177
|
}
|
|
1183
1178
|
else {
|
|
@@ -2326,8 +2321,9 @@ class ManagedIdentityCredential {
|
|
|
2326
2321
|
/** authority host validation and metadata discovery to be skipped in managed identity
|
|
2327
2322
|
* since this wasn't done previously before adding token cache support
|
|
2328
2323
|
*/
|
|
2329
|
-
this.confidentialApp = new
|
|
2324
|
+
this.confidentialApp = new msalCommon.ConfidentialClientApplication({
|
|
2330
2325
|
auth: {
|
|
2326
|
+
authority: "https://login.microsoftonline.com/managed_identity",
|
|
2331
2327
|
clientId: (_a = this.clientId) !== null && _a !== void 0 ? _a : DeveloperSignOnClientId,
|
|
2332
2328
|
clientSecret: "dummy-secret",
|
|
2333
2329
|
cloudDiscoveryMetadata: '{"tenant_discovery_endpoint":"https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}',
|
|
@@ -2415,7 +2411,7 @@ class ManagedIdentityCredential {
|
|
|
2415
2411
|
else {
|
|
2416
2412
|
const appTokenParameters = {
|
|
2417
2413
|
correlationId: this.identityClient.getCorrelationId(),
|
|
2418
|
-
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "
|
|
2414
|
+
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "managed_identity",
|
|
2419
2415
|
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
2420
2416
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
2421
2417
|
};
|
|
@@ -3717,146 +3713,25 @@ const interactiveBrowserMockable = {
|
|
|
3717
3713
|
class MsalOpenBrowser extends MsalNode {
|
|
3718
3714
|
constructor(options) {
|
|
3719
3715
|
super(options);
|
|
3720
|
-
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3721
|
-
this.redirectUri = options.redirectUri;
|
|
3722
3716
|
this.loginHint = options.loginHint;
|
|
3723
|
-
|
|
3724
|
-
this.port = parseInt(url.port);
|
|
3725
|
-
if (isNaN(this.port)) {
|
|
3726
|
-
this.port = 80;
|
|
3727
|
-
}
|
|
3728
|
-
this.hostname = url.hostname;
|
|
3729
|
-
}
|
|
3730
|
-
async acquireTokenByCode(request, enableCae) {
|
|
3731
|
-
return this.getApp("public", enableCae).acquireTokenByCode(request);
|
|
3732
|
-
}
|
|
3733
|
-
doGetToken(scopes, options) {
|
|
3734
|
-
return new Promise((resolve, reject) => {
|
|
3735
|
-
const socketToDestroy = [];
|
|
3736
|
-
const requestListener = (req, res) => {
|
|
3737
|
-
var _a;
|
|
3738
|
-
if (!req.url) {
|
|
3739
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3740
|
-
return;
|
|
3741
|
-
}
|
|
3742
|
-
let url;
|
|
3743
|
-
try {
|
|
3744
|
-
url = new URL(req.url, this.redirectUri);
|
|
3745
|
-
}
|
|
3746
|
-
catch (e) {
|
|
3747
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3748
|
-
return;
|
|
3749
|
-
}
|
|
3750
|
-
const tokenRequest = {
|
|
3751
|
-
code: url.searchParams.get("code"),
|
|
3752
|
-
redirectUri: this.redirectUri,
|
|
3753
|
-
scopes: scopes,
|
|
3754
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3755
|
-
codeVerifier: (_a = this.pkceCodes) === null || _a === void 0 ? void 0 : _a.verifier,
|
|
3756
|
-
};
|
|
3757
|
-
this.acquireTokenByCode(tokenRequest, options === null || options === void 0 ? void 0 : options.enableCae)
|
|
3758
|
-
.then((authResponse) => {
|
|
3759
|
-
if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.account) {
|
|
3760
|
-
this.account = msalToPublic(this.clientId, authResponse.account);
|
|
3761
|
-
}
|
|
3762
|
-
const successMessage = `Authentication Complete. You can close the browser and return to the application.`;
|
|
3763
|
-
if (authResponse && authResponse.expiresOn) {
|
|
3764
|
-
const expiresOnTimestamp = authResponse === null || authResponse === void 0 ? void 0 : authResponse.expiresOn.valueOf();
|
|
3765
|
-
res.writeHead(200);
|
|
3766
|
-
res.end(successMessage);
|
|
3767
|
-
this.logger.getToken.info(formatSuccess(scopes));
|
|
3768
|
-
resolve({
|
|
3769
|
-
expiresOnTimestamp,
|
|
3770
|
-
token: authResponse.accessToken,
|
|
3771
|
-
});
|
|
3772
|
-
}
|
|
3773
|
-
else {
|
|
3774
|
-
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3775
|
-
res.writeHead(500);
|
|
3776
|
-
res.end(errorMessage);
|
|
3777
|
-
this.logger.getToken.info(errorMessage);
|
|
3778
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3779
|
-
}
|
|
3780
|
-
cleanup();
|
|
3781
|
-
return;
|
|
3782
|
-
})
|
|
3783
|
-
.catch(() => {
|
|
3784
|
-
const errorMessage = formatError(scopes, `${url.searchParams.get("error")}. ${url.searchParams.get("error_description")}`);
|
|
3785
|
-
res.writeHead(500);
|
|
3786
|
-
res.end(errorMessage);
|
|
3787
|
-
this.logger.getToken.info(errorMessage);
|
|
3788
|
-
reject(new Error(`Interactive Browser Authentication Error "Did not receive token with a valid expiration"`));
|
|
3789
|
-
cleanup();
|
|
3790
|
-
});
|
|
3791
|
-
};
|
|
3792
|
-
const app = http.createServer(requestListener);
|
|
3793
|
-
const server = stoppable(app);
|
|
3794
|
-
const listen = app.listen(this.port, this.hostname, () => this.logger.info(`InteractiveBrowserCredential listening on port ${this.port}!`));
|
|
3795
|
-
function cleanup() {
|
|
3796
|
-
if (listen) {
|
|
3797
|
-
listen.close();
|
|
3798
|
-
}
|
|
3799
|
-
for (const socket of socketToDestroy) {
|
|
3800
|
-
socket.destroy();
|
|
3801
|
-
}
|
|
3802
|
-
if (server) {
|
|
3803
|
-
server.close();
|
|
3804
|
-
server.stop();
|
|
3805
|
-
}
|
|
3806
|
-
}
|
|
3807
|
-
app.on("connection", (socket) => socketToDestroy.push(socket));
|
|
3808
|
-
app.on("error", (err) => {
|
|
3809
|
-
cleanup();
|
|
3810
|
-
const code = err.code;
|
|
3811
|
-
if (code === "EACCES" || code === "EADDRINUSE") {
|
|
3812
|
-
reject(new CredentialUnavailableError([
|
|
3813
|
-
`InteractiveBrowserCredential: Access denied to port ${this.port}.`,
|
|
3814
|
-
`Try sending a redirect URI with a different port, as follows:`,
|
|
3815
|
-
'`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`',
|
|
3816
|
-
].join(" ")));
|
|
3817
|
-
}
|
|
3818
|
-
else {
|
|
3819
|
-
reject(new CredentialUnavailableError(`InteractiveBrowserCredential: Failed to start the necessary web server. Error: ${err.message}`));
|
|
3820
|
-
}
|
|
3821
|
-
});
|
|
3822
|
-
app.on("listening", () => {
|
|
3823
|
-
const openPromise = this.openAuthCodeUrl(scopes, options);
|
|
3824
|
-
const abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal;
|
|
3825
|
-
if (abortSignal) {
|
|
3826
|
-
abortSignal.addEventListener("abort", () => {
|
|
3827
|
-
cleanup();
|
|
3828
|
-
reject(new Error("Aborted"));
|
|
3829
|
-
});
|
|
3830
|
-
}
|
|
3831
|
-
openPromise.catch((e) => {
|
|
3832
|
-
cleanup();
|
|
3833
|
-
reject(e);
|
|
3834
|
-
});
|
|
3835
|
-
});
|
|
3836
|
-
});
|
|
3717
|
+
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
3837
3718
|
}
|
|
3838
|
-
async
|
|
3839
|
-
// Initialize CryptoProvider instance
|
|
3840
|
-
const cryptoProvider = new msalNode__namespace.CryptoProvider();
|
|
3841
|
-
// Generate PKCE Codes before starting the authorization flow
|
|
3842
|
-
this.pkceCodes = await cryptoProvider.generatePkceCodes();
|
|
3843
|
-
const authCodeUrlParameters = {
|
|
3844
|
-
scopes: scopeArray,
|
|
3845
|
-
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3846
|
-
redirectUri: this.redirectUri,
|
|
3847
|
-
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3848
|
-
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3849
|
-
loginHint: this.loginHint,
|
|
3850
|
-
codeChallenge: this.pkceCodes.challenge,
|
|
3851
|
-
codeChallengeMethod: "S256", // Use SHA256 Algorithm
|
|
3852
|
-
};
|
|
3853
|
-
const response = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).getAuthCodeUrl(authCodeUrlParameters);
|
|
3719
|
+
async doGetToken(scopes, options) {
|
|
3854
3720
|
try {
|
|
3855
|
-
|
|
3856
|
-
|
|
3721
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive({
|
|
3722
|
+
openBrowser: async (url) => {
|
|
3723
|
+
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
|
3724
|
+
},
|
|
3725
|
+
scopes,
|
|
3726
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
3727
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
3728
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
3729
|
+
loginHint: this.loginHint,
|
|
3730
|
+
});
|
|
3731
|
+
return this.handleResult(scopes, this.clientId, result || undefined);
|
|
3857
3732
|
}
|
|
3858
|
-
catch (
|
|
3859
|
-
throw
|
|
3733
|
+
catch (err) {
|
|
3734
|
+
throw this.handleError(scopes, err, options);
|
|
3860
3735
|
}
|
|
3861
3736
|
}
|
|
3862
3737
|
}
|