datakeen-session-react 1.1.200 → 1.1.201

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.
package/README.md CHANGED
@@ -549,6 +549,17 @@ Voir [docs/JOURNEY_NODE_BUILDER.md](./docs/JOURNEY_NODE_BUILDER.md) pour la chec
549
549
 
550
550
  ---
551
551
 
552
+ ## Conformité des licences et SBOM
553
+
554
+ La CI refuse toute dépendance de production sous licence AGPL (**bloquant**) ou GPL (warning) qui n'est pas listée avec justification dans `license-allowlist.json`, et archive un SBOM CycloneDX (`sbom.cdx.json`) à chaque release (`dev`, `staging`, `main`).
555
+
556
+ ```bash
557
+ npm ci
558
+ node scripts/check-licenses.cjs # contrôle local
559
+ ```
560
+
561
+ Procédure complète (ajouter une exception, régénérer le SBOM) : [docs/LICENSE_COMPLIANCE.md](docs/LICENSE_COMPLIANCE.md).
562
+
552
563
  ## Support
553
564
 
554
565
  - **Email** : support@datakeen.co
@@ -14,6 +14,9 @@ var analysisErrors = require('../../utils/analysisErrors.js');
14
14
  var DocumentError = function (_a) {
15
15
  var documentType = _a.documentType, documentTypeLabel = _a.documentTypeLabel, onRetry = _a.onRetry, onContinueAnyway = _a.onContinueAnyway, onBackToUserInput = _a.onBackToUserInput, _b = _a.retryCount, retryCount = _b === void 0 ? 0 : _b, _c = _a.predictions, predictions = _c === void 0 ? [] : _c; _a.errorDetails; _a.allowResubmission; var maxResubmissionAttempts = _a.maxResubmissionAttempts, _d = _a.isRetryAllowed, isRetryAllowed = _d === void 0 ? true : _d, errorCode = _a.errorCode, _e = _a.blockContinue, blockContinue = _e === void 0 ? false : _e;
16
16
  var t = useI18n.useI18n().t;
17
+ // APP3-1955: a service refusal (no credits / quota) blocks the journey,
18
+ // whatever node.allowContinueOnFailure says.
19
+ var continueAnyway = analysisErrors.isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
17
20
  var _f = React.useState([]), validationPoints = _f[0], setValidationPoints = _f[1];
18
21
  React.useEffect(function () {
19
22
  // Use shared utility to get validation points
@@ -62,7 +65,7 @@ var DocumentError = function (_a) {
62
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)
63
66
  ? // Quota / out of credits: nothing for the end user to improve.
64
67
  t("errors.service_refusal_title")
65
- : "\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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, type: "continue", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }) })] }) })] }));
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") }))] })) }) })] }) })] }));
66
69
  };
67
70
 
68
71
  exports.default = DocumentError;
@@ -18,6 +18,9 @@ var JDIError = function (_a) {
18
18
  var _b;
19
19
  _a.documentType; var onRetry = _a.onRetry, onContinueAnyway = _a.onContinueAnyway, onBackToUserInput = _a.onBackToUserInput, _c = _a.retryCount, retryCount = _c === void 0 ? 0 : _c, _d = _a.predictions, predictions = _d === void 0 ? DEFAULT_PREDICTIONS : _d, errorCode = _a.errorCode; _a.allowResubmission; var maxResubmissionAttempts = _a.maxResubmissionAttempts, _e = _a.isRetryAllowed, isRetryAllowed = _e === void 0 ? true : _e, _f = _a.blockContinue, blockContinue = _f === void 0 ? false : _f;
20
20
  var t = useI18n.useI18n().t;
21
+ // APP3-1955: a service refusal (no credits / quota) blocks the journey,
22
+ // whatever node.allowContinueOnFailure says.
23
+ var continueAnyway = analysisErrors.isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
21
24
  var _g = React.useState([]), validationPoints = _g[0], setValidationPoints = _g[1];
22
25
  // Détail de mismatch d'identité (code 7.0), calculé côté backend et porté
23
26
  // par la première prédiction. Absent pour tous les autres codes.
@@ -33,7 +36,7 @@ var JDIError = function (_a) {
33
36
  var guidance = t("user_guidance.".concat(errorCode), "");
34
37
  return guidance || null;
35
38
  };
36
- 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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsxRuntime.jsx(Button.default, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsxRuntime.jsx(ButtonDesktop.default, { onClick: onContinueAnyway, 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
39
+ 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
37
40
  ? t("errors.upload_not_confirmed.title")
38
41
  : t("errors.verification_failed") }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
39
42
  ? t("errors.upload_not_confirmed.subtitle")
@@ -24,6 +24,7 @@ var NfcSuccessAnimation = require('./NfcSuccessAnimation.js');
24
24
  // choisir l'environnement (même rôle que `intent://<host>/scan/<id>` sur Android).
25
25
  var IOS_APP_SCHEME = "datakeenscannerswift";
26
26
  var IOS_APP_STORE_URL = "https://apps.apple.com/app/id6762505375";
27
+ var INSTALL_REVEAL_DELAY_MS = 2500;
27
28
  var NfcScanStep = function (_a) {
28
29
  var sessionId = _a.sessionId, nodeId = _a.nodeId, stepObject = _a.stepObject, template = _a.template, pageTitle = _a.pageTitle, pageDescription = _a.pageDescription, onBack = _a.onBack, onContinueWithoutChip = _a.onContinueWithoutChip;
29
30
  var t = useI18n.useI18n().t;
@@ -41,8 +42,11 @@ var NfcScanStep = function (_a) {
41
42
  var apiBaseUrl = React.useMemo(function () { return api.getBaseURL(); }, []);
42
43
  var iosAppLinks = React.useMemo(function () {
43
44
  var host = new URL(apiBaseUrl, window.location.href).host;
45
+ // `return` : l'app rouvre exactement cette URL en fin de scan, ce qui ramène Safari sur cet
46
+ // onglet (et non un nouvel onglet) quand l'URL est identique.
47
+ var returnUrl = encodeURIComponent(window.location.href);
44
48
  return {
45
- open: "".concat(IOS_APP_SCHEME, "://").concat(host, "/scan/").concat(sessionId),
49
+ open: "".concat(IOS_APP_SCHEME, "://").concat(host, "/scan/").concat(sessionId, "?return=").concat(returnUrl),
46
50
  // Lu par le bouton « Reprendre ma session » de l'app au premier lancement après installation.
47
51
  resume: "https://".concat(host, "/scan/").concat(sessionId),
48
52
  };
@@ -53,6 +57,20 @@ var NfcScanStep = function (_a) {
53
57
  var _a;
54
58
  (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(iosAppLinks.resume).catch(function () { return undefined; });
55
59
  };
60
+ // iOS ne permet pas de savoir si l'app est installée. Un seul bouton « Ouvrir » ; si la page est
61
+ // toujours visible après le délai (app absente : Safari affiche « adresse invalide »), on révèle
62
+ // « Installer ». Pas de redirection automatique vers l'App Store : pendant la confirmation iOS
63
+ // « Ouvrir dans ID Scan ? » la page reste visible, une redirection y enverrait à tort.
64
+ var _e = React.useState(false), showInstall = _e[0], setShowInstall = _e[1];
65
+ var installRevealTimerRef = React.useRef();
66
+ React.useEffect(function () { return function () { return clearTimeout(installRevealTimerRef.current); }; }, []);
67
+ var revealInstallIfAppDidNotOpen = function () {
68
+ clearTimeout(installRevealTimerRef.current);
69
+ installRevealTimerRef.current = setTimeout(function () {
70
+ if (document.visibilityState === "visible")
71
+ setShowInstall(true);
72
+ }, INSTALL_REVEAL_DELAY_MS);
73
+ };
56
74
  var status = useNfcSseStatus.useNfcSseStatus({
57
75
  sessionId: sessionId,
58
76
  apiBaseUrl: apiBaseUrl,
@@ -164,7 +182,7 @@ var NfcScanStep = function (_a) {
164
182
  return (jsxRuntime.jsx(MobilePageLayout.default, { footer: footer, 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.jsxs("div", { className: "text-center space-y-4 mt-16 md:mt-20", children: [jsxRuntime.jsx(Title.default, { className: "text-xl md:text-2xl lg:text-3xl", children: title }), jsxRuntime.jsx(Subtitle.default, { className: "text-sm md:text-base text-gray-600 leading-relaxed whitespace-pre-line", children: subtitle })] }), jsxRuntime.jsx("div", { className: "flex-1 flex flex-col justify-center items-center gap-4", children: status === "success" ? (jsxRuntime.jsx(NfcSuccessAnimation.default, {})) : status === "completed" ? (jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4 p-8", children: [jsxRuntime.jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.verifying", "Vérification en cours…") })] })) : status === "failed" ? (jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2 p-8 text-center", children: [jsxRuntime.jsx("p", { className: "text-base font-semibold text-red-600", children: t("nfc_scan.failed_title", "Le scan n'a pas pu être vérifié") }), jsxRuntime.jsx("p", { className: "text-sm text-gray-600 leading-relaxed", children: t("nfc_scan.failed_description", "Après plusieurs tentatives, la lecture de votre document n'a pas pu être validée.") }), resetError && (jsxRuntime.jsx("p", { className: "text-sm text-red-600", role: "alert", children: resetError }))] })) : (
165
183
  // Contenu principal QR/mobile — reste monté pour "pending" ET "opened", pour ne
166
184
  // jamais démonter le canvas déjà généré.
167
- jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [qrError ? (jsxRuntime.jsx("div", { className: "text-red-500 text-center p-4", children: qrError })) : isIOS ? (jsxRuntime.jsxs("div", { className: "flex w-full flex-col items-center gap-3 p-4 text-center", children: [jsxRuntime.jsx("a", { href: iosAppLinks.open, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] text-sm font-medium hover:brightness-110 active:brightness-90", style: { backgroundColor: "var(--dk-btn-bg)", color: "var(--dk-btn-text)" }, children: t("nfc_scan.open_app_link", "Ouvrir l'application") }), jsxRuntime.jsx("a", { href: IOS_APP_STORE_URL, onClick: copyResumeLink, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] border border-gray-300 text-sm font-medium text-gray-600 hover:bg-black/5", children: t("nfc_scan.install_app_link", "Installer l'application") }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.install_app_hint", "Après l'installation, revenez sur cette page et appuyez sur « Ouvrir l'application ».") })] })) : isMobile ? (jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4 p-8 text-center", children: [jsxRuntime.jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.opening_app", "Ouverture de l'application…") }), jsxRuntime.jsx("a", { href: nfcUrl, className: "text-sm font-medium text-blue-600 underline", children: t("nfc_scan.open_app_link", "Ouvrir l'application") })] })) : (jsxRuntime.jsx("div", { className: "bg-white p-4 rounded-lg shadow-lg border-2 border-gray-200", children: jsxRuntime.jsx("canvas", { ref: canvasRef }) })), status === "opened" && (jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [jsxRuntime.jsx("p", { className: "text-sm font-semibold", style: { color: "var(--uni-secondary-color, #0a9983)" }, children: t("nfc_scan.qr_opened_title", "QR code scanné") }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.qr_opened_description", "L'expérience NFC est ouverte sur votre smartphone. Continuez le scan sur votre téléphone.") }), jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2 text-xs text-gray-500 pt-1", children: [jsxRuntime.jsx("span", { className: "h-2 w-2 rounded-full animate-pulse", style: { backgroundColor: "var(--uni-primary-color, #11e5c5)" } }), t("nfc_scan.waiting_completion", "En attente de la lecture NFC")] })] }))] })) })] }) }) }));
185
+ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [qrError ? (jsxRuntime.jsx("div", { className: "text-red-500 text-center p-4", children: qrError })) : isIOS ? (jsxRuntime.jsxs("div", { className: "flex w-full flex-col items-center gap-3 p-4 text-center", children: [jsxRuntime.jsx("a", { href: iosAppLinks.open, onClick: revealInstallIfAppDidNotOpen, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] text-sm font-medium hover:brightness-110 active:brightness-90", style: { backgroundColor: "var(--dk-btn-bg)", color: "var(--dk-btn-text)" }, children: t("nfc_scan.open_app_link", "Ouvrir l'application") }), showInstall ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("a", { href: IOS_APP_STORE_URL, onClick: copyResumeLink, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] border border-gray-300 text-sm font-medium text-gray-600 hover:bg-black/5", children: t("nfc_scan.install_app_link", "Installer l'application") }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.install_app_hint", "Après l'installation, revenez sur cette page et appuyez sur « Ouvrir l'application ».") })] })) : null] })) : isMobile ? (jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4 p-8 text-center", children: [jsxRuntime.jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.opening_app", "Ouverture de l'application…") }), jsxRuntime.jsx("a", { href: nfcUrl, className: "text-sm font-medium text-blue-600 underline", children: t("nfc_scan.open_app_link", "Ouvrir l'application") })] })) : (jsxRuntime.jsx("div", { className: "bg-white p-4 rounded-lg shadow-lg border-2 border-gray-200", children: jsxRuntime.jsx("canvas", { ref: canvasRef }) })), status === "opened" && (jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [jsxRuntime.jsx("p", { className: "text-sm font-semibold", style: { color: "var(--uni-secondary-color, #0a9983)" }, children: t("nfc_scan.qr_opened_title", "QR code scanné") }), jsxRuntime.jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.qr_opened_description", "L'expérience NFC est ouverte sur votre smartphone. Continuez le scan sur votre téléphone.") }), jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2 text-xs text-gray-500 pt-1", children: [jsxRuntime.jsx("span", { className: "h-2 w-2 rounded-full animate-pulse", style: { backgroundColor: "var(--uni-primary-color, #11e5c5)" } }), t("nfc_scan.waiting_completion", "En attente de la lecture NFC")] })] }))] })) })] }) }) }));
168
186
  };
169
187
 
170
188
  exports.default = NfcScanStep;
@@ -3,6 +3,7 @@
3
3
  var React = require('react');
4
4
 
5
5
  var SUCCESS_DISPLAY_DURATION_MS = 2500;
6
+ var RECONNECT_DELAY_MS = 2000;
6
7
  function useNfcSseStatus(_a) {
7
8
  var sessionId = _a.sessionId, apiBaseUrl = _a.apiBaseUrl, onCompleted = _a.onCompleted;
8
9
  var _b = React.useState("pending"), status = _b[0], setStatus = _b[1];
@@ -12,42 +13,76 @@ function useNfcSseStatus(_a) {
12
13
  if (!sessionId || !apiBaseUrl)
13
14
  return;
14
15
  var url = "".concat(apiBaseUrl, "/session/sdk/").concat(sessionId, "/nfc-status");
15
- var source = new EventSource(url);
16
- source.onmessage = function (event) {
17
- try {
18
- var data = JSON.parse(event.data);
19
- if (data.status === "completed") {
20
- source.close();
21
- setStatus("success");
22
- setTimeout(function () {
23
- setStatus("completed");
24
- onCompletedRef.current();
25
- }, SUCCESS_DISPLAY_DURATION_MS);
16
+ var source = null;
17
+ // Statut terminal reçu : plus aucune (re)connexion, et `onCompleted` n'est appelé qu'une fois.
18
+ var finished = false;
19
+ var reconnectTimer;
20
+ var open = function () {
21
+ clearTimeout(reconnectTimer);
22
+ source === null || source === void 0 ? void 0 : source.close();
23
+ var current = new EventSource(url);
24
+ source = current;
25
+ current.onmessage = function (event) {
26
+ if (finished)
27
+ return;
28
+ try {
29
+ var data = JSON.parse(event.data);
30
+ if (data.status === "completed") {
31
+ finished = true;
32
+ current.close();
33
+ setStatus("success");
34
+ setTimeout(function () {
35
+ setStatus("completed");
36
+ onCompletedRef.current();
37
+ }, SUCCESS_DISPLAY_DURATION_MS);
38
+ }
39
+ else {
40
+ // `failed` est terminal : le serveur ferme le flux, inutile de le rouvrir en boucle.
41
+ if (data.status === "failed")
42
+ finished = true;
43
+ setStatus(data.status);
44
+ }
26
45
  }
27
- else {
28
- setStatus(data.status);
46
+ catch (_a) {
47
+ // message malformé, on ignore
29
48
  }
30
- }
31
- catch (_a) {
32
- // message malformé, on ignore
33
- }
49
+ };
50
+ // EventSource se reconnecte seul tant qu'il est CONNECTING. Mais iOS coupe le flux quand
51
+ // Safari passe en arrière-plan pendant le scan dans l'app, et une réponse non-200 à la
52
+ // reconnexion le ferme définitivement (CLOSED) : on le rouvre alors nous-mêmes.
53
+ current.onerror = function () {
54
+ if (!finished && current.readyState === EventSource.CLOSED) {
55
+ reconnectTimer = setTimeout(open, RECONNECT_DELAY_MS);
56
+ }
57
+ };
34
58
  };
35
- source.onerror = function () {
36
- // EventSource reconnecte automatiquement — pas d'action requise
59
+ // Retour sur la page (depuis l'app de scan, ou restauration bfcache) : le flux a pu mourir
60
+ // pendant la suspension et l'event `completed` être perdu. On rouvre : le serveur renvoie le
61
+ // statut courant dès la connexion, donc le parcours avance sans recharger la page.
62
+ var reopenIfVisible = function () {
63
+ if (!finished && document.visibilityState === "visible")
64
+ open();
37
65
  };
38
66
  // Fermer le flux uniquement quand la page se ferme réellement, sinon le SSE reste ouvert côté
39
67
  // serveur (heartbeat + listener qui fuient). `pagehide` couvre la fermeture d'onglet/navigation
40
68
  // (plus fiable que `beforeunload` sur mobile).
41
69
  //
42
70
  // NE PAS fermer sur `visibilitychange`/`hidden` : le passage en arrière-plan est le geste
43
- // NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR. Fermer à ce
44
- // moment-là tue le flux définitivement (aucune réouverture), donc les events `opened` /
45
- // `completed` émis pendant le scan ne sont jamais reçus et le front reste bloqué sur le QR.
46
- var closeSource = function () { return source.close(); };
71
+ // NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR. On se contente de
72
+ // ROUVRIR au retour (`visible`), ce qui ne coupe jamais un flux encore utile.
73
+ var closeSource = function () {
74
+ clearTimeout(reconnectTimer);
75
+ source === null || source === void 0 ? void 0 : source.close();
76
+ };
77
+ open();
47
78
  window.addEventListener("pagehide", closeSource);
79
+ window.addEventListener("pageshow", reopenIfVisible);
80
+ document.addEventListener("visibilitychange", reopenIfVisible);
48
81
  return function () {
49
82
  window.removeEventListener("pagehide", closeSource);
50
- source.close();
83
+ window.removeEventListener("pageshow", reopenIfVisible);
84
+ document.removeEventListener("visibilitychange", reopenIfVisible);
85
+ closeSource();
51
86
  };
52
87
  }, [sessionId, apiBaseUrl]);
53
88
  return { status: status };
@@ -14,7 +14,8 @@ function getSessionCredential(sessionId) {
14
14
  function credentialForRequest(url) {
15
15
  if (/^[a-z]+:/i.test(url) || url.startsWith('//'))
16
16
  return undefined;
17
- var match = url.match(/^\/?session\/sdk\/([^/?]+)/);
17
+ // Routes SDK et biométrie Unissey : toutes adressent une seule session par son id.
18
+ var match = url.match(/^\/?session\/(?:sdk|unissey)\/([^/?]+)/);
18
19
  return match ? credentials.get(decodeURIComponent(match[1])) : undefined;
19
20
  }
20
21
 
@@ -10,6 +10,9 @@ import { isServiceErrorCode } from '../../utils/analysisErrors.js';
10
10
  var DocumentError = function (_a) {
11
11
  var documentType = _a.documentType, documentTypeLabel = _a.documentTypeLabel, onRetry = _a.onRetry, onContinueAnyway = _a.onContinueAnyway, onBackToUserInput = _a.onBackToUserInput, _b = _a.retryCount, retryCount = _b === void 0 ? 0 : _b, _c = _a.predictions, predictions = _c === void 0 ? [] : _c; _a.errorDetails; _a.allowResubmission; var maxResubmissionAttempts = _a.maxResubmissionAttempts, _d = _a.isRetryAllowed, isRetryAllowed = _d === void 0 ? true : _d, errorCode = _a.errorCode, _e = _a.blockContinue, blockContinue = _e === void 0 ? false : _e;
12
12
  var t = useI18n().t;
13
+ // APP3-1955: a service refusal (no credits / quota) blocks the journey,
14
+ // whatever node.allowContinueOnFailure says.
15
+ var continueAnyway = isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
13
16
  var _f = useState([]), validationPoints = _f[0], setValidationPoints = _f[1];
14
17
  useEffect(function () {
15
18
  // Use shared utility to get validation points
@@ -58,7 +61,7 @@ var DocumentError = function (_a) {
58
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)
59
62
  ? // Quota / out of credits: nothing for the end user to improve.
60
63
  t("errors.service_refusal_title")
61
- : "\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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, type: "continue", children: t("errors.continue_anyway", "Poursuivre tout de même") }))] })) }) })] }) })] }));
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") }))] })) }) })] }) })] }));
62
65
  };
63
66
 
64
67
  export { DocumentError as default };
@@ -14,6 +14,9 @@ var JDIError = function (_a) {
14
14
  var _b;
15
15
  _a.documentType; var onRetry = _a.onRetry, onContinueAnyway = _a.onContinueAnyway, onBackToUserInput = _a.onBackToUserInput, _c = _a.retryCount, retryCount = _c === void 0 ? 0 : _c, _d = _a.predictions, predictions = _d === void 0 ? DEFAULT_PREDICTIONS : _d, errorCode = _a.errorCode; _a.allowResubmission; var maxResubmissionAttempts = _a.maxResubmissionAttempts, _e = _a.isRetryAllowed, isRetryAllowed = _e === void 0 ? true : _e, _f = _a.blockContinue, blockContinue = _f === void 0 ? false : _f;
16
16
  var t = useI18n().t;
17
+ // APP3-1955: a service refusal (no credits / quota) blocks the journey,
18
+ // whatever node.allowContinueOnFailure says.
19
+ var continueAnyway = isServiceErrorCode(errorCode) ? undefined : onContinueAnyway;
17
20
  var _g = useState([]), validationPoints = _g[0], setValidationPoints = _g[1];
18
21
  // Détail de mismatch d'identité (code 7.0), calculé côté backend et porté
19
22
  // par la première prédiction. Absent pour tous les autres codes.
@@ -29,7 +32,7 @@ var JDIError = function (_a) {
29
32
  var guidance = t("user_guidance.".concat(errorCode), "");
30
33
  return guidance || null;
31
34
  };
32
- 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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsx(Button, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, 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 && onContinueAnyway && (jsx(ButtonDesktop, { onClick: onContinueAnyway, 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
35
+ 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
33
36
  ? t("errors.upload_not_confirmed.title")
34
37
  : t("errors.verification_failed") }), jsx(Subtitle, { className: "text-sm text-gray-600 leading-relaxed", children: blockContinue
35
38
  ? t("errors.upload_not_confirmed.subtitle")
@@ -20,6 +20,7 @@ import NfcSuccessAnimation from './NfcSuccessAnimation.js';
20
20
  // choisir l'environnement (même rôle que `intent://<host>/scan/<id>` sur Android).
21
21
  var IOS_APP_SCHEME = "datakeenscannerswift";
22
22
  var IOS_APP_STORE_URL = "https://apps.apple.com/app/id6762505375";
23
+ var INSTALL_REVEAL_DELAY_MS = 2500;
23
24
  var NfcScanStep = function (_a) {
24
25
  var sessionId = _a.sessionId, nodeId = _a.nodeId, stepObject = _a.stepObject, template = _a.template, pageTitle = _a.pageTitle, pageDescription = _a.pageDescription, onBack = _a.onBack, onContinueWithoutChip = _a.onContinueWithoutChip;
25
26
  var t = useI18n().t;
@@ -37,8 +38,11 @@ var NfcScanStep = function (_a) {
37
38
  var apiBaseUrl = useMemo(function () { return getBaseURL(); }, []);
38
39
  var iosAppLinks = useMemo(function () {
39
40
  var host = new URL(apiBaseUrl, window.location.href).host;
41
+ // `return` : l'app rouvre exactement cette URL en fin de scan, ce qui ramène Safari sur cet
42
+ // onglet (et non un nouvel onglet) quand l'URL est identique.
43
+ var returnUrl = encodeURIComponent(window.location.href);
40
44
  return {
41
- open: "".concat(IOS_APP_SCHEME, "://").concat(host, "/scan/").concat(sessionId),
45
+ open: "".concat(IOS_APP_SCHEME, "://").concat(host, "/scan/").concat(sessionId, "?return=").concat(returnUrl),
42
46
  // Lu par le bouton « Reprendre ma session » de l'app au premier lancement après installation.
43
47
  resume: "https://".concat(host, "/scan/").concat(sessionId),
44
48
  };
@@ -49,6 +53,20 @@ var NfcScanStep = function (_a) {
49
53
  var _a;
50
54
  (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(iosAppLinks.resume).catch(function () { return undefined; });
51
55
  };
56
+ // iOS ne permet pas de savoir si l'app est installée. Un seul bouton « Ouvrir » ; si la page est
57
+ // toujours visible après le délai (app absente : Safari affiche « adresse invalide »), on révèle
58
+ // « Installer ». Pas de redirection automatique vers l'App Store : pendant la confirmation iOS
59
+ // « Ouvrir dans ID Scan ? » la page reste visible, une redirection y enverrait à tort.
60
+ var _e = useState(false), showInstall = _e[0], setShowInstall = _e[1];
61
+ var installRevealTimerRef = useRef();
62
+ useEffect(function () { return function () { return clearTimeout(installRevealTimerRef.current); }; }, []);
63
+ var revealInstallIfAppDidNotOpen = function () {
64
+ clearTimeout(installRevealTimerRef.current);
65
+ installRevealTimerRef.current = setTimeout(function () {
66
+ if (document.visibilityState === "visible")
67
+ setShowInstall(true);
68
+ }, INSTALL_REVEAL_DELAY_MS);
69
+ };
52
70
  var status = useNfcSseStatus({
53
71
  sessionId: sessionId,
54
72
  apiBaseUrl: apiBaseUrl,
@@ -160,7 +178,7 @@ var NfcScanStep = function (_a) {
160
178
  return (jsx(MobilePageLayout, { footer: footer, 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: [jsxs("div", { className: "text-center space-y-4 mt-16 md:mt-20", children: [jsx(Title, { className: "text-xl md:text-2xl lg:text-3xl", children: title }), jsx(Subtitle, { className: "text-sm md:text-base text-gray-600 leading-relaxed whitespace-pre-line", children: subtitle })] }), jsx("div", { className: "flex-1 flex flex-col justify-center items-center gap-4", children: status === "success" ? (jsx(NfcSuccessAnimation, {})) : status === "completed" ? (jsxs("div", { className: "flex flex-col items-center gap-4 p-8", children: [jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.verifying", "Vérification en cours…") })] })) : status === "failed" ? (jsxs("div", { className: "flex flex-col items-center gap-2 p-8 text-center", children: [jsx("p", { className: "text-base font-semibold text-red-600", children: t("nfc_scan.failed_title", "Le scan n'a pas pu être vérifié") }), jsx("p", { className: "text-sm text-gray-600 leading-relaxed", children: t("nfc_scan.failed_description", "Après plusieurs tentatives, la lecture de votre document n'a pas pu être validée.") }), resetError && (jsx("p", { className: "text-sm text-red-600", role: "alert", children: resetError }))] })) : (
161
179
  // Contenu principal QR/mobile — reste monté pour "pending" ET "opened", pour ne
162
180
  // jamais démonter le canvas déjà généré.
163
- jsxs(Fragment, { children: [qrError ? (jsx("div", { className: "text-red-500 text-center p-4", children: qrError })) : isIOS ? (jsxs("div", { className: "flex w-full flex-col items-center gap-3 p-4 text-center", children: [jsx("a", { href: iosAppLinks.open, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] text-sm font-medium hover:brightness-110 active:brightness-90", style: { backgroundColor: "var(--dk-btn-bg)", color: "var(--dk-btn-text)" }, children: t("nfc_scan.open_app_link", "Ouvrir l'application") }), jsx("a", { href: IOS_APP_STORE_URL, onClick: copyResumeLink, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] border border-gray-300 text-sm font-medium text-gray-600 hover:bg-black/5", children: t("nfc_scan.install_app_link", "Installer l'application") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.install_app_hint", "Après l'installation, revenez sur cette page et appuyez sur « Ouvrir l'application ».") })] })) : isMobile ? (jsxs("div", { className: "flex flex-col items-center gap-4 p-8 text-center", children: [jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.opening_app", "Ouverture de l'application…") }), jsx("a", { href: nfcUrl, className: "text-sm font-medium text-blue-600 underline", children: t("nfc_scan.open_app_link", "Ouvrir l'application") })] })) : (jsx("div", { className: "bg-white p-4 rounded-lg shadow-lg border-2 border-gray-200", children: jsx("canvas", { ref: canvasRef }) })), status === "opened" && (jsxs("div", { className: "text-center space-y-1", children: [jsx("p", { className: "text-sm font-semibold", style: { color: "var(--uni-secondary-color, #0a9983)" }, children: t("nfc_scan.qr_opened_title", "QR code scanné") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.qr_opened_description", "L'expérience NFC est ouverte sur votre smartphone. Continuez le scan sur votre téléphone.") }), jsxs("div", { className: "flex items-center justify-center gap-2 text-xs text-gray-500 pt-1", children: [jsx("span", { className: "h-2 w-2 rounded-full animate-pulse", style: { backgroundColor: "var(--uni-primary-color, #11e5c5)" } }), t("nfc_scan.waiting_completion", "En attente de la lecture NFC")] })] }))] })) })] }) }) }));
181
+ jsxs(Fragment, { children: [qrError ? (jsx("div", { className: "text-red-500 text-center p-4", children: qrError })) : isIOS ? (jsxs("div", { className: "flex w-full flex-col items-center gap-3 p-4 text-center", children: [jsx("a", { href: iosAppLinks.open, onClick: revealInstallIfAppDidNotOpen, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] text-sm font-medium hover:brightness-110 active:brightness-90", style: { backgroundColor: "var(--dk-btn-bg)", color: "var(--dk-btn-text)" }, children: t("nfc_scan.open_app_link", "Ouvrir l'application") }), showInstall ? (jsxs(Fragment, { children: [jsx("a", { href: IOS_APP_STORE_URL, onClick: copyResumeLink, className: "flex h-[48px] w-full items-center justify-center rounded-[12px] border border-gray-300 text-sm font-medium text-gray-600 hover:bg-black/5", children: t("nfc_scan.install_app_link", "Installer l'application") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.install_app_hint", "Après l'installation, revenez sur cette page et appuyez sur « Ouvrir l'application ».") })] })) : null] })) : isMobile ? (jsxs("div", { className: "flex flex-col items-center gap-4 p-8 text-center", children: [jsx("div", { className: "animate-spin w-10 h-10 border-2 border-gray-300 border-t-blue-500 rounded-full" }), jsx("p", { className: "text-sm text-gray-600", children: t("nfc_scan.opening_app", "Ouverture de l'application…") }), jsx("a", { href: nfcUrl, className: "text-sm font-medium text-blue-600 underline", children: t("nfc_scan.open_app_link", "Ouvrir l'application") })] })) : (jsx("div", { className: "bg-white p-4 rounded-lg shadow-lg border-2 border-gray-200", children: jsx("canvas", { ref: canvasRef }) })), status === "opened" && (jsxs("div", { className: "text-center space-y-1", children: [jsx("p", { className: "text-sm font-semibold", style: { color: "var(--uni-secondary-color, #0a9983)" }, children: t("nfc_scan.qr_opened_title", "QR code scanné") }), jsx("p", { className: "text-xs text-gray-500 leading-relaxed", children: t("nfc_scan.qr_opened_description", "L'expérience NFC est ouverte sur votre smartphone. Continuez le scan sur votre téléphone.") }), jsxs("div", { className: "flex items-center justify-center gap-2 text-xs text-gray-500 pt-1", children: [jsx("span", { className: "h-2 w-2 rounded-full animate-pulse", style: { backgroundColor: "var(--uni-primary-color, #11e5c5)" } }), t("nfc_scan.waiting_completion", "En attente de la lecture NFC")] })] }))] })) })] }) }) }));
164
182
  };
165
183
 
166
184
  export { NfcScanStep as default };
@@ -1,6 +1,7 @@
1
1
  import { useState, useRef, useEffect } from 'react';
2
2
 
3
3
  var SUCCESS_DISPLAY_DURATION_MS = 2500;
4
+ var RECONNECT_DELAY_MS = 2000;
4
5
  function useNfcSseStatus(_a) {
5
6
  var sessionId = _a.sessionId, apiBaseUrl = _a.apiBaseUrl, onCompleted = _a.onCompleted;
6
7
  var _b = useState("pending"), status = _b[0], setStatus = _b[1];
@@ -10,42 +11,76 @@ function useNfcSseStatus(_a) {
10
11
  if (!sessionId || !apiBaseUrl)
11
12
  return;
12
13
  var url = "".concat(apiBaseUrl, "/session/sdk/").concat(sessionId, "/nfc-status");
13
- var source = new EventSource(url);
14
- source.onmessage = function (event) {
15
- try {
16
- var data = JSON.parse(event.data);
17
- if (data.status === "completed") {
18
- source.close();
19
- setStatus("success");
20
- setTimeout(function () {
21
- setStatus("completed");
22
- onCompletedRef.current();
23
- }, SUCCESS_DISPLAY_DURATION_MS);
14
+ var source = null;
15
+ // Statut terminal reçu : plus aucune (re)connexion, et `onCompleted` n'est appelé qu'une fois.
16
+ var finished = false;
17
+ var reconnectTimer;
18
+ var open = function () {
19
+ clearTimeout(reconnectTimer);
20
+ source === null || source === void 0 ? void 0 : source.close();
21
+ var current = new EventSource(url);
22
+ source = current;
23
+ current.onmessage = function (event) {
24
+ if (finished)
25
+ return;
26
+ try {
27
+ var data = JSON.parse(event.data);
28
+ if (data.status === "completed") {
29
+ finished = true;
30
+ current.close();
31
+ setStatus("success");
32
+ setTimeout(function () {
33
+ setStatus("completed");
34
+ onCompletedRef.current();
35
+ }, SUCCESS_DISPLAY_DURATION_MS);
36
+ }
37
+ else {
38
+ // `failed` est terminal : le serveur ferme le flux, inutile de le rouvrir en boucle.
39
+ if (data.status === "failed")
40
+ finished = true;
41
+ setStatus(data.status);
42
+ }
24
43
  }
25
- else {
26
- setStatus(data.status);
44
+ catch (_a) {
45
+ // message malformé, on ignore
27
46
  }
28
- }
29
- catch (_a) {
30
- // message malformé, on ignore
31
- }
47
+ };
48
+ // EventSource se reconnecte seul tant qu'il est CONNECTING. Mais iOS coupe le flux quand
49
+ // Safari passe en arrière-plan pendant le scan dans l'app, et une réponse non-200 à la
50
+ // reconnexion le ferme définitivement (CLOSED) : on le rouvre alors nous-mêmes.
51
+ current.onerror = function () {
52
+ if (!finished && current.readyState === EventSource.CLOSED) {
53
+ reconnectTimer = setTimeout(open, RECONNECT_DELAY_MS);
54
+ }
55
+ };
32
56
  };
33
- source.onerror = function () {
34
- // EventSource reconnecte automatiquement — pas d'action requise
57
+ // Retour sur la page (depuis l'app de scan, ou restauration bfcache) : le flux a pu mourir
58
+ // pendant la suspension et l'event `completed` être perdu. On rouvre : le serveur renvoie le
59
+ // statut courant dès la connexion, donc le parcours avance sans recharger la page.
60
+ var reopenIfVisible = function () {
61
+ if (!finished && document.visibilityState === "visible")
62
+ open();
35
63
  };
36
64
  // Fermer le flux uniquement quand la page se ferme réellement, sinon le SSE reste ouvert côté
37
65
  // serveur (heartbeat + listener qui fuient). `pagehide` couvre la fermeture d'onglet/navigation
38
66
  // (plus fiable que `beforeunload` sur mobile).
39
67
  //
40
68
  // NE PAS fermer sur `visibilitychange`/`hidden` : le passage en arrière-plan est le geste
41
- // NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR. Fermer à ce
42
- // moment-là tue le flux définitivement (aucune réouverture), donc les events `opened` /
43
- // `completed` émis pendant le scan ne sont jamais reçus et le front reste bloqué sur le QR.
44
- var closeSource = function () { return source.close(); };
69
+ // NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR. On se contente de
70
+ // ROUVRIR au retour (`visible`), ce qui ne coupe jamais un flux encore utile.
71
+ var closeSource = function () {
72
+ clearTimeout(reconnectTimer);
73
+ source === null || source === void 0 ? void 0 : source.close();
74
+ };
75
+ open();
45
76
  window.addEventListener("pagehide", closeSource);
77
+ window.addEventListener("pageshow", reopenIfVisible);
78
+ document.addEventListener("visibilitychange", reopenIfVisible);
46
79
  return function () {
47
80
  window.removeEventListener("pagehide", closeSource);
48
- source.close();
81
+ window.removeEventListener("pageshow", reopenIfVisible);
82
+ document.removeEventListener("visibilitychange", reopenIfVisible);
83
+ closeSource();
49
84
  };
50
85
  }, [sessionId, apiBaseUrl]);
51
86
  return { status: status };
@@ -12,7 +12,8 @@ function getSessionCredential(sessionId) {
12
12
  function credentialForRequest(url) {
13
13
  if (/^[a-z]+:/i.test(url) || url.startsWith('//'))
14
14
  return undefined;
15
- var match = url.match(/^\/?session\/sdk\/([^/?]+)/);
15
+ // Routes SDK et biométrie Unissey : toutes adressent une seule session par son id.
16
+ var match = url.match(/^\/?session\/(?:sdk|unissey)\/([^/?]+)/);
16
17
  return match ? credentials.get(decodeURIComponent(match[1])) : undefined;
17
18
  }
18
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.200",
3
+ "version": "1.1.201",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -74,6 +74,7 @@
74
74
  "@types/react": "^18.0.0",
75
75
  "@types/react-dom": "^18.0.0",
76
76
  "@types/testing-library__react": "^10.0.1",
77
+ "@types/ua-parser-js": "0.7.39",
77
78
  "autoprefixer": "^10.4.21",
78
79
  "axios": "^1.12.0",
79
80
  "babel-jest": "^30.1.2",
@@ -120,7 +121,7 @@
120
121
  "react-day-picker": "^9.14.0",
121
122
  "react-i18next": "^15.7.3",
122
123
  "tailwind-merge": "^3.3.1",
123
- "ua-parser-js": "^2.0.5"
124
+ "ua-parser-js": "^1.0.41"
124
125
  },
125
126
  "peerDependencies": {
126
127
  "axios": "^1.8.0",