1.1.2 • Published 8 months ago

@exodus/transform-storage v1.1.2

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

@exodus/transform-storage

Usage

storage-spec enhancer that applies provided onRead/onWrite transformations.

const storage = transformStorage({
  storage: storage.namespace('highly-secret'),
  onRead: async (ciphertext) => {
    const buffer = await decryptSecretBox({ data: Buffer.from(ciphertext, 'base64') })
    return JSON.parse(buffer.toString())
  },
  onWrite: async (value) => {
    const buffer = await encryptSecretBox({ data: JSON.stringify(value) })
    return buffer.toString('base64')
  },
})
1.1.2

8 months ago

1.1.1

9 months ago

1.1.0

1 year ago

1.0.0

3 years ago