datakeen-session-react 1.1.202-rc.3 → 1.1.202-rc.5

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.
@@ -17,6 +17,9 @@ var DocumentError = 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 = analysisErrors.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 && analysisErrors.isServiceErrorCode(errorCode);
20
23
  var _f = React.useState([]), validationPoints = _f[0], setValidationPoints = _f[1];
21
24
  React.useEffect(function () {
22
25
  // Use shared utility to get validation points
@@ -50,22 +53,23 @@ var DocumentError = function (_a) {
50
53
  };
51
54
  return (jsxRuntime.jsxs("div", { className: "flex flex-col justify-between h-full w-full", children: [jsxRuntime.jsx("div", { className: "flex-1 px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: blockContinue
52
55
  ? t("errors.upload_not_confirmed.title")
53
- : t("errors.verification_failed", "Vérification échouée") }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
56
+ : isServiceRefusal
57
+ ? t("errors.service_refusal_title")
58
+ : t("errors.verification_failed", "Vérification échouée") }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
54
59
  ? t("errors.upload_not_confirmed.subtitle")
55
- : isRetryAllowed
56
- ? t("errors.verification_failed_subtitle", {
57
- documentType: getDocumentLabel(documentType),
58
- defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous et réessayer.",
59
- })
60
- : t("errors.verification_failed_subtitle_no_retry", {
61
- documentType: getDocumentLabel(documentType),
62
- defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous.",
63
- }) })] }), !blockContinue && (jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected", "Problèmes détectés") }), jsxRuntime.jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsxRuntime.jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached", "Nombre maximum de tentatives atteint") }), jsxRuntime.jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
60
+ : isServiceRefusal
61
+ ? getUserGuidance()
62
+ : isRetryAllowed
63
+ ? t("errors.verification_failed_subtitle", {
64
+ documentType: getDocumentLabel(documentType),
65
+ defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous et réessayer.",
66
+ })
67
+ : t("errors.verification_failed_subtitle_no_retry", {
68
+ documentType: getDocumentLabel(documentType),
69
+ defaultValue: "Nous n'avons pas pu valider votre {{documentType}}. Veuillez vérifier les points ci-dessous.",
70
+ }) })] }), !blockContinue && !isServiceRefusal && (jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected", "Problèmes détectés") }), jsxRuntime.jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsxRuntime.jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached", "Nombre maximum de tentatives atteint") }), jsxRuntime.jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
64
71
  ? t("errors.resubmission.max_attempts_reached_description")
65
- : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && getUserGuidance() && (jsxRuntime.jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: analysisErrors.isServiceErrorCode(errorCode)
66
- ? // Quota / out of credits: nothing for the end user to improve.
67
- t("errors.service_refusal_title")
68
- : "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsxRuntime.jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps", "Prochaines étapes") }), jsxRuntime.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é.") })] }))] }) }), jsxRuntime.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: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [onBackToUserInput && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }), jsxRuntime.jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsxRuntime.jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [onBackToUserInput && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }) })] }) })] }));
72
+ : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && !isServiceRefusal && getUserGuidance() && (jsxRuntime.jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsxRuntime.jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && !isServiceRefusal && isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps", "Prochaines étapes") }), jsxRuntime.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é.") })] }))] }) }), jsxRuntime.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: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [onBackToUserInput && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }), jsxRuntime.jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsxRuntime.jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [onBackToUserInput && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onBackToUserInput, type: "back", children: t("errors.back_to_user_input", "Retour aux informations d'identité") })), retryCount >= 1 && isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", children: t("errors.continue_anyway", "Poursuivre tout de même") })), isRetryAllowed && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification", "Recommencer la vérification") })), !isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }) })] }) })] }));
69
73
  };
70
74
 
71
75
  exports.default = DocumentError;
@@ -21,6 +21,9 @@ var JDIError = function (_a) {
21
21
  // APP3-1955: a service refusal (no credits / quota) blocks the journey,
22
22
  // whatever node.allowContinueOnFailure says.
23
23
  var continueAnyway = analysisErrors.isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
24
+ // Quota / plus de crédits : rien à corriger sur le document. Écran dédié
25
+ // (message de refus en tête), pas la structure d'un document rejeté.
26
+ var isServiceRefusal = !blockContinue && analysisErrors.isServiceErrorCode(errorCode);
24
27
  var _g = React.useState([]), validationPoints = _g[0], setValidationPoints = _g[1];
25
28
  // Détail de mismatch d'identité (code 7.0), calculé côté backend et porté
26
29
  // par la première prédiction. Absent pour tous les autres codes.
@@ -38,20 +41,21 @@ var JDIError = function (_a) {
38
41
  };
39
42
  return (jsxRuntime.jsx(MobilePageLayout.default, { footer: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto", children: [jsxRuntime.jsx("div", { className: "flex flex-col space-y-3 md:hidden", children: blockContinue ? (jsxRuntime.jsx(Button.default, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [onBackToUserInput && (jsxRuntime.jsx(ButtonDesktop.default, { 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 && (jsxRuntime.jsx(ButtonDesktop.default, { 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 && (jsxRuntime.jsx(Button.default, { onClick: onRetry, className: "w-full py-3", children: t("errors.retry_verification") })), !isRetryAllowed && continueAnyway && (jsxRuntime.jsx(Button.default, { onClick: continueAnyway, className: "w-full py-3", children: t("errors.continue_anyway") }))] })) }), jsxRuntime.jsx("div", { className: "hidden md:flex flex-col space-y-3", children: jsxRuntime.jsx("div", { className: "flex justify-center space-x-3", children: blockContinue ? (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification") })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [onBackToUserInput && (jsxRuntime.jsx(ButtonDesktop.default, { 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 && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "back", className: "text-black text-center font-poppins text-sm font-medium py-2", children: t("errors.continue_anyway") })), isRetryAllowed && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onRetry, type: "continue", children: t("errors.retry_verification") })), !isRetryAllowed && continueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: continueAnyway, type: "continue", children: t("errors.continue_anyway") }))] })) }) })] }), children: jsxRuntime.jsx("div", { className: "px-4 py-6 pt-11 md:px-8 md:py-8", children: jsxRuntime.jsxs("div", { className: "w-full max-w-md mx-auto space-y-6", children: [jsxRuntime.jsx("div", { className: "text-center", children: jsxRuntime.jsx("div", { className: "mx-auto w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4", children: jsxRuntime.jsx("div", { className: "w-8 h-8 bg-red-500 rounded-full flex items-center justify-center", children: jsxRuntime.jsx("span", { className: "text-white text-lg", children: "\u2715" }) }) }) }), jsxRuntime.jsxs("div", { className: "text-center space-y-4", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl text-red-600", children: blockContinue
40
43
  ? t("errors.upload_not_confirmed.title")
41
- : t("errors.verification_failed") }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
44
+ : isServiceRefusal
45
+ ? t("errors.service_refusal_title")
46
+ : t("errors.verification_failed") }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
42
47
  ? t("errors.upload_not_confirmed.subtitle")
43
- : isRetryAllowed
44
- ? t("errors.verification_failed_subtitle", {
45
- documentType: "document",
46
- })
47
- : t("errors.verification_failed_subtitle_no_retry", {
48
- documentType: "document",
49
- }) })] }), !blockContinue && (errorCode === null || errorCode === void 0 ? void 0 : errorCode.startsWith("8")) && (jsxRuntime.jsx("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: jsxRuntime.jsx("p", { className: "text-sm text-orange-800", children: t("errors.specimen_detected") }) })), !blockContinue && (jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected") }), jsxRuntime.jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsxRuntime.jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached") }), jsxRuntime.jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
48
+ : isServiceRefusal
49
+ ? getUserGuidance()
50
+ : isRetryAllowed
51
+ ? t("errors.verification_failed_subtitle", {
52
+ documentType: "document",
53
+ })
54
+ : t("errors.verification_failed_subtitle_no_retry", {
55
+ documentType: "document",
56
+ }) })] }), !blockContinue && (errorCode === null || errorCode === void 0 ? void 0 : errorCode.startsWith("8")) && (jsxRuntime.jsx("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: jsxRuntime.jsx("p", { className: "text-sm text-orange-800", children: t("errors.specimen_detected") }) })), !blockContinue && !isServiceRefusal && (jsxRuntime.jsxs("div", { className: "bg-red-50 border border-red-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-red-900 mb-2", children: t("errors.problems_detected") }), jsxRuntime.jsx("div", { className: "text-sm text-red-800 space-y-1", children: validationPoints.map(function (point, index) { return (jsxRuntime.jsx("p", { children: point }, index)); }) })] })), !blockContinue && !isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-orange-900 mb-2", children: t("errors.resubmission.max_attempts_reached") }), jsxRuntime.jsx("p", { className: "text-sm text-orange-800", children: maxResubmissionAttempts !== undefined
50
57
  ? t("errors.resubmission.max_attempts_reached_description")
51
- : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && getUserGuidance() && (jsxRuntime.jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: analysisErrors.isServiceErrorCode(errorCode)
52
- ? // Quota / out of credits: nothing for the end user to improve.
53
- t("errors.service_refusal_title")
54
- : "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsxRuntime.jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps") }), jsxRuntime.jsx("p", { className: "text-sm text-blue-800", children: t("errors.next_steps_description") })] }))] }) }) }));
58
+ : t("errors.resubmission.no_resubmission_allowed") })] })), !blockContinue && !isServiceRefusal && getUserGuidance() && (jsxRuntime.jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-yellow-900 mb-2", children: "\uD83D\uDCA1 ".concat(t("errors.improvement_tips", "Conseils d'amélioration")) }), jsxRuntime.jsx("p", { className: "text-sm text-yellow-800", children: getUserGuidance() })] })), !blockContinue && !isServiceRefusal && isRetryAllowed && (jsxRuntime.jsxs("div", { className: "bg-blue-50 border border-blue-200 rounded-lg p-4", children: [jsxRuntime.jsx("h3", { className: "font-medium text-blue-900 mb-2", children: t("errors.next_steps") }), jsxRuntime.jsx("p", { className: "text-sm text-blue-800", children: t("errors.next_steps_description") })] }))] }) }) }));
55
59
  };
56
60
 
57
61
  exports.default = JDIError;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
+ var analysisErrors = require('../../utils/analysisErrors.js');
8
9
  var JDIPreIntroduction = require('../jdi/JDIPreIntroduction.js');
9
10
  var JDICountrySelection = require('../jdi/JDICountrySelection.js');
10
11
  var JDIDocumentSelection = require('../jdi/JDIDocumentSelection.js');
@@ -549,12 +550,21 @@ var DocumentCheck = function (_a) {
549
550
  setDocStep(5);
550
551
  }
551
552
  else {
552
- var newRetryCount = retryCount + 1;
553
- // Increment retry count both in state and session
554
- setRetryCount(newRetryCount);
555
- retryService.incrementNodeRetryCount(sessionId, node.id, retryCount).catch(function (error) {
556
- console.error("Failed to update retry count in session:", error);
557
- });
553
+ var failureCode = apiAnalysisData && apiAnalysisData.length > 0
554
+ ? apiAnalysisData[0].code
555
+ : (errorCode !== null && errorCode !== void 0 ? errorCode : undefined);
556
+ // Refus de service (quota du moteur / crédits épuisés) : le document n'y
557
+ // est pour rien. Ce n'est pas une resoumission consommée, et jamais de
558
+ // routage automatique : l'écran d'erreur explique le blocage.
559
+ var isServiceRefusal = analysisErrors.isServiceErrorCode(failureCode);
560
+ var newRetryCount = isServiceRefusal ? retryCount : retryCount + 1;
561
+ if (!isServiceRefusal) {
562
+ // Increment retry count both in state and session
563
+ setRetryCount(newRetryCount);
564
+ retryService.incrementNodeRetryCount(sessionId, node.id, retryCount).catch(function (error) {
565
+ console.error("Failed to update retry count in session:", error);
566
+ });
567
+ }
558
568
  // Routage automatique vers la sortie "false" (nouveau) : uniquement
559
569
  // pour un véritable échec de code JDI bloquant (pas un souci d'upload
560
570
  // S3 non confirmé — cf. shouldBlockContinue), une fois les
@@ -562,9 +572,7 @@ var DocumentCheck = function (_a) {
562
572
  // Sinon, comportement legacy inchangé : écran d'erreur (retry et/ou
563
573
  // "continuer quand même" selon isRetryAllowed/allowContinueOnFailure).
564
574
  if (shouldBlockContinue !== true && template) {
565
- var currentCode = apiAnalysisData && apiAnalysisData.length > 0
566
- ? apiAnalysisData[0].code
567
- : (errorCode !== null && errorCode !== void 0 ? errorCode : undefined);
575
+ var currentCode = failureCode;
568
576
  var effectiveMaxAttempts = (currentCode === null || currentCode === void 0 ? void 0 : currentCode.startsWith("8")) || node.allowResubmission === false
569
577
  ? 0
570
578
  : ((_a = node.maxResubmissionAttempts) !== null && _a !== void 0 ? _a : Infinity);
@@ -572,6 +580,7 @@ var DocumentCheck = function (_a) {
572
580
  hasExceededAttempts: controleJdiPolicy.hasExceededResubmissionAttempts(newRetryCount, effectiveMaxAttempts),
573
581
  hasFalseEdge: sessionService.hasOutgoingEdgeForHandle(node.id, template, "false"),
574
582
  action: controleJdiPolicy.normalizeMaxResubmissionAction(node.maxResubmissionAction),
583
+ isServiceRefusal: isServiceRefusal,
575
584
  });
576
585
  if (!route.showErrorScreen && route.handle) {
577
586
  stepObject.goToNextStep(node.id, template, route.handle);
@@ -605,6 +614,13 @@ var DocumentCheck = function (_a) {
605
614
  maxResubmissionAttempts: node.maxResubmissionAttempts,
606
615
  retryCount: retryCount,
607
616
  });
617
+ // Refus de service (quota / crédits) : réessayer reste possible (le quota
618
+ // peut se libérer) et ne consomme pas de resoumission ; « continuer quand
619
+ // même » est masqué par JDIError. Sans cela, l'utilisateur serait bloqué.
620
+ // `?? undefined` : passe une copie au garde de type pour ne pas réduire `errorCode` à `never` plus bas.
621
+ if (analysisErrors.isServiceErrorCode(errorCode !== null && errorCode !== void 0 ? errorCode : undefined)) {
622
+ return true;
623
+ }
608
624
  // Specimen documents (code 8.x) block retry — user can only continue anyway
609
625
  if (errorCode === null || errorCode === void 0 ? void 0 : errorCode.startsWith("8")) {
610
626
  return false;
@@ -31,9 +31,14 @@ function hasExceededResubmissionAttempts(retryCountAfterFailure, maxAttempts) {
31
31
  * inchangé (rétrocompat totale, aucune navigation automatique).
32
32
  * - Échec épuisé, sortie "false" câblée → navigation automatique silencieuse
33
33
  * selon `action` (miroir de `conditionMaxRetryAction`).
34
+ * - Refus de service (quota / crédits) → toujours l'écran d'erreur : le
35
+ * parcours ne doit pas avancer sans que l'utilisateur sache pourquoi.
34
36
  */
35
37
  function resolveControleJdiOutcomeRoute(params) {
36
- var hasExceededAttempts = params.hasExceededAttempts, hasFalseEdge = params.hasFalseEdge, action = params.action;
38
+ var hasExceededAttempts = params.hasExceededAttempts, hasFalseEdge = params.hasFalseEdge, action = params.action, isServiceRefusal = params.isServiceRefusal;
39
+ if (isServiceRefusal) {
40
+ return { handle: undefined, showErrorScreen: true };
41
+ }
37
42
  if (!hasExceededAttempts || !hasFalseEdge) {
38
43
  return { handle: undefined, showErrorScreen: true };
39
44
  }
@@ -8,6 +8,7 @@ var React = require('react');
8
8
  var reactI18next = require('react-i18next');
9
9
  var index = require('../../i18n/index.js');
10
10
  var api = require('../../services/api.js');
11
+ var sessionService = require('../../services/sessionService.js');
11
12
  var check = require('../../assets/check.svg.js');
12
13
  var LoadingState = require('../states/LoadingState.js');
13
14
  var Title = require('../ui/Title.js');
@@ -193,10 +194,10 @@ var ExternalVerificationNodeHandler = function (_a) {
193
194
  React.useEffect(function () {
194
195
  var abortController = new AbortController();
195
196
  var run = function () { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
196
- var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
197
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
198
- return tslib_es6.__generator(this, function (_w) {
199
- switch (_w.label) {
197
+ var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personRefId_1, personNodeInput_1, fromIdentityCopy, fresh, error_1, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
198
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
199
+ return tslib_es6.__generator(this, function (_y) {
200
+ switch (_y.label) {
200
201
  case 0:
201
202
  result = {
202
203
  isVerified: false,
@@ -210,9 +211,9 @@ var ExternalVerificationNodeHandler = function (_a) {
210
211
  submittedFirstName = '';
211
212
  submittedLastName = '';
212
213
  submittedSiren = '';
213
- _w.label = 1;
214
+ _y.label = 1;
214
215
  case 1:
215
- _w.trys.push([1, 9, , 10]);
216
+ _y.trys.push([1, 15, , 16]);
216
217
  if (!(session === null || session === void 0 ? void 0 : session.id))
217
218
  throw new Error('Session ID is missing');
218
219
  referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
@@ -223,7 +224,7 @@ var ExternalVerificationNodeHandler = function (_a) {
223
224
  message: 'External verification node is missing reference configuration.',
224
225
  errorCode: 'MISSING_REFERENCE_CONFIG',
225
226
  };
226
- return [3 /*break*/, 8];
227
+ return [3 /*break*/, 14];
227
228
  case 2:
228
229
  nodeInput = userInput[referenceNodeId];
229
230
  userInputFlat = userInput;
@@ -266,71 +267,101 @@ var ExternalVerificationNodeHandler = function (_a) {
266
267
  message: 'No SIREN/SIRET value found in source node data.',
267
268
  errorCode: 'REFERENCE_VALUE_NOT_FOUND',
268
269
  };
269
- return [3 /*break*/, 8];
270
+ return [3 /*break*/, 14];
270
271
  case 3:
271
272
  resolvedReferenceValue = referenceValue;
272
273
  referenceValueMasked = maskReferenceValue(referenceValue);
273
274
  comparisonConfig = void 0;
274
- if (isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId)) {
275
- cfg = nodeData.comparisonConfig;
276
- personNodeInput = (_e = userInput[cfg.personReferenceNodeId]) !== null && _e !== void 0 ? _e : {};
277
- flat = userInput;
278
- isPersonneMorale = cfg.personType === 'MORALE';
279
- if (isPersonneMorale) {
280
- sirenKeys = expandFieldKey((_f = cfg.personSirenField) !== null && _f !== void 0 ? _f : '').filter(Boolean);
281
- submittedSiren = (_g = resolveFieldValue(personNodeInput, flat, sirenKeys)) !== null && _g !== void 0 ? _g : '';
282
- if (submittedSiren) {
283
- comparisonConfig = {
284
- personType: 'MORALE',
285
- siren: submittedSiren,
286
- // Un RBE est toujours une personne physique en droit
287
- // français : forcé à 'mandataires' quel que soit le
288
- // contenu de cfg.compareTargets (défense en profondeur).
289
- compareTargets: ['mandataires'],
290
- };
291
- }
275
+ if (!(isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId))) return [3 /*break*/, 9];
276
+ cfg = nodeData.comparisonConfig;
277
+ personRefId_1 = cfg.personReferenceNodeId;
278
+ personNodeInput_1 = userInput[personRefId_1];
279
+ fromIdentityCopy = ((_f = (_e = session.template) === null || _e === void 0 ? void 0 : _e.nodes) !== null && _f !== void 0 ? _f : []).some(function (n) { return n.id === personRefId_1 &&
280
+ (n.type === 'controle-jdi' || n.type === 'identity-control') &&
281
+ n.copyIdentityToUserInput === true; });
282
+ if (!(fromIdentityCopy && !personNodeInput_1)) return [3 /*break*/, 8];
283
+ _y.label = 4;
284
+ case 4:
285
+ _y.trys.push([4, 6, , 7]);
286
+ return [4 /*yield*/, sessionService.fetchSessionById(session.id)];
287
+ case 5:
288
+ fresh = _y.sent();
289
+ personNodeInput_1 = (_g = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) === null || _g === void 0 ? void 0 : _g[personRefId_1];
290
+ if (personNodeInput_1) {
291
+ setUserInput(function (prev) {
292
+ var _a;
293
+ return (tslib_es6.__assign(tslib_es6.__assign({}, prev), (_a = {}, _a[personRefId_1] = personNodeInput_1, _a)));
294
+ });
295
+ }
296
+ return [3 /*break*/, 7];
297
+ case 6:
298
+ error_1 = _y.sent();
299
+ console.warn('[ExternalVerification] Identité reportée indisponible', error_1);
300
+ return [3 /*break*/, 7];
301
+ case 7:
302
+ if (abortController.signal.aborted)
303
+ return [2 /*return*/];
304
+ _y.label = 8;
305
+ case 8:
306
+ personNodeInput_1 = personNodeInput_1 !== null && personNodeInput_1 !== void 0 ? personNodeInput_1 : {};
307
+ flat = fromIdentityCopy ? {} : userInput;
308
+ isPersonneMorale = cfg.personType === 'MORALE';
309
+ if (isPersonneMorale) {
310
+ sirenKeys = expandFieldKey((_h = cfg.personSirenField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
311
+ submittedSiren = (_j = resolveFieldValue(personNodeInput_1, flat, sirenKeys)) !== null && _j !== void 0 ? _j : '';
312
+ if (submittedSiren) {
313
+ comparisonConfig = {
314
+ personType: 'MORALE',
315
+ siren: submittedSiren,
316
+ // Un RBE est toujours une personne physique en droit
317
+ // français : forcé à 'mandataires' quel que soit le
318
+ // contenu de cfg.compareTargets (défense en profondeur).
319
+ compareTargets: ['mandataires'],
320
+ };
292
321
  }
293
- else {
294
- firstNameKeys = expandFieldKey((_h = cfg.personFirstNameField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
295
- lastNameKeys = expandFieldKey((_j = cfg.personLastNameField) !== null && _j !== void 0 ? _j : '').filter(Boolean);
296
- birthDateKeys = cfg.personBirthDateField
297
- ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
298
- : [];
299
- submittedFirstName = (_k = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _k !== void 0 ? _k : '';
300
- submittedLastName = (_l = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _l !== void 0 ? _l : '';
301
- dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
302
- ? resolveFieldValue(personNodeInput, flat, birthDateKeys)
303
- : undefined;
304
- if (submittedFirstName && submittedLastName) {
305
- comparisonConfig = tslib_es6.__assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_m = cfg.compareTargets) !== null && _m !== void 0 ? _m : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
306
- }
322
+ }
323
+ else {
324
+ firstNameKeys = expandFieldKey((_k = cfg.personFirstNameField) !== null && _k !== void 0 ? _k : '').filter(Boolean);
325
+ lastNameKeys = expandFieldKey((_l = cfg.personLastNameField) !== null && _l !== void 0 ? _l : '').filter(Boolean);
326
+ birthDateKeys = cfg.personBirthDateField
327
+ ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
328
+ : [];
329
+ submittedFirstName = (_m = resolveFieldValue(personNodeInput_1, flat, firstNameKeys)) !== null && _m !== void 0 ? _m : '';
330
+ submittedLastName = (_o = resolveFieldValue(personNodeInput_1, flat, lastNameKeys)) !== null && _o !== void 0 ? _o : '';
331
+ dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
332
+ ? resolveFieldValue(personNodeInput_1, flat, birthDateKeys)
333
+ : undefined;
334
+ if (submittedFirstName && submittedLastName) {
335
+ comparisonConfig = tslib_es6.__assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_p = cfg.compareTargets) !== null && _p !== void 0 ? _p : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
307
336
  }
308
337
  }
338
+ _y.label = 9;
339
+ case 9:
309
340
  if (isInpiRbe)
310
341
  advanceStep(1);
311
- _w.label = 4;
312
- case 4:
313
- _w.trys.push([4, 7, , 8]);
342
+ _y.label = 10;
343
+ case 10:
344
+ _y.trys.push([10, 13, , 14]);
314
345
  return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), tslib_es6.__assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true, enableInseeFallback: isInpiRbe && nodeData.enableInseeFallback === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
315
- case 5:
316
- response = _w.sent();
346
+ case 11:
347
+ response = _y.sent();
317
348
  if (isInpiRbe)
318
349
  advanceStep(2);
319
350
  return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
320
- case 6:
321
- _w.sent();
322
- res = (_o = response.data) === null || _o === void 0 ? void 0 : _o.data;
351
+ case 12:
352
+ _y.sent();
353
+ res = (_q = response.data) === null || _q === void 0 ? void 0 : _q.data;
323
354
  if (res && typeof res.isVerified === 'boolean') {
324
355
  result = res;
325
356
  }
326
- return [3 /*break*/, 8];
327
- case 7:
328
- apiErr_1 = _w.sent();
357
+ return [3 /*break*/, 14];
358
+ case 13:
359
+ apiErr_1 = _y.sent();
329
360
  if (abortController.signal.aborted)
330
361
  return [2 /*return*/];
331
362
  if (isInpiRbe)
332
363
  advanceStep(2);
333
- apiResult = (_q = (_p = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.data;
364
+ apiResult = (_s = (_r = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.data;
334
365
  if (apiResult && typeof apiResult.isVerified === 'boolean') {
335
366
  result = apiResult;
336
367
  }
@@ -342,18 +373,18 @@ var ExternalVerificationNodeHandler = function (_a) {
342
373
  errorCode: 'REQUEST_FAILED',
343
374
  };
344
375
  }
345
- return [3 /*break*/, 8];
346
- case 8: return [3 /*break*/, 10];
347
- case 9:
348
- _w.sent();
376
+ return [3 /*break*/, 14];
377
+ case 14: return [3 /*break*/, 16];
378
+ case 15:
379
+ _y.sent();
349
380
  result = {
350
381
  isVerified: false,
351
382
  status: 'external_error',
352
383
  message: 'Unexpected error during verification.',
353
384
  errorCode: 'UNEXPECTED_ERROR',
354
385
  };
355
- return [3 /*break*/, 10];
356
- case 10:
386
+ return [3 /*break*/, 16];
387
+ case 16:
357
388
  if (abortController.signal.aborted)
358
389
  return [2 /*return*/];
359
390
  completeSteps();
@@ -385,13 +416,13 @@ var ExternalVerificationNodeHandler = function (_a) {
385
416
  // physique, tous les mandataires sont listés : une société
386
417
  // mandataire (ex. holding présidente) explique pourquoi la
387
418
  // personne saisie n'apparaît pas en direct au RNE.
388
- mandataires: ((_r = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _r !== void 0 ? _r : []).filter(function (m) {
419
+ mandataires: ((_t = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _t !== void 0 ? _t : []).filter(function (m) {
389
420
  return isPersonneMorale_1 ? m.type === 'personne_morale' : true;
390
421
  }),
391
- beneficiairesEffectifs: (_s = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _s !== void 0 ? _s : [],
392
- compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_t = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _t !== void 0 ? _t : ['mandataires']),
393
- personNodeId: (_u = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _u !== void 0 ? _u : '',
394
- targetDenomination: (_v = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _v === void 0 ? void 0 : _v.denomination,
422
+ beneficiairesEffectifs: (_u = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _u !== void 0 ? _u : [],
423
+ compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_v = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _v !== void 0 ? _v : ['mandataires']),
424
+ personNodeId: (_w = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _w !== void 0 ? _w : '',
425
+ targetDenomination: (_x = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _x === void 0 ? void 0 : _x.denomination,
395
426
  siren: resolvedReferenceValue,
396
427
  sirenNodeId: referenceNodeId,
397
428
  source: inpi === null || inpi === void 0 ? void 0 : inpi.source,
@@ -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 };
@@ -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 };
@@ -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
  }
@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import sdkI18n from '../../i18n/index.js';
6
6
  import { apiService } from '../../services/api.js';
7
+ import { fetchSessionById } from '../../services/sessionService.js';
7
8
  import checkIcon from '../../assets/check.svg.js';
8
9
  import LoadingState from '../states/LoadingState.js';
9
10
  import Title from '../ui/Title.js';
@@ -189,10 +190,10 @@ var ExternalVerificationNodeHandler = function (_a) {
189
190
  useEffect(function () {
190
191
  var abortController = new AbortController();
191
192
  var run = function () { return __awaiter(void 0, void 0, void 0, function () {
192
- var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
193
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
194
- return __generator(this, function (_w) {
195
- switch (_w.label) {
193
+ var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personRefId_1, personNodeInput_1, fromIdentityCopy, fresh, error_1, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
194
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
195
+ return __generator(this, function (_y) {
196
+ switch (_y.label) {
196
197
  case 0:
197
198
  result = {
198
199
  isVerified: false,
@@ -206,9 +207,9 @@ var ExternalVerificationNodeHandler = function (_a) {
206
207
  submittedFirstName = '';
207
208
  submittedLastName = '';
208
209
  submittedSiren = '';
209
- _w.label = 1;
210
+ _y.label = 1;
210
211
  case 1:
211
- _w.trys.push([1, 9, , 10]);
212
+ _y.trys.push([1, 15, , 16]);
212
213
  if (!(session === null || session === void 0 ? void 0 : session.id))
213
214
  throw new Error('Session ID is missing');
214
215
  referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
@@ -219,7 +220,7 @@ var ExternalVerificationNodeHandler = function (_a) {
219
220
  message: 'External verification node is missing reference configuration.',
220
221
  errorCode: 'MISSING_REFERENCE_CONFIG',
221
222
  };
222
- return [3 /*break*/, 8];
223
+ return [3 /*break*/, 14];
223
224
  case 2:
224
225
  nodeInput = userInput[referenceNodeId];
225
226
  userInputFlat = userInput;
@@ -262,71 +263,101 @@ var ExternalVerificationNodeHandler = function (_a) {
262
263
  message: 'No SIREN/SIRET value found in source node data.',
263
264
  errorCode: 'REFERENCE_VALUE_NOT_FOUND',
264
265
  };
265
- return [3 /*break*/, 8];
266
+ return [3 /*break*/, 14];
266
267
  case 3:
267
268
  resolvedReferenceValue = referenceValue;
268
269
  referenceValueMasked = maskReferenceValue(referenceValue);
269
270
  comparisonConfig = void 0;
270
- if (isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId)) {
271
- cfg = nodeData.comparisonConfig;
272
- personNodeInput = (_e = userInput[cfg.personReferenceNodeId]) !== null && _e !== void 0 ? _e : {};
273
- flat = userInput;
274
- isPersonneMorale = cfg.personType === 'MORALE';
275
- if (isPersonneMorale) {
276
- sirenKeys = expandFieldKey((_f = cfg.personSirenField) !== null && _f !== void 0 ? _f : '').filter(Boolean);
277
- submittedSiren = (_g = resolveFieldValue(personNodeInput, flat, sirenKeys)) !== null && _g !== void 0 ? _g : '';
278
- if (submittedSiren) {
279
- comparisonConfig = {
280
- personType: 'MORALE',
281
- siren: submittedSiren,
282
- // Un RBE est toujours une personne physique en droit
283
- // français : forcé à 'mandataires' quel que soit le
284
- // contenu de cfg.compareTargets (défense en profondeur).
285
- compareTargets: ['mandataires'],
286
- };
287
- }
271
+ if (!(isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId))) return [3 /*break*/, 9];
272
+ cfg = nodeData.comparisonConfig;
273
+ personRefId_1 = cfg.personReferenceNodeId;
274
+ personNodeInput_1 = userInput[personRefId_1];
275
+ fromIdentityCopy = ((_f = (_e = session.template) === null || _e === void 0 ? void 0 : _e.nodes) !== null && _f !== void 0 ? _f : []).some(function (n) { return n.id === personRefId_1 &&
276
+ (n.type === 'controle-jdi' || n.type === 'identity-control') &&
277
+ n.copyIdentityToUserInput === true; });
278
+ if (!(fromIdentityCopy && !personNodeInput_1)) return [3 /*break*/, 8];
279
+ _y.label = 4;
280
+ case 4:
281
+ _y.trys.push([4, 6, , 7]);
282
+ return [4 /*yield*/, fetchSessionById(session.id)];
283
+ case 5:
284
+ fresh = _y.sent();
285
+ personNodeInput_1 = (_g = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) === null || _g === void 0 ? void 0 : _g[personRefId_1];
286
+ if (personNodeInput_1) {
287
+ setUserInput(function (prev) {
288
+ var _a;
289
+ return (__assign(__assign({}, prev), (_a = {}, _a[personRefId_1] = personNodeInput_1, _a)));
290
+ });
291
+ }
292
+ return [3 /*break*/, 7];
293
+ case 6:
294
+ error_1 = _y.sent();
295
+ console.warn('[ExternalVerification] Identité reportée indisponible', error_1);
296
+ return [3 /*break*/, 7];
297
+ case 7:
298
+ if (abortController.signal.aborted)
299
+ return [2 /*return*/];
300
+ _y.label = 8;
301
+ case 8:
302
+ personNodeInput_1 = personNodeInput_1 !== null && personNodeInput_1 !== void 0 ? personNodeInput_1 : {};
303
+ flat = fromIdentityCopy ? {} : userInput;
304
+ isPersonneMorale = cfg.personType === 'MORALE';
305
+ if (isPersonneMorale) {
306
+ sirenKeys = expandFieldKey((_h = cfg.personSirenField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
307
+ submittedSiren = (_j = resolveFieldValue(personNodeInput_1, flat, sirenKeys)) !== null && _j !== void 0 ? _j : '';
308
+ if (submittedSiren) {
309
+ comparisonConfig = {
310
+ personType: 'MORALE',
311
+ siren: submittedSiren,
312
+ // Un RBE est toujours une personne physique en droit
313
+ // français : forcé à 'mandataires' quel que soit le
314
+ // contenu de cfg.compareTargets (défense en profondeur).
315
+ compareTargets: ['mandataires'],
316
+ };
288
317
  }
289
- else {
290
- firstNameKeys = expandFieldKey((_h = cfg.personFirstNameField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
291
- lastNameKeys = expandFieldKey((_j = cfg.personLastNameField) !== null && _j !== void 0 ? _j : '').filter(Boolean);
292
- birthDateKeys = cfg.personBirthDateField
293
- ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
294
- : [];
295
- submittedFirstName = (_k = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _k !== void 0 ? _k : '';
296
- submittedLastName = (_l = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _l !== void 0 ? _l : '';
297
- dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
298
- ? resolveFieldValue(personNodeInput, flat, birthDateKeys)
299
- : undefined;
300
- if (submittedFirstName && submittedLastName) {
301
- comparisonConfig = __assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_m = cfg.compareTargets) !== null && _m !== void 0 ? _m : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
302
- }
318
+ }
319
+ else {
320
+ firstNameKeys = expandFieldKey((_k = cfg.personFirstNameField) !== null && _k !== void 0 ? _k : '').filter(Boolean);
321
+ lastNameKeys = expandFieldKey((_l = cfg.personLastNameField) !== null && _l !== void 0 ? _l : '').filter(Boolean);
322
+ birthDateKeys = cfg.personBirthDateField
323
+ ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
324
+ : [];
325
+ submittedFirstName = (_m = resolveFieldValue(personNodeInput_1, flat, firstNameKeys)) !== null && _m !== void 0 ? _m : '';
326
+ submittedLastName = (_o = resolveFieldValue(personNodeInput_1, flat, lastNameKeys)) !== null && _o !== void 0 ? _o : '';
327
+ dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
328
+ ? resolveFieldValue(personNodeInput_1, flat, birthDateKeys)
329
+ : undefined;
330
+ if (submittedFirstName && submittedLastName) {
331
+ comparisonConfig = __assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_p = cfg.compareTargets) !== null && _p !== void 0 ? _p : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
303
332
  }
304
333
  }
334
+ _y.label = 9;
335
+ case 9:
305
336
  if (isInpiRbe)
306
337
  advanceStep(1);
307
- _w.label = 4;
308
- case 4:
309
- _w.trys.push([4, 7, , 8]);
338
+ _y.label = 10;
339
+ case 10:
340
+ _y.trys.push([10, 13, , 14]);
310
341
  return [4 /*yield*/, apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), __assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true, enableInseeFallback: isInpiRbe && nodeData.enableInseeFallback === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
311
- case 5:
312
- response = _w.sent();
342
+ case 11:
343
+ response = _y.sent();
313
344
  if (isInpiRbe)
314
345
  advanceStep(2);
315
346
  return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
316
- case 6:
317
- _w.sent();
318
- res = (_o = response.data) === null || _o === void 0 ? void 0 : _o.data;
347
+ case 12:
348
+ _y.sent();
349
+ res = (_q = response.data) === null || _q === void 0 ? void 0 : _q.data;
319
350
  if (res && typeof res.isVerified === 'boolean') {
320
351
  result = res;
321
352
  }
322
- return [3 /*break*/, 8];
323
- case 7:
324
- apiErr_1 = _w.sent();
353
+ return [3 /*break*/, 14];
354
+ case 13:
355
+ apiErr_1 = _y.sent();
325
356
  if (abortController.signal.aborted)
326
357
  return [2 /*return*/];
327
358
  if (isInpiRbe)
328
359
  advanceStep(2);
329
- apiResult = (_q = (_p = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.data;
360
+ apiResult = (_s = (_r = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.data;
330
361
  if (apiResult && typeof apiResult.isVerified === 'boolean') {
331
362
  result = apiResult;
332
363
  }
@@ -338,18 +369,18 @@ var ExternalVerificationNodeHandler = function (_a) {
338
369
  errorCode: 'REQUEST_FAILED',
339
370
  };
340
371
  }
341
- return [3 /*break*/, 8];
342
- case 8: return [3 /*break*/, 10];
343
- case 9:
344
- _w.sent();
372
+ return [3 /*break*/, 14];
373
+ case 14: return [3 /*break*/, 16];
374
+ case 15:
375
+ _y.sent();
345
376
  result = {
346
377
  isVerified: false,
347
378
  status: 'external_error',
348
379
  message: 'Unexpected error during verification.',
349
380
  errorCode: 'UNEXPECTED_ERROR',
350
381
  };
351
- return [3 /*break*/, 10];
352
- case 10:
382
+ return [3 /*break*/, 16];
383
+ case 16:
353
384
  if (abortController.signal.aborted)
354
385
  return [2 /*return*/];
355
386
  completeSteps();
@@ -381,13 +412,13 @@ var ExternalVerificationNodeHandler = function (_a) {
381
412
  // physique, tous les mandataires sont listés : une société
382
413
  // mandataire (ex. holding présidente) explique pourquoi la
383
414
  // personne saisie n'apparaît pas en direct au RNE.
384
- mandataires: ((_r = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _r !== void 0 ? _r : []).filter(function (m) {
415
+ mandataires: ((_t = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _t !== void 0 ? _t : []).filter(function (m) {
385
416
  return isPersonneMorale_1 ? m.type === 'personne_morale' : true;
386
417
  }),
387
- beneficiairesEffectifs: (_s = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _s !== void 0 ? _s : [],
388
- compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_t = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _t !== void 0 ? _t : ['mandataires']),
389
- personNodeId: (_u = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _u !== void 0 ? _u : '',
390
- targetDenomination: (_v = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _v === void 0 ? void 0 : _v.denomination,
418
+ beneficiairesEffectifs: (_u = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _u !== void 0 ? _u : [],
419
+ compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_v = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _v !== void 0 ? _v : ['mandataires']),
420
+ personNodeId: (_w = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _w !== void 0 ? _w : '',
421
+ targetDenomination: (_x = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _x === void 0 ? void 0 : _x.denomination,
391
422
  siren: resolvedReferenceValue,
392
423
  sirenNodeId: referenceNodeId,
393
424
  source: inpi === null || inpi === void 0 ? void 0 : inpi.source,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.202-rc.3",
3
+ "version": "1.1.202-rc.5",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",