Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 7 additions & 6 deletions impit-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@types/express": "^5.0.0",
"@types/node": "^24.0.0",
"express": "^5.0.0",
"proxy-chain": "^2.5.9",
"socks-server-lib": "^0.0.3",
"tough-cookie": "^6.0.0",
"typedoc": "^0.28.13",
Expand All @@ -53,13 +54,13 @@
"packageManager": "yarn@4.10.3",
"description": "Impit for JavaScript",
"optionalDependencies": {
"impit-darwin-x64": "0.7.0",
"impit-darwin-arm64": "0.7.0",
"impit-win32-x64-msvc": "0.7.0",
"impit-win32-arm64-msvc": "0.7.0",
"impit-darwin-x64": "0.7.0",
"impit-linux-arm64-gnu": "0.7.0",
"impit-linux-arm64-musl": "0.7.0",
"impit-linux-x64-gnu": "0.7.0",
"impit-linux-x64-musl": "0.7.0",
"impit-linux-arm64-gnu": "0.7.0",
"impit-linux-arm64-musl": "0.7.0"
"impit-win32-arm64-msvc": "0.7.0",
"impit-win32-x64-msvc": "0.7.0"
}
}
}
23 changes: 20 additions & 3 deletions impit-node/test/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { test, describe, expect, beforeAll, afterAll } from 'vitest';

import { HttpMethod, Impit, Browser } from '../index.wrapper.js';
import type { Server } from 'net';
import { routes, runServer } from './mock.server.js';
import { routes, runProxyServer, runServer } from './mock.server.js';

import { CookieJar } from 'tough-cookie';
import { runSocksServer } from 'socks-server-lib';
import { Server as ProxyServer } from 'proxy-chain';

function getHttpBinUrl(path: string, https?: boolean): string {
https ??= true;
Expand All @@ -28,6 +29,12 @@ async function getServer() {
return localServer;
}

let proxyServer: ProxyServer | null = null;
async function getProxyServer() {
proxyServer ??= await runProxyServer(3002);
return proxyServer;
}

let socksServer: Server | null = null;
let socksConnectionCount = 0;
beforeAll(async () => {
Expand All @@ -36,6 +43,8 @@ beforeAll(async () => {
await fetch(getHttpBinUrl('/get'));
// Start the local server
await getServer();
// Start the proxy server
await getProxyServer()

Copilot AI Nov 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon at the end of the statement.

Suggested change
await getProxyServer()
await getProxyServer();

Copilot uses AI. Check for mistakes.

socksServer = await runSocksServer({ host: 'localhost', port: 7625, onData: () => { socksConnectionCount++; }});
}, 30e3);
Expand All @@ -46,6 +55,10 @@ afterAll(async () => {
const server = await getServer();
server?.close(() => res())
}),
new Promise<void>(async (res) => {
const server = await getProxyServer();
server?.close(true, () => res())
}),
Promise.race([
new Promise<void>(res => {
socksServer?.on('close', () => res());
Expand Down Expand Up @@ -130,10 +143,14 @@ describe.each([
]);
});

test.each([['socks4'], ['socks5']])('supports %s proxy', async (proxyType) => {
test.each([
{ scheme: 'socks4', url: 'socks4://localhost:7625' },
{ scheme: 'socks5', url: 'socks5://localhost:7625' },
{ scheme: 'http', url: 'http://localhost:3002' },
])('supports %s proxy', async ({ scheme, url }) => {
const impit = new Impit({
browser,
proxyUrl: `${proxyType}://localhost:7625`,
proxyUrl: url,
});

const response = await impit.fetch(
Expand Down
12 changes: 12 additions & 0 deletions impit-node/test/mock.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import express from 'express';
import { Server } from 'http';
import { Server as ProxyServer } from 'proxy-chain';

export const routes = {
charset: {
Expand Down Expand Up @@ -35,3 +36,14 @@ export async function runServer(port: number): Promise<Server> {
});
});
}

export async function runProxyServer(port: number): Promise<ProxyServer> {
const server = new ProxyServer({port});
return new Promise((res, rej) => {
server.listen(() => {
res(server);
}).catch((err) => {
rej(err);
});
});
}
78 changes: 45 additions & 33 deletions impit-node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2500,58 +2500,58 @@ __metadata:
languageName: node
linkType: hard

"impit-darwin-arm64@npm:0.6.1":
version: 0.6.1
resolution: "impit-darwin-arm64@npm:0.6.1"
"impit-darwin-arm64@npm:0.7.0":
version: 0.7.0
resolution: "impit-darwin-arm64@npm:0.7.0"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"impit-darwin-x64@npm:0.6.1":
version: 0.6.1
resolution: "impit-darwin-x64@npm:0.6.1"
"impit-darwin-x64@npm:0.7.0":
version: 0.7.0
resolution: "impit-darwin-x64@npm:0.7.0"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"impit-linux-arm64-gnu@npm:0.6.1":
version: 0.6.1
resolution: "impit-linux-arm64-gnu@npm:0.6.1"
"impit-linux-arm64-gnu@npm:0.7.0":
version: 0.7.0
resolution: "impit-linux-arm64-gnu@npm:0.7.0"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"impit-linux-arm64-musl@npm:0.6.1":
version: 0.6.1
resolution: "impit-linux-arm64-musl@npm:0.6.1"
"impit-linux-arm64-musl@npm:0.7.0":
version: 0.7.0
resolution: "impit-linux-arm64-musl@npm:0.7.0"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"impit-linux-x64-gnu@npm:0.6.1":
version: 0.6.1
resolution: "impit-linux-x64-gnu@npm:0.6.1"
"impit-linux-x64-gnu@npm:0.7.0":
version: 0.7.0
resolution: "impit-linux-x64-gnu@npm:0.7.0"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"impit-linux-x64-musl@npm:0.6.1":
version: 0.6.1
resolution: "impit-linux-x64-musl@npm:0.6.1"
"impit-linux-x64-musl@npm:0.7.0":
version: 0.7.0
resolution: "impit-linux-x64-musl@npm:0.7.0"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"impit-win32-arm64-msvc@npm:0.6.1":
version: 0.6.1
resolution: "impit-win32-arm64-msvc@npm:0.6.1"
"impit-win32-arm64-msvc@npm:0.7.0":
version: 0.7.0
resolution: "impit-win32-arm64-msvc@npm:0.7.0"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"impit-win32-x64-msvc@npm:0.6.1":
version: 0.6.1
resolution: "impit-win32-x64-msvc@npm:0.6.1"
"impit-win32-x64-msvc@npm:0.7.0":
version: 0.7.0
resolution: "impit-win32-x64-msvc@npm:0.7.0"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
Expand All @@ -2564,14 +2564,15 @@ __metadata:
"@types/express": "npm:^5.0.0"
"@types/node": "npm:^24.0.0"
express: "npm:^5.0.0"
impit-darwin-arm64: "npm:0.6.1"
impit-darwin-x64: "npm:0.6.1"
impit-linux-arm64-gnu: "npm:0.6.1"
impit-linux-arm64-musl: "npm:0.6.1"
impit-linux-x64-gnu: "npm:0.6.1"
impit-linux-x64-musl: "npm:0.6.1"
impit-win32-arm64-msvc: "npm:0.6.1"
impit-win32-x64-msvc: "npm:0.6.1"
impit-darwin-arm64: "npm:0.7.0"
impit-darwin-x64: "npm:0.7.0"
impit-linux-arm64-gnu: "npm:0.7.0"
impit-linux-arm64-musl: "npm:0.7.0"
impit-linux-x64-gnu: "npm:0.7.0"
impit-linux-x64-musl: "npm:0.7.0"
impit-win32-arm64-msvc: "npm:0.7.0"
impit-win32-x64-msvc: "npm:0.7.0"
proxy-chain: "npm:^2.5.9"
socks-server-lib: "npm:^0.0.3"
tough-cookie: "npm:^6.0.0"
typedoc: "npm:^0.28.13"
Expand Down Expand Up @@ -3098,6 +3099,17 @@ __metadata:
languageName: node
linkType: hard

"proxy-chain@npm:^2.5.9":
version: 2.5.9
resolution: "proxy-chain@npm:2.5.9"
dependencies:
socks: "npm:^2.8.3"
socks-proxy-agent: "npm:^8.0.3"
tslib: "npm:^2.3.1"
checksum: 10c0/a55ebab793ec4a48b888536bb5ca4840768cb1550b966c82187580deb4c27fe7723a2609fb21f990006fd7a45a3d4c54eb38be4e9fe451027d1d9ce51628e73d
languageName: node
linkType: hard

"punycode.js@npm:^2.3.1":
version: 2.3.1
resolution: "punycode.js@npm:2.3.1"
Expand Down Expand Up @@ -3572,7 +3584,7 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.4.0":
"tslib@npm:^2.3.1, tslib@npm:^2.4.0":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
Expand Down
5 changes: 5 additions & 0 deletions impit-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dev = [
"pytest",
"ruff",
"setuptools",
"pproxy>=2.7.9",
]
docs = [
"sphinx>=7.4.7",
Expand Down Expand Up @@ -130,5 +131,9 @@ warn_return_any = true
warn_unreachable = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = ["pproxy"]
ignore_missing_imports = true

[tool.uv.sources]
stubdoc = { git = "https://github.com/bayashi-cl/stubdoc" }
2 changes: 2 additions & 0 deletions impit-python/python/impit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
patch,
post,
put,
stream,
trace,
)

Expand Down Expand Up @@ -87,6 +88,7 @@
'patch',
'post',
'put',
'stream',
'trace',
]

Expand Down
Loading
Loading