|
| 1 | +# dWeb Secret Key Storage |
| 2 | + |
| 3 | +## Install |
| 4 | + |
| 5 | +``` |
| 6 | +npm install @dpack/secret-storage |
| 7 | +``` |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +Return for the `secret_key` storage in dDrive/dDatabase. To avoid local ownership conflicts, pass the local directory as the first argument. `@dpack/secret-storage` will check for a non-empty ownership file in the source directory storage. |
| 12 | + |
| 13 | +```js |
| 14 | +var secretStore = require('@dpack/secret-storage') |
| 15 | + |
| 16 | +var storage = { |
| 17 | + metadata: function (name, opts) { |
| 18 | + if (name === 'secret_key') return secretStore()(path.join(dir, '.dweb/metadata.ogd'), opts) |
| 19 | + return // other storage |
| 20 | + }, |
| 21 | + content: function (name, opts) { |
| 22 | + return // other storage |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +// store secret key in ~/.dweb/secret_keys |
| 27 | +var vault = ddrive(storage) |
| 28 | +``` |
| 29 | + |
| 30 | +## API |
| 31 | + |
| 32 | +### `secretStorage([dir])(ownershipFile, opts)` |
| 33 | + |
| 34 | +* `dir`: directory to store keys under `dir/.dweb/secret_keys`. Defaults to users home directory. |
| 35 | +* `ownershipFile`: non-empty file that denotes ownership. This helps avoid local ownership conflicts of the same dPack. |
0 commit comments