@azure/msal-node 1.14.2 → 1.14.4
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/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +91 -36
- 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 +91 -36
- 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/utils/Constants.d.ts +12 -2
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/NetworkUtils.d.ts +2 -5
- package/dist/utils/NetworkUtils.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicClientApplication.d.ts","sourceRoot":"","sources":["../src/client/PublicClientApplication.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,oBAAoB,EAQvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAInE;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,iBAAkB,YAAW,wBAAwB;IAC9F;;;;;;;;;;;;;;;;OAgBG;gBACS,aAAa,EAAE,aAAa;IAIxC;;;;;;;;OAQG;IACU,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAwBvG;;OAEG;IACG,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"PublicClientApplication.d.ts","sourceRoot":"","sources":["../src/client/PublicClientApplication.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,oBAAoB,EAQvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAInE;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,iBAAkB,YAAW,wBAAwB;IAC9F;;;;;;;;;;;;;;;;OAgBG;gBACS,aAAa,EAAE,aAAa;IAIxC;;;;;;;;OAQG;IACU,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAwBvG;;OAEG;IACG,uBAAuB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAsC5F"}
|
|
@@ -30,9 +30,22 @@ var HttpMethod;
|
|
|
30
30
|
var HttpStatus;
|
|
31
31
|
|
|
32
32
|
(function (HttpStatus) {
|
|
33
|
-
HttpStatus[HttpStatus["
|
|
33
|
+
HttpStatus[HttpStatus["SUCCESS_RANGE_START"] = 200] = "SUCCESS_RANGE_START";
|
|
34
|
+
HttpStatus[HttpStatus["SUCCESS_RANGE_END"] = 299] = "SUCCESS_RANGE_END";
|
|
34
35
|
HttpStatus[HttpStatus["REDIRECT"] = 302] = "REDIRECT";
|
|
36
|
+
HttpStatus[HttpStatus["CLIENT_ERROR_RANGE_START"] = 400] = "CLIENT_ERROR_RANGE_START";
|
|
37
|
+
HttpStatus[HttpStatus["CLIENT_ERROR_RANGE_END"] = 499] = "CLIENT_ERROR_RANGE_END";
|
|
38
|
+
HttpStatus[HttpStatus["SERVER_ERROR_RANGE_START"] = 500] = "SERVER_ERROR_RANGE_START";
|
|
39
|
+
HttpStatus[HttpStatus["SERVER_ERROR_RANGE_END"] = 599] = "SERVER_ERROR_RANGE_END";
|
|
35
40
|
})(HttpStatus || (HttpStatus = {}));
|
|
41
|
+
|
|
42
|
+
var ProxyStatus;
|
|
43
|
+
|
|
44
|
+
(function (ProxyStatus) {
|
|
45
|
+
ProxyStatus[ProxyStatus["SUCCESS_RANGE_START"] = 200] = "SUCCESS_RANGE_START";
|
|
46
|
+
ProxyStatus[ProxyStatus["SUCCESS_RANGE_END"] = 299] = "SUCCESS_RANGE_END";
|
|
47
|
+
ProxyStatus[ProxyStatus["SERVER_ERROR"] = 500] = "SERVER_ERROR";
|
|
48
|
+
})(ProxyStatus || (ProxyStatus = {}));
|
|
36
49
|
/**
|
|
37
50
|
* Constants used for region discovery
|
|
38
51
|
*/
|
|
@@ -109,6 +122,21 @@ const LOOPBACK_SERVER_CONSTANTS = {
|
|
|
109
122
|
TIMEOUT_MS: 5000
|
|
110
123
|
};
|
|
111
124
|
|
|
125
|
+
/*
|
|
126
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
127
|
+
* Licensed under the MIT License.
|
|
128
|
+
*/
|
|
129
|
+
class NetworkUtils {
|
|
130
|
+
static getNetworkResponse(headers, body, statusCode) {
|
|
131
|
+
return {
|
|
132
|
+
headers: headers,
|
|
133
|
+
body: body,
|
|
134
|
+
status: statusCode
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
112
140
|
/*
|
|
113
141
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
114
142
|
* Licensed under the MIT License.
|
|
@@ -186,12 +214,12 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
186
214
|
request.end(); // establish connection to the proxy
|
|
187
215
|
|
|
188
216
|
request.on("connect", (response, socket) => {
|
|
189
|
-
const
|
|
217
|
+
const proxyStatusCode = (response == null ? void 0 : response.statusCode) || ProxyStatus.SERVER_ERROR;
|
|
190
218
|
|
|
191
|
-
if (
|
|
219
|
+
if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START || proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
|
|
192
220
|
request.destroy();
|
|
193
221
|
socket.destroy();
|
|
194
|
-
reject(new Error(`
|
|
222
|
+
reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${(response == null ? void 0 : response.statusMessage) || "Unknown"}`));
|
|
195
223
|
}
|
|
196
224
|
|
|
197
225
|
if (tunnelRequestOptions.timeout) {
|
|
@@ -213,9 +241,11 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
213
241
|
// combine all received buffer streams into one buffer, and then into a string
|
|
214
242
|
const dataString = Buffer.concat([...data]).toString(); // separate each line into it's own entry in an arry
|
|
215
243
|
|
|
216
|
-
const dataStringArray = dataString.split("\r\n"); // the first entry will contain the statusCode
|
|
244
|
+
const dataStringArray = dataString.split("\r\n"); // the first entry will contain the statusCode and statusMessage
|
|
245
|
+
|
|
246
|
+
const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]); // remove "HTTP/1.1" and the status code to get the status message
|
|
217
247
|
|
|
218
|
-
const
|
|
248
|
+
const statusMessage = dataStringArray[0].split(" ").slice(2).join(" "); // the last entry will contain the body
|
|
219
249
|
|
|
220
250
|
const body = dataStringArray[dataStringArray.length - 1]; // everything in between the first and last entries are the headers
|
|
221
251
|
|
|
@@ -245,13 +275,10 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
245
275
|
entries.set(headerKey, headerValue);
|
|
246
276
|
});
|
|
247
277
|
const headers = Object.fromEntries(entries);
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
body: JSON.parse(body),
|
|
251
|
-
status: statusCode
|
|
252
|
-
};
|
|
278
|
+
const parsedHeaders = headers;
|
|
279
|
+
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
|
|
253
280
|
|
|
254
|
-
if ((
|
|
281
|
+
if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START || httpStatusCode > HttpStatus.SUCCESS_RANGE_END) && // do not destroy the request for the device code flow
|
|
255
282
|
networkResponse.body["error"] !== Constants.AUTHORIZATION_PENDING) {
|
|
256
283
|
request.destroy();
|
|
257
284
|
}
|
|
@@ -309,6 +336,7 @@ const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
|
309
336
|
request.on("response", response => {
|
|
310
337
|
const headers = response.headers;
|
|
311
338
|
const statusCode = response.statusCode;
|
|
339
|
+
const statusMessage = response.statusMessage;
|
|
312
340
|
const data = [];
|
|
313
341
|
response.on("data", chunk => {
|
|
314
342
|
data.push(chunk);
|
|
@@ -316,13 +344,10 @@ const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
|
316
344
|
response.on("end", () => {
|
|
317
345
|
// combine all received buffer streams into one buffer, and then into a string
|
|
318
346
|
const body = Buffer.concat([...data]).toString();
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
body: JSON.parse(body),
|
|
322
|
-
status: statusCode
|
|
323
|
-
};
|
|
347
|
+
const parsedHeaders = headers;
|
|
348
|
+
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
|
|
324
349
|
|
|
325
|
-
if ((statusCode <
|
|
350
|
+
if ((statusCode < HttpStatus.SUCCESS_RANGE_START || statusCode > HttpStatus.SUCCESS_RANGE_END) && // do not destroy the request for the device code flow
|
|
326
351
|
networkResponse.body["error"] !== Constants.AUTHORIZATION_PENDING) {
|
|
327
352
|
request.destroy();
|
|
328
353
|
}
|
|
@@ -336,20 +361,51 @@ const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
|
336
361
|
});
|
|
337
362
|
});
|
|
338
363
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
*
|
|
342
|
-
*
|
|
364
|
+
/**
|
|
365
|
+
* Check if extra parsing is needed on the repsonse from the server
|
|
366
|
+
* @param statusCode {number} the status code of the response from the server
|
|
367
|
+
* @param statusMessage {string | undefined} the status message of the response from the server
|
|
368
|
+
* @param headers {Record<string, string>} the headers of the response from the server
|
|
369
|
+
* @param body {string} the body from the response of the server
|
|
370
|
+
* @returns {Object} JSON parsed body or error object
|
|
343
371
|
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
const parseBody = (statusCode, statusMessage, headers, body) => {
|
|
375
|
+
/*
|
|
376
|
+
* Informational responses (100 – 199)
|
|
377
|
+
* Successful responses (200 – 299)
|
|
378
|
+
* Redirection messages (300 – 399)
|
|
379
|
+
* Client error responses (400 – 499)
|
|
380
|
+
* Server error responses (500 – 599)
|
|
381
|
+
*/
|
|
382
|
+
let parsedBody;
|
|
383
|
+
|
|
384
|
+
try {
|
|
385
|
+
parsedBody = JSON.parse(body);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
let errorType;
|
|
388
|
+
let errorDescriptionHelper;
|
|
389
|
+
|
|
390
|
+
if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START && statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
|
|
391
|
+
errorType = "client_error";
|
|
392
|
+
errorDescriptionHelper = "A client";
|
|
393
|
+
} else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START && statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
|
|
394
|
+
errorType = "server_error";
|
|
395
|
+
errorDescriptionHelper = "A server";
|
|
396
|
+
} else {
|
|
397
|
+
errorType = "unknown_error";
|
|
398
|
+
errorDescriptionHelper = "An unknown";
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
parsedBody = {
|
|
402
|
+
error: errorType,
|
|
403
|
+
error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`
|
|
404
|
+
};
|
|
350
405
|
}
|
|
351
406
|
|
|
352
|
-
|
|
407
|
+
return parsedBody;
|
|
408
|
+
};
|
|
353
409
|
|
|
354
410
|
/*
|
|
355
411
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -385,7 +441,7 @@ const DEFAULT_LOGGER_OPTIONS = {
|
|
|
385
441
|
};
|
|
386
442
|
const DEFAULT_SYSTEM_OPTIONS = {
|
|
387
443
|
loggerOptions: DEFAULT_LOGGER_OPTIONS,
|
|
388
|
-
networkClient: /*#__PURE__*/
|
|
444
|
+
networkClient: /*#__PURE__*/new HttpClient(),
|
|
389
445
|
proxyUrl: msalCommon.Constants.EMPTY_STRING
|
|
390
446
|
};
|
|
391
447
|
const DEFAULT_TELEMETRY_OPTIONS = {
|
|
@@ -1769,7 +1825,7 @@ class TokenCache {
|
|
|
1769
1825
|
|
|
1770
1826
|
/* eslint-disable header/header */
|
|
1771
1827
|
const name = "@azure/msal-node";
|
|
1772
|
-
const version = "1.14.
|
|
1828
|
+
const version = "1.14.4";
|
|
1773
1829
|
|
|
1774
1830
|
/*
|
|
1775
1831
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2217,7 +2273,7 @@ class ClientApplication {
|
|
|
2217
2273
|
azureRegionConfiguration,
|
|
2218
2274
|
skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
|
|
2219
2275
|
};
|
|
2220
|
-
return await msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.config.system.proxyUrl);
|
|
2276
|
+
return await msalCommon.AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.logger, this.config.system.proxyUrl);
|
|
2221
2277
|
}
|
|
2222
2278
|
/**
|
|
2223
2279
|
* Clear the cache
|
|
@@ -2407,7 +2463,7 @@ class PublicClientApplication extends ClientApplication {
|
|
|
2407
2463
|
const authCodeListener = loopbackClient.listenForAuthCode(successTemplate, errorTemplate);
|
|
2408
2464
|
const redirectUri = loopbackClient.getRedirectUri();
|
|
2409
2465
|
const validRequest = { ...remainingProperties,
|
|
2410
|
-
scopes: request.scopes ||
|
|
2466
|
+
scopes: request.scopes || msalCommon.OIDC_DEFAULT_SCOPES,
|
|
2411
2467
|
redirectUri: redirectUri,
|
|
2412
2468
|
responseMode: msalCommon.ResponseMode.QUERY,
|
|
2413
2469
|
codeChallenge: challenge,
|
|
@@ -2428,10 +2484,9 @@ class PublicClientApplication extends ClientApplication {
|
|
|
2428
2484
|
const clientInfo = authCodeResponse.client_info;
|
|
2429
2485
|
const tokenRequest = {
|
|
2430
2486
|
code: authCodeResponse.code,
|
|
2431
|
-
scopes: msalCommon.OIDC_DEFAULT_SCOPES,
|
|
2432
|
-
redirectUri: validRequest.redirectUri,
|
|
2433
2487
|
codeVerifier: verifier,
|
|
2434
|
-
clientInfo: clientInfo || msalCommon.Constants.EMPTY_STRING
|
|
2488
|
+
clientInfo: clientInfo || msalCommon.Constants.EMPTY_STRING,
|
|
2489
|
+
...validRequest
|
|
2435
2490
|
};
|
|
2436
2491
|
return this.acquireTokenByCode(tokenRequest);
|
|
2437
2492
|
}
|