@velion-la/onboarding-sdk-react-native 1.2.0-beta.10 → 1.2.0-beta.12
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.
- package/lib/commonjs/camera/LivenessCamera.js +117 -15
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
- package/lib/commonjs/i18n/strings/en.js +1 -0
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +1 -0
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/steps/LivenessMatchStep.js +273 -37
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -1
- package/lib/module/camera/LivenessCamera.js +118 -16
- package/lib/module/camera/LivenessCamera.js.map +1 -1
- package/lib/module/i18n/strings/en.js +1 -0
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +1 -0
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/steps/LivenessMatchStep.js +276 -40
- package/lib/module/steps/LivenessMatchStep.js.map +1 -1
- package/lib/typescript/camera/LivenessCamera.d.ts +67 -2
- package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +1 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/camera/LivenessCamera.tsx +138 -17
- package/src/i18n/strings/en.ts +2 -0
- package/src/i18n/strings/es.ts +2 -0
- package/src/steps/LivenessMatchStep.tsx +325 -63
|
@@ -24,7 +24,72 @@
|
|
|
24
24
|
* `captureFrame` ref so the step can drive the timing while the camera stays
|
|
25
25
|
* mounted across challenges.
|
|
26
26
|
*/
|
|
27
|
-
import { type
|
|
27
|
+
import { type Photo } from 'react-native-vision-camera';
|
|
28
|
+
/**
|
|
29
|
+
* DIAGNOSTIC (OSDKR-24): which stream combination the liveness session binds.
|
|
30
|
+
*
|
|
31
|
+
* On a Motorola Edge 30 Neo and a Moto G51 every frame stays under Iris's
|
|
32
|
+
* sharpness floor, while a Moto G75 and a Galaxy A04 pass with the same code.
|
|
33
|
+
* v5 no longer lets us pick a photo size from the device's list: CameraX
|
|
34
|
+
* negotiates preview + photo + video (+ the fps cap) as one `SessionConfig`
|
|
35
|
+
* and may silently shrink the JPEG to make the combination fit. These
|
|
36
|
+
* variants isolate which part of the combination costs us the resolution:
|
|
37
|
+
*
|
|
38
|
+
* - `'full'` — preview + photo + video, 30 fps cap. Production behaviour.
|
|
39
|
+
* - `'no-video'` — preview + photo, 30 fps cap. The evidence video is skipped
|
|
40
|
+
* (best-effort path: `liveness-verify` goes without a body).
|
|
41
|
+
* - `'no-fps'` — preview + photo + video, no fps constraint.
|
|
42
|
+
* - `'v4-equivalent'` — the photo capture vision-camera 4.7.3 did before the
|
|
43
|
+
* migration: `'balanced'` (MINIMIZE_LATENCY, what v4 called
|
|
44
|
+
* `'speed'`) at UHD_4_3 (the sensor's largest 4:3 size), with
|
|
45
|
+
* video and no fps constraint — v4 never applied fps to the
|
|
46
|
+
* photo stream, while v5 applies it to the whole session.
|
|
47
|
+
* - `'v4-equivalent-30fps'` — the same photo capture plus the 30 fps cap v4
|
|
48
|
+
* put on preview and video. v5 cannot cap only those two: the
|
|
49
|
+
* constraint covers the whole session, photo included, so
|
|
50
|
+
* check the diagnostic log for the capture size it lands on.
|
|
51
|
+
*
|
|
52
|
+
* Android only: iOS always binds `'full'`, the configuration it passes Iris
|
|
53
|
+
* with (see ACTIVE_LIVENESS_CAMERA_VARIANT).
|
|
54
|
+
*
|
|
55
|
+
* Defaults to `'v4-equivalent'`: on the Edge 30 Neo it doubled the measured
|
|
56
|
+
* sharpness against `'full'` at the same face size. `'v4-equivalent-30fps'`
|
|
57
|
+
* was ruled out on the same device: to hold 30 fps CameraX moved the photo to
|
|
58
|
+
* a 16:9 3264x1836 stream, sharpness fell back to `'full'` levels, and the
|
|
59
|
+
* narrower field of view enlarged the face enough to trip `TOO_CLOSE`.
|
|
60
|
+
* Flip it by hand for a test build.
|
|
61
|
+
*/
|
|
62
|
+
export type LivenessCameraVariant = 'full' | 'no-video' | 'no-fps' | 'v4-equivalent' | 'v4-equivalent-30fps';
|
|
63
|
+
export declare const LIVENESS_CAMERA_VARIANT: LivenessCameraVariant;
|
|
64
|
+
/** The variant this platform actually binds. */
|
|
65
|
+
export declare const ACTIVE_LIVENESS_CAMERA_VARIANT: LivenessCameraVariant;
|
|
66
|
+
/**
|
|
67
|
+
* Android keeps each liveness frame in memory instead of round-tripping it
|
|
68
|
+
* through files (OSDKR-24). With the 8 MP v4-equivalent capture on an Edge 30
|
|
69
|
+
* Neo, the file path cost ~380 ms per frame on top of the camera's ~330 ms —
|
|
70
|
+
* write the JPEG, load it back through the image loader, write the resized
|
|
71
|
+
* copy, read that back — and held the loop at ~1.4 fps. Scaling and encoding
|
|
72
|
+
* are the same on both paths (bilinear scale, `Bitmap.compress`).
|
|
73
|
+
* `Photo.toImage()` applies the photo's rotation but also mirrors
|
|
74
|
+
* front-camera photos, which the file path does not; `encodeFrame` in the
|
|
75
|
+
* liveness step undoes that mirror, or TURN_LEFT / TURN_RIGHT invert.
|
|
76
|
+
*
|
|
77
|
+
* iOS stays on the file path it passes Iris with. Set to `false` to put
|
|
78
|
+
* Android back on it for an A/B run.
|
|
79
|
+
*/
|
|
80
|
+
export declare const ANDROID_IN_MEMORY_FRAMES = true;
|
|
81
|
+
/**
|
|
82
|
+
* A liveness frame as the camera handed it over, before it is scaled and
|
|
83
|
+
* encoded for Iris. A `'memory'` frame holds a camera buffer until its photo
|
|
84
|
+
* is disposed, so whoever ends up with it must release it.
|
|
85
|
+
*/
|
|
86
|
+
export type CapturedFrame = {
|
|
87
|
+
kind: 'file';
|
|
88
|
+
filePath: string;
|
|
89
|
+
} | {
|
|
90
|
+
kind: 'memory';
|
|
91
|
+
photo: Photo;
|
|
92
|
+
};
|
|
28
93
|
/**
|
|
29
94
|
* The recorded liveness video, as this component reports it upwards.
|
|
30
95
|
*
|
|
@@ -41,7 +106,7 @@ export interface LivenessVideoFile {
|
|
|
41
106
|
duration?: number | undefined;
|
|
42
107
|
}
|
|
43
108
|
export interface LivenessCameraHandle {
|
|
44
|
-
takeFrame: () => Promise<
|
|
109
|
+
takeFrame: () => Promise<CapturedFrame | null>;
|
|
45
110
|
/**
|
|
46
111
|
* Start an mp4/h264 video recording on the same `<Camera>` that feeds the
|
|
47
112
|
* frame loop. Audio is disabled. Errors during recording are delivered
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivenessCamera.d.ts","sourceRoot":"","sources":["../../../src/camera/LivenessCamera.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"LivenessCamera.d.ts","sourceRoot":"","sources":["../../../src/camera/LivenessCamera.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAqBH,OAAO,EAQL,KAAK,KAAK,EAEX,MAAM,4BAA4B,CAAC;AAMpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,qBAAqB,GAC7B,MAAM,GACN,UAAU,GACV,QAAQ,GACR,eAAe,GACf,qBAAqB,CAAC;AAE1B,eAAO,MAAM,uBAAuB,EACf,qBAAqB,CAAC;AAE3C,gDAAgD;AAChD,eAAO,MAAM,8BAA8B,EAAE,qBACiB,CAAC;AAM/D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAG7C;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAwBrC;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAC/C;;;;;;OAMG;IACH,mBAAmB,CAAC,IAAI,EAAE;QACxB,mBAAmB,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;QACxD,gBAAgB,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;KAC1C,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB;;;;OAIG;IACH,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,aAAa,GAAG,cAAc,CAAC;AAEzE,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,2EAA2E;IAC3E,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IACtC,iFAAiF;IACjF,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5E,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,wCAAwC;IACxC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CACrC;AAED,eAAO,MAAM,cAAc,sHA8S1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/strings/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,eAAO,MAAM,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/i18n/strings/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,eAAO,MAAM,EAAE,EAAE,YA+UhB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/i18n/strings/es.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/i18n/strings/es.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Ud,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivenessMatchStep.d.ts","sourceRoot":"","sources":["../../../src/steps/LivenessMatchStep.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"LivenessMatchStep.d.ts","sourceRoot":"","sources":["../../../src/steps/LivenessMatchStep.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0DH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAsNpD,qBAAa,iBAAkB,YAAW,UAAU;IAKtC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJjC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,SAAS,CAAS;gBAEG,IAAI,EAAE,QAAQ;IAE3C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BpB,OAAO,IAAI,IAAI;CAIhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velion-la/onboarding-sdk-react-native",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.12",
|
|
4
4
|
"description": "Native React Native SDK for the Velion Onboarding (KYC) flow: ID document OCR, passive + active liveness, device fingerprint, OTP verification, address picker, and personal / legal information forms.",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
ActivityIndicator,
|
|
38
38
|
Animated,
|
|
39
39
|
Easing,
|
|
40
|
+
Platform,
|
|
40
41
|
StyleSheet,
|
|
41
42
|
Text,
|
|
42
43
|
useWindowDimensions,
|
|
@@ -51,13 +52,114 @@ import {
|
|
|
51
52
|
usePhotoOutput,
|
|
52
53
|
useVideoOutput,
|
|
53
54
|
type CameraRef,
|
|
54
|
-
type
|
|
55
|
+
type Photo,
|
|
55
56
|
type Recorder,
|
|
56
57
|
} from 'react-native-vision-camera';
|
|
57
58
|
import { Button } from '../ui/primitives/Button';
|
|
58
59
|
import { useTheme, withAlpha } from '../ui/theme';
|
|
60
|
+
import { log } from '../utils/log';
|
|
59
61
|
import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
|
|
60
62
|
|
|
63
|
+
/**
|
|
64
|
+
* DIAGNOSTIC (OSDKR-24): which stream combination the liveness session binds.
|
|
65
|
+
*
|
|
66
|
+
* On a Motorola Edge 30 Neo and a Moto G51 every frame stays under Iris's
|
|
67
|
+
* sharpness floor, while a Moto G75 and a Galaxy A04 pass with the same code.
|
|
68
|
+
* v5 no longer lets us pick a photo size from the device's list: CameraX
|
|
69
|
+
* negotiates preview + photo + video (+ the fps cap) as one `SessionConfig`
|
|
70
|
+
* and may silently shrink the JPEG to make the combination fit. These
|
|
71
|
+
* variants isolate which part of the combination costs us the resolution:
|
|
72
|
+
*
|
|
73
|
+
* - `'full'` — preview + photo + video, 30 fps cap. Production behaviour.
|
|
74
|
+
* - `'no-video'` — preview + photo, 30 fps cap. The evidence video is skipped
|
|
75
|
+
* (best-effort path: `liveness-verify` goes without a body).
|
|
76
|
+
* - `'no-fps'` — preview + photo + video, no fps constraint.
|
|
77
|
+
* - `'v4-equivalent'` — the photo capture vision-camera 4.7.3 did before the
|
|
78
|
+
* migration: `'balanced'` (MINIMIZE_LATENCY, what v4 called
|
|
79
|
+
* `'speed'`) at UHD_4_3 (the sensor's largest 4:3 size), with
|
|
80
|
+
* video and no fps constraint — v4 never applied fps to the
|
|
81
|
+
* photo stream, while v5 applies it to the whole session.
|
|
82
|
+
* - `'v4-equivalent-30fps'` — the same photo capture plus the 30 fps cap v4
|
|
83
|
+
* put on preview and video. v5 cannot cap only those two: the
|
|
84
|
+
* constraint covers the whole session, photo included, so
|
|
85
|
+
* check the diagnostic log for the capture size it lands on.
|
|
86
|
+
*
|
|
87
|
+
* Android only: iOS always binds `'full'`, the configuration it passes Iris
|
|
88
|
+
* with (see ACTIVE_LIVENESS_CAMERA_VARIANT).
|
|
89
|
+
*
|
|
90
|
+
* Defaults to `'v4-equivalent'`: on the Edge 30 Neo it doubled the measured
|
|
91
|
+
* sharpness against `'full'` at the same face size. `'v4-equivalent-30fps'`
|
|
92
|
+
* was ruled out on the same device: to hold 30 fps CameraX moved the photo to
|
|
93
|
+
* a 16:9 3264x1836 stream, sharpness fell back to `'full'` levels, and the
|
|
94
|
+
* narrower field of view enlarged the face enough to trip `TOO_CLOSE`.
|
|
95
|
+
* Flip it by hand for a test build.
|
|
96
|
+
*/
|
|
97
|
+
export type LivenessCameraVariant =
|
|
98
|
+
| 'full'
|
|
99
|
+
| 'no-video'
|
|
100
|
+
| 'no-fps'
|
|
101
|
+
| 'v4-equivalent'
|
|
102
|
+
| 'v4-equivalent-30fps';
|
|
103
|
+
|
|
104
|
+
export const LIVENESS_CAMERA_VARIANT =
|
|
105
|
+
'v4-equivalent' as LivenessCameraVariant;
|
|
106
|
+
|
|
107
|
+
/** The variant this platform actually binds. */
|
|
108
|
+
export const ACTIVE_LIVENESS_CAMERA_VARIANT: LivenessCameraVariant =
|
|
109
|
+
Platform.OS === 'android' ? LIVENESS_CAMERA_VARIANT : 'full';
|
|
110
|
+
|
|
111
|
+
const IS_V4_EQUIVALENT =
|
|
112
|
+
ACTIVE_LIVENESS_CAMERA_VARIANT === 'v4-equivalent' ||
|
|
113
|
+
ACTIVE_LIVENESS_CAMERA_VARIANT === 'v4-equivalent-30fps';
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Android keeps each liveness frame in memory instead of round-tripping it
|
|
117
|
+
* through files (OSDKR-24). With the 8 MP v4-equivalent capture on an Edge 30
|
|
118
|
+
* Neo, the file path cost ~380 ms per frame on top of the camera's ~330 ms —
|
|
119
|
+
* write the JPEG, load it back through the image loader, write the resized
|
|
120
|
+
* copy, read that back — and held the loop at ~1.4 fps. Scaling and encoding
|
|
121
|
+
* are the same on both paths (bilinear scale, `Bitmap.compress`).
|
|
122
|
+
* `Photo.toImage()` applies the photo's rotation but also mirrors
|
|
123
|
+
* front-camera photos, which the file path does not; `encodeFrame` in the
|
|
124
|
+
* liveness step undoes that mirror, or TURN_LEFT / TURN_RIGHT invert.
|
|
125
|
+
*
|
|
126
|
+
* iOS stays on the file path it passes Iris with. Set to `false` to put
|
|
127
|
+
* Android back on it for an A/B run.
|
|
128
|
+
*/
|
|
129
|
+
export const ANDROID_IN_MEMORY_FRAMES = true;
|
|
130
|
+
const IN_MEMORY_FRAMES = Platform.OS === 'android' && ANDROID_IN_MEMORY_FRAMES;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* A liveness frame as the camera handed it over, before it is scaled and
|
|
134
|
+
* encoded for Iris. A `'memory'` frame holds a camera buffer until its photo
|
|
135
|
+
* is disposed, so whoever ends up with it must release it.
|
|
136
|
+
*/
|
|
137
|
+
export type CapturedFrame =
|
|
138
|
+
| { kind: 'file'; filePath: string }
|
|
139
|
+
| { kind: 'memory'; photo: Photo };
|
|
140
|
+
|
|
141
|
+
// Module-level so `<Camera>` gets stable references across re-renders.
|
|
142
|
+
const FPS_CONSTRAINTS = [{ fps: 30 }];
|
|
143
|
+
const NO_CONSTRAINTS: never[] = [];
|
|
144
|
+
const SESSION_CONSTRAINTS =
|
|
145
|
+
ACTIVE_LIVENESS_CAMERA_VARIANT === 'no-fps' ||
|
|
146
|
+
ACTIVE_LIVENESS_CAMERA_VARIANT === 'v4-equivalent'
|
|
147
|
+
? NO_CONSTRAINTS
|
|
148
|
+
: FPS_CONSTRAINTS;
|
|
149
|
+
|
|
150
|
+
const PHOTO_OUTPUT_OPTIONS =
|
|
151
|
+
IS_V4_EQUIVALENT
|
|
152
|
+
? {
|
|
153
|
+
qualityPrioritization: 'balanced' as const,
|
|
154
|
+
targetResolution: CommonResolutions.UHD_4_3,
|
|
155
|
+
quality: 0.9,
|
|
156
|
+
}
|
|
157
|
+
: {
|
|
158
|
+
qualityPrioritization: 'quality' as const,
|
|
159
|
+
targetResolution: CommonResolutions.FHD_4_3,
|
|
160
|
+
quality: 0.9,
|
|
161
|
+
};
|
|
162
|
+
|
|
61
163
|
/**
|
|
62
164
|
* The recorded liveness video, as this component reports it upwards.
|
|
63
165
|
*
|
|
@@ -75,7 +177,7 @@ export interface LivenessVideoFile {
|
|
|
75
177
|
}
|
|
76
178
|
|
|
77
179
|
export interface LivenessCameraHandle {
|
|
78
|
-
takeFrame: () => Promise<
|
|
180
|
+
takeFrame: () => Promise<CapturedFrame | null>;
|
|
79
181
|
/**
|
|
80
182
|
* Start an mp4/h264 video recording on the same `<Camera>` that feeds the
|
|
81
183
|
* frame loop. Audio is disabled. Errors during recording are delivered
|
|
@@ -150,11 +252,9 @@ export const LivenessCamera = forwardRef<LivenessCameraHandle, LivenessCameraPro
|
|
|
150
252
|
// fraction of the cost of the 12 MP default. Escalate to
|
|
151
253
|
// `CommonResolutions.UHD_4_3` — what iOS used when it passed the gate — if
|
|
152
254
|
// the measured sharpness is still short.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
quality: 0.9,
|
|
157
|
-
});
|
|
255
|
+
// Options live in PHOTO_OUTPUT_OPTIONS so the active variant can swap
|
|
256
|
+
// them; iOS stays on `'quality'` at FHD_4_3.
|
|
257
|
+
const photoOutput = usePhotoOutput(PHOTO_OUTPUT_OPTIONS);
|
|
158
258
|
// Pin the recording to 720p so the mp4 stays a few MB instead of the
|
|
159
259
|
// device-default 1080p–4K bitrate (a 30 s session can otherwise produce a
|
|
160
260
|
// 50–80 MB file that times out on mobile uplinks). Face visibility for
|
|
@@ -178,6 +278,14 @@ export const LivenessCamera = forwardRef<LivenessCameraHandle, LivenessCameraPro
|
|
|
178
278
|
// infinite spinner after 4s without a device.
|
|
179
279
|
const [deviceTimeout, setDeviceTimeout] = useState(false);
|
|
180
280
|
|
|
281
|
+
useEffect(() => {
|
|
282
|
+
log.warn('[Liveness][diag] camera variant', {
|
|
283
|
+
variant: ACTIVE_LIVENESS_CAMERA_VARIANT,
|
|
284
|
+
configured: LIVENESS_CAMERA_VARIANT,
|
|
285
|
+
platform: Platform.OS,
|
|
286
|
+
});
|
|
287
|
+
}, []);
|
|
288
|
+
|
|
181
289
|
useEffect(() => {
|
|
182
290
|
if (!hasPermission && !requestedRef.current) {
|
|
183
291
|
requestedRef.current = true;
|
|
@@ -194,14 +302,17 @@ export const LivenessCamera = forwardRef<LivenessCameraHandle, LivenessCameraPro
|
|
|
194
302
|
return () => clearTimeout(t);
|
|
195
303
|
}, [device, hasPermission]);
|
|
196
304
|
|
|
197
|
-
const takeFrame = useCallback(async (): Promise<
|
|
305
|
+
const takeFrame = useCallback(async (): Promise<CapturedFrame | null> => {
|
|
198
306
|
if (inFlightRef.current) return null;
|
|
199
307
|
inFlightRef.current = true;
|
|
200
308
|
try {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
{}
|
|
204
|
-
|
|
309
|
+
const settings = { flashMode: 'off', enableShutterSound: false } as const;
|
|
310
|
+
if (IN_MEMORY_FRAMES) {
|
|
311
|
+
const photo = await photoOutput.capturePhoto(settings, {});
|
|
312
|
+
return { kind: 'memory', photo };
|
|
313
|
+
}
|
|
314
|
+
const file = await photoOutput.capturePhotoToFile(settings, {});
|
|
315
|
+
return { kind: 'file', filePath: file.filePath };
|
|
205
316
|
} catch {
|
|
206
317
|
// Frame failures are non-fatal — the parent loop just retries on the
|
|
207
318
|
// next tick. Keep the camera mounted.
|
|
@@ -228,6 +339,12 @@ export const LivenessCamera = forwardRef<LivenessCameraHandle, LivenessCameraPro
|
|
|
228
339
|
onRecordingError: (err: unknown) => void;
|
|
229
340
|
}): Promise<void> => {
|
|
230
341
|
if (recorderRef.current) return;
|
|
342
|
+
if (ACTIVE_LIVENESS_CAMERA_VARIANT === 'no-video') {
|
|
343
|
+
// The video output is not bound in this variant, so a Recorder on
|
|
344
|
+
// it would never start. Throwing sends the step down the same
|
|
345
|
+
// best-effort path as any other recording startup failure.
|
|
346
|
+
throw new Error('video recording disabled by diagnostic variant');
|
|
347
|
+
}
|
|
231
348
|
const recorder = await videoOutput.createRecorder({});
|
|
232
349
|
recorderRef.current = recorder;
|
|
233
350
|
recordedDurationRef.current = undefined;
|
|
@@ -347,13 +464,17 @@ export const LivenessCamera = forwardRef<LivenessCameraHandle, LivenessCameraPro
|
|
|
347
464
|
ref={cameraRef}
|
|
348
465
|
style={StyleSheet.absoluteFill}
|
|
349
466
|
device={device}
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
//
|
|
353
|
-
outputs={
|
|
467
|
+
// Photo stills feed Iris, video is the evidence recording; `<Camera>`
|
|
468
|
+
// prepends its own preview. See LIVENESS_CAMERA_VARIANT for the
|
|
469
|
+
// diagnostic combinations.
|
|
470
|
+
outputs={
|
|
471
|
+
ACTIVE_LIVENESS_CAMERA_VARIANT === 'no-video'
|
|
472
|
+
? [photoOutput]
|
|
473
|
+
: [photoOutput, videoOutput]
|
|
474
|
+
}
|
|
354
475
|
// Cap the sensor at 30 fps. Resolution and bit-rate are set on the
|
|
355
476
|
// video output itself (see `useVideoOutput` above).
|
|
356
|
-
constraints={
|
|
477
|
+
constraints={SESSION_CONSTRAINTS}
|
|
357
478
|
// Lock the recorded video orientation to the interface's so it is
|
|
358
479
|
// never upside-down or sideways on the back-office player. (v5's
|
|
359
480
|
// spelling of what v4 called `outputOrientation="preview"`.)
|
package/src/i18n/strings/en.ts
CHANGED
|
@@ -253,6 +253,8 @@ export const EN: StringsTable = {
|
|
|
253
253
|
positioningReady: 'Looking good — starting the challenges',
|
|
254
254
|
getReady: 'Heads up — starting now',
|
|
255
255
|
repositioning: "Let's pause a second — center your face and improve lighting. We'll retry the same step",
|
|
256
|
+
repositioningAfterMoveFarther:
|
|
257
|
+
"Go back to your previous distance — bring the phone a little closer and center your face. We'll retry the same step",
|
|
256
258
|
finalizing: 'Processing your video…',
|
|
257
259
|
challenge: {
|
|
258
260
|
FACE_FORWARD: 'Hold your face forward',
|
package/src/i18n/strings/es.ts
CHANGED
|
@@ -247,6 +247,8 @@ export const ES = {
|
|
|
247
247
|
positioningReady: 'Listo, ya estás bien posicionado — empezamos',
|
|
248
248
|
getReady: 'Atento — empezamos',
|
|
249
249
|
repositioning: 'Pausemos un segundo — centrá tu rostro y mejorá la luz. Reintentamos el mismo paso',
|
|
250
|
+
repositioningAfterMoveFarther:
|
|
251
|
+
'Volvé a la distancia de antes — acercá un poco el teléfono y centrá tu rostro. Reintentamos el mismo paso',
|
|
250
252
|
finalizing: 'Procesando tu video…',
|
|
251
253
|
analyzingHeadline: 'Analizando tu video',
|
|
252
254
|
analyzingCaption: 'Estamos verificando la prueba de vida. Tardará solo unos segundos.',
|