@azure/msal-node 1.8.0 → 1.10.0
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/README.md +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +219 -54
- package/dist/msal-node.cjs.development.js.map +1 -1
- package/dist/msal-node.cjs.production.min.js +1 -1
- package/dist/msal-node.cjs.production.min.js.map +1 -1
- package/dist/msal-node.esm.js +219 -54
- package/dist/msal-node.esm.js.map +1 -1
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/request/ClientCredentialRequest.d.ts +3 -1
- package/dist/request/ClientCredentialRequest.d.ts.map +1 -1
- package/dist/utils/Constants.d.ts +1 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ Any major MSAL Node release:
|
|
|
84
84
|
|
|
85
85
|
| MSAL Node version | MSAL support status | Supported Node versions |
|
|
86
86
|
|-------------------|-------------------------|-------------------------|
|
|
87
|
-
| 1.x.x | Active development | 10, 12, 14, 16
|
|
87
|
+
| 1.x.x | Active development | 10, 12, 14, 16, 18 |
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
## Usage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfidentialClientApplication.d.ts","sourceRoot":"","sources":["../src/client/ConfidentialClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAKH,oBAAoB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;GAIG;AACH,qBAAa,6BAA8B,SAAQ,iBAAkB,YAAW,8BAA8B;IAE1G;;;;;;;;;;;;;;;;;;OAkBG;gBACS,aAAa,EAAE,aAAa;IAKxC;;OAEG;IACU,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfidentialClientApplication.d.ts","sourceRoot":"","sources":["../src/client/ConfidentialClientApplication.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAKH,oBAAoB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;GAIG;AACH,qBAAa,6BAA8B,SAAQ,iBAAkB,YAAW,8BAA8B;IAE1G;;;;;;;;;;;;;;;;;;OAkBG;gBACS,aAAa,EAAE,aAAa;IAKxC;;OAEG;IACU,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA4CnH;;;;;;;;;;OAUG;IACU,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAyBrG,OAAO,CAAC,mBAAmB;CAiC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../src/config/Configuration.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,aAAa,EACb,cAAc,EAEd,YAAY,EACZ,YAAY,EAGZ,iBAAiB,EACjB,oBAAoB,EACvB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;GASG;AACH,oBAAY,eAAe,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"Configuration.d.ts","sourceRoot":"","sources":["../src/config/Configuration.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,aAAa,EACb,cAAc,EAEd,YAAY,EACZ,YAAY,EAGZ,iBAAiB,EACjB,oBAAoB,EACvB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;;;GASG;AACH,oBAAY,eAAe,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,CAAC,EAAE,MAAM,CAAA;KACf,CAAC;IACF,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,YAAY,GAAG;IACvB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC;AAEF;;;;;;GAMG;AACH,oBAAY,iBAAiB,GAAG;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IAC/B,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAEF;;;;;;;GAOG;AACH,oBAAY,aAAa,GAAG;IACxB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,SAAS,CAAC,EAAE,oBAAoB,CAAC;CACpC,CAAC;AA8CF,oBAAY,iBAAiB,GAAG;IAC5B,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAChC,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACpC,SAAS,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,EAClC,IAAI,EACJ,KAAK,EACL,MAAM,EACN,SAAS,EACZ,EAAE,aAAa,GAAG,iBAAiB,CAQnC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,6 @@ export type { OnBehalfOfRequest } from "./request/OnBehalfOfRequest";
|
|
|
25
25
|
export type { UsernamePasswordRequest } from "./request/UsernamePasswordRequest";
|
|
26
26
|
export type { RefreshTokenRequest } from "./request/RefreshTokenRequest";
|
|
27
27
|
export type { SilentFlowRequest } from "./request/SilentFlowRequest";
|
|
28
|
-
export { PromptValue, ResponseMode, AuthenticationResult, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache, AzureCloudInstance, AzureCloudOptions } from "@azure/msal-common";
|
|
28
|
+
export { PromptValue, ResponseMode, AuthorizationCodePayload, AuthenticationResult, AccountInfo, ValidCacheType, AuthError, AuthErrorMessage, ClientAuthError, ClientAuthErrorMessage, ClientConfigurationError, ClientConfigurationErrorMessage, InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, ServerError, INetworkModule, NetworkRequestOptions, NetworkResponse, Logger, LogLevel, ProtocolMode, ICachePlugin, TokenCacheContext, ISerializableTokenCache, AzureCloudInstance, AzureCloudOptions } from "@azure/msal-common";
|
|
29
29
|
export { version } from "./packageMetadata";
|
|
30
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EA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EAER,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EAEvB,kBAAkB,EAClB,iBAAiB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var msalCommon = require('@azure/msal-common');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var http = _interopDefault(require('http'));
|
|
9
|
+
var https = _interopDefault(require('https'));
|
|
10
10
|
var uuid = require('uuid');
|
|
11
11
|
var crypto = _interopDefault(require('crypto'));
|
|
12
12
|
var jsonwebtoken = require('jsonwebtoken');
|
|
@@ -56,7 +56,8 @@ const CharSet = {
|
|
|
56
56
|
|
|
57
57
|
const Constants = {
|
|
58
58
|
MSAL_SKU: "msal.js.node",
|
|
59
|
-
JWT_BEARER_ASSERTION_TYPE: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
|
|
59
|
+
JWT_BEARER_ASSERTION_TYPE: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
|
60
|
+
AUTHORIZATION_PENDING: "authorization_pending"
|
|
60
61
|
};
|
|
61
62
|
/**
|
|
62
63
|
* API Codes for Telemetry purposes.
|
|
@@ -109,29 +110,11 @@ class HttpClient {
|
|
|
109
110
|
* @param options
|
|
110
111
|
*/
|
|
111
112
|
async sendGetRequestAsync(url, options) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/* istanbul ignore next */
|
|
117
|
-
headers: options && options.headers,
|
|
118
|
-
|
|
119
|
-
/* istanbul ignore next */
|
|
120
|
-
validateStatus: () => true
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (options && options.proxyUrl) {
|
|
124
|
-
// for axios, this has to be disabled
|
|
125
|
-
request.proxy = false;
|
|
126
|
-
request.httpsAgent = createHttpsProxyAgent(options.proxyUrl);
|
|
113
|
+
if (options != null && options.proxyUrl) {
|
|
114
|
+
return networkRequestViaProxy(url, HttpMethod.GET, options);
|
|
115
|
+
} else {
|
|
116
|
+
return networkRequestViaHttps(url, HttpMethod.GET, options);
|
|
127
117
|
}
|
|
128
|
-
|
|
129
|
-
const response = await axios(request);
|
|
130
|
-
return {
|
|
131
|
-
headers: response.headers,
|
|
132
|
-
body: response.data,
|
|
133
|
-
status: response.status
|
|
134
|
-
};
|
|
135
118
|
}
|
|
136
119
|
/**
|
|
137
120
|
* Http Post request
|
|
@@ -141,36 +124,207 @@ class HttpClient {
|
|
|
141
124
|
|
|
142
125
|
|
|
143
126
|
async sendPostRequestAsync(url, options, cancellationToken) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
127
|
+
if (options != null && options.proxyUrl) {
|
|
128
|
+
return networkRequestViaProxy(url, HttpMethod.POST, options, cancellationToken);
|
|
129
|
+
} else {
|
|
130
|
+
return networkRequestViaHttps(url, HttpMethod.POST, options, cancellationToken);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
147
135
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
137
|
+
const headers = (options == null ? void 0 : options.headers) || {};
|
|
138
|
+
const proxyUrl = new URL((options == null ? void 0 : options.proxyUrl) || "");
|
|
139
|
+
const destinationUrl = new URL(url); // "method: connect" must be used to establish a connection to the proxy
|
|
140
|
+
|
|
141
|
+
const tunnelRequestOptions = {
|
|
142
|
+
host: proxyUrl.hostname,
|
|
143
|
+
port: proxyUrl.port,
|
|
144
|
+
method: "CONNECT",
|
|
145
|
+
path: destinationUrl.hostname,
|
|
146
|
+
headers: headers
|
|
147
|
+
};
|
|
151
148
|
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
if (timeout) {
|
|
150
|
+
tunnelRequestOptions.timeout = timeout;
|
|
151
|
+
} // compose a request string for the socket
|
|
154
152
|
|
|
155
|
-
/* istanbul ignore next */
|
|
156
|
-
validateStatus: () => true
|
|
157
|
-
};
|
|
158
153
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
let postRequestStringContent = "";
|
|
155
|
+
|
|
156
|
+
if (httpMethod === HttpMethod.POST) {
|
|
157
|
+
const body = (options == null ? void 0 : options.body) || "";
|
|
158
|
+
postRequestStringContent = "Content-Type: application/x-www-form-urlencoded\r\n" + `Content-Length: ${body.length}\r\n` + `\r\n${body}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` + `Host: ${destinationUrl.host}\r\n` + "Connection: close\r\n" + postRequestStringContent + "\r\n";
|
|
162
|
+
return new Promise((resolve, reject) => {
|
|
163
|
+
const request = http.request(tunnelRequestOptions);
|
|
164
|
+
|
|
165
|
+
if (tunnelRequestOptions.timeout) {
|
|
166
|
+
request.on("timeout", () => {
|
|
167
|
+
request.destroy();
|
|
168
|
+
reject(new Error("Request time out"));
|
|
169
|
+
});
|
|
163
170
|
}
|
|
164
171
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
172
|
+
request.end(); // establish connection to the proxy
|
|
173
|
+
|
|
174
|
+
request.on("connect", (response, socket) => {
|
|
175
|
+
const statusCode = (response == null ? void 0 : response.statusCode) || 500;
|
|
176
|
+
|
|
177
|
+
if (statusCode < 200 || statusCode > 299) {
|
|
178
|
+
request.destroy();
|
|
179
|
+
socket.destroy();
|
|
180
|
+
reject(new Error(`HTTP status code ${statusCode}`));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (tunnelRequestOptions.timeout) {
|
|
184
|
+
socket.setTimeout(tunnelRequestOptions.timeout);
|
|
185
|
+
socket.on("timeout", () => {
|
|
186
|
+
request.destroy();
|
|
187
|
+
socket.destroy();
|
|
188
|
+
reject(new Error("Request time out"));
|
|
189
|
+
});
|
|
190
|
+
} // make a request over an HTTP tunnel
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
socket.write(outgoingRequestString);
|
|
194
|
+
const data = [];
|
|
195
|
+
socket.on("data", chunk => {
|
|
196
|
+
data.push(chunk);
|
|
197
|
+
});
|
|
198
|
+
socket.on("end", () => {
|
|
199
|
+
// combine all received buffer streams into one buffer, and then into a string
|
|
200
|
+
const dataString = Buffer.concat([...data]).toString(); // separate each line into it's own entry in an arry
|
|
201
|
+
|
|
202
|
+
const dataStringArray = dataString.split("\r\n"); // the first entry will contain the statusCode
|
|
203
|
+
|
|
204
|
+
const statusCode = parseInt(dataStringArray[0].split(" ")[1]); // the last entry will contain the body
|
|
205
|
+
|
|
206
|
+
const body = dataStringArray[dataStringArray.length - 1]; // everything in between the first and last entries are the headers
|
|
207
|
+
|
|
208
|
+
const headersArray = dataStringArray.slice(1, dataStringArray.length - 2); // build an object out of all the headers
|
|
209
|
+
|
|
210
|
+
const entries = new Map();
|
|
211
|
+
headersArray.forEach(header => {
|
|
212
|
+
/**
|
|
213
|
+
* the header might look like "Content-Length: 1531", but that is just a string
|
|
214
|
+
* it needs to be converted to a key/value pair
|
|
215
|
+
* split the string at the first instance of ":"
|
|
216
|
+
* there may be more than one ":" if the value of the header is supposed to be a JSON object
|
|
217
|
+
*/
|
|
218
|
+
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
|
219
|
+
const headerKey = headerKeyValue[0];
|
|
220
|
+
let headerValue = headerKeyValue[1]; // check if the value of the header is supposed to be a JSON object
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
const object = JSON.parse(headerValue); // if it is, then convert it from a string to a JSON object
|
|
224
|
+
|
|
225
|
+
if (object && typeof object === "object") {
|
|
226
|
+
headerValue = object;
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {// otherwise, leave it as a string
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
entries.set(headerKey, headerValue);
|
|
232
|
+
});
|
|
233
|
+
const headers = Object.fromEntries(entries);
|
|
234
|
+
const networkResponse = {
|
|
235
|
+
headers: headers,
|
|
236
|
+
body: JSON.parse(body),
|
|
237
|
+
status: statusCode
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
if ((statusCode < 200 || statusCode > 299) && // do not destroy the request for the device code flow
|
|
241
|
+
networkResponse.body["error"] !== Constants.AUTHORIZATION_PENDING) {
|
|
242
|
+
request.destroy();
|
|
243
|
+
socket.destroy();
|
|
244
|
+
reject(new Error(`HTTP status code ${statusCode}`));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
resolve(networkResponse);
|
|
248
|
+
});
|
|
249
|
+
socket.on("error", chunk => {
|
|
250
|
+
request.destroy();
|
|
251
|
+
socket.destroy();
|
|
252
|
+
reject(new Error(chunk.toString()));
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
request.on("error", chunk => {
|
|
256
|
+
request.destroy();
|
|
257
|
+
reject(new Error(chunk.toString()));
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
263
|
+
const isPostRequest = httpMethod === HttpMethod.POST;
|
|
264
|
+
const body = (options == null ? void 0 : options.body) || "";
|
|
265
|
+
const emptyHeaders = {};
|
|
266
|
+
const customOptions = {
|
|
267
|
+
method: httpMethod,
|
|
268
|
+
headers: (options == null ? void 0 : options.headers) || emptyHeaders
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
if (timeout) {
|
|
272
|
+
customOptions.timeout = timeout;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (isPostRequest) {
|
|
276
|
+
// needed for post request to work
|
|
277
|
+
customOptions.headers = { ...customOptions.headers,
|
|
278
|
+
"Content-Length": body.length
|
|
170
279
|
};
|
|
171
280
|
}
|
|
172
281
|
|
|
173
|
-
|
|
282
|
+
return new Promise((resolve, reject) => {
|
|
283
|
+
const request = https.request(url, customOptions);
|
|
284
|
+
|
|
285
|
+
if (timeout) {
|
|
286
|
+
request.on("timeout", () => {
|
|
287
|
+
request.destroy();
|
|
288
|
+
reject(new Error("Request time out"));
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (isPostRequest) {
|
|
293
|
+
request.write(body);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
request.end();
|
|
297
|
+
request.on("response", response => {
|
|
298
|
+
const headers = response.headers;
|
|
299
|
+
const statusCode = response.statusCode;
|
|
300
|
+
const data = [];
|
|
301
|
+
response.on("data", chunk => {
|
|
302
|
+
data.push(chunk);
|
|
303
|
+
});
|
|
304
|
+
response.on("end", () => {
|
|
305
|
+
// combine all received buffer streams into one buffer, and then into a string
|
|
306
|
+
const body = Buffer.concat([...data]).toString();
|
|
307
|
+
const networkResponse = {
|
|
308
|
+
headers: headers,
|
|
309
|
+
body: JSON.parse(body),
|
|
310
|
+
status: statusCode
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
if ((statusCode < 200 || statusCode > 299) && // do not destroy the request for the device code flow
|
|
314
|
+
networkResponse.body["error"] !== Constants.AUTHORIZATION_PENDING) {
|
|
315
|
+
request.destroy();
|
|
316
|
+
reject(new Error(`HTTP status code ${statusCode}`));
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
resolve(networkResponse);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
request.on("error", chunk => {
|
|
323
|
+
request.destroy();
|
|
324
|
+
reject(new Error(chunk.toString()));
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
};
|
|
174
328
|
|
|
175
329
|
/*
|
|
176
330
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1603,7 +1757,7 @@ class TokenCache {
|
|
|
1603
1757
|
|
|
1604
1758
|
/* eslint-disable header/header */
|
|
1605
1759
|
const name = "@azure/msal-node";
|
|
1606
|
-
const version = "1.
|
|
1760
|
+
const version = "1.10.0";
|
|
1607
1761
|
|
|
1608
1762
|
/*
|
|
1609
1763
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1917,7 +2071,7 @@ class ClientApplication {
|
|
|
1917
2071
|
authorityMetadata: this.config.auth.authorityMetadata,
|
|
1918
2072
|
azureRegionConfiguration
|
|
1919
2073
|
};
|
|
1920
|
-
return await msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions);
|
|
2074
|
+
return await msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.config.system.proxyUrl);
|
|
1921
2075
|
}
|
|
1922
2076
|
/**
|
|
1923
2077
|
* Clear the cache
|
|
@@ -2117,13 +2271,13 @@ class ClientAssertion {
|
|
|
2117
2271
|
* "." means any string character, "+" means match 1 or more times, and "?" means the shortest match.
|
|
2118
2272
|
* The "g" at the end of the regex means search the string globally, and the "s" enables the "." to match newlines.
|
|
2119
2273
|
*/
|
|
2120
|
-
const regexToFindCerts = /-----BEGIN CERTIFICATE-----\n(.+?)\n-----END CERTIFICATE-----/gs;
|
|
2274
|
+
const regexToFindCerts = /-----BEGIN CERTIFICATE-----\r*\n(.+?)\r*\n-----END CERTIFICATE-----/gs;
|
|
2121
2275
|
const certs = [];
|
|
2122
2276
|
let matches;
|
|
2123
2277
|
|
|
2124
2278
|
while ((matches = regexToFindCerts.exec(publicCertificate)) !== null) {
|
|
2125
2279
|
// matches[1] represents the first parens capture group in the regex.
|
|
2126
|
-
certs.push(matches[1].replace(/\n
|
|
2280
|
+
certs.push(matches[1].replace(/\r*\n/g, msalCommon.Constants.EMPTY_STRING));
|
|
2127
2281
|
}
|
|
2128
2282
|
|
|
2129
2283
|
return certs;
|
|
@@ -2171,9 +2325,20 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2171
2325
|
|
|
2172
2326
|
|
|
2173
2327
|
async acquireTokenByClientCredential(request) {
|
|
2174
|
-
this.logger.info("acquireTokenByClientCredential called", request.correlationId);
|
|
2328
|
+
this.logger.info("acquireTokenByClientCredential called", request.correlationId); // If there is a client assertion present in the request, it overrides the one present in the client configuration
|
|
2329
|
+
|
|
2330
|
+
let clientAssertion;
|
|
2331
|
+
|
|
2332
|
+
if (request.clientAssertion) {
|
|
2333
|
+
clientAssertion = {
|
|
2334
|
+
assertion: request.clientAssertion,
|
|
2335
|
+
assertionType: Constants.JWT_BEARER_ASSERTION_TYPE
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2175
2339
|
const validRequest = { ...request,
|
|
2176
|
-
...(await this.initializeBaseRequest(request))
|
|
2340
|
+
...(await this.initializeBaseRequest(request)),
|
|
2341
|
+
clientAssertion
|
|
2177
2342
|
};
|
|
2178
2343
|
const azureRegionConfiguration = {
|
|
2179
2344
|
azureRegion: validRequest.azureRegion,
|
|
@@ -2215,8 +2380,8 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
2215
2380
|
};
|
|
2216
2381
|
|
|
2217
2382
|
try {
|
|
2218
|
-
const
|
|
2219
|
-
const oboClient = new msalCommon.OnBehalfOfClient(
|
|
2383
|
+
const onBehalfOfConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, undefined, undefined, request.azureCloudOptions);
|
|
2384
|
+
const oboClient = new msalCommon.OnBehalfOfClient(onBehalfOfConfig);
|
|
2220
2385
|
this.logger.verbose("On behalf of client created", validRequest.correlationId);
|
|
2221
2386
|
return oboClient.acquireToken(validRequest);
|
|
2222
2387
|
} catch (e) {
|