datakeen-session-react 1.1.204 → 1.1.207

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 (43) 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/JDIProcessing.js +6 -1
  5. package/dist/cjs/components/nfc-scan/NfcScanNode.js +3 -4
  6. package/dist/cjs/components/session/DocumentCheck.js +2 -2
  7. package/dist/cjs/components/signature-electronic/SignatureElectronic.js +13 -30
  8. package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +94 -63
  9. package/dist/cjs/hooks/useUserInputForm.js +112 -0
  10. package/dist/cjs/i18n/en.json.js +10 -0
  11. package/dist/cjs/i18n/es.json.js +10 -0
  12. package/dist/cjs/i18n/fr.json.js +10 -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/extractedCopy.js +38 -0
  21. package/dist/cjs/utils/sessionStatus.js +3 -2
  22. package/dist/esm/components/document-collection/DocumentCollection.js +2 -2
  23. package/dist/esm/components/document-collection/DocumentProcessing.js +4 -2
  24. package/dist/esm/components/id-check/Photo.js +42 -36
  25. package/dist/esm/components/jdi/JDIProcessing.js +7 -2
  26. package/dist/esm/components/nfc-scan/NfcScanNode.js +3 -4
  27. package/dist/esm/components/session/DocumentCheck.js +2 -2
  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/hooks/useUserInputForm.js +113 -1
  31. package/dist/esm/i18n/en.json.js +10 -0
  32. package/dist/esm/i18n/es.json.js +10 -0
  33. package/dist/esm/i18n/fr.json.js +10 -0
  34. package/dist/esm/index.css.js +1 -1
  35. package/dist/esm/services/analysis.js +7 -0
  36. package/dist/esm/services/cameraService.js +44 -23
  37. package/dist/esm/services/pollingService.js +4 -1
  38. package/dist/esm/services/sessionService.js +16 -7
  39. package/dist/esm/utils/analysisErrors.js +10 -1
  40. package/dist/esm/utils/cameraResolution.js +9 -0
  41. package/dist/esm/utils/extractedCopy.js +36 -0
  42. package/dist/esm/utils/sessionStatus.js +3 -2
  43. package/package.json +2 -1
@@ -5,12 +5,21 @@ var api = require('./api.js');
5
5
  var auditTrailService = require('./auditTrailService.js');
6
6
  var sessionMemoryStore = require('./sessionMemoryStore.js');
7
7
 
8
- /**
9
- * Fetches session data by ID from the Datakeen backend
10
- *
11
- * @param sessionId - The unique identifier of the session
12
- * @returns The session data
13
- */
8
+ /** Reports camera diagnostics without updating local session state. */
9
+ function reportCaptureDiagnostics(sessionId, nodeId, diag) {
10
+ return tslib_es6.__awaiter(this, void 0, void 0, function () {
11
+ var _a;
12
+ return tslib_es6.__generator(this, function (_b) {
13
+ switch (_b.label) {
14
+ case 0: return [4 /*yield*/, api.apiService.patch("/session/sdk/".concat(sessionId), { captureDiagnostics: (_a = {}, _a[nodeId] = diag, _a) })];
15
+ case 1:
16
+ _b.sent();
17
+ return [2 /*return*/];
18
+ }
19
+ });
20
+ });
21
+ }
22
+ /** Fetches session data by ID from the Datakeen backend. */
14
23
  var fetchSessionById = function (sessionId) { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
15
24
  var response, error_1;
16
25
  return tslib_es6.__generator(this, function (_a) {
@@ -518,6 +527,7 @@ exports.getRunPrefillData = getRunPrefillData;
518
527
  exports.hasOutgoingEdgeForHandle = hasOutgoingEdgeForHandle;
519
528
  exports.isSessionExpired = isSessionExpired;
520
529
  exports.reconstructHistoryToStep = reconstructHistoryToStep;
530
+ exports.reportCaptureDiagnostics = reportCaptureDiagnostics;
521
531
  exports.reportSelfieFailure = reportSelfieFailure;
522
532
  exports.resetNfcScan = resetNfcScan;
523
533
  exports.sendClientInfo = sendClientInfo;
@@ -16,6 +16,15 @@ var isS3UploadNotConfirmedError = function (error) {
16
16
  return (apiError.details.code ===
17
17
  S3_UPLOAD_NOT_CONFIRMED_CODE);
18
18
  };
19
+ // Code SDK interne : l'analyse s'est terminée en `error`/`failed` côté moteur
20
+ // (posé par pollingService). Distinct d'un simple timeout de polling, où le
21
+ // backend peut encore produire un résultat.
22
+ var ANALYSIS_FAILED_CODE = "ANALYSIS_FAILED";
23
+ var isAnalysisFailedError = function (error) {
24
+ return typeof error === "object" &&
25
+ error !== null &&
26
+ error.code === ANALYSIS_FAILED_CODE;
27
+ };
19
28
  // Must stay aligned with QUOTA_EXCEEDED_CODE in the backend
20
29
  // (src/common/constants/quota-exceeded.constant.ts).
21
30
  var QUOTA_EXCEEDED_CODE = "QUOTA_EXCEEDED";
@@ -51,10 +60,12 @@ var isServiceErrorCode = function (code) {
51
60
  /** Same as getServiceErrorCode, from the polled fallback document codeName. */
52
61
  var getServiceErrorCodeFromCodeName = function (codeName) { var _a; return typeof codeName === "string" ? (_a = SERVICE_ERROR_CODE_NAMES[codeName]) !== null && _a !== void 0 ? _a : null : null; };
53
62
 
63
+ exports.ANALYSIS_FAILED_CODE = ANALYSIS_FAILED_CODE;
54
64
  exports.INSUFFICIENT_CREDITS_CODE = INSUFFICIENT_CREDITS_CODE;
55
65
  exports.QUOTA_EXCEEDED_CODE = QUOTA_EXCEEDED_CODE;
56
66
  exports.S3_UPLOAD_NOT_CONFIRMED_CODE = S3_UPLOAD_NOT_CONFIRMED_CODE;
57
67
  exports.getServiceErrorCode = getServiceErrorCode;
58
68
  exports.getServiceErrorCodeFromCodeName = getServiceErrorCodeFromCodeName;
69
+ exports.isAnalysisFailedError = isAnalysisFailedError;
59
70
  exports.isS3UploadNotConfirmedError = isS3UploadNotConfirmedError;
60
71
  exports.isServiceErrorCode = isServiceErrorCode;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var HD_MIN = { long: 1280, short: 720 };
4
+ function isBelowHd(settings) {
5
+ var _a = settings !== null && settings !== void 0 ? settings : {}, width = _a.width, height = _a.height;
6
+ if (!width || !height)
7
+ return false;
8
+ return Math.max(width, height) < HD_MIN.long || Math.min(width, height) < HD_MIN.short;
9
+ }
10
+
11
+ exports.HD_MIN = HD_MIN;
12
+ exports.isBelowHd = isBelowHd;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * APP3-2142 — Champs de formulaire standard que le backend pré-remplit à la racine de
5
+ * userInput à partir d'un champ extrait coché sur un nœud collecte de documents.
6
+ * Jumeaux : backend `extracted-user-input-copy.ts` (EXTRACTED_COPY_TARGETS), front `utils/extractedCopy.ts`.
7
+ */
8
+ var EXTRACTED_COPY_TARGETS = new Set([
9
+ "firstName",
10
+ "lastName",
11
+ "birthDate",
12
+ "nationality",
13
+ "email",
14
+ "phoneNumber",
15
+ "addressLine1",
16
+ "addressLine2",
17
+ "postalCode",
18
+ "city",
19
+ "countryCode",
20
+ "companyName",
21
+ "registrationNumber",
22
+ "siret",
23
+ "tva",
24
+ "legalRepresentativeFirstName",
25
+ "legalRepresentativeLastName",
26
+ ]);
27
+ /** Champs extraits dont la clé diffère du champ de formulaire qu'ils pré-remplissent. */
28
+ var ROOT_ALIASES = {
29
+ rcs: "registrationNumber",
30
+ siren: "registrationNumber",
31
+ };
32
+ /** Champ de formulaire (racine de userInput) que pré-remplit un champ extrait, s'il y en a un. */
33
+ function extractedRootTarget(field) {
34
+ var _a;
35
+ return (_a = ROOT_ALIASES[field]) !== null && _a !== void 0 ? _a : (EXTRACTED_COPY_TARGETS.has(field) ? field : undefined);
36
+ }
37
+
38
+ exports.extractedRootTarget = extractedRootTarget;
@@ -15,8 +15,9 @@ var CONSOLIDATED_RESULT_STATUSES = new Set([
15
15
  * true si la session est terminée (écran de fin), qu'elle porte encore le
16
16
  * statut brut "ended" ou déjà un statut de résultat consolidé.
17
17
  *
18
- * Ne PAS confondre avec "conform" : posé par SignatureElectronic juste après
19
- * la signature, avant le vrai nœud "end" — ce n'est pas une fin de parcours.
18
+ * Ne PAS confondre avec "conform" : posé juste après la signature par les
19
+ * anciennes versions du SDK (la signature ne modifie plus le statut depuis
20
+ * APP3-1996), avant le vrai nœud "end" — ce n'est pas une fin de parcours.
20
21
  */
21
22
  var isSessionFinished = function (status) {
22
23
  if (!status)
@@ -304,7 +304,7 @@ var DocumentCollection = function (_a) {
304
304
  case "before-recto":
305
305
  return jsx(BeforePhoto, { setStep: function () { return setPhotoSubStep("recto"); }, isSingleSided: !requiresTwoSides_1, onBack: handleBack });
306
306
  case "recto":
307
- return jsx(Photo, { onCapture: function (img) { return handlePhotoCapture(img, "recto"); }, automaticCapture: false, maskType: "document" });
307
+ return jsx(Photo, { sessionId: sessionId, nodeId: node.id, onCapture: function (img) { return handlePhotoCapture(img, "recto"); }, automaticCapture: false, maskType: "document" });
308
308
  case "preview-recto":
309
309
  return (jsx(PhotoPreview, { imageUrl: capturedImages.recto, side: "recto", isSingleSided: !requiresTwoSides_1, onValidate: function () { return setPhotoSubStep(requiresTwoSides_1 ? "before-verso" : "confirmation"); }, onRetake: function () {
310
310
  setCapturedImages(function (prev) { var next = __assign({}, prev); delete next.recto; return next; });
@@ -313,7 +313,7 @@ var DocumentCollection = function (_a) {
313
313
  case "before-verso":
314
314
  return jsx(BeforeVersoPhoto, { setStep: function () { return setPhotoSubStep("verso"); } });
315
315
  case "verso":
316
- return jsx(Photo, { onCapture: function (img) { return handlePhotoCapture(img, "verso"); }, automaticCapture: false, maskType: "document" });
316
+ return jsx(Photo, { sessionId: sessionId, nodeId: node.id, onCapture: function (img) { return handlePhotoCapture(img, "verso"); }, automaticCapture: false, maskType: "document" });
317
317
  case "preview-verso":
318
318
  return (jsx(PhotoPreview, { imageUrl: capturedImages.verso, side: "verso", onValidate: function () { return setPhotoSubStep("confirmation"); }, onRetake: function () {
319
319
  setCapturedImages(function (prev) { var next = __assign({}, prev); delete next.verso; return next; });
@@ -6,7 +6,7 @@ import Subtitle from '../ui/Subtitle.js';
6
6
  import { useI18n } from '../../hooks/useI18n.js';
7
7
  import { analyzeFiles } from '../../services/analysis.js';
8
8
  import { getActiveSessionId } from '../../services/sessionMemoryStore.js';
9
- import { getServiceErrorCodeFromCodeName, isS3UploadNotConfirmedError, getServiceErrorCode } from '../../utils/analysisErrors.js';
9
+ import { getServiceErrorCodeFromCodeName, isS3UploadNotConfirmedError, getServiceErrorCode, isAnalysisFailedError } from '../../utils/analysisErrors.js';
10
10
 
11
11
  // Localized processing steps generator
12
12
  var getProcessingSteps = function (t) { return [
@@ -230,7 +230,9 @@ var DocumentProcessing = memo(function (_a) {
230
230
  },
231
231
  ]
232
232
  : undefined,
233
- canRetry: isUploadNotConfirmed || !!serviceErrorCode,
233
+ canRetry: isUploadNotConfirmed ||
234
+ !!serviceErrorCode ||
235
+ isAnalysisFailedError(error_1),
234
236
  blockContinue: isUploadNotConfirmed,
235
237
  });
236
238
  setIsComplete(true);
@@ -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), 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];
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 _r = useState(null); _r[0]; var setLastCaptureMeta = _r[1];
30
- var _s = useState(null), maskRect = _s[0], setMaskRect = _s[1];
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
- return __generator(this, function (_a) {
221
- switch (_a.label) {
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 = _a.sent();
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
- 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
- });
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
  };
@@ -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, getServiceErrorCodeFromCodeName } from '../../utils/analysisErrors.js';
11
+ import { isS3UploadNotConfirmedError, getServiceErrorCode, isAnalysisFailedError, 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,7 +316,12 @@ var JDIProcessing = memo(function (_a) {
316
316
  },
317
317
  ]
318
318
  : undefined,
319
- canRetry: isNetworkError || isUploadNotConfirmed || !!serviceErrorCode,
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),
320
325
  blockContinue: isUploadNotConfirmed,
321
326
  });
322
327
  setIsComplete(true);
@@ -31,11 +31,10 @@ var NfcScanStep = function (_a) {
31
31
  // Sur mobile, on ouvre directement l'app de scan au lieu d'afficher un QR code inutile.
32
32
  var isMobile = useMemo(function () { return isMobileDevice(); }, []);
33
33
  var isIOS = useMemo(function () { return isIOSDevice(); }, []);
34
- var nfcUrl = useMemo(function () {
35
- var origin = typeof window !== "undefined" ? window.location.origin : "";
36
- return "".concat(origin, "/scan/").concat(sessionId);
37
- }, [sessionId]);
38
34
  var apiBaseUrl = useMemo(function () { return getBaseURL(); }, []);
35
+ // Domaine Datakeen (celui de l'API), pas celui de la page hôte : seul lui sert l'AASA qui
36
+ // déclenche l'App Clip iOS. Sur un site intégrateur, l'origine de la page ouvrait le navigateur.
37
+ var nfcUrl = useMemo(function () { return "".concat(new URL(apiBaseUrl, window.location.href).origin, "/scan/").concat(sessionId); }, [apiBaseUrl, sessionId]);
39
38
  var iosAppLinks = useMemo(function () {
40
39
  var host = new URL(apiBaseUrl, window.location.href).host;
41
40
  // `return` : l'app rouvre exactement cette URL en fin de scan, ce qui ramène Safari sur cet
@@ -776,13 +776,13 @@ var DocumentCheck = function (_a) {
776
776
  return (jsx(BeforePhoto, { setStep: function () { return setCurrentPhotoStep("recto"); }, isSingleSided: isSingleSided, onBack: function () { return setDocStep(2); } }));
777
777
  }
778
778
  if (currentPhotoStep === "recto") {
779
- return (jsx(Photo, { onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
779
+ return (jsx(Photo, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "recto"); } }));
780
780
  }
781
781
  if (currentPhotoStep === "before-verso") {
782
782
  return (jsx(BeforeVersoPhoto, { setStep: function () { return setCurrentPhotoStep("verso"); } }));
783
783
  }
784
784
  if (currentPhotoStep === "verso") {
785
- return (jsx(Photo, { onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
785
+ return (jsx(Photo, { sessionId: sessionId, nodeId: node.id, onCapture: function (imageData) { return handlePhotoCapture(imageData, "verso"); } }));
786
786
  }
787
787
  if (currentPhotoStep === "confirmation") {
788
788
  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 }));
@@ -1,4 +1,3 @@
1
- import { __awaiter, __generator } from '../../node_modules/tslib/tslib.es6.js';
2
1
  import { jsx, jsxs } from 'react/jsx-runtime';
3
2
  import { useMemo, useState, useEffect } from 'react';
4
3
  import { useTranslation } from 'react-i18next';
@@ -6,7 +5,6 @@ import sdkI18n from '../../i18n/index.js';
6
5
  import SignatureElectronicIntroduction from './SignatureElectronicIntroduction.js';
7
6
  import DocusealSignature from './DocusealSignature.js';
8
7
  import SignedDocumentPreview from './SignedDocumentPreview.js';
9
- import { updateSessionStatus } from '../../services/sessionService.js';
10
8
 
11
9
  /**
12
10
  * Maps an InformationFieldKey (journey field) to the corresponding UserInput key.
@@ -86,34 +84,19 @@ var SignatureElectronic = function (_a) {
86
84
  var handleContinue = function () {
87
85
  setShowSignature(true);
88
86
  };
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
- }); };
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
+ };
117
100
  var handleContinueFromPreview = function () {
118
101
  // Progress to the next step via graph edges (pas d'arithmétique — évite de sauter dans la mauvaise branche)
119
102
  stepObject.goToNextStep(node.id, session.template);