@exodus/transform-storage
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@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')
  },
})

Readme

Keywords

none

Package Sidebar

Install

npm i @exodus/transform-storage

Weekly Downloads

981

Version

1.1.2

License

MIT

Unpacked Size

6.31 kB

Total Files

8

Last publish

Collaborators

  • joshuabot