Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed http(s) import errors in msal-node #6349

Merged
merged 6 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fixed http(s) imports",
"packageName": "@azure/msal-node",
"email": "rginsburg@microsoft.com",
"dependentChangeType": "patch"
}
10 changes: 5 additions & 5 deletions lib/msal-node/src/config/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
INativeBrokerPlugin,
} from "@azure/msal-common";
import { HttpClient } from "../network/HttpClient";
import { AgentOptions as httpAgentOptions } from "http";
import { AgentOptions as httpsAgentOptions } from "https";
import http from "http";
import https from "https";

/**
* - clientId - Client id of the application.
Expand Down Expand Up @@ -82,7 +82,7 @@ export type NodeSystemOptions = {
loggerOptions?: LoggerOptions;
networkClient?: INetworkModule;
proxyUrl?: string;
customAgentOptions?: httpAgentOptions | httpsAgentOptions;
customAgentOptions?: http.AgentOptions | https.AgentOptions;
};

export type NodeTelemetryOptions = {
Expand Down Expand Up @@ -145,7 +145,7 @@ const DEFAULT_SYSTEM_OPTIONS: Required<NodeSystemOptions> = {
loggerOptions: DEFAULT_LOGGER_OPTIONS,
networkClient: new HttpClient(),
proxyUrl: Constants.EMPTY_STRING,
customAgentOptions: {} as httpAgentOptions | httpsAgentOptions,
customAgentOptions: {} as http.AgentOptions | https.AgentOptions,
};

const DEFAULT_TELEMETRY_OPTIONS: Required<NodeTelemetryOptions> = {
Expand Down Expand Up @@ -185,7 +185,7 @@ export function buildAppConfiguration({
...DEFAULT_SYSTEM_OPTIONS,
networkClient: new HttpClient(
system?.proxyUrl,
system?.customAgentOptions as httpAgentOptions | httpsAgentOptions
system?.customAgentOptions as http.AgentOptions | https.AgentOptions
),
loggerOptions: system?.loggerOptions || DEFAULT_LOGGER_OPTIONS,
};
Expand Down
8 changes: 4 additions & 4 deletions lib/msal-node/src/network/LoopbackClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ServerAuthorizationCodeResponse,
UrlString,
} from "@azure/msal-common";
import { createServer, IncomingMessage, Server, ServerResponse } from "http";
import http from "http";
import { NodeAuthError } from "../error/NodeAuthError";
import {
Constants,
Expand All @@ -18,7 +18,7 @@ import {
import { ILoopbackClient } from "./ILoopbackClient";

export class LoopbackClient implements ILoopbackClient {
private server: Server;
private server: http.Server;

/**
* Spins up a loopback server which returns the server response when the localhost redirectUri is hit
Expand All @@ -36,8 +36,8 @@ export class LoopbackClient implements ILoopbackClient {

const authCodeListener = new Promise<ServerAuthorizationCodeResponse>(
(resolve, reject) => {
this.server = createServer(
async (req: IncomingMessage, res: ServerResponse) => {
this.server = http.createServer(
async (req: http.IncomingMessage, res: http.ServerResponse) => {
const url = req.url;
if (!url) {
res.end(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { createServer, IncomingMessage, Server, ServerResponse } from "http";
import http from "http";
import { ILoopbackClient, ServerAuthorizationCodeResponse } from "@azure/msal-node";

/**
Expand All @@ -13,7 +13,7 @@ import { ILoopbackClient, ServerAuthorizationCodeResponse } from "@azure/msal-no
*/
export class CustomLoopbackClient implements ILoopbackClient {
port: number = 0; // default port, which will be set to a random available port
private server: Server;
private server: http.Server;

private constructor(port: number = 0) {
this.port = port;
Expand Down Expand Up @@ -52,7 +52,7 @@ export class CustomLoopbackClient implements ILoopbackClient {
}

const authCodeListener = new Promise<ServerAuthorizationCodeResponse>((resolve, reject) => {
this.server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
this.server = http.createServer(async (req: http.IncomingMessage, res: http.ServerResponse) => {
const url = req.url;
if (!url) {
res.end(errorTemplate || "Error occurred loading redirectUrl");
Expand Down Expand Up @@ -129,7 +129,7 @@ export class CustomLoopbackClient implements ILoopbackClient {
*/
isPortAvailable(port: number): Promise<boolean> {
return new Promise(resolve => {
const server = createServer()
const server = http.createServer()
.listen(port, () => {
server.close();
resolve(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { createServer, IncomingMessage, Server, ServerResponse } from "http";
import http from "http";
import { CryptoProvider } from "@azure/msal-node";
import open from "open";

Expand All @@ -13,7 +13,7 @@ import open from "open";
* https://learn.microsoft.com/azure/active-directory/develop/single-and-multi-tenant-apps
*/
class ProvisionHandler {
private server: Server;
private server: http.Server;
private cryptoProvider: CryptoProvider;
private state: string;

Expand Down Expand Up @@ -64,7 +64,7 @@ class ProvisionHandler {
}

const adminConsentListener = new Promise<boolean>((resolve, reject) => {
this.server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
this.server = http.createServer(async (req: http.IncomingMessage, res: http.ServerResponse) => {
const url = req.url;

if (!url) {
Expand Down