@deshina/agekey-react-native
v0.1.3
Published
React Native bindings for the AgeKey Core SDK. This package wraps `@deshina/agekey-core` with secure storage, push notification helpers, QR scanning adapters, and a light native bridge so iOS/Android shells can hook in.
Readme
@deshina/agekey-react-native
React Native bindings for the AgeKey Core SDK. This package wraps @deshina/agekey-core with secure storage, push notification helpers, QR scanning adapters, and a light native bridge so iOS/Android shells can hook in.
Installation
pnpm add @deshina/agekey-react-native react-native-encrypted-storageOptional providers:
- Expo push + QR:
expo-notifications,expo-barcode-scanner - Firebase push:
@react-native-firebase/messaging
These are not installed automatically—add whichever provider your app needs.
Usage
import { AgeKeyRN } from "@deshina/agekey-react-native";
AgeKeyRN.init({ apiKey: "AGEKEY_API_KEY", endpoint: "https://api.agekey.com" });
const token = await AgeKeyRN.requestToken();
await AgeKeyRN.saveToken(token.token);
const stored = await AgeKeyRN.loadToken();
if (stored) {
await AgeKeyRN.validateToken(stored);
}
AgeKeyRN.onToken((decoded) => {
console.log("AgeKey token updated", decoded);
});Secure Storage
react-native-encrypted-storage is used when available. In CI / Node environments a JSON file fallback is used (set AGEKEY_RN_STORAGE_PATH or pass storage.fallbackPath in init). All storage helpers are async and throw descriptive errors if permissions are missing.
Push Notifications
Use AgeKeyRN.setupPushHandler(callback, provider) to register a push handler. Providers:
expo: requests permissions viaexpo-notificationsif installed.firebase: logs setup guidance for@react-native-firebase/messaging.none: pure JS fallback; pair withAgeKeyRN.triggerPushRequest(payload)during development.
QR Scanning
Call AgeKeyRN.startQRScanner(provider) to launch a provider-specific QR flow. Adapters for Expo BarCodeScanner and react-native-camera are stubbed—bring your own UI and feed the resulting session ID to AgeKeyRN.beginQRFlow. A simulator fallback returns a mock session for CI/tests.
Native Bridge
registerNativeBridge lets Swift/Kotlin wrappers plug in custom storage or push hooks. Each method is optional so you can progressively adopt native integrations.
Testing
Run the package tests via:
pnpm --filter @deshina/agekey-react-native testFor end-to-end validation, use the included Expo demo app under apps/example-react-native.
