{"_id":"@agree-able/rpc","_rev":"3-aca5867d46020712a40386d2dd9b4761","name":"@agree-able/rpc","dist-tags":{"latest":"3.0.0"},"versions":{"2.0.1":{"name":"@agree-able/rpc","version":"2.0.1","keywords":["agreeable","rpc","p2p"],"author":{"name":"Ryan Ramage"},"license":"ISC","_id":"@agree-able/rpc@2.0.1","maintainers":[{"name":"eckoit","email":"ryan.ramage@gmail.com"}],"homepage":"https://github.com/agree-able/rpc#readme","bugs":{"url":"https://github.com/agree-able/rpc/issues"},"dist":{"shasum":"49e3a03aa28acc3453010eff46ef9f582e134fc1","tarball":"https://registry.npmjs.org/@agree-able/rpc/-/rpc-2.0.1.tgz","fileCount":6,"integrity":"sha512-WYTQsI7ov79WrChrQgR9swJX8THUVC2rZL53Fa4MfS/nGSRAoDiodQ18FFYdv5ZD8TQKJeYGadRTnTDuRwZiUQ==","signatures":[{"sig":"MEYCIQCS7Edd21kSBQI988JFcx/Tk+zAAkPAGWX/cbjeEPtZRAIhAION668dOFZ/sEB2n9dszOlMojsMIMcNlBWEu+PNQtUw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9554},"main":"index.mjs","gitHead":"89fb116d1a61419fd539230d79e66fcbd5e89c71","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"eckoit","email":"ryan.ramage@gmail.com"},"repository":{"url":"git+https://github.com/agree-able/rpc.git","type":"git"},"_npmVersion":"10.7.0","description":"create and use rpc using p2p","directories":{},"_nodeVersion":"20.14.0","dependencies":{"hyperdht":"^6.14.0","protomux":"^3.5.1","jsonrpc-mux":"^1.1.1","@agree-able/contract":"^1.4.1","hypercore-id-encoding":"^1.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/rpc_2.0.1_1732238712828_0.17979341955469175","host":"s3://npm-registry-packages"}},"2.0.2":{"name":"@agree-able/rpc","version":"2.0.2","keywords":["agreeable","rpc","p2p"],"author":{"name":"Ryan Ramage"},"license":"ISC","_id":"@agree-able/rpc@2.0.2","maintainers":[{"name":"eckoit","email":"ryan.ramage@gmail.com"}],"homepage":"https://github.com/agree-able/rpc#readme","bugs":{"url":"https://github.com/agree-able/rpc/issues"},"dist":{"shasum":"8d880ec6354e55a5504a7d31ffb77b1e3304776d","tarball":"https://registry.npmjs.org/@agree-able/rpc/-/rpc-2.0.2.tgz","fileCount":6,"integrity":"sha512-mdCnjunyk3W3j4EXGRXaCWI70mykfvLv0wp2PepP50RxGw1T9b9BlYR5FLxHgCNT8OmSJc1mnIeIjkjkaWczRg==","signatures":[{"sig":"MEUCIHAsegCrPU+CICLU4roCi5+8LG+QmfwrhZ7HBTQhsm+OAiEAuu1gS8DsxCPFm5p3fbOm0VMw7qTQyeKbAi+VpOT3D54=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9555},"main":"index.mjs","gitHead":"9b9d93e727484b5813775a0f1ea9c9bf85010bc9","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"eckoit","email":"ryan.ramage@gmail.com"},"repository":{"url":"git+https://github.com/agree-able/rpc.git","type":"git"},"_npmVersion":"10.7.0","description":"create and use rpc using p2p","directories":{},"_nodeVersion":"20.14.0","dependencies":{"hyperdht":"^6.14.0","protomux":"^3.5.1","jsonrpc-mux":"^1.1.1","@agree-able/contract":"^1.4.1","hypercore-id-encoding":"^1.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/rpc_2.0.2_1732239828504_0.4377547154468284","host":"s3://npm-registry-packages"}},"2.0.3":{"name":"@agree-able/rpc","version":"2.0.3","keywords":["agreeable","rpc","p2p"],"author":{"name":"Ryan Ramage"},"license":"ISC","_id":"@agree-able/rpc@2.0.3","maintainers":[{"name":"eckoit","email":"ryan.ramage@gmail.com"}],"homepage":"https://github.com/agree-able/rpc#readme","bugs":{"url":"https://github.com/agree-able/rpc/issues"},"dist":{"shasum":"ef615e1ee15159b69e7f2152f78de87bec609eaf","tarball":"https://registry.npmjs.org/@agree-able/rpc/-/rpc-2.0.3.tgz","fileCount":6,"integrity":"sha512-WH7+M9y0QgbeEm1weDVAidzizHiaNbE9ZWyFO0iQnD0awgDn4fg6PA3sx68eH1yDd6qJLe13eoNpF7AUQ5xLTw==","signatures":[{"sig":"MEQCIF/VFrehkuYw95zIkARdt2C/7mBLN0t8JAfdIkze67NfAiAjkYcXjdj3LAjz5j+zFz26tHit2isktpUdns7HayAG7Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9555},"main":"index.mjs","gitHead":"320a2688e0e60f25ff3b6256d73c60560c82a9e3","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"eckoit","email":"ryan.ramage@gmail.com"},"repository":{"url":"git+https://github.com/agree-able/rpc.git","type":"git"},"_npmVersion":"10.7.0","description":"create and use rpc using p2p","directories":{},"_nodeVersion":"20.14.0","dependencies":{"hyperdht":"^6.14.0","protomux":"^3.5.1","jsonrpc-mux":"^1.1.1","@agree-able/contract":"^1.4.1","hypercore-id-encoding":"^1.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/rpc_2.0.3_1732293467674_0.7350815778916611","host":"s3://npm-registry-packages"}},"3.0.0":{"name":"@agree-able/rpc","version":"3.0.0","description":"create and use rpc using p2p","main":"index.mjs","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/agree-able/rpc.git"},"keywords":["agreeable","rpc","p2p"],"author":{"name":"Ryan Ramage"},"license":"ISC","bugs":{"url":"https://github.com/agree-able/rpc/issues"},"homepage":"https://github.com/agree-able/rpc#readme","dependencies":{"@agree-able/contract":"^2.0.0","hypercore-id-encoding":"^1.3.0","hyperdht":"^6.14.0","jsonrpc-mux":"^1.1.1","protomux":"^3.5.1"},"_id":"@agree-able/rpc@3.0.0","gitHead":"19dc62081a2b84079717338cbf80fdde5b5fa8fd","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-Y3203MHo7nxN5rpo9DPDefkDntRZW84MBTW1b/w/1kaZXaN8M7KoN2PFidQcY+8CLNGEyovDIDz8OZ0m6Joebg==","shasum":"76a8c383941cad0f4f6fe7472dfdd5d143026526","tarball":"https://registry.npmjs.org/@agree-able/rpc/-/rpc-3.0.0.tgz","fileCount":15,"unpackedSize":65965,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCxfrPM/20+oxJDBlv2dTYX2siyT5AN6Ye59wDVSgSi8QIhAPEIDGhc9YFva/dq/eJPVM4Iw4VPYndwpfRPKuNrOSvK"}]},"_npmUser":{"name":"eckoit","email":"ryan.ramage@gmail.com"},"directories":{},"maintainers":[{"name":"eckoit","email":"ryan.ramage@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rpc_3.0.0_1732820165013_0.40434503231561814"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-22T01:25:12.718Z","modified":"2024-11-28T18:56:05.418Z","2.0.1":"2024-11-22T01:25:13.027Z","2.0.2":"2024-11-22T01:43:48.667Z","2.0.3":"2024-11-22T16:37:47.859Z","3.0.0":"2024-11-28T18:56:05.238Z"},"bugs":{"url":"https://github.com/agree-able/rpc/issues"},"author":{"name":"Ryan Ramage"},"license":"ISC","homepage":"https://github.com/agree-able/rpc#readme","keywords":["agreeable","rpc","p2p"],"repository":{"type":"git","url":"git+https://github.com/agree-able/rpc.git"},"description":"create and use rpc using p2p","maintainers":[{"name":"eckoit","email":"ryan.ramage@gmail.com"}],"readme":"# Agreeable RPC\n\n🤝 Type-safe P2P RPC that just works. A [🍐](https://docs.pears.com) project.\n\n## Why Agreeable RPC?\n\n- **Simple API**: Build P2P services with minimal boilerplate\n- **Developer Experience**: Interactive testing UI included\n- **Trust**: Define clear contracts between peers\n- **Type Safety**: Full TypeScript/JSDoc support with runtime validation\n\n## Quick Start\n\n### 1. Install\n\n```bash\nnpm i @agree-able/contract @agreeable/rpc\n```\n\n### 2. Define Your API (agreement.mjs)\n\n```js\nimport { z, addRoute } from '@agree-able/contract'\n\n// Define your functions with Zod\nexport const AddTwo = z.function()\n  .args(z.object({\n    a: z.number(),\n    b: z.number()\n  }))\n  .returns(z.promise(z.number()))\n\n// Create the API contract\nexport default {\n  role: 'calculator',\n  version: '1.0.0',\n  routes: {\n    addTwo: addRoute(AddTwo)\n  }\n}\n```\n\n### 3. Implement the Server (server.mjs)\n\n```js\nimport { loadAgreement, host } from '@agree-able/rpc'\n\n// Implement your functions\nconst addTwo = async ({a, b}) => a + b\n\n// Start the server\nhost(await loadAgreement('./agreement.mjs', import.meta.url), { addTwo })\n```\n\n### 4. Create the Client (client.mjs)\n\n```js\nimport { Caller } from '@agree-able/rpc'\nimport agreement from './agreement.mjs'\n\nconst peerKey = process.argv[2]\nconst caller = new Caller(peerKey)\nconst { addTwo } = caller.proxy(agreement)\n\n// Call remote functions\nconst result = await addTwo({ a: 1, b: 2 })\nconsole.log(result) // 3\ncaller.destroy()\n```\n\n## Running the Example\n\n1. Start the server:\n```bash\nnode server.mjs\n# Will print a public key like: 3e32bb2d191316d952ae77439f7ec00a5c4fea8a01953b84d1b4eee36173e1ca\n```\n\n2. Run the client with the server's public key:\n```bash\nnode client.mjs 3e32bb2d191316d952ae77439f7ec00a5c4fea8a01953b84d1b4eee36173e1ca\n```\n\n## Interactive Testing\n\nUse our UI tool to explore and test your APIs: [https://github.com/agree-able/ui](https://github.com/agree-able/ui)\n\n## Learn More\n\n- [Full Documentation](https://github.com/agree-able/rpc/tree/master/docs)\n- [Example](https://github.com/agree-able/rpc/tree/master/demo)\n\n## Contributing\n\nWe welcome contributions! See our [contributing guide](CONTRIBUTING.md) for details.\n\n\n","readmeFilename":"README.md"}