@ms-cloudpack/remote-cache 0.8.12 → 0.8.14
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.
- package/dist/{AzureRemoteCacheClient-SXMK4YHG.js → AzureRemoteCacheClient-RYQX2JZE.js} +2 -2
- package/dist/{ReporterDecorator-FPB3SR62.js → ReporterDecorator-V2YEIC5V.js} +2 -2
- package/dist/{chunk-4MIMLTI6.js → chunk-S3ZJNZYB.js} +33 -184
- package/dist/{chunk-OSKYHKJO.js → chunk-WR3ABZS6.js} +149 -49
- package/dist/{getCredential-FLIB2Y4Q.js → getCredential-TGHZRNZU.js} +1304 -491
- package/dist/{getListOfBlobs-LFPGQVDD.js → getListOfBlobs-6GZGACOS.js} +2 -2
- package/dist/index.js +4 -4
- package/package.json +5 -5
|
@@ -8,13 +8,12 @@ import {
|
|
|
8
8
|
require_package as require_package2
|
|
9
9
|
} from "./chunk-F35F2EJX.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
require_dist,
|
|
11
|
+
require_commonjs2,
|
|
12
|
+
require_commonjs3,
|
|
13
|
+
require_commonjs4,
|
|
14
|
+
require_commonjs5,
|
|
16
15
|
require_package
|
|
17
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S3ZJNZYB.js";
|
|
18
17
|
import {
|
|
19
18
|
__commonJS,
|
|
20
19
|
__esm,
|
|
@@ -26,6 +25,157 @@ import {
|
|
|
26
25
|
require_commonjs
|
|
27
26
|
} from "./chunk-PAESICSC.js";
|
|
28
27
|
|
|
28
|
+
// ../../node_modules/.store/@azure-abort-controller-npm-1.1.0-5b4e309629/package/dist/index.js
|
|
29
|
+
var require_dist = __commonJS({
|
|
30
|
+
"../../node_modules/.store/@azure-abort-controller-npm-1.1.0-5b4e309629/package/dist/index.js"(exports) {
|
|
31
|
+
"use strict";
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
var listenersMap = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
var abortedMap = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
var _AbortSignal = class _AbortSignal {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.onabort = null;
|
|
38
|
+
listenersMap.set(this, []);
|
|
39
|
+
abortedMap.set(this, false);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Status of whether aborted or not.
|
|
43
|
+
*
|
|
44
|
+
* @readonly
|
|
45
|
+
*/
|
|
46
|
+
get aborted() {
|
|
47
|
+
if (!abortedMap.has(this)) {
|
|
48
|
+
throw new TypeError("Expected `this` to be an instance of AbortSignal.");
|
|
49
|
+
}
|
|
50
|
+
return abortedMap.get(this);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new AbortSignal instance that will never be aborted.
|
|
54
|
+
*
|
|
55
|
+
* @readonly
|
|
56
|
+
*/
|
|
57
|
+
static get none() {
|
|
58
|
+
return new _AbortSignal();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Added new "abort" event listener, only support "abort" event.
|
|
62
|
+
*
|
|
63
|
+
* @param _type - Only support "abort" event
|
|
64
|
+
* @param listener - The listener to be added
|
|
65
|
+
*/
|
|
66
|
+
addEventListener(_type, listener) {
|
|
67
|
+
if (!listenersMap.has(this)) {
|
|
68
|
+
throw new TypeError("Expected `this` to be an instance of AbortSignal.");
|
|
69
|
+
}
|
|
70
|
+
const listeners = listenersMap.get(this);
|
|
71
|
+
listeners.push(listener);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Remove "abort" event listener, only support "abort" event.
|
|
75
|
+
*
|
|
76
|
+
* @param _type - Only support "abort" event
|
|
77
|
+
* @param listener - The listener to be removed
|
|
78
|
+
*/
|
|
79
|
+
removeEventListener(_type, listener) {
|
|
80
|
+
if (!listenersMap.has(this)) {
|
|
81
|
+
throw new TypeError("Expected `this` to be an instance of AbortSignal.");
|
|
82
|
+
}
|
|
83
|
+
const listeners = listenersMap.get(this);
|
|
84
|
+
const index = listeners.indexOf(listener);
|
|
85
|
+
if (index > -1) {
|
|
86
|
+
listeners.splice(index, 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Dispatches a synthetic event to the AbortSignal.
|
|
91
|
+
*/
|
|
92
|
+
dispatchEvent(_event) {
|
|
93
|
+
throw new Error("This is a stub dispatchEvent implementation that should not be used. It only exists for type-checking purposes.");
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
__name(_AbortSignal, "AbortSignal");
|
|
97
|
+
var AbortSignal = _AbortSignal;
|
|
98
|
+
function abortSignal(signal) {
|
|
99
|
+
if (signal.aborted) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (signal.onabort) {
|
|
103
|
+
signal.onabort.call(signal);
|
|
104
|
+
}
|
|
105
|
+
const listeners = listenersMap.get(signal);
|
|
106
|
+
if (listeners) {
|
|
107
|
+
listeners.slice().forEach((listener) => {
|
|
108
|
+
listener.call(signal, { type: "abort" });
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
abortedMap.set(signal, true);
|
|
112
|
+
}
|
|
113
|
+
__name(abortSignal, "abortSignal");
|
|
114
|
+
var _AbortError = class _AbortError extends Error {
|
|
115
|
+
constructor(message) {
|
|
116
|
+
super(message);
|
|
117
|
+
this.name = "AbortError";
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
__name(_AbortError, "AbortError");
|
|
121
|
+
var AbortError = _AbortError;
|
|
122
|
+
var _AbortController = class _AbortController {
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
124
|
+
constructor(parentSignals) {
|
|
125
|
+
this._signal = new AbortSignal();
|
|
126
|
+
if (!parentSignals) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!Array.isArray(parentSignals)) {
|
|
130
|
+
parentSignals = arguments;
|
|
131
|
+
}
|
|
132
|
+
for (const parentSignal of parentSignals) {
|
|
133
|
+
if (parentSignal.aborted) {
|
|
134
|
+
this.abort();
|
|
135
|
+
} else {
|
|
136
|
+
parentSignal.addEventListener("abort", () => {
|
|
137
|
+
this.abort();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The AbortSignal associated with this controller that will signal aborted
|
|
144
|
+
* when the abort method is called on this controller.
|
|
145
|
+
*
|
|
146
|
+
* @readonly
|
|
147
|
+
*/
|
|
148
|
+
get signal() {
|
|
149
|
+
return this._signal;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Signal that any operations passed this controller's associated abort signal
|
|
153
|
+
* to cancel any remaining work and throw an `AbortError`.
|
|
154
|
+
*/
|
|
155
|
+
abort() {
|
|
156
|
+
abortSignal(this._signal);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Creates a new AbortSignal instance that will abort after the provided ms.
|
|
160
|
+
* @param ms - Elapsed time in milliseconds to trigger an abort.
|
|
161
|
+
*/
|
|
162
|
+
static timeout(ms) {
|
|
163
|
+
const signal = new AbortSignal();
|
|
164
|
+
const timer = setTimeout(abortSignal, ms, signal);
|
|
165
|
+
if (typeof timer.unref === "function") {
|
|
166
|
+
timer.unref();
|
|
167
|
+
}
|
|
168
|
+
return signal;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
__name(_AbortController, "AbortController");
|
|
172
|
+
var AbortController = _AbortController;
|
|
173
|
+
exports.AbortController = AbortController;
|
|
174
|
+
exports.AbortError = AbortError;
|
|
175
|
+
exports.AbortSignal = AbortSignal;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
29
179
|
// ../../node_modules/.store/uuid-npm-8.3.2-eca0baba53/package/dist/esm-node/rng.js
|
|
30
180
|
import crypto from "crypto";
|
|
31
181
|
function rng() {
|
|
@@ -4063,9 +4213,9 @@ var require_package14 = __commonJS({
|
|
|
4063
4213
|
}
|
|
4064
4214
|
});
|
|
4065
4215
|
|
|
4066
|
-
// ../../node_modules/.store/@azure-msal-node-npm-2.
|
|
4216
|
+
// ../../node_modules/.store/@azure-msal-node-npm-2.15.0-02a613cb10/package/lib/msal-node.cjs
|
|
4067
4217
|
var require_msal_node = __commonJS({
|
|
4068
|
-
"../../node_modules/.store/@azure-msal-node-npm-2.
|
|
4218
|
+
"../../node_modules/.store/@azure-msal-node-npm-2.15.0-02a613cb10/package/lib/msal-node.cjs"(exports) {
|
|
4069
4219
|
"use strict";
|
|
4070
4220
|
var http = __require("http");
|
|
4071
4221
|
var https = __require("https");
|
|
@@ -12439,7 +12589,7 @@ Headers: ${JSON.stringify(headers)}`
|
|
|
12439
12589
|
__name(_ClientAssertion, "ClientAssertion");
|
|
12440
12590
|
var ClientAssertion = _ClientAssertion;
|
|
12441
12591
|
var name = "@azure/msal-node";
|
|
12442
|
-
var version2 = "2.
|
|
12592
|
+
var version2 = "2.15.0";
|
|
12443
12593
|
var _UsernamePasswordClient = class _UsernamePasswordClient extends BaseClient {
|
|
12444
12594
|
constructor(configuration) {
|
|
12445
12595
|
super(configuration);
|
|
@@ -14254,7 +14404,7 @@ Headers: ${JSON.stringify(headers)}`
|
|
|
14254
14404
|
authority: this.fakeAuthority.canonicalAuthority,
|
|
14255
14405
|
correlationId: this.cryptoProvider.createNewGuid()
|
|
14256
14406
|
};
|
|
14257
|
-
if (managedIdentityRequest.forceRefresh) {
|
|
14407
|
+
if (managedIdentityRequestParams.claims || managedIdentityRequest.forceRefresh) {
|
|
14258
14408
|
return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
|
|
14259
14409
|
}
|
|
14260
14410
|
const [cachedAuthenticationResult, lastCacheOutcome] = await this.fakeClientCredentialClient.getCachedAuthenticationResult(managedIdentityRequest, this.config, this.cryptoProvider, this.fakeAuthority, _ManagedIdentityApplication.nodeStorage);
|
|
@@ -14686,12 +14836,12 @@ var require_package18 = __commonJS({
|
|
|
14686
14836
|
}
|
|
14687
14837
|
});
|
|
14688
14838
|
|
|
14689
|
-
// ../../node_modules/.store/@azure-identity-npm-4.
|
|
14839
|
+
// ../../node_modules/.store/@azure-identity-npm-4.3.0-e85334d38f/package/dist/index.js
|
|
14690
14840
|
var require_dist2 = __commonJS({
|
|
14691
|
-
"../../node_modules/.store/@azure-identity-npm-4.
|
|
14841
|
+
"../../node_modules/.store/@azure-identity-npm-4.3.0-e85334d38f/package/dist/index.js"(exports) {
|
|
14692
14842
|
"use strict";
|
|
14693
14843
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14694
|
-
var logger$
|
|
14844
|
+
var logger$r = require_commonjs();
|
|
14695
14845
|
var coreClient = require_commonjs5();
|
|
14696
14846
|
var coreUtil = require_commonjs2();
|
|
14697
14847
|
var coreRestPipeline = require_commonjs4();
|
|
@@ -14701,12 +14851,13 @@ var require_dist2 = __commonJS({
|
|
|
14701
14851
|
var os = __require("os");
|
|
14702
14852
|
var path4 = __require("path");
|
|
14703
14853
|
var msalCommon = require_msal_node();
|
|
14704
|
-
var
|
|
14854
|
+
var fs$1 = __require("node:fs");
|
|
14855
|
+
var https = __require("https");
|
|
14705
14856
|
var promises = __require("fs/promises");
|
|
14706
14857
|
var child_process = __require("child_process");
|
|
14707
14858
|
var crypto4 = __require("crypto");
|
|
14708
|
-
var
|
|
14709
|
-
var
|
|
14859
|
+
var open = require_package18();
|
|
14860
|
+
var util = __require("util");
|
|
14710
14861
|
function _interopNamespaceDefault(e) {
|
|
14711
14862
|
var n = /* @__PURE__ */ Object.create(null);
|
|
14712
14863
|
if (e) {
|
|
@@ -14728,7 +14879,7 @@ var require_dist2 = __commonJS({
|
|
|
14728
14879
|
__name(_interopNamespaceDefault, "_interopNamespaceDefault");
|
|
14729
14880
|
var msalCommon__namespace = /* @__PURE__ */ _interopNamespaceDefault(msalCommon);
|
|
14730
14881
|
var child_process__namespace = /* @__PURE__ */ _interopNamespaceDefault(child_process);
|
|
14731
|
-
var SDK_VERSION = `4.
|
|
14882
|
+
var SDK_VERSION = `4.3.0-beta.3`;
|
|
14732
14883
|
var DeveloperSignOnClientId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46";
|
|
14733
14884
|
var DefaultTenantId = "common";
|
|
14734
14885
|
exports.AzureAuthorityHosts = void 0;
|
|
@@ -14750,6 +14901,10 @@ var require_dist2 = __commonJS({
|
|
|
14750
14901
|
}
|
|
14751
14902
|
};
|
|
14752
14903
|
var nativeBrokerInfo = void 0;
|
|
14904
|
+
function hasNativeBroker() {
|
|
14905
|
+
return nativeBrokerInfo !== void 0;
|
|
14906
|
+
}
|
|
14907
|
+
__name(hasNativeBroker, "hasNativeBroker");
|
|
14753
14908
|
var msalNodeFlowNativeBrokerControl = {
|
|
14754
14909
|
setNativeBroker(broker) {
|
|
14755
14910
|
nativeBrokerInfo = {
|
|
@@ -14797,7 +14952,7 @@ var require_dist2 = __commonJS({
|
|
|
14797
14952
|
var msalPlugins = {
|
|
14798
14953
|
generatePluginConfiguration
|
|
14799
14954
|
};
|
|
14800
|
-
var logger$
|
|
14955
|
+
var logger$q = logger$r.createClientLogger("identity");
|
|
14801
14956
|
function processEnvVars(supportedEnvVars) {
|
|
14802
14957
|
return supportedEnvVars.reduce((acc, envVariable) => {
|
|
14803
14958
|
if (process.env[envVariable]) {
|
|
@@ -14821,7 +14976,7 @@ var require_dist2 = __commonJS({
|
|
|
14821
14976
|
return `${message} Error message: ${typeof error === "string" ? error : error.message}.`;
|
|
14822
14977
|
}
|
|
14823
14978
|
__name(formatError, "formatError");
|
|
14824
|
-
function credentialLoggerInstance(title, parent, log = logger$
|
|
14979
|
+
function credentialLoggerInstance(title, parent, log = logger$q) {
|
|
14825
14980
|
const fullTitle = parent ? `${parent.fullTitle} ${title}` : title;
|
|
14826
14981
|
function info(message) {
|
|
14827
14982
|
log.info(`${fullTitle} =>`, message);
|
|
@@ -14849,7 +15004,7 @@ var require_dist2 = __commonJS({
|
|
|
14849
15004
|
};
|
|
14850
15005
|
}
|
|
14851
15006
|
__name(credentialLoggerInstance, "credentialLoggerInstance");
|
|
14852
|
-
function credentialLogger(title, log = logger$
|
|
15007
|
+
function credentialLogger(title, log = logger$q) {
|
|
14853
15008
|
const credLogger = credentialLoggerInstance(title, void 0, log);
|
|
14854
15009
|
return Object.assign(Object.assign({}, credLogger), { parent: log, getToken: credentialLoggerInstance("=> getToken()", credLogger, log) });
|
|
14855
15010
|
}
|
|
@@ -15016,6 +15171,8 @@ ${errorDetail}`);
|
|
|
15016
15171
|
var imdsHost = "http://169.254.169.254";
|
|
15017
15172
|
var imdsEndpointPath = "/metadata/identity/oauth2/token";
|
|
15018
15173
|
var imdsApiVersion = "2018-02-01";
|
|
15174
|
+
var azureArcAPIVersion = "2019-11-01";
|
|
15175
|
+
var azureFabricVersion = "2019-07-01-preview";
|
|
15019
15176
|
function mapScopesToResource(scopes) {
|
|
15020
15177
|
let scope = "";
|
|
15021
15178
|
if (Array.isArray(scopes)) {
|
|
@@ -15075,17 +15232,13 @@ ${errorDetail}`);
|
|
|
15075
15232
|
} }, options), { userAgentOptions: {
|
|
15076
15233
|
userAgentPrefix
|
|
15077
15234
|
}, baseUri }));
|
|
15078
|
-
this.allowInsecureConnection = false;
|
|
15079
15235
|
this.authorityHost = baseUri;
|
|
15080
15236
|
this.abortControllers = /* @__PURE__ */ new Map();
|
|
15081
15237
|
this.allowLoggingAccountIdentifiers = (_b2 = options === null || options === void 0 ? void 0 : options.loggingOptions) === null || _b2 === void 0 ? void 0 : _b2.allowLoggingAccountIdentifiers;
|
|
15082
15238
|
this.tokenCredentialOptions = Object.assign({}, options);
|
|
15083
|
-
if (options === null || options === void 0 ? void 0 : options.allowInsecureConnection) {
|
|
15084
|
-
this.allowInsecureConnection = options.allowInsecureConnection;
|
|
15085
|
-
}
|
|
15086
15239
|
}
|
|
15087
15240
|
async sendTokenRequest(request) {
|
|
15088
|
-
logger$
|
|
15241
|
+
logger$q.info(`IdentityClient: sending token request to [${request.url}]`);
|
|
15089
15242
|
const response = await this.sendRequest(request);
|
|
15090
15243
|
if (response.bodyAsText && (response.status === 200 || response.status === 201)) {
|
|
15091
15244
|
const parsedBody = JSON.parse(response.bodyAsText);
|
|
@@ -15100,11 +15253,11 @@ ${errorDetail}`);
|
|
|
15100
15253
|
},
|
|
15101
15254
|
refreshToken: parsedBody.refresh_token
|
|
15102
15255
|
};
|
|
15103
|
-
logger$
|
|
15256
|
+
logger$q.info(`IdentityClient: [${request.url}] token acquired, expires on ${token.accessToken.expiresOnTimestamp}`);
|
|
15104
15257
|
return token;
|
|
15105
15258
|
} else {
|
|
15106
15259
|
const error = new AuthenticationError(response.status, response.bodyAsText);
|
|
15107
|
-
logger$
|
|
15260
|
+
logger$q.warning(`IdentityClient: authentication error. HTTP status: ${response.status}, ${error.errorResponse.errorDescription}`);
|
|
15108
15261
|
throw error;
|
|
15109
15262
|
}
|
|
15110
15263
|
}
|
|
@@ -15112,7 +15265,7 @@ ${errorDetail}`);
|
|
|
15112
15265
|
if (refreshToken === void 0) {
|
|
15113
15266
|
return null;
|
|
15114
15267
|
}
|
|
15115
|
-
logger$
|
|
15268
|
+
logger$q.info(`IdentityClient: refreshing access token with client ID: ${clientId}, scopes: ${scopes} started`);
|
|
15116
15269
|
const refreshParams = {
|
|
15117
15270
|
grant_type: "refresh_token",
|
|
15118
15271
|
client_id: clientId,
|
|
@@ -15138,14 +15291,14 @@ ${errorDetail}`);
|
|
|
15138
15291
|
tracingOptions: updatedOptions.tracingOptions
|
|
15139
15292
|
});
|
|
15140
15293
|
const response = await this.sendTokenRequest(request);
|
|
15141
|
-
logger$
|
|
15294
|
+
logger$q.info(`IdentityClient: refreshed token for client ID: ${clientId}`);
|
|
15142
15295
|
return response;
|
|
15143
15296
|
} catch (err) {
|
|
15144
15297
|
if (err.name === AuthenticationErrorName && err.errorResponse.error === "interaction_required") {
|
|
15145
|
-
logger$
|
|
15298
|
+
logger$q.info(`IdentityClient: interaction required for client ID: ${clientId}`);
|
|
15146
15299
|
return null;
|
|
15147
15300
|
} else {
|
|
15148
|
-
logger$
|
|
15301
|
+
logger$q.warning(`IdentityClient: failed refreshing token for client ID: ${clientId}: ${err}`);
|
|
15149
15302
|
throw err;
|
|
15150
15303
|
}
|
|
15151
15304
|
}
|
|
@@ -15193,7 +15346,6 @@ ${errorDetail}`);
|
|
|
15193
15346
|
url,
|
|
15194
15347
|
method: "GET",
|
|
15195
15348
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
15196
|
-
allowInsecureConnection: this.allowInsecureConnection,
|
|
15197
15349
|
headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
|
|
15198
15350
|
abortSignal: this.generateAbortSignal(noCorrelationId)
|
|
15199
15351
|
});
|
|
@@ -15211,7 +15363,6 @@ ${errorDetail}`);
|
|
|
15211
15363
|
method: "POST",
|
|
15212
15364
|
body: options === null || options === void 0 ? void 0 : options.body,
|
|
15213
15365
|
headers: coreRestPipeline.createHttpHeaders(options === null || options === void 0 ? void 0 : options.headers),
|
|
15214
|
-
allowInsecureConnection: this.allowInsecureConnection,
|
|
15215
15366
|
// MSAL doesn't send the correlation ID on the get requests.
|
|
15216
15367
|
abortSignal: this.generateAbortSignal(this.getCorrelationId(options))
|
|
15217
15368
|
});
|
|
@@ -15255,9 +15406,9 @@ ${errorDetail}`);
|
|
|
15255
15406
|
}
|
|
15256
15407
|
const base64Metadata = accessToken.split(".")[1];
|
|
15257
15408
|
const { appid, upn, tid, oid } = JSON.parse(Buffer.from(base64Metadata, "base64").toString("utf8"));
|
|
15258
|
-
logger$
|
|
15409
|
+
logger$q.info(`[Authenticated account] Client ID: ${appid}. Tenant ID: ${tid}. User Principal Name: ${upn || unavailableUpn}. Object ID (user): ${oid}`);
|
|
15259
15410
|
} catch (e) {
|
|
15260
|
-
logger$
|
|
15411
|
+
logger$q.warning("allowLoggingAccountIdentifiers was set, but we couldn't log the account information. Error:", e.message);
|
|
15261
15412
|
}
|
|
15262
15413
|
}
|
|
15263
15414
|
};
|
|
@@ -15265,7 +15416,7 @@ ${errorDetail}`);
|
|
|
15265
15416
|
var IdentityClient = _IdentityClient;
|
|
15266
15417
|
var CommonTenantId = "common";
|
|
15267
15418
|
var AzureAccountClientId = "aebc6443-996d-45c2-90f0-388ff96faa56";
|
|
15268
|
-
var logger$
|
|
15419
|
+
var logger$p = credentialLogger("VisualStudioCodeCredential");
|
|
15269
15420
|
var findCredentials = void 0;
|
|
15270
15421
|
var vsCodeCredentialControl = {
|
|
15271
15422
|
setVsCodeCredentialFinder(finder) {
|
|
@@ -15312,7 +15463,7 @@ ${errorDetail}`);
|
|
|
15312
15463
|
return;
|
|
15313
15464
|
}
|
|
15314
15465
|
} catch (e) {
|
|
15315
|
-
logger$
|
|
15466
|
+
logger$p.info(`Failed to load the Visual Studio Code configuration file. Error: ${e.message}`);
|
|
15316
15467
|
return;
|
|
15317
15468
|
}
|
|
15318
15469
|
}
|
|
@@ -15333,7 +15484,7 @@ ${errorDetail}`);
|
|
|
15333
15484
|
const authorityHost = mapVSCodeAuthorityHosts[this.cloudName];
|
|
15334
15485
|
this.identityClient = new IdentityClient(Object.assign({ authorityHost }, options));
|
|
15335
15486
|
if (options && options.tenantId) {
|
|
15336
|
-
checkTenantId(logger$
|
|
15487
|
+
checkTenantId(logger$p, options.tenantId);
|
|
15337
15488
|
this.tenantId = options.tenantId;
|
|
15338
15489
|
} else {
|
|
15339
15490
|
this.tenantId = CommonTenantId;
|
|
@@ -15371,7 +15522,7 @@ ${errorDetail}`);
|
|
|
15371
15522
|
async getToken(scopes, options) {
|
|
15372
15523
|
var _a2, _b2;
|
|
15373
15524
|
await this.prepareOnce();
|
|
15374
|
-
const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds, logger$
|
|
15525
|
+
const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds, logger$p) || this.tenantId;
|
|
15375
15526
|
if (findCredentials === void 0) {
|
|
15376
15527
|
throw new CredentialUnavailableError([
|
|
15377
15528
|
"No implementation of `VisualStudioCodeCredential` is available.",
|
|
@@ -15384,7 +15535,7 @@ ${errorDetail}`);
|
|
|
15384
15535
|
let scopeString = typeof scopes === "string" ? scopes : scopes.join(" ");
|
|
15385
15536
|
if (!scopeString.match(/^[0-9a-zA-Z-.:/]+$/)) {
|
|
15386
15537
|
const error = new Error("Invalid scope was specified by the user or calling client");
|
|
15387
|
-
logger$
|
|
15538
|
+
logger$p.getToken.info(formatError(scopes, error));
|
|
15388
15539
|
throw error;
|
|
15389
15540
|
}
|
|
15390
15541
|
if (scopeString.indexOf("offline_access") < 0) {
|
|
@@ -15395,16 +15546,16 @@ ${errorDetail}`);
|
|
|
15395
15546
|
if (refreshToken) {
|
|
15396
15547
|
const tokenResponse = await this.identityClient.refreshAccessToken(tenantId, AzureAccountClientId, scopeString, refreshToken, void 0);
|
|
15397
15548
|
if (tokenResponse) {
|
|
15398
|
-
logger$
|
|
15549
|
+
logger$p.getToken.info(formatSuccess(scopes));
|
|
15399
15550
|
return tokenResponse.accessToken;
|
|
15400
15551
|
} else {
|
|
15401
15552
|
const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Have you connected using the 'Azure Account' extension recently? To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.");
|
|
15402
|
-
logger$
|
|
15553
|
+
logger$p.getToken.info(formatError(scopes, error));
|
|
15403
15554
|
throw error;
|
|
15404
15555
|
}
|
|
15405
15556
|
} else {
|
|
15406
15557
|
const error = new CredentialUnavailableError("Could not retrieve the token associated with Visual Studio Code. Did you connect using the 'Azure Account' extension? To troubleshoot, visit https://aka.ms/azsdk/js/identity/vscodecredential/troubleshoot.");
|
|
15407
|
-
logger$
|
|
15558
|
+
logger$p.getToken.info(formatError(scopes, error));
|
|
15408
15559
|
throw error;
|
|
15409
15560
|
}
|
|
15410
15561
|
}
|
|
@@ -15420,6 +15571,377 @@ ${errorDetail}`);
|
|
|
15420
15571
|
plugin(pluginContext);
|
|
15421
15572
|
}
|
|
15422
15573
|
__name(useIdentityPlugin2, "useIdentityPlugin");
|
|
15574
|
+
var msiName$6 = "ManagedIdentityCredential - AppServiceMSI 2017";
|
|
15575
|
+
var logger$o = credentialLogger(msiName$6);
|
|
15576
|
+
function prepareRequestOptions$5(scopes, clientId) {
|
|
15577
|
+
const resource = mapScopesToResource(scopes);
|
|
15578
|
+
if (!resource) {
|
|
15579
|
+
throw new Error(`${msiName$6}: Multiple scopes are not supported.`);
|
|
15580
|
+
}
|
|
15581
|
+
const queryParameters = {
|
|
15582
|
+
resource,
|
|
15583
|
+
"api-version": "2017-09-01"
|
|
15584
|
+
};
|
|
15585
|
+
if (clientId) {
|
|
15586
|
+
queryParameters.clientid = clientId;
|
|
15587
|
+
}
|
|
15588
|
+
const query = new URLSearchParams(queryParameters);
|
|
15589
|
+
if (!process.env.MSI_ENDPOINT) {
|
|
15590
|
+
throw new Error(`${msiName$6}: Missing environment variable: MSI_ENDPOINT`);
|
|
15591
|
+
}
|
|
15592
|
+
if (!process.env.MSI_SECRET) {
|
|
15593
|
+
throw new Error(`${msiName$6}: Missing environment variable: MSI_SECRET`);
|
|
15594
|
+
}
|
|
15595
|
+
return {
|
|
15596
|
+
url: `${process.env.MSI_ENDPOINT}?${query.toString()}`,
|
|
15597
|
+
method: "GET",
|
|
15598
|
+
headers: coreRestPipeline.createHttpHeaders({
|
|
15599
|
+
Accept: "application/json",
|
|
15600
|
+
secret: process.env.MSI_SECRET
|
|
15601
|
+
})
|
|
15602
|
+
};
|
|
15603
|
+
}
|
|
15604
|
+
__name(prepareRequestOptions$5, "prepareRequestOptions$5");
|
|
15605
|
+
var appServiceMsi2017 = {
|
|
15606
|
+
name: "appServiceMsi2017",
|
|
15607
|
+
async isAvailable({ scopes }) {
|
|
15608
|
+
const resource = mapScopesToResource(scopes);
|
|
15609
|
+
if (!resource) {
|
|
15610
|
+
logger$o.info(`${msiName$6}: Unavailable. Multiple scopes are not supported.`);
|
|
15611
|
+
return false;
|
|
15612
|
+
}
|
|
15613
|
+
const env = process.env;
|
|
15614
|
+
const result = Boolean(env.MSI_ENDPOINT && env.MSI_SECRET);
|
|
15615
|
+
if (!result) {
|
|
15616
|
+
logger$o.info(`${msiName$6}: Unavailable. The environment variables needed are: MSI_ENDPOINT and MSI_SECRET.`);
|
|
15617
|
+
}
|
|
15618
|
+
return result;
|
|
15619
|
+
},
|
|
15620
|
+
async getToken(configuration, getTokenOptions = {}) {
|
|
15621
|
+
const { identityClient, scopes, clientId, resourceId } = configuration;
|
|
15622
|
+
if (resourceId) {
|
|
15623
|
+
logger$o.warning(`${msiName$6}: managed Identity by resource Id is not supported. Argument resourceId might be ignored by the service.`);
|
|
15624
|
+
}
|
|
15625
|
+
logger$o.info(`${msiName$6}: Using the endpoint and the secret coming form the environment variables: MSI_ENDPOINT=${process.env.MSI_ENDPOINT} and MSI_SECRET=[REDACTED].`);
|
|
15626
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$5(scopes, clientId)), {
|
|
15627
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
15628
|
+
allowInsecureConnection: true
|
|
15629
|
+
}));
|
|
15630
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
15631
|
+
return tokenResponse && tokenResponse.accessToken || null;
|
|
15632
|
+
}
|
|
15633
|
+
};
|
|
15634
|
+
var msiName$5 = "ManagedIdentityCredential - AppServiceMSI 2019";
|
|
15635
|
+
var logger$n = credentialLogger(msiName$5);
|
|
15636
|
+
function prepareRequestOptions$4(scopes, clientId, resourceId) {
|
|
15637
|
+
const resource = mapScopesToResource(scopes);
|
|
15638
|
+
if (!resource) {
|
|
15639
|
+
throw new Error(`${msiName$5}: Multiple scopes are not supported.`);
|
|
15640
|
+
}
|
|
15641
|
+
const queryParameters = {
|
|
15642
|
+
resource,
|
|
15643
|
+
"api-version": "2019-08-01"
|
|
15644
|
+
};
|
|
15645
|
+
if (clientId) {
|
|
15646
|
+
queryParameters.client_id = clientId;
|
|
15647
|
+
}
|
|
15648
|
+
if (resourceId) {
|
|
15649
|
+
queryParameters.mi_res_id = resourceId;
|
|
15650
|
+
}
|
|
15651
|
+
const query = new URLSearchParams(queryParameters);
|
|
15652
|
+
if (!process.env.IDENTITY_ENDPOINT) {
|
|
15653
|
+
throw new Error(`${msiName$5}: Missing environment variable: IDENTITY_ENDPOINT`);
|
|
15654
|
+
}
|
|
15655
|
+
if (!process.env.IDENTITY_HEADER) {
|
|
15656
|
+
throw new Error(`${msiName$5}: Missing environment variable: IDENTITY_HEADER`);
|
|
15657
|
+
}
|
|
15658
|
+
return {
|
|
15659
|
+
url: `${process.env.IDENTITY_ENDPOINT}?${query.toString()}`,
|
|
15660
|
+
method: "GET",
|
|
15661
|
+
headers: coreRestPipeline.createHttpHeaders({
|
|
15662
|
+
Accept: "application/json",
|
|
15663
|
+
"X-IDENTITY-HEADER": process.env.IDENTITY_HEADER
|
|
15664
|
+
})
|
|
15665
|
+
};
|
|
15666
|
+
}
|
|
15667
|
+
__name(prepareRequestOptions$4, "prepareRequestOptions$4");
|
|
15668
|
+
var appServiceMsi2019 = {
|
|
15669
|
+
name: "appServiceMsi2019",
|
|
15670
|
+
async isAvailable({ scopes }) {
|
|
15671
|
+
const resource = mapScopesToResource(scopes);
|
|
15672
|
+
if (!resource) {
|
|
15673
|
+
logger$n.info(`${msiName$5}: Unavailable. Multiple scopes are not supported.`);
|
|
15674
|
+
return false;
|
|
15675
|
+
}
|
|
15676
|
+
const env = process.env;
|
|
15677
|
+
const result = Boolean(env.IDENTITY_ENDPOINT && env.IDENTITY_HEADER);
|
|
15678
|
+
if (!result) {
|
|
15679
|
+
logger$n.info(`${msiName$5}: Unavailable. The environment variables needed are: IDENTITY_ENDPOINT and IDENTITY_HEADER.`);
|
|
15680
|
+
}
|
|
15681
|
+
return result;
|
|
15682
|
+
},
|
|
15683
|
+
async getToken(configuration, getTokenOptions = {}) {
|
|
15684
|
+
const { identityClient, scopes, clientId, resourceId } = configuration;
|
|
15685
|
+
logger$n.info(`${msiName$5}: Using the endpoint and the secret coming form the environment variables: IDENTITY_ENDPOINT=${process.env.IDENTITY_ENDPOINT} and IDENTITY_HEADER=[REDACTED].`);
|
|
15686
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$4(scopes, clientId, resourceId)), {
|
|
15687
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
15688
|
+
allowInsecureConnection: true
|
|
15689
|
+
}));
|
|
15690
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
15691
|
+
return tokenResponse && tokenResponse.accessToken || null;
|
|
15692
|
+
}
|
|
15693
|
+
};
|
|
15694
|
+
var msiName$4 = "ManagedIdentityCredential - Azure Arc MSI";
|
|
15695
|
+
var logger$m = credentialLogger(msiName$4);
|
|
15696
|
+
function prepareRequestOptions$3(scopes, clientId, resourceId) {
|
|
15697
|
+
const resource = mapScopesToResource(scopes);
|
|
15698
|
+
if (!resource) {
|
|
15699
|
+
throw new Error(`${msiName$4}: Multiple scopes are not supported.`);
|
|
15700
|
+
}
|
|
15701
|
+
const queryParameters = {
|
|
15702
|
+
resource,
|
|
15703
|
+
"api-version": azureArcAPIVersion
|
|
15704
|
+
};
|
|
15705
|
+
if (clientId) {
|
|
15706
|
+
queryParameters.client_id = clientId;
|
|
15707
|
+
}
|
|
15708
|
+
if (resourceId) {
|
|
15709
|
+
queryParameters.msi_res_id = resourceId;
|
|
15710
|
+
}
|
|
15711
|
+
if (!process.env.IDENTITY_ENDPOINT) {
|
|
15712
|
+
throw new Error(`${msiName$4}: Missing environment variable: IDENTITY_ENDPOINT`);
|
|
15713
|
+
}
|
|
15714
|
+
const query = new URLSearchParams(queryParameters);
|
|
15715
|
+
return coreRestPipeline.createPipelineRequest({
|
|
15716
|
+
// Should be similar to: http://localhost:40342/metadata/identity/oauth2/token
|
|
15717
|
+
url: `${process.env.IDENTITY_ENDPOINT}?${query.toString()}`,
|
|
15718
|
+
method: "GET",
|
|
15719
|
+
headers: coreRestPipeline.createHttpHeaders({
|
|
15720
|
+
Accept: "application/json",
|
|
15721
|
+
Metadata: "true"
|
|
15722
|
+
})
|
|
15723
|
+
});
|
|
15724
|
+
}
|
|
15725
|
+
__name(prepareRequestOptions$3, "prepareRequestOptions$3");
|
|
15726
|
+
async function filePathRequest(identityClient, requestPrepareOptions) {
|
|
15727
|
+
const response = await identityClient.sendRequest(coreRestPipeline.createPipelineRequest(requestPrepareOptions));
|
|
15728
|
+
if (response.status !== 401) {
|
|
15729
|
+
let message = "";
|
|
15730
|
+
if (response.bodyAsText) {
|
|
15731
|
+
message = ` Response: ${response.bodyAsText}`;
|
|
15732
|
+
}
|
|
15733
|
+
throw new AuthenticationError(response.status, `${msiName$4}: To authenticate with Azure Arc MSI, status code 401 is expected on the first request. ${message}`);
|
|
15734
|
+
}
|
|
15735
|
+
const authHeader = response.headers.get("www-authenticate") || "";
|
|
15736
|
+
try {
|
|
15737
|
+
return authHeader.split("=").slice(1)[0];
|
|
15738
|
+
} catch (e) {
|
|
15739
|
+
throw Error(`Invalid www-authenticate header format: ${authHeader}`);
|
|
15740
|
+
}
|
|
15741
|
+
}
|
|
15742
|
+
__name(filePathRequest, "filePathRequest");
|
|
15743
|
+
function platformToFilePath() {
|
|
15744
|
+
switch (process.platform) {
|
|
15745
|
+
case "win32":
|
|
15746
|
+
if (!process.env.PROGRAMDATA) {
|
|
15747
|
+
throw new Error(`${msiName$4}: PROGRAMDATA environment variable has no value.`);
|
|
15748
|
+
}
|
|
15749
|
+
return `${process.env.PROGRAMDATA}\\AzureConnectedMachineAgent\\Tokens`;
|
|
15750
|
+
case "linux":
|
|
15751
|
+
return "/var/opt/azcmagent/tokens";
|
|
15752
|
+
default:
|
|
15753
|
+
throw new Error(`${msiName$4}: Unsupported platform ${process.platform}.`);
|
|
15754
|
+
}
|
|
15755
|
+
}
|
|
15756
|
+
__name(platformToFilePath, "platformToFilePath");
|
|
15757
|
+
function validateKeyFile(filePath) {
|
|
15758
|
+
if (!filePath) {
|
|
15759
|
+
throw new Error(`${msiName$4}: Failed to find the token file.`);
|
|
15760
|
+
}
|
|
15761
|
+
if (!filePath.endsWith(".key")) {
|
|
15762
|
+
throw new Error(`${msiName$4}: unexpected file path from HIMDS service: ${filePath}.`);
|
|
15763
|
+
}
|
|
15764
|
+
const expectedPath = platformToFilePath();
|
|
15765
|
+
if (!filePath.startsWith(expectedPath)) {
|
|
15766
|
+
throw new Error(`${msiName$4}: unexpected file path from HIMDS service: ${filePath}.`);
|
|
15767
|
+
}
|
|
15768
|
+
const stats = fs$1.statSync(filePath);
|
|
15769
|
+
if (stats.size > 4096) {
|
|
15770
|
+
throw new Error(`${msiName$4}: The file at ${filePath} is larger than expected at ${stats.size} bytes.`);
|
|
15771
|
+
}
|
|
15772
|
+
}
|
|
15773
|
+
__name(validateKeyFile, "validateKeyFile");
|
|
15774
|
+
var arcMsi = {
|
|
15775
|
+
name: "arc",
|
|
15776
|
+
async isAvailable({ scopes }) {
|
|
15777
|
+
const resource = mapScopesToResource(scopes);
|
|
15778
|
+
if (!resource) {
|
|
15779
|
+
logger$m.info(`${msiName$4}: Unavailable. Multiple scopes are not supported.`);
|
|
15780
|
+
return false;
|
|
15781
|
+
}
|
|
15782
|
+
const result = Boolean(process.env.IMDS_ENDPOINT && process.env.IDENTITY_ENDPOINT);
|
|
15783
|
+
if (!result) {
|
|
15784
|
+
logger$m.info(`${msiName$4}: The environment variables needed are: IMDS_ENDPOINT and IDENTITY_ENDPOINT`);
|
|
15785
|
+
}
|
|
15786
|
+
return result;
|
|
15787
|
+
},
|
|
15788
|
+
async getToken(configuration, getTokenOptions = {}) {
|
|
15789
|
+
var _a2;
|
|
15790
|
+
const { identityClient, scopes, clientId, resourceId } = configuration;
|
|
15791
|
+
if (clientId) {
|
|
15792
|
+
logger$m.warning(`${msiName$4}: user-assigned identities not supported. The argument clientId might be ignored by the service.`);
|
|
15793
|
+
}
|
|
15794
|
+
if (resourceId) {
|
|
15795
|
+
logger$m.warning(`${msiName$4}: user defined managed Identity by resource Id is not supported. Argument resourceId will be ignored.`);
|
|
15796
|
+
}
|
|
15797
|
+
logger$m.info(`${msiName$4}: Authenticating.`);
|
|
15798
|
+
const requestOptions = Object.assign(Object.assign({ disableJsonStringifyOnBody: true, deserializationMapper: void 0, abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$3(scopes, clientId, resourceId)), { allowInsecureConnection: true });
|
|
15799
|
+
const filePath = await filePathRequest(identityClient, requestOptions);
|
|
15800
|
+
validateKeyFile(filePath);
|
|
15801
|
+
const key = await fs$1.promises.readFile(filePath, { encoding: "utf-8" });
|
|
15802
|
+
(_a2 = requestOptions.headers) === null || _a2 === void 0 ? void 0 : _a2.set("Authorization", `Basic ${key}`);
|
|
15803
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({}, requestOptions), {
|
|
15804
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
15805
|
+
allowInsecureConnection: true
|
|
15806
|
+
}));
|
|
15807
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
15808
|
+
return tokenResponse && tokenResponse.accessToken || null;
|
|
15809
|
+
}
|
|
15810
|
+
};
|
|
15811
|
+
var msiName$3 = "ManagedIdentityCredential - CloudShellMSI";
|
|
15812
|
+
var logger$l = credentialLogger(msiName$3);
|
|
15813
|
+
function prepareRequestOptions$2(scopes, clientId, resourceId) {
|
|
15814
|
+
const resource = mapScopesToResource(scopes);
|
|
15815
|
+
if (!resource) {
|
|
15816
|
+
throw new Error(`${msiName$3}: Multiple scopes are not supported.`);
|
|
15817
|
+
}
|
|
15818
|
+
const body = {
|
|
15819
|
+
resource
|
|
15820
|
+
};
|
|
15821
|
+
if (clientId) {
|
|
15822
|
+
body.client_id = clientId;
|
|
15823
|
+
}
|
|
15824
|
+
if (resourceId) {
|
|
15825
|
+
body.msi_res_id = resourceId;
|
|
15826
|
+
}
|
|
15827
|
+
if (!process.env.MSI_ENDPOINT) {
|
|
15828
|
+
throw new Error(`${msiName$3}: Missing environment variable: MSI_ENDPOINT`);
|
|
15829
|
+
}
|
|
15830
|
+
const params = new URLSearchParams(body);
|
|
15831
|
+
return {
|
|
15832
|
+
url: process.env.MSI_ENDPOINT,
|
|
15833
|
+
method: "POST",
|
|
15834
|
+
body: params.toString(),
|
|
15835
|
+
headers: coreRestPipeline.createHttpHeaders({
|
|
15836
|
+
Accept: "application/json",
|
|
15837
|
+
Metadata: "true",
|
|
15838
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
15839
|
+
})
|
|
15840
|
+
};
|
|
15841
|
+
}
|
|
15842
|
+
__name(prepareRequestOptions$2, "prepareRequestOptions$2");
|
|
15843
|
+
var cloudShellMsi = {
|
|
15844
|
+
name: "cloudShellMsi",
|
|
15845
|
+
async isAvailable({ scopes }) {
|
|
15846
|
+
const resource = mapScopesToResource(scopes);
|
|
15847
|
+
if (!resource) {
|
|
15848
|
+
logger$l.info(`${msiName$3}: Unavailable. Multiple scopes are not supported.`);
|
|
15849
|
+
return false;
|
|
15850
|
+
}
|
|
15851
|
+
const result = Boolean(process.env.MSI_ENDPOINT);
|
|
15852
|
+
if (!result) {
|
|
15853
|
+
logger$l.info(`${msiName$3}: Unavailable. The environment variable MSI_ENDPOINT is needed.`);
|
|
15854
|
+
}
|
|
15855
|
+
return result;
|
|
15856
|
+
},
|
|
15857
|
+
async getToken(configuration, getTokenOptions = {}) {
|
|
15858
|
+
const { identityClient, scopes, clientId, resourceId } = configuration;
|
|
15859
|
+
if (clientId) {
|
|
15860
|
+
logger$l.warning(`${msiName$3}: user-assigned identities not supported. The argument clientId might be ignored by the service.`);
|
|
15861
|
+
}
|
|
15862
|
+
if (resourceId) {
|
|
15863
|
+
logger$l.warning(`${msiName$3}: user defined managed Identity by resource Id not supported. The argument resourceId might be ignored by the service.`);
|
|
15864
|
+
}
|
|
15865
|
+
logger$l.info(`${msiName$3}: Using the endpoint coming form the environment variable MSI_ENDPOINT = ${process.env.MSI_ENDPOINT}.`);
|
|
15866
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$2(scopes, clientId, resourceId)), {
|
|
15867
|
+
// Generally, MSI endpoints use the HTTP protocol, without transport layer security (TLS).
|
|
15868
|
+
allowInsecureConnection: true
|
|
15869
|
+
}));
|
|
15870
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
15871
|
+
return tokenResponse && tokenResponse.accessToken || null;
|
|
15872
|
+
}
|
|
15873
|
+
};
|
|
15874
|
+
var msiName$2 = "ManagedIdentityCredential - Fabric MSI";
|
|
15875
|
+
var logger$k = credentialLogger(msiName$2);
|
|
15876
|
+
function prepareRequestOptions$1(scopes, clientId, resourceId) {
|
|
15877
|
+
const resource = mapScopesToResource(scopes);
|
|
15878
|
+
if (!resource) {
|
|
15879
|
+
throw new Error(`${msiName$2}: Multiple scopes are not supported.`);
|
|
15880
|
+
}
|
|
15881
|
+
const queryParameters = {
|
|
15882
|
+
resource,
|
|
15883
|
+
"api-version": azureFabricVersion
|
|
15884
|
+
};
|
|
15885
|
+
if (clientId) {
|
|
15886
|
+
queryParameters.client_id = clientId;
|
|
15887
|
+
}
|
|
15888
|
+
if (resourceId) {
|
|
15889
|
+
queryParameters.msi_res_id = resourceId;
|
|
15890
|
+
}
|
|
15891
|
+
const query = new URLSearchParams(queryParameters);
|
|
15892
|
+
if (!process.env.IDENTITY_ENDPOINT) {
|
|
15893
|
+
throw new Error("Missing environment variable: IDENTITY_ENDPOINT");
|
|
15894
|
+
}
|
|
15895
|
+
if (!process.env.IDENTITY_HEADER) {
|
|
15896
|
+
throw new Error("Missing environment variable: IDENTITY_HEADER");
|
|
15897
|
+
}
|
|
15898
|
+
return {
|
|
15899
|
+
url: `${process.env.IDENTITY_ENDPOINT}?${query.toString()}`,
|
|
15900
|
+
method: "GET",
|
|
15901
|
+
headers: coreRestPipeline.createHttpHeaders({
|
|
15902
|
+
Accept: "application/json",
|
|
15903
|
+
secret: process.env.IDENTITY_HEADER
|
|
15904
|
+
})
|
|
15905
|
+
};
|
|
15906
|
+
}
|
|
15907
|
+
__name(prepareRequestOptions$1, "prepareRequestOptions$1");
|
|
15908
|
+
var fabricMsi = {
|
|
15909
|
+
name: "fabricMsi",
|
|
15910
|
+
async isAvailable({ scopes }) {
|
|
15911
|
+
const resource = mapScopesToResource(scopes);
|
|
15912
|
+
if (!resource) {
|
|
15913
|
+
logger$k.info(`${msiName$2}: Unavailable. Multiple scopes are not supported.`);
|
|
15914
|
+
return false;
|
|
15915
|
+
}
|
|
15916
|
+
const env = process.env;
|
|
15917
|
+
const result = Boolean(env.IDENTITY_ENDPOINT && env.IDENTITY_HEADER && env.IDENTITY_SERVER_THUMBPRINT);
|
|
15918
|
+
if (!result) {
|
|
15919
|
+
logger$k.info(`${msiName$2}: Unavailable. The environment variables needed are: IDENTITY_ENDPOINT, IDENTITY_HEADER and IDENTITY_SERVER_THUMBPRINT`);
|
|
15920
|
+
}
|
|
15921
|
+
return result;
|
|
15922
|
+
},
|
|
15923
|
+
async getToken(configuration, getTokenOptions = {}) {
|
|
15924
|
+
const { scopes, identityClient, clientId, resourceId } = configuration;
|
|
15925
|
+
if (resourceId) {
|
|
15926
|
+
logger$k.warning(`${msiName$2}: user defined managed Identity by resource Id is not supported. Argument resourceId might be ignored by the service.`);
|
|
15927
|
+
}
|
|
15928
|
+
logger$k.info([
|
|
15929
|
+
`${msiName$2}:`,
|
|
15930
|
+
"Using the endpoint and the secret coming from the environment variables:",
|
|
15931
|
+
`IDENTITY_ENDPOINT=${process.env.IDENTITY_ENDPOINT},`,
|
|
15932
|
+
"IDENTITY_HEADER=[REDACTED] and",
|
|
15933
|
+
"IDENTITY_SERVER_THUMBPRINT=[REDACTED]."
|
|
15934
|
+
].join(" "));
|
|
15935
|
+
const request = coreRestPipeline.createPipelineRequest(Object.assign({ abortSignal: getTokenOptions.abortSignal }, prepareRequestOptions$1(scopes, clientId, resourceId)));
|
|
15936
|
+
request.agent = new https.Agent({
|
|
15937
|
+
// This is necessary because Service Fabric provides a self-signed certificate.
|
|
15938
|
+
// The alternative path is to verify the certificate using the IDENTITY_SERVER_THUMBPRINT env variable.
|
|
15939
|
+
rejectUnauthorized: false
|
|
15940
|
+
});
|
|
15941
|
+
const tokenResponse = await identityClient.sendTokenRequest(request);
|
|
15942
|
+
return tokenResponse && tokenResponse.accessToken || null;
|
|
15943
|
+
}
|
|
15944
|
+
};
|
|
15423
15945
|
var logger$j = credentialLogger("IdentityUtils");
|
|
15424
15946
|
var LatestAuthenticationRecordVersion = "1.0";
|
|
15425
15947
|
function ensureValidMsalToken(scopes, msalToken, getTokenOptions) {
|
|
@@ -15497,6 +16019,10 @@ ${errorDetail}`);
|
|
|
15497
16019
|
}
|
|
15498
16020
|
}
|
|
15499
16021
|
__name(getMSALLogLevel, "getMSALLogLevel");
|
|
16022
|
+
function randomUUID() {
|
|
16023
|
+
return coreUtil.randomUUID();
|
|
16024
|
+
}
|
|
16025
|
+
__name(randomUUID, "randomUUID");
|
|
15500
16026
|
function handleMsalError(scopes, error, getTokenOptions) {
|
|
15501
16027
|
if (error.name === "AuthError" || error.name === "ClientAuthError" || error.name === "BrowserAuthError") {
|
|
15502
16028
|
const msalError = error;
|
|
@@ -15666,26 +16192,6 @@ ${errorDetail}`);
|
|
|
15666
16192
|
throw new AuthenticationError(404, `${msiName$1}: Failed to retrieve IMDS token after ${configuration.retryConfig.maxRetries} retries.`);
|
|
15667
16193
|
}
|
|
15668
16194
|
};
|
|
15669
|
-
var DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1e3 * 64;
|
|
15670
|
-
function imdsRetryPolicy(msiRetryConfig) {
|
|
15671
|
-
return coreRestPipeline.retryPolicy([
|
|
15672
|
-
{
|
|
15673
|
-
name: "imdsRetryPolicy",
|
|
15674
|
-
retry: /* @__PURE__ */ __name(({ retryCount, response }) => {
|
|
15675
|
-
if ((response === null || response === void 0 ? void 0 : response.status) !== 404) {
|
|
15676
|
-
return { skipStrategy: true };
|
|
15677
|
-
}
|
|
15678
|
-
const exponentialDelay = msiRetryConfig.startDelayInMs * Math.pow(2, retryCount);
|
|
15679
|
-
const clampedExponentialDelay = Math.min(DEFAULT_CLIENT_MAX_RETRY_INTERVAL, exponentialDelay);
|
|
15680
|
-
const retryAfterInMs = clampedExponentialDelay / 2 + coreUtil.getRandomIntegerInclusive(0, clampedExponentialDelay / 2);
|
|
15681
|
-
return { retryAfterInMs };
|
|
15682
|
-
}, "retry")
|
|
15683
|
-
}
|
|
15684
|
-
], {
|
|
15685
|
-
maxRetries: msiRetryConfig.maxRetries
|
|
15686
|
-
});
|
|
15687
|
-
}
|
|
15688
|
-
__name(imdsRetryPolicy, "imdsRetryPolicy");
|
|
15689
16195
|
var RegionalAuthority;
|
|
15690
16196
|
(function(RegionalAuthority2) {
|
|
15691
16197
|
RegionalAuthority2["AutoDiscoverRegion"] = "AutoDiscoverRegion";
|
|
@@ -15754,9 +16260,6 @@ ${errorDetail}`);
|
|
|
15754
16260
|
return azureRegion;
|
|
15755
16261
|
}
|
|
15756
16262
|
__name(calculateRegionalAuthority, "calculateRegionalAuthority");
|
|
15757
|
-
var interactiveBrowserMockable = {
|
|
15758
|
-
open
|
|
15759
|
-
};
|
|
15760
16263
|
var msalLogger = credentialLogger("MsalClient");
|
|
15761
16264
|
function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
|
|
15762
16265
|
var _a2, _b2, _c, _d;
|
|
@@ -15773,7 +16276,7 @@ ${errorDetail}`);
|
|
|
15773
16276
|
networkClient: httpClient,
|
|
15774
16277
|
loggerOptions: {
|
|
15775
16278
|
loggerCallback: defaultLoggerCallback((_c = msalClientOptions.logger) !== null && _c !== void 0 ? _c : msalLogger),
|
|
15776
|
-
logLevel: getMSALLogLevel(logger$
|
|
16279
|
+
logLevel: getMSALLogLevel(logger$r.getLogLevel()),
|
|
15777
16280
|
piiLoggingEnabled: (_d = msalClientOptions.loggingOptions) === null || _d === void 0 ? void 0 : _d.enableUnsafeSupportLogging
|
|
15778
16281
|
}
|
|
15779
16282
|
}
|
|
@@ -15857,13 +16360,6 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
15857
16360
|
return app.acquireTokenSilent(silentRequest);
|
|
15858
16361
|
}
|
|
15859
16362
|
__name(getTokenSilent, "getTokenSilent");
|
|
15860
|
-
function calculateRequestAuthority(options) {
|
|
15861
|
-
if (options === null || options === void 0 ? void 0 : options.tenantId) {
|
|
15862
|
-
return getAuthority(options.tenantId, createMsalClientOptions.authorityHost);
|
|
15863
|
-
}
|
|
15864
|
-
return state.msalConfig.auth.authority;
|
|
15865
|
-
}
|
|
15866
|
-
__name(calculateRequestAuthority, "calculateRequestAuthority");
|
|
15867
16363
|
async function withSilentAuthentication(msalApp, scopes, options, onAuthenticationRequired) {
|
|
15868
16364
|
var _a3;
|
|
15869
16365
|
let response = null;
|
|
@@ -15904,7 +16400,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
15904
16400
|
try {
|
|
15905
16401
|
const response = await msalApp.acquireTokenByClientCredential({
|
|
15906
16402
|
scopes,
|
|
15907
|
-
authority:
|
|
16403
|
+
authority: state.msalConfig.auth.authority,
|
|
15908
16404
|
azureRegion: calculateRegionalAuthority(),
|
|
15909
16405
|
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
15910
16406
|
});
|
|
@@ -15926,7 +16422,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
15926
16422
|
try {
|
|
15927
16423
|
const response = await msalApp.acquireTokenByClientCredential({
|
|
15928
16424
|
scopes,
|
|
15929
|
-
authority:
|
|
16425
|
+
authority: state.msalConfig.auth.authority,
|
|
15930
16426
|
azureRegion: calculateRegionalAuthority(),
|
|
15931
16427
|
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
15932
16428
|
clientAssertion
|
|
@@ -15949,7 +16445,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
15949
16445
|
try {
|
|
15950
16446
|
const response = await msalApp.acquireTokenByClientCredential({
|
|
15951
16447
|
scopes,
|
|
15952
|
-
authority:
|
|
16448
|
+
authority: state.msalConfig.auth.authority,
|
|
15953
16449
|
azureRegion: calculateRegionalAuthority(),
|
|
15954
16450
|
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
15955
16451
|
});
|
|
@@ -15973,7 +16469,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
15973
16469
|
scopes,
|
|
15974
16470
|
cancel: (_b2 = (_a3 = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a3 === void 0 ? void 0 : _a3.aborted) !== null && _b2 !== void 0 ? _b2 : false,
|
|
15975
16471
|
deviceCodeCallback,
|
|
15976
|
-
authority:
|
|
16472
|
+
authority: state.msalConfig.auth.authority,
|
|
15977
16473
|
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
15978
16474
|
};
|
|
15979
16475
|
const deviceCodeRequest = msalApp.acquireTokenByDeviceCode(requestOptions);
|
|
@@ -15994,7 +16490,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
15994
16490
|
scopes,
|
|
15995
16491
|
username,
|
|
15996
16492
|
password,
|
|
15997
|
-
authority:
|
|
16493
|
+
authority: state.msalConfig.auth.authority,
|
|
15998
16494
|
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
15999
16495
|
};
|
|
16000
16496
|
return msalApp.acquireTokenByUsernamePassword(requestOptions);
|
|
@@ -16022,133 +16518,38 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
16022
16518
|
scopes,
|
|
16023
16519
|
redirectUri,
|
|
16024
16520
|
code: authorizationCode,
|
|
16025
|
-
authority:
|
|
16521
|
+
authority: state.msalConfig.auth.authority,
|
|
16026
16522
|
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
16027
16523
|
});
|
|
16028
16524
|
});
|
|
16029
16525
|
}
|
|
16030
16526
|
__name(getTokenByAuthorizationCode, "getTokenByAuthorizationCode");
|
|
16031
|
-
|
|
16032
|
-
|
|
16033
|
-
|
|
16034
|
-
|
|
16035
|
-
|
|
16036
|
-
|
|
16037
|
-
|
|
16038
|
-
|
|
16039
|
-
|
|
16040
|
-
|
|
16041
|
-
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16048
|
-
|
|
16049
|
-
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
} catch (err) {
|
|
16058
|
-
throw handleMsalError(scopes, err, options);
|
|
16059
|
-
}
|
|
16060
|
-
}
|
|
16061
|
-
__name(getTokenOnBehalfOf, "getTokenOnBehalfOf");
|
|
16062
|
-
async function getTokenByInteractiveRequest(scopes, options = {}) {
|
|
16063
|
-
msalLogger.getToken.info(`Attempting to acquire token interactively`);
|
|
16064
|
-
const app = await getPublicApp(options);
|
|
16065
|
-
async function getBrokeredToken(useDefaultBrokerAccount) {
|
|
16066
|
-
var _a3;
|
|
16067
|
-
msalLogger.verbose("Authentication will resume through the broker");
|
|
16068
|
-
const interactiveRequest = createBaseInteractiveRequest();
|
|
16069
|
-
if (state.pluginConfiguration.broker.parentWindowHandle) {
|
|
16070
|
-
interactiveRequest.windowHandle = Buffer.from(state.pluginConfiguration.broker.parentWindowHandle);
|
|
16071
|
-
} else {
|
|
16072
|
-
msalLogger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
16073
|
-
}
|
|
16074
|
-
if (state.pluginConfiguration.broker.enableMsaPassthrough) {
|
|
16075
|
-
((_a3 = interactiveRequest.tokenQueryParameters) !== null && _a3 !== void 0 ? _a3 : interactiveRequest.tokenQueryParameters = {})["msal_request_type"] = "consumer_passthrough";
|
|
16076
|
-
}
|
|
16077
|
-
if (useDefaultBrokerAccount) {
|
|
16078
|
-
interactiveRequest.prompt = "none";
|
|
16079
|
-
msalLogger.verbose("Attempting broker authentication using the default broker account");
|
|
16080
|
-
} else {
|
|
16081
|
-
msalLogger.verbose("Attempting broker authentication without the default broker account");
|
|
16082
|
-
}
|
|
16083
|
-
try {
|
|
16084
|
-
return await app.acquireTokenInteractive(interactiveRequest);
|
|
16085
|
-
} catch (e) {
|
|
16086
|
-
msalLogger.verbose(`Failed to authenticate through the broker: ${e.message}`);
|
|
16087
|
-
if (useDefaultBrokerAccount) {
|
|
16088
|
-
return getBrokeredToken(
|
|
16089
|
-
/* useDefaultBrokerAccount: */
|
|
16090
|
-
false
|
|
16091
|
-
);
|
|
16092
|
-
} else {
|
|
16093
|
-
throw e;
|
|
16094
|
-
}
|
|
16095
|
-
}
|
|
16096
|
-
}
|
|
16097
|
-
__name(getBrokeredToken, "getBrokeredToken");
|
|
16098
|
-
function createBaseInteractiveRequest() {
|
|
16099
|
-
var _a3, _b2;
|
|
16100
|
-
return {
|
|
16101
|
-
openBrowser: /* @__PURE__ */ __name(async (url) => {
|
|
16102
|
-
this.logger.verbose(`Opening browser to ${url}`);
|
|
16103
|
-
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
|
16104
|
-
}, "openBrowser"),
|
|
16105
|
-
scopes,
|
|
16106
|
-
authority: calculateRequestAuthority(options),
|
|
16107
|
-
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
16108
|
-
loginHint: options === null || options === void 0 ? void 0 : options.loginHint,
|
|
16109
|
-
errorTemplate: (_a3 = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _a3 === void 0 ? void 0 : _a3.errorMessage,
|
|
16110
|
-
successTemplate: (_b2 = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _b2 === void 0 ? void 0 : _b2.successMessage
|
|
16111
|
-
};
|
|
16112
|
-
}
|
|
16113
|
-
__name(createBaseInteractiveRequest, "createBaseInteractiveRequest");
|
|
16114
|
-
return withSilentAuthentication(app, scopes, options, async () => {
|
|
16115
|
-
var _a3;
|
|
16116
|
-
const interactiveRequest = createBaseInteractiveRequest();
|
|
16117
|
-
if (state.pluginConfiguration.broker.isEnabled) {
|
|
16118
|
-
return getBrokeredToken((_a3 = state.pluginConfiguration.broker.useDefaultBrokerAccount) !== null && _a3 !== void 0 ? _a3 : false);
|
|
16119
|
-
}
|
|
16120
|
-
return app.acquireTokenInteractive(interactiveRequest);
|
|
16121
|
-
});
|
|
16122
|
-
}
|
|
16123
|
-
__name(getTokenByInteractiveRequest, "getTokenByInteractiveRequest");
|
|
16124
|
-
return {
|
|
16125
|
-
getActiveAccount,
|
|
16126
|
-
getTokenByClientSecret,
|
|
16127
|
-
getTokenByClientAssertion,
|
|
16128
|
-
getTokenByClientCertificate,
|
|
16129
|
-
getTokenByDeviceCode,
|
|
16130
|
-
getTokenByUsernamePassword,
|
|
16131
|
-
getTokenByAuthorizationCode,
|
|
16132
|
-
getTokenOnBehalfOf,
|
|
16133
|
-
getTokenByInteractiveRequest
|
|
16134
|
-
};
|
|
16135
|
-
}
|
|
16136
|
-
__name(createMsalClient, "createMsalClient");
|
|
16137
|
-
var logger$h = credentialLogger("ClientAssertionCredential");
|
|
16138
|
-
var _ClientAssertionCredential = class _ClientAssertionCredential {
|
|
16139
|
-
/**
|
|
16140
|
-
* Creates an instance of the ClientAssertionCredential with the details
|
|
16141
|
-
* needed to authenticate against Microsoft Entra ID with a client
|
|
16142
|
-
* assertion provided by the developer through the `getAssertion` function parameter.
|
|
16143
|
-
*
|
|
16144
|
-
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
16145
|
-
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
16146
|
-
* @param getAssertion - A function that retrieves the assertion for the credential to use.
|
|
16147
|
-
* @param options - Options for configuring the client which makes the authentication request.
|
|
16148
|
-
*/
|
|
16149
|
-
constructor(tenantId, clientId, getAssertion, options = {}) {
|
|
16150
|
-
if (!tenantId || !clientId || !getAssertion) {
|
|
16151
|
-
throw new Error("ClientAssertionCredential: tenantId, clientId, and clientAssertion are required parameters.");
|
|
16527
|
+
return {
|
|
16528
|
+
getActiveAccount,
|
|
16529
|
+
getTokenByClientSecret,
|
|
16530
|
+
getTokenByClientAssertion,
|
|
16531
|
+
getTokenByClientCertificate,
|
|
16532
|
+
getTokenByDeviceCode,
|
|
16533
|
+
getTokenByUsernamePassword,
|
|
16534
|
+
getTokenByAuthorizationCode
|
|
16535
|
+
};
|
|
16536
|
+
}
|
|
16537
|
+
__name(createMsalClient, "createMsalClient");
|
|
16538
|
+
var logger$h = credentialLogger("ClientAssertionCredential");
|
|
16539
|
+
var _ClientAssertionCredential = class _ClientAssertionCredential {
|
|
16540
|
+
/**
|
|
16541
|
+
* Creates an instance of the ClientAssertionCredential with the details
|
|
16542
|
+
* needed to authenticate against Microsoft Entra ID with a client
|
|
16543
|
+
* assertion provided by the developer through the `getAssertion` function parameter.
|
|
16544
|
+
*
|
|
16545
|
+
* @param tenantId - The Microsoft Entra tenant (directory) ID.
|
|
16546
|
+
* @param clientId - The client (application) ID of an App Registration in the tenant.
|
|
16547
|
+
* @param getAssertion - A function that retrieves the assertion for the credential to use.
|
|
16548
|
+
* @param options - Options for configuring the client which makes the authentication request.
|
|
16549
|
+
*/
|
|
16550
|
+
constructor(tenantId, clientId, getAssertion, options = {}) {
|
|
16551
|
+
if (!tenantId || !clientId || !getAssertion) {
|
|
16552
|
+
throw new Error("ClientAssertionCredential: tenantId, clientId, and clientAssertion are required parameters.");
|
|
16152
16553
|
}
|
|
16153
16554
|
this.tenantId = tenantId;
|
|
16154
16555
|
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
@@ -16167,8 +16568,9 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
16167
16568
|
async getToken(scopes, options = {}) {
|
|
16168
16569
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
|
|
16169
16570
|
newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$h);
|
|
16571
|
+
const clientAssertion = await this.getAssertion();
|
|
16170
16572
|
const arrayScopes = Array.isArray(scopes) ? scopes : [scopes];
|
|
16171
|
-
return this.msalClient.getTokenByClientAssertion(arrayScopes,
|
|
16573
|
+
return this.msalClient.getTokenByClientAssertion(arrayScopes, clientAssertion, newOptions);
|
|
16172
16574
|
});
|
|
16173
16575
|
}
|
|
16174
16576
|
};
|
|
@@ -16249,68 +16651,124 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
16249
16651
|
var WorkloadIdentityCredential = _WorkloadIdentityCredential;
|
|
16250
16652
|
var msiName = "ManagedIdentityCredential - Token Exchange";
|
|
16251
16653
|
var logger$f = credentialLogger(msiName);
|
|
16252
|
-
|
|
16253
|
-
|
|
16254
|
-
|
|
16255
|
-
|
|
16256
|
-
|
|
16257
|
-
|
|
16258
|
-
|
|
16654
|
+
function tokenExchangeMsi() {
|
|
16655
|
+
return {
|
|
16656
|
+
name: "tokenExchangeMsi",
|
|
16657
|
+
async isAvailable({ clientId }) {
|
|
16658
|
+
const env = process.env;
|
|
16659
|
+
const result = Boolean((clientId || env.AZURE_CLIENT_ID) && env.AZURE_TENANT_ID && process.env.AZURE_FEDERATED_TOKEN_FILE);
|
|
16660
|
+
if (!result) {
|
|
16661
|
+
logger$f.info(`${msiName}: Unavailable. The environment variables needed are: AZURE_CLIENT_ID (or the client ID sent through the parameters), AZURE_TENANT_ID and AZURE_FEDERATED_TOKEN_FILE`);
|
|
16662
|
+
}
|
|
16663
|
+
return result;
|
|
16664
|
+
},
|
|
16665
|
+
async getToken(configuration, getTokenOptions = {}) {
|
|
16666
|
+
const { scopes, clientId } = configuration;
|
|
16667
|
+
const identityClientTokenCredentialOptions = {};
|
|
16668
|
+
const workloadIdentityCredential = new WorkloadIdentityCredential(Object.assign(Object.assign({ clientId, tenantId: process.env.AZURE_TENANT_ID, tokenFilePath: process.env.AZURE_FEDERATED_TOKEN_FILE }, identityClientTokenCredentialOptions), { disableInstanceDiscovery: true }));
|
|
16669
|
+
const token = await workloadIdentityCredential.getToken(scopes, getTokenOptions);
|
|
16670
|
+
return token;
|
|
16259
16671
|
}
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
|
|
16266
|
-
|
|
16267
|
-
|
|
16268
|
-
|
|
16269
|
-
|
|
16270
|
-
var _MsalMsiProvider = class _MsalMsiProvider {
|
|
16271
|
-
constructor(clientIdOrOptions, options = {}) {
|
|
16672
|
+
};
|
|
16673
|
+
}
|
|
16674
|
+
__name(tokenExchangeMsi, "tokenExchangeMsi");
|
|
16675
|
+
var logger$e = credentialLogger("ManagedIdentityCredential");
|
|
16676
|
+
var _ManagedIdentityCredential = class _ManagedIdentityCredential {
|
|
16677
|
+
/**
|
|
16678
|
+
* @internal
|
|
16679
|
+
* @hidden
|
|
16680
|
+
*/
|
|
16681
|
+
constructor(clientIdOrOptions, options) {
|
|
16272
16682
|
var _a2, _b2;
|
|
16683
|
+
this.isEndpointUnavailable = null;
|
|
16684
|
+
this.isAppTokenProviderInitialized = false;
|
|
16273
16685
|
this.msiRetryConfig = {
|
|
16274
16686
|
maxRetries: 5,
|
|
16275
16687
|
startDelayInMs: 800,
|
|
16276
16688
|
intervalIncrement: 2
|
|
16277
16689
|
};
|
|
16278
|
-
let _options
|
|
16690
|
+
let _options;
|
|
16279
16691
|
if (typeof clientIdOrOptions === "string") {
|
|
16280
16692
|
this.clientId = clientIdOrOptions;
|
|
16281
16693
|
_options = options;
|
|
16282
16694
|
} else {
|
|
16283
16695
|
this.clientId = clientIdOrOptions === null || clientIdOrOptions === void 0 ? void 0 : clientIdOrOptions.clientId;
|
|
16284
|
-
_options = clientIdOrOptions
|
|
16696
|
+
_options = clientIdOrOptions;
|
|
16285
16697
|
}
|
|
16286
16698
|
this.resourceId = _options === null || _options === void 0 ? void 0 : _options.resourceId;
|
|
16287
16699
|
if (this.clientId && this.resourceId) {
|
|
16288
|
-
throw new Error(
|
|
16700
|
+
throw new Error(`${_ManagedIdentityCredential.name} - Client Id and Resource Id can't be provided at the same time.`);
|
|
16289
16701
|
}
|
|
16290
|
-
_options.allowInsecureConnection = true;
|
|
16291
16702
|
if (((_a2 = _options === null || _options === void 0 ? void 0 : _options.retryOptions) === null || _a2 === void 0 ? void 0 : _a2.maxRetries) !== void 0) {
|
|
16292
16703
|
this.msiRetryConfig.maxRetries = _options.retryOptions.maxRetries;
|
|
16293
16704
|
}
|
|
16294
|
-
this.identityClient = new IdentityClient(
|
|
16295
|
-
this.
|
|
16296
|
-
|
|
16297
|
-
|
|
16298
|
-
|
|
16705
|
+
this.identityClient = new IdentityClient(_options);
|
|
16706
|
+
this.isAvailableIdentityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { retryOptions: {
|
|
16707
|
+
maxRetries: 0
|
|
16708
|
+
} }));
|
|
16709
|
+
this.confidentialApp = new msalCommon.ConfidentialClientApplication({
|
|
16710
|
+
auth: {
|
|
16711
|
+
authority: "https://login.microsoftonline.com/managed_identity",
|
|
16712
|
+
clientId: (_b2 = this.clientId) !== null && _b2 !== void 0 ? _b2 : DeveloperSignOnClientId,
|
|
16713
|
+
clientSecret: "dummy-secret",
|
|
16714
|
+
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"]}]}',
|
|
16715
|
+
authorityMetadata: '{"token_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/common/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/{tenantid}/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/common/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/common/kerberos","tenant_region_scope":null,"cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}',
|
|
16716
|
+
clientCapabilities: []
|
|
16299
16717
|
},
|
|
16300
16718
|
system: {
|
|
16301
|
-
// todo: proxyUrl?
|
|
16302
|
-
disableInternalRetries: true,
|
|
16303
|
-
networkClient: this.identityClient,
|
|
16304
16719
|
loggerOptions: {
|
|
16305
|
-
logLevel: getMSALLogLevel(logger$
|
|
16306
|
-
piiLoggingEnabled: (_b2 = options.loggingOptions) === null || _b2 === void 0 ? void 0 : _b2.enableUnsafeSupportLogging,
|
|
16307
|
-
loggerCallback: defaultLoggerCallback(logger$e)
|
|
16720
|
+
logLevel: getMSALLogLevel(logger$r.getLogLevel())
|
|
16308
16721
|
}
|
|
16309
16722
|
}
|
|
16310
16723
|
});
|
|
16311
|
-
|
|
16312
|
-
|
|
16313
|
-
|
|
16724
|
+
}
|
|
16725
|
+
async cachedAvailableMSI(scopes, getTokenOptions) {
|
|
16726
|
+
if (this.cachedMSI) {
|
|
16727
|
+
return this.cachedMSI;
|
|
16728
|
+
}
|
|
16729
|
+
const MSIs = [
|
|
16730
|
+
arcMsi,
|
|
16731
|
+
fabricMsi,
|
|
16732
|
+
appServiceMsi2019,
|
|
16733
|
+
appServiceMsi2017,
|
|
16734
|
+
cloudShellMsi,
|
|
16735
|
+
tokenExchangeMsi(),
|
|
16736
|
+
imdsMsi
|
|
16737
|
+
];
|
|
16738
|
+
for (const msi of MSIs) {
|
|
16739
|
+
if (await msi.isAvailable({
|
|
16740
|
+
scopes,
|
|
16741
|
+
identityClient: this.isAvailableIdentityClient,
|
|
16742
|
+
clientId: this.clientId,
|
|
16743
|
+
resourceId: this.resourceId,
|
|
16744
|
+
getTokenOptions
|
|
16745
|
+
})) {
|
|
16746
|
+
this.cachedMSI = msi;
|
|
16747
|
+
return msi;
|
|
16748
|
+
}
|
|
16749
|
+
}
|
|
16750
|
+
throw new CredentialUnavailableError(`${_ManagedIdentityCredential.name} - No MSI credential available`);
|
|
16751
|
+
}
|
|
16752
|
+
async authenticateManagedIdentity(scopes, getTokenOptions) {
|
|
16753
|
+
const { span, updatedOptions } = tracingClient.startSpan(`${_ManagedIdentityCredential.name}.authenticateManagedIdentity`, getTokenOptions);
|
|
16754
|
+
try {
|
|
16755
|
+
const availableMSI = await this.cachedAvailableMSI(scopes, updatedOptions);
|
|
16756
|
+
return availableMSI.getToken({
|
|
16757
|
+
identityClient: this.identityClient,
|
|
16758
|
+
scopes,
|
|
16759
|
+
clientId: this.clientId,
|
|
16760
|
+
resourceId: this.resourceId,
|
|
16761
|
+
retryConfig: this.msiRetryConfig
|
|
16762
|
+
}, updatedOptions);
|
|
16763
|
+
} catch (err) {
|
|
16764
|
+
span.setStatus({
|
|
16765
|
+
status: "error",
|
|
16766
|
+
error: err
|
|
16767
|
+
});
|
|
16768
|
+
throw err;
|
|
16769
|
+
} finally {
|
|
16770
|
+
span.end();
|
|
16771
|
+
}
|
|
16314
16772
|
}
|
|
16315
16773
|
/**
|
|
16316
16774
|
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
@@ -16321,131 +16779,138 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
16321
16779
|
* @param options - The options used to configure any requests this
|
|
16322
16780
|
* TokenCredential implementation might make.
|
|
16323
16781
|
*/
|
|
16324
|
-
async getToken(scopes, options
|
|
16325
|
-
|
|
16326
|
-
const
|
|
16327
|
-
|
|
16328
|
-
|
|
16329
|
-
|
|
16330
|
-
|
|
16331
|
-
|
|
16332
|
-
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
|
|
16341
|
-
|
|
16342
|
-
logger$e.getToken.info("Using the token exchange managed identity.");
|
|
16343
|
-
const result = await tokenExchangeMsi.getToken({
|
|
16344
|
-
scopes,
|
|
16345
|
-
clientId: this.clientId,
|
|
16346
|
-
identityClient: this.identityClient,
|
|
16347
|
-
retryConfig: this.msiRetryConfig,
|
|
16348
|
-
resourceId: this.resourceId
|
|
16349
|
-
});
|
|
16350
|
-
if (result === null) {
|
|
16351
|
-
throw new CredentialUnavailableError("The managed identity endpoint was reached, yet no tokens were received.");
|
|
16352
|
-
}
|
|
16353
|
-
return result;
|
|
16354
|
-
} else if (isImdsMsi) {
|
|
16355
|
-
logger$e.getToken.info("Using the IMDS endpoint to probe for availability.");
|
|
16356
|
-
const isAvailable = await imdsMsi.isAvailable({
|
|
16357
|
-
scopes,
|
|
16358
|
-
clientId: this.clientId,
|
|
16359
|
-
getTokenOptions: options,
|
|
16360
|
-
identityClient: this.isAvailableIdentityClient,
|
|
16361
|
-
resourceId: this.resourceId
|
|
16362
|
-
});
|
|
16363
|
-
if (!isAvailable) {
|
|
16364
|
-
throw new CredentialUnavailableError(`ManagedIdentityCredential: The managed identity endpoint is not available.`);
|
|
16365
|
-
}
|
|
16782
|
+
async getToken(scopes, options) {
|
|
16783
|
+
let result = null;
|
|
16784
|
+
const { span, updatedOptions } = tracingClient.startSpan(`${_ManagedIdentityCredential.name}.getToken`, options);
|
|
16785
|
+
try {
|
|
16786
|
+
if (this.isEndpointUnavailable !== true) {
|
|
16787
|
+
const availableMSI = await this.cachedAvailableMSI(scopes, updatedOptions);
|
|
16788
|
+
if (availableMSI.name === "tokenExchangeMsi") {
|
|
16789
|
+
result = await this.authenticateManagedIdentity(scopes, updatedOptions);
|
|
16790
|
+
} else {
|
|
16791
|
+
const appTokenParameters = {
|
|
16792
|
+
correlationId: this.identityClient.getCorrelationId(),
|
|
16793
|
+
tenantId: (options === null || options === void 0 ? void 0 : options.tenantId) || "managed_identity",
|
|
16794
|
+
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
16795
|
+
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
16796
|
+
};
|
|
16797
|
+
this.initializeSetAppTokenProvider();
|
|
16798
|
+
const authenticationResult = await this.confidentialApp.acquireTokenByClientCredential(Object.assign({}, appTokenParameters));
|
|
16799
|
+
result = this.handleResult(scopes, authenticationResult || void 0);
|
|
16366
16800
|
}
|
|
16367
|
-
|
|
16368
|
-
|
|
16369
|
-
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
logger$e.getToken.info(formatSuccess(scopes));
|
|
16373
|
-
return {
|
|
16374
|
-
expiresOnTimestamp: token.expiresOn.getTime(),
|
|
16375
|
-
token: token.accessToken
|
|
16376
|
-
};
|
|
16377
|
-
} catch (err) {
|
|
16378
|
-
logger$e.getToken.error(formatError(scopes, err));
|
|
16379
|
-
if (err.name === "AuthenticationRequiredError") {
|
|
16380
|
-
throw err;
|
|
16801
|
+
if (result === null) {
|
|
16802
|
+
this.isEndpointUnavailable = true;
|
|
16803
|
+
const error = new CredentialUnavailableError("The managed identity endpoint was reached, yet no tokens were received.");
|
|
16804
|
+
logger$e.getToken.info(formatError(scopes, error));
|
|
16805
|
+
throw error;
|
|
16381
16806
|
}
|
|
16382
|
-
|
|
16383
|
-
|
|
16807
|
+
this.isEndpointUnavailable = false;
|
|
16808
|
+
} else {
|
|
16809
|
+
const error = new CredentialUnavailableError("The managed identity endpoint is not currently available");
|
|
16810
|
+
logger$e.getToken.info(formatError(scopes, error));
|
|
16811
|
+
throw error;
|
|
16812
|
+
}
|
|
16813
|
+
logger$e.getToken.info(formatSuccess(scopes));
|
|
16814
|
+
return result;
|
|
16815
|
+
} catch (err) {
|
|
16816
|
+
if (err.name === "AuthenticationRequiredError") {
|
|
16817
|
+
throw err;
|
|
16818
|
+
}
|
|
16819
|
+
span.setStatus({
|
|
16820
|
+
status: "error",
|
|
16821
|
+
error: err
|
|
16822
|
+
});
|
|
16823
|
+
if (err.code === "ENETUNREACH") {
|
|
16824
|
+
const error = new CredentialUnavailableError(`${_ManagedIdentityCredential.name}: Unavailable. Network unreachable. Message: ${err.message}`);
|
|
16825
|
+
logger$e.getToken.info(formatError(scopes, error));
|
|
16826
|
+
throw error;
|
|
16827
|
+
}
|
|
16828
|
+
if (err.code === "EHOSTUNREACH") {
|
|
16829
|
+
const error = new CredentialUnavailableError(`${_ManagedIdentityCredential.name}: Unavailable. No managed identity endpoint found. Message: ${err.message}`);
|
|
16830
|
+
logger$e.getToken.info(formatError(scopes, error));
|
|
16831
|
+
throw error;
|
|
16832
|
+
}
|
|
16833
|
+
if (err.statusCode === 400) {
|
|
16834
|
+
throw new CredentialUnavailableError(`${_ManagedIdentityCredential.name}: The managed identity endpoint is indicating there's no available identity. Message: ${err.message}`);
|
|
16835
|
+
}
|
|
16836
|
+
if (err.statusCode === 403 || err.code === 403) {
|
|
16837
|
+
if (err.message.includes("unreachable")) {
|
|
16838
|
+
const error = new CredentialUnavailableError(`${_ManagedIdentityCredential.name}: Unavailable. Network unreachable. Message: ${err.message}`);
|
|
16839
|
+
logger$e.getToken.info(formatError(scopes, error));
|
|
16840
|
+
throw error;
|
|
16384
16841
|
}
|
|
16385
|
-
throw new CredentialUnavailableError(`ManagedIdentityCredential: Authentication failed. Message ${err.message}`);
|
|
16386
16842
|
}
|
|
16387
|
-
|
|
16843
|
+
if (err.statusCode === void 0) {
|
|
16844
|
+
throw new CredentialUnavailableError(`${_ManagedIdentityCredential.name}: Authentication failed. Message ${err.message}`);
|
|
16845
|
+
}
|
|
16846
|
+
throw new AuthenticationError(err.statusCode, {
|
|
16847
|
+
error: `${_ManagedIdentityCredential.name} authentication failed.`,
|
|
16848
|
+
error_description: err.message
|
|
16849
|
+
});
|
|
16850
|
+
} finally {
|
|
16851
|
+
span.end();
|
|
16852
|
+
}
|
|
16853
|
+
}
|
|
16854
|
+
/**
|
|
16855
|
+
* Handles the MSAL authentication result.
|
|
16856
|
+
* If the result has an account, we update the local account reference.
|
|
16857
|
+
* If the token received is invalid, an error will be thrown depending on what's missing.
|
|
16858
|
+
*/
|
|
16859
|
+
handleResult(scopes, result, getTokenOptions) {
|
|
16860
|
+
this.ensureValidMsalToken(scopes, result, getTokenOptions);
|
|
16861
|
+
logger$e.getToken.info(formatSuccess(scopes));
|
|
16862
|
+
return {
|
|
16863
|
+
token: result.accessToken,
|
|
16864
|
+
expiresOnTimestamp: result.expiresOn.getTime()
|
|
16865
|
+
};
|
|
16388
16866
|
}
|
|
16389
16867
|
/**
|
|
16390
16868
|
* Ensures the validity of the MSAL token
|
|
16391
16869
|
*/
|
|
16392
16870
|
ensureValidMsalToken(scopes, msalToken, getTokenOptions) {
|
|
16393
|
-
const
|
|
16871
|
+
const error = /* @__PURE__ */ __name((message) => {
|
|
16394
16872
|
logger$e.getToken.info(message);
|
|
16395
16873
|
return new AuthenticationRequiredError({
|
|
16396
16874
|
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
16397
16875
|
getTokenOptions,
|
|
16398
16876
|
message
|
|
16399
16877
|
});
|
|
16400
|
-
}, "
|
|
16878
|
+
}, "error");
|
|
16401
16879
|
if (!msalToken) {
|
|
16402
|
-
throw
|
|
16880
|
+
throw error("No response");
|
|
16403
16881
|
}
|
|
16404
16882
|
if (!msalToken.expiresOn) {
|
|
16405
|
-
throw
|
|
16883
|
+
throw error(`Response had no "expiresOn" property.`);
|
|
16406
16884
|
}
|
|
16407
16885
|
if (!msalToken.accessToken) {
|
|
16408
|
-
throw
|
|
16409
|
-
}
|
|
16410
|
-
}
|
|
16411
|
-
|
|
16412
|
-
|
|
16413
|
-
|
|
16414
|
-
|
|
16415
|
-
|
|
16416
|
-
|
|
16417
|
-
|
|
16418
|
-
|
|
16419
|
-
|
|
16420
|
-
|
|
16421
|
-
|
|
16422
|
-
|
|
16423
|
-
|
|
16886
|
+
throw error(`Response had no "accessToken" property.`);
|
|
16887
|
+
}
|
|
16888
|
+
}
|
|
16889
|
+
initializeSetAppTokenProvider() {
|
|
16890
|
+
if (!this.isAppTokenProviderInitialized) {
|
|
16891
|
+
this.confidentialApp.SetAppTokenProvider(async (appTokenProviderParameters) => {
|
|
16892
|
+
logger$e.info(`SetAppTokenProvider invoked with parameters- ${JSON.stringify(appTokenProviderParameters)}`);
|
|
16893
|
+
const getTokenOptions = Object.assign({}, appTokenProviderParameters);
|
|
16894
|
+
logger$e.info(`authenticateManagedIdentity invoked with scopes- ${JSON.stringify(appTokenProviderParameters.scopes)} and getTokenOptions - ${JSON.stringify(getTokenOptions)}`);
|
|
16895
|
+
const resultToken = await this.authenticateManagedIdentity(appTokenProviderParameters.scopes, getTokenOptions);
|
|
16896
|
+
if (resultToken) {
|
|
16897
|
+
logger$e.info(`SetAppTokenProvider will save the token in cache`);
|
|
16898
|
+
const expiresInSeconds = (resultToken === null || resultToken === void 0 ? void 0 : resultToken.expiresOnTimestamp) ? Math.floor((resultToken.expiresOnTimestamp - Date.now()) / 1e3) : 0;
|
|
16899
|
+
return {
|
|
16900
|
+
accessToken: resultToken === null || resultToken === void 0 ? void 0 : resultToken.token,
|
|
16901
|
+
expiresInSeconds
|
|
16902
|
+
};
|
|
16903
|
+
} else {
|
|
16904
|
+
logger$e.info(`SetAppTokenProvider token has "no_access_token_returned" as the saved token`);
|
|
16905
|
+
return {
|
|
16906
|
+
accessToken: "no_access_token_returned",
|
|
16907
|
+
expiresInSeconds: 0
|
|
16908
|
+
};
|
|
16909
|
+
}
|
|
16910
|
+
});
|
|
16911
|
+
this.isAppTokenProviderInitialized = true;
|
|
16424
16912
|
}
|
|
16425
16913
|
}
|
|
16426
|
-
return false;
|
|
16427
|
-
}
|
|
16428
|
-
__name(isNetworkError, "isNetworkError");
|
|
16429
|
-
var _ManagedIdentityCredential = class _ManagedIdentityCredential {
|
|
16430
|
-
/**
|
|
16431
|
-
* @internal
|
|
16432
|
-
* @hidden
|
|
16433
|
-
*/
|
|
16434
|
-
constructor(clientIdOrOptions, options) {
|
|
16435
|
-
this.implProvider = new MsalMsiProvider(clientIdOrOptions, options);
|
|
16436
|
-
}
|
|
16437
|
-
/**
|
|
16438
|
-
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
16439
|
-
* If authentication fails, a {@link CredentialUnavailableError} will be thrown with the details of the failure.
|
|
16440
|
-
* If an unexpected error occurs, an {@link AuthenticationError} will be thrown with the details of the failure.
|
|
16441
|
-
*
|
|
16442
|
-
* @param scopes - The list of scopes for which the token will have access.
|
|
16443
|
-
* @param options - The options used to configure any requests this
|
|
16444
|
-
* TokenCredential implementation might make.
|
|
16445
|
-
*/
|
|
16446
|
-
async getToken(scopes, options) {
|
|
16447
|
-
return this.implProvider.getToken(scopes, options);
|
|
16448
|
-
}
|
|
16449
16914
|
};
|
|
16450
16915
|
__name(_ManagedIdentityCredential, "ManagedIdentityCredential");
|
|
16451
16916
|
var ManagedIdentityCredential = _ManagedIdentityCredential;
|
|
@@ -16850,7 +17315,11 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
16850
17315
|
]
|
|
16851
17316
|
]);
|
|
16852
17317
|
const result = results[1];
|
|
16853
|
-
|
|
17318
|
+
try {
|
|
17319
|
+
return JSON.parse(result);
|
|
17320
|
+
} catch (e) {
|
|
17321
|
+
throw new Error(`Unable to parse the output of PowerShell. Received output: ${result}`);
|
|
17322
|
+
}
|
|
16854
17323
|
}
|
|
16855
17324
|
throw new Error(`Unable to execute PowerShell. Ensure that it is installed in your system`);
|
|
16856
17325
|
}
|
|
@@ -16897,33 +17366,6 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
16897
17366
|
};
|
|
16898
17367
|
__name(_AzurePowerShellCredential, "AzurePowerShellCredential");
|
|
16899
17368
|
var AzurePowerShellCredential = _AzurePowerShellCredential;
|
|
16900
|
-
async function parseJsonToken(result) {
|
|
16901
|
-
const jsonRegex = /{[^{}]*}/g;
|
|
16902
|
-
const matches = result.match(jsonRegex);
|
|
16903
|
-
let resultWithoutToken = result;
|
|
16904
|
-
if (matches) {
|
|
16905
|
-
try {
|
|
16906
|
-
for (const item of matches) {
|
|
16907
|
-
try {
|
|
16908
|
-
const jsonContent = JSON.parse(item);
|
|
16909
|
-
if (jsonContent === null || jsonContent === void 0 ? void 0 : jsonContent.Token) {
|
|
16910
|
-
resultWithoutToken = resultWithoutToken.replace(item, "");
|
|
16911
|
-
if (resultWithoutToken) {
|
|
16912
|
-
logger$b.getToken.warning(resultWithoutToken);
|
|
16913
|
-
}
|
|
16914
|
-
return jsonContent;
|
|
16915
|
-
}
|
|
16916
|
-
} catch (e) {
|
|
16917
|
-
continue;
|
|
16918
|
-
}
|
|
16919
|
-
}
|
|
16920
|
-
} catch (e) {
|
|
16921
|
-
throw new Error(`Unable to parse the output of PowerShell. Received output: ${result}`);
|
|
16922
|
-
}
|
|
16923
|
-
}
|
|
16924
|
-
throw new Error(`No access token found in the output. Received output: ${result}`);
|
|
16925
|
-
}
|
|
16926
|
-
__name(parseJsonToken, "parseJsonToken");
|
|
16927
17369
|
var logger$a = credentialLogger("ChainedTokenCredential");
|
|
16928
17370
|
var _ChainedTokenCredential = class _ChainedTokenCredential {
|
|
16929
17371
|
/**
|
|
@@ -17361,6 +17803,362 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17361
17803
|
};
|
|
17362
17804
|
__name(_DefaultAzureCredential, "DefaultAzureCredential");
|
|
17363
17805
|
var DefaultAzureCredential = _DefaultAzureCredential;
|
|
17806
|
+
var _MsalNode = class _MsalNode {
|
|
17807
|
+
constructor(options) {
|
|
17808
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
17809
|
+
this.app = {};
|
|
17810
|
+
this.caeApp = {};
|
|
17811
|
+
this.requiresConfidential = false;
|
|
17812
|
+
this.logger = options.logger;
|
|
17813
|
+
this.msalConfig = this.defaultNodeMsalConfig(options);
|
|
17814
|
+
this.tenantId = resolveTenantId(options.logger, options.tenantId, options.clientId);
|
|
17815
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds((_a2 = options === null || options === void 0 ? void 0 : options.tokenCredentialOptions) === null || _a2 === void 0 ? void 0 : _a2.additionallyAllowedTenants);
|
|
17816
|
+
this.clientId = this.msalConfig.auth.clientId;
|
|
17817
|
+
if (options === null || options === void 0 ? void 0 : options.getAssertion) {
|
|
17818
|
+
this.getAssertion = options.getAssertion;
|
|
17819
|
+
}
|
|
17820
|
+
this.enableBroker = (_b2 = options === null || options === void 0 ? void 0 : options.brokerOptions) === null || _b2 === void 0 ? void 0 : _b2.enabled;
|
|
17821
|
+
this.enableMsaPassthrough = (_c = options === null || options === void 0 ? void 0 : options.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough;
|
|
17822
|
+
this.parentWindowHandle = (_d = options.brokerOptions) === null || _d === void 0 ? void 0 : _d.parentWindowHandle;
|
|
17823
|
+
if (persistenceProvider !== void 0 && ((_e = options.tokenCachePersistenceOptions) === null || _e === void 0 ? void 0 : _e.enabled)) {
|
|
17824
|
+
const cacheBaseName = options.tokenCachePersistenceOptions.name || DEFAULT_TOKEN_CACHE_NAME;
|
|
17825
|
+
const nonCaeOptions = Object.assign({ name: `${cacheBaseName}.${CACHE_NON_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);
|
|
17826
|
+
const caeOptions = Object.assign({ name: `${cacheBaseName}.${CACHE_CAE_SUFFIX}` }, options.tokenCachePersistenceOptions);
|
|
17827
|
+
this.createCachePlugin = () => persistenceProvider(nonCaeOptions);
|
|
17828
|
+
this.createCachePluginCae = () => persistenceProvider(caeOptions);
|
|
17829
|
+
} else if ((_f = options.tokenCachePersistenceOptions) === null || _f === void 0 ? void 0 : _f.enabled) {
|
|
17830
|
+
throw new Error([
|
|
17831
|
+
"Persistent token caching was requested, but no persistence provider was configured.",
|
|
17832
|
+
"You must install the identity-cache-persistence plugin package (`npm install --save @azure/identity-cache-persistence`)",
|
|
17833
|
+
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
17834
|
+
"`useIdentityPlugin(cachePersistencePlugin)` before using `tokenCachePersistenceOptions`."
|
|
17835
|
+
].join(" "));
|
|
17836
|
+
}
|
|
17837
|
+
if (!hasNativeBroker() && this.enableBroker) {
|
|
17838
|
+
throw new Error([
|
|
17839
|
+
"Broker for WAM was requested to be enabled, but no native broker was configured.",
|
|
17840
|
+
"You must install the identity-broker plugin package (`npm install --save @azure/identity-broker`)",
|
|
17841
|
+
"and enable it by importing `useIdentityPlugin` from `@azure/identity` and calling",
|
|
17842
|
+
"`useIdentityPlugin(createNativeBrokerPlugin())` before using `enableBroker`."
|
|
17843
|
+
].join(" "));
|
|
17844
|
+
}
|
|
17845
|
+
this.azureRegion = calculateRegionalAuthority(options.regionalAuthority);
|
|
17846
|
+
}
|
|
17847
|
+
/**
|
|
17848
|
+
* Generates a MSAL configuration that generally works for Node.js
|
|
17849
|
+
*/
|
|
17850
|
+
defaultNodeMsalConfig(options) {
|
|
17851
|
+
var _a2;
|
|
17852
|
+
const clientId = options.clientId || DeveloperSignOnClientId;
|
|
17853
|
+
const tenantId = resolveTenantId(options.logger, options.tenantId, options.clientId);
|
|
17854
|
+
this.authorityHost = options.authorityHost || process.env.AZURE_AUTHORITY_HOST;
|
|
17855
|
+
const authority = getAuthority(tenantId, this.authorityHost);
|
|
17856
|
+
this.identityClient = new IdentityClient(Object.assign(Object.assign({}, options.tokenCredentialOptions), { authorityHost: authority, loggingOptions: options.loggingOptions }));
|
|
17857
|
+
const clientCapabilities = [];
|
|
17858
|
+
return {
|
|
17859
|
+
auth: {
|
|
17860
|
+
clientId,
|
|
17861
|
+
authority,
|
|
17862
|
+
knownAuthorities: getKnownAuthorities(tenantId, authority, options.disableInstanceDiscovery),
|
|
17863
|
+
clientCapabilities
|
|
17864
|
+
},
|
|
17865
|
+
// Cache is defined in this.prepare();
|
|
17866
|
+
system: {
|
|
17867
|
+
networkClient: this.identityClient,
|
|
17868
|
+
loggerOptions: {
|
|
17869
|
+
loggerCallback: defaultLoggerCallback(options.logger),
|
|
17870
|
+
logLevel: getMSALLogLevel(logger$r.getLogLevel()),
|
|
17871
|
+
piiLoggingEnabled: (_a2 = options.loggingOptions) === null || _a2 === void 0 ? void 0 : _a2.enableUnsafeSupportLogging
|
|
17872
|
+
}
|
|
17873
|
+
}
|
|
17874
|
+
};
|
|
17875
|
+
}
|
|
17876
|
+
getApp(appType, enableCae) {
|
|
17877
|
+
const app = enableCae ? this.caeApp : this.app;
|
|
17878
|
+
if (appType === "publicFirst") {
|
|
17879
|
+
return app.public || app.confidential;
|
|
17880
|
+
} else if (appType === "confidentialFirst") {
|
|
17881
|
+
return app.confidential || app.public;
|
|
17882
|
+
} else if (appType === "confidential") {
|
|
17883
|
+
return app.confidential;
|
|
17884
|
+
} else {
|
|
17885
|
+
return app.public;
|
|
17886
|
+
}
|
|
17887
|
+
}
|
|
17888
|
+
/**
|
|
17889
|
+
* Prepares the MSAL applications.
|
|
17890
|
+
*/
|
|
17891
|
+
async init(options) {
|
|
17892
|
+
if (options === null || options === void 0 ? void 0 : options.abortSignal) {
|
|
17893
|
+
options.abortSignal.addEventListener("abort", () => {
|
|
17894
|
+
this.identityClient.abortRequests(options.correlationId);
|
|
17895
|
+
});
|
|
17896
|
+
}
|
|
17897
|
+
const app = (options === null || options === void 0 ? void 0 : options.enableCae) ? this.caeApp : this.app;
|
|
17898
|
+
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
17899
|
+
this.msalConfig.auth.clientCapabilities = ["cp1"];
|
|
17900
|
+
}
|
|
17901
|
+
if (app.public || app.confidential) {
|
|
17902
|
+
return;
|
|
17903
|
+
}
|
|
17904
|
+
if ((options === null || options === void 0 ? void 0 : options.enableCae) && this.createCachePluginCae !== void 0) {
|
|
17905
|
+
this.msalConfig.cache = {
|
|
17906
|
+
cachePlugin: await this.createCachePluginCae()
|
|
17907
|
+
};
|
|
17908
|
+
}
|
|
17909
|
+
if (this.createCachePlugin !== void 0) {
|
|
17910
|
+
this.msalConfig.cache = {
|
|
17911
|
+
cachePlugin: await this.createCachePlugin()
|
|
17912
|
+
};
|
|
17913
|
+
}
|
|
17914
|
+
if (hasNativeBroker() && this.enableBroker) {
|
|
17915
|
+
this.msalConfig.broker = {
|
|
17916
|
+
nativeBrokerPlugin: nativeBrokerInfo.broker
|
|
17917
|
+
};
|
|
17918
|
+
if (!this.parentWindowHandle) {
|
|
17919
|
+
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
17920
|
+
}
|
|
17921
|
+
}
|
|
17922
|
+
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
17923
|
+
this.caeApp.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
17924
|
+
} else {
|
|
17925
|
+
this.app.public = new msalCommon__namespace.PublicClientApplication(this.msalConfig);
|
|
17926
|
+
}
|
|
17927
|
+
if (this.getAssertion) {
|
|
17928
|
+
this.msalConfig.auth.clientAssertion = await this.getAssertion();
|
|
17929
|
+
}
|
|
17930
|
+
if (this.msalConfig.auth.clientSecret || this.msalConfig.auth.clientAssertion || this.msalConfig.auth.clientCertificate) {
|
|
17931
|
+
if (options === null || options === void 0 ? void 0 : options.enableCae) {
|
|
17932
|
+
this.caeApp.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
17933
|
+
} else {
|
|
17934
|
+
this.app.confidential = new msalCommon__namespace.ConfidentialClientApplication(this.msalConfig);
|
|
17935
|
+
}
|
|
17936
|
+
} else {
|
|
17937
|
+
if (this.requiresConfidential) {
|
|
17938
|
+
throw new Error("Unable to generate the MSAL confidential client. Missing either the client's secret, certificate or assertion.");
|
|
17939
|
+
}
|
|
17940
|
+
}
|
|
17941
|
+
}
|
|
17942
|
+
/**
|
|
17943
|
+
* Allows the cancellation of a MSAL request.
|
|
17944
|
+
*/
|
|
17945
|
+
withCancellation(promise, abortSignal, onCancel) {
|
|
17946
|
+
return new Promise((resolve, reject) => {
|
|
17947
|
+
promise.then((msalToken) => {
|
|
17948
|
+
return resolve(msalToken);
|
|
17949
|
+
}).catch(reject);
|
|
17950
|
+
if (abortSignal) {
|
|
17951
|
+
abortSignal.addEventListener("abort", () => {
|
|
17952
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
17953
|
+
});
|
|
17954
|
+
}
|
|
17955
|
+
});
|
|
17956
|
+
}
|
|
17957
|
+
/**
|
|
17958
|
+
* Returns the existing account, attempts to load the account from MSAL.
|
|
17959
|
+
*/
|
|
17960
|
+
async getActiveAccount(enableCae = false) {
|
|
17961
|
+
if (this.account) {
|
|
17962
|
+
return this.account;
|
|
17963
|
+
}
|
|
17964
|
+
const cache = this.getApp("confidentialFirst", enableCae).getTokenCache();
|
|
17965
|
+
const accountsByTenant = await (cache === null || cache === void 0 ? void 0 : cache.getAllAccounts());
|
|
17966
|
+
if (!accountsByTenant) {
|
|
17967
|
+
return;
|
|
17968
|
+
}
|
|
17969
|
+
if (accountsByTenant.length === 1) {
|
|
17970
|
+
this.account = msalToPublic(this.clientId, accountsByTenant[0]);
|
|
17971
|
+
} else {
|
|
17972
|
+
this.logger.info(`More than one account was found authenticated for this Client ID and Tenant ID.
|
|
17973
|
+
However, no "authenticationRecord" has been provided for this credential,
|
|
17974
|
+
therefore we're unable to pick between these accounts.
|
|
17975
|
+
A new login attempt will be requested, to ensure the correct account is picked.
|
|
17976
|
+
To work with multiple accounts for the same Client ID and Tenant ID, please provide an "authenticationRecord" when initializing a credential to prevent this from happening.`);
|
|
17977
|
+
return;
|
|
17978
|
+
}
|
|
17979
|
+
return this.account;
|
|
17980
|
+
}
|
|
17981
|
+
/**
|
|
17982
|
+
* Attempts to retrieve a token from cache.
|
|
17983
|
+
*/
|
|
17984
|
+
async getTokenSilent(scopes, options) {
|
|
17985
|
+
var _a2, _b2, _c;
|
|
17986
|
+
await this.getActiveAccount(options === null || options === void 0 ? void 0 : options.enableCae);
|
|
17987
|
+
if (!this.account) {
|
|
17988
|
+
throw new AuthenticationRequiredError({
|
|
17989
|
+
scopes,
|
|
17990
|
+
getTokenOptions: options,
|
|
17991
|
+
message: "Silent authentication failed. We couldn't retrieve an active account from the cache."
|
|
17992
|
+
});
|
|
17993
|
+
}
|
|
17994
|
+
const silentRequest = {
|
|
17995
|
+
// To be able to re-use the account, the Token Cache must also have been provided.
|
|
17996
|
+
account: publicToMsal(this.account),
|
|
17997
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
17998
|
+
scopes,
|
|
17999
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
18000
|
+
claims: options === null || options === void 0 ? void 0 : options.claims
|
|
18001
|
+
};
|
|
18002
|
+
if (hasNativeBroker() && this.enableBroker) {
|
|
18003
|
+
if (!silentRequest.tokenQueryParameters) {
|
|
18004
|
+
silentRequest.tokenQueryParameters = {};
|
|
18005
|
+
}
|
|
18006
|
+
if (!this.parentWindowHandle) {
|
|
18007
|
+
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
18008
|
+
}
|
|
18009
|
+
if (this.enableMsaPassthrough) {
|
|
18010
|
+
silentRequest.tokenQueryParameters["msal_request_type"] = "consumer_passthrough";
|
|
18011
|
+
}
|
|
18012
|
+
}
|
|
18013
|
+
try {
|
|
18014
|
+
this.logger.info("Attempting to acquire token silently");
|
|
18015
|
+
await ((_a2 = this.getApp("publicFirst", options === null || options === void 0 ? void 0 : options.enableCae)) === null || _a2 === void 0 ? void 0 : _a2.getTokenCache().getAllAccounts());
|
|
18016
|
+
const response = (_c = await ((_b2 = this.getApp("confidential", options === null || options === void 0 ? void 0 : options.enableCae)) === null || _b2 === void 0 ? void 0 : _b2.acquireTokenSilent(silentRequest))) !== null && _c !== void 0 ? _c : await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenSilent(silentRequest);
|
|
18017
|
+
return this.handleResult(scopes, response || void 0);
|
|
18018
|
+
} catch (err) {
|
|
18019
|
+
throw handleMsalError(scopes, err, options);
|
|
18020
|
+
}
|
|
18021
|
+
}
|
|
18022
|
+
/**
|
|
18023
|
+
* Wrapper around each MSAL flow get token operation: doGetToken.
|
|
18024
|
+
* If disableAutomaticAuthentication is sent through the constructor, it will prevent MSAL from requesting the user input.
|
|
18025
|
+
*/
|
|
18026
|
+
async getToken(scopes, options = {}) {
|
|
18027
|
+
const tenantId = processMultiTenantRequest(this.tenantId, options, this.additionallyAllowedTenantIds) || this.tenantId;
|
|
18028
|
+
options.authority = getAuthority(tenantId, this.authorityHost);
|
|
18029
|
+
options.correlationId = (options === null || options === void 0 ? void 0 : options.correlationId) || randomUUID();
|
|
18030
|
+
await this.init(options);
|
|
18031
|
+
try {
|
|
18032
|
+
const optionsClaims = options.claims;
|
|
18033
|
+
if (optionsClaims) {
|
|
18034
|
+
this.cachedClaims = optionsClaims;
|
|
18035
|
+
}
|
|
18036
|
+
if (this.cachedClaims && !optionsClaims) {
|
|
18037
|
+
options.claims = this.cachedClaims;
|
|
18038
|
+
}
|
|
18039
|
+
return await this.getTokenSilent(scopes, options);
|
|
18040
|
+
} catch (err) {
|
|
18041
|
+
if (err.name !== "AuthenticationRequiredError") {
|
|
18042
|
+
throw err;
|
|
18043
|
+
}
|
|
18044
|
+
if (options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication) {
|
|
18045
|
+
throw new AuthenticationRequiredError({
|
|
18046
|
+
scopes,
|
|
18047
|
+
getTokenOptions: options,
|
|
18048
|
+
message: "Automatic authentication has been disabled. You may call the authentication() method."
|
|
18049
|
+
});
|
|
18050
|
+
}
|
|
18051
|
+
this.logger.info(`Silent authentication failed, falling back to interactive method.`);
|
|
18052
|
+
return this.doGetToken(scopes, options);
|
|
18053
|
+
}
|
|
18054
|
+
}
|
|
18055
|
+
/**
|
|
18056
|
+
* Handles the MSAL authentication result.
|
|
18057
|
+
* If the result has an account, we update the local account reference.
|
|
18058
|
+
* If the token received is invalid, an error will be thrown depending on what's missing.
|
|
18059
|
+
*/
|
|
18060
|
+
handleResult(scopes, result, getTokenOptions) {
|
|
18061
|
+
if (result === null || result === void 0 ? void 0 : result.account) {
|
|
18062
|
+
this.account = msalToPublic(this.clientId, result.account);
|
|
18063
|
+
}
|
|
18064
|
+
ensureValidMsalToken(scopes, result, getTokenOptions);
|
|
18065
|
+
this.logger.getToken.info(formatSuccess(scopes));
|
|
18066
|
+
return {
|
|
18067
|
+
token: result.accessToken,
|
|
18068
|
+
expiresOnTimestamp: result.expiresOn.getTime()
|
|
18069
|
+
};
|
|
18070
|
+
}
|
|
18071
|
+
};
|
|
18072
|
+
__name(_MsalNode, "MsalNode");
|
|
18073
|
+
var MsalNode = _MsalNode;
|
|
18074
|
+
var interactiveBrowserMockable = {
|
|
18075
|
+
open
|
|
18076
|
+
};
|
|
18077
|
+
var _MsalOpenBrowser = class _MsalOpenBrowser extends MsalNode {
|
|
18078
|
+
constructor(options) {
|
|
18079
|
+
var _a2, _b2, _c, _d;
|
|
18080
|
+
super(options);
|
|
18081
|
+
this.loginHint = options.loginHint;
|
|
18082
|
+
this.errorTemplate = (_a2 = options.browserCustomizationOptions) === null || _a2 === void 0 ? void 0 : _a2.errorMessage;
|
|
18083
|
+
this.successTemplate = (_b2 = options.browserCustomizationOptions) === null || _b2 === void 0 ? void 0 : _b2.successMessage;
|
|
18084
|
+
this.logger = credentialLogger("Node.js MSAL Open Browser");
|
|
18085
|
+
this.useDefaultBrokerAccount = ((_c = options.brokerOptions) === null || _c === void 0 ? void 0 : _c.enabled) && ((_d = options.brokerOptions) === null || _d === void 0 ? void 0 : _d.useDefaultBrokerAccount);
|
|
18086
|
+
}
|
|
18087
|
+
async doGetToken(scopes, options = {}) {
|
|
18088
|
+
try {
|
|
18089
|
+
const interactiveRequest = {
|
|
18090
|
+
openBrowser: /* @__PURE__ */ __name(async (url) => {
|
|
18091
|
+
this.logger.verbose(`Opening browser to ${url}`);
|
|
18092
|
+
await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
|
|
18093
|
+
}, "openBrowser"),
|
|
18094
|
+
scopes,
|
|
18095
|
+
authority: options === null || options === void 0 ? void 0 : options.authority,
|
|
18096
|
+
claims: options === null || options === void 0 ? void 0 : options.claims,
|
|
18097
|
+
correlationId: options === null || options === void 0 ? void 0 : options.correlationId,
|
|
18098
|
+
loginHint: this.loginHint,
|
|
18099
|
+
errorTemplate: this.errorTemplate,
|
|
18100
|
+
successTemplate: this.successTemplate
|
|
18101
|
+
};
|
|
18102
|
+
if (hasNativeBroker() && this.enableBroker) {
|
|
18103
|
+
return this.doGetBrokeredToken(scopes, interactiveRequest, {
|
|
18104
|
+
enableCae: options.enableCae,
|
|
18105
|
+
useDefaultBrokerAccount: this.useDefaultBrokerAccount
|
|
18106
|
+
});
|
|
18107
|
+
}
|
|
18108
|
+
if (hasNativeBroker() && !this.enableBroker) {
|
|
18109
|
+
this.logger.verbose("Authentication will resume normally without the broker, since it's not enabled");
|
|
18110
|
+
}
|
|
18111
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive(interactiveRequest);
|
|
18112
|
+
return this.handleResult(scopes, result || void 0);
|
|
18113
|
+
} catch (err) {
|
|
18114
|
+
throw handleMsalError(scopes, err, options);
|
|
18115
|
+
}
|
|
18116
|
+
}
|
|
18117
|
+
/**
|
|
18118
|
+
* A helper function that supports brokered authentication through the MSAL's public application.
|
|
18119
|
+
*
|
|
18120
|
+
* When options.useDefaultBrokerAccount is true, the method will attempt to authenticate using the default broker account.
|
|
18121
|
+
* If the default broker account is not available, the method will fall back to interactive authentication.
|
|
18122
|
+
*/
|
|
18123
|
+
async doGetBrokeredToken(scopes, interactiveRequest, options) {
|
|
18124
|
+
var _a2;
|
|
18125
|
+
this.logger.verbose("Authentication will resume through the broker");
|
|
18126
|
+
if (this.parentWindowHandle) {
|
|
18127
|
+
interactiveRequest.windowHandle = Buffer.from(this.parentWindowHandle);
|
|
18128
|
+
} else {
|
|
18129
|
+
this.logger.warning("Parent window handle is not specified for the broker. This may cause unexpected behavior. Please provide the parentWindowHandle.");
|
|
18130
|
+
}
|
|
18131
|
+
if (this.enableMsaPassthrough) {
|
|
18132
|
+
((_a2 = interactiveRequest.tokenQueryParameters) !== null && _a2 !== void 0 ? _a2 : interactiveRequest.tokenQueryParameters = {})["msal_request_type"] = "consumer_passthrough";
|
|
18133
|
+
}
|
|
18134
|
+
if (options.useDefaultBrokerAccount) {
|
|
18135
|
+
interactiveRequest.prompt = "none";
|
|
18136
|
+
this.logger.verbose("Attempting broker authentication using the default broker account");
|
|
18137
|
+
} else {
|
|
18138
|
+
interactiveRequest.prompt = void 0;
|
|
18139
|
+
this.logger.verbose("Attempting broker authentication without the default broker account");
|
|
18140
|
+
}
|
|
18141
|
+
try {
|
|
18142
|
+
const result = await this.getApp("public", options === null || options === void 0 ? void 0 : options.enableCae).acquireTokenInteractive(interactiveRequest);
|
|
18143
|
+
if (result.fromNativeBroker) {
|
|
18144
|
+
this.logger.verbose(`This result is returned from native broker`);
|
|
18145
|
+
}
|
|
18146
|
+
return this.handleResult(scopes, result || void 0);
|
|
18147
|
+
} catch (e) {
|
|
18148
|
+
this.logger.verbose(`Failed to authenticate through the broker: ${e.message}`);
|
|
18149
|
+
if (options.useDefaultBrokerAccount) {
|
|
18150
|
+
return this.doGetBrokeredToken(scopes, interactiveRequest, {
|
|
18151
|
+
enableCae: options.enableCae,
|
|
18152
|
+
useDefaultBrokerAccount: false
|
|
18153
|
+
});
|
|
18154
|
+
} else {
|
|
18155
|
+
throw handleMsalError(scopes, e);
|
|
18156
|
+
}
|
|
18157
|
+
}
|
|
18158
|
+
}
|
|
18159
|
+
};
|
|
18160
|
+
__name(_MsalOpenBrowser, "MsalOpenBrowser");
|
|
18161
|
+
var MsalOpenBrowser = _MsalOpenBrowser;
|
|
17364
18162
|
var logger$4 = credentialLogger("InteractiveBrowserCredential");
|
|
17365
18163
|
var _InteractiveBrowserCredential = class _InteractiveBrowserCredential {
|
|
17366
18164
|
/**
|
|
@@ -17376,26 +18174,36 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17376
18174
|
* @param options - Options for configuring the client which makes the authentication requests.
|
|
17377
18175
|
*/
|
|
17378
18176
|
constructor(options) {
|
|
17379
|
-
var _a2, _b2, _c, _d
|
|
17380
|
-
|
|
18177
|
+
var _a2, _b2, _c, _d;
|
|
18178
|
+
const redirectUri = typeof options.redirectUri === "function" ? options.redirectUri() : options.redirectUri || "http://localhost";
|
|
18179
|
+
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
17381
18180
|
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
17382
|
-
const msalClientOptions = Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$4 });
|
|
17383
18181
|
const ibcNodeOptions = options;
|
|
17384
|
-
this.browserCustomizationOptions = ibcNodeOptions.browserCustomizationOptions;
|
|
17385
|
-
this.loginHint = ibcNodeOptions.loginHint;
|
|
17386
18182
|
if ((_a2 = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _a2 === void 0 ? void 0 : _a2.enabled) {
|
|
17387
18183
|
if (!((_b2 = ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.brokerOptions) === null || _b2 === void 0 ? void 0 : _b2.parentWindowHandle)) {
|
|
17388
18184
|
throw new Error("In order to do WAM authentication, `parentWindowHandle` under `brokerOptions` is a required parameter");
|
|
17389
18185
|
} else {
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
|
|
17395
|
-
|
|
18186
|
+
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), {
|
|
18187
|
+
tokenCredentialOptions: options,
|
|
18188
|
+
logger: logger$4,
|
|
18189
|
+
redirectUri,
|
|
18190
|
+
browserCustomizationOptions: ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.browserCustomizationOptions,
|
|
18191
|
+
brokerOptions: {
|
|
18192
|
+
enabled: true,
|
|
18193
|
+
parentWindowHandle: ibcNodeOptions.brokerOptions.parentWindowHandle,
|
|
18194
|
+
legacyEnableMsaPassthrough: (_c = ibcNodeOptions.brokerOptions) === null || _c === void 0 ? void 0 : _c.legacyEnableMsaPassthrough,
|
|
18195
|
+
useDefaultBrokerAccount: (_d = ibcNodeOptions.brokerOptions) === null || _d === void 0 ? void 0 : _d.useDefaultBrokerAccount
|
|
18196
|
+
}
|
|
18197
|
+
}));
|
|
17396
18198
|
}
|
|
18199
|
+
} else {
|
|
18200
|
+
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), {
|
|
18201
|
+
tokenCredentialOptions: options,
|
|
18202
|
+
logger: logger$4,
|
|
18203
|
+
redirectUri,
|
|
18204
|
+
browserCustomizationOptions: ibcNodeOptions === null || ibcNodeOptions === void 0 ? void 0 : ibcNodeOptions.browserCustomizationOptions
|
|
18205
|
+
}));
|
|
17397
18206
|
}
|
|
17398
|
-
this.msalClient = createMsalClient((_e = options.clientId) !== null && _e !== void 0 ? _e : DeveloperSignOnClientId, this.tenantId, msalClientOptions);
|
|
17399
18207
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
17400
18208
|
}
|
|
17401
18209
|
/**
|
|
@@ -17414,7 +18222,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17414
18222
|
return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async (newOptions) => {
|
|
17415
18223
|
newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger$4);
|
|
17416
18224
|
const arrayScopes = ensureScopes(scopes);
|
|
17417
|
-
return this.
|
|
18225
|
+
return this.msalFlow.getToken(arrayScopes, Object.assign(Object.assign({}, newOptions), { disableAutomaticAuthentication: this.disableAutomaticAuthentication }));
|
|
17418
18226
|
});
|
|
17419
18227
|
}
|
|
17420
18228
|
/**
|
|
@@ -17433,8 +18241,8 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17433
18241
|
async authenticate(scopes, options = {}) {
|
|
17434
18242
|
return tracingClient.withSpan(`${this.constructor.name}.authenticate`, options, async (newOptions) => {
|
|
17435
18243
|
const arrayScopes = ensureScopes(scopes);
|
|
17436
|
-
await this.
|
|
17437
|
-
return this.
|
|
18244
|
+
await this.msalFlow.getToken(arrayScopes, newOptions);
|
|
18245
|
+
return this.msalFlow.getActiveAccount();
|
|
17438
18246
|
});
|
|
17439
18247
|
}
|
|
17440
18248
|
};
|
|
@@ -17582,48 +18390,32 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17582
18390
|
})
|
|
17583
18391
|
});
|
|
17584
18392
|
const response = await this.identityClient.sendRequest(request);
|
|
17585
|
-
|
|
18393
|
+
const text = response.bodyAsText;
|
|
18394
|
+
if (!text) {
|
|
18395
|
+
logger$2.error(`${credentialName$1}: Authenticated Failed. Received null token from OIDC request. Response status- ${response.status}. Complete response - ${JSON.stringify(response)}`);
|
|
18396
|
+
throw new AuthenticationError(response.status, `${credentialName$1}: Authenticated Failed. Received null token from OIDC request. Response status- ${response.status}. Complete response - ${JSON.stringify(response)}`);
|
|
18397
|
+
}
|
|
18398
|
+
try {
|
|
18399
|
+
const result = JSON.parse(text);
|
|
18400
|
+
if (result === null || result === void 0 ? void 0 : result.oidcToken) {
|
|
18401
|
+
return result.oidcToken;
|
|
18402
|
+
} else {
|
|
18403
|
+
let errorMessage = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
|
|
18404
|
+
if (response.status !== 200) {
|
|
18405
|
+
errorMessage += `Response = ${JSON.stringify(result)}`;
|
|
18406
|
+
}
|
|
18407
|
+
logger$2.error(errorMessage);
|
|
18408
|
+
throw new AuthenticationError(response.status, errorMessage);
|
|
18409
|
+
}
|
|
18410
|
+
} catch (e) {
|
|
18411
|
+
logger$2.error(e.message);
|
|
18412
|
+
logger$2.error(`${credentialName$1}: Authentication Failed. oidcToken field not detected in the response. Response = ${text}`);
|
|
18413
|
+
throw new AuthenticationError(response.status, `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response. Response = ${text}`);
|
|
18414
|
+
}
|
|
17586
18415
|
}
|
|
17587
18416
|
};
|
|
17588
18417
|
__name(_AzurePipelinesCredential, "AzurePipelinesCredential");
|
|
17589
18418
|
var AzurePipelinesCredential = _AzurePipelinesCredential;
|
|
17590
|
-
function handleOidcResponse(response) {
|
|
17591
|
-
const text = response.bodyAsText;
|
|
17592
|
-
if (!text) {
|
|
17593
|
-
logger$2.error(`${credentialName$1}: Authentication Failed. Received null token from OIDC request. Response status- ${response.status}. Complete response - ${JSON.stringify(response)}`);
|
|
17594
|
-
throw new AuthenticationError(response.status, {
|
|
17595
|
-
error: `${credentialName$1}: Authentication Failed. Received null token from OIDC request.`,
|
|
17596
|
-
error_description: `${JSON.stringify(response)}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`
|
|
17597
|
-
});
|
|
17598
|
-
}
|
|
17599
|
-
try {
|
|
17600
|
-
const result = JSON.parse(text);
|
|
17601
|
-
if (result === null || result === void 0 ? void 0 : result.oidcToken) {
|
|
17602
|
-
return result.oidcToken;
|
|
17603
|
-
} else {
|
|
17604
|
-
const errorMessage = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
|
|
17605
|
-
let errorDescription = ``;
|
|
17606
|
-
if (response.status !== 200) {
|
|
17607
|
-
errorDescription = `Complete response - ${JSON.stringify(result)}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`;
|
|
17608
|
-
}
|
|
17609
|
-
logger$2.error(errorMessage);
|
|
17610
|
-
logger$2.error(errorDescription);
|
|
17611
|
-
throw new AuthenticationError(response.status, {
|
|
17612
|
-
error: errorMessage,
|
|
17613
|
-
error_description: errorDescription
|
|
17614
|
-
});
|
|
17615
|
-
}
|
|
17616
|
-
} catch (e) {
|
|
17617
|
-
const errorDetails = `${credentialName$1}: Authentication Failed. oidcToken field not detected in the response.`;
|
|
17618
|
-
logger$2.error(`Response from service = ${text} and error message = ${e.message}`);
|
|
17619
|
-
logger$2.error(errorDetails);
|
|
17620
|
-
throw new AuthenticationError(response.status, {
|
|
17621
|
-
error: errorDetails,
|
|
17622
|
-
error_description: `Response = ${text}. See the troubleshooting guide for more information: https://aka.ms/azsdk/js/identity/azurepipelinescredential/troubleshoot`
|
|
17623
|
-
});
|
|
17624
|
-
}
|
|
17625
|
-
}
|
|
17626
|
-
__name(handleOidcResponse, "handleOidcResponse");
|
|
17627
18419
|
var logger$1 = credentialLogger("AuthorizationCodeCredential");
|
|
17628
18420
|
var _AuthorizationCodeCredential = class _AuthorizationCodeCredential {
|
|
17629
18421
|
/**
|
|
@@ -17665,25 +18457,91 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17665
18457
|
};
|
|
17666
18458
|
__name(_AuthorizationCodeCredential, "AuthorizationCodeCredential");
|
|
17667
18459
|
var AuthorizationCodeCredential = _AuthorizationCodeCredential;
|
|
18460
|
+
var readFileAsync = util.promisify(fs3.readFile);
|
|
18461
|
+
async function parseCertificate(configuration, sendCertificateChain) {
|
|
18462
|
+
const certificateParts = {};
|
|
18463
|
+
const certificate = configuration.certificate;
|
|
18464
|
+
const certificatePath = configuration.certificatePath;
|
|
18465
|
+
certificateParts.certificateContents = certificate || await readFileAsync(certificatePath, "utf8");
|
|
18466
|
+
if (sendCertificateChain) {
|
|
18467
|
+
certificateParts.x5c = certificateParts.certificateContents;
|
|
18468
|
+
}
|
|
18469
|
+
const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/g;
|
|
18470
|
+
const publicKeys = [];
|
|
18471
|
+
let match;
|
|
18472
|
+
do {
|
|
18473
|
+
match = certificatePattern.exec(certificateParts.certificateContents);
|
|
18474
|
+
if (match) {
|
|
18475
|
+
publicKeys.push(match[3]);
|
|
18476
|
+
}
|
|
18477
|
+
} while (match);
|
|
18478
|
+
if (publicKeys.length === 0) {
|
|
18479
|
+
throw new Error("The file at the specified path does not contain a PEM-encoded certificate.");
|
|
18480
|
+
}
|
|
18481
|
+
certificateParts.thumbprint = crypto4.createHash("sha1").update(Buffer.from(publicKeys[0], "base64")).digest("hex").toUpperCase();
|
|
18482
|
+
return certificateParts;
|
|
18483
|
+
}
|
|
18484
|
+
__name(parseCertificate, "parseCertificate");
|
|
18485
|
+
var _MsalOnBehalfOf = class _MsalOnBehalfOf extends MsalNode {
|
|
18486
|
+
constructor(options) {
|
|
18487
|
+
super(options);
|
|
18488
|
+
this.logger.info("Initialized MSAL's On-Behalf-Of flow");
|
|
18489
|
+
this.requiresConfidential = true;
|
|
18490
|
+
this.userAssertionToken = options.userAssertionToken;
|
|
18491
|
+
this.certificatePath = options.certificatePath;
|
|
18492
|
+
this.sendCertificateChain = options.sendCertificateChain;
|
|
18493
|
+
this.clientSecret = options.clientSecret;
|
|
18494
|
+
}
|
|
18495
|
+
// Changing the MSAL configuration asynchronously
|
|
18496
|
+
async init(options) {
|
|
18497
|
+
if (this.certificatePath) {
|
|
18498
|
+
try {
|
|
18499
|
+
const parts = await parseCertificate({ certificatePath: this.certificatePath }, this.sendCertificateChain);
|
|
18500
|
+
this.msalConfig.auth.clientCertificate = {
|
|
18501
|
+
thumbprint: parts.thumbprint,
|
|
18502
|
+
privateKey: parts.certificateContents,
|
|
18503
|
+
x5c: parts.x5c
|
|
18504
|
+
};
|
|
18505
|
+
} catch (error) {
|
|
18506
|
+
this.logger.info(formatError("", error));
|
|
18507
|
+
throw error;
|
|
18508
|
+
}
|
|
18509
|
+
} else {
|
|
18510
|
+
this.msalConfig.auth.clientSecret = this.clientSecret;
|
|
18511
|
+
}
|
|
18512
|
+
return super.init(options);
|
|
18513
|
+
}
|
|
18514
|
+
async doGetToken(scopes, options = {}) {
|
|
18515
|
+
try {
|
|
18516
|
+
const result = await this.getApp("confidential", options.enableCae).acquireTokenOnBehalfOf({
|
|
18517
|
+
scopes,
|
|
18518
|
+
correlationId: options.correlationId,
|
|
18519
|
+
authority: options.authority,
|
|
18520
|
+
claims: options.claims,
|
|
18521
|
+
oboAssertion: this.userAssertionToken
|
|
18522
|
+
});
|
|
18523
|
+
return this.handleResult(scopes, result || void 0);
|
|
18524
|
+
} catch (err) {
|
|
18525
|
+
throw handleMsalError(scopes, err, options);
|
|
18526
|
+
}
|
|
18527
|
+
}
|
|
18528
|
+
};
|
|
18529
|
+
__name(_MsalOnBehalfOf, "MsalOnBehalfOf");
|
|
18530
|
+
var MsalOnBehalfOf = _MsalOnBehalfOf;
|
|
17668
18531
|
var credentialName = "OnBehalfOfCredential";
|
|
17669
18532
|
var logger = credentialLogger(credentialName);
|
|
17670
18533
|
var _OnBehalfOfCredential = class _OnBehalfOfCredential {
|
|
17671
18534
|
constructor(options) {
|
|
18535
|
+
this.options = options;
|
|
17672
18536
|
const { clientSecret } = options;
|
|
17673
|
-
const { certificatePath
|
|
17674
|
-
const { getAssertion } = options;
|
|
18537
|
+
const { certificatePath } = options;
|
|
17675
18538
|
const { tenantId, clientId, userAssertionToken, additionallyAllowedTenants: additionallyAllowedTenantIds } = options;
|
|
17676
|
-
if (!tenantId || !clientId || !(clientSecret || certificatePath
|
|
17677
|
-
throw new Error(`${credentialName}: tenantId, clientId, clientSecret (or certificatePath
|
|
18539
|
+
if (!tenantId || !clientId || !(clientSecret || certificatePath) || !userAssertionToken) {
|
|
18540
|
+
throw new Error(`${credentialName}: tenantId, clientId, clientSecret (or certificatePath) and userAssertionToken are required parameters.`);
|
|
17678
18541
|
}
|
|
17679
|
-
this.certificatePath = certificatePath;
|
|
17680
|
-
this.clientSecret = clientSecret;
|
|
17681
|
-
this.userAssertionToken = userAssertionToken;
|
|
17682
|
-
this.sendCertificateChain = sendCertificateChain;
|
|
17683
|
-
this.clientAssertion = getAssertion;
|
|
17684
18542
|
this.tenantId = tenantId;
|
|
17685
18543
|
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(additionallyAllowedTenantIds);
|
|
17686
|
-
this.
|
|
18544
|
+
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
17687
18545
|
}
|
|
17688
18546
|
/**
|
|
17689
18547
|
* Authenticates with Microsoft Entra ID and returns an access token if successful.
|
|
@@ -17696,54 +18554,9 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17696
18554
|
return tracingClient.withSpan(`${credentialName}.getToken`, options, async (newOptions) => {
|
|
17697
18555
|
newOptions.tenantId = processMultiTenantRequest(this.tenantId, newOptions, this.additionallyAllowedTenantIds, logger);
|
|
17698
18556
|
const arrayScopes = ensureScopes(scopes);
|
|
17699
|
-
|
|
17700
|
-
const clientCertificate = await this.buildClientCertificate(this.certificatePath);
|
|
17701
|
-
return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, clientCertificate, newOptions);
|
|
17702
|
-
} else if (this.clientSecret) {
|
|
17703
|
-
return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, this.clientSecret, options);
|
|
17704
|
-
} else if (this.clientAssertion) {
|
|
17705
|
-
return this.msalClient.getTokenOnBehalfOf(arrayScopes, this.userAssertionToken, this.clientAssertion, options);
|
|
17706
|
-
} else {
|
|
17707
|
-
throw new Error("Expected either clientSecret or certificatePath or clientAssertion to be defined.");
|
|
17708
|
-
}
|
|
18557
|
+
return this.msalFlow.getToken(arrayScopes, newOptions);
|
|
17709
18558
|
});
|
|
17710
18559
|
}
|
|
17711
|
-
async buildClientCertificate(certificatePath) {
|
|
17712
|
-
try {
|
|
17713
|
-
const parts = await this.parseCertificate({ certificatePath }, this.sendCertificateChain);
|
|
17714
|
-
return {
|
|
17715
|
-
thumbprint: parts.thumbprint,
|
|
17716
|
-
privateKey: parts.certificateContents,
|
|
17717
|
-
x5c: parts.x5c
|
|
17718
|
-
};
|
|
17719
|
-
} catch (error) {
|
|
17720
|
-
logger.info(formatError("", error));
|
|
17721
|
-
throw error;
|
|
17722
|
-
}
|
|
17723
|
-
}
|
|
17724
|
-
async parseCertificate(configuration, sendCertificateChain) {
|
|
17725
|
-
const certificatePath = configuration.certificatePath;
|
|
17726
|
-
const certificateContents = await promises$1.readFile(certificatePath, "utf8");
|
|
17727
|
-
const x5c = sendCertificateChain ? certificateContents : void 0;
|
|
17728
|
-
const certificatePattern = /(-+BEGIN CERTIFICATE-+)(\n\r?|\r\n?)([A-Za-z0-9+/\n\r]+=*)(\n\r?|\r\n?)(-+END CERTIFICATE-+)/g;
|
|
17729
|
-
const publicKeys = [];
|
|
17730
|
-
let match;
|
|
17731
|
-
do {
|
|
17732
|
-
match = certificatePattern.exec(certificateContents);
|
|
17733
|
-
if (match) {
|
|
17734
|
-
publicKeys.push(match[3]);
|
|
17735
|
-
}
|
|
17736
|
-
} while (match);
|
|
17737
|
-
if (publicKeys.length === 0) {
|
|
17738
|
-
throw new Error("The file at the specified path does not contain a PEM-encoded certificate.");
|
|
17739
|
-
}
|
|
17740
|
-
const thumbprint = node_crypto.createHash("sha1").update(Buffer.from(publicKeys[0], "base64")).digest("hex").toUpperCase();
|
|
17741
|
-
return {
|
|
17742
|
-
certificateContents,
|
|
17743
|
-
thumbprint,
|
|
17744
|
-
x5c
|
|
17745
|
-
};
|
|
17746
|
-
}
|
|
17747
18560
|
};
|
|
17748
18561
|
__name(_OnBehalfOfCredential, "OnBehalfOfCredential");
|
|
17749
18562
|
var OnBehalfOfCredential = _OnBehalfOfCredential;
|
|
@@ -17806,7 +18619,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
|
|
|
17806
18619
|
exports.deserializeAuthenticationRecord = deserializeAuthenticationRecord2;
|
|
17807
18620
|
exports.getBearerTokenProvider = getBearerTokenProvider;
|
|
17808
18621
|
exports.getDefaultAzureCredential = getDefaultAzureCredential;
|
|
17809
|
-
exports.logger = logger$
|
|
18622
|
+
exports.logger = logger$q;
|
|
17810
18623
|
exports.serializeAuthenticationRecord = serializeAuthenticationRecord2;
|
|
17811
18624
|
exports.useIdentityPlugin = useIdentityPlugin2;
|
|
17812
18625
|
}
|
|
@@ -17939,7 +18752,7 @@ var BasePersistence = _BasePersistence;
|
|
|
17939
18752
|
import { promises as fs } from "fs";
|
|
17940
18753
|
import { dirname } from "path";
|
|
17941
18754
|
|
|
17942
|
-
// ../../node_modules/.store/@azure-msal-common-npm-14.
|
|
18755
|
+
// ../../node_modules/.store/@azure-msal-common-npm-14.13.0-f77242c157/package/dist/utils/Constants.mjs
|
|
17943
18756
|
var Constants2 = {
|
|
17944
18757
|
LIBRARY_NAME: "MSAL.JS",
|
|
17945
18758
|
SKU: "msal.js.common",
|
|
@@ -18019,7 +18832,7 @@ var AUTHORITY_METADATA_CONSTANTS = {
|
|
|
18019
18832
|
// 24 Hours
|
|
18020
18833
|
};
|
|
18021
18834
|
|
|
18022
|
-
// ../../node_modules/.store/@azure-msal-common-npm-14.
|
|
18835
|
+
// ../../node_modules/.store/@azure-msal-common-npm-14.13.0-f77242c157/package/dist/logger/Logger.mjs
|
|
18023
18836
|
var LogLevel;
|
|
18024
18837
|
(function(LogLevel2) {
|
|
18025
18838
|
LogLevel2[LogLevel2["Error"] = 0] = "Error";
|
|
@@ -18881,16 +19694,16 @@ export {
|
|
|
18881
19694
|
};
|
|
18882
19695
|
/*! Bundled license information:
|
|
18883
19696
|
|
|
18884
|
-
.store/@azure-msal-node-npm-2.
|
|
18885
|
-
(*! @azure/msal-node v2.
|
|
18886
|
-
(*! @azure/msal-common v14.15.0 2024-
|
|
19697
|
+
.store/@azure-msal-node-npm-2.15.0-02a613cb10/package/lib/msal-node.cjs:
|
|
19698
|
+
(*! @azure/msal-node v2.15.0 2024-10-03 *)
|
|
19699
|
+
(*! @azure/msal-common v14.15.0 2024-10-03 *)
|
|
18887
19700
|
|
|
18888
|
-
.store/@azure-msal-common-npm-14.
|
|
18889
|
-
(*! @azure/msal-common v14.
|
|
19701
|
+
.store/@azure-msal-common-npm-14.13.0-f77242c157/package/dist/utils/Constants.mjs:
|
|
19702
|
+
(*! @azure/msal-common v14.13.0 2024-07-01 *)
|
|
18890
19703
|
|
|
18891
|
-
.store/@azure-msal-common-npm-14.
|
|
18892
|
-
(*! @azure/msal-common v14.
|
|
19704
|
+
.store/@azure-msal-common-npm-14.13.0-f77242c157/package/dist/logger/Logger.mjs:
|
|
19705
|
+
(*! @azure/msal-common v14.13.0 2024-07-01 *)
|
|
18893
19706
|
|
|
18894
|
-
.store/@azure-msal-common-npm-14.
|
|
18895
|
-
(*! @azure/msal-common v14.
|
|
19707
|
+
.store/@azure-msal-common-npm-14.13.0-f77242c157/package/dist/index.mjs:
|
|
19708
|
+
(*! @azure/msal-common v14.13.0 2024-07-01 *)
|
|
18896
19709
|
*/
|