datakeen-session-react 1.1.202-dev.7 → 1.1.202-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/cjs/components/document-collection/DocumentCollection.js +2 -2
  2. package/dist/cjs/components/document-collection/DocumentProcessing.js +1 -3
  3. package/dist/cjs/components/id-check/Photo.js +36 -42
  4. package/dist/cjs/components/jdi/JDIDocumentSelection.js +0 -3
  5. package/dist/cjs/components/jdi/JDIDocumentUpload.js +2 -5
  6. package/dist/cjs/components/jdi/JDIProcessing.js +1 -6
  7. package/dist/cjs/components/session/DocumentCheck.js +23 -23
  8. package/dist/cjs/components/signature-electronic/SignatureElectronic.js +30 -13
  9. package/dist/cjs/i18n/en.json.js +0 -11
  10. package/dist/cjs/i18n/es.json.js +0 -11
  11. package/dist/cjs/i18n/fr.json.js +0 -11
  12. package/dist/cjs/index.css.js +1 -1
  13. package/dist/cjs/services/analysis.js +0 -7
  14. package/dist/cjs/services/cameraService.js +23 -44
  15. package/dist/cjs/services/pollingService.js +1 -4
  16. package/dist/cjs/services/sessionService.js +6 -16
  17. package/dist/cjs/utils/analysisErrors.js +0 -11
  18. package/dist/cjs/utils/sessionStatus.js +2 -3
  19. package/dist/esm/components/document-collection/DocumentCollection.js +2 -2
  20. package/dist/esm/components/document-collection/DocumentProcessing.js +2 -4
  21. package/dist/esm/components/id-check/Photo.js +36 -42
  22. package/dist/esm/components/jdi/JDIDocumentSelection.js +0 -3
  23. package/dist/esm/components/jdi/JDIDocumentUpload.js +2 -5
  24. package/dist/esm/components/jdi/JDIProcessing.js +2 -7
  25. package/dist/esm/components/session/DocumentCheck.js +23 -23
  26. package/dist/esm/components/signature-electronic/SignatureElectronic.js +30 -13
  27. package/dist/esm/i18n/en.json.js +0 -11
  28. package/dist/esm/i18n/es.json.js +0 -11
  29. package/dist/esm/i18n/fr.json.js +0 -11
  30. package/dist/esm/index.css.js +1 -1
  31. package/dist/esm/services/analysis.js +0 -7
  32. package/dist/esm/services/cameraService.js +23 -44
  33. package/dist/esm/services/pollingService.js +1 -4
  34. package/dist/esm/services/sessionService.js +7 -16
  35. package/dist/esm/utils/analysisErrors.js +1 -10
  36. package/dist/esm/utils/sessionStatus.js +2 -3
  37. package/package.json +1 -2
  38. package/dist/cjs/utils/cameraResolution.js +0 -12
  39. package/dist/esm/utils/cameraResolution.js +0 -9
@@ -7,31 +7,27 @@ 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';
12
10
  import useIsMobile from '../../hooks/useIsMobile.js';
13
11
 
14
12
  var Photo = function (_a) {
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;
13
+ var onCapture = _a.onCapture, _b = _a.automaticCapture, automaticCapture = _b === void 0 ? false : _b, _c = _a.maskType, maskType = _c === void 0 ? "id" : _c;
16
14
  var isMobile = useIsMobile(768);
17
15
  var videoRef = useRef(null);
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];
16
+ var _d = useState(false), isDetecting = _d[0], setIsDetecting = _d[1];
17
+ var _e = useState("environment"), facingMode = _e[0], setFacingMode = _e[1];
18
+ var _f = useState(null), cameraError = _f[0], setCameraError = _f[1];
19
+ var _g = useState(window.matchMedia("(orientation: portrait)").matches), isPortrait = _g[0], setIsPortrait = _g[1];
20
+ var _h = useState(false), isCountingDown = _h[0], setIsCountingDown = _h[1];
21
+ var _j = useState(0), countdown = _j[0], setCountdown = _j[1];
22
+ var _k = useState(false), documentDetected = _k[0], setDocumentDetected = _k[1];
23
+ var _l = useState(undefined), qualityHint = _l[0], setQualityHint = _l[1];
24
+ var _m = useState(true), isInitializing = _m[0], setIsInitializing = _m[1];
25
+ var _o = useState(false), isProcessing = _o[0], setIsProcessing = _o[1];
26
+ var _p = useState(null), captureError = _p[0], setCaptureError = _p[1];
27
+ var _q = useState(false), showCaptureFlash = _q[0], setShowCaptureFlash = _q[1];
32
28
  var t = useI18n().t;
33
- var _t = useState(null); _t[0]; var setLastCaptureMeta = _t[1];
34
- var _u = useState(null), maskRect = _u[0], setMaskRect = _u[1];
29
+ var _r = useState(null); _r[0]; var setLastCaptureMeta = _r[1];
30
+ var _s = useState(null), maskRect = _s[0], setMaskRect = _s[1];
35
31
  var countdownIntervalRef = useRef(null);
36
32
  var detectionHandlerRef = useRef(null);
37
33
  var flashTimeoutRef = useRef(null);
@@ -220,13 +216,11 @@ var Photo = function (_a) {
220
216
  useEffect(function () {
221
217
  var isCancelled = false;
222
218
  var initCamera = function () { return __awaiter(void 0, void 0, void 0, function () {
223
- var result, belowHd;
224
- var _a, _b, _c, _d;
225
- return __generator(this, function (_e) {
226
- switch (_e.label) {
219
+ var result;
220
+ return __generator(this, function (_a) {
221
+ switch (_a.label) {
227
222
  case 0:
228
223
  setCameraError(null);
229
- setLowResolution(false);
230
224
  setIsInitializing(true);
231
225
  return [4 /*yield*/, cameraService.startCamera(videoRef.current, {
232
226
  facingMode: facingMode,
@@ -234,25 +228,11 @@ var Photo = function (_a) {
234
228
  preferImageCapture: true,
235
229
  })];
236
230
  case 1:
237
- result = _e.sent();
231
+ result = _a.sent();
238
232
  if (isCancelled)
239
233
  return [2 /*return*/];
240
234
  setIsInitializing(false);
241
235
  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
- }
256
236
  setLastCaptureMeta(null);
257
237
  // Detection also runs in manual mode: it only drives the visual
258
238
  // feedback on the mask (documentDetected), it never starts the
@@ -280,7 +260,7 @@ var Photo = function (_a) {
280
260
  flashTimeoutRef.current = null;
281
261
  }
282
262
  };
283
- }, [facingMode, cameraAttempt, sessionId, nodeId, clearCountdown, stopDetection]);
263
+ }, [facingMode, clearCountdown, stopDetection]);
284
264
  useEffect(function () {
285
265
  if (!isDetecting || !videoRef.current) {
286
266
  return;
@@ -323,7 +303,21 @@ var Photo = function (_a) {
323
303
  setIsInitializing(true);
324
304
  stopDetection();
325
305
  cameraService.stopCamera();
326
- setCameraAttempt(function (attempt) { return attempt + 1; });
306
+ cameraService
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
+ });
327
321
  };
328
322
  var handleManualCapture = function () {
329
323
  if (isProcessing) {
@@ -347,7 +341,7 @@ var Photo = function (_a) {
347
341
  zIndex: isMobile ? 50 : "auto",
348
342
  height: "100%",
349
343
  width: "100%",
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
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
351
345
  ? "bg-[#11E5C5] animate-pulse"
352
346
  : "bg-orange-500") }), jsx("span", { children: statusMessage })] }), captureError && (jsx("p", { className: "text-red-400 text-xs mt-2 text-center", children: captureError }))] })] }) })] }));
353
347
  };
@@ -135,7 +135,6 @@ 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"),
139
138
  t("jdi.document_selection.instructions.idCard.readable"),
140
139
  t("jdi.document_selection.instructions.idCard.valid"),
141
140
  ];
@@ -148,7 +147,6 @@ var JDIDocumentSelection = function (_a) {
148
147
  case "driverLicense":
149
148
  return [
150
149
  t("jdi.document_selection.instructions.driverLicense.recto_verso"),
151
- t("jdi.document_selection.instructions.two_sided_files"),
152
150
  t("jdi.document_selection.instructions.driverLicense.not_expired"),
153
151
  t("jdi.document_selection.instructions.driverLicense.all_visible"),
154
152
  ];
@@ -161,7 +159,6 @@ var JDIDocumentSelection = function (_a) {
161
159
  case "residencePermit":
162
160
  return [
163
161
  t("jdi.document_selection.instructions.residencePermit.recto_verso"),
164
- t("jdi.document_selection.instructions.two_sided_files"),
165
162
  t("jdi.document_selection.instructions.residencePermit.valid"),
166
163
  t("jdi.document_selection.instructions.residencePermit.readable"),
167
164
  ];
@@ -11,11 +11,8 @@ 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; var title = _a.title, description = _a.description;
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;
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; });
19
16
  // Helper functions for conditional text
20
17
  var getDropZoneText = function () {
21
18
  return t("jdi.document_upload.drop_zone", {
@@ -461,7 +458,7 @@ var JDIDocumentUpload = function (_a) {
461
458
  }
462
459
  });
463
460
  }); };
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
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
465
462
  ? "border-teal-500 bg-teal-100/50"
466
463
  : "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
467
464
  ? frontPreview
@@ -8,7 +8,7 @@ import { getActiveSessionId } from '../../services/sessionMemoryStore.js';
8
8
  import { isPng, dataUrlToFile, isJpeg, convertJpegToPng, isPdf, convertPdfToPng } from '../../utils/imageConverter.js';
9
9
  import { useI18n } from '../../hooks/useI18n.js';
10
10
  import { requiresTwoSides } from '../../utils/documentLabels.js';
11
- import { isS3UploadNotConfirmedError, getServiceErrorCode, isAnalysisFailedError, getServiceErrorCodeFromCodeName } from '../../utils/analysisErrors.js';
11
+ import { isS3UploadNotConfirmedError, getServiceErrorCode, getServiceErrorCodeFromCodeName } from '../../utils/analysisErrors.js';
12
12
  import { isBlockingCode } from '../../utils/jdiCodes.js';
13
13
 
14
14
  // Fonction pour obtenir les étapes de traitement traduites
@@ -316,12 +316,7 @@ var JDIProcessing = memo(function (_a) {
316
316
  },
317
317
  ]
318
318
  : undefined,
319
- // Analyse en erreur côté moteur : nouvel essai possible (dans la
320
- // limite de resoumission du nœud), jamais un passage silencieux.
321
- canRetry: isNetworkError ||
322
- isUploadNotConfirmed ||
323
- !!serviceErrorCode ||
324
- isAnalysisFailedError(error_2),
319
+ canRetry: isNetworkError || isUploadNotConfirmed || !!serviceErrorCode,
325
320
  blockContinue: isUploadNotConfirmed,
326
321
  });
327
322
  setIsComplete(true);
@@ -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, _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;
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, _p = _a.isMobileCapture, isMobileCapture = _p === void 0 ? false : _p, allowedAddingMethods = _a.allowedAddingMethods, template = _a.template, setUserInput = _a.setUserInput;
76
76
  var t = useI18n().t;
77
77
  var session = getSession().session;
78
- var _s = useState(), documentTemplates = _s[0], setDocumentTemplates = _s[1];
79
- var _t = useState(true), loadingTemplates = _t[0], setLoadingTemplates = _t[1];
78
+ var _q = useState(), documentTemplates = _q[0], setDocumentTemplates = _q[1];
79
+ var _r = useState(true), loadingTemplates = _r[0], setLoadingTemplates = _r[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 _u = useState(null), selectedMethod = _u[0], setSelectedMethod = _u[1];
98
+ var _s = useState(null), selectedMethod = _s[0], setSelectedMethod = _s[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 _v = useState(function () {
117
+ var _t = 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 = _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];
122
+ }), docStep = _t[0], setDocStep = _t[1];
123
+ var _u = 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 = _u[0], setSelectedCountry = _u[1];
124
+ var _v = useState(null), fileUploaded = _v[0], setFileUploaded = _v[1];
125
+ var _w = useState(null), analysisData = _w[0], setAnalysisData = _w[1];
126
+ var _x = useState(null), errorCode = _x[0], setErrorCode = _x[1];
127
+ var _y = useState(false), blockContinue = _y[0], setBlockContinue = _y[1];
128
+ var _z = useState(null), nfcPreparationError = _z[0], setNfcPreparationError = _z[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 _2 = useState(false), nfcSkipped = _2[0], setNfcSkipped = _2[1];
131
+ var _0 = useState(false), nfcSkipped = _0[0], setNfcSkipped = _0[1];
132
132
  // Initialize retry count from session data
133
- var _3 = useState(function () {
133
+ var _1 = useState(function () {
134
134
  return getNodeRetryCount(session, node.id);
135
- }), retryCount = _3[0], setRetryCount = _3[1];
135
+ }), retryCount = _1[0], setRetryCount = _1[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 _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;
230
+ var _2 = useState({}), capturedImages = _2[0], setCapturedImages = _2[1];
231
+ var _3 = useState("before-recto"), currentPhotoStep = _3[0], setCurrentPhotoStep = _3[1];
232
+ var _4 = useState("photo"), videoFlowPhase = _4[0], setVideoFlowPhase = _4[1];
233
+ var _5 = useDocumentContext(), selectedDocumentType = _5.selectedDocumentType, setSelectedDocumentType = _5.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, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
763
+ return (jsx(Photo, { 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, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
769
+ return (jsx(Photo, { 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, { 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 () {
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 () {
778
778
  if (isPictureAllowed && isDownloadAllowed) {
779
779
  setSelectedMethod(null);
780
780
  }
@@ -1,3 +1,4 @@
1
+ import { __awaiter, __generator } from '../../node_modules/tslib/tslib.es6.js';
1
2
  import { jsx, jsxs } from 'react/jsx-runtime';
2
3
  import { useMemo, useState, useEffect } from 'react';
3
4
  import { useTranslation } from 'react-i18next';
@@ -5,6 +6,7 @@ import sdkI18n from '../../i18n/index.js';
5
6
  import SignatureElectronicIntroduction from './SignatureElectronicIntroduction.js';
6
7
  import DocusealSignature from './DocusealSignature.js';
7
8
  import SignedDocumentPreview from './SignedDocumentPreview.js';
9
+ import { updateSessionStatus } from '../../services/sessionService.js';
8
10
 
9
11
  /**
10
12
  * Maps an InformationFieldKey (journey field) to the corresponding UserInput key.
@@ -84,19 +86,34 @@ var SignatureElectronic = function (_a) {
84
86
  var handleContinue = function () {
85
87
  setShowSignature(true);
86
88
  };
87
- var handleComplete = function () {
88
- if (typeof window !== "undefined") {
89
- window.sessionStorage.removeItem(signatureViewStorageKey);
90
- }
91
- // La signature ne modifie PLUS le statut de la session (APP3-1996) : seul le
92
- // nœud « end » le fait (PATCH `ended`). Poser `conform` ici affichait « Conforme »
93
- // dans le backoffice, en vert, entre la signature et la fin du parcours, alors
94
- // que le verdict n'était pas encore rendu.
95
- // Toujours montrer le document réellement signé avant de continuer
96
- // (rassure l'utilisateur — pas de bascule directe vers l'étape suivante).
97
- setSignedAt(new Date().toISOString());
98
- setShowSignedDocumentPreview(true);
99
- };
89
+ var handleComplete = function () { return __awaiter(void 0, void 0, void 0, function () {
90
+ var err_1;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0:
94
+ if (typeof window !== "undefined") {
95
+ window.sessionStorage.removeItem(signatureViewStorageKey);
96
+ }
97
+ _a.label = 1;
98
+ case 1:
99
+ _a.trys.push([1, 3, , 4]);
100
+ return [4 /*yield*/, updateSessionStatus(sessionId, "conform")];
101
+ case 2:
102
+ _a.sent();
103
+ return [3 /*break*/, 4];
104
+ case 3:
105
+ err_1 = _a.sent();
106
+ console.error("[SignatureElectronic] Failed to update session status:", err_1);
107
+ return [3 /*break*/, 4];
108
+ case 4:
109
+ // Toujours montrer le document réellement signé avant de continuer
110
+ // (rassure l'utilisateur — pas de bascule directe vers l'étape suivante).
111
+ setSignedAt(new Date().toISOString());
112
+ setShowSignedDocumentPreview(true);
113
+ return [2 /*return*/];
114
+ }
115
+ });
116
+ }); };
100
117
  var handleContinueFromPreview = function () {
101
118
  // Progress to the next step via graph edges (pas d'arithmétique — évite de sauter dans la mauvaise branche)
102
119
  stepObject.goToNextStep(node.id, session.template);
@@ -498,7 +498,6 @@ 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.",
502
501
  jdd: {
503
502
  recent: "• The document must be recent (less than 3 months old).",
504
503
  name_address_visible: "• Your name and address must be clearly visible.",
@@ -781,21 +780,11 @@ var id_check = {
781
780
  alt_verso: "Before taking the verso photo"
782
781
  },
783
782
  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
- },
790
783
  error_title: "Camera error",
791
784
  retry: "Retry",
792
785
  document_detected: "Document detected"
793
786
  },
794
787
  photo: {
795
- hint: {
796
- too_dark: "Too dark, find more light",
797
- too_bright: "Too much glare, avoid direct light"
798
- },
799
788
  capture_failed: "Capture failed. Please try again.",
800
789
  mode_autocapture: "Autocapture enabled",
801
790
  mode_manual: "Manual mode",
@@ -498,7 +498,6 @@ 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.",
502
501
  jdd: {
503
502
  recent: "• El documento debe ser reciente (menos de 3 meses).",
504
503
  name_address_visible: "• Tu nombre y dirección deben verse claramente.",
@@ -781,21 +780,11 @@ var id_check = {
781
780
  alt_verso: "Antes de tomar la foto del reverso"
782
781
  },
783
782
  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
- },
790
783
  error_title: "Error de cámara",
791
784
  retry: "Reintentar",
792
785
  document_detected: "Documento detectado"
793
786
  },
794
787
  photo: {
795
- hint: {
796
- too_dark: "Demasiado oscuro, busque más luz",
797
- too_bright: "Demasiados reflejos, evite la luz directa"
798
- },
799
788
  capture_failed: "La captura ha fallado. Inténtalo de nuevo.",
800
789
  mode_autocapture: "Captura automática activada",
801
790
  mode_manual: "Modo manual",
@@ -498,7 +498,6 @@ 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.",
502
501
  jdd: {
503
502
  recent: "• Le document doit être récent (moins de 3 mois).",
504
503
  name_address_visible: "• Votre nom et adresse doivent être clairement visibles.",
@@ -781,21 +780,11 @@ var id_check = {
781
780
  alt_verso: "Avant de prendre la photo du verso"
782
781
  },
783
782
  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
- },
790
783
  error_title: "Erreur de caméra",
791
784
  retry: "Réessayer",
792
785
  document_detected: "Document détecté"
793
786
  },
794
787
  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
- },
799
788
  capture_failed: "La capture a échoué. Veuillez réessayer.",
800
789
  mode_autocapture: "Autocapture activée",
801
790
  mode_manual: "Mode manuel",