React Native Secure Storage Configuration (Deprecated)
Legacy setup and authentication options for deprecated React Native Secure Storage
@tetherto/wdk-react-native-secure-storage is deprecated and no longer maintained. Use React Native Core for new integrations. For existing apps, follow Legacy Storage Compatibility before changing imports or storage options.
This page retains the setup and authentication options for existing standalone integrations.
Install the package
npm install @tetherto/wdk-react-native-secure-storage@1.0.0-beta.4 react-native-keychain expo-crypto expo-local-authenticationThe v1.0.0-beta.5 npm artifact includes the React Native source entry at src/index.ts, but it does not include the dist/ files declared by main, types, and exports.default. The install command pins beta.4, the latest artifact with those compiled JavaScript and declaration files. Use beta.5 only with a React Native resolver configuration you have verified against its source entry.
The package declares react-native as a peer dependency and uses native modules through react-native-keychain.
Use this package in a React Native app or development build with native modules available. Expo Go is not enough for all keychain-backed flows.
Create a storage instance
Use createSecureStorage() once and reuse the returned object in your wallet storage layer.
import { createSecureStorage } from '@tetherto/wdk-react-native-secure-storage'
const storage = createSecureStorage({
authentication: {
promptMessage: 'Authenticate to access wallet',
cancelLabel: 'Cancel',
disableDeviceFallback: false
},
timeoutMs: 30000
})Store wallet material
Store encrypted values only. The package stores encrypted seed and entropy payloads plus the encryption key you provide.
const walletId = 'primary-wallet'
await storage.setEncryptedSeed(encryptedSeed, walletId)
await storage.setEncryptedEntropy(encryptedEntropy, walletId)
await storage.setEncryptionKey(encryptionKey, walletId, {
requireBiometrics: true
})Restore wallet material
Getters return null when a value has not been stored. They throw typed errors for validation, authentication, timeout, and keychain failures.
const walletId = 'primary-wallet'
const { encryptedSeed, encryptedEntropy, encryptionKey } =
await storage.getAllEncrypted(walletId)
if (!encryptedSeed || !encryptionKey) {
throw new Error('Wallet data is incomplete')
}Check device security
Use device checks before prompting the user to create or unlock a wallet.
const deviceSecurityEnabled = await storage.isDeviceSecurityEnabled()
const biometricsAvailable = await storage.isBiometricAvailable()
if (!deviceSecurityEnabled) {
throw new Error('Enable device security before creating a wallet')
}Cleanup
Call cleanup() when the storage instance is no longer needed. Use deleteWallet(identifier) when you want to remove stored wallet data.