Skip to content

feature/c10-nfc-core#35

Merged
JoelVR17 merged 6 commits into
Ding-Payments:developfrom
YAustinXYZ:feature/c10-nfc-core
Jul 18, 2026
Merged

feature/c10-nfc-core#35
JoelVR17 merged 6 commits into
Ding-Payments:developfrom
YAustinXYZ:feature/c10-nfc-core

Conversation

@YAustinXYZ

@YAustinXYZ YAustinXYZ commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Closes #32


Summary

This PR implements C10 — NFC protocol and session management (CLI-046 through CLI-052), delivering the core NFC transport stack required for receive/send payment flows.

Native setup & configuration (CLI-046)

  • Installed react-native-nfc-manager, zod, and zustand
  • Added app.config.ts with NFC plugin, iOS NFCReaderUsageDescription, Android NFC permission, and NDEF entitlements
  • Documented rebuild requirements in README.md and docs/adr-nfc-library.md

NfcService abstraction (CLI-047)

  • Defined stable interface in NfcService.types.ts (isSupported, isEnabled, startReaderSession, startWriterSession, cancelSession)
  • Native implementation in NfcService.native.ts (NDEF MIME application/json)
  • Web stub in NfcService.web.ts returning unsupported
  • createMockNfcService() for unit tests

Payment request schema (CLI-048)

  • Zod schema aligned to payment_request.v1: type, recipient, asset, amount, timestamp, expiresAt
  • Stellar public key, decimal amount, and asset validation via wallet/constants/assets.ts
  • validateExpiry() and parsePaymentRequestFresh() helpers

Payload codec (CLI-049)

  • NfcPayloadCodec: compact JSON encode/decode with 880-byte max guard
  • Typed errors for malformed JSON, oversize payloads, invalid/expired requests

Writer & reader sessions (CLI-050 / CLI-051)

  • Writer (receiver): 60s timeout, auto-cancel, cleanup on unmount/cancel
  • Reader (payer): 45s timeout, single-read policy, rejects expired payloads
  • React hooks: useNfcWriter, useNfcReader

Session store & auth coordination (CLI-052)

  • nfcSessionStore state machine: idlescanning / writingsuccess / error
  • Single active session enforced via nfcActive
  • useSessionPolicy respects nfcActive to avoid auth lock during NFC sessions

Tests & docs

  • 15 unit tests: schema parsing, codec roundtrip/oversize/expiry, store transitions
  • Manual PoC helpers in nfc-spike.ts for device verification
  • Jest + npm run typecheck configured

Test plan

  • npm test — 15 tests passing (schema, codec, session store)
  • npm run typecheck — no TypeScript errors
  • Rebuild dev client: npx expo prebuild --clean && npx expo run:android (or iOS)
  • Device smoke: nfcSpikeCheckSupport() returns supported: true
  • Two-device manual: writer broadcasts request, reader receives and validates payload
  • Verify writer timeout (60s) and reader timeout (45s) cancel cleanly
  • Verify expired payload is rejected on reader path

Out of scope (follow-up PRs)

  • Receive/send screen orchestration (C11+)
  • NfcAvailabilityBanner UI (CLI-053)
  • Server-side replay protection API
  • QR fallback

YAustinXYZ and others added 6 commits July 16, 2026 17:31
Co-authored-by: Cursor <cursoragent@cursor.com>
Regenerate lock file from upstream develop and npm install so transitive deps (jest, testing-library, metro-config) match package.json.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore top-level @emnapi optional deps and align lockfile with Node 20 npm ci on Linux runners.

Co-authored-by: Cursor <cursoragent@cursor.com>
Format codebase with Prettier, fix hook deps in useSessionPolicy, replace require() in PasskeyService tests, and rename AuthErrorCode type alias to avoid redeclare.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JoelVR17
JoelVR17 merged commit c181ba0 into Ding-Payments:develop Jul 18, 2026
1 check passed
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.

[C10] NFC protocol and session management

2 participants