UNPKG

ssb-box

Version:

The original private-box SSB encryption format, for ssb-db2

58 lines 3.2 kB
{ "name": "ssb-box", "version": "1.0.1", "description": "The original private-box SSB encryption format, for ssb-db2", "repository": { "type": "git", "url": "git+https://github.com/ssbc/ssb-box.git" }, "bugs": { "url": "https://github.com/ssbc/ssb-box/issues" }, "homepage": "https://github.com/ssbc/ssb-box#readme", "author": "Andre Staltz <contact@staltz.com>", "contributors": [ "Anders Rune Jensen <arj03@protonmail.ch>" ], "license": "LGPL-3.0", "keywords": [ "ssb" ], "engines": { "node": ">=12" }, "main": "index.js", "files": [ "package.json.license", "LICENSES/*", "*.js" ], "dependencies": { "chloride": "^2.4.1", "private-box": "^0.3.1", "ssb-ref": "^2.16.0", "ssb-uri2": "^2.0.2" }, "devDependencies": { "c8": "^7.11.3", "husky": "4.3", "prettier": "^2.6.2", "pretty-quick": "^3.1.3", "ssb-encryption-format": "^2.2.0", "ssb-keys": "^8.4.0", "tap-arc": "^0.3.4", "tape": "^5.5.3" }, "husky": { "hooks": { "pre-commit": "npm run format-code-staged" } }, "scripts": { "test": "tape test/*.js | tap-arc --bail", "format-code": "prettier --write \"*.js\"", "format-code-staged": "pretty-quick --staged --pattern \"*.js\"", "coverage": "c8 --reporter=lcov npm run test" }, "readme": "<!--\nSPDX-FileCopyrightText: 2022 Andre 'Staltz' Medeiros <contact@staltz.com>\n\nSPDX-License-Identifier: CC0-1.0\n-->\n\n# ssb-box\n\nThis module implements the original \"private-box\" encryption format for SSB. You can use this module as an ssb-db2 plugin, or you can use it as a standalone tool to encrypt and decrypt messages.\n\n## Installation\n\n- Requires **Node.js 12** or higher\n\n```bash\nnpm install ssb-box\n```\n\n## Usage in ssb-db2\n\nYOU MOST LIKELY DON'T NEED TO DO THIS, because ssb-db2 bundles ssb-box already. But maybe one day ssb-db2 won't bundle it anymore, and then you _would_ have to do this.\n\n- Requires `secret-stack@^6.2.0`\n- Requires `ssb-db2@>=5.0.0`\n\n```diff\n SecretStack({appKey: require('ssb-caps').shs})\n .use(require('ssb-master'))\n+ .use(require('ssb-db2'))\n+ .use(require('ssb-box'))\n .use(require('ssb-conn'))\n .use(require('ssb-blobs'))\n .call(null, config)\n```\n\n## Usage as a standalone\n\nThis module conforms with [ssb-encryption-format](https://github.com/ssbc/ssb-encryption-format) so with ssb-box you can use all the methods specified by ssb-encryption-format.\n\n```js\nconst ssbKeys = require('ssb-keys');\nconst boxFormat = require('ssb-box/format');\n\nconst keys = ssbKeys.generate('ed25519', 'alice');\nconst opts = {recps: [keys.id], keys};\n\nconst plaintext = Buffer.from('hello');\nconsole.log(plaintext);\n// <Buffer 68 65 6c 6c 6f>\n\nconst ciphertext = boxFormat.encrypt(plaintext, opts);\nconsole.log(ciphertext);\n// <Buffer 9e 60 59 b7 02 a3 c8 74 0f 1e 3c b9 b7 99 80 b4 cb f1 35 a0 48 40 16 d4 fa b9 a6 18 37 f0 cc 1c 37 18 e0 c0 a4 c4 3a 9e 3a 74 6a 89 1f 50 0d 4f 78 6a ... 76 more bytes>\n\nconst decrypted = boxFormat.decrypt(ciphertext, opts);\nconsole.log(decrypted);\n// <Buffer 68 65 6c 6c 6f>\n```\n\n## License\n\nLGPL-3.0-only\n" }