Commit iniziale
This commit is contained in:
26
node_modules/@azure/msal-node/dist/network/HttpClient.d.ts
generated
vendored
Normal file
26
node_modules/@azure/msal-node/dist/network/HttpClient.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/// <reference types="node" resolution-mode="require"/>
|
||||
/// <reference types="node" resolution-mode="require"/>
|
||||
import { INetworkModule, NetworkRequestOptions, NetworkResponse } from "@azure/msal-common/node";
|
||||
import http from "http";
|
||||
import https from "https";
|
||||
/**
|
||||
* This class implements the API for network requests.
|
||||
*/
|
||||
export declare class HttpClient implements INetworkModule {
|
||||
private proxyUrl;
|
||||
private customAgentOptions;
|
||||
constructor(proxyUrl?: string, customAgentOptions?: http.AgentOptions | https.AgentOptions);
|
||||
/**
|
||||
* Http Get request
|
||||
* @param url
|
||||
* @param options
|
||||
*/
|
||||
sendGetRequestAsync<T>(url: string, options?: NetworkRequestOptions, timeout?: number): Promise<NetworkResponse<T>>;
|
||||
/**
|
||||
* Http Post request
|
||||
* @param url
|
||||
* @param options
|
||||
*/
|
||||
sendPostRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
||||
}
|
||||
//# sourceMappingURL=HttpClient.d.ts.map
|
||||
1
node_modules/@azure/msal-node/dist/network/HttpClient.d.ts.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/HttpClient.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/network/HttpClient.ts"],"names":[],"mappings":";;AAKA,OAAO,EACH,cAAc,EACd,qBAAqB,EACrB,eAAe,EAElB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC7C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,kBAAkB,CAAyC;gBAG/D,QAAQ,CAAC,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY;IAM/D;;;;OAIG;IACG,mBAAmB,CAAC,CAAC,EACvB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAqB9B;;;;OAIG;IACG,oBAAoB,CAAC,CAAC,EACxB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,GAChC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CAkBjC"}
|
||||
292
node_modules/@azure/msal-node/dist/network/HttpClient.mjs
generated
vendored
Normal file
292
node_modules/@azure/msal-node/dist/network/HttpClient.mjs
generated
vendored
Normal file
@@ -0,0 +1,292 @@
|
||||
/*! @azure/msal-node v2.16.2 2024-11-19 */
|
||||
'use strict';
|
||||
import { HttpStatus } from '@azure/msal-common/node';
|
||||
import { ProxyStatus, Constants, HttpMethod } from '../utils/Constants.mjs';
|
||||
import { NetworkUtils } from '../utils/NetworkUtils.mjs';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
/**
|
||||
* This class implements the API for network requests.
|
||||
*/
|
||||
class HttpClient {
|
||||
constructor(proxyUrl, customAgentOptions) {
|
||||
this.proxyUrl = proxyUrl || "";
|
||||
this.customAgentOptions = customAgentOptions || {};
|
||||
}
|
||||
/**
|
||||
* Http Get request
|
||||
* @param url
|
||||
* @param options
|
||||
*/
|
||||
async sendGetRequestAsync(url, options, timeout) {
|
||||
if (this.proxyUrl) {
|
||||
return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.GET, options, this.customAgentOptions, timeout);
|
||||
}
|
||||
else {
|
||||
return networkRequestViaHttps(url, HttpMethod.GET, options, this.customAgentOptions, timeout);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Http Post request
|
||||
* @param url
|
||||
* @param options
|
||||
*/
|
||||
async sendPostRequestAsync(url, options) {
|
||||
if (this.proxyUrl) {
|
||||
return networkRequestViaProxy(url, this.proxyUrl, HttpMethod.POST, options, this.customAgentOptions);
|
||||
}
|
||||
else {
|
||||
return networkRequestViaHttps(url, HttpMethod.POST, options, this.customAgentOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
const networkRequestViaProxy = (destinationUrlString, proxyUrlString, httpMethod, options, agentOptions, timeout) => {
|
||||
const destinationUrl = new URL(destinationUrlString);
|
||||
const proxyUrl = new URL(proxyUrlString);
|
||||
// "method: connect" must be used to establish a connection to the proxy
|
||||
const headers = options?.headers || {};
|
||||
const tunnelRequestOptions = {
|
||||
host: proxyUrl.hostname,
|
||||
port: proxyUrl.port,
|
||||
method: "CONNECT",
|
||||
path: destinationUrl.hostname,
|
||||
headers: headers,
|
||||
};
|
||||
if (agentOptions && Object.keys(agentOptions).length) {
|
||||
tunnelRequestOptions.agent = new http.Agent(agentOptions);
|
||||
}
|
||||
// compose a request string for the socket
|
||||
let postRequestStringContent = "";
|
||||
if (httpMethod === HttpMethod.POST) {
|
||||
const body = options?.body || "";
|
||||
postRequestStringContent =
|
||||
"Content-Type: application/x-www-form-urlencoded\r\n" +
|
||||
`Content-Length: ${body.length}\r\n` +
|
||||
`\r\n${body}`;
|
||||
}
|
||||
else {
|
||||
// optional timeout is only for get requests (regionDiscovery, for example)
|
||||
if (timeout) {
|
||||
tunnelRequestOptions.timeout = timeout;
|
||||
}
|
||||
}
|
||||
const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
|
||||
`Host: ${destinationUrl.host}\r\n` +
|
||||
"Connection: close\r\n" +
|
||||
postRequestStringContent +
|
||||
"\r\n";
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = http.request(tunnelRequestOptions);
|
||||
if (timeout) {
|
||||
request.on("timeout", () => {
|
||||
request.destroy();
|
||||
reject(new Error("Request time out"));
|
||||
});
|
||||
}
|
||||
request.end();
|
||||
// establish connection to the proxy
|
||||
request.on("connect", (response, socket) => {
|
||||
const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
|
||||
if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
|
||||
proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
|
||||
request.destroy();
|
||||
socket.destroy();
|
||||
reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
|
||||
}
|
||||
// make a request over an HTTP tunnel
|
||||
socket.write(outgoingRequestString);
|
||||
const data = [];
|
||||
socket.on("data", (chunk) => {
|
||||
data.push(chunk);
|
||||
});
|
||||
socket.on("end", () => {
|
||||
// combine all received buffer streams into one buffer, and then into a string
|
||||
const dataString = Buffer.concat([...data]).toString();
|
||||
// separate each line into it's own entry in an arry
|
||||
const dataStringArray = dataString.split("\r\n");
|
||||
// the first entry will contain the statusCode and statusMessage
|
||||
const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
|
||||
// remove "HTTP/1.1" and the status code to get the status message
|
||||
const statusMessage = dataStringArray[0]
|
||||
.split(" ")
|
||||
.slice(2)
|
||||
.join(" ");
|
||||
// the last entry will contain the body
|
||||
const body = dataStringArray[dataStringArray.length - 1];
|
||||
// everything in between the first and last entries are the headers
|
||||
const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
|
||||
// build an object out of all the headers
|
||||
const entries = new Map();
|
||||
headersArray.forEach((header) => {
|
||||
/**
|
||||
* the header might look like "Content-Length: 1531", but that is just a string
|
||||
* it needs to be converted to a key/value pair
|
||||
* split the string at the first instance of ":"
|
||||
* there may be more than one ":" if the value of the header is supposed to be a JSON object
|
||||
*/
|
||||
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
||||
const headerKey = headerKeyValue[0];
|
||||
let headerValue = headerKeyValue[1];
|
||||
// check if the value of the header is supposed to be a JSON object
|
||||
try {
|
||||
const object = JSON.parse(headerValue);
|
||||
// if it is, then convert it from a string to a JSON object
|
||||
if (object && typeof object === "object") {
|
||||
headerValue = object;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// otherwise, leave it as a string
|
||||
}
|
||||
entries.set(headerKey, headerValue);
|
||||
});
|
||||
const headers = Object.fromEntries(entries);
|
||||
const parsedHeaders = headers;
|
||||
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
|
||||
if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START ||
|
||||
httpStatusCode > HttpStatus.SUCCESS_RANGE_END) &&
|
||||
// do not destroy the request for the device code flow
|
||||
networkResponse.body["error"] !==
|
||||
Constants.AUTHORIZATION_PENDING) {
|
||||
request.destroy();
|
||||
}
|
||||
resolve(networkResponse);
|
||||
});
|
||||
socket.on("error", (chunk) => {
|
||||
request.destroy();
|
||||
socket.destroy();
|
||||
reject(new Error(chunk.toString()));
|
||||
});
|
||||
});
|
||||
request.on("error", (chunk) => {
|
||||
request.destroy();
|
||||
reject(new Error(chunk.toString()));
|
||||
});
|
||||
});
|
||||
};
|
||||
const networkRequestViaHttps = (urlString, httpMethod, options, agentOptions, timeout) => {
|
||||
const isPostRequest = httpMethod === HttpMethod.POST;
|
||||
const body = options?.body || "";
|
||||
const url = new URL(urlString);
|
||||
const headers = options?.headers || {};
|
||||
const customOptions = {
|
||||
method: httpMethod,
|
||||
headers: headers,
|
||||
...NetworkUtils.urlToHttpOptions(url),
|
||||
};
|
||||
if (agentOptions && Object.keys(agentOptions).length) {
|
||||
customOptions.agent = new https.Agent(agentOptions);
|
||||
}
|
||||
if (isPostRequest) {
|
||||
// needed for post request to work
|
||||
customOptions.headers = {
|
||||
...customOptions.headers,
|
||||
"Content-Length": body.length,
|
||||
};
|
||||
}
|
||||
else {
|
||||
// optional timeout is only for get requests (regionDiscovery, for example)
|
||||
if (timeout) {
|
||||
customOptions.timeout = timeout;
|
||||
}
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let request;
|
||||
// managed identity sources use http instead of https
|
||||
if (customOptions.protocol === "http:") {
|
||||
request = http.request(customOptions);
|
||||
}
|
||||
else {
|
||||
request = https.request(customOptions);
|
||||
}
|
||||
if (isPostRequest) {
|
||||
request.write(body);
|
||||
}
|
||||
if (timeout) {
|
||||
request.on("timeout", () => {
|
||||
request.destroy();
|
||||
reject(new Error("Request time out"));
|
||||
});
|
||||
}
|
||||
request.end();
|
||||
request.on("response", (response) => {
|
||||
const headers = response.headers;
|
||||
const statusCode = response.statusCode;
|
||||
const statusMessage = response.statusMessage;
|
||||
const data = [];
|
||||
response.on("data", (chunk) => {
|
||||
data.push(chunk);
|
||||
});
|
||||
response.on("end", () => {
|
||||
// combine all received buffer streams into one buffer, and then into a string
|
||||
const body = Buffer.concat([...data]).toString();
|
||||
const parsedHeaders = headers;
|
||||
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
|
||||
if ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
|
||||
statusCode > HttpStatus.SUCCESS_RANGE_END) &&
|
||||
// do not destroy the request for the device code flow
|
||||
networkResponse.body["error"] !==
|
||||
Constants.AUTHORIZATION_PENDING) {
|
||||
request.destroy();
|
||||
}
|
||||
resolve(networkResponse);
|
||||
});
|
||||
});
|
||||
request.on("error", (chunk) => {
|
||||
request.destroy();
|
||||
reject(new Error(chunk.toString()));
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Check if extra parsing is needed on the repsonse from the server
|
||||
* @param statusCode {number} the status code of the response from the server
|
||||
* @param statusMessage {string | undefined} the status message of the response from the server
|
||||
* @param headers {Record<string, string>} the headers of the response from the server
|
||||
* @param body {string} the body from the response of the server
|
||||
* @returns {Object} JSON parsed body or error object
|
||||
*/
|
||||
const parseBody = (statusCode, statusMessage, headers, body) => {
|
||||
/*
|
||||
* Informational responses (100 – 199)
|
||||
* Successful responses (200 – 299)
|
||||
* Redirection messages (300 – 399)
|
||||
* Client error responses (400 – 499)
|
||||
* Server error responses (500 – 599)
|
||||
*/
|
||||
let parsedBody;
|
||||
try {
|
||||
parsedBody = JSON.parse(body);
|
||||
}
|
||||
catch (error) {
|
||||
let errorType;
|
||||
let errorDescriptionHelper;
|
||||
if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
|
||||
statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
|
||||
errorType = "client_error";
|
||||
errorDescriptionHelper = "A client";
|
||||
}
|
||||
else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
|
||||
statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
|
||||
errorType = "server_error";
|
||||
errorDescriptionHelper = "A server";
|
||||
}
|
||||
else {
|
||||
errorType = "unknown_error";
|
||||
errorDescriptionHelper = "An unknown";
|
||||
}
|
||||
parsedBody = {
|
||||
error: errorType,
|
||||
error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
|
||||
};
|
||||
}
|
||||
return parsedBody;
|
||||
};
|
||||
|
||||
export { HttpClient };
|
||||
//# sourceMappingURL=HttpClient.mjs.map
|
||||
1
node_modules/@azure/msal-node/dist/network/HttpClient.mjs.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/HttpClient.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.d.ts
generated
vendored
Normal file
12
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { INetworkModule, NetworkRequestOptions, NetworkResponse } from "@azure/msal-common/node";
|
||||
import { IHttpRetryPolicy } from "../retry/IHttpRetryPolicy.js";
|
||||
export declare class HttpClientWithRetries implements INetworkModule {
|
||||
private httpClientNoRetries;
|
||||
private retryPolicy;
|
||||
constructor(httpClientNoRetries: INetworkModule, retryPolicy: IHttpRetryPolicy);
|
||||
private sendNetworkRequestAsyncHelper;
|
||||
private sendNetworkRequestAsync;
|
||||
sendGetRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
||||
sendPostRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
||||
}
|
||||
//# sourceMappingURL=HttpClientWithRetries.d.ts.map
|
||||
1
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.d.ts.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HttpClientWithRetries.d.ts","sourceRoot":"","sources":["../../src/network/HttpClientWithRetries.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,cAAc,EACd,qBAAqB,EACrB,eAAe,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,qBAAa,qBAAsB,YAAW,cAAc;IACxD,OAAO,CAAC,mBAAmB,CAAiB;IAC5C,OAAO,CAAC,WAAW,CAAmB;gBAGlC,mBAAmB,EAAE,cAAc,EACnC,WAAW,EAAE,gBAAgB;YAMnB,6BAA6B;YAY7B,uBAAuB;IA4BxB,mBAAmB,CAAC,CAAC,EAC9B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,GAChC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAIjB,oBAAoB,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,qBAAqB,GAChC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CAGjC"}
|
||||
42
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.mjs
generated
vendored
Normal file
42
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.mjs
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*! @azure/msal-node v2.16.2 2024-11-19 */
|
||||
'use strict';
|
||||
import { HeaderNames } from '@azure/msal-common/node';
|
||||
import { HttpMethod } from '../utils/Constants.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
class HttpClientWithRetries {
|
||||
constructor(httpClientNoRetries, retryPolicy) {
|
||||
this.httpClientNoRetries = httpClientNoRetries;
|
||||
this.retryPolicy = retryPolicy;
|
||||
}
|
||||
async sendNetworkRequestAsyncHelper(httpMethod, url, options) {
|
||||
if (httpMethod === HttpMethod.GET) {
|
||||
return this.httpClientNoRetries.sendGetRequestAsync(url, options);
|
||||
}
|
||||
else {
|
||||
return this.httpClientNoRetries.sendPostRequestAsync(url, options);
|
||||
}
|
||||
}
|
||||
async sendNetworkRequestAsync(httpMethod, url, options) {
|
||||
// the underlying network module (custom or HttpClient) will make the call
|
||||
let response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
|
||||
let currentRetry = 0;
|
||||
while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, response.headers[HeaderNames.RETRY_AFTER])) {
|
||||
response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
|
||||
currentRetry++;
|
||||
}
|
||||
return response;
|
||||
}
|
||||
async sendGetRequestAsync(url, options) {
|
||||
return this.sendNetworkRequestAsync(HttpMethod.GET, url, options);
|
||||
}
|
||||
async sendPostRequestAsync(url, options) {
|
||||
return this.sendNetworkRequestAsync(HttpMethod.POST, url, options);
|
||||
}
|
||||
}
|
||||
|
||||
export { HttpClientWithRetries };
|
||||
//# sourceMappingURL=HttpClientWithRetries.mjs.map
|
||||
1
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.mjs.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/HttpClientWithRetries.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HttpClientWithRetries.mjs","sources":["../../src/network/HttpClientWithRetries.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;;;AAGG;MAWU,qBAAqB,CAAA;IAI9B,WACI,CAAA,mBAAmC,EACnC,WAA6B,EAAA;AAE7B,QAAA,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;AAC/C,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;KAClC;AAEO,IAAA,MAAM,6BAA6B,CACvC,UAAsB,EACtB,GAAW,EACX,OAA+B,EAAA;AAE/B,QAAA,IAAI,UAAU,KAAK,UAAU,CAAC,GAAG,EAAE;YAC/B,OAAO,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACrE,SAAA;AAAM,aAAA;YACH,OAAO,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACtE,SAAA;KACJ;AAEO,IAAA,MAAM,uBAAuB,CACjC,UAAsB,EACtB,GAAW,EACX,OAA+B,EAAA;;AAG/B,QAAA,IAAI,QAAQ,GACR,MAAM,IAAI,CAAC,6BAA6B,CAAC,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QAEvE,IAAI,YAAY,GAAW,CAAC,CAAC;QAC7B,OACI,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAChC,QAAQ,CAAC,MAAM,EACf,YAAY,EACZ,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAC5C,EACH;AACE,YAAA,QAAQ,GAAG,MAAM,IAAI,CAAC,6BAA6B,CAC/C,UAAU,EACV,GAAG,EACH,OAAO,CACV,CAAC;AACF,YAAA,YAAY,EAAE,CAAC;AAClB,SAAA;AAED,QAAA,OAAO,QAAQ,CAAC;KACnB;AAEM,IAAA,MAAM,mBAAmB,CAC5B,GAAW,EACX,OAA+B,EAAA;AAE/B,QAAA,OAAO,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;KACrE;AAEM,IAAA,MAAM,oBAAoB,CAC7B,GAAW,EACX,OAA+B,EAAA;AAE/B,QAAA,OAAO,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;KACtE;AACJ;;;;"}
|
||||
11
node_modules/@azure/msal-node/dist/network/ILoopbackClient.d.ts
generated
vendored
Normal file
11
node_modules/@azure/msal-node/dist/network/ILoopbackClient.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ServerAuthorizationCodeResponse } from "@azure/msal-common/node";
|
||||
/**
|
||||
* Interface for LoopbackClient allowing to replace the default loopback server with a custom implementation.
|
||||
* @public
|
||||
*/
|
||||
export interface ILoopbackClient {
|
||||
listenForAuthCode(successTemplate?: string, errorTemplate?: string): Promise<ServerAuthorizationCodeResponse>;
|
||||
getRedirectUri(): string;
|
||||
closeServer(): void;
|
||||
}
|
||||
//# sourceMappingURL=ILoopbackClient.d.ts.map
|
||||
1
node_modules/@azure/msal-node/dist/network/ILoopbackClient.d.ts.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/ILoopbackClient.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ILoopbackClient.d.ts","sourceRoot":"","sources":["../../src/network/ILoopbackClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,iBAAiB,CACb,eAAe,CAAC,EAAE,MAAM,EACxB,aAAa,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAC5C,cAAc,IAAI,MAAM,CAAC;IACzB,WAAW,IAAI,IAAI,CAAC;CACvB"}
|
||||
22
node_modules/@azure/msal-node/dist/network/LoopbackClient.d.ts
generated
vendored
Normal file
22
node_modules/@azure/msal-node/dist/network/LoopbackClient.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { ServerAuthorizationCodeResponse } from "@azure/msal-common/node";
|
||||
import { ILoopbackClient } from "./ILoopbackClient.js";
|
||||
export declare class LoopbackClient implements ILoopbackClient {
|
||||
private server;
|
||||
/**
|
||||
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
|
||||
* @param successTemplate
|
||||
* @param errorTemplate
|
||||
* @returns
|
||||
*/
|
||||
listenForAuthCode(successTemplate?: string, errorTemplate?: string): Promise<ServerAuthorizationCodeResponse>;
|
||||
/**
|
||||
* Get the port that the loopback server is running on
|
||||
* @returns
|
||||
*/
|
||||
getRedirectUri(): string;
|
||||
/**
|
||||
* Close the loopback server
|
||||
*/
|
||||
closeServer(): void;
|
||||
}
|
||||
//# sourceMappingURL=LoopbackClient.d.ts.map
|
||||
1
node_modules/@azure/msal-node/dist/network/LoopbackClient.d.ts.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/LoopbackClient.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LoopbackClient.d.ts","sourceRoot":"","sources":["../../src/network/LoopbackClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,+BAA+B,EAGlC,MAAM,yBAAyB,CAAC;AAIjC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,qBAAa,cAAe,YAAW,eAAe;IAClD,OAAO,CAAC,MAAM,CAA0B;IAExC;;;;;OAKG;IACG,iBAAiB,CACnB,eAAe,CAAC,EAAE,MAAM,EACxB,aAAa,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,+BAA+B,CAAC;IAqD3C;;;OAGG;IACH,cAAc,IAAI,MAAM;IAgBxB;;OAEG;IACH,WAAW,IAAI,IAAI;CAetB"}
|
||||
91
node_modules/@azure/msal-node/dist/network/LoopbackClient.mjs
generated
vendored
Normal file
91
node_modules/@azure/msal-node/dist/network/LoopbackClient.mjs
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
/*! @azure/msal-node v2.16.2 2024-11-19 */
|
||||
'use strict';
|
||||
import { Constants, UrlUtils, HttpStatus } from '@azure/msal-common/node';
|
||||
import http from 'http';
|
||||
import { NodeAuthError } from '../error/NodeAuthError.mjs';
|
||||
import { Constants as Constants$1 } from '../utils/Constants.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
class LoopbackClient {
|
||||
/**
|
||||
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
|
||||
* @param successTemplate
|
||||
* @param errorTemplate
|
||||
* @returns
|
||||
*/
|
||||
async listenForAuthCode(successTemplate, errorTemplate) {
|
||||
if (this.server) {
|
||||
throw NodeAuthError.createLoopbackServerAlreadyExistsError();
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
this.server = http.createServer((req, res) => {
|
||||
const url = req.url;
|
||||
if (!url) {
|
||||
res.end(errorTemplate ||
|
||||
"Error occurred loading redirectUrl");
|
||||
reject(NodeAuthError.createUnableToLoadRedirectUrlError());
|
||||
return;
|
||||
}
|
||||
else if (url === Constants.FORWARD_SLASH) {
|
||||
res.end(successTemplate ||
|
||||
"Auth code was successfully acquired. You can close this window now.");
|
||||
return;
|
||||
}
|
||||
const redirectUri = this.getRedirectUri();
|
||||
const parsedUrl = new URL(url, redirectUri);
|
||||
const authCodeResponse = UrlUtils.getDeserializedResponse(parsedUrl.search) || {};
|
||||
if (authCodeResponse.code) {
|
||||
res.writeHead(HttpStatus.REDIRECT, {
|
||||
location: redirectUri,
|
||||
}); // Prevent auth code from being saved in the browser history
|
||||
res.end();
|
||||
}
|
||||
if (authCodeResponse.error) {
|
||||
res.end(errorTemplate ||
|
||||
`Error occurred: ${authCodeResponse.error}`);
|
||||
}
|
||||
resolve(authCodeResponse);
|
||||
});
|
||||
this.server.listen(0, "127.0.0.1"); // Listen on any available port
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get the port that the loopback server is running on
|
||||
* @returns
|
||||
*/
|
||||
getRedirectUri() {
|
||||
if (!this.server || !this.server.listening) {
|
||||
throw NodeAuthError.createNoLoopbackServerExistsError();
|
||||
}
|
||||
const address = this.server.address();
|
||||
if (!address || typeof address === "string" || !address.port) {
|
||||
this.closeServer();
|
||||
throw NodeAuthError.createInvalidLoopbackAddressTypeError();
|
||||
}
|
||||
const port = address && address.port;
|
||||
return `${Constants$1.HTTP_PROTOCOL}${Constants$1.LOCALHOST}:${port}`;
|
||||
}
|
||||
/**
|
||||
* Close the loopback server
|
||||
*/
|
||||
closeServer() {
|
||||
if (this.server) {
|
||||
// Only stops accepting new connections, server will close once open/idle connections are closed.
|
||||
this.server.close();
|
||||
if (typeof this.server.closeAllConnections === "function") {
|
||||
/*
|
||||
* Close open/idle connections. This API is available in Node versions 18.2 and higher
|
||||
*/
|
||||
this.server.closeAllConnections();
|
||||
}
|
||||
this.server.unref();
|
||||
this.server = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { LoopbackClient };
|
||||
//# sourceMappingURL=LoopbackClient.mjs.map
|
||||
1
node_modules/@azure/msal-node/dist/network/LoopbackClient.mjs.map
generated
vendored
Normal file
1
node_modules/@azure/msal-node/dist/network/LoopbackClient.mjs.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LoopbackClient.mjs","sources":["../../src/network/LoopbackClient.ts"],"sourcesContent":[null],"names":["CommonConstants","Constants"],"mappings":";;;;;;;AAAA;;;AAGG;MAaU,cAAc,CAAA;AAGvB;;;;;AAKG;AACH,IAAA,MAAM,iBAAiB,CACnB,eAAwB,EACxB,aAAsB,EAAA;QAEtB,IAAI,IAAI,CAAC,MAAM,EAAE;AACb,YAAA,MAAM,aAAa,C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