Commit ae9c590
authored
feat: add native PCI-compliant credit card input (iOS + Android) (#51)
### Description
Adds a `NativeCreditCard` component that replaces the WebView-based card
input with platform-native text fields (`UITextField` on iOS, `EditText`
on Android). Card data stays in native Swift/Kotlin memory and never
enters the JavaScript heap. Tokenization uses NaCl-encrypted
communication (Curve25519-XSalsa20-Poly1305 via vendored TweetNaCl) with
Bolt's tokenizer service, matching the protocol used by the existing
WebView iframe. The native component coexists with the existing WebView
implementation — merchants opt in by changing a single import.
Includes all PCI security controls: screen capture prevention (SR-7),
accessibility hardening (SR-8), memory zeroing on all exit paths (SR-2),
debug/simulator detection (SR-12), jailbreak/root detection (SR-13),
runtime integrity checks (SR-15), ProGuard/R8 rules (SR-14), dark mode
support, native `setStyles()` with full prop wiring, and validation
error parity with the WebView. Transport security is provided by NaCl
`crypto_box` end-to-end encryption — a MITM cannot decrypt the payload
without the server's private key. Also bumps React Native from 0.84 to
0.85.
### Testing
- **Unit tests**: 27 new tests across 3 test files
(`NativeCreditCard.test.tsx`, `NativeCreditCardComponent.test.tsx`,
`useNativeCreditCardController.test.ts`) covering namespace exports,
component rendering, prop forwarding, all 4 event types, tokenize
success/error/unmounted/malformed JSON/null fields/null native module,
and `setStyles`. Updated `index.test.tsx` with export validation. All
147 tests pass.
- **iOS manual**: `yarn example ios` → "Native" tab renders card fields,
card brand icon appears on BIN detection (Visa/MC/Amex/Discover), PAN
masks on blur, validation errors highlight red, tokenization succeeds
with Bolt sandbox, screen capture overlay appears during recording,
`setStyles()` applies changes, dark mode colors update on trait change.
- **Android manual**: `yarn example android` → same flows verified with
compound drawable icons, postal code watcher enables button,
`FLAG_SECURE` applied on attach and cleared on detach, TalkBack
announces "Card number ending in XXXX" without reading full PAN, dark
mode colors respond to night mode.
- **Coexistence**: "WebView" tab continues to work alongside "Native"
tab with no interference.
- **TypeScript**: `npx tsc --noEmit` passes with 0 errors.
- **Lint**: `npx eslint` passes with 0 errors.
- **npm pack**: should be tested with a fresh Expo project before
release per established process.
### Security Review
> [!IMPORTANT]
> A security review is required for every PR in this repository to
comply with PCI requirements.
- [x] I have considered and reviewed security implications of this PR
and included the summary below.
#### Security Impact Summary
This PR introduces native handling of cardholder data (PAN, CVV, expiry)
in Swift and Kotlin. Security controls implemented:
- **SR-1 CHD isolation**: Card data exists only in native `UInt8[]` /
`CharArray` buffers, never crosses the JS bridge as strings.
- **SR-2 Memory zeroing**: All card buffers explicitly zeroed after
tokenization on every exit path (success, failure, timeout, view
unmount). Local copies in the TurboModule completion handler also
zeroed. Client secret key zeroed in-place after decryption (no Swift CoW
copy). Postal field text cleared.
- **SR-5 CVV masked**: `isSecureTextEntry` /
`TYPE_NUMBER_VARIATION_PASSWORD` at all times.
- **SR-6 PAN masked**: Only last 4 visible after field loses focus.
- **SR-7 Screen capture**: iOS monitors
`UIScreen.capturedDidChangeNotification` and overlays card fields when
recording. Android applies `FLAG_SECURE` on attach and clears on detach.
- **SR-8 Accessibility**: iOS PAN returns "ending in XXXX" for
VoiceOver, CVV sets `isAccessibilityElement = false`. Android PAN uses
custom `AccessibilityDelegate` showing masked value.
- **SR-9 No disk persistence**: `autocorrectionType = .no`,
`IMPORTANT_FOR_AUTOFILL_NO`, `TYPE_TEXT_FLAG_NO_SUGGESTIONS`,
`dispatchFreezeSelfOnly` prevents `Bundle` serialization.
- **SR-12 Debug detection**: Detects debug builds and
simulators/emulators. Logs warning in production for jailbroken/rooted
devices only — does not block during development.
- **SR-13 Jailbreak/root detection**: iOS checks Cydia/apt paths and
sandbox escape. Android checks su binaries, test-keys, and root
management apps. Reports via `BoltDeviceIntegrity.integrityReport()`.
- **SR-14 ProGuard**: `proguard-rules.pro` with `-keepclassmembers` for
crypto and zeroing methods, `-keepnames` for bridge registration.
Consumer rules applied via `defaultConfig`.
- **SR-15 Runtime integrity**: iOS verifies code signing validity.
Android verifies APK signature presence.
- **Encrypted tokenization**: PAN/CVV encrypted via NaCl `crypto_box`
(Curve25519-XSalsa20-Poly1305) before transmission. Plaintext bytes
zeroed immediately after encryption. No `String` intermediaries for CHD
(FR-3.4). Transport protection provided by end-to-end encryption — MITM
cannot decrypt without server's private key.
- **Crypto safety**: `SecRandomCopyBytes` return checked — aborts on
PRNG failure. Empty token responses rejected.
- **Dark mode**: Dynamic colors on both platforms prevent UI artifacts
that could expose field state.
- **PCI SSS certification**: In progress. Native component labeled as
beta. WebView remains the production SAQ A path until certification
completes.1 parent 9b13d0e commit ae9c590
File tree
72 files changed
+6610
-887
lines changed- android
- src/main
- java/com/boltreactnativesdk
- creditcardfield
- res
- drawable-mdpi
- drawable-xhdpi
- drawable-xxhdpi
- example
- ios
- src
- ios
- CardBrandAssets
- src
- __tests__
- native
- payments
- telemetry
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
72 files changed
+6610
-887
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
272 | 368 | | |
273 | 369 | | |
274 | 370 | | |
| |||
282 | 378 | | |
283 | 379 | | |
284 | 380 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
292 | 390 | | |
293 | 391 | | |
294 | 392 | | |
| |||
313 | 411 | | |
314 | 412 | | |
315 | 413 | | |
316 | | - | |
317 | | - | |
| 414 | + | |
| 415 | + | |
318 | 416 | | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
325 | 423 | | |
326 | 424 | | |
327 | 425 | | |
| |||
339 | 437 | | |
340 | 438 | | |
341 | 439 | | |
| 440 | + | |
342 | 441 | | |
343 | 442 | | |
344 | 443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
52 | | - | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Lines changed: 95 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
0 commit comments