dPay

dPack Storage

dPack specific storage provider for dDrive

npm install @dpack/storage

Usage

var storage = require('@dpack/storage')

// files are stored in ./my-dataset
// metadata (hashes and stuff) are stored in ./my-dataset/.dpack
// secret keys are stored in ~/.dpack/secret_keys/
var vault = 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 dPack storage methods for other files. Here's an example of overriding only the secret key storage and nothing else:

const defaultStorage = require('@dpack/storage')
const alternativeSecretStorage = require('your-custom-dwref-module')

module.exports = function keychainStorage() {
  const storage = defaultStorage(...arguments)
  return {
    metadata: function(file, opts) {
      if (file === 'secret_key') alternativeSecretStorage(file)
      return storage.metadata(...arguments)
    },
    content: function(file, opts) {
      return storage.content(...arguments)
    }
  }
}

Options

  • secretDir - folder to store secret keys in (default is users home dir)
  • prefix - subfolder to put dPack syncing and historical files in (default is .dpack/)

Secret Keys

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

var storage = require('@dpack/storage')

var vault = ddrive(storage('my-dataset', {secretDir: '/secret_keys'})