datakeen-session-react 1.1.200 → 1.1.202-dev.1
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/README.md +11 -0
- package/dist/cjs/components/document-collection/DocumentCollection.js +2 -2
- package/dist/cjs/components/document-collection/DocumentError.js +4 -1
- package/dist/cjs/components/id-check/Photo.js +42 -36
- package/dist/cjs/components/jdi/JDIDocumentSelection.js +3 -0
- package/dist/cjs/components/jdi/JDIDocumentUpload.js +5 -2
- package/dist/cjs/components/jdi/JDIError.js +4 -1
- package/dist/cjs/components/nfc-scan/NfcScanNode.js +20 -2
- package/dist/cjs/components/session/DocumentCheck.js +23 -23
- package/dist/cjs/hooks/useNfcSseStatus.js +59 -24
- package/dist/cjs/i18n/en.json.js +11 -0
- package/dist/cjs/i18n/es.json.js +11 -0
- package/dist/cjs/i18n/fr.json.js +11 -0
- package/dist/cjs/index.css.js +1 -1
- package/dist/cjs/services/cameraService.js +44 -23
- package/dist/cjs/services/sessionCredentials.js +2 -1
- package/dist/cjs/services/sessionService.js +16 -6
- package/dist/cjs/utils/cameraResolution.js +12 -0
- package/dist/esm/components/document-collection/DocumentCollection.js +2 -2
- package/dist/esm/components/document-collection/DocumentError.js +4 -1
- package/dist/esm/components/id-check/Photo.js +42 -36
- package/dist/esm/components/jdi/JDIDocumentSelection.js +3 -0
- package/dist/esm/components/jdi/JDIDocumentUpload.js +5 -2
- package/dist/esm/components/jdi/JDIError.js +4 -1
- package/dist/esm/components/nfc-scan/NfcScanNode.js +20 -2
- package/dist/esm/components/session/DocumentCheck.js +23 -23
- package/dist/esm/hooks/useNfcSseStatus.js +59 -24
- package/dist/esm/i18n/en.json.js +11 -0
- package/dist/esm/i18n/es.json.js +11 -0
- package/dist/esm/i18n/fr.json.js +11 -0
- package/dist/esm/index.css.js +1 -1
- package/dist/esm/services/cameraService.js +44 -23
- package/dist/esm/services/sessionCredentials.js +2 -1
- package/dist/esm/services/sessionService.js +16 -7
- package/dist/esm/utils/cameraResolution.js +9 -0
- package/package.json +3 -2
|
@@ -7,27 +7,31 @@ import CameraError from './CameraError.js';
|
|
|
7
7
|
import CameraMask from './CameraMask.js';
|
|
8
8
|
import OrientationToggle from './OrientationToggle.js';
|
|
9
9
|
import { useI18n } from '../../hooks/useI18n.js';
|
|
10
|
+
import { isBelowHd } from '../../utils/cameraResolution.js';
|
|
11
|
+
import { reportCaptureDiagnostics } from '../../services/sessionService.js';
|
|
10
12
|
import useIsMobile from '../../hooks/useIsMobile.js';
|
|
11
13
|
|
|
12
14
|
var Photo = function (_a) {
|
|
13
|
-
var onCapture = _a.onCapture, _b = _a.automaticCapture, automaticCapture = _b === void 0 ? false : _b, _c = _a.maskType, maskType = _c === void 0 ? "id" : _c;
|
|
15
|
+
var onCapture = _a.onCapture, sessionId = _a.sessionId, nodeId = _a.nodeId, _b = _a.automaticCapture, automaticCapture = _b === void 0 ? false : _b, _c = _a.maskType, maskType = _c === void 0 ? "id" : _c;
|
|
14
16
|
var isMobile = useIsMobile(768);
|
|
15
17
|
var videoRef = useRef(null);
|
|
16
|
-
var _d = useState(false),
|
|
17
|
-
var _e = useState(
|
|
18
|
-
var _f = useState(
|
|
19
|
-
var _g = useState(
|
|
20
|
-
var _h = useState(
|
|
21
|
-
var _j = useState(
|
|
22
|
-
var _k = useState(false),
|
|
23
|
-
var _l = useState(
|
|
24
|
-
var _m = useState(
|
|
25
|
-
var _o = useState(
|
|
26
|
-
var _p = useState(
|
|
27
|
-
var _q = useState(false),
|
|
18
|
+
var _d = useState(false), lowResolution = _d[0], setLowResolution = _d[1];
|
|
19
|
+
var _e = useState(0), cameraAttempt = _e[0], setCameraAttempt = _e[1];
|
|
20
|
+
var _f = useState(false), isDetecting = _f[0], setIsDetecting = _f[1];
|
|
21
|
+
var _g = useState("environment"), facingMode = _g[0], setFacingMode = _g[1];
|
|
22
|
+
var _h = useState(null), cameraError = _h[0], setCameraError = _h[1];
|
|
23
|
+
var _j = useState(window.matchMedia("(orientation: portrait)").matches), isPortrait = _j[0], setIsPortrait = _j[1];
|
|
24
|
+
var _k = useState(false), isCountingDown = _k[0], setIsCountingDown = _k[1];
|
|
25
|
+
var _l = useState(0), countdown = _l[0], setCountdown = _l[1];
|
|
26
|
+
var _m = useState(false), documentDetected = _m[0], setDocumentDetected = _m[1];
|
|
27
|
+
var _o = useState(undefined), qualityHint = _o[0], setQualityHint = _o[1];
|
|
28
|
+
var _p = useState(true), isInitializing = _p[0], setIsInitializing = _p[1];
|
|
29
|
+
var _q = useState(false), isProcessing = _q[0], setIsProcessing = _q[1];
|
|
30
|
+
var _r = useState(null), captureError = _r[0], setCaptureError = _r[1];
|
|
31
|
+
var _s = useState(false), showCaptureFlash = _s[0], setShowCaptureFlash = _s[1];
|
|
28
32
|
var t = useI18n().t;
|
|
29
|
-
var
|
|
30
|
-
var
|
|
33
|
+
var _t = useState(null); _t[0]; var setLastCaptureMeta = _t[1];
|
|
34
|
+
var _u = useState(null), maskRect = _u[0], setMaskRect = _u[1];
|
|
31
35
|
var countdownIntervalRef = useRef(null);
|
|
32
36
|
var detectionHandlerRef = useRef(null);
|
|
33
37
|
var flashTimeoutRef = useRef(null);
|
|
@@ -216,11 +220,13 @@ var Photo = function (_a) {
|
|
|
216
220
|
useEffect(function () {
|
|
217
221
|
var isCancelled = false;
|
|
218
222
|
var initCamera = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
219
|
-
var result;
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
var result, belowHd;
|
|
224
|
+
var _a, _b, _c, _d;
|
|
225
|
+
return __generator(this, function (_e) {
|
|
226
|
+
switch (_e.label) {
|
|
222
227
|
case 0:
|
|
223
228
|
setCameraError(null);
|
|
229
|
+
setLowResolution(false);
|
|
224
230
|
setIsInitializing(true);
|
|
225
231
|
return [4 /*yield*/, cameraService.startCamera(videoRef.current, {
|
|
226
232
|
facingMode: facingMode,
|
|
@@ -228,11 +234,25 @@ var Photo = function (_a) {
|
|
|
228
234
|
preferImageCapture: true,
|
|
229
235
|
})];
|
|
230
236
|
case 1:
|
|
231
|
-
result =
|
|
237
|
+
result = _e.sent();
|
|
232
238
|
if (isCancelled)
|
|
233
239
|
return [2 /*return*/];
|
|
234
240
|
setIsInitializing(false);
|
|
235
241
|
if (result.success) {
|
|
242
|
+
belowHd = isBelowHd(result.settings);
|
|
243
|
+
setLowResolution(belowHd);
|
|
244
|
+
if (sessionId && nodeId) {
|
|
245
|
+
void reportCaptureDiagnostics(sessionId, nodeId, {
|
|
246
|
+
requested: result.requested,
|
|
247
|
+
obtained: { w: (_a = result.settings) === null || _a === void 0 ? void 0 : _a.width, h: (_b = result.settings) === null || _b === void 0 ? void 0 : _b.height, frameRate: (_c = result.settings) === null || _c === void 0 ? void 0 : _c.frameRate },
|
|
248
|
+
retriedWithHd: (_d = result.retriedWithHd) !== null && _d !== void 0 ? _d : false,
|
|
249
|
+
devicePixelRatio: window.devicePixelRatio,
|
|
250
|
+
cameraLabel: result.label,
|
|
251
|
+
lowResolutionWarningShown: belowHd,
|
|
252
|
+
facingMode: facingMode,
|
|
253
|
+
at: new Date().toISOString(),
|
|
254
|
+
}).catch(function () { });
|
|
255
|
+
}
|
|
236
256
|
setLastCaptureMeta(null);
|
|
237
257
|
// Detection also runs in manual mode: it only drives the visual
|
|
238
258
|
// feedback on the mask (documentDetected), it never starts the
|
|
@@ -260,7 +280,7 @@ var Photo = function (_a) {
|
|
|
260
280
|
flashTimeoutRef.current = null;
|
|
261
281
|
}
|
|
262
282
|
};
|
|
263
|
-
}, [facingMode, clearCountdown, stopDetection]);
|
|
283
|
+
}, [facingMode, cameraAttempt, sessionId, nodeId, clearCountdown, stopDetection]);
|
|
264
284
|
useEffect(function () {
|
|
265
285
|
if (!isDetecting || !videoRef.current) {
|
|
266
286
|
return;
|
|
@@ -303,21 +323,7 @@ var Photo = function (_a) {
|
|
|
303
323
|
setIsInitializing(true);
|
|
304
324
|
stopDetection();
|
|
305
325
|
cameraService.stopCamera();
|
|
306
|
-
|
|
307
|
-
.startCamera(videoRef.current, {
|
|
308
|
-
facingMode: facingMode,
|
|
309
|
-
idealResolution: { width: 4096, height: 3072 },
|
|
310
|
-
preferImageCapture: true,
|
|
311
|
-
})
|
|
312
|
-
.then(function (result) {
|
|
313
|
-
setIsInitializing(false);
|
|
314
|
-
if (result.success) {
|
|
315
|
-
setIsDetecting(true);
|
|
316
|
-
}
|
|
317
|
-
else if (result.error) {
|
|
318
|
-
setCameraError(result.error);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
326
|
+
setCameraAttempt(function (attempt) { return attempt + 1; });
|
|
321
327
|
};
|
|
322
328
|
var handleManualCapture = function () {
|
|
323
329
|
if (isProcessing) {
|
|
@@ -341,7 +347,7 @@ var Photo = function (_a) {
|
|
|
341
347
|
zIndex: isMobile ? 50 : "auto",
|
|
342
348
|
height: "100%",
|
|
343
349
|
width: "100%",
|
|
344
|
-
}, children: [jsx("div", { className: "flex-1 relative overflow-hidden bg-black", children: cameraError ? (jsx("div", { className: "flex items-center justify-center h-full px-4 py-6", children: jsx(CameraError, { errorMessage: cameraError, onRetry: handleRetry }) })) : (jsxs(Fragment, { children: [isInitializing && (jsxs("div", { "data-testid": "camera-initializing", className: "absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black", children: [jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsx("span", { className: "text-white text-sm", children: t("id_check.photo.initializing", "Ouverture de la caméra…") })] })), isProcessing && (jsxs("div", { "data-testid": "camera-processing", className: "absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black bg-opacity-70", children: [jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsx("span", { className: "text-white text-sm", children: t("id_check.photo.processing", "Traitement de l'image…") })] })), jsx("video", { ref: videoRef, autoPlay: true, playsInline: true, muted: true, className: "absolute inset-0 w-full h-full object-cover z-0 bg-black ".concat(facingMode === "user" ? "scale-x-[-1]" : "") }), jsx("div", { className: "absolute top-4 left-1/2 transform -translate-x-1/2 z-50", children: jsx("span", { className: "text-white z-50 text-sm font-semibold drop-shadow-lg", children: automaticCapture ? (jsx("span", { className: "animate-pulse", children: t("id_check.photo.mode_autocapture", "Autocapture activée") })) : (jsx("span", { className: "bg-orange-500 px-2 py-1 rounded hidden", children: t("id_check.photo.mode_manual", "Mode manuel") })) }) }), jsx(CameraMask, { isDetecting: isDetecting, isPortrait: isPortrait, facingMode: facingMode, isCountingDown: isCountingDown, countdown: countdown, maskType: maskType, documentDetected: documentDetected, qualityHint: qualityHint, onMaskRectChange: setMaskRect }), jsx("div", { className: "absolute bottom-20 left-0 right-0 z-20 pointer-events-none", children: jsx("div", { className: "text-center px-4", children: jsx("div", { className: "bg-black bg-opacity-60 text-white text-sm px-4 py-2 rounded-lg inline-block", children: t("id_check.photo.position_document", "Posez le document à plat ou tenez-le dans le cadre") }) }) }), jsx(OrientationToggle, { onCameraToggle: toggleCamera }), showCaptureFlash && (jsx("div", { "data-testid": "capture-flash", className: "absolute inset-0 z-40 bg-white pointer-events-none animate-pulse" }))] })) }), jsx("div", { className: "relative z-20 bg-black bg-opacity-80 p-4", children: jsxs("div", { className: "flex flex-col items-center space-y-4", children: [jsx("button", { onClick: handleManualCapture, className: "w-16 h-16 rounded-full border-4 border-white flex items-center justify-center transition-all duration-150 bg-transparent hover:bg-white hover:bg-opacity-20 cursor-pointer ".concat(showCaptureFlash ? "scale-90 ring-4 ring-[#11E5C5]" : ""), children: jsx("div", { className: "w-8 h-8 bg-white rounded-full" }) }), jsxs("div", { className: "text-white text-center text-sm", children: [jsxs("div", { className: "flex items-center justify-center space-x-2", children: [jsx("div", { className: "w-2 h-2 rounded-full ".concat(automaticCapture
|
|
350
|
+
}, children: [jsx("div", { className: "flex-1 relative overflow-hidden bg-black", children: cameraError ? (jsx("div", { className: "flex items-center justify-center h-full px-4 py-6", children: jsx(CameraError, { errorMessage: cameraError, onRetry: handleRetry }) })) : (jsxs(Fragment, { children: [isInitializing && (jsxs("div", { "data-testid": "camera-initializing", className: "absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black", children: [jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsx("span", { className: "text-white text-sm", children: t("id_check.photo.initializing", "Ouverture de la caméra…") })] })), isProcessing && (jsxs("div", { "data-testid": "camera-processing", className: "absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black bg-opacity-70", children: [jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsx("span", { className: "text-white text-sm", children: t("id_check.photo.processing", "Traitement de l'image…") })] })), jsx("video", { ref: videoRef, autoPlay: true, playsInline: true, muted: true, className: "absolute inset-0 w-full h-full object-cover z-0 bg-black ".concat(facingMode === "user" ? "scale-x-[-1]" : "") }), jsx("div", { className: "absolute top-4 left-1/2 transform -translate-x-1/2 z-50", children: jsx("span", { className: "text-white z-50 text-sm font-semibold drop-shadow-lg", children: automaticCapture ? (jsx("span", { className: "animate-pulse", children: t("id_check.photo.mode_autocapture", "Autocapture activée") })) : (jsx("span", { className: "bg-orange-500 px-2 py-1 rounded hidden", children: t("id_check.photo.mode_manual", "Mode manuel") })) }) }), jsx(CameraMask, { isDetecting: isDetecting, isPortrait: isPortrait, facingMode: facingMode, isCountingDown: isCountingDown, countdown: countdown, maskType: maskType, documentDetected: documentDetected, qualityHint: qualityHint, onMaskRectChange: setMaskRect }), jsx("div", { className: "absolute bottom-20 left-0 right-0 z-20 pointer-events-none", children: jsx("div", { className: "text-center px-4", children: jsx("div", { className: "bg-black bg-opacity-60 text-white text-sm px-4 py-2 rounded-lg inline-block", children: t("id_check.photo.position_document", "Posez le document à plat ou tenez-le dans le cadre") }) }) }), jsx(OrientationToggle, { onCameraToggle: toggleCamera }), lowResolution && !cameraError && (jsx("div", { role: "status", className: "absolute inset-x-3 z-30 ".concat(automaticCapture ? "top-12" : "top-3"), children: jsx("div", { className: "rounded-xl bg-black/75 text-white shadow-lg backdrop-blur-sm", children: jsxs("details", { className: "group", children: [jsxs("summary", { className: "flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium focus-visible:outline focus-visible:outline-2 focus-visible:outline-white [&::-webkit-details-marker]:hidden", children: [jsx("svg", { "aria-hidden": "true", className: "h-5 w-5 shrink-0 text-amber-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 9v4m0 4h.01M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z" }) }), jsx("span", { className: "min-w-0 flex-1", children: t("id_check.camera.low_resolution.title") }), jsx("svg", { "aria-hidden": "true", className: "h-4 w-4 shrink-0 transition-transform group-open:rotate-180 motion-reduce:transition-none", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m6 9 6 6 6-6" }) })] }), jsxs("div", { className: "space-y-2 px-3 pb-3 text-sm leading-relaxed text-white/85", children: [jsx("p", { children: t("id_check.camera.low_resolution.body") }), jsx("p", { children: t("id_check.camera.low_resolution.tips") }), jsx("button", { type: "button", onClick: handleRetry, disabled: isProcessing, className: "min-h-11 w-full rounded-lg bg-white px-4 font-medium text-gray-900 hover:bg-white/90 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white disabled:opacity-50", children: t("id_check.camera.low_resolution.retry") })] })] }) }) })), showCaptureFlash && (jsx("div", { "data-testid": "capture-flash", className: "absolute inset-0 z-40 bg-white pointer-events-none animate-pulse" }))] })) }), jsx("div", { className: "relative z-20 bg-black bg-opacity-80 p-4", children: jsxs("div", { className: "flex flex-col items-center space-y-4", children: [jsx("button", { onClick: handleManualCapture, className: "w-16 h-16 rounded-full border-4 border-white flex items-center justify-center transition-all duration-150 bg-transparent hover:bg-white hover:bg-opacity-20 cursor-pointer ".concat(showCaptureFlash ? "scale-90 ring-4 ring-[#11E5C5]" : ""), children: jsx("div", { className: "w-8 h-8 bg-white rounded-full" }) }), jsxs("div", { className: "text-white text-center text-sm", children: [jsxs("div", { className: "flex items-center justify-center space-x-2", children: [jsx("div", { className: "w-2 h-2 rounded-full ".concat(automaticCapture
|
|
345
351
|
? "bg-[#11E5C5] animate-pulse"
|
|
346
352
|
: "bg-orange-500") }), jsx("span", { children: statusMessage })] }), captureError && (jsx("p", { className: "text-red-400 text-xs mt-2 text-center", children: captureError }))] })] }) })] }));
|
|
347
353
|
};
|
|
@@ -135,6 +135,7 @@ var JDIDocumentSelection = function (_a) {
|
|
|
135
135
|
case "idCard":
|
|
136
136
|
return [
|
|
137
137
|
t("jdi.document_selection.instructions.idCard.recto_verso"),
|
|
138
|
+
t("jdi.document_selection.instructions.two_sided_files"),
|
|
138
139
|
t("jdi.document_selection.instructions.idCard.readable"),
|
|
139
140
|
t("jdi.document_selection.instructions.idCard.valid"),
|
|
140
141
|
];
|
|
@@ -147,6 +148,7 @@ var JDIDocumentSelection = function (_a) {
|
|
|
147
148
|
case "driverLicense":
|
|
148
149
|
return [
|
|
149
150
|
t("jdi.document_selection.instructions.driverLicense.recto_verso"),
|
|
151
|
+
t("jdi.document_selection.instructions.two_sided_files"),
|
|
150
152
|
t("jdi.document_selection.instructions.driverLicense.not_expired"),
|
|
151
153
|
t("jdi.document_selection.instructions.driverLicense.all_visible"),
|
|
152
154
|
];
|
|
@@ -159,6 +161,7 @@ var JDIDocumentSelection = function (_a) {
|
|
|
159
161
|
case "residencePermit":
|
|
160
162
|
return [
|
|
161
163
|
t("jdi.document_selection.instructions.residencePermit.recto_verso"),
|
|
164
|
+
t("jdi.document_selection.instructions.two_sided_files"),
|
|
162
165
|
t("jdi.document_selection.instructions.residencePermit.valid"),
|
|
163
166
|
t("jdi.document_selection.instructions.residencePermit.readable"),
|
|
164
167
|
];
|
|
@@ -11,8 +11,11 @@ import { requiresTwoSides } from '../../utils/documentLabels.js';
|
|
|
11
11
|
import MobilePageLayout from '../ui/MobilePageLayout.js';
|
|
12
12
|
|
|
13
13
|
var JDIDocumentUpload = function (_a) {
|
|
14
|
-
var documentType = _a.documentType, onUpload = _a.onUpload, onBack = _a.onBack, documentTypeId = _a.documentTypeId, documentLabel = _a.documentLabel, _b = _a.initialFront, initialFront = _b === void 0 ? null : _b, _c = _a.initialBack, initialBack = _c === void 0 ? null : _c; _a.sessionId;
|
|
14
|
+
var documentType = _a.documentType, onUpload = _a.onUpload, onBack = _a.onBack, documentTypeId = _a.documentTypeId, documentLabel = _a.documentLabel, _b = _a.initialFront, initialFront = _b === void 0 ? null : _b, _c = _a.initialBack, initialBack = _c === void 0 ? null : _c; _a.sessionId; var title = _a.title, description = _a.description;
|
|
15
15
|
var t = useI18n().t;
|
|
16
|
+
var documentName = t("documentTypes." + documentType);
|
|
17
|
+
var customTitle = title === null || title === void 0 ? void 0 : title.trim().replace(/\{\{\s*document\s*\}\}/g, function () { return documentName; });
|
|
18
|
+
var customDescription = description === null || description === void 0 ? void 0 : description.trim().replace(/\{\{\s*document\s*\}\}/g, function () { return documentName; });
|
|
16
19
|
// Helper functions for conditional text
|
|
17
20
|
var getDropZoneText = function () {
|
|
18
21
|
return t("jdi.document_upload.drop_zone", {
|
|
@@ -458,7 +461,7 @@ var JDIDocumentUpload = function (_a) {
|
|
|
458
461
|
}
|
|
459
462
|
});
|
|
460
463
|
}); };
|
|
461
|
-
return (jsx(MobilePageLayout, { contentClassName: "h-full", footer: jsx(PageActions, { primary: jsx(Button, { onClick: handleUpload, disabled: (!frontFile && !isFrontFromInitial) || isUploading, children: getValidateButtonText() }), secondary: onBack ? (jsx(Button, { variant: "secondary", onClick: onBack, disabled: isUploading, children: t("jdi.document_upload.back") })) : undefined }), children: jsx("div", { className: "flex-1 flex items-start justify-center md:items-center p-4", children: jsxs("div", { className: "w-full max-w-lg", children: [jsxs("div", { className: "text-center mb-8", children: [jsx("h1", { className: "text-2xl md:text-3xl font-bold text-gray-900 mb-2", children: getDropZoneText() }), jsx("p", { className: "text-gray-600", children: getUploadInstruction() })] }), jsx(Card, { ref: dropZoneRef, className: "border-2 border-dashed ".concat(isDragging
|
|
464
|
+
return (jsx(MobilePageLayout, { contentClassName: "h-full", footer: jsx(PageActions, { primary: jsx(Button, { onClick: handleUpload, disabled: (!frontFile && !isFrontFromInitial) || isUploading, children: getValidateButtonText() }), secondary: onBack ? (jsx(Button, { variant: "secondary", onClick: onBack, disabled: isUploading, children: t("jdi.document_upload.back") })) : undefined }), children: jsx("div", { className: "flex-1 flex items-start justify-center md:items-center p-4", children: jsxs("div", { className: "w-full max-w-lg", children: [jsxs("div", { className: "text-center mb-8", children: [jsx("h1", { className: "text-2xl md:text-3xl font-bold text-gray-900 mb-2", children: customTitle || getDropZoneText() }), jsx("p", { className: "text-gray-600 whitespace-pre-line", children: customDescription || getUploadInstruction() })] }), jsx(Card, { ref: dropZoneRef, className: "border-2 border-dashed ".concat(isDragging
|
|
462
465
|
? "border-teal-500 bg-teal-100/50"
|
|
463
466
|
: "border-teal-300 bg-teal-50/30", " p-8 mb-6 transition-colors"), onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, children: jsx("div", { className: "text-center space-y-6", children: !frontPreview ? (jsxs(Fragment, { children: [jsx("h3", { className: "text-lg font-semibold text-gray-900 mb-4", children: t("documentTypes." + documentType) }), jsx("div", { className: "flex justify-center w-full", children: jsx(Button, { onClick: function () { var _a; return (_a = frontInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, className: "border border-teal-300 text-teal-600 bg-transparent hover:bg-teal-50 px-4 py-2 rounded-lg font-medium text-sm mx-auto flex items-center", disabled: isUploading, children: jsx("span", { children: t("jdi.document_upload.add_file") }) }) }), jsx("p", { className: "text-sm text-gray-500 italic", children: t("jdi.document_upload.drag_drop_hint", "ou glissez-déposez vos fichiers ici") }), jsxs("div", { className: "text-sm text-gray-600 space-y-1", children: [jsx("p", { children: t("jdi.document_upload.accepted_formats") }), jsx("p", { children: twoSidesRequired
|
|
464
467
|
? frontPreview
|
|
@@ -14,6 +14,9 @@ var JDIError = function (_a) {
|
|
|
14
14
|
var _b;
|
|
15
15
|
_a.documentType; var onRetry = _a.onRetry, onContinueAnyway = _a.onContinueAnyway, onBackToUserInput = _a.onBackToUserInput, _c = _a.retryCount, retryCount = _c === void 0 ? 0 : _c, _d = _a.predictions, predictions = _d === void 0 ? DEFAULT_PREDICTIONS : _d, errorCode = _a.errorCode; _a.allowResubmission; var maxResubmissionAttempts = _a.maxResubmissionAttempts, _e = _a.isRetryAllowed, isRetryAllowed = _e === void 0 ? true : _e, _f = _a.blockContinue, blockContinue = _f === void 0 ? false : _f;
|
|
16
16
|
var t = useI18n().t;
|
|
17
|
+
// APP3-1955: a service refusal (no credits / quota) blocks the journey,
|
|
18
|
+
// whatever node.allowContinueOnFailure says.
|
|
19
|
+
var continueAnyway = isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
|
|
17
20
|
var _g = useState([]), validationPoints = _g[0], setValidationPoints = _g[1];
|
|
18
21
|
// Détail de mismatch d'identité (code 7.0), calculé côté backend et porté
|
|
19
22
|
// par la première prédiction. Absent pour tous les autres codes.
|
|
@@ -29,7 +32,7 @@ var JDIError = function (_a) {
|
|
|
29
32
|
var guidance = t("user_guidance.".concat(errorCode), "");
|
|
30
33
|
return guidance || null;
|
|
31
34
|
};
|
|
32
|
-
return (jsx(MobilePageLayout, { footer: jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsx(Button, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", className: "w-full text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.back_to_user_input") })), retryCount >= 1 && isRetryAllowed &&
|
|
35
|
+
return (jsx(MobilePageLayout, { footer: jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsx(Button, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", className: "w-full text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.back_to_user_input") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", className: "w-full text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.continue_anyway") })), isRetryAllowed && (jsx(Button, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })), !isRetryAllowed && continueAnyway && (jsx(Button, { onClick: continueAnyway, className: "w-full py-3", children: t("errors.continue_anyway") }))] })) }), jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", className: "text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.back_to_user_input") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", className: "text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.continue_anyway") })), isRetryAllowed && (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification") })), !isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway") }))] })) }) })] }), children: jsx("div", { className: "px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsx("div", { className: "text-center", children: jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxs("div", { className: "text-center space-y-4", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: blockContinue
|
|
33
36
|
? t("errors.upload_not_confirmed.title")
|
|
34
37
|
: t("errors.verification_failed") }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
|
|
35
38
|
? t("errors.upload_not_confirmed.subtitle")
|
|
@@ -20,6 +20,7 @@ import NfcSuccessAnimation from './NfcSuccessAnimation.js';
|
|
|
20
20
|
// choisir l'environnement (même rôle que `intent://<host>/scan/<id>` sur Android).
|
|
21
21
|
var IOS_APP_SCHEME = "datakeenscannerswift";
|
|
22
22
|
var IOS_APP_STORE_URL = "https://apps.apple.com/app/id6762505375";
|
|
23
|
+
var INSTALL_REVEAL_DELAY_MS = 2500;
|
|
23
24
|
var NfcScanStep = function (_a) {
|
|
24
25
|
var sessionId = _a.sessionId, nodeId = _a.nodeId, stepObject = _a.stepObject, template = _a.template, pageTitle = _a.pageTitle, pageDescription = _a.pageDescription, onBack = _a.onBack, onContinueWithoutChip = _a.onContinueWithoutChip;
|
|
25
26
|
var t = useI18n().t;
|
|
@@ -37,8 +38,11 @@ var NfcScanStep = function (_a) {
|
|
|
37
38
|
var apiBaseUrl = useMemo(function () { return getBaseURL(); }, []);
|
|
38
39
|
var iosAppLinks = useMemo(function () {
|
|
39
40
|
var host = new URL(apiBaseUrl, window.location.href).host;
|
|
41
|
+
// `return` : l'app rouvre exactement cette URL en fin de scan, ce qui ramène Safari sur cet
|
|
42
|
+
// onglet (et non un nouvel onglet) quand l'URL est identique.
|
|
43
|
+
var returnUrl = encodeURIComponent(window.location.href);
|
|
40
44
|
return {
|
|
41
|
-
open: "".concat(IOS_APP_SCHEME, "://").concat(host, "/scan/").concat(sessionId),
|
|
45
|
+
open: "".concat(IOS_APP_SCHEME, "://").concat(host, "/scan/").concat(sessionId, "?return=").concat(returnUrl),
|
|
42
46
|
// Lu par le bouton « Reprendre ma session » de l'app au premier lancement après installation.
|
|
43
47
|
resume: "https://".concat(host, "/scan/").concat(sessionId),
|
|
44
48
|
};
|
|
@@ -49,6 +53,20 @@ var NfcScanStep = function (_a) {
|
|
|
49
53
|
var _a;
|
|
50
54
|
(_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(iosAppLinks.resume).catch(function () { return undefined; });
|
|
51
55
|
};
|
|
56
|
+
// iOS ne permet pas de savoir si l'app est installée. Un seul bouton « Ouvrir » ; si la page est
|
|
57
|
+
// toujours visible après le délai (app absente : Safari affiche « adresse invalide »), on révèle
|
|
58
|
+
// « Installer ». Pas de redirection automatique vers l'App Store : pendant la confirmation iOS
|
|
59
|
+
// « Ouvrir dans ID Scan ? » la page reste visible, une redirection y enverrait à tort.
|
|
60
|
+
var _e = useState(false), showInstall = _e[0], setShowInstall = _e[1];
|
|
61
|
+
var installRevealTimerRef = useRef();
|
|
62
|
+
useEffect(function () { return function () { return clearTimeout(installRevealTimerRef.current); }; }, []);
|
|
63
|
+
var revealInstallIfAppDidNotOpen = function () {
|
|
64
|
+
clearTimeout(installRevealTimerRef.current);
|
|
65
|
+
installRevealTimerRef.current = setTimeout(function () {
|
|
66
|
+
if (document.visibilityState === "visible")
|
|
67
|
+
setShowInstall(true);
|
|
68
|
+
}, INSTALL_REVEAL_DELAY_MS);
|
|
69
|
+
};
|
|
52
70
|
var status = useNfcSseStatus({
|
|
53
71
|
sessionId: sessionId,
|
|
54
72
|
apiBaseUrl: apiBaseUrl,
|
|
@@ -160,7 +178,7 @@ var NfcScanStep = function (_a) {
|
|
|
160
178
|
return (jsx(MobilePageLayout, { footer: footer, children: jsx("div", { className: "px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxs("div", { className: "text-center space-y-4 mt-16 md:mt-20", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl", children: title }), jsx(Subtitle, { className: "text-sm md:text-base text-gray-600 leading-relaxed whitespace-pre-line", children: subtitle })] }), jsx("div", { className: "flex-1 flex flex-col justify-center items-center gap-4", children: status === "success" ? (jsx(NfcSuccessAnimation, {})) : status === "completed" ? (jsxs("div", { className: "flex flex-col items-center gap-4 p-8", children: [jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.verifying", "Vérification en cours…") })] })) : status === "failed" ? (jsxs("div", { className: "flex flex-col items-center gap-2 p-8 text-center", children: [jsx("p", { className: "text-base font-semibold text-red-600", children: t("nfc_scan.failed_title", "Le scan n'a pas pu être vérifié") }), jsx("p", { className: "text-sm text-gray-600 leading-relaxed", children: t("nfc_scan.failed_description", "Après plusieurs tentatives, la lecture de votre document n'a pas pu être validée.") }), resetError && (jsx("p", { className: "text-sm text-red-600", role: "alert", children: resetError }))] })) : (
|
|
161
179
|
// Contenu principal QR/mobile — reste monté pour "pending" ET "opened", pour ne
|
|
162
180
|
// jamais démonter le canvas déjà généré.
|
|
163
|
-
jsxs(Fragment, { children: [qrError ? (jsx("div", { className: "text-red-500 text-center p-4", children: qrError })) : isIOS ? (jsxs("div", { className: "flex w-full flex-col items-center gap-3 p-4 text-center", children: [jsx("a", { href: iosAppLinks.open, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] text-sm font-medium hover:brightness-110 active:brightness-90", style: { backgroundColor: "var(--dk-btn-bg)", color: "var(--dk-btn-text)" }, children: t("nfc_scan.open_app_link", "Ouvrir l'application") }), jsx("a", { href: IOS_APP_STORE_URL, onClick: copyResumeLink, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] border border-gray-300 text-sm font-medium text-gray-600 hover:bg-black/5", children: t("nfc_scan.install_app_link", "Installer l'application") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.install_app_hint", "Après l'installation, revenez sur cette page et appuyez sur « Ouvrir l'application ».") })] })) : isMobile ? (jsxs("div", { className: "flex flex-col items-center gap-4 p-8 text-center", children: [jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.opening_app", "Ouverture de l'application…") }), jsx("a", { href: nfcUrl, className: "text-sm font-medium text-blue-600 underline", children: t("nfc_scan.open_app_link", "Ouvrir l'application") })] })) : (jsx("div", { className: "bg-white p-4 rounded-lg shadow-lg border-2 border-gray-200", children: jsx("canvas", { ref: canvasRef }) })), status === "opened" && (jsxs("div", { className: "text-center space-y-1", children: [jsx("p", { className: "text-sm font-semibold", style: { color: "var(--uni-secondary-color, #0a9983)" }, children: t("nfc_scan.qr_opened_title", "QR code scanné") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.qr_opened_description", "L'expérience NFC est ouverte sur votre smartphone. Continuez le scan sur votre téléphone.") }), jsxs("div", { className: "flex items-center justify-center gap-2 text-xs text-gray-500 pt-1", children: [jsx("span", { className: "h-2 w-2 rounded-full animate-pulse", style: { backgroundColor: "var(--uni-primary-color, #11e5c5)" } }), t("nfc_scan.waiting_completion", "En attente de la lecture NFC")] })] }))] })) })] }) }) }));
|
|
181
|
+
jsxs(Fragment, { children: [qrError ? (jsx("div", { className: "text-red-500 text-center p-4", children: qrError })) : isIOS ? (jsxs("div", { className: "flex w-full flex-col items-center gap-3 p-4 text-center", children: [jsx("a", { href: iosAppLinks.open, onClick: revealInstallIfAppDidNotOpen, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] text-sm font-medium hover:brightness-110 active:brightness-90", style: { backgroundColor: "var(--dk-btn-bg)", color: "var(--dk-btn-text)" }, children: t("nfc_scan.open_app_link", "Ouvrir l'application") }), showInstall ? (jsxs(Fragment, { children: [jsx("a", { href: IOS_APP_STORE_URL, onClick: copyResumeLink, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] border border-gray-300 text-sm font-medium text-gray-600 hover:bg-black/5", children: t("nfc_scan.install_app_link", "Installer l'application") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.install_app_hint", "Après l'installation, revenez sur cette page et appuyez sur « Ouvrir l'application ».") })] })) : null] })) : isMobile ? (jsxs("div", { className: "flex flex-col items-center gap-4 p-8 text-center", children: [jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.opening_app", "Ouverture de l'application…") }), jsx("a", { href: nfcUrl, className: "text-sm font-medium text-blue-600 underline", children: t("nfc_scan.open_app_link", "Ouvrir l'application") })] })) : (jsx("div", { className: "bg-white p-4 rounded-lg shadow-lg border-2 border-gray-200", children: jsx("canvas", { ref: canvasRef }) })), status === "opened" && (jsxs("div", { className: "text-center space-y-1", children: [jsx("p", { className: "text-sm font-semibold", style: { color: "var(--uni-secondary-color, #0a9983)" }, children: t("nfc_scan.qr_opened_title", "QR code scanné") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.qr_opened_description", "L'expérience NFC est ouverte sur votre smartphone. Continuez le scan sur votre téléphone.") }), jsxs("div", { className: "flex items-center justify-center gap-2 text-xs text-gray-500 pt-1", children: [jsx("span", { className: "h-2 w-2 rounded-full animate-pulse", style: { backgroundColor: "var(--uni-primary-color, #11e5c5)" } }), t("nfc_scan.waiting_completion", "En attente de la lecture NFC")] })] }))] })) })] }) }) }));
|
|
164
182
|
};
|
|
165
183
|
|
|
166
184
|
export { NfcScanStep as default };
|
|
@@ -71,12 +71,12 @@ var normalizeNfcMode = function (mode) {
|
|
|
71
71
|
* - Uses hooks for translation, retry navigation, and context management.
|
|
72
72
|
*/
|
|
73
73
|
var DocumentCheck = function (_a) {
|
|
74
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
75
|
-
var stepObject = _a.stepObject, sessionId = _a.sessionId, node = _a.node, documentTypeId = _a.documentTypeId, acceptedCountries = _a.acceptedCountries,
|
|
74
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
75
|
+
var stepObject = _a.stepObject, sessionId = _a.sessionId, node = _a.node, documentTypeId = _a.documentTypeId, acceptedCountries = _a.acceptedCountries, _r = _a.isMobileCapture, isMobileCapture = _r === void 0 ? false : _r, allowedAddingMethods = _a.allowedAddingMethods, template = _a.template, setUserInput = _a.setUserInput;
|
|
76
76
|
var t = useI18n().t;
|
|
77
77
|
var session = getSession().session;
|
|
78
|
-
var
|
|
79
|
-
var
|
|
78
|
+
var _s = useState(), documentTemplates = _s[0], setDocumentTemplates = _s[1];
|
|
79
|
+
var _t = useState(true), loadingTemplates = _t[0], setLoadingTemplates = _t[1];
|
|
80
80
|
useEffect(function () {
|
|
81
81
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
82
|
var templates;
|
|
@@ -95,7 +95,7 @@ var DocumentCheck = function (_a) {
|
|
|
95
95
|
}); })();
|
|
96
96
|
}, []);
|
|
97
97
|
var initialRetryCount = getNodeRetryCount(session, node.id);
|
|
98
|
-
var
|
|
98
|
+
var _u = useState(null), selectedMethod = _u[0], setSelectedMethod = _u[1];
|
|
99
99
|
var isPictureAllowed = (_b = allowedAddingMethods === null || allowedAddingMethods === void 0 ? void 0 : allowedAddingMethods.includes("picture")) !== null && _b !== void 0 ? _b : true;
|
|
100
100
|
var isDownloadAllowed = (_c = allowedAddingMethods === null || allowedAddingMethods === void 0 ? void 0 : allowedAddingMethods.includes("download")) !== null && _c !== void 0 ? _c : true;
|
|
101
101
|
// Check if retry is allowed based on initial retry count
|
|
@@ -114,25 +114,25 @@ var DocumentCheck = function (_a) {
|
|
|
114
114
|
return true;
|
|
115
115
|
};
|
|
116
116
|
// Initialize docStep - if retries exhausted, start at error page (step 6)
|
|
117
|
-
var
|
|
117
|
+
var _v = useState(function () {
|
|
118
118
|
if (initialRetryCount > 0 && !isInitialRetryAllowed()) {
|
|
119
119
|
return 6; // Error page
|
|
120
120
|
}
|
|
121
121
|
return 0; // Normal flow - start with introduction
|
|
122
|
-
}), docStep =
|
|
123
|
-
var
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
127
|
-
var
|
|
128
|
-
var
|
|
122
|
+
}), docStep = _v[0], setDocStep = _v[1];
|
|
123
|
+
var _w = useState(((_e = (_d = acceptedCountries === null || acceptedCountries === void 0 ? void 0 : acceptedCountries[0]) === null || _d === void 0 ? void 0 : _d.code) === null || _e === void 0 ? void 0 : _e.toUpperCase()) || "FR"), selectedCountry = _w[0], setSelectedCountry = _w[1];
|
|
124
|
+
var _x = useState(null), fileUploaded = _x[0], setFileUploaded = _x[1];
|
|
125
|
+
var _y = useState(null), analysisData = _y[0], setAnalysisData = _y[1];
|
|
126
|
+
var _z = useState(null), errorCode = _z[0], setErrorCode = _z[1];
|
|
127
|
+
var _0 = useState(false), blockContinue = _0[0], setBlockContinue = _0[1];
|
|
128
|
+
var _1 = useState(null), nfcPreparationError = _1[0], setNfcPreparationError = _1[1];
|
|
129
129
|
// Quand l'utilisateur déclare ne pas avoir de puce (questionnaire de fallback),
|
|
130
130
|
// on ne doit plus le réorienter vers le scan NFC (ni avant, ni après l'analyse API).
|
|
131
|
-
var
|
|
131
|
+
var _2 = useState(false), nfcSkipped = _2[0], setNfcSkipped = _2[1];
|
|
132
132
|
// Initialize retry count from session data
|
|
133
|
-
var
|
|
133
|
+
var _3 = useState(function () {
|
|
134
134
|
return getNodeRetryCount(session, node.id);
|
|
135
|
-
}), retryCount =
|
|
135
|
+
}), retryCount = _3[0], setRetryCount = _3[1];
|
|
136
136
|
// Update retry count when session loads/changes
|
|
137
137
|
useEffect(function () {
|
|
138
138
|
if (session) {
|
|
@@ -227,10 +227,10 @@ var DocumentCheck = function (_a) {
|
|
|
227
227
|
setDocStep(6);
|
|
228
228
|
}
|
|
229
229
|
}, [retryCount, node.allowResubmission, node.maxResubmissionAttempts]);
|
|
230
|
-
var
|
|
231
|
-
var
|
|
232
|
-
var
|
|
233
|
-
var
|
|
230
|
+
var _4 = useState({}), capturedImages = _4[0], setCapturedImages = _4[1];
|
|
231
|
+
var _5 = useState("before-recto"), currentPhotoStep = _5[0], setCurrentPhotoStep = _5[1];
|
|
232
|
+
var _6 = useState("photo"), videoFlowPhase = _6[0], setVideoFlowPhase = _6[1];
|
|
233
|
+
var _7 = useDocumentContext(), selectedDocumentType = _7.selectedDocumentType, setSelectedDocumentType = _7.setSelectedDocumentType;
|
|
234
234
|
var finalAcceptedCountries = useMemo(function () {
|
|
235
235
|
if (loadingTemplates)
|
|
236
236
|
return acceptedCountries;
|
|
@@ -760,13 +760,13 @@ var DocumentCheck = function (_a) {
|
|
|
760
760
|
return (jsx(BeforePhoto, { setStep: function () { return setCurrentPhotoStep("recto"); }, isSingleSided: isSingleSided, onBack: function () { return setDocStep(2); } }));
|
|
761
761
|
}
|
|
762
762
|
if (currentPhotoStep === "recto") {
|
|
763
|
-
return (jsx(Photo, { onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
|
|
763
|
+
return (jsx(Photo, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
|
|
764
764
|
}
|
|
765
765
|
if (currentPhotoStep === "before-verso") {
|
|
766
766
|
return (jsx(BeforeVersoPhoto, { setStep: function () { return setCurrentPhotoStep("verso"); } }));
|
|
767
767
|
}
|
|
768
768
|
if (currentPhotoStep === "verso") {
|
|
769
|
-
return (jsx(Photo, { onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
|
|
769
|
+
return (jsx(Photo, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
|
|
770
770
|
}
|
|
771
771
|
if (currentPhotoStep === "confirmation") {
|
|
772
772
|
return (jsx(PhotoConfirmation, { imageUrl: capturedImages.recto || "", versoImageUrl: capturedImages.verso, requiresTwoSides: !!capturedImages.verso, onConfirm: onConfirm, onRetry: function () { return setCurrentPhotoStep("before-recto"); }, onRetryAfterProcessing: function () { return setCurrentPhotoStep("before-recto"); }, fileUploaded: fileUploaded, isSingleSided: isSingleSided }));
|
|
@@ -774,7 +774,7 @@ var DocumentCheck = function (_a) {
|
|
|
774
774
|
return (jsx(BeforePhoto, { setStep: function () { return setCurrentPhotoStep("recto"); }, isSingleSided: isSingleSided, onBack: function () { return setDocStep(2); } }));
|
|
775
775
|
}
|
|
776
776
|
else {
|
|
777
|
-
return (jsx(JDIDocumentUpload, { documentType: (selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id) || documentTypeId, documentTypeId: documentTypeId, documentLabel: selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.label, onUpload: handleDocumentUpload, onBack: function () {
|
|
777
|
+
return (jsx(JDIDocumentUpload, { title: (_p = node.documentUpload) === null || _p === void 0 ? void 0 : _p.title, description: (_q = node.documentUpload) === null || _q === void 0 ? void 0 : _q.description, documentType: (selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id) || documentTypeId, documentTypeId: documentTypeId, documentLabel: selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.label, onUpload: handleDocumentUpload, onBack: function () {
|
|
778
778
|
if (isPictureAllowed && isDownloadAllowed) {
|
|
779
779
|
setSelectedMethod(null);
|
|
780
780
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useRef, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
var SUCCESS_DISPLAY_DURATION_MS = 2500;
|
|
4
|
+
var RECONNECT_DELAY_MS = 2000;
|
|
4
5
|
function useNfcSseStatus(_a) {
|
|
5
6
|
var sessionId = _a.sessionId, apiBaseUrl = _a.apiBaseUrl, onCompleted = _a.onCompleted;
|
|
6
7
|
var _b = useState("pending"), status = _b[0], setStatus = _b[1];
|
|
@@ -10,42 +11,76 @@ function useNfcSseStatus(_a) {
|
|
|
10
11
|
if (!sessionId || !apiBaseUrl)
|
|
11
12
|
return;
|
|
12
13
|
var url = "".concat(apiBaseUrl, "/session/sdk/").concat(sessionId, "/nfc-status");
|
|
13
|
-
var source =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
var source = null;
|
|
15
|
+
// Statut terminal reçu : plus aucune (re)connexion, et `onCompleted` n'est appelé qu'une fois.
|
|
16
|
+
var finished = false;
|
|
17
|
+
var reconnectTimer;
|
|
18
|
+
var open = function () {
|
|
19
|
+
clearTimeout(reconnectTimer);
|
|
20
|
+
source === null || source === void 0 ? void 0 : source.close();
|
|
21
|
+
var current = new EventSource(url);
|
|
22
|
+
source = current;
|
|
23
|
+
current.onmessage = function (event) {
|
|
24
|
+
if (finished)
|
|
25
|
+
return;
|
|
26
|
+
try {
|
|
27
|
+
var data = JSON.parse(event.data);
|
|
28
|
+
if (data.status === "completed") {
|
|
29
|
+
finished = true;
|
|
30
|
+
current.close();
|
|
31
|
+
setStatus("success");
|
|
32
|
+
setTimeout(function () {
|
|
33
|
+
setStatus("completed");
|
|
34
|
+
onCompletedRef.current();
|
|
35
|
+
}, SUCCESS_DISPLAY_DURATION_MS);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// `failed` est terminal : le serveur ferme le flux, inutile de le rouvrir en boucle.
|
|
39
|
+
if (data.status === "failed")
|
|
40
|
+
finished = true;
|
|
41
|
+
setStatus(data.status);
|
|
42
|
+
}
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
catch (_a) {
|
|
45
|
+
// message malformé, on ignore
|
|
27
46
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
};
|
|
48
|
+
// EventSource se reconnecte seul tant qu'il est CONNECTING. Mais iOS coupe le flux quand
|
|
49
|
+
// Safari passe en arrière-plan pendant le scan dans l'app, et une réponse non-200 à la
|
|
50
|
+
// reconnexion le ferme définitivement (CLOSED) : on le rouvre alors nous-mêmes.
|
|
51
|
+
current.onerror = function () {
|
|
52
|
+
if (!finished && current.readyState === EventSource.CLOSED) {
|
|
53
|
+
reconnectTimer = setTimeout(open, RECONNECT_DELAY_MS);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
32
56
|
};
|
|
33
|
-
|
|
34
|
-
|
|
57
|
+
// Retour sur la page (depuis l'app de scan, ou restauration bfcache) : le flux a pu mourir
|
|
58
|
+
// pendant la suspension et l'event `completed` être perdu. On rouvre : le serveur renvoie le
|
|
59
|
+
// statut courant dès la connexion, donc le parcours avance sans recharger la page.
|
|
60
|
+
var reopenIfVisible = function () {
|
|
61
|
+
if (!finished && document.visibilityState === "visible")
|
|
62
|
+
open();
|
|
35
63
|
};
|
|
36
64
|
// Fermer le flux uniquement quand la page se ferme réellement, sinon le SSE reste ouvert côté
|
|
37
65
|
// serveur (heartbeat + listener qui fuient). `pagehide` couvre la fermeture d'onglet/navigation
|
|
38
66
|
// (plus fiable que `beforeunload` sur mobile).
|
|
39
67
|
//
|
|
40
68
|
// NE PAS fermer sur `visibilitychange`/`hidden` : le passage en arrière-plan est le geste
|
|
41
|
-
// NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR.
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
// NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR. On se contente de
|
|
70
|
+
// ROUVRIR au retour (`visible`), ce qui ne coupe jamais un flux encore utile.
|
|
71
|
+
var closeSource = function () {
|
|
72
|
+
clearTimeout(reconnectTimer);
|
|
73
|
+
source === null || source === void 0 ? void 0 : source.close();
|
|
74
|
+
};
|
|
75
|
+
open();
|
|
45
76
|
window.addEventListener("pagehide", closeSource);
|
|
77
|
+
window.addEventListener("pageshow", reopenIfVisible);
|
|
78
|
+
document.addEventListener("visibilitychange", reopenIfVisible);
|
|
46
79
|
return function () {
|
|
47
80
|
window.removeEventListener("pagehide", closeSource);
|
|
48
|
-
|
|
81
|
+
window.removeEventListener("pageshow", reopenIfVisible);
|
|
82
|
+
document.removeEventListener("visibilitychange", reopenIfVisible);
|
|
83
|
+
closeSource();
|
|
49
84
|
};
|
|
50
85
|
}, [sessionId, apiBaseUrl]);
|
|
51
86
|
return { status: status };
|
package/dist/esm/i18n/en.json.js
CHANGED
|
@@ -498,6 +498,7 @@ var jdi = {
|
|
|
498
498
|
error_select_document: "Please select a document type",
|
|
499
499
|
info_title: "Important information",
|
|
500
500
|
instructions: {
|
|
501
|
+
two_sided_files: "• Ensure both sides of the document (front and back) are included, either in a single file or in two separate files.",
|
|
501
502
|
jdd: {
|
|
502
503
|
recent: "• The document must be recent (less than 3 months old).",
|
|
503
504
|
name_address_visible: "• Your name and address must be clearly visible.",
|
|
@@ -780,11 +781,21 @@ var id_check = {
|
|
|
780
781
|
alt_verso: "Before taking the verso photo"
|
|
781
782
|
},
|
|
782
783
|
camera: {
|
|
784
|
+
low_resolution: {
|
|
785
|
+
title: "Limited camera resolution",
|
|
786
|
+
body: "Your camera resolution is below HD. The photo may be blurry, but you can continue.",
|
|
787
|
+
tips: "Close other apps using the camera, choose another camera or switch to mobile, and improve the lighting.",
|
|
788
|
+
retry: "Try again"
|
|
789
|
+
},
|
|
783
790
|
error_title: "Camera error",
|
|
784
791
|
retry: "Retry",
|
|
785
792
|
document_detected: "Document detected"
|
|
786
793
|
},
|
|
787
794
|
photo: {
|
|
795
|
+
hint: {
|
|
796
|
+
too_dark: "Too dark, find more light",
|
|
797
|
+
too_bright: "Too much glare, avoid direct light"
|
|
798
|
+
},
|
|
788
799
|
capture_failed: "Capture failed. Please try again.",
|
|
789
800
|
mode_autocapture: "Autocapture enabled",
|
|
790
801
|
mode_manual: "Manual mode",
|
package/dist/esm/i18n/es.json.js
CHANGED
|
@@ -498,6 +498,7 @@ var jdi = {
|
|
|
498
498
|
error_select_document: "Selecciona un tipo de documento",
|
|
499
499
|
info_title: "Información importante",
|
|
500
500
|
instructions: {
|
|
501
|
+
two_sided_files: "• Asegúrese de que ambas caras del documento (anverso y reverso) estén presentes, en un mismo archivo o en dos archivos distintos.",
|
|
501
502
|
jdd: {
|
|
502
503
|
recent: "• El documento debe ser reciente (menos de 3 meses).",
|
|
503
504
|
name_address_visible: "• Tu nombre y dirección deben verse claramente.",
|
|
@@ -780,11 +781,21 @@ var id_check = {
|
|
|
780
781
|
alt_verso: "Antes de tomar la foto del reverso"
|
|
781
782
|
},
|
|
782
783
|
camera: {
|
|
784
|
+
low_resolution: {
|
|
785
|
+
title: "Resolución de cámara limitada",
|
|
786
|
+
body: "La resolución de la cámara es inferior a HD. La foto puede salir borrosa, pero puede continuar.",
|
|
787
|
+
tips: "Cierre otras aplicaciones que usen la cámara, elija otra cámara o pase al móvil y mejore la iluminación.",
|
|
788
|
+
retry: "Reintentar"
|
|
789
|
+
},
|
|
783
790
|
error_title: "Error de cámara",
|
|
784
791
|
retry: "Reintentar",
|
|
785
792
|
document_detected: "Documento detectado"
|
|
786
793
|
},
|
|
787
794
|
photo: {
|
|
795
|
+
hint: {
|
|
796
|
+
too_dark: "Demasiado oscuro, busque más luz",
|
|
797
|
+
too_bright: "Demasiados reflejos, evite la luz directa"
|
|
798
|
+
},
|
|
788
799
|
capture_failed: "La captura ha fallado. Inténtalo de nuevo.",
|
|
789
800
|
mode_autocapture: "Captura automática activada",
|
|
790
801
|
mode_manual: "Modo manual",
|
package/dist/esm/i18n/fr.json.js
CHANGED
|
@@ -498,6 +498,7 @@ var jdi = {
|
|
|
498
498
|
error_select_document: "Veuillez sélectionner un type de document",
|
|
499
499
|
info_title: "Information importante",
|
|
500
500
|
instructions: {
|
|
501
|
+
two_sided_files: "• Assurez-vous que les deux faces du document (recto et verso) sont présentes, dans un même fichier ou dans deux fichiers distincts.",
|
|
501
502
|
jdd: {
|
|
502
503
|
recent: "• Le document doit être récent (moins de 3 mois).",
|
|
503
504
|
name_address_visible: "• Votre nom et adresse doivent être clairement visibles.",
|
|
@@ -780,11 +781,21 @@ var id_check = {
|
|
|
780
781
|
alt_verso: "Avant de prendre la photo du verso"
|
|
781
782
|
},
|
|
782
783
|
camera: {
|
|
784
|
+
low_resolution: {
|
|
785
|
+
title: "Résolution de la caméra limitée",
|
|
786
|
+
body: "La résolution de votre caméra est inférieure à la HD. La photo risque d’être floue, mais vous pouvez continuer.",
|
|
787
|
+
tips: "Fermez les autres applications utilisant la caméra, choisissez une autre caméra ou passez sur mobile, et améliorez l’éclairage.",
|
|
788
|
+
retry: "Réessayer"
|
|
789
|
+
},
|
|
783
790
|
error_title: "Erreur de caméra",
|
|
784
791
|
retry: "Réessayer",
|
|
785
792
|
document_detected: "Document détecté"
|
|
786
793
|
},
|
|
787
794
|
photo: {
|
|
795
|
+
hint: {
|
|
796
|
+
too_dark: "Trop sombre, cherchez plus de lumière",
|
|
797
|
+
too_bright: "Trop de reflets, évitez la lumière directe"
|
|
798
|
+
},
|
|
788
799
|
capture_failed: "La capture a échoué. Veuillez réessayer.",
|
|
789
800
|
mode_autocapture: "Autocapture activée",
|
|
790
801
|
mode_manual: "Mode manuel",
|