@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-keychain

Usage#

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#

ImportKey exports
@solidnative-dev/secure-storagecreateSecureStorage, SecureStorage, SecureStorageAdapter, SECURE_STORAGE_MAX_KEY_LENGTH (128), SECURE_STORAGE_MAX_VALUE_LENGTH (65536)
@solidnative-dev/secure-storage/react-nativecreateReactNativeSecureStorage (resolves RNKeychainManager directly)
@solidnative-dev/secure-storage/keychain-10createKeychain10SecureStorage, ReactNativeKeychain10Module, Keychain10SecureStorageOptions
@solidnative-dev/secure-storage/solidcreateSecureStorageController, SecureStorageOwnerDisposedError

Behavior & platform notes#

  • Bounds & encoding: Keys are limited to 128 UTF-16 code units, values to 65,536, and servicePrefix to 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 SecureStorageOwnerDisposedError so 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-keychain 10 exposes RNKeychainManager via React Native's bridgeless legacy-module interop (enabled automatically by @solidnative-dev/fabric-host); all values crossing the boundary are validated by the keychain-10 adapter.