datakeen-session-react 1.1.202-rc.2 → 1.1.202-rc.4

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 (41) hide show
  1. package/dist/cjs/components/document-collection/DocumentCollection.js +2 -2
  2. package/dist/cjs/components/document-collection/DocumentProcessing.js +3 -1
  3. package/dist/cjs/components/id-check/Photo.js +42 -36
  4. package/dist/cjs/components/jdi/JDIDocumentSelection.js +3 -0
  5. package/dist/cjs/components/jdi/JDIDocumentUpload.js +5 -2
  6. package/dist/cjs/components/jdi/JDIProcessing.js +6 -1
  7. package/dist/cjs/components/session/DocumentCheck.js +23 -23
  8. package/dist/cjs/components/signature-electronic/SignatureElectronic.js +13 -30
  9. package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +94 -63
  10. package/dist/cjs/i18n/en.json.js +11 -0
  11. package/dist/cjs/i18n/es.json.js +11 -0
  12. package/dist/cjs/i18n/fr.json.js +11 -0
  13. package/dist/cjs/index.css.js +1 -1
  14. package/dist/cjs/services/analysis.js +7 -0
  15. package/dist/cjs/services/cameraService.js +44 -23
  16. package/dist/cjs/services/pollingService.js +4 -1
  17. package/dist/cjs/services/sessionService.js +16 -6
  18. package/dist/cjs/utils/analysisErrors.js +11 -0
  19. package/dist/cjs/utils/cameraResolution.js +12 -0
  20. package/dist/cjs/utils/sessionStatus.js +3 -2
  21. package/dist/esm/components/document-collection/DocumentCollection.js +2 -2
  22. package/dist/esm/components/document-collection/DocumentProcessing.js +4 -2
  23. package/dist/esm/components/id-check/Photo.js +42 -36
  24. package/dist/esm/components/jdi/JDIDocumentSelection.js +3 -0
  25. package/dist/esm/components/jdi/JDIDocumentUpload.js +5 -2
  26. package/dist/esm/components/jdi/JDIProcessing.js +7 -2
  27. package/dist/esm/components/session/DocumentCheck.js +23 -23
  28. package/dist/esm/components/signature-electronic/SignatureElectronic.js +13 -30
  29. package/dist/esm/components/template/ExternalVerificationNodeHandler.js +94 -63
  30. package/dist/esm/i18n/en.json.js +11 -0
  31. package/dist/esm/i18n/es.json.js +11 -0
  32. package/dist/esm/i18n/fr.json.js +11 -0
  33. package/dist/esm/index.css.js +1 -1
  34. package/dist/esm/services/analysis.js +7 -0
  35. package/dist/esm/services/cameraService.js +44 -23
  36. package/dist/esm/services/pollingService.js +4 -1
  37. package/dist/esm/services/sessionService.js +16 -7
  38. package/dist/esm/utils/analysisErrors.js +10 -1
  39. package/dist/esm/utils/cameraResolution.js +9 -0
  40. package/dist/esm/utils/sessionStatus.js +3 -2
  41. package/package.json +2 -1
@@ -308,7 +308,7 @@ var DocumentCollection = function (_a) {
308
308
  case "before-recto":
309
309
  return jsxRuntime.jsx(BeforePhoto.default, { setStep: function () { return setPhotoSubStep("recto"); }, isSingleSided: !requiresTwoSides_1, onBack: handleBack });
310
310
  case "recto":
311
- return jsxRuntime.jsx(Photo.default, { onCapture: function (img) { return handlePhotoCapture(img, "recto"); }, automaticCapture: false, maskType: "document" });
311
+ return jsxRuntime.jsx(Photo.default, { sessionId: sessionId, nodeId: node.id, onCapture: function (img) { return handlePhotoCapture(img, "recto"); }, automaticCapture: false, maskType: "document" });
312
312
  case "preview-recto":
313
313
  return (jsxRuntime.jsx(PhotoPreview.default, { imageUrl: capturedImages.recto, side: "recto", isSingleSided: !requiresTwoSides_1, onValidate: function () { return setPhotoSubStep(requiresTwoSides_1 ? "before-verso" : "confirmation"); }, onRetake: function () {
314
314
  setCapturedImages(function (prev) { var next = tslib_es6.__assign({}, prev); delete next.recto; return next; });
@@ -317,7 +317,7 @@ var DocumentCollection = function (_a) {
317
317
  case "before-verso":
318
318
  return jsxRuntime.jsx(BeforeVersoPhoto.default, { setStep: function () { return setPhotoSubStep("verso"); } });
319
319
  case "verso":
320
- return jsxRuntime.jsx(Photo.default, { onCapture: function (img) { return handlePhotoCapture(img, "verso"); }, automaticCapture: false, maskType: "document" });
320
+ return jsxRuntime.jsx(Photo.default, { sessionId: sessionId, nodeId: node.id, onCapture: function (img) { return handlePhotoCapture(img, "verso"); }, automaticCapture: false, maskType: "document" });
321
321
  case "preview-verso":
322
322
  return (jsxRuntime.jsx(PhotoPreview.default, { imageUrl: capturedImages.verso, side: "verso", onValidate: function () { return setPhotoSubStep("confirmation"); }, onRetake: function () {
323
323
  setCapturedImages(function (prev) { var next = tslib_es6.__assign({}, prev); delete next.verso; return next; });
@@ -234,7 +234,9 @@ var DocumentProcessing = React.memo(function (_a) {
234
234
  },
235
235
  ]
236
236
  : undefined,
237
- canRetry: isUploadNotConfirmed || !!serviceErrorCode,
237
+ canRetry: isUploadNotConfirmed ||
238
+ !!serviceErrorCode ||
239
+ analysisErrors.isAnalysisFailedError(error_1),
238
240
  blockContinue: isUploadNotConfirmed,
239
241
  });
240
242
  setIsComplete(true);
@@ -11,27 +11,31 @@ var CameraError = require('./CameraError.js');
11
11
  var CameraMask = require('./CameraMask.js');
12
12
  var OrientationToggle = require('./OrientationToggle.js');
13
13
  var useI18n = require('../../hooks/useI18n.js');
14
+ var cameraResolution = require('../../utils/cameraResolution.js');
15
+ var sessionService = require('../../services/sessionService.js');
14
16
  var useIsMobile = require('../../hooks/useIsMobile.js');
15
17
 
16
18
  var Photo = function (_a) {
17
- var onCapture = _a.onCapture, _b = _a.automaticCapture, automaticCapture = _b === void 0 ? false : _b, _c = _a.maskType, maskType = _c === void 0 ? "id" : _c;
19
+ 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;
18
20
  var isMobile = useIsMobile.default(768);
19
21
  var videoRef = React.useRef(null);
20
- var _d = React.useState(false), isDetecting = _d[0], setIsDetecting = _d[1];
21
- var _e = React.useState("environment"), facingMode = _e[0], setFacingMode = _e[1];
22
- var _f = React.useState(null), cameraError = _f[0], setCameraError = _f[1];
23
- var _g = React.useState(window.matchMedia("(orientation: portrait)").matches), isPortrait = _g[0], setIsPortrait = _g[1];
24
- var _h = React.useState(false), isCountingDown = _h[0], setIsCountingDown = _h[1];
25
- var _j = React.useState(0), countdown = _j[0], setCountdown = _j[1];
26
- var _k = React.useState(false), documentDetected = _k[0], setDocumentDetected = _k[1];
27
- var _l = React.useState(undefined), qualityHint = _l[0], setQualityHint = _l[1];
28
- var _m = React.useState(true), isInitializing = _m[0], setIsInitializing = _m[1];
29
- var _o = React.useState(false), isProcessing = _o[0], setIsProcessing = _o[1];
30
- var _p = React.useState(null), captureError = _p[0], setCaptureError = _p[1];
31
- var _q = React.useState(false), showCaptureFlash = _q[0], setShowCaptureFlash = _q[1];
22
+ var _d = React.useState(false), lowResolution = _d[0], setLowResolution = _d[1];
23
+ var _e = React.useState(0), cameraAttempt = _e[0], setCameraAttempt = _e[1];
24
+ var _f = React.useState(false), isDetecting = _f[0], setIsDetecting = _f[1];
25
+ var _g = React.useState("environment"), facingMode = _g[0], setFacingMode = _g[1];
26
+ var _h = React.useState(null), cameraError = _h[0], setCameraError = _h[1];
27
+ var _j = React.useState(window.matchMedia("(orientation: portrait)").matches), isPortrait = _j[0], setIsPortrait = _j[1];
28
+ var _k = React.useState(false), isCountingDown = _k[0], setIsCountingDown = _k[1];
29
+ var _l = React.useState(0), countdown = _l[0], setCountdown = _l[1];
30
+ var _m = React.useState(false), documentDetected = _m[0], setDocumentDetected = _m[1];
31
+ var _o = React.useState(undefined), qualityHint = _o[0], setQualityHint = _o[1];
32
+ var _p = React.useState(true), isInitializing = _p[0], setIsInitializing = _p[1];
33
+ var _q = React.useState(false), isProcessing = _q[0], setIsProcessing = _q[1];
34
+ var _r = React.useState(null), captureError = _r[0], setCaptureError = _r[1];
35
+ var _s = React.useState(false), showCaptureFlash = _s[0], setShowCaptureFlash = _s[1];
32
36
  var t = useI18n.useI18n().t;
33
- var _r = React.useState(null); _r[0]; var setLastCaptureMeta = _r[1];
34
- var _s = React.useState(null), maskRect = _s[0], setMaskRect = _s[1];
37
+ var _t = React.useState(null); _t[0]; var setLastCaptureMeta = _t[1];
38
+ var _u = React.useState(null), maskRect = _u[0], setMaskRect = _u[1];
35
39
  var countdownIntervalRef = React.useRef(null);
36
40
  var detectionHandlerRef = React.useRef(null);
37
41
  var flashTimeoutRef = React.useRef(null);
@@ -220,11 +224,13 @@ var Photo = function (_a) {
220
224
  React.useEffect(function () {
221
225
  var isCancelled = false;
222
226
  var initCamera = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
223
- var result;
224
- return tslib_es6.__generator(this, function (_a) {
225
- switch (_a.label) {
227
+ var result, belowHd;
228
+ var _a, _b, _c, _d;
229
+ return tslib_es6.__generator(this, function (_e) {
230
+ switch (_e.label) {
226
231
  case 0:
227
232
  setCameraError(null);
233
+ setLowResolution(false);
228
234
  setIsInitializing(true);
229
235
  return [4 /*yield*/, cameraService.cameraService.startCamera(videoRef.current, {
230
236
  facingMode: facingMode,
@@ -232,11 +238,25 @@ var Photo = function (_a) {
232
238
  preferImageCapture: true,
233
239
  })];
234
240
  case 1:
235
- result = _a.sent();
241
+ result = _e.sent();
236
242
  if (isCancelled)
237
243
  return [2 /*return*/];
238
244
  setIsInitializing(false);
239
245
  if (result.success) {
246
+ belowHd = cameraResolution.isBelowHd(result.settings);
247
+ setLowResolution(belowHd);
248
+ if (sessionId && nodeId) {
249
+ void sessionService.reportCaptureDiagnostics(sessionId, nodeId, {
250
+ requested: result.requested,
251
+ 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 },
252
+ retriedWithHd: (_d = result.retriedWithHd) !== null && _d !== void 0 ? _d : false,
253
+ devicePixelRatio: window.devicePixelRatio,
254
+ cameraLabel: result.label,
255
+ lowResolutionWarningShown: belowHd,
256
+ facingMode: facingMode,
257
+ at: new Date().toISOString(),
258
+ }).catch(function () { });
259
+ }
240
260
  setLastCaptureMeta(null);
241
261
  // Detection also runs in manual mode: it only drives the visual
242
262
  // feedback on the mask (documentDetected), it never starts the
@@ -264,7 +284,7 @@ var Photo = function (_a) {
264
284
  flashTimeoutRef.current = null;
265
285
  }
266
286
  };
267
- }, [facingMode, clearCountdown, stopDetection]);
287
+ }, [facingMode, cameraAttempt, sessionId, nodeId, clearCountdown, stopDetection]);
268
288
  React.useEffect(function () {
269
289
  if (!isDetecting || !videoRef.current) {
270
290
  return;
@@ -307,21 +327,7 @@ var Photo = function (_a) {
307
327
  setIsInitializing(true);
308
328
  stopDetection();
309
329
  cameraService.cameraService.stopCamera();
310
- cameraService.cameraService
311
- .startCamera(videoRef.current, {
312
- facingMode: facingMode,
313
- idealResolution: { width: 4096, height: 3072 },
314
- preferImageCapture: true,
315
- })
316
- .then(function (result) {
317
- setIsInitializing(false);
318
- if (result.success) {
319
- setIsDetecting(true);
320
- }
321
- else if (result.error) {
322
- setCameraError(result.error);
323
- }
324
- });
330
+ setCameraAttempt(function (attempt) { return attempt + 1; });
325
331
  };
326
332
  var handleManualCapture = function () {
327
333
  if (isProcessing) {
@@ -345,7 +351,7 @@ var Photo = function (_a) {
345
351
  zIndex: isMobile ? 50 : "auto",
346
352
  height: "100%",
347
353
  width: "100%",
348
- }, children: [jsxRuntime.jsx("div", { className: "flex-1 relative overflow-hidden bg-black", children: cameraError ? (jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full px-4 py-6", children: jsxRuntime.jsx(CameraError.default, { errorMessage: cameraError, onRetry: handleRetry }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isInitializing && (jsxRuntime.jsxs("div", { "data-testid": "camera-initializing", className: "absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black", children: [jsxRuntime.jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsxRuntime.jsx("span", { className: "text-white text-sm", children: t("id_check.photo.initializing", "Ouverture de la caméra…") })] })), isProcessing && (jsxRuntime.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: [jsxRuntime.jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsxRuntime.jsx("span", { className: "text-white text-sm", children: t("id_check.photo.processing", "Traitement de l'image…") })] })), jsxRuntime.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]" : "") }), jsxRuntime.jsx("div", { className: "absolute top-4 left-1/2 transform -translate-x-1/2 z-50", children: jsxRuntime.jsx("span", { className: "text-white z-50 text-sm font-semibold drop-shadow-lg", children: automaticCapture ? (jsxRuntime.jsx("span", { className: "animate-pulse", children: t("id_check.photo.mode_autocapture", "Autocapture activée") })) : (jsxRuntime.jsx("span", { className: "bg-orange-500 px-2 py-1 rounded hidden", children: t("id_check.photo.mode_manual", "Mode manuel") })) }) }), jsxRuntime.jsx(CameraMask.default, { isDetecting: isDetecting, isPortrait: isPortrait, facingMode: facingMode, isCountingDown: isCountingDown, countdown: countdown, maskType: maskType, documentDetected: documentDetected, qualityHint: qualityHint, onMaskRectChange: setMaskRect }), jsxRuntime.jsx("div", { className: "absolute bottom-20 left-0 right-0 z-20 pointer-events-none", children: jsxRuntime.jsx("div", { className: "text-center px-4", children: jsxRuntime.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") }) }) }), jsxRuntime.jsx(OrientationToggle.default, { onCameraToggle: toggleCamera }), showCaptureFlash && (jsxRuntime.jsx("div", { "data-testid": "capture-flash", className: "absolute inset-0 z-40 bg-white pointer-events-none animate-pulse" }))] })) }), jsxRuntime.jsx("div", { className: "relative z-20 bg-black bg-opacity-80 p-4", children: jsxRuntime.jsxs("div", { className: "flex flex-col items-center space-y-4", children: [jsxRuntime.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: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-white rounded-full" }) }), jsxRuntime.jsxs("div", { className: "text-white text-center text-sm", children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-center space-x-2", children: [jsxRuntime.jsx("div", { className: "w-2 h-2 rounded-full ".concat(automaticCapture
354
+ }, children: [jsxRuntime.jsx("div", { className: "flex-1 relative overflow-hidden bg-black", children: cameraError ? (jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full px-4 py-6", children: jsxRuntime.jsx(CameraError.default, { errorMessage: cameraError, onRetry: handleRetry }) })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isInitializing && (jsxRuntime.jsxs("div", { "data-testid": "camera-initializing", className: "absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black", children: [jsxRuntime.jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsxRuntime.jsx("span", { className: "text-white text-sm", children: t("id_check.photo.initializing", "Ouverture de la caméra…") })] })), isProcessing && (jsxRuntime.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: [jsxRuntime.jsx("div", { className: "w-10 h-10 border-4 border-white border-t-transparent rounded-full animate-spin" }), jsxRuntime.jsx("span", { className: "text-white text-sm", children: t("id_check.photo.processing", "Traitement de l'image…") })] })), jsxRuntime.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]" : "") }), jsxRuntime.jsx("div", { className: "absolute top-4 left-1/2 transform -translate-x-1/2 z-50", children: jsxRuntime.jsx("span", { className: "text-white z-50 text-sm font-semibold drop-shadow-lg", children: automaticCapture ? (jsxRuntime.jsx("span", { className: "animate-pulse", children: t("id_check.photo.mode_autocapture", "Autocapture activée") })) : (jsxRuntime.jsx("span", { className: "bg-orange-500 px-2 py-1 rounded hidden", children: t("id_check.photo.mode_manual", "Mode manuel") })) }) }), jsxRuntime.jsx(CameraMask.default, { isDetecting: isDetecting, isPortrait: isPortrait, facingMode: facingMode, isCountingDown: isCountingDown, countdown: countdown, maskType: maskType, documentDetected: documentDetected, qualityHint: qualityHint, onMaskRectChange: setMaskRect }), jsxRuntime.jsx("div", { className: "absolute bottom-20 left-0 right-0 z-20 pointer-events-none", children: jsxRuntime.jsx("div", { className: "text-center px-4", children: jsxRuntime.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") }) }) }), jsxRuntime.jsx(OrientationToggle.default, { onCameraToggle: toggleCamera }), lowResolution && !cameraError && (jsxRuntime.jsx("div", { role: "status", className: "absolute inset-x-3 z-30 ".concat(automaticCapture ? "top-12" : "top-3"), children: jsxRuntime.jsx("div", { className: "rounded-xl bg-black/75 text-white shadow-lg backdrop-blur-sm", children: jsxRuntime.jsxs("details", { className: "group", children: [jsxRuntime.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: [jsxRuntime.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: jsxRuntime.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" }) }), jsxRuntime.jsx("span", { className: "min-w-0 flex-1", children: t("id_check.camera.low_resolution.title") }), jsxRuntime.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: jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m6 9 6 6 6-6" }) })] }), jsxRuntime.jsxs("div", { className: "space-y-2 px-3 pb-3 text-sm leading-relaxed text-white/85", children: [jsxRuntime.jsx("p", { children: t("id_check.camera.low_resolution.body") }), jsxRuntime.jsx("p", { children: t("id_check.camera.low_resolution.tips") }), jsxRuntime.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 && (jsxRuntime.jsx("div", { "data-testid": "capture-flash", className: "absolute inset-0 z-40 bg-white pointer-events-none animate-pulse" }))] })) }), jsxRuntime.jsx("div", { className: "relative z-20 bg-black bg-opacity-80 p-4", children: jsxRuntime.jsxs("div", { className: "flex flex-col items-center space-y-4", children: [jsxRuntime.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: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-white rounded-full" }) }), jsxRuntime.jsxs("div", { className: "text-white text-center text-sm", children: [jsxRuntime.jsxs("div", { className: "flex items-center justify-center space-x-2", children: [jsxRuntime.jsx("div", { className: "w-2 h-2 rounded-full ".concat(automaticCapture
349
355
  ? "bg-[#11E5C5] animate-pulse"
350
356
  : "bg-orange-500") }), jsxRuntime.jsx("span", { children: statusMessage })] }), captureError && (jsxRuntime.jsx("p", { className: "text-red-400 text-xs mt-2 text-center", children: captureError }))] })] }) })] }));
351
357
  };
@@ -139,6 +139,7 @@ var JDIDocumentSelection = function (_a) {
139
139
  case "idCard":
140
140
  return [
141
141
  t("jdi.document_selection.instructions.idCard.recto_verso"),
142
+ t("jdi.document_selection.instructions.two_sided_files"),
142
143
  t("jdi.document_selection.instructions.idCard.readable"),
143
144
  t("jdi.document_selection.instructions.idCard.valid"),
144
145
  ];
@@ -151,6 +152,7 @@ var JDIDocumentSelection = function (_a) {
151
152
  case "driverLicense":
152
153
  return [
153
154
  t("jdi.document_selection.instructions.driverLicense.recto_verso"),
155
+ t("jdi.document_selection.instructions.two_sided_files"),
154
156
  t("jdi.document_selection.instructions.driverLicense.not_expired"),
155
157
  t("jdi.document_selection.instructions.driverLicense.all_visible"),
156
158
  ];
@@ -163,6 +165,7 @@ var JDIDocumentSelection = function (_a) {
163
165
  case "residencePermit":
164
166
  return [
165
167
  t("jdi.document_selection.instructions.residencePermit.recto_verso"),
168
+ t("jdi.document_selection.instructions.two_sided_files"),
166
169
  t("jdi.document_selection.instructions.residencePermit.valid"),
167
170
  t("jdi.document_selection.instructions.residencePermit.readable"),
168
171
  ];
@@ -15,8 +15,11 @@ var documentLabels = require('../../utils/documentLabels.js');
15
15
  var MobilePageLayout = require('../ui/MobilePageLayout.js');
16
16
 
17
17
  var JDIDocumentUpload = function (_a) {
18
- 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;
18
+ 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;
19
19
  var t = useI18n.useI18n().t;
20
+ var documentName = t("documentTypes." + documentType);
21
+ var customTitle = title === null || title === void 0 ? void 0 : title.trim().replace(/\{\{\s*document\s*\}\}/g, function () { return documentName; });
22
+ var customDescription = description === null || description === void 0 ? void 0 : description.trim().replace(/\{\{\s*document\s*\}\}/g, function () { return documentName; });
20
23
  // Helper functions for conditional text
21
24
  var getDropZoneText = function () {
22
25
  return t("jdi.document_upload.drop_zone", {
@@ -462,7 +465,7 @@ var JDIDocumentUpload = function (_a) {
462
465
  }
463
466
  });
464
467
  }); };
465
- return (jsxRuntime.jsx(MobilePageLayout.default, { contentClassName: "h-full", footer: jsxRuntime.jsx(PageActions.default, { primary: jsxRuntime.jsx(Button.default, { onClick: handleUpload, disabled: (!frontFile && !isFrontFromInitial) || isUploading, children: getValidateButtonText() }), secondary: onBack ? (jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: onBack, disabled: isUploading, children: t("jdi.document_upload.back") })) : undefined }), children: jsxRuntime.jsx("div", { className: "flex-1 flex items-start justify-center md:items-center p-4", children: jsxRuntime.jsxs("div", { className: "w-full max-w-lg", children: [jsxRuntime.jsxs("div", { className: "text-center mb-8", children: [jsxRuntime.jsx("h1", { className: "text-2xl md:text-3xl font-bold text-gray-900 mb-2", children: getDropZoneText() }), jsxRuntime.jsx("p", { className: "text-gray-600", children: getUploadInstruction() })] }), jsxRuntime.jsx(Card.Card, { ref: dropZoneRef, className: "border-2 border-dashed ".concat(isDragging
468
+ return (jsxRuntime.jsx(MobilePageLayout.default, { contentClassName: "h-full", footer: jsxRuntime.jsx(PageActions.default, { primary: jsxRuntime.jsx(Button.default, { onClick: handleUpload, disabled: (!frontFile && !isFrontFromInitial) || isUploading, children: getValidateButtonText() }), secondary: onBack ? (jsxRuntime.jsx(Button.default, { variant: "secondary", onClick: onBack, disabled: isUploading, children: t("jdi.document_upload.back") })) : undefined }), children: jsxRuntime.jsx("div", { className: "flex-1 flex items-start justify-center md:items-center p-4", children: jsxRuntime.jsxs("div", { className: "w-full max-w-lg", children: [jsxRuntime.jsxs("div", { className: "text-center mb-8", children: [jsxRuntime.jsx("h1", { className: "text-2xl md:text-3xl font-bold text-gray-900 mb-2", children: customTitle || getDropZoneText() }), jsxRuntime.jsx("p", { className: "text-gray-600 whitespace-pre-line", children: customDescription || getUploadInstruction() })] }), jsxRuntime.jsx(Card.Card, { ref: dropZoneRef, className: "border-2 border-dashed ".concat(isDragging
466
469
  ? "border-teal-500 bg-teal-100/50"
467
470
  : "border-teal-300 bg-teal-50/30", " p-8 mb-6 transition-colors"), onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, children: jsxRuntime.jsx("div", { className: "text-center space-y-6", children: !frontPreview ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-gray-900 mb-4", children: t("documentTypes." + documentType) }), jsxRuntime.jsx("div", { className: "flex justify-center w-full", children: jsxRuntime.jsx(Button.default, { 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: jsxRuntime.jsx("span", { children: t("jdi.document_upload.add_file") }) }) }), jsxRuntime.jsx("p", { className: "text-sm text-gray-500 italic", children: t("jdi.document_upload.drag_drop_hint", "ou glissez-déposez vos fichiers ici") }), jsxRuntime.jsxs("div", { className: "text-sm text-gray-600 space-y-1", children: [jsxRuntime.jsx("p", { children: t("jdi.document_upload.accepted_formats") }), jsxRuntime.jsx("p", { children: twoSidesRequired
468
471
  ? frontPreview
@@ -320,7 +320,12 @@ var JDIProcessing = React.memo(function (_a) {
320
320
  },
321
321
  ]
322
322
  : undefined,
323
- canRetry: isNetworkError || isUploadNotConfirmed || !!serviceErrorCode,
323
+ // Analyse en erreur côté moteur : nouvel essai possible (dans la
324
+ // limite de resoumission du nœud), jamais un passage silencieux.
325
+ canRetry: isNetworkError ||
326
+ isUploadNotConfirmed ||
327
+ !!serviceErrorCode ||
328
+ analysisErrors.isAnalysisFailedError(error_2),
324
329
  blockContinue: isUploadNotConfirmed,
325
330
  });
326
331
  setIsComplete(true);
@@ -75,12 +75,12 @@ var normalizeNfcMode = function (mode) {
75
75
  * - Uses hooks for translation, retry navigation, and context management.
76
76
  */
77
77
  var DocumentCheck = function (_a) {
78
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
79
- 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;
78
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
79
+ 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;
80
80
  var t = useI18n.useI18n().t;
81
81
  var session = SessionContext.getSession().session;
82
- var _q = React.useState(), documentTemplates = _q[0], setDocumentTemplates = _q[1];
83
- var _r = React.useState(true), loadingTemplates = _r[0], setLoadingTemplates = _r[1];
82
+ var _s = React.useState(), documentTemplates = _s[0], setDocumentTemplates = _s[1];
83
+ var _t = React.useState(true), loadingTemplates = _t[0], setLoadingTemplates = _t[1];
84
84
  React.useEffect(function () {
85
85
  (function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
86
86
  var templates;
@@ -99,7 +99,7 @@ var DocumentCheck = function (_a) {
99
99
  }); })();
100
100
  }, []);
101
101
  var initialRetryCount = retryService.getNodeRetryCount(session, node.id);
102
- var _s = React.useState(null), selectedMethod = _s[0], setSelectedMethod = _s[1];
102
+ var _u = React.useState(null), selectedMethod = _u[0], setSelectedMethod = _u[1];
103
103
  var isPictureAllowed = (_b = allowedAddingMethods === null || allowedAddingMethods === void 0 ? void 0 : allowedAddingMethods.includes("picture")) !== null && _b !== void 0 ? _b : true;
104
104
  var isDownloadAllowed = (_c = allowedAddingMethods === null || allowedAddingMethods === void 0 ? void 0 : allowedAddingMethods.includes("download")) !== null && _c !== void 0 ? _c : true;
105
105
  // Check if retry is allowed based on initial retry count
@@ -118,25 +118,25 @@ var DocumentCheck = function (_a) {
118
118
  return true;
119
119
  };
120
120
  // Initialize docStep - if retries exhausted, start at error page (step 6)
121
- var _t = React.useState(function () {
121
+ var _v = React.useState(function () {
122
122
  if (initialRetryCount > 0 && !isInitialRetryAllowed()) {
123
123
  return 6; // Error page
124
124
  }
125
125
  return 0; // Normal flow - start with introduction
126
- }), docStep = _t[0], setDocStep = _t[1];
127
- var _u = React.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];
128
- var _v = React.useState(null), fileUploaded = _v[0], setFileUploaded = _v[1];
129
- var _w = React.useState(null), analysisData = _w[0], setAnalysisData = _w[1];
130
- var _x = React.useState(null), errorCode = _x[0], setErrorCode = _x[1];
131
- var _y = React.useState(false), blockContinue = _y[0], setBlockContinue = _y[1];
132
- var _z = React.useState(null), nfcPreparationError = _z[0], setNfcPreparationError = _z[1];
126
+ }), docStep = _v[0], setDocStep = _v[1];
127
+ var _w = React.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];
128
+ var _x = React.useState(null), fileUploaded = _x[0], setFileUploaded = _x[1];
129
+ var _y = React.useState(null), analysisData = _y[0], setAnalysisData = _y[1];
130
+ var _z = React.useState(null), errorCode = _z[0], setErrorCode = _z[1];
131
+ var _0 = React.useState(false), blockContinue = _0[0], setBlockContinue = _0[1];
132
+ var _1 = React.useState(null), nfcPreparationError = _1[0], setNfcPreparationError = _1[1];
133
133
  // Quand l'utilisateur déclare ne pas avoir de puce (questionnaire de fallback),
134
134
  // on ne doit plus le réorienter vers le scan NFC (ni avant, ni après l'analyse API).
135
- var _0 = React.useState(false), nfcSkipped = _0[0], setNfcSkipped = _0[1];
135
+ var _2 = React.useState(false), nfcSkipped = _2[0], setNfcSkipped = _2[1];
136
136
  // Initialize retry count from session data
137
- var _1 = React.useState(function () {
137
+ var _3 = React.useState(function () {
138
138
  return retryService.getNodeRetryCount(session, node.id);
139
- }), retryCount = _1[0], setRetryCount = _1[1];
139
+ }), retryCount = _3[0], setRetryCount = _3[1];
140
140
  // Update retry count when session loads/changes
141
141
  React.useEffect(function () {
142
142
  if (session) {
@@ -231,10 +231,10 @@ var DocumentCheck = function (_a) {
231
231
  setDocStep(6);
232
232
  }
233
233
  }, [retryCount, node.allowResubmission, node.maxResubmissionAttempts]);
234
- var _2 = React.useState({}), capturedImages = _2[0], setCapturedImages = _2[1];
235
- var _3 = React.useState("before-recto"), currentPhotoStep = _3[0], setCurrentPhotoStep = _3[1];
236
- var _4 = React.useState("photo"), videoFlowPhase = _4[0], setVideoFlowPhase = _4[1];
237
- var _5 = DocumentContext.useDocumentContext(), selectedDocumentType = _5.selectedDocumentType, setSelectedDocumentType = _5.setSelectedDocumentType;
234
+ var _4 = React.useState({}), capturedImages = _4[0], setCapturedImages = _4[1];
235
+ var _5 = React.useState("before-recto"), currentPhotoStep = _5[0], setCurrentPhotoStep = _5[1];
236
+ var _6 = React.useState("photo"), videoFlowPhase = _6[0], setVideoFlowPhase = _6[1];
237
+ var _7 = DocumentContext.useDocumentContext(), selectedDocumentType = _7.selectedDocumentType, setSelectedDocumentType = _7.setSelectedDocumentType;
238
238
  var finalAcceptedCountries = React.useMemo(function () {
239
239
  if (loadingTemplates)
240
240
  return acceptedCountries;
@@ -764,13 +764,13 @@ var DocumentCheck = function (_a) {
764
764
  return (jsxRuntime.jsx(BeforePhoto.default, { setStep: function () { return setCurrentPhotoStep("recto"); }, isSingleSided: isSingleSided, onBack: function () { return setDocStep(2); } }));
765
765
  }
766
766
  if (currentPhotoStep === "recto") {
767
- return (jsxRuntime.jsx(Photo.default, { onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
767
+ return (jsxRuntime.jsx(Photo.default, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
768
768
  }
769
769
  if (currentPhotoStep === "before-verso") {
770
770
  return (jsxRuntime.jsx(BeforeVersoPhoto.default, { setStep: function () { return setCurrentPhotoStep("verso"); } }));
771
771
  }
772
772
  if (currentPhotoStep === "verso") {
773
- return (jsxRuntime.jsx(Photo.default, { onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
773
+ return (jsxRuntime.jsx(Photo.default, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
774
774
  }
775
775
  if (currentPhotoStep === "confirmation") {
776
776
  return (jsxRuntime.jsx(PhotoConfirmation.default, { 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 }));
@@ -778,7 +778,7 @@ var DocumentCheck = function (_a) {
778
778
  return (jsxRuntime.jsx(BeforePhoto.default, { setStep: function () { return setCurrentPhotoStep("recto"); }, isSingleSided: isSingleSided, onBack: function () { return setDocStep(2); } }));
779
779
  }
780
780
  else {
781
- return (jsxRuntime.jsx(JDIDocumentUpload.default, { 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 () {
781
+ return (jsxRuntime.jsx(JDIDocumentUpload.default, { 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 () {
782
782
  if (isPictureAllowed && isDownloadAllowed) {
783
783
  setSelectedMethod(null);
784
784
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
6
5
  var jsxRuntime = require('react/jsx-runtime');
7
6
  var React = require('react');
8
7
  var reactI18next = require('react-i18next');
@@ -10,7 +9,6 @@ var index = require('../../i18n/index.js');
10
9
  var SignatureElectronicIntroduction = require('./SignatureElectronicIntroduction.js');
11
10
  var DocusealSignature = require('./DocusealSignature.js');
12
11
  var SignedDocumentPreview = require('./SignedDocumentPreview.js');
13
- var sessionService = require('../../services/sessionService.js');
14
12
 
15
13
  /**
16
14
  * Maps an InformationFieldKey (journey field) to the corresponding UserInput key.
@@ -90,34 +88,19 @@ var SignatureElectronic = function (_a) {
90
88
  var handleContinue = function () {
91
89
  setShowSignature(true);
92
90
  };
93
- var handleComplete = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
94
- var err_1;
95
- return tslib_es6.__generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0:
98
- if (typeof window !== "undefined") {
99
- window.sessionStorage.removeItem(signatureViewStorageKey);
100
- }
101
- _a.label = 1;
102
- case 1:
103
- _a.trys.push([1, 3, , 4]);
104
- return [4 /*yield*/, sessionService.updateSessionStatus(sessionId, "conform")];
105
- case 2:
106
- _a.sent();
107
- return [3 /*break*/, 4];
108
- case 3:
109
- err_1 = _a.sent();
110
- console.error("[SignatureElectronic] Failed to update session status:", err_1);
111
- return [3 /*break*/, 4];
112
- case 4:
113
- // Toujours montrer le document réellement signé avant de continuer
114
- // (rassure l'utilisateur — pas de bascule directe vers l'étape suivante).
115
- setSignedAt(new Date().toISOString());
116
- setShowSignedDocumentPreview(true);
117
- return [2 /*return*/];
118
- }
119
- });
120
- }); };
91
+ var handleComplete = function () {
92
+ if (typeof window !== "undefined") {
93
+ window.sessionStorage.removeItem(signatureViewStorageKey);
94
+ }
95
+ // La signature ne modifie PLUS le statut de la session (APP3-1996) : seul le
96
+ // nœud « end » le fait (PATCH `ended`). Poser `conform` ici affichait « Conforme »
97
+ // dans le backoffice, en vert, entre la signature et la fin du parcours, alors
98
+ // que le verdict n'était pas encore rendu.
99
+ // Toujours montrer le document réellement signé avant de continuer
100
+ // (rassure l'utilisateur — pas de bascule directe vers l'étape suivante).
101
+ setSignedAt(new Date().toISOString());
102
+ setShowSignedDocumentPreview(true);
103
+ };
121
104
  var handleContinueFromPreview = function () {
122
105
  // Progress to the next step via graph edges (pas d'arithmétique — évite de sauter dans la mauvaise branche)
123
106
  stepObject.goToNextStep(node.id, session.template);