{"id":15356697,"url":"https://github.com/filips123/zeroframejs","last_synced_at":"2025-09-14T19:54:36.631Z","repository":{"id":35003947,"uuid":"195115292","full_name":"filips123/ZeroFrameJS","owner":"filips123","description":"ZeroFrame WebSocket API for JavaScript","archived":false,"fork":false,"pushed_at":"2022-04-28T21:21:04.000Z","size":1713,"stargazers_count":6,"open_issues_count":13,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T06:41:47.072Z","etag":null,"topics":["decentralized","library","p2p","websocket","zeroframe","zeronet"],"latest_commit_sha":null,"homepage":"https://github.com/filips123/ZeroFrameJS","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/filips123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"filips123","tidelift":"npm/zeroframe-ws-client","open_collective":"filips123","patreon":"filips","ko_fi":"filips","liberapay":"filips","custom":["https://donorbox.org/filips","https://buymeacoff.ee/filips","https://beerpay.io/filips123","https://tippin.me/@123filips123"]}},"created_at":"2019-07-03T19:29:08.000Z","updated_at":"2020-04-28T14:36:31.000Z","dependencies_parsed_at":"2022-08-08T03:16:12.598Z","dependency_job_id":null,"html_url":"https://github.com/filips123/ZeroFrameJS","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FZeroFrameJS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FZeroFrameJS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FZeroFrameJS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/filips123%2FZeroFrameJS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/filips123","download_url":"https://codeload.github.com/filips123/ZeroFrameJS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023725,"owners_count":21199958,"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":["decentralized","library","p2p","websocket","zeroframe","zeronet"],"created_at":"2024-10-01T12:29:38.864Z","updated_at":"2025-04-15T06:41:55.250Z","avatar_url":"https://github.com/filips123.png","language":"JavaScript","funding_links":["https://github.com/sponsors/filips123","https://tidelift.com/funding/github/npm/zeroframe-ws-client","https://opencollective.com/filips123","https://patreon.com/filips","https://ko-fi.com/filips","https://liberapay.com/filips","https://donorbox.org/filips","https://buymeacoff.ee/filips","https://beerpay.io/filips123","https://tippin.me/@123filips123"],"categories":[],"sub_categories":[],"readme":"ZeroFrameJS\n===========\n\n[![version][icon-version]][link-npm]\n[![downloads][icon-downloads]][link-npm]\n[![license][icon-license]][link-license]\n[![node][icon-nodejs]][link-nodejs]\n[![build][icon-travis]][link-travis]\n\nZeroFrame WebSocket API for JavaScript.\n\n## Description\n\nThis is JavaScript WebSocket client for [ZeroFrame API][link-zeroframe]. It supports (almost) same features as default ZeroFrame that is included in ZeroNet sites, but it is using WebSocket client so it can be used in local programs, such as Node.js and Electron. It can't be used in browsers because of CORS restrictions.\n\n## Installation\n\n### Requirements\n\nZeroFrameJS requires Node.js 10 or higher.\n\n### With Yarn\n\nThe recommended way to install ZeroFrameJS is with Yarn.\n\n```bash\nyarn add zeroframe-ws-client\n```\n\n### With NPM\n\nAlternatively, you can also install it with NPM but it won't respect `yarn.lock` file.\n\n```bash\nnpm install --save zeroframe-ws-client\n```\n\n## Usage\n\n### Importing Package\n\nYou can import ZeroFrameJS with CJS or ESM.\n\n```js\nconst ZeroFrame = require('zeroframe-ws-client') // Using CJS\nimport ZeroFrame from 'zeroframe-ws-client' // Using ESM\n```\n\n### Creating Connection\n\nTo create a connection, you need to specify the ZeroNet site address.\n\n```js\nconst zeroframe = new ZeroFrame('1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D')\n```\n\nIf ZeroNet instance is using `Multiuser` plugin, you need to specify a master address of the account you want to use. Account must already exist on the instance.\n\n```js\nconst zeroframe = new ZeroFrame(\n  '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D', {\n    multiuser: {\n      masterAddress: '1Hxki73XprDRedUdA3Remm3kBX5FZxhFR3'\n    }\n})\n```\n\nIf you want to create a new account, you also need to specify a master seed of it. Note that this feature is unsafe on the untrusted proxy. Also, it is currently not implemented yet.\n\n```js\nconst zeroframe = new ZeroFrame(\n  '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D', {\n    multiuser: {\n      masterAddress: '1KAtuzxwbD1QuMHMuXWcUdoo5ppc5wnot9',\n      masterSeed: 'fdbaf75427ba69a3d4aa8e19372e05879e9e2d866e579dd30be25e6fab7e3fb2'\n    }\n})\n```\n\nIf needed, you can also specify protocol, host and port of ZeroNet instance.\n\n```js\nconst zeroframe = new ZeroFrame(\n  '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D', {\n    instance: {\n      host: '192.168.1.1',\n      port: 8080,\n      secure: true\n    }\n})\n```\n\nLog and error message from `zeroframe.log` and `zeroframe.error` will not be displayed by default. If you want to, you can also display them as debug info.\n\n```js\nconst zeroframe = new ZeroFrame(\n  '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D', {\n    show: {\n      log: true,\n      error: true\n    }\n})\n```\n\nBy default, the client will try to reconnect WebSocket if the connection was closed every 5 seconds. You can also configure time delay and total attempts. Delay is specified in milliseconds. The number of attempts `-1` means infinity and `0` means zero (disabled reconnecting).\n\n```js\nconst zeroframe = new ZeroFrame(\n  '1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D', {\n      reconnect: {\n        attempts: 10,\n        delay: 1000\n      }\n})\n```\n\nThe client will then obtain wrapper key to the site and connect to WebSocket using it.\n\nYou can now normally use ZeroFrame API. Just remember that there is no wrapper, so wrapper commands are not available. The client is connected directly to the WebSocket server, so you need to use its commands.\n\nNote that the WebSocket server sometimes sends commands (`notification`, `progress`, `error`, `prompt`, `confirm`, `setSiteInfo`, `setAnnouncerInfo`, `updating`, `redirect`, `injectHtml`, `injectScript`) that are normally handled by the wrapper. Because there is no wrapper, you need to handle those commands yourself if needed. Commands `response` and `ping` are already handled by this client so you don't need to handle them.\n\n### Sending Command\n\nYou can use the `cmd` method to issue commands.\n\n```js\nzeroframe.cmd(\n  'siteInfo',\n  {},\n  (result) =\u003e {\n    console.log(result)\n  }\n)\n```\n\nYou can also use the `cmdp` method to get results as JavaScript promises.\n\n```js\nlet result = await zeroframe.cmdp('siteInfo', {})\n```\n\n### Sending Response\n\nTo submit responses, you need to use `response` command.\n\n```js\nzeroframe.response(10, 'Hello World')\n```\n\n### Logging Information\n\nThere are also `log` and `error` methods which are available for logging. They will display output to console if enabled.\n\n```js\nzeroframe.log('Connected')\nzeroframe.error('Connection failed')\n```\n\n### Handling Connection\n\nThere are also public handler methods which you can overwrite to add your own logic to ZeroFrame.\n\n```js\nclass ZeroApp extends ZeroFrame {\n  onRequest (cmd, message) {\n    if (cmd === 'helloWorld') {\n      this.log('Hello World')\n    }\n  }\n\n  onOpenWebsocket (event) {\n    this.log('Connected to WebSocket')\n  }\n\n  onErrorWebsocket (event) {\n    this.error('WebSocket connection error')\n  }\n\n  onCloseWebsocket (event) {\n    this.error('WebSocket connection closed')\n  }\n}\n```\n\n### Closing Connection\n\nYou can use `close` method to close WebSocket connection to ZeroFrame API.\n\n```js\nzeroframe.close()\n```\n\n### Calling Commands Directly\n\nYou can also directly call commands via `Proxy` object. Command name is accepted as an object's property and parameters are accepted as a method's arguments. Command returns `Promise` with the result.\n\n * Command with no arguments can be accessed with `zeroframe.proxy.cmdName()`.\n * Command with keyword arguments can be accessed with `zeroframe.proxy.cmdName({key1: value1, key2: value2})`.\n * Command with normal arguments can be accessed with `zeroframe.proxy.cmdName(value1, value2)`.\n\n```js\nlet siteInfo = await zeroframe.proxy.siteInfo()\n```\n\n### Other Examples\n\nYou could also look to [`example.js`][link-example] or [API documentation][link-documentation].\n\n## Versioning\n\nThis library uses [SemVer][link-semver] for versioning. For the versions available, see [the tags][link-tags] on this repository.\n\n## License\n\nThis library is licensed under the MIT license. See the [LICENSE][link-license-file] file for details.\n\n[icon-version]: https://img.shields.io/npm/v/zeroframe-ws-client.svg?style=flat-square\u0026label=version\n[icon-downloads]: https://img.shields.io/npm/dt/zeroframe-ws-client.svg?style=flat-square\u0026label=downloads\n[icon-license]: https://img.shields.io/npm/l/zeroframe-ws-client.svg?style=flat-square\u0026label=license\n[icon-nodejs]: https://img.shields.io/node/v/zeroframe-ws-client.svg?style=flat-square\u0026label=node\n[icon-travis]: https://img.shields.io/travis/com/filips123/ZeroFrameJS.svg?style=flat-square\u0026labelbuild\n\n[link-npm]: https://www.npmjs.com/package/zeroframe-ws-client/\n[link-license]: https://choosealicense.com/licenses/mit/\n[link-nodejs]: https://nodejs.org/\n[link-travis]: https://travis-ci.com/filips123/ZeroFrameJS/\n[link-semver]: https://semver.org/\n\n[link-tags]: https://github.com/filips123/ZeroFrameJS/tags/\n[link-license-file]: https://github.com/filips123/ZeroFrameJS/blob/master/LICENSE\n[link-example]: https://github.com/filips123/ZeroFrameJS/blob/master/example.js\n[link-documentation]: https://zeroframe.js.org/\n\n[link-zeroframe]: https://zeronet.io/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilips123%2Fzeroframejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffilips123%2Fzeroframejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffilips123%2Fzeroframejs/lists"}