@exodus/storage-seed
An implementation of the unified storage spec used to store bip39 mnemonics / seeds.
Install
yarn add @exodus/storage-seed
Usage
import createSeedStorage from '@exodus/storage-seed'
import createKeystore from '@exodus/keystore-mobile'
import * as reactNativeKeychain from '@exodus/react-native-keychain'
const keystore = createKeystore({
reactNativeKeychain,
platform: Platform.OS,
})
const seedStorage = createSeedStorage({
storage: {
get: (key) => keystore.getSecret(key),
set: (key, value) => keystore.setSecret(key, value),
delete: (key) => keystore.deleteSecret(key),
// TODO: backwards compat, delete me
remove: (key) => keystore.deleteSecret(key),
},
// optional key prefix
prefix: 'my-favorite-prefix:',
// optional authentication check that will be called on get() and set()
auth: {
hasPassphrase: async () => {
// return true if the user has a passphrase set
},
isCorrectPassphrase: async (passphrase) => {
// return true if the passphrase is correct
},
},
// optional mapping from storage-spec-derived keys to currently stored keys,
// to avoid having to move keys around when adopting this library
keyMap: {
// i.e. when storage.namespace('wallet').get('seed') is called, fetch the key 'wallet:v3:seed' instead
'!wallet!seed': 'wallet:v3:seed',
},
})
// use as any other `@exodus/storage-spec` compliant interface