Coder Social home page Coder Social logo

redux-persist-transform-compress-encrypt's Introduction

redux-persist-transform-compress-encrypt

GitHub license Build Status Coverage Status

To persist a compressed and encrypted Redux store

The package creates a transformer for redux-persist. The transformer stringifies the inbound state, compresses it using lz-string and encrypts the compressed string with AES.

Installation

npm install --save redux-persist-transform-compress-encrypt

Usage

import { persistReducer } from 'redux-persist'
import createCompressEncryptor from 'redux-persist-transform-compress-encrypt'

const transformer = createCompressEncryptor({
    secretKey: 'secret-key',
    onError: function(error) {
        //fired whenever there is any issue with transformation, 
        //compression or encryption/decryption
    }
})

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

If the package encounters anything unexpected, it skips the transformation, called onError and returns the state as it received.

Config

Here are all the keys you can pass to createCompressEncryptor.

interface TransformConfigType {
    //The whitelist and blacklist keys are passed as it is to the 
    //createTransform function
    whitelist?: Array<string>
    blacklist?: Array<string>

    //key for encryption/decryption
    secretKey: string

    //if any error occurs during transformation, this function is called
    onError?: (e: Error) => void
}

Test

npm run test

Notes

This package is technically bundling the packages redux-persist-transform-compress and redux-persist-transform-encrypt into one. Personally, I could not get them to work together and found it easier to just create my own transform.

redux-persist-transform-compress-encrypt's People

Contributors

dante-101 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.