datakeen-session-react 1.1.202-dev.1 → 1.1.202-dev.11

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 (33) hide show
  1. package/dist/cjs/components/document-collection/DocumentError.js +18 -14
  2. package/dist/cjs/components/document-collection/DocumentProcessing.js +3 -1
  3. package/dist/cjs/components/jdi/JDIError.js +16 -12
  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 +25 -9
  7. package/dist/cjs/components/session/controleJdiPolicy.js +6 -1
  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/hooks/useStepNavigation.js +9 -1
  11. package/dist/cjs/hooks/useUserInputForm.js +42 -0
  12. package/dist/cjs/services/analysis.js +7 -0
  13. package/dist/cjs/services/pollingService.js +4 -1
  14. package/dist/cjs/services/sessionService.js +4 -4
  15. package/dist/cjs/utils/analysisErrors.js +11 -0
  16. package/dist/cjs/utils/sessionStatus.js +3 -2
  17. package/dist/esm/components/document-collection/DocumentError.js +18 -14
  18. package/dist/esm/components/document-collection/DocumentProcessing.js +4 -2
  19. package/dist/esm/components/jdi/JDIError.js +16 -12
  20. package/dist/esm/components/jdi/JDIProcessing.js +7 -2
  21. package/dist/esm/components/nfc-scan/NfcScanNode.js +3 -4
  22. package/dist/esm/components/session/DocumentCheck.js +25 -9
  23. package/dist/esm/components/session/controleJdiPolicy.js +6 -1
  24. package/dist/esm/components/signature-electronic/SignatureElectronic.js +13 -30
  25. package/dist/esm/components/template/ExternalVerificationNodeHandler.js +94 -63
  26. package/dist/esm/hooks/useStepNavigation.js +9 -1
  27. package/dist/esm/hooks/useUserInputForm.js +42 -0
  28. package/dist/esm/services/analysis.js +7 -0
  29. package/dist/esm/services/pollingService.js +4 -1
  30. package/dist/esm/services/sessionService.js +4 -4
  31. package/dist/esm/utils/analysisErrors.js +10 -1
  32. package/dist/esm/utils/sessionStatus.js +3 -2
  33. package/package.json +2 -1
@@ -13,6 +13,7 @@ var labelToKey = require('../utils/labelToKey.js');
13
13
  var session = require('../types/session.js');
14
14
  var useI18n = require('./useI18n.js');
15
15
  var auditTrailService = require('../services/auditTrailService.js');
16
+ var sessionService = require('../services/sessionService.js');
16
17
 
17
18
  var useUserInputForm = function (_a) {
18
19
  var stepObject = _a.stepObject, setUserInput = _a.setUserInput, initialUserInput = _a.initialUserInput, node = _a.node, template = _a.template, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo, onContinueCallback = _a.onContinueCallback, sessionId = _a.sessionId;
@@ -269,6 +270,47 @@ var useUserInputForm = function (_a) {
269
270
  form.phoneNumber,
270
271
  form.companyName,
271
272
  ]);
273
+ // APP3-2020 — le serveur reporte prénom, nom et date de naissance lus sur la pièce
274
+ // à la racine de userInput après l'analyse : absents de la mémoire du SDK, on les
275
+ // relit à l'ouverture du formulaire personne physique (une fois par nœud, remount
276
+ // par key). Seules les clés vides sont complétées ; l'effet ci-dessus re-synchronise.
277
+ React.useEffect(function () {
278
+ var _a;
279
+ if (informationType !== "identity" ||
280
+ !sessionId ||
281
+ (initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.firstName) ||
282
+ (initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.lastName) ||
283
+ !((_a = template === null || template === void 0 ? void 0 : template.nodes) !== null && _a !== void 0 ? _a : []).some(function (n) {
284
+ return (n.type === "controle-jdi" || n.type === "identity-control") &&
285
+ n.copyIdentityToUserInput === true;
286
+ })) {
287
+ return;
288
+ }
289
+ var cancelled = false;
290
+ sessionService.fetchSessionById(sessionId)
291
+ .then(function (fresh) {
292
+ var _a;
293
+ var server = ((_a = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) !== null && _a !== void 0 ? _a : {});
294
+ var fill = ["firstName", "lastName", "birthDate"].filter(function (key) { return typeof server[key] === "string" && server[key]; });
295
+ if (cancelled || !fill.length)
296
+ return;
297
+ setUserInput(function (prev) {
298
+ var next = tslib_es6.__assign({}, prev);
299
+ for (var _i = 0, fill_1 = fill; _i < fill_1.length; _i++) {
300
+ var key = fill_1[_i];
301
+ if (!next[key])
302
+ next[key] = server[key];
303
+ }
304
+ return next;
305
+ });
306
+ })
307
+ .catch(function (error) {
308
+ console.warn("[UserInputForm] Identité reportée indisponible", error);
309
+ });
310
+ return function () {
311
+ cancelled = true;
312
+ };
313
+ }, []); // Une seule relecture à l'ouverture du nœud.
272
314
  // Re-synchronise customFormData depuis initialUserInput quand on (ré)affiche un
273
315
  // nœud DIFFÉRENT sur une instance réutilisée (retour arrière sans remount).
274
316
  // Le champ form standard a déjà son propre effet de re-sync ci-dessus ; le
@@ -7,6 +7,7 @@ var api = require('./api.js');
7
7
  var sessionMemoryStore = require('./sessionMemoryStore.js');
8
8
  var auditTrailService = require('./auditTrailService.js');
9
9
  var pollingService = require('./pollingService.js');
10
+ var analysisErrors = require('../utils/analysisErrors.js');
10
11
 
11
12
  // Timeout configurations (in milliseconds)
12
13
  var ANALYSIS_TIMEOUT = 600000; // 10 minutes for document analysis (increased for large files + ML processing)
@@ -248,6 +249,10 @@ function analyzeFiles(sessionId_1, nodeId_1, files_1, documentTypeId_1) {
248
249
  return [2 /*return*/, pollingResult];
249
250
  case 7:
250
251
  pollError_1 = _a.sent();
252
+ // Une analyse terminée en erreur doit bloquer le nœud : seule une
253
+ // panne du polling (timeout, réseau) laisse le backend finir.
254
+ if (analysisErrors.isAnalysisFailedError(pollError_1))
255
+ throw pollError_1;
251
256
  console.warn("⚠️ Polling error (analysis may still be processing):", pollError_1);
252
257
  // Don't throw - polling error shouldn't fail the analysis submission
253
258
  // The backend is still processing even if polling fails
@@ -509,6 +514,8 @@ function analyzeDocumentVideo(sessionId_1, nodeId_1, videoData_1, previews_1, do
509
514
  return [2 /*return*/, pollingResult];
510
515
  case 5:
511
516
  pollError_2 = _k.sent();
517
+ if (analysisErrors.isAnalysisFailedError(pollError_2))
518
+ throw pollError_2;
512
519
  console.warn("⚠️ Polling error (document-video may still be processing):", pollError_2);
513
520
  return [3 /*break*/, 6];
514
521
  case 6:
@@ -2,6 +2,7 @@
2
2
 
3
3
  var tslib_es6 = require('../node_modules/tslib/tslib.es6.js');
4
4
  var api = require('./api.js');
5
+ var analysisErrors = require('../utils/analysisErrors.js');
5
6
 
6
7
  var pollingTimeoutId = null;
7
8
  var pollingStartTime = 0;
@@ -107,7 +108,9 @@ function pollAnalysisStatus(sessionId_1) {
107
108
  }
108
109
  isPollingActive = false;
109
110
  pollingTimeoutId = null;
110
- reject(new Error("Analysis failed: ".concat(userMessage)));
111
+ reject(Object.assign(new Error("Analysis failed: ".concat(userMessage)), {
112
+ code: analysisErrors.ANALYSIS_FAILED_CODE,
113
+ }));
111
114
  return [2 /*return*/];
112
115
  }
113
116
  // Analysis completed successfully (approved, rejected, to_verify, or completed)
@@ -202,17 +202,17 @@ var updateSessionStatus = function (sessionId, status, reachedEndNodeId) { retur
202
202
  *
203
203
  * @param sessionId - The unique identifier of the session
204
204
  * @param currentStep - The current step index in the workflow
205
+ * @param currentNodeId - Stable id of the journey node at this step, when there is one
206
+ * (none for the welcome and QR screens). The backend timestamps the node entry.
205
207
  * @returns The updated session data
206
208
  */
207
- var updateSessionCurrentStep = function (sessionId, currentStep) { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
209
+ var updateSessionCurrentStep = function (sessionId, currentStep, currentNodeId) { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
208
210
  var response, error_6;
209
211
  return tslib_es6.__generator(this, function (_a) {
210
212
  switch (_a.label) {
211
213
  case 0:
212
214
  _a.trys.push([0, 2, , 3]);
213
- return [4 /*yield*/, api.apiService.patch("/session/sdk/".concat(sessionId), {
214
- currentStep: currentStep,
215
- })];
215
+ return [4 /*yield*/, api.apiService.patch("/session/sdk/".concat(sessionId), tslib_es6.__assign({ currentStep: currentStep }, (currentNodeId ? { currentNodeId: currentNodeId } : {})))];
216
216
  case 1:
217
217
  response = _a.sent();
218
218
  return [2 /*return*/, response.data];
@@ -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;
@@ -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)
@@ -13,6 +13,9 @@ var DocumentError = function (_a) {
13
13
  // APP3-1955: a service refusal (no credits / quota) blocks the journey,
14
14
  // whatever node.allowContinueOnFailure says.
15
15
  var continueAnyway = isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
16
+ // Quota / plus de crédits : rien à corriger sur le document. Écran dédié
17
+ // (message de refus en tête), pas la structure d'un document rejeté.
18
+ var isServiceRefusal = !blockContinue && isServiceErrorCode(errorCode);
16
19
  var _f = useState([]), validationPoints = _f[0], setValidationPoints = _f[1];
17
20
  useEffect(function () {
18
21
  // Use shared utility to get validation points
@@ -46,22 +49,23 @@ var DocumentError = function (_a) {
46
49
  };
47
50
  return (jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsx("div", { className: "text-center", children: jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxs("div", { className: "text-center space-y-4", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: blockContinue
48
51
  ? t("errors.upload_not_confirmed.title")
49
- : t("errors.verification_failed", "Vérification échouée") }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
52
+ : isServiceRefusal
53
+ ? t("errors.service_refusal_title")
54
+ : t("errors.verification_failed", "Vérification échouée") }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
50
55
  ? t("errors.upload_not_confirmed.subtitle")
51
- : isRetryAllowed
52
- ? t("errors.verification_failed_subtitle", {
53
- documentType: getDocumentLabel(documentType),
54
- defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous et réessayer.",
55
- })
56
- : t("errors.verification_failed_subtitle_no_retry", {
57
- documentType: getDocumentLabel(documentType),
58
- defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous.",
59
- }) })] }), !blockContinue && (jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected", "Problèmes détectés") }), jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached", "Nombre maximum de tentatives atteint") }), jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
56
+ : isServiceRefusal
57
+ ? getUserGuidance()
58
+ : isRetryAllowed
59
+ ? t("errors.verification_failed_subtitle", {
60
+ documentType: getDocumentLabel(documentType),
61
+ defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous et réessayer.",
62
+ })
63
+ : t("errors.verification_failed_subtitle_no_retry", {
64
+ documentType: getDocumentLabel(documentType),
65
+ defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous.",
66
+ }) })] }), !blockContinue && !isServiceRefusal && (jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected", "Problèmes détectés") }), jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached", "Nombre maximum de tentatives atteint") }), jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
60
67
  ? t("errors.resubmission.max_attempts_reached_description")
61
- : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && getUserGuidance() && (jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: isServiceErrorCode(errorCode)
62
- ? // Quota / out of credits: nothing for the end user to improve.
63
- t("errors.service_refusal_title")
64
- : "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && isRetryAllowed && (jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps", "Prochaines étapes") }), jsx("p", { className: "text-sm text-blue-800", children: t("errors.next_steps_description", "Veuillez reprendre les photos de votre document en suivant les conseils d'amélioration pour une meilleure qualité.") })] }))] }) }), jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }), jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }) })] }) })] }));
68
+ : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && !isServiceRefusal && getUserGuidance() && (jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && !isServiceRefusal && isRetryAllowed && (jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps", "Prochaines étapes") }), jsx("p", { className: "text-sm text-blue-800", children: t("errors.next_steps_description", "Veuillez reprendre les photos de votre document en suivant les conseils d'amélioration pour une meilleure qualité.") })] }))] }) }), jsx("div", { className: "sticky bottom-0 md:static bg-white border-t md:border-t-0 p-4 md:p-0 md:pb-8", children: jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }), jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }) })] }) })] }));
65
69
  };
66
70
 
67
71
  export { DocumentError as default };
@@ -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);
@@ -17,6 +17,9 @@ var JDIError = function (_a) {
17
17
  // APP3-1955: a service refusal (no credits / quota) blocks the journey,
18
18
  // whatever node.allowContinueOnFailure says.
19
19
  var continueAnyway = isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
20
+ // Quota / plus de crédits : rien à corriger sur le document. Écran dédié
21
+ // (message de refus en tête), pas la structure d'un document rejeté.
22
+ var isServiceRefusal = !blockContinue && isServiceErrorCode(errorCode);
20
23
  var _g = useState([]), validationPoints = _g[0], setValidationPoints = _g[1];
21
24
  // Détail de mismatch d'identité (code 7.0), calculé côté backend et porté
22
25
  // par la première prédiction. Absent pour tous les autres codes.
@@ -34,20 +37,21 @@ var JDIError = function (_a) {
34
37
  };
35
38
  return (jsx(MobilePageLayout, { footer: jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsx(Button, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", className: "w-full text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.back_to_user_input") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", className: "w-full text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.continue_anyway") })), isRetryAllowed && (jsx(Button, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })), !isRetryAllowed && continueAnyway && (jsx(Button, { onClick: continueAnyway, className: "w-full py-3", children: t("errors.continue_anyway") }))] })) }), jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification") })) : (jsxs(Fragment, { children: [onBackToUserInput && (jsx(ButtonDesktop, { onClick: onBackToUserInput, type: "back", className: "text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.back_to_user_input") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "back", className: "text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.continue_anyway") })), isRetryAllowed && (jsx(ButtonDesktop, { onClick: onRetry, type: "continue", children: t("errors.retry_verification") })), !isRetryAllowed && continueAnyway && (jsx(ButtonDesktop, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway") }))] })) }) })] }), children: jsx("div", { className: "px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsx("div", { className: "text-center", children: jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxs("div", { className: "text-center space-y-4", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: blockContinue
36
39
  ? t("errors.upload_not_confirmed.title")
37
- : t("errors.verification_failed") }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
40
+ : isServiceRefusal
41
+ ? t("errors.service_refusal_title")
42
+ : t("errors.verification_failed") }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
38
43
  ? t("errors.upload_not_confirmed.subtitle")
39
- : isRetryAllowed
40
- ? t("errors.verification_failed_subtitle", {
41
- documentType: "document",
42
- })
43
- : t("errors.verification_failed_subtitle_no_retry", {
44
- documentType: "document",
45
- }) })] }), !blockContinue && (errorCode === null || errorCode === void 0 ? void 0 : errorCode.startsWith("8")) && (jsx("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: jsx("p", { className: "text-sm text-orange-800", children: t("errors.specimen_detected") }) })), !blockContinue && (jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected") }), jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached") }), jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
44
+ : isServiceRefusal
45
+ ? getUserGuidance()
46
+ : isRetryAllowed
47
+ ? t("errors.verification_failed_subtitle", {
48
+ documentType: "document",
49
+ })
50
+ : t("errors.verification_failed_subtitle_no_retry", {
51
+ documentType: "document",
52
+ }) })] }), !blockContinue && (errorCode === null || errorCode === void 0 ? void 0 : errorCode.startsWith("8")) && (jsx("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: jsx("p", { className: "text-sm text-orange-800", children: t("errors.specimen_detected") }) })), !blockContinue && !isServiceRefusal && (jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected") }), jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached") }), jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
46
53
  ? t("errors.resubmission.max_attempts_reached_description")
47
- : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && getUserGuidance() && (jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: isServiceErrorCode(errorCode)
48
- ? // Quota / out of credits: nothing for the end user to improve.
49
- t("errors.service_refusal_title")
50
- : "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && isRetryAllowed && (jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps") }), jsx("p", { className: "text-sm text-blue-800", children: t("errors.next_steps_description") })] }))] }) }) }));
54
+ : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && !isServiceRefusal && getUserGuidance() && (jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && !isServiceRefusal && isRetryAllowed && (jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps") }), jsx("p", { className: "text-sm text-blue-800", children: t("errors.next_steps_description") })] }))] }) }) }));
51
55
  };
52
56
 
53
57
  export { JDIError as default };
@@ -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
@@ -1,6 +1,7 @@
1
1
  import { __awaiter, __generator, __assign } from '../../node_modules/tslib/tslib.es6.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useEffect, useRef, useMemo } from 'react';
4
+ import { isServiceErrorCode } from '../../utils/analysisErrors.js';
4
5
  import JDIPreIntroduction from '../jdi/JDIPreIntroduction.js';
5
6
  import JDICountrySelection from '../jdi/JDICountrySelection.js';
6
7
  import JDIDocumentSelection from '../jdi/JDIDocumentSelection.js';
@@ -545,12 +546,21 @@ var DocumentCheck = function (_a) {
545
546
  setDocStep(5);
546
547
  }
547
548
  else {
548
- var newRetryCount = retryCount + 1;
549
- // Increment retry count both in state and session
550
- setRetryCount(newRetryCount);
551
- incrementNodeRetryCount(sessionId, node.id, retryCount).catch(function (error) {
552
- console.error("Failed to update retry count in session:", error);
553
- });
549
+ var failureCode = apiAnalysisData && apiAnalysisData.length > 0
550
+ ? apiAnalysisData[0].code
551
+ : (errorCode !== null && errorCode !== void 0 ? errorCode : undefined);
552
+ // Refus de service (quota du moteur / crédits épuisés) : le document n'y
553
+ // est pour rien. Ce n'est pas une resoumission consommée, et jamais de
554
+ // routage automatique : l'écran d'erreur explique le blocage.
555
+ var isServiceRefusal = isServiceErrorCode(failureCode);
556
+ var newRetryCount = isServiceRefusal ? retryCount : retryCount + 1;
557
+ if (!isServiceRefusal) {
558
+ // Increment retry count both in state and session
559
+ setRetryCount(newRetryCount);
560
+ incrementNodeRetryCount(sessionId, node.id, retryCount).catch(function (error) {
561
+ console.error("Failed to update retry count in session:", error);
562
+ });
563
+ }
554
564
  // Routage automatique vers la sortie "false" (nouveau) : uniquement
555
565
  // pour un véritable échec de code JDI bloquant (pas un souci d'upload
556
566
  // S3 non confirmé — cf. shouldBlockContinue), une fois les
@@ -558,9 +568,7 @@ var DocumentCheck = function (_a) {
558
568
  // Sinon, comportement legacy inchangé : écran d'erreur (retry et/ou
559
569
  // "continuer quand même" selon isRetryAllowed/allowContinueOnFailure).
560
570
  if (shouldBlockContinue !== true && template) {
561
- var currentCode = apiAnalysisData && apiAnalysisData.length > 0
562
- ? apiAnalysisData[0].code
563
- : (errorCode !== null && errorCode !== void 0 ? errorCode : undefined);
571
+ var currentCode = failureCode;
564
572
  var effectiveMaxAttempts = (currentCode === null || currentCode === void 0 ? void 0 : currentCode.startsWith("8")) || node.allowResubmission === false
565
573
  ? 0
566
574
  : ((_a = node.maxResubmissionAttempts) !== null && _a !== void 0 ? _a : Infinity);
@@ -568,6 +576,7 @@ var DocumentCheck = function (_a) {
568
576
  hasExceededAttempts: hasExceededResubmissionAttempts(newRetryCount, effectiveMaxAttempts),
569
577
  hasFalseEdge: hasOutgoingEdgeForHandle(node.id, template, "false"),
570
578
  action: normalizeMaxResubmissionAction(node.maxResubmissionAction),
579
+ isServiceRefusal: isServiceRefusal,
571
580
  });
572
581
  if (!route.showErrorScreen && route.handle) {
573
582
  stepObject.goToNextStep(node.id, template, route.handle);
@@ -601,6 +610,13 @@ var DocumentCheck = function (_a) {
601
610
  maxResubmissionAttempts: node.maxResubmissionAttempts,
602
611
  retryCount: retryCount,
603
612
  });
613
+ // Refus de service (quota / crédits) : réessayer reste possible (le quota
614
+ // peut se libérer) et ne consomme pas de resoumission ; « continuer quand
615
+ // même » est masqué par JDIError. Sans cela, l'utilisateur serait bloqué.
616
+ // `?? undefined` : passe une copie au garde de type pour ne pas réduire `errorCode` à `never` plus bas.
617
+ if (isServiceErrorCode(errorCode !== null && errorCode !== void 0 ? errorCode : undefined)) {
618
+ return true;
619
+ }
604
620
  // Specimen documents (code 8.x) block retry — user can only continue anyway
605
621
  if (errorCode === null || errorCode === void 0 ? void 0 : errorCode.startsWith("8")) {
606
622
  return false;
@@ -29,9 +29,14 @@ function hasExceededResubmissionAttempts(retryCountAfterFailure, maxAttempts) {
29
29
  * inchangé (rétrocompat totale, aucune navigation automatique).
30
30
  * - Échec épuisé, sortie "false" câblée → navigation automatique silencieuse
31
31
  * selon `action` (miroir de `conditionMaxRetryAction`).
32
+ * - Refus de service (quota / crédits) → toujours l'écran d'erreur : le
33
+ * parcours ne doit pas avancer sans que l'utilisateur sache pourquoi.
32
34
  */
33
35
  function resolveControleJdiOutcomeRoute(params) {
34
- var hasExceededAttempts = params.hasExceededAttempts, hasFalseEdge = params.hasFalseEdge, action = params.action;
36
+ var hasExceededAttempts = params.hasExceededAttempts, hasFalseEdge = params.hasFalseEdge, action = params.action, isServiceRefusal = params.isServiceRefusal;
37
+ if (isServiceRefusal) {
38
+ return { handle: undefined, showErrorScreen: true };
39
+ }
35
40
  if (!hasExceededAttempts || !hasFalseEdge) {
36
41
  return { handle: undefined, showErrorScreen: true };
37
42
  }
@@ -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);