@velion-la/onboarding-sdk-react-native 1.0.0-beta.10 → 1.0.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/DocumentCapture.js +67 -26
- package/lib/commonjs/camera/DocumentCapture.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/DocumentsOcrStep.js +121 -23
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneContactStep.js +10 -4
- package/lib/commonjs/steps/PhoneContactStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneOtpStep.js +17 -6
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -1
- package/lib/commonjs/utils/documentCrop.js +115 -0
- package/lib/commonjs/utils/documentCrop.js.map +1 -0
- package/lib/module/camera/DocumentCapture.js +67 -26
- package/lib/module/camera/DocumentCapture.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/DocumentsOcrStep.js +121 -23
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/PhoneContactStep.js +10 -4
- package/lib/module/steps/PhoneContactStep.js.map +1 -1
- package/lib/module/steps/PhoneOtpStep.js +17 -6
- package/lib/module/steps/PhoneOtpStep.js.map +1 -1
- package/lib/module/utils/documentCrop.js +109 -0
- package/lib/module/utils/documentCrop.js.map +1 -0
- package/lib/typescript/camera/DocumentCapture.d.ts +20 -8
- package/lib/typescript/camera/DocumentCapture.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/DocumentsOcrStep.d.ts +8 -6
- package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -1
- package/lib/typescript/utils/documentCrop.d.ts +62 -0
- package/lib/typescript/utils/documentCrop.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/camera/DocumentCapture.tsx +66 -25
- package/src/i18n/strings/en.ts +1 -0
- package/src/i18n/strings/es.ts +1 -0
- package/src/steps/DocumentsOcrStep.tsx +145 -24
- package/src/steps/PhoneContactStep.tsx +9 -3
- package/src/steps/PhoneOtpStep.tsx +14 -4
- package/src/utils/documentCrop.ts +138 -0
|
@@ -119,6 +119,8 @@ function PhoneOtpView({
|
|
|
119
119
|
setBannerError(sdkErr.message);
|
|
120
120
|
}
|
|
121
121
|
}, [api, onComplete, otp, otpValidation, sessionId, t]);
|
|
122
|
+
const phoneField = phoneValidation.bind('phone', phone);
|
|
123
|
+
const otpField = otpValidation.bind('otp', otp);
|
|
122
124
|
if (retry) {
|
|
123
125
|
return /*#__PURE__*/_jsx(RetryDialog, {
|
|
124
126
|
title: t.common.submissionTitle,
|
|
@@ -148,9 +150,11 @@ function PhoneOtpView({
|
|
|
148
150
|
onBack: stage === 'request' ? onBack : undefined,
|
|
149
151
|
backLabel: t.common.back,
|
|
150
152
|
backDisabled: busy !== null,
|
|
151
|
-
children: [/*#__PURE__*/_jsx(Input
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
children: [/*#__PURE__*/_jsx(Input
|
|
154
|
+
// No visible label — the step title already names the field. Keep an
|
|
155
|
+
// accessibility label so screen readers still announce it.
|
|
156
|
+
, {
|
|
157
|
+
accessibilityLabel: t.phone_otp.phoneLabel,
|
|
154
158
|
autoCapitalize: "none",
|
|
155
159
|
autoCorrect: false,
|
|
156
160
|
autoComplete: "tel",
|
|
@@ -159,14 +163,19 @@ function PhoneOtpView({
|
|
|
159
163
|
placeholder: "+5491112345678",
|
|
160
164
|
editable: stage === 'request',
|
|
161
165
|
value: phone,
|
|
162
|
-
...
|
|
166
|
+
...phoneField,
|
|
167
|
+
// Strip whitespace so a pasted "+54 911 1234 5678" lands as E.164.
|
|
168
|
+
onChangeText: text => phoneField.onChangeText(text.replace(/\s+/g, ''))
|
|
163
169
|
}), stage === 'request' ? /*#__PURE__*/_jsx(Button, {
|
|
164
170
|
label: t.phone_otp.sendCode,
|
|
165
171
|
onPress: sendOtp,
|
|
166
172
|
loading: busy === 'sending',
|
|
167
173
|
disabled: busy !== null
|
|
168
174
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
169
|
-
children: [/*#__PURE__*/_jsx(Input
|
|
175
|
+
children: [/*#__PURE__*/_jsx(Input
|
|
176
|
+
// Label kept here: in the verify stage the phone field is also
|
|
177
|
+
// visible, so the label disambiguates which field is the code.
|
|
178
|
+
, {
|
|
170
179
|
label: t.phone_otp.otpLabel,
|
|
171
180
|
required: true,
|
|
172
181
|
autoCapitalize: "none",
|
|
@@ -175,7 +184,9 @@ function PhoneOtpView({
|
|
|
175
184
|
textContentType: "oneTimeCode",
|
|
176
185
|
maxLength: 6,
|
|
177
186
|
value: otp,
|
|
178
|
-
...
|
|
187
|
+
...otpField,
|
|
188
|
+
// Strip whitespace so a pasted code (e.g. "123 456") becomes "123456".
|
|
189
|
+
onChangeText: text => otpField.onChangeText(text.replace(/\s+/g, ''))
|
|
179
190
|
}), bannerError ? /*#__PURE__*/_jsx(Banner, {
|
|
180
191
|
message: bannerError
|
|
181
192
|
}) : null, /*#__PURE__*/_jsx(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useState","Pressable","StyleSheet","Text","View","SdkErrorCode","Banner","Button","Input","LoadingOverlay","RetryDialog","StepShell","StepIcon","compose","required","useInlineValidation","getStrings","useTheme","isE164Phone","isOtpCode","toSubmissionError","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PhoneOtpStep","destroyed","constructor","deps","run","Promise","resolve","reject","resolveStep","rejectStep","ui","setNode","PhoneOtpView","api","sessionId","locale","onBack","onComplete","onCancel","err","destroy","t","theme","phone","setPhone","otp","setOtp","stage","setStage","bannerError","setBannerError","busy","setBusy","retry","setRetry","phoneValidation","name","validate","phone_otp","phoneRequired","v","phone_contact","invalid","_n","otpValidation","otpRequired","otpFormat","sendOtp","validateAll","post","trim","sdkErr","message","verifyOtp","title","common","submissionTitle","submissionFallback","retryLabel","cancelLabel","cancel","onRetry","code","API_ERROR","style","flex","children","subtitle","phoneHint","iconNode","undefined","backLabel","back","backDisabled","
|
|
1
|
+
{"version":3,"names":["useCallback","useState","Pressable","StyleSheet","Text","View","SdkErrorCode","Banner","Button","Input","LoadingOverlay","RetryDialog","StepShell","StepIcon","compose","required","useInlineValidation","getStrings","useTheme","isE164Phone","isOtpCode","toSubmissionError","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PhoneOtpStep","destroyed","constructor","deps","run","Promise","resolve","reject","resolveStep","rejectStep","ui","setNode","PhoneOtpView","api","sessionId","locale","onBack","onComplete","onCancel","err","destroy","t","theme","phone","setPhone","otp","setOtp","stage","setStage","bannerError","setBannerError","busy","setBusy","retry","setRetry","phoneValidation","name","validate","phone_otp","phoneRequired","v","phone_contact","invalid","_n","otpValidation","otpRequired","otpFormat","sendOtp","validateAll","post","trim","sdkErr","message","verifyOtp","phoneField","bind","otpField","title","common","submissionTitle","submissionFallback","retryLabel","cancelLabel","cancel","onRetry","code","API_ERROR","style","flex","children","subtitle","phoneHint","iconNode","undefined","backLabel","back","backDisabled","accessibilityLabel","phoneLabel","autoCapitalize","autoCorrect","autoComplete","textContentType","keyboardType","placeholder","editable","value","onChangeText","text","replace","label","sendCode","onPress","loading","disabled","otpLabel","maxLength","verify","accessibilityRole","styles","resend","resendText","color","primaryColor","sendingCode","verifying","create","paddingVertical","alignItems","fontSize","fontWeight","textDecorationLine"],"sourceRoot":"../../../src","sources":["steps/PhoneOtpStep.tsx"],"mappings":";;AAAA;AAC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;UACxBN,OAAO,EAAEA,CAAA,KAAM;YACblE,MAAM,CAAC,EAAE,CAAC;YACVE,QAAQ,CAAC,SAAS,CAAC;UACrB,CAAE;UACFuC,KAAK,EAAEgC,MAAM,CAACC,MAAO;UAAA/B,QAAA,eAErB1E,IAAA,CAACnB,IAAI;YAAC2F,KAAK,EAAE,CAACgC,MAAM,CAACE,UAAU,EAAE;cAAEC,KAAK,EAAEhF,KAAK,CAACiF;YAAa,CAAC,CAAE;YAAAlC,QAAA,EAC7DhD,CAAC,CAACiB,SAAS,CAAC8D;UAAM,CACf;QAAC,CACE,CAAC;MAAA,CACZ,CACH,EACAzE,KAAK,KAAK,SAAS,IAAIE,WAAW,gBACjClC,IAAA,CAAChB,MAAM;QAACyE,OAAO,EAAEvB;MAAY,CAAE,CAAC,GAC9B,IAAI;IAAA,CACC,CAAC,EACXE,IAAI,gBACHpC,IAAA,CAACb,cAAc;MACbsE,OAAO,EAAErB,IAAI,KAAK,SAAS,GAAGV,CAAC,CAACiB,SAAS,CAACkE,WAAW,GAAGnF,CAAC,CAACiB,SAAS,CAACmE;IAAU,CAC/E,CAAC,GACA,IAAI;EAAA,CACJ,CAAC;AAEX;AAEA,MAAMN,MAAM,GAAG5H,UAAU,CAACmI,MAAM,CAAC;EAC/BN,MAAM,EAAE;IACNO,eAAe,EAAE,CAAC;IAClBC,UAAU,EAAE;EACd,CAAC;EACDP,UAAU,EAAE;IACVQ,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,KAAK;IACjBC,kBAAkB,EAAE;EACtB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Geometry for the document capture guide + crop.
|
|
5
|
+
*
|
|
6
|
+
* Two pure helpers, shared between the camera overlay and the post-capture
|
|
7
|
+
* crop so the pixels we keep are *exactly* the rectangle the user framed:
|
|
8
|
+
*
|
|
9
|
+
* - `computeCutout` — the on-screen ID-1 guide rectangle (screen px).
|
|
10
|
+
* - `computeGuideCropRect` — maps that guide rectangle into the captured
|
|
11
|
+
* photo's pixel space, compensating for the camera preview's `cover` fit
|
|
12
|
+
* (the preview center-crops the sensor frame to the screen aspect ratio).
|
|
13
|
+
*
|
|
14
|
+
* This is a *geometric* crop to a fixed guide, NOT edge detection / OpenCV —
|
|
15
|
+
* we never inspect pixels. The backend's Document AI still runs OCR and its
|
|
16
|
+
* own face crop on top, so we keep a safety margin around the guide to avoid
|
|
17
|
+
* clipping the document (or the portrait the backend needs).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// ID-1 aspect ratios (width / height). Portrait ≈ 0.625 (held vertically),
|
|
21
|
+
// landscape ≈ 1.586 (the real ID-1 card ratio, 85.6 × 53.98 mm).
|
|
22
|
+
const PORTRAIT_ASPECT = 0.625;
|
|
23
|
+
const LANDSCAPE_ASPECT = 1.586;
|
|
24
|
+
|
|
25
|
+
// The guide is 85% of screen width, but never taller than 62% of screen height
|
|
26
|
+
// (portrait ID-1 on tall phones would otherwise overflow).
|
|
27
|
+
const CUTOUT_WIDTH_RATIO = 0.85;
|
|
28
|
+
const CUTOUT_MAX_HEIGHT_RATIO = 0.62;
|
|
29
|
+
|
|
30
|
+
/** Default crop margin: expand each side of the guide by this fraction of the
|
|
31
|
+
* guide size, so a document slightly overflowing the frame isn't clipped. */
|
|
32
|
+
export const DEFAULT_CROP_MARGIN = 0.07;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The on-screen guide rectangle, in screen pixels. Mirrors what the mask
|
|
36
|
+
* overlay draws so the crop matches the visible cutout exactly.
|
|
37
|
+
*/
|
|
38
|
+
export function computeCutout(screenW, screenH, orientation) {
|
|
39
|
+
const aspectRatio = orientation === 'portrait' ? PORTRAIT_ASPECT : LANDSCAPE_ASPECT;
|
|
40
|
+
let width = screenW * CUTOUT_WIDTH_RATIO;
|
|
41
|
+
let height = width / aspectRatio;
|
|
42
|
+
const maxH = screenH * CUTOUT_MAX_HEIGHT_RATIO;
|
|
43
|
+
if (height > maxH) {
|
|
44
|
+
height = maxH;
|
|
45
|
+
width = height * aspectRatio;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
left: (screenW - width) / 2,
|
|
49
|
+
top: (screenH - height) / 2,
|
|
50
|
+
width,
|
|
51
|
+
height
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Map the on-screen guide rectangle into the captured photo's pixel space.
|
|
57
|
+
*
|
|
58
|
+
* The preview renders the photo with `cover` fit: the sensor frame is scaled
|
|
59
|
+
* up until it fills the screen and the overflow is center-cropped. So a screen
|
|
60
|
+
* point `(sx, sy)` maps to photo pixel `((W_img - W_screen/s)/2 + sx/s, …)`,
|
|
61
|
+
* where `s = max(W_screen/W_img, H_screen/H_img)`.
|
|
62
|
+
*
|
|
63
|
+
* `imageW`/`imageH` MUST be the photo's *display* (orientation-normalized)
|
|
64
|
+
* dimensions — i.e. portrait when the device is portrait — not the raw sensor
|
|
65
|
+
* dimensions, which are often landscape with an EXIF rotation flag.
|
|
66
|
+
*
|
|
67
|
+
* The result is expanded by `margin` (fraction of the mapped guide) and
|
|
68
|
+
* clamped to the image bounds, then rounded to integers (the manipulator
|
|
69
|
+
* rejects fractional crop rects).
|
|
70
|
+
*/
|
|
71
|
+
export function computeGuideCropRect(params) {
|
|
72
|
+
const {
|
|
73
|
+
screenW,
|
|
74
|
+
screenH,
|
|
75
|
+
imageW,
|
|
76
|
+
imageH,
|
|
77
|
+
cutout,
|
|
78
|
+
margin = DEFAULT_CROP_MARGIN
|
|
79
|
+
} = params;
|
|
80
|
+
const scale = Math.max(screenW / imageW, screenH / imageH);
|
|
81
|
+
// Image pixels hidden off each edge by the cover crop.
|
|
82
|
+
const offsetX = (imageW - screenW / scale) / 2;
|
|
83
|
+
const offsetY = (imageH - screenH / scale) / 2;
|
|
84
|
+
let x = offsetX + cutout.left / scale;
|
|
85
|
+
let y = offsetY + cutout.top / scale;
|
|
86
|
+
let width = cutout.width / scale;
|
|
87
|
+
let height = cutout.height / scale;
|
|
88
|
+
|
|
89
|
+
// Expand by the safety margin.
|
|
90
|
+
const mx = width * margin;
|
|
91
|
+
const my = height * margin;
|
|
92
|
+
x -= mx;
|
|
93
|
+
y -= my;
|
|
94
|
+
width += mx * 2;
|
|
95
|
+
height += my * 2;
|
|
96
|
+
|
|
97
|
+
// Clamp to image bounds.
|
|
98
|
+
x = Math.max(0, x);
|
|
99
|
+
y = Math.max(0, y);
|
|
100
|
+
width = Math.min(width, imageW - x);
|
|
101
|
+
height = Math.min(height, imageH - y);
|
|
102
|
+
return {
|
|
103
|
+
x: Math.round(x),
|
|
104
|
+
y: Math.round(y),
|
|
105
|
+
width: Math.round(width),
|
|
106
|
+
height: Math.round(height)
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=documentCrop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PORTRAIT_ASPECT","LANDSCAPE_ASPECT","CUTOUT_WIDTH_RATIO","CUTOUT_MAX_HEIGHT_RATIO","DEFAULT_CROP_MARGIN","computeCutout","screenW","screenH","orientation","aspectRatio","width","height","maxH","left","top","computeGuideCropRect","params","imageW","imageH","cutout","margin","scale","Math","max","offsetX","offsetY","x","y","mx","my","min","round"],"sourceRoot":"../../../src","sources":["utils/documentCrop.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA,MAAMA,eAAe,GAAG,KAAK;AAC7B,MAAMC,gBAAgB,GAAG,KAAK;;AAE9B;AACA;AACA,MAAMC,kBAAkB,GAAG,IAAI;AAC/B,MAAMC,uBAAuB,GAAG,IAAI;;AAEpC;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAG,IAAI;;AAEvC;AACA;AACA;AACA;AACA,OAAO,SAASC,aA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AK,GAAGW,KAAK;EAChC,IAAIV,MAAM,GAAGQ,MAAM,CAACR,MAAM,GAAGU,KAAK;;EAElC;EACA,MAAMO,EAAE,GAAGlB,KAAK,GAAGU,MAAM;EACzB,MAAMS,EAAE,GAAGlB,MAAM,GAAGS,MAAM;EAC1BM,CAAC,IAAIE,EAAE;EACPD,CAAC,IAAIE,EAAE;EACPnB,KAAK,IAAIkB,EAAE,GAAG,CAAC;EACfjB,MAAM,IAAIkB,EAAE,GAAG,CAAC;;EAEhB;EACAH,CAAC,GAAGJ,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEG,CAAC,CAAC;EAClBC,CAAC,GAAGL,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEI,CAAC,CAAC;EAClBjB,KAAK,GAAGY,IAAI,CAACQ,GAAG,CAACpB,KAAK,EAAEO,MAAM,GAAGS,CAAC,CAAC;EACnCf,MAAM,GAAGW,IAAI,CAACQ,GAAG,CAACnB,MAAM,EAAEO,MAAM,GAAGS,CAAC,CAAC;EAErC,OAAO;IACLD,CAAC,EAAEJ,IAAI,CAACS,KAAK,CAACL,CAAC,CAAC;IAChBC,CAAC,EAAEL,IAAI,CAACS,KAAK,CAACJ,CAAC,CAAC;IAChBjB,KAAK,EAAEY,IAAI,CAACS,KAAK,CAACrB,KAAK,CAAC;IACxBC,MAAM,EAAEW,IAAI,CAACS,KAAK,CAACpB,MAAM;EAC3B,CAAC;AACH","ignoreList":[]}
|
|
@@ -5,15 +5,25 @@
|
|
|
5
5
|
* triggers `takePhoto()` with `qualityPrioritization: 'balanced'`; the file
|
|
6
6
|
* URI is returned to the caller via `onCaptured`.
|
|
7
7
|
*
|
|
8
|
-
* Visual: dark scrim with a transparent rectangular cutout (ID-1
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* Visual: dark scrim with a transparent rectangular cutout (ID-1 ratio). The
|
|
9
|
+
* cutout is both the visible guide AND the crop region: on capture we hand the
|
|
10
|
+
* caller the guide rectangle so the photo can be cropped to exactly what the
|
|
11
|
+
* user framed (OSDKR-2). This is a geometric crop to a fixed guide — NOT edge
|
|
12
|
+
* detection / OpenCV; we never inspect pixels. The backend's Document AI still
|
|
13
|
+
* runs OCR and its own face crop on top.
|
|
14
14
|
*/
|
|
15
15
|
import { type PhotoFile } from 'react-native-vision-camera';
|
|
16
16
|
import type { DocumentOrientation, DocumentSide } from '../types';
|
|
17
|
+
import { type CutoutRect } from '../utils/documentCrop';
|
|
18
|
+
/**
|
|
19
|
+
* Geometry of the on-screen guide at capture time, handed to `onCaptured` so
|
|
20
|
+
* the photo can be cropped to exactly what the user framed.
|
|
21
|
+
*/
|
|
22
|
+
export interface CaptureGuide {
|
|
23
|
+
cutout: CutoutRect;
|
|
24
|
+
screenW: number;
|
|
25
|
+
screenH: number;
|
|
26
|
+
}
|
|
17
27
|
export interface DocumentCaptureProps {
|
|
18
28
|
side: DocumentSide;
|
|
19
29
|
orientation: DocumentOrientation;
|
|
@@ -27,8 +37,10 @@ export interface DocumentCaptureProps {
|
|
|
27
37
|
retryLabel: string;
|
|
28
38
|
/** Localized "Cancel" / back label. */
|
|
29
39
|
cancelLabel: string;
|
|
30
|
-
|
|
40
|
+
/** Localized label shown over the camera while the shot is processed. */
|
|
41
|
+
processingLabel: string;
|
|
42
|
+
onCaptured: (photo: PhotoFile, side: DocumentSide, guide: CaptureGuide) => void | Promise<void>;
|
|
31
43
|
onCancel: () => void;
|
|
32
44
|
}
|
|
33
|
-
export declare function DocumentCapture({ side, orientation, instructions, captureLabel, permissionDeniedLabel, retryLabel, cancelLabel, onCaptured, onCancel, }: DocumentCaptureProps): import("react").JSX.Element;
|
|
45
|
+
export declare function DocumentCapture({ side, orientation, instructions, captureLabel, permissionDeniedLabel, retryLabel, cancelLabel, processingLabel, onCaptured, onCancel, }: DocumentCaptureProps): import("react").JSX.Element;
|
|
34
46
|
//# sourceMappingURL=DocumentCapture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentCapture.d.ts","sourceRoot":"","sources":["../../../src/camera/DocumentCapture.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"DocumentCapture.d.ts","sourceRoot":"","sources":["../../../src/camera/DocumentCapture.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIlE,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,mBAAmB,CAAC;IACjC,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,CACV,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,YAAY,KAChB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,eAAe,EACf,UAAU,EACV,QAAQ,GACT,EAAE,oBAAoB,+BAoPtB"}
|
|
@@ -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,YA6UhB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Ud,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,EAAE,CAAC"}
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
* intro → captureFront → reviewFront → captureBack → reviewBack →
|
|
6
6
|
* POST /documents-init → PUT image/jpeg × 2 → POST /documents-verify → done.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Crop: on capture we receive the on-screen guide rectangle and crop the photo
|
|
9
|
+
* to it (OSDKR-2) — a geometric crop to the visible ID-1 frame, NOT edge
|
|
10
|
+
* detection / OpenCV. This trims the camera background, improves OCR framing
|
|
11
|
+
* and shrinks the upload. The backend's Document AI still runs OCR + its own
|
|
12
|
+
* face crop on top, so we keep a safety margin around the guide.
|
|
11
13
|
*
|
|
12
|
-
* Compression: vision-camera writes a high-quality JPEG.
|
|
13
|
-
* `expo-image-manipulator` before upload so we keep
|
|
14
|
-
* 5 MB ceiling Velion's storage layer expects.
|
|
14
|
+
* Compression: vision-camera writes a high-quality JPEG. After cropping we
|
|
15
|
+
* resize + re-compress with `expo-image-manipulator` before upload so we keep
|
|
16
|
+
* the payload under the 5 MB ceiling Velion's storage layer expects.
|
|
15
17
|
*/
|
|
16
18
|
import type { StepDeps, StepModule } from './types';
|
|
17
19
|
export declare class DocumentsOcrStep implements StepModule {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentsOcrStep.d.ts","sourceRoot":"","sources":["../../../src/steps/DocumentsOcrStep.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"DocumentsOcrStep.d.ts","sourceRoot":"","sources":["../../../src/steps/DocumentsOcrStep.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAkCH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAsBpD,qBAAa,gBAAiB,YAAW,UAAU;IAKrC,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;IA0BpB,OAAO,IAAI,IAAI;CAIhB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Geometry for the document capture guide + crop.
|
|
3
|
+
*
|
|
4
|
+
* Two pure helpers, shared between the camera overlay and the post-capture
|
|
5
|
+
* crop so the pixels we keep are *exactly* the rectangle the user framed:
|
|
6
|
+
*
|
|
7
|
+
* - `computeCutout` — the on-screen ID-1 guide rectangle (screen px).
|
|
8
|
+
* - `computeGuideCropRect` — maps that guide rectangle into the captured
|
|
9
|
+
* photo's pixel space, compensating for the camera preview's `cover` fit
|
|
10
|
+
* (the preview center-crops the sensor frame to the screen aspect ratio).
|
|
11
|
+
*
|
|
12
|
+
* This is a *geometric* crop to a fixed guide, NOT edge detection / OpenCV —
|
|
13
|
+
* we never inspect pixels. The backend's Document AI still runs OCR and its
|
|
14
|
+
* own face crop on top, so we keep a safety margin around the guide to avoid
|
|
15
|
+
* clipping the document (or the portrait the backend needs).
|
|
16
|
+
*/
|
|
17
|
+
import type { DocumentOrientation } from '../types';
|
|
18
|
+
export interface CutoutRect {
|
|
19
|
+
left: number;
|
|
20
|
+
top: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
export interface PixelRect {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
}
|
|
30
|
+
/** Default crop margin: expand each side of the guide by this fraction of the
|
|
31
|
+
* guide size, so a document slightly overflowing the frame isn't clipped. */
|
|
32
|
+
export declare const DEFAULT_CROP_MARGIN = 0.07;
|
|
33
|
+
/**
|
|
34
|
+
* The on-screen guide rectangle, in screen pixels. Mirrors what the mask
|
|
35
|
+
* overlay draws so the crop matches the visible cutout exactly.
|
|
36
|
+
*/
|
|
37
|
+
export declare function computeCutout(screenW: number, screenH: number, orientation: DocumentOrientation): CutoutRect;
|
|
38
|
+
/**
|
|
39
|
+
* Map the on-screen guide rectangle into the captured photo's pixel space.
|
|
40
|
+
*
|
|
41
|
+
* The preview renders the photo with `cover` fit: the sensor frame is scaled
|
|
42
|
+
* up until it fills the screen and the overflow is center-cropped. So a screen
|
|
43
|
+
* point `(sx, sy)` maps to photo pixel `((W_img - W_screen/s)/2 + sx/s, …)`,
|
|
44
|
+
* where `s = max(W_screen/W_img, H_screen/H_img)`.
|
|
45
|
+
*
|
|
46
|
+
* `imageW`/`imageH` MUST be the photo's *display* (orientation-normalized)
|
|
47
|
+
* dimensions — i.e. portrait when the device is portrait — not the raw sensor
|
|
48
|
+
* dimensions, which are often landscape with an EXIF rotation flag.
|
|
49
|
+
*
|
|
50
|
+
* The result is expanded by `margin` (fraction of the mapped guide) and
|
|
51
|
+
* clamped to the image bounds, then rounded to integers (the manipulator
|
|
52
|
+
* rejects fractional crop rects).
|
|
53
|
+
*/
|
|
54
|
+
export declare function computeGuideCropRect(params: {
|
|
55
|
+
screenW: number;
|
|
56
|
+
screenH: number;
|
|
57
|
+
imageW: number;
|
|
58
|
+
imageH: number;
|
|
59
|
+
cutout: CutoutRect;
|
|
60
|
+
margin?: number;
|
|
61
|
+
}): PixelRect;
|
|
62
|
+
//# sourceMappingURL=documentCrop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentCrop.d.ts","sourceRoot":"","sources":["../../../src/utils/documentCrop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD;8EAC8E;AAC9E,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,mBAAmB,GAC/B,UAAU,CAiBZ;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,SAAS,CAwCZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velion-la/onboarding-sdk-react-native",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.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",
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* triggers `takePhoto()` with `qualityPrioritization: 'balanced'`; the file
|
|
6
6
|
* URI is returned to the caller via `onCaptured`.
|
|
7
7
|
*
|
|
8
|
-
* Visual: dark scrim with a transparent rectangular cutout (ID-1
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* Visual: dark scrim with a transparent rectangular cutout (ID-1 ratio). The
|
|
9
|
+
* cutout is both the visible guide AND the crop region: on capture we hand the
|
|
10
|
+
* caller the guide rectangle so the photo can be cropped to exactly what the
|
|
11
|
+
* user framed (OSDKR-2). This is a geometric crop to a fixed guide — NOT edge
|
|
12
|
+
* detection / OpenCV; we never inspect pixels. The backend's Document AI still
|
|
13
|
+
* runs OCR and its own face crop on top.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
@@ -33,6 +33,17 @@ import type { DocumentOrientation, DocumentSide } from '../types';
|
|
|
33
33
|
import { useTheme, withAlpha } from '../ui/theme';
|
|
34
34
|
import { Button } from '../ui/primitives/Button';
|
|
35
35
|
import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
|
|
36
|
+
import { computeCutout, type CutoutRect } from '../utils/documentCrop';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Geometry of the on-screen guide at capture time, handed to `onCaptured` so
|
|
40
|
+
* the photo can be cropped to exactly what the user framed.
|
|
41
|
+
*/
|
|
42
|
+
export interface CaptureGuide {
|
|
43
|
+
cutout: CutoutRect;
|
|
44
|
+
screenW: number;
|
|
45
|
+
screenH: number;
|
|
46
|
+
}
|
|
36
47
|
|
|
37
48
|
export interface DocumentCaptureProps {
|
|
38
49
|
side: DocumentSide;
|
|
@@ -47,7 +58,13 @@ export interface DocumentCaptureProps {
|
|
|
47
58
|
retryLabel: string;
|
|
48
59
|
/** Localized "Cancel" / back label. */
|
|
49
60
|
cancelLabel: string;
|
|
50
|
-
|
|
61
|
+
/** Localized label shown over the camera while the shot is processed. */
|
|
62
|
+
processingLabel: string;
|
|
63
|
+
onCaptured: (
|
|
64
|
+
photo: PhotoFile,
|
|
65
|
+
side: DocumentSide,
|
|
66
|
+
guide: CaptureGuide,
|
|
67
|
+
) => void | Promise<void>;
|
|
51
68
|
onCancel: () => void;
|
|
52
69
|
}
|
|
53
70
|
|
|
@@ -59,11 +76,13 @@ export function DocumentCapture({
|
|
|
59
76
|
permissionDeniedLabel,
|
|
60
77
|
retryLabel,
|
|
61
78
|
cancelLabel,
|
|
79
|
+
processingLabel,
|
|
62
80
|
onCaptured,
|
|
63
81
|
onCancel,
|
|
64
82
|
}: DocumentCaptureProps) {
|
|
65
83
|
const theme = useTheme();
|
|
66
84
|
const insets = useSafeAreaInsets();
|
|
85
|
+
const { width: screenW, height: screenH } = useWindowDimensions();
|
|
67
86
|
const cameraRef = useRef<Camera>(null);
|
|
68
87
|
// Cross-platform back-camera selection.
|
|
69
88
|
//
|
|
@@ -157,13 +176,19 @@ export function DocumentCapture({
|
|
|
157
176
|
flash: 'off',
|
|
158
177
|
enableShutterSound: false,
|
|
159
178
|
});
|
|
160
|
-
|
|
179
|
+
// Await the caller's crop/compress so the processing overlay stays up
|
|
180
|
+
// for the whole capture→preview gap (a few seconds), giving the user
|
|
181
|
+
// feedback instead of an idle camera. On success the parent flips phase
|
|
182
|
+
// and this component unmounts; on failure / "stay on capture" the finally
|
|
183
|
+
// re-enables the shutter.
|
|
184
|
+
const cutout = computeCutout(screenW, screenH, orientation);
|
|
185
|
+
await onCaptured(photo, side, { cutout, screenW, screenH });
|
|
161
186
|
} catch (err) {
|
|
162
187
|
setError(err instanceof Error ? err.message : String(err));
|
|
163
188
|
} finally {
|
|
164
189
|
setShooting(false);
|
|
165
190
|
}
|
|
166
|
-
}, [onCaptured, side, shooting]);
|
|
191
|
+
}, [onCaptured, side, shooting, orientation, screenW, screenH]);
|
|
167
192
|
|
|
168
193
|
if (!hasPermission) {
|
|
169
194
|
return (
|
|
@@ -227,6 +252,11 @@ export function DocumentCapture({
|
|
|
227
252
|
device={device}
|
|
228
253
|
photo
|
|
229
254
|
photoQualityBalance="quality"
|
|
255
|
+
// Explicit `cover`: the guide-crop math in `computeGuideCropRect`
|
|
256
|
+
// assumes the preview center-crops the sensor frame to the screen
|
|
257
|
+
// aspect ratio. `cover` is vision-camera's default, but we pin it so
|
|
258
|
+
// the crop never silently drifts if that default changes.
|
|
259
|
+
resizeMode="cover"
|
|
230
260
|
enableZoomGesture={false}
|
|
231
261
|
isActive
|
|
232
262
|
/>
|
|
@@ -285,6 +315,12 @@ export function DocumentCapture({
|
|
|
285
315
|
/>
|
|
286
316
|
</Pressable>
|
|
287
317
|
</View>
|
|
318
|
+
{shooting ? (
|
|
319
|
+
<View style={styles.processingOverlay}>
|
|
320
|
+
<ActivityIndicator color="#FFFFFF" size="large" />
|
|
321
|
+
<Text style={styles.processingText}>{processingLabel}</Text>
|
|
322
|
+
</View>
|
|
323
|
+
) : null}
|
|
288
324
|
</View>
|
|
289
325
|
);
|
|
290
326
|
}
|
|
@@ -295,8 +331,6 @@ interface MaskProps {
|
|
|
295
331
|
orientation: DocumentOrientation;
|
|
296
332
|
}
|
|
297
333
|
|
|
298
|
-
const CUTOUT_WIDTH_RATIO = 0.85; // 85% of screen width
|
|
299
|
-
const CUTOUT_MAX_HEIGHT_RATIO = 0.62; // never taller than 62% of screen height
|
|
300
334
|
const CORNER_LENGTH = 28;
|
|
301
335
|
const CORNER_THICKNESS = 3;
|
|
302
336
|
/**
|
|
@@ -309,20 +343,14 @@ const DIM_COLOR = 'rgba(0,0,0,0.55)';
|
|
|
309
343
|
|
|
310
344
|
function DocumentMaskOverlay({ orientation }: MaskProps) {
|
|
311
345
|
const { width: screenW, height: screenH } = useWindowDimensions();
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (cutoutH > maxH) {
|
|
321
|
-
cutoutH = maxH;
|
|
322
|
-
cutoutW = cutoutH * aspectRatio;
|
|
323
|
-
}
|
|
324
|
-
const left = (screenW - cutoutW) / 2;
|
|
325
|
-
const top = (screenH - cutoutH) / 2;
|
|
346
|
+
// Shared with the post-capture crop (`computeGuideCropRect`) so the dimmed
|
|
347
|
+
// cutout the user sees and the pixels we keep are the exact same rectangle.
|
|
348
|
+
const {
|
|
349
|
+
left,
|
|
350
|
+
top,
|
|
351
|
+
width: cutoutW,
|
|
352
|
+
height: cutoutH,
|
|
353
|
+
} = computeCutout(screenW, screenH, orientation);
|
|
326
354
|
const R = CUTOUT_RADIUS;
|
|
327
355
|
|
|
328
356
|
// SVG mask: opaque outer rect minus a rounded inner rect. The mask paints
|
|
@@ -511,4 +539,17 @@ const styles = StyleSheet.create({
|
|
|
511
539
|
borderColor: '#FFFFFF',
|
|
512
540
|
backgroundColor: 'transparent',
|
|
513
541
|
},
|
|
542
|
+
processingOverlay: {
|
|
543
|
+
...StyleSheet.absoluteFillObject,
|
|
544
|
+
alignItems: 'center',
|
|
545
|
+
justifyContent: 'center',
|
|
546
|
+
gap: 14,
|
|
547
|
+
backgroundColor: 'rgba(0,0,0,0.6)',
|
|
548
|
+
},
|
|
549
|
+
processingText: {
|
|
550
|
+
color: '#FFFFFF',
|
|
551
|
+
fontSize: 15,
|
|
552
|
+
fontWeight: '600',
|
|
553
|
+
textAlign: 'center',
|
|
554
|
+
},
|
|
514
555
|
});
|
package/src/i18n/strings/en.ts
CHANGED
|
@@ -216,6 +216,7 @@ export const EN: StringsTable = {
|
|
|
216
216
|
confirmBtn: 'Confirm',
|
|
217
217
|
confirmFront: 'Confirm front',
|
|
218
218
|
confirmBack: 'Confirm back',
|
|
219
|
+
processing: 'Processing image…',
|
|
219
220
|
initializing: 'Preparing capture…',
|
|
220
221
|
uploadingFront: 'Uploading front…',
|
|
221
222
|
uploadingBack: 'Uploading back…',
|
package/src/i18n/strings/es.ts
CHANGED
|
@@ -219,6 +219,7 @@ export const ES = {
|
|
|
219
219
|
confirmBtn: 'Confirmar',
|
|
220
220
|
confirmFront: 'Confirmar frente',
|
|
221
221
|
confirmBack: 'Confirmar dorso',
|
|
222
|
+
processing: 'Procesando imagen…',
|
|
222
223
|
initializing: 'Preparando captura…',
|
|
223
224
|
uploadingFront: 'Subiendo frente…',
|
|
224
225
|
uploadingBack: 'Subiendo dorso…',
|