1.5.0 • Published 5 months ago

@exodus/storage-encrypted v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@exodus/storage-encrypted

Usage

Storage enhancer for the @exodus/storage-spec interface. It encrypts values on write, and decrypts them on read. To address cases where the encryption keys are available asynchronously, the enhancer accepts a promise that resolves to the encryption/decryption functions.

import pDefer from 'p-defer'
import withEncryption from '@exodus/storage-encrypted'
import { EXODUS_KEY_IDS } from '@exodus/key-ids'

const cryptoFunctions = pDefer()

const storage = withEncryption({
  storage: storage.namespace('wayne-foundation-blueprints'),
  cryptoFunctionsPromise: cryptoFunctions.promise,
})

const keyId = EXODUS_KEY_IDS.WALLET_INFO

// Crypto functions have to be resolved before the storage can be used
cryptoFunctions.resolve({
  // `keychain` is an instance of `@exodus/keychain`
  // `seedId` is the bip32 identifier, e.g. one you get via exodus.wallet.getPrimarySeedId()
  encrypt: (data) => keychain.sodium.encryptSecretBox({ seedId, keyId, data }),
  decrypt: (data) => keychain.sodium.decryptSecretBox({ seedId, keyId, data }),
})
1.5.0

5 months ago

1.4.2

10 months ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

2 years ago

1.1.2

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago