From 922003d771c1751c899802a7b0f9f960307b8517 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Sep 2026 18:17:44 +0000 Subject: [PATCH] fix: use node: imports so JSR publish no longer panics Deno's bare-node-builtins rewrite overlaps on JSDoc import('net') and crashes during jsr publish. Prefix Node builtins with node: and bump to 0.2.4 so npm/JSR can republish after 0.2.3's partial publish. Co-authored-by: ProxyMesh AI --- jsr.json | 2 +- lib/core/proxy-headers-agent.js | 4 ++-- lib/core/utils.js | 8 ++++---- lib/undici-proxy.js | 2 +- package.json | 2 +- types/index.d.ts | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jsr.json b/jsr.json index 1dc388a..ddc35a3 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@proxymesh/javascript-proxy-headers", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "exports": "./mod.ts" } diff --git a/lib/core/proxy-headers-agent.js b/lib/core/proxy-headers-agent.js index b0288f3..126092b 100644 --- a/lib/core/proxy-headers-agent.js +++ b/lib/core/proxy-headers-agent.js @@ -5,8 +5,8 @@ * and captures the proxy's response headers. */ -import { Agent } from 'https'; -import tls from 'tls'; +import { Agent } from 'node:https'; +import tls from 'node:tls'; import { parseProxyUrl, buildConnectRequest, createProxySocket, proxyReadyEvent } from './utils.js'; import { parseConnectResponse, hasCompleteHeaders, ConnectError } from './connect-parser.js'; diff --git a/lib/core/utils.js b/lib/core/utils.js index 9c3de3b..8900006 100644 --- a/lib/core/utils.js +++ b/lib/core/utils.js @@ -2,8 +2,8 @@ * Utility functions for proxy header handling. */ -import net from 'net'; -import tls from 'tls'; +import net from 'node:net'; +import tls from 'node:tls'; const INVALID_HEADER_CHAR = /[\r\n\0]/; @@ -79,8 +79,8 @@ export function parseTargetUrl(targetUrl) { * Open a TCP or TLS socket to the proxy. * HTTPS proxy URLs use tls.connect so Proxy-Authorization is not sent in the clear. * @param {{ host: string, port: number, protocol: string }} proxyInfo - * @param {import('tls').ConnectionOptions} [proxyTlsOptions] - * @returns {import('net').Socket|import('tls').TLSSocket} + * @param {import('node:tls').ConnectionOptions} [proxyTlsOptions] + * @returns {import('node:net').Socket|import('node:tls').TLSSocket} */ export function createProxySocket(proxyInfo, proxyTlsOptions = {}) { if (proxyInfo.protocol === 'https:') { diff --git a/lib/undici-proxy.js b/lib/undici-proxy.js index 57e84b9..d48eca5 100644 --- a/lib/undici-proxy.js +++ b/lib/undici-proxy.js @@ -18,7 +18,7 @@ import { parseConnectResponse, hasCompleteHeaders, ConnectError } from './core/c * @param {Object} options.proxyHeaders - Headers to send to proxy * @param {Object} [options.proxyTlsOptions] - TLS options for an https:// proxy * @param {number} options.timeout - Timeout in ms - * @returns {Promise<{ socket: import('net').Socket, proxyHeaders: Map }>} + * @returns {Promise<{ socket: import('node:net').Socket, proxyHeaders: Map }>} */ async function createProxyTunnel(options) { const { proxy, targetHost, targetPort, proxyHeaders = {}, proxyTlsOptions = {}, timeout = 30000 } = options; diff --git a/package.json b/package.json index e47878d..a425d8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "javascript-proxy-headers", - "version": "0.2.3", + "version": "0.2.4", "description": "Extensions for JavaScript HTTP libraries to support sending and receiving custom proxy headers during HTTPS CONNECT tunneling", "type": "module", "main": "index.js", diff --git a/types/index.d.ts b/types/index.d.ts index ff2f967..4ac0bd0 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,7 +2,7 @@ * JavaScript Proxy Headers - TypeScript Definitions */ -import { Agent } from 'https'; +import { Agent } from 'node:https'; // ============================================================================= // Core Types