@velion-la/onboarding-sdk-react-native 1.2.0-beta.1 → 1.2.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +47 -17
  2. package/lib/commonjs/camera/DocumentCapture.js +57 -35
  3. package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
  4. package/lib/commonjs/camera/LivenessCamera.js +240 -87
  5. package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
  6. package/lib/commonjs/camera/MapAddressPicker.js +1 -1
  7. package/lib/commonjs/camera/MapAddressPicker.js.map +1 -1
  8. package/lib/commonjs/i18n/strings/en.js +1 -0
  9. package/lib/commonjs/i18n/strings/en.js.map +1 -1
  10. package/lib/commonjs/i18n/strings/es.js +1 -0
  11. package/lib/commonjs/i18n/strings/es.js.map +1 -1
  12. package/lib/commonjs/steps/DocumentsOcrStep.js +140 -20
  13. package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
  14. package/lib/commonjs/steps/LivenessMatchStep.js +361 -63
  15. package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -1
  16. package/lib/commonjs/transport/irisWebSocket.js +38 -3
  17. package/lib/commonjs/transport/irisWebSocket.js.map +1 -1
  18. package/lib/commonjs/ui/icons/StepIcon.js +8 -3
  19. package/lib/commonjs/ui/icons/StepIcon.js.map +1 -1
  20. package/lib/commonjs/ui/overlays/LoadingOverlay.js +1 -1
  21. package/lib/commonjs/ui/overlays/LoadingOverlay.js.map +1 -1
  22. package/lib/commonjs/ui/overlays/RetryDialog.js +1 -1
  23. package/lib/commonjs/ui/overlays/RetryDialog.js.map +1 -1
  24. package/lib/commonjs/utils/jpegFromUri.js +54 -14
  25. package/lib/commonjs/utils/jpegFromUri.js.map +1 -1
  26. package/lib/module/camera/DocumentCapture.js +58 -36
  27. package/lib/module/camera/DocumentCapture.js.map +1 -1
  28. package/lib/module/camera/LivenessCamera.js +242 -89
  29. package/lib/module/camera/LivenessCamera.js.map +1 -1
  30. package/lib/module/camera/MapAddressPicker.js +1 -1
  31. package/lib/module/camera/MapAddressPicker.js.map +1 -1
  32. package/lib/module/i18n/strings/en.js +1 -0
  33. package/lib/module/i18n/strings/en.js.map +1 -1
  34. package/lib/module/i18n/strings/es.js +1 -0
  35. package/lib/module/i18n/strings/es.js.map +1 -1
  36. package/lib/module/steps/DocumentsOcrStep.js +140 -20
  37. package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
  38. package/lib/module/steps/LivenessMatchStep.js +364 -66
  39. package/lib/module/steps/LivenessMatchStep.js.map +1 -1
  40. package/lib/module/transport/irisWebSocket.js +38 -3
  41. package/lib/module/transport/irisWebSocket.js.map +1 -1
  42. package/lib/module/ui/icons/StepIcon.js +8 -3
  43. package/lib/module/ui/icons/StepIcon.js.map +1 -1
  44. package/lib/module/ui/overlays/LoadingOverlay.js +1 -1
  45. package/lib/module/ui/overlays/LoadingOverlay.js.map +1 -1
  46. package/lib/module/ui/overlays/RetryDialog.js +1 -1
  47. package/lib/module/ui/overlays/RetryDialog.js.map +1 -1
  48. package/lib/module/utils/jpegFromUri.js +52 -14
  49. package/lib/module/utils/jpegFromUri.js.map +1 -1
  50. package/lib/typescript/camera/DocumentCapture.d.ts +15 -3
  51. package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -1
  52. package/lib/typescript/camera/LivenessCamera.d.ts +101 -10
  53. package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -1
  54. package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
  55. package/lib/typescript/i18n/strings/es.d.ts +1 -0
  56. package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
  57. package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -1
  58. package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -1
  59. package/lib/typescript/transport/irisWebSocket.d.ts.map +1 -1
  60. package/lib/typescript/ui/icons/StepIcon.d.ts +7 -2
  61. package/lib/typescript/ui/icons/StepIcon.d.ts.map +1 -1
  62. package/lib/typescript/utils/jpegFromUri.d.ts +31 -10
  63. package/lib/typescript/utils/jpegFromUri.d.ts.map +1 -1
  64. package/package.json +20 -14
  65. package/src/camera/DocumentCapture.tsx +59 -41
  66. package/src/camera/LivenessCamera.tsx +283 -89
  67. package/src/camera/MapAddressPicker.tsx +1 -1
  68. package/src/i18n/strings/en.ts +2 -0
  69. package/src/i18n/strings/es.ts +2 -0
  70. package/src/steps/DocumentsOcrStep.tsx +160 -18
  71. package/src/steps/LivenessMatchStep.tsx +416 -89
  72. package/src/transport/irisWebSocket.ts +32 -2
  73. package/src/ui/icons/StepIcon.tsx +9 -3
  74. package/src/ui/overlays/LoadingOverlay.tsx +1 -1
  75. package/src/ui/overlays/RetryDialog.tsx +1 -1
  76. package/src/utils/jpegFromUri.ts +54 -16
@@ -122,11 +122,36 @@ export function openIrisWebSocket(opts: IrisOpenOptions): IrisConnection {
122
122
 
123
123
  ws.onmessage = (event: WebSocketMessageEvent) => {
124
124
  if (typeof event.data !== 'string') return;
125
+
126
+ // Parsing and handling are deliberately in SEPARATE try blocks (OSDKR-23).
127
+ // They used to share one, so a `catch` written to ignore non-JSON noise
128
+ // also swallowed every exception thrown by the handler. A message that
129
+ // arrived and blew up looked exactly like a message that never arrived —
130
+ // which is how a hung liveness step went undiagnosed.
131
+ let parsed: IrisServerMessage;
125
132
  try {
126
- const parsed = JSON.parse(event.data) as IrisServerMessage;
127
- opts.onMessage(parsed);
133
+ parsed = JSON.parse(event.data) as IrisServerMessage;
128
134
  } catch {
129
135
  // Iris only sends JSON; ignore noise.
136
+ return;
137
+ }
138
+
139
+ // Logged before dispatch so the record exists even if the handler throws.
140
+ // This is the line that answers "did SESSION_COMPLETE / the WARNING
141
+ // actually arrive?", which nothing could answer before.
142
+ log.info('[IrisWS] message', {
143
+ type: parsed.type,
144
+ ...(parsed.code != null ? { code: parsed.code } : {}),
145
+ ...(parsed.message != null ? { message: parsed.message } : {}),
146
+ ...(parsed.consecutiveMisses != null
147
+ ? { consecutiveMisses: parsed.consecutiveMisses }
148
+ : {}),
149
+ });
150
+
151
+ try {
152
+ opts.onMessage(parsed);
153
+ } catch (err) {
154
+ log.error('[IrisWS] message handler threw', { type: parsed.type, err });
130
155
  }
131
156
  };
132
157
 
@@ -183,4 +208,9 @@ export const TERMINAL_WARNING_CODES = new Set<string>([
183
208
  'SPOOF_RISK_HIGH',
184
209
  'SESSION_TERMINATED',
185
210
  'BIOMETRIC_LOCK',
211
+ // Iris sends this and immediately closes with 1000 when the session ran
212
+ // to the end without confirming every challenge. If we treat it as a
213
+ // toast, the close wins a race and the step looks like a hung socket.
214
+ 'CHALLENGE_NOT_CONFIRMED',
215
+ 'CHALLENGE_FAILED_TERMINAL',
186
216
  ]);
@@ -1,6 +1,11 @@
1
1
  /**
2
- * @fileoverview StepIcon — small wrapper around `MaterialIcons` (shipped with
3
- * `@expo/vector-icons`, which Expo SDK 54 includes by default).
2
+ * @fileoverview StepIcon — small wrapper around `MaterialIcons`, shipped with
3
+ * `@expo/vector-icons`.
4
+ *
5
+ * That package is an OPTIONAL peer dependency the host installs itself. It
6
+ * used to arrive for free because `expo` depended on it, but `expo@57` dropped
7
+ * that dependency, so relying on it silently blanked every step icon
8
+ * (OSDKR-21). Nothing here assumes it is present.
4
9
  *
5
10
  * Steps pass an icon by name (e.g. `<StepIcon name="badge" />`) and the
6
11
  * shell renders it inside the colored circle next to the title. When the
@@ -46,7 +51,8 @@ try {
46
51
  } catch {
47
52
  log.warn(
48
53
  '[StepIcon] @expo/vector-icons is not installed — step header icons will be hidden. ' +
49
- 'Either install it (Expo SDK 54+ ships it by default) or set VelionTheme.hideStepIcons=true.',
54
+ 'Install it (`npx expo install @expo/vector-icons`) or set VelionTheme.hideStepIcons=true. ' +
55
+ 'Note it is no longer bundled with expo: since SDK 57 the host has to add it explicitly.',
50
56
  );
51
57
  }
52
58
 
@@ -88,7 +88,7 @@ export function LoadingOverlay({ message }: LoadingOverlayProps) {
88
88
 
89
89
  const styles = StyleSheet.create({
90
90
  root: {
91
- ...StyleSheet.absoluteFillObject,
91
+ ...StyleSheet.absoluteFill,
92
92
  alignItems: 'center',
93
93
  justifyContent: 'center',
94
94
  paddingHorizontal: 32,
@@ -81,7 +81,7 @@ export function RetryDialog({
81
81
 
82
82
  const styles = StyleSheet.create({
83
83
  root: {
84
- ...StyleSheet.absoluteFillObject,
84
+ ...StyleSheet.absoluteFill,
85
85
  alignItems: 'center',
86
86
  justifyContent: 'center',
87
87
  padding: 24,
@@ -5,14 +5,23 @@
5
5
  * path into either base64 (for the Iris HMAC envelope) or raw bytes (for
6
6
  * binary WebSocket frames + direct PUT to signed URLs).
7
7
  *
8
- * Why not `fetch(uri).then(r => r.blob()).then(b => b.arrayBuffer())`?
8
+ * Why not `fetch(uri)`?
9
9
  *
10
- * React Native's Blob polyfill does NOT implement `Blob.arrayBuffer()`
11
- * (it's web-only). Calling it crashes with
12
- * `TypeError: blob.arrayBuffer is not a function`. The reliable path on
13
- * iOS + Android is the native `File.arrayBuffer()` from
14
- * `expo-file-system` v19+, which reads directly from disk into an
15
- * ArrayBuffer without going through the JS Blob bridge.
10
+ * Two independent reasons, and the second one is the load-bearing one now:
11
+ *
12
+ * 1. React Native's Blob polyfill does NOT implement `Blob.arrayBuffer()`
13
+ * (it's web-only) — calling it throws `blob.arrayBuffer is not a
14
+ * function`.
15
+ * 2. **`fetch` cannot read local files at all since Expo SDK 57.** Expo now
16
+ * replaces the global `fetch` (`expo/src/winter/runtime.native.ts`:
17
+ * `install('fetch', ...)`) with a native HTTP client, and that client does
18
+ * not handle the `file://` scheme. It answers with an empty body instead
19
+ * of failing, so anything reading a capture through `fetch` silently
20
+ * uploads 0 bytes (OSDKR-22). SDK 54 did not install it, which is why the
21
+ * old code worked.
22
+ *
23
+ * `File.arrayBuffer()` from `expo-file-system` reads straight from disk and is
24
+ * unaffected by either.
16
25
  */
17
26
 
18
27
  import { File } from 'expo-file-system';
@@ -25,18 +34,47 @@ export interface JpegFromUri {
25
34
  }
26
35
 
27
36
  /**
28
- * Reads a `file://` URI into JPEG bytes + base64 representation.
29
- *
30
- * Accepts both forms vision-camera returns (`/var/mobile/...` without a
31
- * scheme on iOS; `file:///data/...` on Android). Normalises to `file://`.
37
+ * Normalises the path forms vision-camera returns (`/var/mobile/...` without a
38
+ * scheme on iOS; `file:///data/...` on Android) to a `file://` URI.
32
39
  */
33
- export async function readJpegFromUri(uri: string): Promise<JpegFromUri> {
34
- const normalised = uri.startsWith('file://') || uri.startsWith('http')
40
+ function normalise(uri: string): string {
41
+ return uri.startsWith('file://') || uri.startsWith('http')
35
42
  ? uri
36
43
  : `file://${uri}`;
37
- const file = new File(normalised);
38
- const buf = await file.arrayBuffer();
39
- const bytes = new Uint8Array(buf);
44
+ }
45
+
46
+ /**
47
+ * Reads a local file into raw bytes.
48
+ *
49
+ * Prefer this over `readJpegFromUri` when the caller only needs the bytes —
50
+ * uploads, for instance. It skips the base64 encoding, which is pure waste for
51
+ * a multi-megabyte video.
52
+ */
53
+ export async function readBytesFromUri(uri: string): Promise<Uint8Array> {
54
+ const buf = await new File(normalise(uri)).arrayBuffer();
55
+ return new Uint8Array(buf);
56
+ }
57
+
58
+ /**
59
+ * Size of a local file in bytes, or `0` when it cannot be read.
60
+ *
61
+ * Reads the filesystem metadata instead of loading the contents, so it stays
62
+ * cheap enough to call before an upload.
63
+ */
64
+ export function byteLengthOfUri(uri: string): number {
65
+ try {
66
+ const size = new File(normalise(uri)).size;
67
+ return typeof size === 'number' ? size : 0;
68
+ } catch {
69
+ return 0;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Reads a `file://` URI into JPEG bytes + base64 representation.
75
+ */
76
+ export async function readJpegFromUri(uri: string): Promise<JpegFromUri> {
77
+ const bytes = await readBytesFromUri(uri);
40
78
  const base64 = bytesToBase64(bytes);
41
79
  return { bytes, base64, byteLength: bytes.byteLength };
42
80
  }