@solidnative-dev/secure-storage
Bounded credential storage backed by iOS Keychain and Android Keystore, with owner-scoped Solid settlements. The React Native adapter targets react-native-keychain 10's native ABI directly without evaluating its React-facing wrapper.
Installation#
sh
pnpm add @solidnative-dev/secure-storage react-native-keychainUsage#
ts
import { createReactNativeSecureStorage } from "@solidnative-dev/secure-storage/react-native";
import { createSecureStorageController } from "@solidnative-dev/secure-storage/solid";
const storage = createSecureStorageController(
createReactNativeSecureStorage({ servicePrefix: "com.example.session" }),
);
await storage.setItem("refresh-token", token);
const restored = await storage.getItem("refresh-token");
await storage.removeItem("refresh-token");Entrypoints#
| Import | Key exports |
|---|---|
@solidnative-dev/secure-storage | createSecureStorage, SecureStorage, SecureStorageAdapter, SECURE_STORAGE_MAX_KEY_LENGTH (128), SECURE_STORAGE_MAX_VALUE_LENGTH (65536) |
@solidnative-dev/secure-storage/react-native | createReactNativeSecureStorage (resolves RNKeychainManager directly) |
@solidnative-dev/secure-storage/keychain-10 | createKeychain10SecureStorage, ReactNativeKeychain10Module, Keychain10SecureStorageOptions |
@solidnative-dev/secure-storage/solid | createSecureStorageController, SecureStorageOwnerDisposedError |
Behavior & platform notes#
- Bounds & encoding: Keys are limited to 128 UTF-16 code units, values to 65,536, and
servicePrefixto 96. Each key maps to a separate generic-password service, and empty strings are encoded safely for Android's non-empty credential ABI. - Security defaults: iOS items are accessible only while the device is unlocked and never migrate across devices; iCloud Keychain sync is always disabled. Android requires at least software-backed Keystore by default (hardware-backed storage is opt-in so older devices are not excluded).
- Owner disposal & privacy: Disposing the Solid owner rejects pending promises with
SecureStorageOwnerDisposedErrorso late native results cannot write into retired state. Reads, writes, and removals emit default-priority causal events without ever recording keys or values. - Legacy-module seam:
react-native-keychain10 exposesRNKeychainManagervia React Native's bridgeless legacy-module interop (enabled automatically by@solidnative-dev/fabric-host); all values crossing the boundary are validated by thekeychain-10adapter.