C11 — NFC platform config, security and documentation
| Field |
Value |
| ID |
C11 |
| ETA |
ETA 3 |
| Priority |
P0 |
| Complexity |
H |
| Depends on |
C10 |
| Atomic tasks |
CLI-053, CLI-054, CLI-055, CLI-056, CLI-057, CLI-058, CLI-059, CLI-060 |
| Est. effort |
6-8 days |
Executive summary
Consolidate platform-level NFC readiness for iOS and Android, then lock down payload safety and replay protections so receive/send flows can trust inbound requests.
Centralize NFC session composition, user-facing error mapping, and analytics instrumentation in one implementation surface (useNfc + error services) to reduce duplicated failure handling.
Publish docs/nfc-flow.md as the implementation and onboarding source of truth, including handshake sequence, security constraints, and device requirements for beta testers.
Product context
This deliverable completes the hardening layer between C10 protocol primitives and end-user payment flows. It addresses platform capability detection, expiration/replay validation, strict payload privacy rules, iOS/Android native configuration checks, and operational documentation. Without C11, C12/C13 can technically run but remain fragile, non-portable, and unsafe for production-like testing.
User stories
- As a user on a misconfigured device, I see immediately why NFC is unavailable and how to fix it.
- As a security reviewer, I can verify that NFC payloads never include secrets and that replay windows are constrained.
- As a mobile engineer, I can use one
useNfc() hook API across receive/send without re-implementing session lifecycle.
- As QA, I have deterministic error messages and analytics events for timeout, interruption, invalid payload, and disabled NFC paths.
- As a new contributor, I can implement and debug NFC flows from
docs/nfc-flow.md without reverse engineering app internals.
Prerequisites
- C10 completed with stable reader/writer primitives and payload codec.
- Dev builds available on physical iOS and Android devices (Expo Go unsupported).
- Analytics stub from CLI-012 available for event constants and tracking.
- Agreement on NFC security policy (no secret/seed/private key fields in payload schema).
Atomic sub-task checklist
| CLI-ID |
Title |
Key deliverable |
| CLI-053 |
NfcAvailabilityBanner and redirect to settings |
Detect unsupported/disabled NFC and guide user to OS settings |
| CLI-054 |
Expiry validation and replay protection |
Reject expired/duplicate requests with skew and TTL constraints |
| CLI-055 |
NFC security: prohibit secrets in payload |
Enforce static checks and documentation for forbidden payload fields |
| CLI-056 |
Config iOS Core NFC sessions |
Validate iOS entitlements, usage strings, and foreground behavior |
| CLI-057 |
Config Android foreground dispatch NFC |
Validate Android permission, dispatch behavior, and OEM caveats |
| CLI-058 |
Hook useNfc() composer |
Expose unified hook API for read/write/cancel/status |
| CLI-059 |
NFC error handling and analytics |
Map native/flow errors to user copy and analytics events |
| CLI-060 |
Document nfc-flow.md |
Publish end-to-end NFC implementation and troubleshooting guide |
Scope — In
- NFC availability UX in send/receive entry points.
- Validation pipeline for expiry, replay dedupe, and clock skew tolerance.
- Schema guardrails and tests that fail on secret-like payload fields.
- iOS + Android native configuration verification and checklists.
- Reusable
useNfc() orchestration hook and cleanup semantics.
- Unified NFC error taxonomy and analytics coverage.
- NFC documentation including diagrams, errors, security rules, and device checklist links.
Scope — Out
- QR fallback or hybrid transport.
- Payload cryptographic signatures or server nonce protocol.
- Background NFC scanning/HCE card emulation.
- Automated E2E framework implementation (covered by later deliverables).
Architecture & conventions
Keep NFC concerns inside src/features/nfc/ as a layered stack: schema/validation -> service adapters -> hook orchestration -> UI components. Enforce non-sensitive payload contract at schema boundary, and keep analytics/logging redacted by design. Platform capability and session lifecycle state should remain feature-local and exposed to screens only through hooks/selectors.
Files to create/modify
src/features/nfc/components/NfcAvailabilityBanner.tsx
src/features/nfc/services/paymentRequestValidation.ts
src/features/nfc/schemas/__tests__/paymentRequest.security.test.ts
src/features/nfc/hooks/useNfc.ts
src/features/nfc/services/nfcErrors.ts
src/features/nfc/schemas/paymentRequest.ts
src/features/nfc/services/NfcReader.ts
src/features/nfc/state/nfcSessionStore.ts
src/app/(tabs)/receive.tsx
src/app/(tabs)/send.tsx
app.config.ts
docs/nfc-flow.md
docs/nfc-device-checklist.md
README.md
src/constants/analytics-events.ts
Implementation guide
- Implement capability banner rendering paths for unsupported/disabled NFC and add settings deep-link helper.
- Build
validatePaymentRequest() with expiry, clock skew tolerance, and short-lived dedupe key cache.
- Add schema security tests that assert forbidden key patterns are absent from request payload model.
- Audit and update
app.config.ts for iOS Core NFC and Android NFC permission/foreground requirements.
- Create
useNfc() hook that wraps reader/writer services, exposes status primitives, and guarantees unmount cleanup.
- Introduce centralized
NfcErrorCode and mapping utility with Spanish-first user copy and no sensitive logging.
- Wire analytics events for success/failure/timeout paths from hook-level transitions.
- Document flow sequence, security checklist, payload contract references, and test-device caveats in
docs/nfc-flow.md.
- Update README and checklist links so onboarding references a single authoritative NFC runbook.
Acceptance criteria
Test plan
- Unit: Validation tests for expiry/skew/replay; schema security tests;
mapNfcError tests; useNfc hook behavior tests with mocked services.
- Manual: Disable NFC and verify banner; run 2-device happy path; replay same payload within TTL; force timeout/interruption; verify analytics payload redaction.
- Device: Physical iPhone (Core NFC), physical Android (Pixel/Samsung class), and at least one cross-platform pair for tap exchange.
Server coordination
No direct server dependency. Keep payload versioning aligned with server-side expectations (payment-request.v1) documented in shared contracts and ADR references.
Security notes
- Explicitly forbid private keys, seeds, credential secrets, and auth tokens in NFC payload schema.
- Replay mitigation uses expiry + dedupe cache; document residual risk when attacker captures payload inside valid window.
- Analytics and logs must only include error codes/categories, never raw payload or credential identifiers.
- Document platform-specific behavior differences that can affect reliability/security assumptions (foreground requirement, session interruption).
Risks & pitfalls
- Device/OEM NFC variance can create false negatives in readiness checks.
- Clock drift between devices may reject otherwise valid requests if skew window is too strict.
- Overly broad security test regex may produce developer friction; define clear allowed/forbidden patterns.
- Missing cleanup in hook layer can leak session state and cause flaky downstream flows.
Definition of done
Source: build plan
C11 — NFC platform config, security and documentation
Executive summary
Consolidate platform-level NFC readiness for iOS and Android, then lock down payload safety and replay protections so receive/send flows can trust inbound requests.
Centralize NFC session composition, user-facing error mapping, and analytics instrumentation in one implementation surface (
useNfc+ error services) to reduce duplicated failure handling.Publish
docs/nfc-flow.mdas the implementation and onboarding source of truth, including handshake sequence, security constraints, and device requirements for beta testers.Product context
This deliverable completes the hardening layer between C10 protocol primitives and end-user payment flows. It addresses platform capability detection, expiration/replay validation, strict payload privacy rules, iOS/Android native configuration checks, and operational documentation. Without C11, C12/C13 can technically run but remain fragile, non-portable, and unsafe for production-like testing.
User stories
useNfc()hook API across receive/send without re-implementing session lifecycle.docs/nfc-flow.mdwithout reverse engineering app internals.Prerequisites
Atomic sub-task checklist
Scope — In
useNfc()orchestration hook and cleanup semantics.Scope — Out
Architecture & conventions
Keep NFC concerns inside
src/features/nfc/as a layered stack: schema/validation -> service adapters -> hook orchestration -> UI components. Enforce non-sensitive payload contract at schema boundary, and keep analytics/logging redacted by design. Platform capability and session lifecycle state should remain feature-local and exposed to screens only through hooks/selectors.Files to create/modify
src/features/nfc/components/NfcAvailabilityBanner.tsxsrc/features/nfc/services/paymentRequestValidation.tssrc/features/nfc/schemas/__tests__/paymentRequest.security.test.tssrc/features/nfc/hooks/useNfc.tssrc/features/nfc/services/nfcErrors.tssrc/features/nfc/schemas/paymentRequest.tssrc/features/nfc/services/NfcReader.tssrc/features/nfc/state/nfcSessionStore.tssrc/app/(tabs)/receive.tsxsrc/app/(tabs)/send.tsxapp.config.tsdocs/nfc-flow.mddocs/nfc-device-checklist.mdREADME.mdsrc/constants/analytics-events.tsImplementation guide
validatePaymentRequest()with expiry, clock skew tolerance, and short-lived dedupe key cache.app.config.tsfor iOS Core NFC and Android NFC permission/foreground requirements.useNfc()hook that wraps reader/writer services, exposes status primitives, and guarantees unmount cleanup.NfcErrorCodeand mapping utility with Spanish-first user copy and no sensitive logging.docs/nfc-flow.md.Acceptance criteria
useNfc()exposes stable API (startWriting,startReading,cancel,status) used by send/receive flows.docs/nfc-flow.mdcontains handshake diagram, role split (writer/reader), security rules, and troubleshooting table.Test plan
mapNfcErrortests;useNfchook behavior tests with mocked services.Server coordination
No direct server dependency. Keep payload versioning aligned with server-side expectations (
payment-request.v1) documented in shared contracts and ADR references.Security notes
Risks & pitfalls
Definition of done
useNfcAPIs without duplicating low-level service orchestration.Source: build plan