# decane-connect-kit-expo > Non-custodial embedded wallets for React Native / Expo apps (`decane-connect-kit-expo`, MIT, TypeScript declarations included). Users sign in with email, Google or KingsChat and get EVM + Solana + Tron wallets — no seed phrase, no extension, no browser popup. The private key is never assembled on the device: it is a 2-of-3 Shamir split, reconstructed only inside an attested TEE for the moment it takes to produce one signature. This package is **headless** — functions only, no UI components. This file is a self-contained integration spec, grounded in the actual package source. ``` npx expo install decane-connect-kit-expo \ expo-secure-store expo-crypto expo-local-authentication expo-web-browser ``` --- ## Version and freshness ```yaml package: decane-connect-kit-expo version: 0.7.0 document-revision: 2026-11-16 canonical: https://kit.decane.app/llms-expo.txt web-sibling: https://kit.decane.app/llms.txt swift-sibling: https://kit.decane.app/llms-swift.txt # DecaneKit (native iOS / macOS, same wallet) kotlin-sibling: https://kit.decane.app/llms-kotlin.txt # app.decane:decane-kit (native Android, same wallet) ``` The web SDK (`decane-connect-kit`) is a **separate package** with its own spec at `web-sibling`. Do not mix their APIs: this package has no React components, no hooks, and no `` provider. --- ## Critical: this cannot run in Expo Go `expo-secure-store` and (optionally) `react-native-passkeys` are native modules. Expo Go has no binary for them and rejects the project **before any JavaScript runs** — which presents as the app opening and closing instantly with nothing in the Metro logs. This is the single most common integration failure. ``` npx expo prebuild npx expo run:android # or run:ios ``` A development build is required. There is no workaround. --- ## Minimal working setup Four required config values. Everything else is opt-in. ```ts import { createDecaneConnect } from "decane-connect-kit-expo"; const decane = await createDecaneConnect({ appId: "proj_…", // Decane dashboard, public apiKey: "dck_live_…", // Decane dashboard chains: ["evm:8453", "solana:mainnet"], authMethods: ["email"], }); await decane.connectWithEmail("user@example.com"); await decane.verifyEmailCode("user@example.com", "123456"); const { evm, solana, tron } = decane.getAddresses()!; await decane.sendTransaction({ chain: "evm:8453", to: "0x…", value: 10_000n }); ``` `createDecaneConnect` is **async** and returns a client object. Create it once and keep it — it restores a persisted session on construction. --- ## Configuration ```ts interface DecaneConnectNativeConfig { // Required appId: string; apiKey: string; chains: Chain[]; // `evm:${number}` | `solana:mainnet|devnet` | `tron:mainnet|shasta|nile` authMethods: Array<'google' | 'x' | 'email' | 'phone' | 'external' | 'kingschat'>; // Needed for Google, X and KingsChat — must equal `scheme` in app.json, // and be one of the API key's callback URLs in the dashboard. From 0.6.1 // the SDK sends it to /auth/{google,x}/init, so two apps sharing one key // each get their own redirect; an unregistered value fails with // CALLBACK_URL_NOT_REGISTERED instead of redirecting elsewhere. redirectUri?: string; // Required if the PIN tier can be reached. Must resolve to 4-8 digits. promptPin?: () => Promise; // Passkey tier only. rpId is a domain you control; there is NO default // (unlike web, which uses window.location.hostname). Without it the SDK // silently uses the secure-enclave tier. rpId?: string; rpName?: string; origin?: string; // Android: `android:apk-key-hash:`; iOS defaults to https:// unlockPreference?: Array<'passkey' | 'secure-enclave' | 'pin'>; // How this device holds its share — see "Protection tiers". 'device' // (default): the first unlock tier that works wraps it. 'identity': nothing // stored, nothing asked; every visit is a sign-in. Same key either way. protection?: 'identity' | 'device'; // Recovery UI hooks offerRecoveryAtSignup?: boolean; // default false since 0.2.2 — opt in onRecoveryShareOffer?: (a: { evmAddress: string; solanaAddress: string }) => Promise<{ wants: boolean; password: string; passwordHint?: string }>; onRecoveryFileReady?: (file: RecoveryShareFile, filename: string) => Promise; promptForRecoveryFile?: () => Promise<{ value: unknown; getPassword: () => Promise } | null>; onRecoveryRotated?: (a: { evmAddress: string; solanaAddress: string }) => Promise<{ password: string; passwordHint?: string }>; onRecoveryProgress?: (e: RecoveryProgress) => void; // Advanced sessionDurationMinutes?: number; // default 120 rpcUrls?: Record; persistSession?: boolean; // default true requireAssertionPerSignature?: boolean; kingsChatScopes?: string[]; // default ['send_chat_message'] verifyAttestation?: (q: { quote: string; eventLog: unknown; measurement?: string; nonce: string }) => Promise; // 0.8.0: eventLog added; measurement is the enclave's own claim, ignore it rotateOnNewDeviceRecovery?: boolean; } ``` There is **no** `serverAssistedRecovery` option — login-alone recovery is always on (see Recovery). There is **no** Google client ID option: the recommended Google flow needs nothing registered in Google Cloud. --- ## Sign-in ```ts // Email — nothing to register anywhere await decane.connectWithEmail(email); // { codeRequired: true } await decane.verifyEmailCode(email, code); // ConnectResult // Google — RECOMMENDED. In-app auth sheet, returns to redirectUri. await decane.connectWithGoogle(); // X (Twitter) — the same in-app sheet and redirect. X releases no email; // profile carries the handle as `username`. Needs X credentials on the backend // (503 X_NOT_CONFIGURED otherwise). await decane.connectWithX(); // KingsChat await decane.connectWithKingsChat(); await decane.connectWithKingsChatToken(accessToken); // Your own JWT issuer (Auth0, Clerk, Firebase, …) await decane.connectWithToken(idToken, { providerId }); // Google with a token you already hold (native sheet — see below) await decane.connectWithGoogleToken(idToken); // Returning user whose passkey-wrapped share is still on this device if (await decane.canSignInWithPasskey()) await decane.signInWithPasskey(); // Returning user on ANY tier: the device's own unlock reopens the session // (see "Session renewal" under Unlock tiers) if (decane.needsReconnect() && (await decane.canUnlock())) await decane.unlock(); await decane.disconnect(); ``` `ConnectResult` is `{ addresses: { evm?, solana?, tron? }, isNewUser: boolean, profile?: AuthProfile }`. `profile` carries who the provider says the user is — `{ name?, email?, picture?, username? }` — and is **absent** when the provider released nothing (email sign-in always, and Google when the user withheld it). X never releases an email; it sends the handle as `username`, which can be renamed and is not an id. Decane never stores it: the backend keeps only an HMAC and a masked identifier, so there is no profile to fetch later. Cache what you need at sign-in if you want to greet the user by name after a reload. ### Google: use connectWithGoogle(), not the native sheet `connectWithGoogle()` opens an in-app auth sheet (`ASWebAuthenticationSession` on iOS, Chrome Custom Tab on Android) and returns to `redirectUri`. The app is never backgrounded. **Nothing is registered in Google Cloud.** The OAuth client belongs to Decane and the redirect goes to Decane's backend, which then hops to your scheme — so Google never sees your package name, bundle ID, or signing fingerprint. No SHA-1 registration, no per-build-type fingerprints, nothing blocking your release. `connectWithGoogleToken(idToken)` exists for apps that want the native account sheet via `@react-native-google-signin/google-signin`. It is opt-in and costs real setup: Google must know your exact binary, meaning a package name plus a SHA-1 for **every** build type — debug, release, and Play App Signing each produce a different fingerprint. Two failure modes dominate: passing the Android client ID instead of the **web** one gives an opaque `INVALID_TOKEN` (the token's `aud` always carries the web client ID, on both platforms), and registering only the debug SHA-1 gives `DEVELOPER_ERROR` on release builds. **Never use `connectWithToken()` for Google.** It routes through the generic external-provider path, which namespaces the identity by provider id and would give the same person a *different* wallet than your website does. ### One wallet across web and app The wallet derives from **identity**, never device. The same person signing in on your website and in your app gets the same addresses, provided both use the same `appId`. Two API keys on that one project is normal — the web redirect and the app deep link need different `callback_url` values. Two apps on one key also work from 0.6.1: register both schemes on the key, and each app's `redirectUri` picks its own. --- ## Unlock tiers The device's share is encrypted at rest. Which key protects it depends on what the device can do; the SDK probes each tier in order and uses the first that genuinely works. The passkey probe is a real ceremony, not a feature flag — a device that claims passkey support but returns no PRF output falls through rather than ending up with a wallet nothing can unlock. | tier | key source | passkey sign-in | rotate/export | | --- | --- | --- | --- | | `passkey` | WebAuthn PRF output | yes | yes | | `secure-enclave` | random key in Keychain/Keystore behind biometrics | no | no | | `pin` | PBKDF2-SHA256 (600k) over a user PIN | no | no | ```ts const caps = await decane.getCapabilities(); // { passkeys, passkeyPrf, secureEnclave, activeUnlockMethod } ``` The passkey tier needs `rpId`, an associated domain (`webcredentials:` + `apple-app-site-association` on iOS, `assetlinks.json` on Android), and OS-level PRF support (roughly iOS 18+ / Android 14+). Expect **two biometric prompts at signup** on this tier: WebAuthn's `create()` only reports that PRF is *available*, so a follow-up assertion is needed to evaluate it. It does not repeat on later unlocks. PBKDF2 runs in pure JavaScript (no native implementation to call), so the PIN tier and recovery-file encrypt/decrypt cost **seconds, not milliseconds**. Never paid on the passkey or biometric path, and never per signature. ### Sessions — renewal since 0.5.0, device unlock token since 0.4.0 The access token lasts **eight hours**. Since 0.5.0 the SDK renews it at 75% of its life while the app holds a live identity (`session-renewed` fires; the backend caps the chain at seven days), so an active user is not signed out at expiry. When the enclave's signing session lapses with the token still valid, `unlock()` reopens it — no sign-in. Once the token itself is gone (a phone left for days), the device tier has a second way back that is not an email code: the **device unlock token** — 90 days, stored beside the share and encrypted under the same key — so the one unlock the device already does (biometric, or the PIN) yields both the share and a new JWT: ```ts if (decane.needsReconnect() && (await decane.canUnlock())) { await decane.unlock(); // biometric / PIN prompt; no email code, no Google } else if (decane.needsReconnect()) { // identity tier, or no token on this device: sign in } ``` - Issued at wallet creation and whenever a device is provisioned or recovered; a normal sign-in re-issues it. Not issued in the identity tier (nothing is stored there; `canUnlock()` is false and a gone session means a sign-in). - `unlock()` prefers a passkey, then the token; an expired JWT in memory is treated as no JWT. A token the backend refuses throws `UNLOCK_TOKEN_REJECTED` and is forgotten. - `removeDeviceUnlock()` revokes the account's tokens (every device) and forgets this device's copy — the "lost phone" switch. `disconnect()` keeps it. - One token per account: setting up a second device revokes the first's. ### Protection tiers — since 0.5.0 `protection` decides whether this app holds a piece of the wallet on the phone at all. `'device'` (default) is everything above — the unlock tiers, the unlock token, `addPasskey()`. `'identity'` establishes nothing: no passkey ceremony, no biometric key, no PIN, nothing in the keystore; sign-in is the whole ceremony every time and the enclave provisions a fresh share against it. **The identity tier's security statement, verbatim:** a wallet is exactly as safe as the user's identity-provider account plus Decane (the JWT signing key and the attested enclave). Anyone who can obtain a valid Decane session for the user can sign. There is no device-bound factor. Mitigations: a new-device email on every provision from an unseen device, a per-user freeze switch operated by Decane, and (follow-up) a fresh sign-in requirement for high-value operations. - The tier belongs to this client, not the wallet: two apps on one project can hold the same wallet in different tiers. Same key, same addresses, same funds. - Switching an app to `'identity'` ports users on their next sign-in: enrolled wallets provision silently; one never enrolled but holding a wrapped share on this phone is unlocked with its tier ONE last time, enrolled, and never prompted again (`migrated-to-identity` fires). Nothing is re-split or moved. - In the identity tier `canUnlock()`, `hasPasskey()` and `canSignInWithPasskey()` are false; `signInWithPasskey()` and `addPasskey()` throw `CALL_SEQUENCE`; `getCapabilities().activeUnlockMethod` is null; `promptPin`/`rpId` are unused. - **Creation waits for enrolment, in every tier** (since 0.5.0): the server share is uploaded as provisional, the enclave seals the recovery share (three attempts), and only then does the session open. On failure the SDK throws `WALLET_ENROLMENT_FAILED`, deletes any share it stored, and the backend still reports no wallet — the next sign-in creates afresh. ### Adding a passkey later — since 0.4.0 A device that signed in with email, Google or X and landed on the secure-enclave or PIN tier can move to the passkey tier: ```ts if (!(await decane.hasPasskey())) await decane.addPasskey(); // needs rpId and a live session ``` It unwraps the share with the current tier (one biometric or PIN prompt), registers a passkey, re-wraps the share and the unlock token under its PRF key, and backs the wrapped share up for passkey-sync recovery — after which `signInWithPasskey()` and `rotateShares()`/`exportPortableBackup()` work on this device. Idempotent on a device already on a passkey; throws `WEBAUTHN_NOT_SUPPORTED` without `rpId` or PRF. The Android origin the backend accepts is still `https://` — pass `origin` for an `android:apk-key-hash` build only once the backend allows it. --- ## Wallet API ```ts decane.getAddresses(); // { evm, solana, tron } | null decane.isUnlocked(); // boolean decane.needsReconnect(); // identity known, session gone -> show sign-in decane.sessionExpiresAt(); // epoch ms | null decane.getAccessToken(); // Decane JWT for your own backend | null await decane.unlock(); await decane.canUnlock(); // a passkey or a device unlock token is here await decane.removeDeviceUnlock(); await decane.hasPasskey(); await decane.addPasskey(); await decane.getCapabilities(); await decane.signMessage({ chain, message }); // string | Uint8Array; EVM/Tron bytes must be valid UTF-8 (the enclave hashes text), else CallSequenceError. Solana signs raw bytes. await decane.sendTransaction({ chain, to, value?, data?, gasLimit?, gasPrice? }); // EVM only, broadcasts await decane.signTypedData({ chain, domain, types, message, primaryType? }); // EIP-712, EVM only await decane.signAuthorization({ chainId, address, nonce }); // EIP-7702 await decane.signSolanaTransaction(serializedTx); // returns signed bytes; YOU broadcast await decane.signTronTransaction(rawDataHex); // An EIP-1193 provider for viem / wagmi / ethers — the same module as the web // SDK's. Signing goes through the enclave; reads go to the chain's RPC. const provider = decane.getEthereumProvider({ chainId: 8453, rpcUrls? }); await provider.request({ method: "personal_sign", params: [hex, address] }); await provider.request({ method: "eth_sendTransaction", params: [tx] }); await decane.getBalance(chain?); await decane.getBalances(); await decane.recordTransaction({ chain, txHash, to, value, kind }); await decane.getTransactionHistory(limit); decane.on(event, handler); // 'connected' | 'disconnected' | 'session-started' // | 'session-expired' | 'wallet-creating' | 'wallet-unlocking' decane.off(event, handler); ``` `wallet-creating` covers key generation, the Shamir split, unlock-tier setup and the first enclave session — several seconds. Show progress. Standalone exports usable without a client: `detectCapabilities`, `isPasskeySupported`, `isEnclaveAvailable`, `startEmailAuth`, `startGoogleAuth`, `startXAuth`, `readRedirectResult`, `createEthereumProvider`, `loginWithKingsChat`, `parseRecoveryShareFile`, `decryptRecoveryShareFile`, `buildRecoveryShareFile`, `parsePortableBackup`, `decryptPortableBackup`, `fetchBalance`, `formatBalanceDisplay`, `evmToTronAddress`, `clearDeviceState`. --- ## Sign-in only, no wallet — `wallet: 'on-demand'` (since 0.8.0, `next` tag) The same as the web SDK (see https://kit.decane.app/llms.txt, "Sign-in only"): every sign-in method gives a session with no wallet and no enclave call; `isSignedIn()`, `hasWallet()`, `createWallet()` (emits `wallet-creating` then `wallet-created`), and `NoWalletError` (`NO_WALLET`) from any signing call or `unlock()` before a wallet exists. The session is saved on its token and survives an app restart. Users without a wallet are billed apart: free up to 10,000 a month, then $25/month with 10,000 included and $0.02 per user above. --- ## Gas sponsorship — since 0.7.0 (early access) In `decane-connect-kit-expo` 0.7.0 and later. Turned on per project from the dashboard's Gas sponsorship page (see https://kit.decane.app/llms.txt). The same three client methods as the web SDK (see https://kit.decane.app/llms.txt, "Gas sponsorship"): `sendSponsoredTransaction({ chain, to?, value?, data?, calls?, payGasWith? })`, `getSponsorshipStatus(chain)`, `quoteGasInToken({ chain, token, gas? })`, and the `gasSponsorship: { payGasWith?, routeSendTransaction? }` config. EVM only, Base first, off per project until Decane switches it on. The project pays by default; `payGasWith: { token }` has the user pay in that token. A first send delegates the wallet to Simple7702Account (EIP-7702) without changing its address; the EntryPoint, paymaster and delegate are pinned in the package. ## Recovery A user who reinstalls the app, or opens it on a new phone, gets their wallet back from **signing in alone** — nothing to write down, nothing to keep. This is always on and is not configurable. How: at signup the wallet is enrolled by sending the third share once to the enclave, which seals it under a key only it can derive; the backend stores ciphertext it cannot read. The enclave then holds two shares and can issue a fresh device share to anyone who authenticates. Every provisioning re-splits the set, so a leaked device share stops working the next time the user signs in anywhere. **The trade, stated plainly:** an enrolled wallet can be reconstructed by the enclave alone. Your backend and its database still cannot — but a malicious enclave image, or anyone able to mint JWTs, could. Before enrolment no single party could reconstruct. Fallbacks, tried in order after server-assisted provisioning: 1. **Passkey sync** — the wrapped share is fetched and unwrapped with PRF. Passkey tier only. 2. **Recovery file** — a JSON envelope holding one 33-byte Shamir share, AES-256-GCM under PBKDF2-SHA256 (600k). Format is identical across the web and native SDKs, so a file written on a phone opens in a web app. Every recovery and rotation invalidates the previous file, so `onRecoveryRotated` must capture a password for the replacement. The SDK refuses to begin a recovery that has nowhere to hand the new file. ```ts await decane.rotateShares({ password, passwordHint }); // new file; needs a passkey assertion await decane.exportPortableBackup({ password }); // BEARER SECRET — two shares in one file await decane.hasRecoveryShare(); await decane.shouldPromptRecovery(); // true only once a balance exists await decane.dismissRecoveryPrompt(); ``` --- ## Attestation Where the enclave is, and what it may run, come from a **signed enclave manifest** (0.8.0). The SDK fetches it from Decane's backend (`GET /attestation/manifest`), verifies its ECDSA P-256 signature **on the device** against public keys pinned in the package, and refuses one older than the newest this install has accepted (remembered in SecureStore). If the backend is unreachable it uses the last accepted manifest, then the one bundled in the package; with none it talks to no enclave. Moving the enclave or changing what it runs is a newly signed manifest, not a package release. An explicit `teeUrl` pins the URL (tests, a self-hosted signer). Before any share moves, the SDK fetches a TDX attestation quote bound to a fresh nonce, together with the enclave's dstack event log. React Native has **no WebAssembly**, so the Intel DCAP verifier cannot run on device; the SDK posts the quote and the log to Decane's backend, which checks: - the signature chain to Intel's root CA, the TCB status and the nonce; - MRTD and RTMR0-2 **read from the quote** against an approved OS; - that the event log replays to the quote's RTMR3, and that the app-id and compose-hash dstack recorded at boot are approved in the signed manifest. An enclave that sends no event log is refused. Before 0.8.0 the SDK compared a measurement string the enclave reported about itself, which any TDX machine could claim; that check is gone. The backend check catches a third party impersonating the enclave but cannot catch Decane approving a malicious one, since the same party vouches for it. Supply `verifyAttestation` to verify independently: verify the quote's signature, TCB status and nonce, then run `verifyEvidence` from `infra/enclave-evidence.ts` (one file, no dependencies) on its registers, the `eventLog` and the signed manifest. Throw from it to refuse the session. --- ## Errors Every error is a `DecaneConnectError` with a stable `code` matching the web SDK, so shared code can branch identically. | code | meaning | | --- | --- | | `UNLOCK_REQUIRED` | session expired — call `unlock()` | | `RECONNECT_REQUIRED` | identity known, session gone — show sign-in | | `NEW_DEVICE` | no share here and every recovery path exhausted | | `STALE_DEVICE_SHARE` | share belongs to a superseded set; cleared, re-recover | | `INVALID_PIN` | wrong PIN | | `UNLOCK_TOKEN_REJECTED` | the device unlocked its token but the backend refused it (revoked / expired / account reset); it is forgotten — sign in | | `WEBAUTHN_NOT_SUPPORTED` | no `rpId`, no passkey support or no PRF — `addPasskey()` cannot run here | | `USER_CANCELLED` | user dismissed a prompt | | `BIOMETRIC_UNAVAILABLE` | biometrics dismissed, or keystore entry gone | | `NATIVE_MODULE_MISSING` | a peer dependency is absent — install and rebuild | | `ATTESTATION_FAILED` | the enclave is not one the signed manifest approves, or no trusted manifest was available | | `WALLET_ENROLMENT_FAILED` | creation stopped: the enclave did not seal the wallet's share; nothing was created — sign in again (0.5.0) | | `PROVISIONING_RATE_LIMITED` | `/signer/provision` answered 429; the wallet is fine, wait and sign in again — never a new-device dead end (0.5.0) | | `ENCLAVE_HTTP` | any other non-OK enclave answer; `.status` carries the HTTP status (0.5.0) | | `CALL_SEQUENCE` | a method that does not apply here — e.g. `addPasskey()` in the identity tier | | `WRONG_PASSWORD` | recovery file password is wrong | | `INVALID_API_KEY` | key invalid or revoked | | `NETWORK` | request failed | --- ## Platform notes **iOS**: `scheme` in `app.json` is required for `redirectUri`. The passkey tier additionally needs `webcredentials:` in associated domains. Everything else works without iOS-specific setup. **Android**: `scheme` in `app.json`. For the passkey tier, `assetlinks.json` plus an explicit `origin` (`android:apk-key-hash:`), because Android does not report a URL origin. `crypto.getRandomValues` and `Buffer` are polyfilled by the SDK on import — `react-native-get-random-values` is not needed. --- ## What this is not - Not MPC — Shamir splitting, not threshold signatures. The key does exist, briefly, inside the enclave. - Not a smart-contract wallet — these are plain EOAs. EIP-7702 authorization is supported for delegating to one. - Not a UI library — no components, no hooks. Build your own screens.