All Projects → Cretezy → Redux Persist Expo Securestore

Cretezy / Redux Persist Expo Securestore

Licence: mit
redux-persist storage for Expo's SecureStore

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Redux Persist Expo Securestore

Reactnativelaravellogin
Sample App for login using laravel 5.5 React Native and Redux
Stars: ✭ 75 (+22.95%)
Mutual labels:  redux-persist, expo
React Native Paypal
PayPal clone with React Native
Stars: ✭ 47 (-22.95%)
Mutual labels:  expo
Pound Random
Expo Blue - a discussion app for small groups
Stars: ✭ 21 (-65.57%)
Mutual labels:  expo
Slopeninja Frontend
Slope Ninja Frontend 🏂❄️⛄️
Stars: ✭ 39 (-36.07%)
Mutual labels:  redux-persist
Expo Chroma Key Camera
Live green-screen effect with Expo and THREE.js
Stars: ✭ 28 (-54.1%)
Mutual labels:  expo
React Antd Todo
A simple todo list app built with React, Redux and Antd - Ant Design
Stars: ✭ 42 (-31.15%)
Mutual labels:  redux-persist
React Native Boilerplate
🚀 React Native Boilerplate Updated
Stars: ✭ 9 (-85.25%)
Mutual labels:  redux-persist
Sunset Cyberspace
🎮👾Retro-runner Game made in Expo, Three.js, OpenGL, WebGL, Tween. 🕹
Stars: ✭ 54 (-11.48%)
Mutual labels:  expo
Ecoleta
Projecto construído durante o Next Level Week 1 - Ecoleta by @Rocketseat
Stars: ✭ 46 (-24.59%)
Mutual labels:  expo
Reactnativeexpo.js
An React Native Starter Kit with Expo + NativeBase + Best configuration for VSCode IDE.
Stars: ✭ 37 (-39.34%)
Mutual labels:  expo
Instabyte
Clone of Instagram made with React Native
Stars: ✭ 36 (-40.98%)
Mutual labels:  expo
React Native Number Please
🔢 Generate react-native pickers with range numbers.
Stars: ✭ 30 (-50.82%)
Mutual labels:  expo
React Native Meetio
A free UI Kit built-in react-native to speed up your workflow and get your app ready for market in no time...
Stars: ✭ 43 (-29.51%)
Mutual labels:  expo
React Native Workshop
Prototyping Airbnb with React Native
Stars: ✭ 21 (-65.57%)
Mutual labels:  redux-persist
Expo Sdk
This repo has been superseded by https://github.com/expo/expo/tree/master/packages/expo
Stars: ✭ 1,066 (+1647.54%)
Mutual labels:  expo
React Native Starter Kit
React Native starter kit, get up and running !
Stars: ✭ 9 (-85.25%)
Mutual labels:  expo
React Native Helpers
All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy useEasy to use & awesome helpers for React Native.
Stars: ✭ 31 (-49.18%)
Mutual labels:  expo
Expo Three Ar
Utilities for using Expo AR with THREE.js
Stars: ✭ 40 (-34.43%)
Mutual labels:  expo
Expo Common Issues
Common issues while developing with Expo
Stars: ✭ 1,086 (+1680.33%)
Mutual labels:  expo
Stanforddaily
The Stanford Daily website frontend is proudly powered by Expo.
Stars: ✭ 53 (-13.11%)
Mutual labels:  expo

redux-persist-expo-securestore

Storage engine for redux-persist for use with Expo's SecureStorage .

iOS: Values are stored using the keychain services as kSecClassGenericPassword. iOS has the additional option of being able to set the value’s kSecAttrAccessible attribute, which controls when the value is available to be fetched.

Android: Values are stored in SharedPreferences, encrypted with Android’s Keystore system.

Installation

Requires Expo SDK (automatically used when using Expo or create-react-native-app).

yarn add redux-persist-expo-securestore
# or
npm install --save redux-persist-expo-securestore

Usage

Use as a redux-persist global storage engine:

import createSecureStore from "redux-persist-expo-securestore";

import { createStore } from "redux";
import { persistStore, persistCombineReducers } from "redux-persist";
import reducers from "./reducers";

// Secure storage
const storage = createSecureStore();

const config = {
  key: "root",
  storage
};

const reducer = persistCombineReducers(config, reducers);

function configureStore() {
  // ...
  const store = createStore(reducer);
  const persistor = persistStore(store);

  return { persistor, store };
}

Use as an engine for only a reducer:

import createSecureStore from "redux-persist-expo-securestore";

import { combineReducers } from "redux";
import { persistReducer } from "redux-persist";
import AsyncStorage from "redux-persist/lib/storage";

import { mainReducer, secureReducer } from "./reducers";

// Secure storage
const secureStorage = createSecureStore();

const securePersistConfig = {
  key: "secure",
  storage: secureStorage
};

// Non-secure (AsyncStorage) storage
const mainPersistConfig = {
  key: "main",
  storage: AsyncStorage
};

// Combine them together
const rootReducer = combineReducers({
  main: persistReducer(mainPersistConfig, mainReducer),
  secure: persistReducer(securePersistConfig, secureReducer)
});

function configureStore() {
  // ...
  let store = createStore(rootReducer);
  let persistor = persistStore(store);

  return { persistor, store };
}

Jest integration

You will need to update transformIgnorePatterns to exclude this module, as it exports untranspiled code.

As an example, the following is the suggested transformIgnorePatterns from the Expo docs with redux-persist-expo-securestore also whitelisted:

node_modules/(?!((jest-)?react-native|react-clone-referenced-element|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|sentry-expo|native-base|redux-persist-expo-securestore))

API

createSecureStore([options])

[options]: object

Options to pass to Expo's SecureStore:

keychainService: string

iOS: The item’s service, equivalent to kSecAttrService

Android: Equivalent of the public/private key pair Alias

keychainAccessible: enum

iOS only: Specifies when the stored entry is accessible, using iOS’s kSecAttrAccessible property. See Apple’s documentation on keychain item accessibility. The available options are:

Expo.SecureStore.WHEN_UNLOCKED: The data in the keychain item can be accessed only while the device is unlocked by the user.

Expo.SecureStore.AFTER_FIRST_UNLOCK: The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user. This may be useful if you need to access the item when the phone is locked.

Expo.SecureStore.ALWAYS: The data in the keychain item can always be accessed regardless of whether the device is locked. This is the least secure option.

Expo.SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY: Similar to WHEN_UNLOCKED, except the entry is not migrated to a new device when restoring from a backup.

Expo.SecureStore.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY: Similar to WHEN_UNLOCKED_THIS_DEVICE_ONLY, except the user must have set a passcode in order to store an entry. If the user removes their passcode, the entry will be deleted.

Expo.SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY: Similar to AFTER_FIRST_UNLOCK, except the entry is not migrated to a new device when restoring from a backup.

Expo.SecureStore.ALWAYS_THIS_DEVICE_ONLY: Similar to ALWAYS, except the entry is not migrated to a new device when restoring from a backup.

redux-persist-expo-securestore specific options:

replaceCharacter: string

Default: _

See caveat.

replacer: function(key: string, replaceCharacter: string): string

Default: replace all illegal characters by replaceCharacter

See caveat.

Caveat

Keys for SecureStorage only support [A-Za-z0-9.-_], meaning all other characters are replaced by options.replaceCharacter (defaults to _).

You may change this character by replacing options.replaceCharacter.

You may also change the default key transformer by replacing options.replacer.

Note

Inspired by redux-persist-sensitive-storage (which required a native module).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].