@azure/msal-node 1.14.3 → 1.14.5
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/cache/serializer/Deserializer.d.ts.map +1 -1
- package/dist/cache/serializer/Serializer.d.ts.map +1 -1
- package/dist/cache/serializer/SerializerTypes.d.ts +1 -0
- package/dist/cache/serializer/SerializerTypes.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/msal-node.cjs.development.js +95 -38
- 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 +95 -38
- 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
package/dist/msal-node.esm.js
CHANGED
|
@@ -24,9 +24,22 @@ var HttpMethod;
|
|
|
24
24
|
var HttpStatus;
|
|
25
25
|
|
|
26
26
|
(function (HttpStatus) {
|
|
27
|
-
HttpStatus[HttpStatus["
|
|
27
|
+
HttpStatus[HttpStatus["SUCCESS_RANGE_START"] = 200] = "SUCCESS_RANGE_START";
|
|
28
|
+
HttpStatus[HttpStatus["SUCCESS_RANGE_END"] = 299] = "SUCCESS_RANGE_END";
|
|
28
29
|
HttpStatus[HttpStatus["REDIRECT"] = 302] = "REDIRECT";
|
|
30
|
+
HttpStatus[HttpStatus["CLIENT_ERROR_RANGE_START"] = 400] = "CLIENT_ERROR_RANGE_START";
|
|
31
|
+
HttpStatus[HttpStatus["CLIENT_ERROR_RANGE_END"] = 499] = "CLIENT_ERROR_RANGE_END";
|
|
32
|
+
HttpStatus[HttpStatus["SERVER_ERROR_RANGE_START"] = 500] = "SERVER_ERROR_RANGE_START";
|
|
33
|
+
HttpStatus[HttpStatus["SERVER_ERROR_RANGE_END"] = 599] = "SERVER_ERROR_RANGE_END";
|
|
29
34
|
})(HttpStatus || (HttpStatus = {}));
|
|
35
|
+
|
|
36
|
+
var ProxyStatus;
|
|
37
|
+
|
|
38
|
+
(function (ProxyStatus) {
|
|
39
|
+
ProxyStatus[ProxyStatus["SUCCESS_RANGE_START"] = 200] = "SUCCESS_RANGE_START";
|
|
40
|
+
ProxyStatus[ProxyStatus["SUCCESS_RANGE_END"] = 299] = "SUCCESS_RANGE_END";
|
|
41
|
+
ProxyStatus[ProxyStatus["SERVER_ERROR"] = 500] = "SERVER_ERROR";
|
|
42
|
+
})(ProxyStatus || (ProxyStatus = {}));
|
|
30
43
|
/**
|
|
31
44
|
* Constants used for region discovery
|
|
32
45
|
*/
|
|
@@ -103,6 +116,21 @@ const LOOPBACK_SERVER_CONSTANTS = {
|
|
|
103
116
|
TIMEOUT_MS: 5000
|
|
104
117
|
};
|
|
105
118
|
|
|
119
|
+
/*
|
|
120
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
121
|
+
* Licensed under the MIT License.
|
|
122
|
+
*/
|
|
123
|
+
class NetworkUtils {
|
|
124
|
+
static getNetworkResponse(headers, body, statusCode) {
|
|
125
|
+
return {
|
|
126
|
+
headers: headers,
|
|
127
|
+
body: body,
|
|
128
|
+
status: statusCode
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
106
134
|
/*
|
|
107
135
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
108
136
|
* Licensed under the MIT License.
|
|
@@ -180,12 +208,12 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
180
208
|
request.end(); // establish connection to the proxy
|
|
181
209
|
|
|
182
210
|
request.on("connect", (response, socket) => {
|
|
183
|
-
const
|
|
211
|
+
const proxyStatusCode = (response == null ? void 0 : response.statusCode) || ProxyStatus.SERVER_ERROR;
|
|
184
212
|
|
|
185
|
-
if (
|
|
213
|
+
if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START || proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
|
|
186
214
|
request.destroy();
|
|
187
215
|
socket.destroy();
|
|
188
|
-
reject(new Error(`
|
|
216
|
+
reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${(response == null ? void 0 : response.statusMessage) || "Unknown"}`));
|
|
189
217
|
}
|
|
190
218
|
|
|
191
219
|
if (tunnelRequestOptions.timeout) {
|
|
@@ -207,9 +235,11 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
207
235
|
// combine all received buffer streams into one buffer, and then into a string
|
|
208
236
|
const dataString = Buffer.concat([...data]).toString(); // separate each line into it's own entry in an arry
|
|
209
237
|
|
|
210
|
-
const dataStringArray = dataString.split("\r\n"); // the first entry will contain the statusCode
|
|
238
|
+
const dataStringArray = dataString.split("\r\n"); // the first entry will contain the statusCode and statusMessage
|
|
239
|
+
|
|
240
|
+
const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]); // remove "HTTP/1.1" and the status code to get the status message
|
|
211
241
|
|
|
212
|
-
const
|
|
242
|
+
const statusMessage = dataStringArray[0].split(" ").slice(2).join(" "); // the last entry will contain the body
|
|
213
243
|
|
|
214
244
|
const body = dataStringArray[dataStringArray.length - 1]; // everything in between the first and last entries are the headers
|
|
215
245
|
|
|
@@ -239,13 +269,10 @@ const networkRequestViaProxy = (url, httpMethod, options, timeout) => {
|
|
|
239
269
|
entries.set(headerKey, headerValue);
|
|
240
270
|
});
|
|
241
271
|
const headers = Object.fromEntries(entries);
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
body: JSON.parse(body),
|
|
245
|
-
status: statusCode
|
|
246
|
-
};
|
|
272
|
+
const parsedHeaders = headers;
|
|
273
|
+
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
|
|
247
274
|
|
|
248
|
-
if ((
|
|
275
|
+
if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START || httpStatusCode > HttpStatus.SUCCESS_RANGE_END) && // do not destroy the request for the device code flow
|
|
249
276
|
networkResponse.body["error"] !== Constants.AUTHORIZATION_PENDING) {
|
|
250
277
|
request.destroy();
|
|
251
278
|
}
|
|
@@ -303,6 +330,7 @@ const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
|
303
330
|
request.on("response", response => {
|
|
304
331
|
const headers = response.headers;
|
|
305
332
|
const statusCode = response.statusCode;
|
|
333
|
+
const statusMessage = response.statusMessage;
|
|
306
334
|
const data = [];
|
|
307
335
|
response.on("data", chunk => {
|
|
308
336
|
data.push(chunk);
|
|
@@ -310,13 +338,10 @@ const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
|
310
338
|
response.on("end", () => {
|
|
311
339
|
// combine all received buffer streams into one buffer, and then into a string
|
|
312
340
|
const body = Buffer.concat([...data]).toString();
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
body: JSON.parse(body),
|
|
316
|
-
status: statusCode
|
|
317
|
-
};
|
|
341
|
+
const parsedHeaders = headers;
|
|
342
|
+
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
|
|
318
343
|
|
|
319
|
-
if ((statusCode <
|
|
344
|
+
if ((statusCode < HttpStatus.SUCCESS_RANGE_START || statusCode > HttpStatus.SUCCESS_RANGE_END) && // do not destroy the request for the device code flow
|
|
320
345
|
networkResponse.body["error"] !== Constants.AUTHORIZATION_PENDING) {
|
|
321
346
|
request.destroy();
|
|
322
347
|
}
|
|
@@ -330,20 +355,51 @@ const networkRequestViaHttps = (url, httpMethod, options, timeout) => {
|
|
|
330
355
|
});
|
|
331
356
|
});
|
|
332
357
|
};
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
*
|
|
336
|
-
*
|
|
358
|
+
/**
|
|
359
|
+
* Check if extra parsing is needed on the repsonse from the server
|
|
360
|
+
* @param statusCode {number} the status code of the response from the server
|
|
361
|
+
* @param statusMessage {string | undefined} the status message of the response from the server
|
|
362
|
+
* @param headers {Record<string, string>} the headers of the response from the server
|
|
363
|
+
* @param body {string} the body from the response of the server
|
|
364
|
+
* @returns {Object} JSON parsed body or error object
|
|
337
365
|
*/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
const parseBody = (statusCode, statusMessage, headers, body) => {
|
|
369
|
+
/*
|
|
370
|
+
* Informational responses (100 – 199)
|
|
371
|
+
* Successful responses (200 – 299)
|
|
372
|
+
* Redirection messages (300 – 399)
|
|
373
|
+
* Client error responses (400 – 499)
|
|
374
|
+
* Server error responses (500 – 599)
|
|
375
|
+
*/
|
|
376
|
+
let parsedBody;
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
parsedBody = JSON.parse(body);
|
|
380
|
+
} catch (error) {
|
|
381
|
+
let errorType;
|
|
382
|
+
let errorDescriptionHelper;
|
|
383
|
+
|
|
384
|
+
if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START && statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
|
|
385
|
+
errorType = "client_error";
|
|
386
|
+
errorDescriptionHelper = "A client";
|
|
387
|
+
} else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START && statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
|
|
388
|
+
errorType = "server_error";
|
|
389
|
+
errorDescriptionHelper = "A server";
|
|
390
|
+
} else {
|
|
391
|
+
errorType = "unknown_error";
|
|
392
|
+
errorDescriptionHelper = "An unknown";
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
parsedBody = {
|
|
396
|
+
error: errorType,
|
|
397
|
+
error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`
|
|
398
|
+
};
|
|
344
399
|
}
|
|
345
400
|
|
|
346
|
-
|
|
401
|
+
return parsedBody;
|
|
402
|
+
};
|
|
347
403
|
|
|
348
404
|
/*
|
|
349
405
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -379,7 +435,7 @@ const DEFAULT_LOGGER_OPTIONS = {
|
|
|
379
435
|
};
|
|
380
436
|
const DEFAULT_SYSTEM_OPTIONS = {
|
|
381
437
|
loggerOptions: DEFAULT_LOGGER_OPTIONS,
|
|
382
|
-
networkClient: /*#__PURE__*/
|
|
438
|
+
networkClient: /*#__PURE__*/new HttpClient(),
|
|
383
439
|
proxyUrl: Constants$1.EMPTY_STRING
|
|
384
440
|
};
|
|
385
441
|
const DEFAULT_TELEMETRY_OPTIONS = {
|
|
@@ -779,7 +835,8 @@ class Deserializer {
|
|
|
779
835
|
keyId: serializedAT.key_id,
|
|
780
836
|
tokenType: serializedAT.token_type,
|
|
781
837
|
requestedClaims: serializedAT.requestedClaims,
|
|
782
|
-
requestedClaimsHash: serializedAT.requestedClaimsHash
|
|
838
|
+
requestedClaimsHash: serializedAT.requestedClaimsHash,
|
|
839
|
+
userAssertionHash: serializedAT.userAssertionHash
|
|
783
840
|
};
|
|
784
841
|
const accessToken = new AccessTokenEntity();
|
|
785
842
|
CacheManager.toObject(accessToken, mappedAT);
|
|
@@ -945,7 +1002,8 @@ class Serializer {
|
|
|
945
1002
|
key_id: atEntity.keyId,
|
|
946
1003
|
token_type: atEntity.tokenType,
|
|
947
1004
|
requestedClaims: atEntity.requestedClaims,
|
|
948
|
-
requestedClaimsHash: atEntity.requestedClaimsHash
|
|
1005
|
+
requestedClaimsHash: atEntity.requestedClaimsHash,
|
|
1006
|
+
userAssertionHash: atEntity.userAssertionHash
|
|
949
1007
|
};
|
|
950
1008
|
});
|
|
951
1009
|
return accessTokens;
|
|
@@ -1763,7 +1821,7 @@ class TokenCache {
|
|
|
1763
1821
|
|
|
1764
1822
|
/* eslint-disable header/header */
|
|
1765
1823
|
const name = "@azure/msal-node";
|
|
1766
|
-
const version = "1.14.
|
|
1824
|
+
const version = "1.14.5";
|
|
1767
1825
|
|
|
1768
1826
|
/*
|
|
1769
1827
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2211,7 +2269,7 @@ class ClientApplication {
|
|
|
2211
2269
|
azureRegionConfiguration,
|
|
2212
2270
|
skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
|
|
2213
2271
|
};
|
|
2214
|
-
return await AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.config.system.proxyUrl);
|
|
2272
|
+
return await AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.logger, this.config.system.proxyUrl);
|
|
2215
2273
|
}
|
|
2216
2274
|
/**
|
|
2217
2275
|
* Clear the cache
|
|
@@ -2401,7 +2459,7 @@ class PublicClientApplication extends ClientApplication {
|
|
|
2401
2459
|
const authCodeListener = loopbackClient.listenForAuthCode(successTemplate, errorTemplate);
|
|
2402
2460
|
const redirectUri = loopbackClient.getRedirectUri();
|
|
2403
2461
|
const validRequest = { ...remainingProperties,
|
|
2404
|
-
scopes: request.scopes ||
|
|
2462
|
+
scopes: request.scopes || OIDC_DEFAULT_SCOPES,
|
|
2405
2463
|
redirectUri: redirectUri,
|
|
2406
2464
|
responseMode: ResponseMode.QUERY,
|
|
2407
2465
|
codeChallenge: challenge,
|
|
@@ -2422,10 +2480,9 @@ class PublicClientApplication extends ClientApplication {
|
|
|
2422
2480
|
const clientInfo = authCodeResponse.client_info;
|
|
2423
2481
|
const tokenRequest = {
|
|
2424
2482
|
code: authCodeResponse.code,
|
|
2425
|
-
scopes: OIDC_DEFAULT_SCOPES,
|
|
2426
|
-
redirectUri: validRequest.redirectUri,
|
|
2427
2483
|
codeVerifier: verifier,
|
|
2428
|
-
clientInfo: clientInfo || Constants$1.EMPTY_STRING
|
|
2484
|
+
clientInfo: clientInfo || Constants$1.EMPTY_STRING,
|
|
2485
|
+
...validRequest
|
|
2429
2486
|
};
|
|
2430
2487
|
return this.acquireTokenByCode(tokenRequest);
|
|
2431
2488
|
}
|