Skip to content

feat(mobile): secure metadata storage helper - #597

Open
Lazyartist1 wants to merge 1 commit into
Miracle656:mainfrom
Lazyartist1:feat/mobile-secure-metadata
Open

feat(mobile): secure metadata storage helper#597
Lazyartist1 wants to merge 1 commit into
Miracle656:mainfrom
Lazyartist1:feat/mobile-secure-metadata

Conversation

@Lazyartist1

Copy link
Copy Markdown

Summary

Adds secure metadata storage (backlog item 23): wallet metadata — credential id, contract address, public key — and the fee-payer secret are kept in the platform secure enclave (iOS Keychain / Android Keystore), behind a single helper the rest of the app routes sensitive data through, so secrets never land in unencrypted storage.

Changes

  • lib/storage.ts (new) — wraps expo-secure-store with:
    • string accessors (getSecureItem / setSecureItem / deleteSecureItem),
    • a JSON helper (getSecureJSON / setSecureJSON) for structured metadata,
    • a centralized SecureKey map so every reader/writer agrees on the keys,
    • soft-failing reads (a keychain error logs and returns null, never crashing a screen) and corrupt-JSON tolerance.
  • lib/walletStore.ts — every accessor now delegates to lib/storage.ts (single source of truth), and it gains symmetric setters (setPasskeyId, setPasskeyPublicKey, setSignerSecret) plus clearWalletStore(). All existing exported signatures are unchanged, so current callers (passkey, walletConnect, ConnectDAppModal) keep working.

Acceptance

  • Wallet metadata survives relaunch (SecureStore persists across launches; covered by a round-trip test)
  • Secrets never hit AsyncStorage / plain storage — the signer secret and passkey identifiers route exclusively through the keychain helper

Notes

  • expo-secure-store is already a dependency; no new deps.
  • The non-secret backup metadata read in lib/backupFile.ts (address / public key for assembling an encrypted export) is intentionally left as-is — it touches no secret material, and the secret (veil_signer_secret) is keychain-only.

Testing

  • tsc --noEmit clean (existing walletStore importers still compile)
  • jest lib/__tests__/storage.test.ts — 10/10 passing (string round-trip + persistence, delete, soft-fail on read error, JSON serialise/parse, malformed-JSON → null, walletStore reads/writes the canonical secure keys, clear wipes all)

Closes #451

Persist wallet metadata (credential id, contract address, public key) and the
fee-payer secret in the platform secure enclave (iOS Keychain / Android
Keystore) rather than plain storage, behind a single helper the rest of the app
routes sensitive data through.

- lib/storage.ts: wraps expo-secure-store with string and JSON accessors, a
  centralized SecureKey map, soft-failing reads (return null on a keychain
  error), and corrupt-JSON tolerance.
- lib/walletStore.ts: now delegates every accessor to lib/storage.ts, and gains
  symmetric setters plus clearWalletStore(); existing signatures are unchanged
  so current callers keep working.

Secure-store values persist across relaunch, so wallet metadata survives, and
secrets never touch AsyncStorage or any plaintext store.

Closes Miracle656#451
@Lazyartist1
Lazyartist1 requested a review from Miracle656 as a code owner July 30, 2026 06:59
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Lazyartist1 is attempting to deploy a commit to the miracle656's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Lazyartist1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

23. Secure metadata storage

1 participant