{"_id":"@decentchat/transport-webrtc","_rev":"5-6a224c18e719a8b27d29770be45ec302","name":"@decentchat/transport-webrtc","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"@decentchat/transport-webrtc","version":"0.1.0","license":"MIT","_id":"@decentchat/transport-webrtc@0.1.0","maintainers":[{"name":"alino","email":"alino.sadovsky@gmail.com"}],"homepage":"https://github.com/Alino/DecentChat#readme","bugs":{"url":"https://github.com/Alino/DecentChat/issues"},"dist":{"shasum":"45da91e6f54df92ac60450c397cc0c5eeb41dc8a","tarball":"https://registry.npmjs.org/@decentchat/transport-webrtc/-/transport-webrtc-0.1.0.tgz","fileCount":16,"integrity":"sha512-TLpxmUPYoQCfJaTi7Om8zEzqrOU/lPsG3XgwCG98cvuGv8+4G4i1taM0oUSUpoAncEIp+BU+YdMJZqaFbMLKwA==","signatures":[{"sig":"MEQCIHT6TnqddU1L00RbUcbw6idH4v07/5UuwwhMt1qtLGPkAiAo90qZCgseKjZXH2j8TMfUFNfvxjphVq0WUb5xq67UzA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":204309},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"bun":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"4e8c6e33480cb93571400b87aaa19d28f91255e5","scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"alino","email":"alino.sadovsky@gmail.com"},"repository":{"url":"git+https://github.com/Alino/DecentChat.git","type":"git","directory":"decent-transport-webrtc"},"_npmVersion":"11.9.0","description":"WebRTC/PeerJS transport implementation for @decentchat/protocol","directories":{},"_nodeVersion":"25.6.1","dependencies":{"peerjs":"^1.5.4","@decentchat/protocol":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/transport-webrtc_0.1.0_1774655383109_0.9084742477112868","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@decentchat/transport-webrtc","version":"0.1.1","license":"MIT","_id":"@decentchat/transport-webrtc@0.1.1","maintainers":[{"name":"alino","email":"alino.sadovsky@gmail.com"}],"homepage":"https://github.com/Alino/DecentChat#readme","bugs":{"url":"https://github.com/Alino/DecentChat/issues"},"dist":{"shasum":"d92eae1f66902c2ad8eb4f5ab6b51f0b50ba1a99","tarball":"https://registry.npmjs.org/@decentchat/transport-webrtc/-/transport-webrtc-0.1.1.tgz","fileCount":17,"integrity":"sha512-XY6wDOPrHsMIqSxdabBt5iTQPG79D8YtDtvcAEfWXYZlQw6He8C0GTPo45tb5Re9rZ/ri29cozdJcfcviaQwXA==","signatures":[{"sig":"MEUCIDRR69ptR5weVge0qm8XOEGCXaB74ZICMGwoBwqBOn+WAiEA/hlZlPRXC7j+EZ/8QpbTMQeo1To5LRHK1Yxui7WKASo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":207680},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"bun":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"9160a6586f512c89c2778329d1c955879d224708","scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"alino","email":"alino.sadovsky@gmail.com"},"repository":{"url":"git+https://github.com/Alino/DecentChat.git","type":"git","directory":"decent-transport-webrtc"},"_npmVersion":"11.9.0","description":"WebRTC/PeerJS transport implementation for @decentchat/protocol","directories":{},"_nodeVersion":"25.6.1","dependencies":{"peerjs":"^1.5.4","@decentchat/protocol":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/transport-webrtc_0.1.1_1774657374422_0.865373809041156","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@decentchat/transport-webrtc","version":"0.1.2","license":"MIT","_id":"@decentchat/transport-webrtc@0.1.2","maintainers":[{"name":"alino","email":"alino.sadovsky@gmail.com"}],"dist":{"shasum":"d073f2f635e5dd27019ffcc5b3cd2a89a12ddd9a","tarball":"https://registry.npmjs.org/@decentchat/transport-webrtc/-/transport-webrtc-0.1.2.tgz","fileCount":17,"integrity":"sha512-YHIA3V9x7VKRBBIhH6E1Zlx+Z2biyQKvu+jLkdIIxjwYq5IAZoqrt2aBZAoPGN0L5ZLJsMUkfeULv6Ko5Bj8pQ==","signatures":[{"sig":"MEUCIQDxVZMrDKdwXQBJhn2A4HQklz7p5AYniP9D8rpee/IltwIgLzL5KIlSXVWUtKL8igvGaR8a2Cj6BNThjZgd1CfdUaI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":207690},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","shasum":"d073f2f635e5dd27019ffcc5b3cd2a89a12ddd9a","exports":{".":{"bun":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"alino","email":"alino.sadovsky@gmail.com"},"_integrity":"sha512-YHIA3V9x7VKRBBIhH6E1Zlx+Z2biyQKvu+jLkdIIxjwYq5IAZoqrt2aBZAoPGN0L5ZLJsMUkfeULv6Ko5Bj8pQ==","repository":{"url":"https://github.com/DecentChat/DecentChat.git","type":"git","directory":"decent-transport-webrtc"},"_npmVersion":"10.8.3","description":"WebRTC/PeerJS transport implementation for @decentchat/protocol","directories":{},"_nodeVersion":"24.3.0","dependencies":{"peerjs":"^1.5.4","@decentchat/protocol":"^0.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/transport-webrtc_0.1.2_1774694038590_0.1292022324226365","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@decentchat/transport-webrtc","version":"0.1.3","license":"MIT","_id":"@decentchat/transport-webrtc@0.1.3","maintainers":[{"name":"alino","email":"alino.sadovsky@gmail.com"}],"homepage":"https://github.com/DecentChat/DecentChat#readme","bugs":{"url":"https://github.com/DecentChat/DecentChat/issues"},"dist":{"shasum":"4890a5c5606b463af1398c0a57120a55c6d71912","tarball":"https://registry.npmjs.org/@decentchat/transport-webrtc/-/transport-webrtc-0.1.3.tgz","fileCount":17,"integrity":"sha512-qpw36xo3Kaz+LZ30hJjAe3TZkXiljbeOGGGyEQ1pad8cKW3ccGhTZ7LFgPNo+5Rk2HIGYLRzZ9gKo0bumAiY5Q==","signatures":[{"sig":"MEUCIQDl87akFqg93C5DKvN9jO4DqM8YmWbJdnpCwj1jkWUF/gIgQ+rASKodwNBCj2chHrvO/Zg/RAnBy+c7HtGS3VTxyu0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":213361},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"bun":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"67d8e63019215b0db3c0d2c3b35bbae3f4fb0263","scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"alino","email":"alino.sadovsky@gmail.com"},"repository":{"url":"git+https://github.com/DecentChat/DecentChat.git","type":"git","directory":"decent-transport-webrtc"},"_npmVersion":"11.9.0","description":"WebRTC/PeerJS transport implementation for @decentchat/protocol","directories":{},"_nodeVersion":"25.6.1","dependencies":{"peerjs":"^1.5.4","@decentchat/protocol":"workspace:^"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/transport-webrtc_0.1.3_1775242736109_0.6633303424639694","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@decentchat/transport-webrtc","publishConfig":{"access":"public"},"version":"0.1.4","description":"WebRTC/PeerJS transport implementation for @decentchat/protocol","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","bun":"./src/index.ts"}},"scripts":{"typecheck":"tsc --noEmit","build":"tsc -p tsconfig.build.json","prepublishOnly":"npm run build"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/DecentChat/DecentChat.git","directory":"decent-transport-webrtc"},"dependencies":{"@decentchat/protocol":"^0.1.4","peerjs":"^1.5.4"},"devDependencies":{"@types/bun":"latest","typescript":"^5.6.0"},"_id":"@decentchat/transport-webrtc@0.1.4","bugs":{"url":"https://github.com/DecentChat/DecentChat/issues"},"homepage":"https://github.com/DecentChat/DecentChat#readme","_integrity":"sha512-nskUPAAqlRs0ItrtUGmwwX6ghYjymyYwMjNFcUW4pcucNhZbIO+AlgceAdDhaTN3aEF7LdpS0CIyxW3V0cgbdA==","_resolved":"/tmp/decent-transport-webrtc-0.1.4.tgz","_from":"file:/tmp/decent-transport-webrtc-0.1.4.tgz","_nodeVersion":"25.6.1","_npmVersion":"11.9.0","dist":{"integrity":"sha512-nskUPAAqlRs0ItrtUGmwwX6ghYjymyYwMjNFcUW4pcucNhZbIO+AlgceAdDhaTN3aEF7LdpS0CIyxW3V0cgbdA==","shasum":"797d4336f1d5888996bed737e6cb07e80ef18ad2","tarball":"https://registry.npmjs.org/@decentchat/transport-webrtc/-/transport-webrtc-0.1.4.tgz","fileCount":17,"unpackedSize":225226,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHtP8YQBv+jmv+BDLYYFRaA5UmXZmg76vAtBizes0wesAiEA2WZlSxmMpvVLUZSQFYpQpRSKYgxEwgLnbLDM3NLDPxc="}]},"_npmUser":{"name":"alino","email":"alino.sadovsky@gmail.com"},"directories":{},"maintainers":[{"name":"alino","email":"alino.sadovsky@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/transport-webrtc_0.1.4_1775767446871_0.9930320844680496"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-27T23:49:43.055Z","modified":"2026-04-09T20:44:07.179Z","0.1.0":"2026-03-27T23:49:43.270Z","0.1.1":"2026-03-28T00:22:54.579Z","0.1.2":"2026-03-28T10:33:58.729Z","0.1.3":"2026-04-03T18:58:56.249Z","0.1.4":"2026-04-09T20:44:07.064Z"},"bugs":{"url":"https://github.com/DecentChat/DecentChat/issues"},"license":"MIT","homepage":"https://github.com/DecentChat/DecentChat#readme","repository":{"type":"git","url":"git+https://github.com/DecentChat/DecentChat.git","directory":"decent-transport-webrtc"},"description":"WebRTC/PeerJS transport implementation for @decentchat/protocol","maintainers":[{"name":"alino","email":"alino.sadovsky@gmail.com"}],"readme":"# @decentchat/transport-webrtc\n\nWebRTC transport for [`@decentchat/protocol`](https://npmjs.com/package/@decentchat/protocol). Connects peers over WebRTC data channels using [PeerJS](https://peerjs.com/) for signaling.\n\n## What it does\n\nImplements the `Transport` interface from `@decentchat/protocol` so peers can send and receive messages over WebRTC. Handles signaling server connections, ICE/TURN negotiation, connection deduplication (glare resolution), heartbeat monitoring, and auto-reconnect with exponential backoff.\n\nSupports multiple signaling servers simultaneously. Alice on `signal.alice.com` and Bob on `signal.bob.com` can talk if they share at least one server -- similar to how email MX records work. If both servers discover the same peer, only one connection is kept.\n\n## Install\n\n```\nnpm install @decentchat/transport-webrtc\n```\n\nDepends on `@decentchat/protocol` and `peerjs`.\n\n## Quick start\n\n```ts\nimport { PeerTransport } from '@decentchat/transport-webrtc';\n\nconst transport = new PeerTransport({\n  signalingServers: ['https://0.peerjs.com/'],\n});\n\ntransport.onConnect = (peerId) => console.log('connected:', peerId);\ntransport.onMessage = (peerId, data) => console.log('message from', peerId, data);\n\nconst myId = await transport.init();\nawait transport.connect('some-peer-id');\ntransport.send('some-peer-id', { hello: 'world' });\n```\n\n## Embedded signaling server\n\nEvery node can run its own signaling server, removing the need for external infrastructure:\n\n```ts\nimport { EmbeddedSignaling } from '@decentchat/transport-webrtc';\n\nconst server = new EmbeddedSignaling({ port: 9000 });\nawait server.start();\n// Other peers can now connect via ws://your-ip:9000/peerjs\n```\n\nThis runs in Node.js/Bun. Browser clients connect to it; they don't run it.\n\n## ICE/TURN configuration\n\nThree ICE server constants are exported for convenience:\n\n- `DEFAULT_ICE_SERVERS` -- Google STUN servers\n- `DEFAULT_TURN_SERVERS` -- open relay TURN (dev only, rate-limited)\n- `ICE_SERVERS_WITH_TURN` -- both combined\n\nFor production, pass your own TURN credentials:\n\n```ts\nconst transport = new PeerTransport({\n  signalingServers: ['https://signal.example.com/peerjs'],\n  turnServers: [\n    { urls: 'turn:turn.example.com:443', username: 'user', credential: 'pass' },\n  ],\n});\n```\n\nOn localhost, ICE servers are skipped entirely (host candidates work fine, and STUN timeouts break tests).\n\n## Config reference\n\n`PeerTransportConfig` fields:\n\n| Field | Default | Description |\n|-------|---------|-------------|\n| `signalingServer` | -- | Single server URL (legacy) |\n| `signalingServers` | `[]` | Multiple servers for federation |\n| `iceServers` | auto | Full override for ICE config |\n| `useTurn` | `true` | Include TURN servers (auto-false on localhost) |\n| `turnServers` | open relay | Custom TURN servers |\n| `debug` | `1` | PeerJS log level (0-3) |\n| `maxRetries` | `3` | Connection retries per server |\n| `retryDelayMs` | `2000` | Base retry delay (doubles each attempt) |\n\n## Build\n\n```\nnpm run build    # compiles to dist/ via tsc\n```\n\nBoth compiled JS (`dist/`) and raw TypeScript (`src/`) are included in the npm package. Bun users get direct `.ts` imports via the `\"bun\"` export condition.\n\n## Repository\n\nThis package lives in the `decent-transport-webrtc/` directory of the [DecentChat monorepo](https://github.com/DecentChat/DecentChat).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}