{"id":16252107,"url":"https://github.com/samuelmaddock/swarm-peer-server","last_synced_at":"2025-03-19T20:31:11.913Z","repository":{"id":52690635,"uuid":"121343246","full_name":"samuelmaddock/swarm-peer-server","owner":"samuelmaddock","description":"🖧 A network swarm for creating secure P2P connections over BitTorrent DHT, DNS, and mDNS.","archived":false,"fork":false,"pushed_at":"2023-04-20T14:10:10.000Z","size":76,"stargazers_count":43,"open_issues_count":3,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-17T10:51:32.882Z","etag":null,"topics":["bittorrent","decentralized","p2p"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samuelmaddock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-13T05:35:31.000Z","updated_at":"2024-07-09T09:49:55.000Z","dependencies_parsed_at":"2024-10-27T21:31:09.199Z","dependency_job_id":"c5490f9a-0f11-4f33-93bb-634a7e4f5f1d","html_url":"https://github.com/samuelmaddock/swarm-peer-server","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.023809523809523836","last_synced_commit":"e76bd2b3fa66b4275e6ef861e67c72587ccfa05e"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Fswarm-peer-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Fswarm-peer-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Fswarm-peer-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samuelmaddock%2Fswarm-peer-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samuelmaddock","download_url":"https://codeload.github.com/samuelmaddock/swarm-peer-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244501275,"owners_count":20462834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bittorrent","decentralized","p2p"],"created_at":"2024-10-10T15:12:28.176Z","updated_at":"2025-03-19T20:31:11.591Z","avatar_url":"https://github.com/samuelmaddock.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swarm-peer-server\n\nA network swarm for creating secure P2P connections over Bittorrent DHT, DNS, and mDNS.\n\nUses [discovery-swarm](https://github.com/mafintosh/discovery-swarm) to find and connect peers. Connections use asymmetric encryption and [Elliptic-curve Diffie-Hellman](https://en.wikipedia.org/wiki/Elliptic-curve_Diffie%E2%80%93Hellman) to establish a secure communication channel. Clients must know the public key of a peer ahead of time to initiate the connection.\n\nDepends on native modules [libsodium](https://libsodium.org) (via [sodium-native](https://github.com/sodium-friends/sodium-native)) and [libutp](https://github.com/bittorrent/libutp) (via [utp-native](https://github.com/mafintosh/utp-native)).\n\n```bash\nnpm install swarm-peer-server\n```\n\n## Usage\n\n### Server\n```js\nvar swarm = require('swarm-peer-server')\n\nswarm.listen({\n  publicKey: Buffer.from('...'),\n  secretKey: Buffer.from('...')\n}, (socket, peerKey, info) =\u003e {\n  console.log('New authenticated connection')\n  socket.once('data', data =\u003e {\n    console.log('Received:', data.toString())\n    socket.destroy()\n  })\n})\n```\n\n### Client\n```js\nvar swarm = require('swarm-peer-server')\n\nvar { socket } = await swarm.connect({\n  publicKey: Buffer.from('...'),\n  secretKey: Buffer.from('...'),\n  hostPublicKey: Buffer.from('...')\n})\n\nconsole.log('Established connection')\nconst data = Buffer.from('hello world')\nsocket.write(data)\n```\n\n### Examples\n\n```bash\nexamples/echo.js # CLI echo server\n```\n\n## API\n\n#### `var sw = swarm.listen(opts)`\n\nCreate a new swarm server. Options include:\n\n```js\n{\n  publicKey: crypto.randomBytes(32), // server public key\n  secretKey: crypto.randomBytes(64), // server secret key\n  convert: false, // convert signatures to authentication encryption [1]\n}\n```\n[1] https://download.libsodium.org/doc/advanced/ed25519-curve25519.html\n\nFor full list of options take a look at [discovery-swarm](https://github.com/mafintosh/discovery-swarm/blob/master/README.md#var-sw--swarmopts) or the [TypeScript definitions](index.d.ts).\n\n#### `swarm.connect(opts, (socket, peerKey, info) =\u003e {})`\n\nCreate a new swarm server. Options include:\n\n```js\n{\n  hostPublicKey: crypto.randomBytes(32), // host/server public key\n  publicKey: crypto.randomBytes(32), // client public key\n  secretKey: crypto.randomBytes(64), // client secret key\n  convert: false, // convert signatures to authentication encryption\n}\n```\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmaddock%2Fswarm-peer-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamuelmaddock%2Fswarm-peer-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamuelmaddock%2Fswarm-peer-server/lists"}