@refactorjs/http-proxy
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,12 +0,60 @@ | ||
import * as net from 'node:net'; | ||
import * as http from 'node:http'; | ||
import * as url from 'node:url'; | ||
import * as stream from 'node:stream'; | ||
import EventEmitter from 'eventemitter3'; | ||
import http$1 from 'http'; | ||
import https from 'https'; | ||
import * as url from 'url'; | ||
import * as net from 'net'; | ||
import * as http from 'http'; | ||
import http__default from 'http'; | ||
import * as https from 'https'; | ||
import https__default from 'https'; | ||
import * as buffer from 'buffer'; | ||
import * as followRedirects from 'follow-redirects'; | ||
import { EventEmitter } from 'events'; | ||
declare class ProxyServer extends EventEmitter { | ||
#private; | ||
options: Server.ServerOptions; | ||
$server: http__default.Server | https__default.Server | undefined; | ||
/** | ||
* Used for proxying regular HTTP(S) requests | ||
* @param req - Client request. | ||
* @param res - Client response. | ||
* @param options - Additional options. | ||
*/ | ||
web: Passthrough; | ||
/** | ||
* Used for proxying regular HTTP(S) requests | ||
* @param req - Client request. | ||
* @param socket - Client socket. | ||
* @param head - Client head. | ||
* @param options - Additionnal options. | ||
*/ | ||
ws: Passthrough; | ||
webPasses: Passthrough[]; | ||
wsPasses: Passthrough[]; | ||
/** | ||
* Creates the proxy server with specified options. | ||
* @param options - Config object passed to the proxy | ||
*/ | ||
constructor(options?: Server.ServerOptions); | ||
onError(err: Error): void; | ||
/** | ||
* A function that wraps the object in a webserver, for your convenience | ||
* @param port - Port to listen on | ||
* @param hostname - Hostname to listen on | ||
*/ | ||
listen(port: number, hostname: string): this; | ||
/** | ||
* A function that closes the inner webserver and stops listening on given port | ||
*/ | ||
close(callback?: () => void): void; | ||
before(type: 'web' | 'ws', passName: string, callback: Passthrough): void; | ||
after(type: 'web' | 'ws', passName: string, callback: Passthrough): void; | ||
} | ||
declare const createProxyServer: (options?: Server.ServerOptions) => ProxyServer; | ||
declare const createServer: (options?: Server.ServerOptions) => ProxyServer; | ||
declare const createProxy: (options?: Server.ServerOptions) => ProxyServer; | ||
interface ProxyTargetDetailed { | ||
host: string; | ||
port: number; | ||
href?: string; | ||
method?: string; | ||
protocol?: string | undefined; | ||
@@ -17,11 +65,28 @@ hostname?: string | undefined; | ||
passphrase?: string | undefined; | ||
pfx?: Buffer | string | undefined; | ||
cert?: string | undefined; | ||
ca?: string | undefined; | ||
pfx?: buffer.Buffer | string | undefined; | ||
cert?: string | buffer.Buffer | Array<string | buffer.Buffer> | undefined; | ||
ca?: string | buffer.Buffer | Array<string | buffer.Buffer> | undefined; | ||
ciphers?: string | undefined; | ||
secureProtocol?: string | undefined; | ||
servername?: string | undefined; | ||
searchParams?: string | url.URLSearchParams | undefined; | ||
pathname?: string | undefined; | ||
path?: string | undefined; | ||
} | ||
interface OutgoingOptions extends ProxyTargetDetailed, followRedirects.FollowOptions<Server.followOptions> { | ||
localAddress?: string; | ||
headers?: Server.ServerOptions['headers']; | ||
agent?: Server.ServerOptions['agent']; | ||
auth?: Server.ServerOptions['auth']; | ||
rejectUnauthorized?: boolean; | ||
} | ||
interface Passthrough { | ||
(req: http.IncomingMessage, res: http.ServerResponse): boolean | void; | ||
(req: http.IncomingMessage, res: http.ServerResponse | net.Socket, head?: buffer.Buffer): boolean | void; | ||
(req: http.IncomingMessage, res: http.ServerResponse, options: Server.ServerOptions, head?: buffer.Buffer, server?: ProxyServer, callback?: (err?: Error, req?: http.IncomingMessage, res?: http.ServerResponse, url?: Server.ServerOptions['target']) => void): boolean | void; | ||
} | ||
declare namespace Server { | ||
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed; | ||
type ProxyTargetUrl = string | Partial<url.Url>; | ||
type ProxyTarget = ProxyTargetUrl | url.URL & ProxyTargetDetailed; | ||
type ProxyTargetUrl = Partial<url.URL & ProxyTargetDetailed>; | ||
type followOptions = {}; | ||
interface ServerOptions { | ||
@@ -33,5 +98,5 @@ /** URL string to be parsed with the url module. */ | ||
/** Object to be passed to http(s).request. */ | ||
agent?: any; | ||
agent?: http.Agent | boolean | undefined; | ||
/** Object to be passed to https.createServer(). */ | ||
ssl?: any; | ||
ssl?: https.ServerOptions | undefined; | ||
/** If you want to proxy websockets. */ | ||
@@ -71,6 +136,14 @@ ws?: boolean | undefined; | ||
} | undefined; | ||
/** specify if you want to remove the secure flag from the cookie */ | ||
cookieRemoveSecure?: boolean | undefined; | ||
/** allows to merge `set-cookie` headers from passed response and response from target. Default: false. */ | ||
mergeCookies?: boolean | undefined; | ||
/** object with extra headers to be added to target requests. */ | ||
headers?: { | ||
[header: string]: string; | ||
} | undefined; | ||
} | http.IncomingHttpHeaders | undefined; | ||
/** object with extra headers to be added to proxy requests. */ | ||
outgoingHeaders?: { | ||
[header: string]: string; | ||
} | http.IncomingHttpHeaders | undefined; | ||
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */ | ||
@@ -81,7 +154,13 @@ proxyTimeout?: number | undefined; | ||
/** Specify whether you want to follow redirects. Default: false */ | ||
followRedirects?: boolean | undefined; | ||
followRedirects?: followRedirects.FollowOptions<followOptions>; | ||
/** if set to true the web passes will be run even if `selfHandleResponse` is also set to true. */ | ||
forcePasses?: boolean | undefined; | ||
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */ | ||
selfHandleResponse?: boolean | undefined; | ||
selfHandleResponse?: boolean | Function | undefined; | ||
/** if set, this function will be called with three arguments `req`, `proxyReq` and `proxyRes` and should return a Duplex stream, data from the client websocket will be piped through this stream before being piped to the server, allowing you to influence the request data. */ | ||
createWsClientTransformStream?: (req: http.IncomingMessage, proxyReq: http.ClientRequest, proxyRes: http.IncomingMessage) => net.Socket | undefined; | ||
/** if set, this function will be called with three arguments `req`, `proxyReq` and `proxyRes` and should return a Duplex stream, data from the server websocket will be piped through this stream before being piped to the client, allowing you to influence the response data. */ | ||
createWsServerTransformStream?: (req: http.IncomingMessage, proxyReq: http.ClientRequest, proxyRes: http.IncomingMessage) => net.Socket | undefined; | ||
/** Buffer */ | ||
buffer?: stream.Stream | undefined; | ||
buffer?: buffer.Buffer | undefined; | ||
} | ||
@@ -99,26 +178,2 @@ type StartCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (req: TIncomingMessage, res: TServerResponse, target: ProxyTargetUrl) => void; | ||
declare class ProxyServer extends EventEmitter { | ||
options: Server.ServerOptions; | ||
$server: http$1.Server | https.Server | undefined; | ||
web: any; | ||
ws: any; | ||
proxyRequest: any; | ||
proxyWebsocketRequest: any; | ||
webPasses: Array<Function>; | ||
wsPasses: Array<Function>; | ||
static createProxyServer: (options: Server.ServerOptions) => ProxyServer; | ||
static createServer: (options: Server.ServerOptions) => ProxyServer; | ||
static createProxy: (options: Server.ServerOptions) => ProxyServer; | ||
/** | ||
* Creates the proxy server with specified options. | ||
* @param options - Config object passed to the proxy | ||
*/ | ||
constructor(options: Server.ServerOptions); | ||
onError(err: any): void; | ||
listen(port: any, hostname: any): this; | ||
close(callback: any): void; | ||
before(type: any, passName: any, callback: any): void; | ||
after(type: any, passName: any, callback: any): void; | ||
} | ||
export { ProxyTargetDetailed, Server, ProxyServer as default }; | ||
export { OutgoingOptions, Passthrough, ProxyServer, ProxyTargetDetailed, Server, createProxy, createProxyServer, createServer }; |
{ | ||
"name": "@refactorjs/http-proxy", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "http-proxy alternative", | ||
@@ -26,16 +26,17 @@ "repository": { | ||
"build": "unbuild", | ||
"preapck": "unbuild", | ||
"tscbuild": "tsc -p ./tsconfig.json", | ||
"release": "standard-version && git push --follow-tags && pnpm publish", | ||
"mocha": "mocha test/*-test.js", | ||
"test": "nyc --reporter=text --reporter=lcov npm run mocha" | ||
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"eventemitter3": "^4.0.0", | ||
"follow-redirects": "^1.15.1" | ||
"follow-redirects": "^1.15.1", | ||
"requires-port": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/follow-redirects": "^1.14.1", | ||
"@types/node": "^18.0.0", | ||
"@types/requires-port": "^1.0.0", | ||
"async": "^3.0.0", | ||
"concat-stream": "^2.0.0", | ||
"expect.js": "~0.3.1", | ||
"mocha": "^10.0.0", | ||
"nyc": "^15.0.0", | ||
@@ -47,9 +48,9 @@ "semver": "^7.3.7", | ||
"standard-version": "latest", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.7.4", | ||
"unbuild": "^0.7.6", | ||
"vitest": "^0.21.1", | ||
"ws": "^8.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=14.0.0" | ||
}, | ||
@@ -66,4 +67,3 @@ "packageManager": "yarn@3.2.0", | ||
"alternative" | ||
], | ||
"author": "" | ||
] | ||
} |
@@ -1,1 +0,1 @@ | ||
# http-proxi | ||
# http-proxy |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56550
1373
3
15
+ Addedrequires-port@^1.0.0
+ Addedrequires-port@1.0.0(transitive)