{"id":24143323,"url":"https://github.com/little-core-labs/hypercore-xsalsa20-onwrite-hook","last_synced_at":"2025-07-18T04:36:10.874Z","repository":{"id":100550564,"uuid":"185222420","full_name":"little-core-labs/hypercore-xsalsa20-onwrite-hook","owner":"little-core-labs","description":"A write hook to encrypt/decrypt data using a XSalsa20 cipher into a hypercore storage when replicating from peers","archived":false,"fork":false,"pushed_at":"2020-02-04T12:08:58.000Z","size":29,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T16:03:51.425Z","etag":null,"topics":["hook","hypercore","write","xsalsa20"],"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/little-core-labs.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":"2019-05-06T15:21:43.000Z","updated_at":"2023-08-08T00:55:14.000Z","dependencies_parsed_at":"2023-05-15T20:45:44.823Z","dependency_job_id":null,"html_url":"https://github.com/little-core-labs/hypercore-xsalsa20-onwrite-hook","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.04166666666666663,"last_synced_commit":"cdc88f1a348b5eba3e5fb1c7f972fa01bbc5c8bc"},"previous_names":["jwerle/hypercore-xsalsa20-onwrite-hook"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/little-core-labs/hypercore-xsalsa20-onwrite-hook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fhypercore-xsalsa20-onwrite-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fhypercore-xsalsa20-onwrite-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fhypercore-xsalsa20-onwrite-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fhypercore-xsalsa20-onwrite-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/little-core-labs","download_url":"https://codeload.github.com/little-core-labs/hypercore-xsalsa20-onwrite-hook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fhypercore-xsalsa20-onwrite-hook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265701124,"owners_count":23813751,"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":["hook","hypercore","write","xsalsa20"],"created_at":"2025-01-12T05:15:14.242Z","updated_at":"2025-07-18T04:36:10.850Z","avatar_url":"https://github.com/little-core-labs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"hypercore-xsalsa20-onwrite-hook\n===============================\n\n\u003e A write hook to decrypt data using a xsalsa20 cipher into a Hypercore\n\u003e storage when replicating from peers.\n\n## Installation\n\n```sh\n$ npm install hypercore-xsalsa20-onwrite-hook\n```\n\n## Usage\n\n```js\nconst onwrite = hook(sharedSecret)\n```\n\n## Example\n\n```js\nconst replicate = require('hypercore-replicate')\nconst hypercore = require('hypercore')\nconst crypto = require('hypercore-crypto')\nconst pump = require('pump')\nconst hook = require('hypercore-xsalsa20-onwrite-hook')\nconst ram = require('random-access-memory')\n\nconst key = crypto.randomBytes(32)\n\nconst { publicKey, secretKey } = crypto.keyPair()\n\nconst source = hypercore(ram, publicKey, {\n  secretKey,\n})\n\nconst cipher = hypercore(ram, publicKey, {\n  secretKey,\n  onwrite: hook(key)\n})\n\nconst edge = hypercore(ram, publicKey)\n\nconst reader = hypercore(ram, publicKey, {\n  onwrite: hook(key)\n})\n\nsource.append(Buffer.from('hello'), (err) =\u003e {\n  source.head(console.log) // plaintext\n\n  // load cipher hypercore\n  pump(source.createReadStream(), cipher.createWriteStream(), (err) =\u003e {\n    if (err) throw err\n    cipher.head(console.log) // ciphertext\n\n    replicate(cipher, edge, (err) =\u003e {\n      if (err) throw err\n      edge.head(console.log) // ciphertext\n\n      replicate(edge, reader, (err) =\u003e {\n        if (err) throw err\n        reader.head(console.log) // plaintext\n      })\n    })\n  })\n})\n```\n\n## API\n\n### `const onwrite = hook(nonceStorage, sharedKey)`\n\nCreates a `onwrite()` hook for a Hypercore feed that uses the\nxsalsa20 cipher to encipher or decipher blocks in a Hypercore feed.\nNonces are computed from the Hypercore feed's public key and block\nindex.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fhypercore-xsalsa20-onwrite-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittle-core-labs%2Fhypercore-xsalsa20-onwrite-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fhypercore-xsalsa20-onwrite-hook/lists"}