项目作者: DistributedWeb

项目描述 :
DEPRECATED LEGACY DWEB MODULE
高级语言: JavaScript
项目地址: git://github.com/DistributedWeb/dwebx-storage.git
创建时间: 2020-08-21T09:36:53Z
项目社区:https://github.com/DistributedWeb/dwebx-storage

开源协议:MIT License

下载


dwebx-storage

DWebX specific storage provider for DDrive

  1. npm install dwebx-storage

Usage

  1. var storage = require('dwebx-storage')
  2. // files are stored in ./my-dataset
  3. // metadata (hashes and stuff) are stored in ./my-dataset/.dwebx
  4. // secret keys are stored in ~/.dwebx/secret_keys/<discovery-key>
  5. var archive = ddrive(storage('my-dataset'))

Custom storage provider

You can require this module in your own storage provider in order to override certain behaviors for some files while still using the default dwebx storage methods for other files. Here’s an example of overriding only the secret key storage and nothing else:

  1. const defaultStorage = require('dwebx-storage')
  2. const alternativeSecretStorage = require('your-own-custom-random-access-file-module')
  3. module.exports = function keychainStorage() {
  4. const storage = defaultStorage(...arguments)
  5. return {
  6. metadata: function(file, opts) {
  7. if (file === 'secret_key') alternativeSecretStorage(file)
  8. return storage.metadata(...arguments)
  9. },
  10. content: function(file, opts) {
  11. return storage.content(...arguments)
  12. }
  13. }
  14. }

Options

  • secretDir - folder to store secret keys in (default is users home dir)
  • prefix - subfolder to put dwebx SLEEP files in (default is .dwebx/)

Secret Keys

By default secret keys are stored in the users home directory via dwebx-secret-storage. To change the directory, pass it as an option:

  1. var storage = require('dwebx-storage')
  2. var archive = ddrive(storage('my-dataset', {secretDir: '/secret_keys'})

License

MIT