Registry / http-networking / caw
library0.8.0jsnpmunverified

caw is a JavaScript utility designed to simplify the creation of HTTP/HTTPS agents for tunneling through proxies. It abstracts the configuration of proxy agents by internally utilizing `tunnel-agent` for the tunneling logic and `get-proxy` for automatic discovery of proxy settings from environment variables if a proxy URL is not explicitly provided. The current stable version is 2.0.1. Due to the age of its underlying dependencies (`tunnel-agent` and `get-proxy`), which are themselves largely unmaintained or deprecated, `caw` has seen no recent development and can be considered abandoned. It serves a niche for older Node.js environments (targeting `node >=4`) that require simple proxy agent construction, but modern applications should seek more actively maintained alternatives.

npm install caw
INSTALL
IMPORT
SIG · CAW
C
caw
http-networkingjavascriptv0.8.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

caw
const caw = require('caw');
import caw from 'caw';
caw is a CommonJS module and does not natively support ES module `import` syntax. For ESM projects, direct migration to an ESM-compatible alternative is recommended.
caw (for `agent` option)
agent: caw('http://proxy.example.com:8080')
agent: new caw()
The `caw` function is called directly to create an agent instance, it's not a class constructor.

Demonstrates how to create and use `caw` agents with the `got` HTTP client, both with explicit proxy URLs and automatic proxy discovery from environment variables.

const caw = require('caw'); const got = require('got'); // Example using an explicit proxy URL const proxyAgent = caw('http://your-proxy-server:8080', { protocol: 'http' }); // If no proxy URL is provided, caw will try to get it from environment variables (HTTP_PROXY, HTTPS_PROXY) const autoProxyAgent = caw(); (async () => { try { // Make a request using the proxy agent const { body: explicitProxyBody } = await got('https://api.github.com/zen', { agent: { https: proxyAgent } // Specify https agent for https requests }); console.log('Response with explicit proxy:', explicitProxyBody); // Make another request, letting caw discover proxy from env vars // For this to work, ensure HTTP_PROXY or HTTPS_PROXY are set in your environment // For demonstration, we'll just show the call. // process.env.HTTPS_PROXY = 'http://another-proxy.example.com:8081'; // Uncomment to test env var discovery const { body: autoProxyBody } = await got('https://ipinfo.io/json', { agent: { https: autoProxyAgent } }); console.log('Response with auto-discovered proxy:', autoProxyBody); } catch (error) { console.error('Request failed:', error.message); } })();
Debug
Known issues
breakingcaw relies on deprecated and unmaintained underlying dependencies (`tunnel-agent` and `get-proxy`). This can lead to security vulnerabilities, lack of compatibility with modern Node.js versions, and unaddressed bugs.
fix
Consider migrating to actively maintained libraries such as `http-proxy-agent`, `https-proxy-agent`, or `socks-proxy-agent` for proxy tunneling, ideally used with modern HTTP clients like `undici` or `axios` with appropriate proxy agent integration.
affects: >=1.0
gotchacaw is a CommonJS module and does not provide native ES Module (ESM) support. Using `import` syntax will typically result in errors in pure ESM environments without a transpilation step.
fix
Always use `const caw = require('caw');` for importing. For ESM-only projects, a direct migration to an ESM-first proxy agent library is the most robust solution.
affects: >=1.0
gotchaWhile `caw` states compatibility with Node.js versions `>=4`, its internal mechanisms and dependencies may not function correctly or securely on modern Node.js versions (e.g., Node.js 14+).
fix
Thoroughly test `caw` on your target Node.js version. For production environments, it is highly recommended to migrate to a current, actively maintained solution that explicitly supports your Node.js runtime.
affects: >=1.0
gotchaWhen no proxy URL is explicitly provided to `caw()`, it attempts to automatically discover proxy settings from environment variables (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`). This can lead to unintended proxying if these variables are set in your environment without your explicit knowledge or intent for a specific application.
fix
Always provide an explicit `proxy` URL to `caw(proxyUrl)` for predictable behavior. If relying on environment variables, ensure they are correctly configured and understood for the application's context. Always be mindful of `NO_PROXY` to prevent local requests from being proxied.
affects: >=1.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to import `caw` using ES module `import` syntax in an ES module environment.
fix
Change the import statement to `const caw = require('caw');` or convert your project to CommonJS. For pure ESM projects, migrate to an ESM-compatible proxy agent library.
Error: tunneling socket could not be established, cause=...
The configured proxy server either rejected the connection, is misconfigured, or network issues prevented the application from reaching the proxy.
fix
Verify the proxy URL, port, and authentication credentials. Ensure network connectivity from your application to the proxy server. Check the proxy server's logs for more detailed error information. Also, check for `NO_PROXY` environment variables that might unintentionally prevent proxying for certain domains.
TypeError: Cannot read properties of undefined (reading 'protocol')
This or similar `TypeError` issues often arise when the `caw` agent, built on older `tunnel-agent` mechanisms, becomes incompatible with newer Node.js `http`/`https` module internals or other HTTP client libraries due to its age.
fix
Upgrade to a modern, actively maintained HTTP/HTTPS proxy agent library (e.g., `@http-proxy-agent/https`, `@https-proxy-agent/https`) that is explicitly compatible with your Node.js version and chosen HTTP client.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies
tunnel-agentrequiredProvides the core tunneling logic for HTTP/HTTPS agents, but is itself deprecated and unmaintained.
get-proxyrequiredUsed to automatically discover proxy settings from environment variables if not specified, also largely unmaintained.
Agent activity
16 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources