wwws
v1.1.2
Published
a worldwide (node, bun, & deno) websocket socks5/h proxy implementation
Readme
wwws is a global websocket proxy implementation that works on every flavor of the javascript runtime: node, deno, and bun (as well as with require AND import)!
you can install wwws using any of your favorite PMs:
bun add wwws(recommended)pnpm add wwwsnpm install wwws
(yarn's main branch hasn't been updated in a year and is not recommended for everyday use, but you can if you wish)
wwws follows most of the syntax as the ws library. the only addition is the proxy param in the constructor:
import { WWWebSocket } from 'wwws'; // the WWWebSocket is exported as both default and as "WWWebSocket"
const ws = new WWWebSocket('wss://ip.villainsrule.xyz', {
proxy: 'socks5://user:pass@host:port' // can be socks5 or socks5h
});the goal of WWWebSocket is to always work, no matter what environment you're in. if you're in an environment that doesn't work, open an issue!
wwws supports:
it also supports both cjs & esm file formats.
[!WARNING] wwws does NOT support fake node hosting platforms! the main example of this is cloudflare workers. the reason? many of these platforms rewrite node internals to the point where there is massive compatbility loss.
wwws requires several node:* internals to run. it does not rely on any npm packages or platform-specific features. deno & bun fully support all of these internals without issues, so wwws works smoothly on all 3 runtimes! if you need a checklist for some reason, here you go:
node:cryptocrypto.randomBytes- required
node:dnsdns.lookup- required only if using socks5 proxies, socks5h works without
node:netnet.connect- required
node:tlstls.connect- required
node:zlibzlib.deflateRaw- required only if using thepermessage-deflatefeaturezlib.inflateRaw- required only if using thepermessage-deflatefeature
[!NOTE] if you are building your own runtime, you should make sure all of the above modules can be imported without issues at the top level. it's probably also a smart idea to stub the things that aren't required "just in case".
since this library rewrites the entire WebSocket object, the following things are supported:
class params
headersproxy
[!NOTE]
agentis supported to the extent that a proxy URL will try to be extracted from it.agentis not recommended and is only present so you can use wwws as a dropin solution.
methods
send(message)close(code)
props
- static
CONNECTING= 0 - static
OPEN= 1 - static
CLOSING= 2 - static
CLOSED= 3 - binaryType (default 'nodebuffer') [TODO]
- url
events
- onopen / open
- onerror / error
- onclose / close
- onmessage / message
- ping
- pong
[!WARNING] events might not have all required properties on them; they are essentially polyfills...
if something here is missing that you require, you are encouraged to open an issue for support!
[!NOTE] there are no plans to officially use
Deno.createHttpClientunder the hood.
reading through hundreds of pages to add features 95% of users will not use is a waste of my time. if something is wrong or you need something implemented, open an issue and we'll figure out how to make it work.
