@connected-home/redux-persist-transform-encrypt

3.1.1 • Public • Published

redux-persist-transform-encrypt

npm Travis

Encrypt your Redux store.

Usage

Synchronous

import { persistReducer } from 'redux-persist'
import createEncryptor from 'redux-persist-transform-encrypt'

const encryptor = createEncryptor({
  secretKey: 'my-super-secret-key',
  onError: function(error) {
    // Handle the error.
  }
})

const reducer = persistReducer(
  {
    transforms: [encryptor]
  },
  baseReducer
)

Asynchronous

Note: Asynchronous support is still a work in progress.

import { persistReducer } from 'redux-persist'
import createAsyncEncryptor from 'redux-persist-transform-encrypt/async'

const asyncEncryptor = createAsyncEncryptor({
  secretKey: 'my-super-secret-key'
})

const reducer = persistReducer(
  {
    transforms: [asyncEncryptor]
  },
  baseReducer
)

Custom Error Handling

The onError property given to the createEncryptor options is an optional function that receives an Error object as its only parameter. This allows custom error handling from the parent application.

/@connected-home/redux-persist-transform-encrypt/

    Package Sidebar

    Install

    npm i @connected-home/redux-persist-transform-encrypt

    Weekly Downloads

    16

    Version

    3.1.1

    License

    MIT

    Unpacked Size

    14.6 kB

    Total Files

    13

    Last publish

    Collaborators

    • sandfox
    • domthom
    • bvic23
    • christopher.goodchild