datakeen-session-react 1.1.140-rc.67 → 1.1.140-rc.68

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.
@@ -28,7 +28,7 @@ var useI18n = require('../../hooks/useI18n.js');
28
28
  */
29
29
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
30
  var EndFlow = function (_a) {
31
- var sessionId = _a.sessionId, sessionStatus = _a.sessionStatus, callbackURL = _a.callbackURL;
31
+ var sessionId = _a.sessionId, sessionStatus = _a.sessionStatus, callbackURL = _a.callbackURL, endNodeId = _a.endNodeId;
32
32
  var _b = React.useState(false), isEnding = _b[0], setIsEnding = _b[1];
33
33
  var _c = React.useState(false), isRedirecting = _c[0], setIsRedirecting = _c[1];
34
34
  var _d = React.useState(false), shouldRedirect = _d[0], setShouldRedirect = _d[1];
@@ -36,7 +36,7 @@ var EndFlow = function (_a) {
36
36
  // Trigger session end as soon as the user reaches this screen,
37
37
  // regardless of whether they click the button (e.g. tab close)
38
38
  React.useEffect(function () {
39
- sessionService.updateSessionStatus(sessionId, "ended")
39
+ sessionService.updateSessionStatus(sessionId, "ended", endNodeId)
40
40
  .then(function (updatedSession) {
41
41
  if (updatedSession && updatedSession.analysisId) {
42
42
  auditTrailService.logSessionEnded(sessionId).catch(function (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"EndFlow.js","sources":["../../../../../src/components/session/EndFlow.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport type { stepObject } from \"../../types/session\";\nimport checkIcon from \"../../assets/check.svg\";\nimport Button from \"../ui/Button\";\nimport PageActions from \"../ui/PageActions\";\nimport Title from \"../ui/Title\";\nimport Subtitle from \"../ui/Subtitle\";\nimport {\n clearSessionSensitiveData,\n updateSessionStatus,\n} from \"../../services/sessionService\";\nimport { logSessionEnded } from \"../../services/auditTrailService\";\nimport MobilePageLayout from \"../ui/MobilePageLayout\";\nimport { useI18n } from \"../../hooks/useI18n\";\n\ninterface EndFlowProps {\n sessionId: string;\n sessionStatus?: string; // Ajout du statut de session optionnel\n callbackURL?: string | null;\n}\n\n/**\n * EndFlow Component\n *\n * Composant affiché à la fin du flux de vérification lorsque toutes les étapes ont été complétées.\n * Affiche un message de confirmation avec une icône de succès.\n *\n * @param {EndFlowProps} props - Propriétés du composant\n * @param {string} props.sessionId - L'identifiant de la session\n * @param {string} props.sessionStatus - Le statut actuel de la session\n * @returns {JSX.Element} Le composant EndFlow\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst EndFlow: React.FC<EndFlowProps> = ({\n sessionId,\n sessionStatus,\n callbackURL,\n}) => {\n const [isEnding, setIsEnding] = useState(false);\n const [isRedirecting, setIsRedirecting] = useState(false);\n const [shouldRedirect, setShouldRedirect] = useState(false);\n const { t } = useI18n();\n\n // Trigger session end as soon as the user reaches this screen,\n // regardless of whether they click the button (e.g. tab close)\n useEffect(() => {\n updateSessionStatus(sessionId, \"ended\")\n .then((updatedSession) => {\n if (updatedSession && updatedSession.analysisId) {\n logSessionEnded(sessionId).catch((err) => {\n console.error(\"Failed to log session end in audit trail:\", err);\n });\n }\n })\n .catch((error) => {\n console.error(\"Error updating session status on EndFlow mount:\", error);\n });\n }, []);\n\n const handleEndSession = async () => {\n setIsEnding(true);\n try {\n clearSessionSensitiveData(sessionId);\n } catch (error) {\n console.error(\"Erreur lors de la finalisation de la session:\", error);\n } finally {\n setIsEnding(false);\n if (callbackURL) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n } else {\n // Forcer la fermeture immédiatement lorsqu'aucune redirection n'est attendue\n closeWindow();\n }\n }\n };\n\n const redirectToCallback = (url: string) => {\n try {\n window.location.replace(url);\n } catch (e) {\n console.error(\"Redirection vers le callback échouée:\", e);\n setIsRedirecting(false);\n closeWindow();\n }\n };\n\n useEffect(() => {\n if (sessionStatus === \"ended\" && callbackURL && !shouldRedirect) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n }\n }, [sessionStatus, callbackURL, shouldRedirect]);\n\n useEffect(() => {\n if (!shouldRedirect || !callbackURL) {\n return;\n }\n\n const REDIRECT_DELAY_MS = 2000;\n const timer = window.setTimeout(\n () => redirectToCallback(callbackURL),\n REDIRECT_DELAY_MS,\n );\n return () => window.clearTimeout(timer);\n }, [shouldRedirect, callbackURL]);\n\n const closeWindow = () => {\n console.log(\"Tentative de fermeture de la fenêtre...\");\n\n // Méthode 1: Si dans un iframe, communiquer avec le parent IMMÉDIATEMENT\n if (window.parent && window.parent !== window) {\n try {\n window.parent.postMessage(\n {\n action: \"closeSession\",\n sessionId,\n status: \"ended\",\n message: \"Session terminée, veuillez fermer cette fenêtre\",\n },\n \"*\",\n );\n console.log(\"Message envoyé au parent pour fermeture\");\n } catch (e) {\n console.log(\"postMessage échoué:\", e);\n }\n }\n\n // Méthode 2: Essayer window.close() avec différentes approches\n try {\n // Essayer close direct\n window.close();\n console.log(\"window.close() direct appelé\");\n } catch (e) {\n console.log(\"window.close() direct échoué:\", e);\n }\n\n // Méthode 3: Si on a un opener, essayer de se fermer via l'opener\n setTimeout(() => {\n try {\n if (window.opener) {\n window.opener.focus();\n window.close();\n console.log(\"Fermeture via opener\");\n }\n } catch (e) {\n console.log(\"Fermeture via opener échouée:\", e);\n }\n }, 100);\n\n // Méthode 4: Forcer avec self.close()\n setTimeout(() => {\n try {\n self.close();\n console.log(\"self.close() appelé\");\n } catch (e) {\n console.log(\"self.close() échoué:\", e);\n }\n }, 200);\n\n // Méthode 5: Essayer de manipuler l'historique pour forcer la fermeture\n setTimeout(() => {\n try {\n window.history.back();\n window.close();\n console.log(\"history.back() + close\");\n } catch (e) {\n console.log(\"history.back() + close échoué:\", e);\n }\n }, 300);\n\n // Méthode 6: Rediriger vers une page de fermeture personnalisée\n setTimeout(() => {\n try {\n // Créer une URL de données avec un script de fermeture automatique\n const closeScript = `\n <html>\n <head><title>Session terminée</title></head>\n <body style=\"margin:0;padding:0;background:#f0f0f0;font-family:Arial,sans-serif;\">\n <div style=\"display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;text-align:center;\">\n <h1 style=\"color:#4ade80;margin-bottom:20px;\">✅ Session terminée avec succès</h1>\n <p style=\"color:#666;margin-bottom:30px;\">Cette fenêtre va se fermer automatiquement.</p>\n <button onclick=\"attemptClose()\" style=\"background:#3b82f6;color:white;border:none;padding:12px 24px;border-radius:6px;cursor:pointer;font-size:16px;\">\n Fermer maintenant\n </button>\n </div>\n <script>\n function attemptClose() {\n try {\n window.close();\n self.close();\n if (window.opener) {\n window.opener.focus();\n window.close();\n }\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({action:'closeWindow'}, '*');\n }\n } catch(e) {\n console.log('Fermeture impossible:', e);\n document.body.innerHTML = '<div style=\"text-align:center;padding:50px;\"><h2>Veuillez fermer cette fenêtre manuellement</h2><p>Appuyez sur Alt+F4 ou cliquez sur le X</p></div>';\n }\n }\n // Essayer de fermer automatiquement après 1 seconde\n setTimeout(attemptClose, 1000);\n </script>\n </body>\n </html>\n `;\n const dataUrl =\n \"data:text/html;charset=utf-8,\" + encodeURIComponent(closeScript);\n window.location.replace(dataUrl);\n console.log(\"Redirection vers page de fermeture personnalisée\");\n } catch (e) {\n console.log(\"Redirection vers page personnalisée échouée:\", e);\n }\n }, 500);\n };\n return (\n <MobilePageLayout\n footer={\n <PageActions\n primary={\n <Button\n onClick={handleEndSession}\n disabled={isEnding || isRedirecting}\n >\n {isRedirecting\n ? t(\"session.end.button_redirecting\", \"Redirection...\")\n : isEnding\n ? t(\"session.end.button_finalizing\", \"Finalisation...\")\n : t(\"session.end.button_end\", \"Terminer\")}\n </Button>\n }\n />\n }\n >\n <div className=\"flex flex-col items-center justify-center px-4 py-8 md:px-8\">\n <div className=\"w-full max-w-md mx-auto text-center space-y-6\">\n {/* Icon - shown on top for both mobile and desktop */}\n <div className=\"flex justify-center\">\n <img\n src={checkIcon}\n alt={t(\"session.end.image_alt\", \"Vérification terminée\")}\n className=\"w-48 h-48\"\n />\n </div>\n\n {/* Text content */}\n <div className=\"space-y-4\">\n <Title className=\"text-xl md:text-2xl lg:text-3xl\">\n {t(\"session.end.title\", \"C'est tout bon !\")}\n </Title>\n <Subtitle className=\"text-sm md:text-base text-gray-600 leading-relaxed\">\n {t(\n \"session.end.subtitle\",\n \"Merci d'avoir terminé ce parcours, vous pouvez quitter cette fenêtre.\",\n )}\n </Subtitle>\n </div>\n </div>\n </div>\n </MobilePageLayout>\n );\n};\n\nexport default EndFlow;\n"],"names":["useState","useI18n","useEffect","updateSessionStatus","logSessionEnded","__awaiter","clearSessionSensitiveData","_jsx","MobilePageLayout","PageActions","Button","_jsxs","checkIcon","Title","Subtitle"],"mappings":";;;;;;;;;;;;;;;;;AAqBA;;;;;;;;;;AAUG;AACH;AACA,IAAM,OAAO,GAA2B,UAAC,EAIxC,EAAA;AAHC,IAAA,IAAA,SAAS,eAAA,EACT,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,WAAW,GAAA,EAAA,CAAA,WAAA;IAEL,IAAA,EAAA,GAA0BA,cAAQ,CAAC,KAAK,CAAC,EAAxC,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,WAAW,GAAA,EAAA,CAAA,CAAA,CAAmB;IACzC,IAAA,EAAA,GAAoCA,cAAQ,CAAC,KAAK,CAAC,EAAlD,aAAa,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,gBAAgB,GAAA,EAAA,CAAA,CAAA,CAAmB;IACnD,IAAA,EAAA,GAAsCA,cAAQ,CAAC,KAAK,CAAC,EAApD,cAAc,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,iBAAiB,GAAA,EAAA,CAAA,CAAA,CAAmB;AACnD,IAAA,IAAA,CAAC,GAAKC,eAAO,EAAE,EAAd;;;AAIT,IAAAC,eAAS,CAAC,YAAA;AACR,QAAAC,kCAAmB,CAAC,SAAS,EAAE,OAAO;aACnC,IAAI,CAAC,UAAC,cAAc,EAAA;AACnB,YAAA,IAAI,cAAc,IAAI,cAAc,CAAC,UAAU,EAAE;AA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;;;;"}
1
+ {"version":3,"file":"EndFlow.js","sources":["../../../../../src/components/session/EndFlow.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport type { stepObject } from \"../../types/session\";\nimport checkIcon from \"../../assets/check.svg\";\nimport Button from \"../ui/Button\";\nimport PageActions from \"../ui/PageActions\";\nimport Title from \"../ui/Title\";\nimport Subtitle from \"../ui/Subtitle\";\nimport {\n clearSessionSensitiveData,\n updateSessionStatus,\n} from \"../../services/sessionService\";\nimport { logSessionEnded } from \"../../services/auditTrailService\";\nimport MobilePageLayout from \"../ui/MobilePageLayout\";\nimport { useI18n } from \"../../hooks/useI18n\";\n\ninterface EndFlowProps {\n sessionId: string;\n sessionStatus?: string; // Ajout du statut de session optionnel\n callbackURL?: string | null;\n endNodeId?: string; // Id du nœud `end` atteint, transmis au backend pour forcer le bon statut\n}\n\n/**\n * EndFlow Component\n *\n * Composant affiché à la fin du flux de vérification lorsque toutes les étapes ont été complétées.\n * Affiche un message de confirmation avec une icône de succès.\n *\n * @param {EndFlowProps} props - Propriétés du composant\n * @param {string} props.sessionId - L'identifiant de la session\n * @param {string} props.sessionStatus - Le statut actuel de la session\n * @returns {JSX.Element} Le composant EndFlow\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst EndFlow: React.FC<EndFlowProps> = ({\n sessionId,\n sessionStatus,\n callbackURL,\n endNodeId,\n}) => {\n const [isEnding, setIsEnding] = useState(false);\n const [isRedirecting, setIsRedirecting] = useState(false);\n const [shouldRedirect, setShouldRedirect] = useState(false);\n const { t } = useI18n();\n\n // Trigger session end as soon as the user reaches this screen,\n // regardless of whether they click the button (e.g. tab close)\n useEffect(() => {\n updateSessionStatus(sessionId, \"ended\", endNodeId)\n .then((updatedSession) => {\n if (updatedSession && updatedSession.analysisId) {\n logSessionEnded(sessionId).catch((err) => {\n console.error(\"Failed to log session end in audit trail:\", err);\n });\n }\n })\n .catch((error) => {\n console.error(\"Error updating session status on EndFlow mount:\", error);\n });\n }, []);\n\n const handleEndSession = async () => {\n setIsEnding(true);\n try {\n clearSessionSensitiveData(sessionId);\n } catch (error) {\n console.error(\"Erreur lors de la finalisation de la session:\", error);\n } finally {\n setIsEnding(false);\n if (callbackURL) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n } else {\n // Forcer la fermeture immédiatement lorsqu'aucune redirection n'est attendue\n closeWindow();\n }\n }\n };\n\n const redirectToCallback = (url: string) => {\n try {\n window.location.replace(url);\n } catch (e) {\n console.error(\"Redirection vers le callback échouée:\", e);\n setIsRedirecting(false);\n closeWindow();\n }\n };\n\n useEffect(() => {\n if (sessionStatus === \"ended\" && callbackURL && !shouldRedirect) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n }\n }, [sessionStatus, callbackURL, shouldRedirect]);\n\n useEffect(() => {\n if (!shouldRedirect || !callbackURL) {\n return;\n }\n\n const REDIRECT_DELAY_MS = 2000;\n const timer = window.setTimeout(\n () => redirectToCallback(callbackURL),\n REDIRECT_DELAY_MS,\n );\n return () => window.clearTimeout(timer);\n }, [shouldRedirect, callbackURL]);\n\n const closeWindow = () => {\n console.log(\"Tentative de fermeture de la fenêtre...\");\n\n // Méthode 1: Si dans un iframe, communiquer avec le parent IMMÉDIATEMENT\n if (window.parent && window.parent !== window) {\n try {\n window.parent.postMessage(\n {\n action: \"closeSession\",\n sessionId,\n status: \"ended\",\n message: \"Session terminée, veuillez fermer cette fenêtre\",\n },\n \"*\",\n );\n console.log(\"Message envoyé au parent pour fermeture\");\n } catch (e) {\n console.log(\"postMessage échoué:\", e);\n }\n }\n\n // Méthode 2: Essayer window.close() avec différentes approches\n try {\n // Essayer close direct\n window.close();\n console.log(\"window.close() direct appelé\");\n } catch (e) {\n console.log(\"window.close() direct échoué:\", e);\n }\n\n // Méthode 3: Si on a un opener, essayer de se fermer via l'opener\n setTimeout(() => {\n try {\n if (window.opener) {\n window.opener.focus();\n window.close();\n console.log(\"Fermeture via opener\");\n }\n } catch (e) {\n console.log(\"Fermeture via opener échouée:\", e);\n }\n }, 100);\n\n // Méthode 4: Forcer avec self.close()\n setTimeout(() => {\n try {\n self.close();\n console.log(\"self.close() appelé\");\n } catch (e) {\n console.log(\"self.close() échoué:\", e);\n }\n }, 200);\n\n // Méthode 5: Essayer de manipuler l'historique pour forcer la fermeture\n setTimeout(() => {\n try {\n window.history.back();\n window.close();\n console.log(\"history.back() + close\");\n } catch (e) {\n console.log(\"history.back() + close échoué:\", e);\n }\n }, 300);\n\n // Méthode 6: Rediriger vers une page de fermeture personnalisée\n setTimeout(() => {\n try {\n // Créer une URL de données avec un script de fermeture automatique\n const closeScript = `\n <html>\n <head><title>Session terminée</title></head>\n <body style=\"margin:0;padding:0;background:#f0f0f0;font-family:Arial,sans-serif;\">\n <div style=\"display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;text-align:center;\">\n <h1 style=\"color:#4ade80;margin-bottom:20px;\">✅ Session terminée avec succès</h1>\n <p style=\"color:#666;margin-bottom:30px;\">Cette fenêtre va se fermer automatiquement.</p>\n <button onclick=\"attemptClose()\" style=\"background:#3b82f6;color:white;border:none;padding:12px 24px;border-radius:6px;cursor:pointer;font-size:16px;\">\n Fermer maintenant\n </button>\n </div>\n <script>\n function attemptClose() {\n try {\n window.close();\n self.close();\n if (window.opener) {\n window.opener.focus();\n window.close();\n }\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({action:'closeWindow'}, '*');\n }\n } catch(e) {\n console.log('Fermeture impossible:', e);\n document.body.innerHTML = '<div style=\"text-align:center;padding:50px;\"><h2>Veuillez fermer cette fenêtre manuellement</h2><p>Appuyez sur Alt+F4 ou cliquez sur le X</p></div>';\n }\n }\n // Essayer de fermer automatiquement après 1 seconde\n setTimeout(attemptClose, 1000);\n </script>\n </body>\n </html>\n `;\n const dataUrl =\n \"data:text/html;charset=utf-8,\" + encodeURIComponent(closeScript);\n window.location.replace(dataUrl);\n console.log(\"Redirection vers page de fermeture personnalisée\");\n } catch (e) {\n console.log(\"Redirection vers page personnalisée échouée:\", e);\n }\n }, 500);\n };\n return (\n <MobilePageLayout\n footer={\n <PageActions\n primary={\n <Button\n onClick={handleEndSession}\n disabled={isEnding || isRedirecting}\n >\n {isRedirecting\n ? t(\"session.end.button_redirecting\", \"Redirection...\")\n : isEnding\n ? t(\"session.end.button_finalizing\", \"Finalisation...\")\n : t(\"session.end.button_end\", \"Terminer\")}\n </Button>\n }\n />\n }\n >\n <div className=\"flex flex-col items-center justify-center px-4 py-8 md:px-8\">\n <div className=\"w-full max-w-md mx-auto text-center space-y-6\">\n {/* Icon - shown on top for both mobile and desktop */}\n <div className=\"flex justify-center\">\n <img\n src={checkIcon}\n alt={t(\"session.end.image_alt\", \"Vérification terminée\")}\n className=\"w-48 h-48\"\n />\n </div>\n\n {/* Text content */}\n <div className=\"space-y-4\">\n <Title className=\"text-xl md:text-2xl lg:text-3xl\">\n {t(\"session.end.title\", \"C'est tout bon !\")}\n </Title>\n <Subtitle className=\"text-sm md:text-base text-gray-600 leading-relaxed\">\n {t(\n \"session.end.subtitle\",\n \"Merci d'avoir terminé ce parcours, vous pouvez quitter cette fenêtre.\",\n )}\n </Subtitle>\n </div>\n </div>\n </div>\n </MobilePageLayout>\n );\n};\n\nexport default EndFlow;\n"],"names":["useState","useI18n","useEffect","updateSessionStatus","logSessionEnded","__awaiter","clearSessionSensitiveData","_jsx","MobilePageLayout","PageActions","Button","_jsxs","checkIcon","Title","Subtitle"],"mappings":";;;;;;;;;;;;;;;;;AAsBA;;;;;;;;;;AAUG;AACH;AACA,IAAM,OAAO,GAA2B,UAAC,EAKxC,EAAA;QAJC,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,SAAS,GAAA,EAAA,CAAA,SAAA;IAEH,IAAA,EAAA,GAA0BA,cAAQ,CAAC,KAAK,CAAC,EAAxC,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,WAAW,GAAA,EAAA,C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BAAqB,EAAA,QAAA,EAClCA,wBACE,GAAG,EAAEK,aAAS,EACd,GAAG,EAAE,CAAC,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,EACxD,SAAS,EAAC,WAAW,EAAA,CACrB,EAAA,CACE,EAGND,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,WAAW,EAAA,QAAA,EAAA,CACxBJ,eAACM,aAAK,EAAA,EAAC,SAAS,EAAC,iCAAiC,EAAA,QAAA,EAC/C,CAAC,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,EAAA,CACrC,EACRN,cAAA,CAACO,gBAAQ,EAAA,EAAC,SAAS,EAAC,oDAAoD,EAAA,QAAA,EACrE,CAAC,CACA,sBAAsB,EACtB,uEAAuE,CACxE,EAAA,CACQ,CAAA,EAAA,CACP,IACF,EAAA,CACF,EAAA,CACW;AAEvB;;;;"}
@@ -61,7 +61,7 @@ var TemplateNodeRenderer = function (_a) {
61
61
  switch (node.type) {
62
62
  case "end":
63
63
  console.log("📄 Rendering EndFlow component");
64
- return (jsxRuntime.jsx(EndFlow.default, { sessionId: sessionId, sessionStatus: session === null || session === void 0 ? void 0 : session.status, callbackURL: session === null || session === void 0 ? void 0 : session.callbackURL }));
64
+ return (jsxRuntime.jsx(EndFlow.default, { sessionId: sessionId, sessionStatus: session === null || session === void 0 ? void 0 : session.status, callbackURL: session === null || session === void 0 ? void 0 : session.callbackURL, endNodeId: node.id }));
65
65
  case "information-input": {
66
66
  // runIndex = nombre de fois que ce step a déjà été visité dans l'historique
67
67
  // (0 = premier passage, 1 = deuxième, …).
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateNodeRenderer.js","sources":["../../../../../src/components/template/TemplateNodeRenderer.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport Selfie from \"../session/Selfie\";\nimport VideoWorkInProgress from \"../session/VideoWorkInProgress\";\nimport DocumentCheck, { NodeIdentityControl } from \"../session/DocumentCheck\";\nimport DocumentCollection, {\n DocumentTypeSide,\n NodeDocumentCollection,\n} from \"../document-collection/DocumentCollection\";\nimport EndFlow from \"../session/EndFlow\";\nimport LoadingState from \"../states/LoadingState\";\nimport JDDWorkInProgress from \"../jdi/JDDWorkInProgress\";\nimport { getOrderedJourneySteps, getRunPrefillData } from \"../../services/sessionService\";\nimport type { SessionData, stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport UserInputForm from \"../session/UserInputForm\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ConditionNodeHandler from \"./ConditionNodeHandler\";\nimport SignatureElectronic from \"../signature-electronic/SignatureElectronic\";\nimport ExternalVerificationNodeHandler from \"./ExternalVerificationNodeHandler\";\nimport PdfGeneration from \"../session/PdfGeneration\";\nimport LegalConsentNode from \"../legal-consent/LegalConsentNode\";\n\ninterface TemplateNodeRendererProps {\n session: SessionData;\n sessionId: string;\n stepObject: stepObject;\n stepHistory: number[];\n templateIndex: number;\n onContinueOnPC: () => void;\n userInput: UserInput;\n setUserInput: React.Dispatch<React.SetStateAction<UserInput>>;\n contactInfo: ContactInfo;\n setContactInfo: React.Dispatch<React.SetStateAction<ContactInfo>>;\n isMobileTemplate: boolean;\n}\n\nconst TemplateNodeRenderer: React.FC<TemplateNodeRendererProps> = ({\n session,\n sessionId,\n stepObject,\n stepHistory,\n templateIndex,\n onContinueOnPC,\n userInput,\n setUserInput,\n contactInfo,\n setContactInfo,\n isMobileTemplate,\n}) => {\n const { t } = useI18n();\n\n if (!session?.template) {\n console.error(t(\"template.error.console_no_template\"));\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.configuration\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{t(\"template.error.no_template\")}</p>\n </div>\n );\n }\n\n // Check if session is ended before rendering nodes\n if (session.status === \"ended\") {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session.status}\n callbackURL={session.callbackURL}\n />\n );\n }\n\n // Use getOrderedWorkflowSteps to get sorted and filtered nodes\n const templateNodes = useMemo(\n () => getOrderedJourneySteps(session.template),\n [session.template],\n );\n\n // Check if index is valid\n if (templateNodes.length === 0) {\n console.warn(\"No valid template nodes found after filtering\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n if (templateIndex < 0 || templateIndex >= templateNodes.length) {\n console.warn(\n `Invalid template index: ${templateIndex}, max index: ${templateNodes.length - 1\n }`,\n );\n\n // If we're beyond the maximum index, it means we've completed all nodes\n if (templateIndex >= templateNodes.length) {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n // If index is negative, redirect to start\n if (templateIndex < 0) {\n setTimeout(() => stepObject.setStep(0), 0);\n return <LoadingState message={t(\"loading.step\")} subtitle=\"\" />;\n }\n }\n\n // At this point, we should have a valid node\n const node = templateNodes[templateIndex];\n if (!node) {\n console.error(\n `Node at index ${templateIndex} is undefined. Available nodes:`,\n templateNodes,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.render\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"template.error.node_not_found\")}\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n {t(\"template.buttons.restart\")}\n </button>\n </div>\n );\n }\n\n switch (node.type) {\n case \"end\":\n console.log(\"📄 Rendering EndFlow component\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n\n case \"information-input\": {\n // runIndex = nombre de fois que ce step a déjà été visité dans l'historique\n // (0 = premier passage, 1 = deuxième, …).\n // On compte les occurrences de (templateIndex + 1) dans stepHistory,\n // minus 1 car le step courant est déjà dans l'historique.\n const currentStep = templateIndex + 1;\n const visitCount = stepHistory.filter((s) => s === currentStep).length;\n const runIndex = Math.max(0, visitCount - 1);\n\n // Pré-remplissage multi-ENTITÉS : si _list présent, utiliser _list[runIndex]\n // (ou {} hors borne). L'énumération de plusieurs entités successives passe\n // exclusivement par _list (cf. docs/multi-runs.md).\n // Sans _list : on pré-remplit TOUJOURS depuis le userInput persisté — y compris\n // sur une ré-entrée (boucle condition de correction, retour arrière, bouton\n // \"Corriger ma saisie\"). Une ré-entrée sans _list = corriger les MÊMES données,\n // pas en saisir de nouvelles → on ne doit pas vider le formulaire.\n const hasList = Array.isArray(\n (session.userInput as Record<string, unknown>)?._list,\n );\n let initialUserInput: UserInput;\n if (hasList) {\n const prefill = getRunPrefillData(\n session.userInput as Record<string, unknown>,\n runIndex,\n );\n initialUserInput = (prefill ?? {}) as UserInput;\n } else {\n initialUserInput = userInput;\n }\n return (\n // key={node.id} : remonte le formulaire à chaque changement de nœud, pour\n // qu'il se ré-initialise depuis initialUserInput (comportement \"refresh sans\n // refresh\"). Évite la réutilisation d'instance qui laissait customFormData\n // périmé au retour arrière entre deux nœuds information-input.\n <UserInputForm\n key={node.id}\n stepObject={stepObject}\n node={node}\n template={session.template}\n setUserInput={setUserInput}\n initialUserInput={initialUserInput}\n contactInfo={contactInfo}\n setContactInfo={setContactInfo}\n sessionId={sessionId}\n />\n );\n }\n\n case \"document-collection\": {\n return (\n <DocumentCollection\n key={`doc-collection-${templateIndex}`}\n node={node as NodeDocumentCollection}\n stepObject={stepObject}\n sessionId={sessionId}\n template={session.template}\n onContinueOnPC={onContinueOnPC}\n allowedDocumentTypes={(node.allowedDocumentTypes || []).map(\n (docType: any) => ({\n ...docType,\n side:\n typeof docType.side === \"string\" ||\n typeof docType.side === \"number\"\n ? (docType.side as DocumentTypeSide)\n : undefined,\n }),\n )}\n allowedAddingMethods={node.allowedAddingMethods || [\"download\"]}\n introductionPage={node.introductionPage}\n documentSelection={node.documentSelection}\n allowResubmission={node.allowResubmission}\n maxResubmissionAttempts={node.maxResubmissionAttempts}\n />\n );\n }\n\n case \"document-selection\":\n case \"controle-jdi\": {\n if (!node.requiredDocumentType) {\n console.error(\n \"Missing requiredDocumentType in document-selection node:\",\n node,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n Erreur de configuration\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type de document requis n'est pas spécifié dans le template.\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n Recommencer\n </button>\n </div>\n );\n }\n\n // Determine if current device is mobile for capture method\n const isMobile =\n /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(\n navigator.userAgent,\n );\n\n return (\n <DocumentCheck\n key={`doc-check-${templateIndex}`}\n stepObject={stepObject}\n node={node as NodeIdentityControl}\n sessionId={sessionId}\n documentTypeId={node.requiredDocumentType}\n acceptedCountries={node.acceptedCountries}\n onContinueOnPC={onContinueOnPC}\n isMobileCapture={isMobileTemplate && isMobile}\n allowedAddingMethods={\n node.allowedAddingMethods || [\"download\", \"picture\"]\n }\n template={session.template}\n templateIndex={templateIndex}\n setUserInput={setUserInput}\n />\n );\n // }\n }\n\n case \"biometric-capture\":\n case \"selfie-capture\":\n return (\n <Selfie\n key={`selfie-${templateIndex}`}\n stepObject={stepObject}\n sessionId={sessionId}\n node={node}\n template={session.template}\n />\n );\n\n case \"signature-electronic\":\n return (\n <SignatureElectronic\n key={`signature-${templateIndex}`}\n sessionId={sessionId}\n stepObject={stepObject}\n title={node.title}\n description={node.description}\n // Always pass a stable node identifier so backend can resolve\n // either a static DocuSeal template OR a generated PDF source.\n external_id={node.templateId || node.external_id || node.id}\n fieldMappings={node.fieldMappings}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"video-capture\":\n console.log(\"🎥 Rendering Video Work in Progress component\");\n return <VideoWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"jdd\":\n console.log(\"🚧 Rendering JDD Work in Progress component\");\n return <JDDWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"condition\":\n console.debug(\"🔀 Rendering Condition Node Handler component and well\");\n return (\n <ConditionNodeHandler\n node={node}\n session={session}\n templateNodes={templateNodes}\n stepObject={stepObject}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"external-verification\":\n console.debug(\"🔍 Rendering External Verification Node Handler\");\n return (\n <ExternalVerificationNodeHandler\n node={node}\n session={session}\n userInput={userInput}\n setUserInput={setUserInput}\n onNext={() => stepObject.goToNextStep(node.id, session.template)}\n onPrevious={() => stepObject.goBack()}\n onNavigateToNode={(nodeId: string) => {\n const idx = templateNodes.findIndex((n: any) => n.id === nodeId);\n // idx est 0-based, les steps sont 1-based → idx + 1.\n // goBackToStep tronque l'historique pour que le nœud corrigé\n // redevienne runIndex 0 (formulaire pré-rempli).\n if (idx !== -1) stepObject.goBackToStep(idx + 1);\n else stepObject.goBack();\n }}\n />\n );\n\n case \"pdf-generation\":\n console.debug(\"📄 Rendering PDF Generation component\");\n return (\n <PdfGeneration\n key={`pdf-generation-${templateIndex}`}\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n userInput={userInput}\n />\n );\n\n case \"legal-consent\":\n return (\n <LegalConsentNode\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n />\n );\n\n case \"custom\":\n // For custom nodes, we provide a basic structure that can be extended\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-blue-500 text-4xl mb-4\">🔧</div>\n <h2 className=\"text-xl font-bold text-blue-600 mb-2\">\n Nœud personnalisé\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Implémentation personnalisée requise pour: \"{node.title || node.id}\"\n </p>\n <div className=\"bg-blue-50 border border-blue-200 rounded p-3 text-left text-sm mb-4 max-w-md\">\n <p className=\"font-semibold text-blue-700 mb-2\">\n Configuration du nœud:\n </p>\n <pre className=\"text-xs overflow-auto max-h-32\">\n {JSON.stringify(\n {\n id: node.id,\n title: node.title,\n description: node.description,\n options: node.options,\n selectedOptions: node.selectedOptions,\n },\n null,\n 2,\n )}\n </pre>\n </div>\n <button\n className=\"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors\"\n onClick={() => {\n console.log(\"Custom node action:\", node);\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n\n default:\n console.warn(`❌ Type de nœud non supporté: ${node.type}`, node);\n console.log(\"❓ Available supported types:\", [\n \"end\",\n \"information-input\",\n \"document-collection\",\n \"document-selection\",\n \"document-upload\",\n \"controle-jdi\",\n \"selfie-capture\",\n \"video-capture\",\n \"country-selection\",\n \"identity-control\",\n \"jdd\",\n \"condition\",\n \"custom\",\n ]);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-yellow-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-yellow-600 mb-2\">\n Étape non supportée\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type d'étape \"{node.type}\" n'est pas pris en charge.\n </p>\n <div className=\"bg-gray-100 p-4 rounded mb-4 text-left text-xs overflow-auto max-h-32\">\n <pre>{JSON.stringify(node, null, 2)}</pre>\n </div>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => {\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n }\n};\n\nexport default TemplateNodeRenderer;\n"],"names":["useI18n","_jsxs","_jsx","EndFlow","useMemo","getOrderedJourneySteps","LoadingState","getRunPrefillData","UserInputForm","DocumentCollection","__assign","DocumentCheck","Selfie","SignatureElectronic","VideoWorkInProgress","JDDWorkInProgress","ConditionNodeHandler","ExternalVerificationNodeHandler","PdfGeneration","LegalConsentNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqCA,IAAM,oBAAoB,GAAwC,UAAC,EAYlE,EAAA;;AAXC,IAAA,IAAA,OAAO,GAAA,EAAA,CAAA,OAAA,EACP,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,aAAa,mBAAA,EACb,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,gBAAgB,GAAA,EAAA,CAAA,gBAAA;AAER,IAAA,IAAA,CAAC,GAAKA,eAAO,EAAE,EAAd;IAET,IAAI,EAAC,OAAO,KAAA,IAAA,IAAP,OAAO,KAAA,MAAA,GAAA,MAAA,GAAP,OAAO,CAAE,QAAQ,CAAA,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC;AACtD,QAAA,QACEC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC/EC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAChD,CAAC,CAAC,8BAA8B,CAAC,EAAA,CAC/B,EACLA,cAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,CAAC,CAAC,4BAA4B,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ACnB,kBAAkB;gBAClB,KAAK;gBACL,WAAW;gBACX,QAAQ;AACT,aAAA,CAAC;YACF,QACED,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,aAC/EC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACvDA,uBAAI,SAAS,EAAC,wCAAwC,EAAA,QAAA,EAAA,+BAAA,EAAA,CAEjD,EACLD,eAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAA,CAAA,yBAAA,EACb,IAAI,CAAC,IAAI,oCACzB,EACJC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,uEAAuE,EAAA,QAAA,EACpFA,kCAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAA,CAAO,EAAA,CACtC,EACNA,cAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,YAAA;4BACP,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;wBACpD,CAAC,EAAA,QAAA,EAEA,CAAC,CAAC,2BAA2B,CAAC,EAAA,CACxB,CAAA,EAAA,CACL;;AAGd;;;;"}
1
+ {"version":3,"file":"TemplateNodeRenderer.js","sources":["../../../../../src/components/template/TemplateNodeRenderer.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport Selfie from \"../session/Selfie\";\nimport VideoWorkInProgress from \"../session/VideoWorkInProgress\";\nimport DocumentCheck, { NodeIdentityControl } from \"../session/DocumentCheck\";\nimport DocumentCollection, {\n DocumentTypeSide,\n NodeDocumentCollection,\n} from \"../document-collection/DocumentCollection\";\nimport EndFlow from \"../session/EndFlow\";\nimport LoadingState from \"../states/LoadingState\";\nimport JDDWorkInProgress from \"../jdi/JDDWorkInProgress\";\nimport { getOrderedJourneySteps, getRunPrefillData } from \"../../services/sessionService\";\nimport type { SessionData, stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport UserInputForm from \"../session/UserInputForm\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ConditionNodeHandler from \"./ConditionNodeHandler\";\nimport SignatureElectronic from \"../signature-electronic/SignatureElectronic\";\nimport ExternalVerificationNodeHandler from \"./ExternalVerificationNodeHandler\";\nimport PdfGeneration from \"../session/PdfGeneration\";\nimport LegalConsentNode from \"../legal-consent/LegalConsentNode\";\n\ninterface TemplateNodeRendererProps {\n session: SessionData;\n sessionId: string;\n stepObject: stepObject;\n stepHistory: number[];\n templateIndex: number;\n onContinueOnPC: () => void;\n userInput: UserInput;\n setUserInput: React.Dispatch<React.SetStateAction<UserInput>>;\n contactInfo: ContactInfo;\n setContactInfo: React.Dispatch<React.SetStateAction<ContactInfo>>;\n isMobileTemplate: boolean;\n}\n\nconst TemplateNodeRenderer: React.FC<TemplateNodeRendererProps> = ({\n session,\n sessionId,\n stepObject,\n stepHistory,\n templateIndex,\n onContinueOnPC,\n userInput,\n setUserInput,\n contactInfo,\n setContactInfo,\n isMobileTemplate,\n}) => {\n const { t } = useI18n();\n\n if (!session?.template) {\n console.error(t(\"template.error.console_no_template\"));\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.configuration\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{t(\"template.error.no_template\")}</p>\n </div>\n );\n }\n\n // Check if session is ended before rendering nodes\n if (session.status === \"ended\") {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session.status}\n callbackURL={session.callbackURL}\n />\n );\n }\n\n // Use getOrderedWorkflowSteps to get sorted and filtered nodes\n const templateNodes = useMemo(\n () => getOrderedJourneySteps(session.template),\n [session.template],\n );\n\n // Check if index is valid\n if (templateNodes.length === 0) {\n console.warn(\"No valid template nodes found after filtering\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n if (templateIndex < 0 || templateIndex >= templateNodes.length) {\n console.warn(\n `Invalid template index: ${templateIndex}, max index: ${templateNodes.length - 1\n }`,\n );\n\n // If we're beyond the maximum index, it means we've completed all nodes\n if (templateIndex >= templateNodes.length) {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n // If index is negative, redirect to start\n if (templateIndex < 0) {\n setTimeout(() => stepObject.setStep(0), 0);\n return <LoadingState message={t(\"loading.step\")} subtitle=\"\" />;\n }\n }\n\n // At this point, we should have a valid node\n const node = templateNodes[templateIndex];\n if (!node) {\n console.error(\n `Node at index ${templateIndex} is undefined. Available nodes:`,\n templateNodes,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.render\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"template.error.node_not_found\")}\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n {t(\"template.buttons.restart\")}\n </button>\n </div>\n );\n }\n\n switch (node.type) {\n case \"end\":\n console.log(\"📄 Rendering EndFlow component\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n endNodeId={node.id}\n />\n );\n\n case \"information-input\": {\n // runIndex = nombre de fois que ce step a déjà été visité dans l'historique\n // (0 = premier passage, 1 = deuxième, …).\n // On compte les occurrences de (templateIndex + 1) dans stepHistory,\n // minus 1 car le step courant est déjà dans l'historique.\n const currentStep = templateIndex + 1;\n const visitCount = stepHistory.filter((s) => s === currentStep).length;\n const runIndex = Math.max(0, visitCount - 1);\n\n // Pré-remplissage multi-ENTITÉS : si _list présent, utiliser _list[runIndex]\n // (ou {} hors borne). L'énumération de plusieurs entités successives passe\n // exclusivement par _list (cf. docs/multi-runs.md).\n // Sans _list : on pré-remplit TOUJOURS depuis le userInput persisté — y compris\n // sur une ré-entrée (boucle condition de correction, retour arrière, bouton\n // \"Corriger ma saisie\"). Une ré-entrée sans _list = corriger les MÊMES données,\n // pas en saisir de nouvelles → on ne doit pas vider le formulaire.\n const hasList = Array.isArray(\n (session.userInput as Record<string, unknown>)?._list,\n );\n let initialUserInput: UserInput;\n if (hasList) {\n const prefill = getRunPrefillData(\n session.userInput as Record<string, unknown>,\n runIndex,\n );\n initialUserInput = (prefill ?? {}) as UserInput;\n } else {\n initialUserInput = userInput;\n }\n return (\n // key={node.id} : remonte le formulaire à chaque changement de nœud, pour\n // qu'il se ré-initialise depuis initialUserInput (comportement \"refresh sans\n // refresh\"). Évite la réutilisation d'instance qui laissait customFormData\n // périmé au retour arrière entre deux nœuds information-input.\n <UserInputForm\n key={node.id}\n stepObject={stepObject}\n node={node}\n template={session.template}\n setUserInput={setUserInput}\n initialUserInput={initialUserInput}\n contactInfo={contactInfo}\n setContactInfo={setContactInfo}\n sessionId={sessionId}\n />\n );\n }\n\n case \"document-collection\": {\n return (\n <DocumentCollection\n key={`doc-collection-${templateIndex}`}\n node={node as NodeDocumentCollection}\n stepObject={stepObject}\n sessionId={sessionId}\n template={session.template}\n onContinueOnPC={onContinueOnPC}\n allowedDocumentTypes={(node.allowedDocumentTypes || []).map(\n (docType: any) => ({\n ...docType,\n side:\n typeof docType.side === \"string\" ||\n typeof docType.side === \"number\"\n ? (docType.side as DocumentTypeSide)\n : undefined,\n }),\n )}\n allowedAddingMethods={node.allowedAddingMethods || [\"download\"]}\n introductionPage={node.introductionPage}\n documentSelection={node.documentSelection}\n allowResubmission={node.allowResubmission}\n maxResubmissionAttempts={node.maxResubmissionAttempts}\n />\n );\n }\n\n case \"document-selection\":\n case \"controle-jdi\": {\n if (!node.requiredDocumentType) {\n console.error(\n \"Missing requiredDocumentType in document-selection node:\",\n node,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n Erreur de configuration\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type de document requis n'est pas spécifié dans le template.\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n Recommencer\n </button>\n </div>\n );\n }\n\n // Determine if current device is mobile for capture method\n const isMobile =\n /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(\n navigator.userAgent,\n );\n\n return (\n <DocumentCheck\n key={`doc-check-${templateIndex}`}\n stepObject={stepObject}\n node={node as NodeIdentityControl}\n sessionId={sessionId}\n documentTypeId={node.requiredDocumentType}\n acceptedCountries={node.acceptedCountries}\n onContinueOnPC={onContinueOnPC}\n isMobileCapture={isMobileTemplate && isMobile}\n allowedAddingMethods={\n node.allowedAddingMethods || [\"download\", \"picture\"]\n }\n template={session.template}\n templateIndex={templateIndex}\n setUserInput={setUserInput}\n />\n );\n // }\n }\n\n case \"biometric-capture\":\n case \"selfie-capture\":\n return (\n <Selfie\n key={`selfie-${templateIndex}`}\n stepObject={stepObject}\n sessionId={sessionId}\n node={node}\n template={session.template}\n />\n );\n\n case \"signature-electronic\":\n return (\n <SignatureElectronic\n key={`signature-${templateIndex}`}\n sessionId={sessionId}\n stepObject={stepObject}\n title={node.title}\n description={node.description}\n // Always pass a stable node identifier so backend can resolve\n // either a static DocuSeal template OR a generated PDF source.\n external_id={node.templateId || node.external_id || node.id}\n fieldMappings={node.fieldMappings}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"video-capture\":\n console.log(\"🎥 Rendering Video Work in Progress component\");\n return <VideoWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"jdd\":\n console.log(\"🚧 Rendering JDD Work in Progress component\");\n return <JDDWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"condition\":\n console.debug(\"🔀 Rendering Condition Node Handler component and well\");\n return (\n <ConditionNodeHandler\n node={node}\n session={session}\n templateNodes={templateNodes}\n stepObject={stepObject}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"external-verification\":\n console.debug(\"🔍 Rendering External Verification Node Handler\");\n return (\n <ExternalVerificationNodeHandler\n node={node}\n session={session}\n userInput={userInput}\n setUserInput={setUserInput}\n onNext={() => stepObject.goToNextStep(node.id, session.template)}\n onPrevious={() => stepObject.goBack()}\n onNavigateToNode={(nodeId: string) => {\n const idx = templateNodes.findIndex((n: any) => n.id === nodeId);\n // idx est 0-based, les steps sont 1-based → idx + 1.\n // goBackToStep tronque l'historique pour que le nœud corrigé\n // redevienne runIndex 0 (formulaire pré-rempli).\n if (idx !== -1) stepObject.goBackToStep(idx + 1);\n else stepObject.goBack();\n }}\n />\n );\n\n case \"pdf-generation\":\n console.debug(\"📄 Rendering PDF Generation component\");\n return (\n <PdfGeneration\n key={`pdf-generation-${templateIndex}`}\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n userInput={userInput}\n />\n );\n\n case \"legal-consent\":\n return (\n <LegalConsentNode\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n />\n );\n\n case \"custom\":\n // For custom nodes, we provide a basic structure that can be extended\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-blue-500 text-4xl mb-4\">🔧</div>\n <h2 className=\"text-xl font-bold text-blue-600 mb-2\">\n Nœud personnalisé\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Implémentation personnalisée requise pour: \"{node.title || node.id}\"\n </p>\n <div className=\"bg-blue-50 border border-blue-200 rounded p-3 text-left text-sm mb-4 max-w-md\">\n <p className=\"font-semibold text-blue-700 mb-2\">\n Configuration du nœud:\n </p>\n <pre className=\"text-xs overflow-auto max-h-32\">\n {JSON.stringify(\n {\n id: node.id,\n title: node.title,\n description: node.description,\n options: node.options,\n selectedOptions: node.selectedOptions,\n },\n null,\n 2,\n )}\n </pre>\n </div>\n <button\n className=\"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors\"\n onClick={() => {\n console.log(\"Custom node action:\", node);\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n\n default:\n console.warn(`❌ Type de nœud non supporté: ${node.type}`, node);\n console.log(\"❓ Available supported types:\", [\n \"end\",\n \"information-input\",\n \"document-collection\",\n \"document-selection\",\n \"document-upload\",\n \"controle-jdi\",\n \"selfie-capture\",\n \"video-capture\",\n \"country-selection\",\n \"identity-control\",\n \"jdd\",\n \"condition\",\n \"custom\",\n ]);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-yellow-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-yellow-600 mb-2\">\n Étape non supportée\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type d'étape \"{node.type}\" n'est pas pris en charge.\n </p>\n <div className=\"bg-gray-100 p-4 rounded mb-4 text-left text-xs overflow-auto max-h-32\">\n <pre>{JSON.stringify(node, null, 2)}</pre>\n </div>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => {\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n }\n};\n\nexport default TemplateNodeRenderer;\n"],"names":["useI18n","_jsxs","_jsx","EndFlow","useMemo","getOrderedJourneySteps","LoadingState","getRunPrefillData","UserInputForm","DocumentCollection","__assign","DocumentCheck","Selfie","SignatureElectronic","VideoWorkInProgress","JDDWorkInProgress","ConditionNodeHandler","ExternalVerificationNodeHandler","Pd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AAA,EAAK,SAAS,EAAC,kEAAkE,aAC/EC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACvDA,uBAAI,SAAS,EAAC,wCAAwC,EAAA,QAAA,EAAA,+BAAA,EAAA,CAEjD,EACLD,eAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAA,CAAA,yBAAA,EACb,IAAI,CAAC,IAAI,oCACzB,EACJC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,uEAAuE,EAAA,QAAA,EACpFA,kCAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAA,CAAO,EAAA,CACtC,EACNA,cAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,YAAA;4BACP,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;wBACpD,CAAC,EAAA,QAAA,EAEA,CAAC,CAAC,2BAA2B,CAAC,EAAA,CACxB,CAAA,EAAA,CACL;;AAGd;;;;"}
@@ -117,17 +117,17 @@ var updateSessionContactInfo = function (sessionId, contactInfo) { return tslib_
117
117
  *
118
118
  * @param sessionId - The unique identifier of the session
119
119
  * @param status - The new status for the session
120
+ * @param reachedEndNodeId - Id of the end node actually reached (when status is "ended"),
121
+ * so the backend can force the correct final status with multiple end nodes.
120
122
  * @returns The updated session data
121
123
  */
122
- var updateSessionStatus = function (sessionId, status) { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
124
+ var updateSessionStatus = function (sessionId, status, reachedEndNodeId) { return tslib_es6.__awaiter(void 0, void 0, void 0, function () {
123
125
  var response, err_1, error_5;
124
126
  return tslib_es6.__generator(this, function (_a) {
125
127
  switch (_a.label) {
126
128
  case 0:
127
129
  _a.trys.push([0, 6, , 7]);
128
- return [4 /*yield*/, api.apiService.patch("/session/sdk/".concat(sessionId), {
129
- status: status,
130
- })];
130
+ return [4 /*yield*/, api.apiService.patch("/session/sdk/".concat(sessionId), tslib_es6.__assign({ status: status }, (reachedEndNodeId ? { reachedEndNodeId: reachedEndNodeId } : {})))];
131
131
  case 1:
132
132
  response = _a.sent();
133
133
  if (!(response.data && response.data.analysisId)) return [3 /*break*/, 5];
@@ -1 +1 @@
1
- {"version":3,"file":"sessionService.js","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n\n/**\n * Returns the pre-fill data for a given run index from a `userInput` object\n * that contains a `_list` array.\n *\n * Convention: when the integrator wants to pre-fill different data per run\n * (e.g. multiple persons in a loop), they pass `userInput: { _list: [...] }`\n * at session creation. Each element in `_list` corresponds to a run (0-indexed).\n *\n * @param userInput - The session's userInput object\n * @param runIndex - The current run index (0 = first pass, 1 = second pass, …)\n * @returns The pre-fill data for that run, or null if not defined\n */\nexport const getRunPrefillData = (\n userInput: Record<string, unknown>,\n runIndex: number,\n): Record<string, unknown> | null => {\n const list = userInput?._list;\n if (!Array.isArray(list)) return null;\n return (list[runIndex] as Record<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","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @param reachedEndNodeId - Id of the end node actually reached (when status is \"ended\"),\n * so the backend can force the correct final status with multiple end nodes.\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n reachedEndNodeId?: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n ...(reachedEndNodeId ? { reachedEndNodeId } : {}),\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n\n/**\n * Returns the pre-fill data for a given run index from a `userInput` object\n * that contains a `_list` array.\n *\n * Convention: when the integrator wants to pre-fill different data per run\n * (e.g. multiple persons in a loop), they pass `userInput: { _list: [...] }`\n * at session creation. Each element in `_list` corresponds to a run (0-indexed).\n *\n * @param userInput - The session's userInput object\n * @param runIndex - The current run index (0 = first pass, 1 = second pass, …)\n * @returns The pre-fill data for that run, or null if not defined\n */\nexport const getRunPrefillData = (\n userInput: Record<string, unknown>,\n runIndex: number,\n): Record<string, unknown> | null => {\n const list = userInput?._list;\n if (!Array.isArray(list)) return null;\n return (list[runIndex] as Record<string, unknown>) ?? null;\n};\n"],"names":["__awaiter","apiService","__assign","logStatusModified","clearSessionMemory"],"mappings":";;;;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SA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vars
26
26
  var EndFlow = function (_a) {
27
- var sessionId = _a.sessionId, sessionStatus = _a.sessionStatus, callbackURL = _a.callbackURL;
27
+ var sessionId = _a.sessionId, sessionStatus = _a.sessionStatus, callbackURL = _a.callbackURL, endNodeId = _a.endNodeId;
28
28
  var _b = useState(false), isEnding = _b[0], setIsEnding = _b[1];
29
29
  var _c = useState(false), isRedirecting = _c[0], setIsRedirecting = _c[1];
30
30
  var _d = useState(false), shouldRedirect = _d[0], setShouldRedirect = _d[1];
@@ -32,7 +32,7 @@ var EndFlow = function (_a) {
32
32
  // Trigger session end as soon as the user reaches this screen,
33
33
  // regardless of whether they click the button (e.g. tab close)
34
34
  useEffect(function () {
35
- updateSessionStatus(sessionId, "ended")
35
+ updateSessionStatus(sessionId, "ended", endNodeId)
36
36
  .then(function (updatedSession) {
37
37
  if (updatedSession && updatedSession.analysisId) {
38
38
  logSessionEnded(sessionId).catch(function (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"EndFlow.js","sources":["../../../../../src/components/session/EndFlow.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport type { stepObject } from \"../../types/session\";\nimport checkIcon from \"../../assets/check.svg\";\nimport Button from \"../ui/Button\";\nimport PageActions from \"../ui/PageActions\";\nimport Title from \"../ui/Title\";\nimport Subtitle from \"../ui/Subtitle\";\nimport {\n clearSessionSensitiveData,\n updateSessionStatus,\n} from \"../../services/sessionService\";\nimport { logSessionEnded } from \"../../services/auditTrailService\";\nimport MobilePageLayout from \"../ui/MobilePageLayout\";\nimport { useI18n } from \"../../hooks/useI18n\";\n\ninterface EndFlowProps {\n sessionId: string;\n sessionStatus?: string; // Ajout du statut de session optionnel\n callbackURL?: string | null;\n}\n\n/**\n * EndFlow Component\n *\n * Composant affiché à la fin du flux de vérification lorsque toutes les étapes ont été complétées.\n * Affiche un message de confirmation avec une icône de succès.\n *\n * @param {EndFlowProps} props - Propriétés du composant\n * @param {string} props.sessionId - L'identifiant de la session\n * @param {string} props.sessionStatus - Le statut actuel de la session\n * @returns {JSX.Element} Le composant EndFlow\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst EndFlow: React.FC<EndFlowProps> = ({\n sessionId,\n sessionStatus,\n callbackURL,\n}) => {\n const [isEnding, setIsEnding] = useState(false);\n const [isRedirecting, setIsRedirecting] = useState(false);\n const [shouldRedirect, setShouldRedirect] = useState(false);\n const { t } = useI18n();\n\n // Trigger session end as soon as the user reaches this screen,\n // regardless of whether they click the button (e.g. tab close)\n useEffect(() => {\n updateSessionStatus(sessionId, \"ended\")\n .then((updatedSession) => {\n if (updatedSession && updatedSession.analysisId) {\n logSessionEnded(sessionId).catch((err) => {\n console.error(\"Failed to log session end in audit trail:\", err);\n });\n }\n })\n .catch((error) => {\n console.error(\"Error updating session status on EndFlow mount:\", error);\n });\n }, []);\n\n const handleEndSession = async () => {\n setIsEnding(true);\n try {\n clearSessionSensitiveData(sessionId);\n } catch (error) {\n console.error(\"Erreur lors de la finalisation de la session:\", error);\n } finally {\n setIsEnding(false);\n if (callbackURL) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n } else {\n // Forcer la fermeture immédiatement lorsqu'aucune redirection n'est attendue\n closeWindow();\n }\n }\n };\n\n const redirectToCallback = (url: string) => {\n try {\n window.location.replace(url);\n } catch (e) {\n console.error(\"Redirection vers le callback échouée:\", e);\n setIsRedirecting(false);\n closeWindow();\n }\n };\n\n useEffect(() => {\n if (sessionStatus === \"ended\" && callbackURL && !shouldRedirect) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n }\n }, [sessionStatus, callbackURL, shouldRedirect]);\n\n useEffect(() => {\n if (!shouldRedirect || !callbackURL) {\n return;\n }\n\n const REDIRECT_DELAY_MS = 2000;\n const timer = window.setTimeout(\n () => redirectToCallback(callbackURL),\n REDIRECT_DELAY_MS,\n );\n return () => window.clearTimeout(timer);\n }, [shouldRedirect, callbackURL]);\n\n const closeWindow = () => {\n console.log(\"Tentative de fermeture de la fenêtre...\");\n\n // Méthode 1: Si dans un iframe, communiquer avec le parent IMMÉDIATEMENT\n if (window.parent && window.parent !== window) {\n try {\n window.parent.postMessage(\n {\n action: \"closeSession\",\n sessionId,\n status: \"ended\",\n message: \"Session terminée, veuillez fermer cette fenêtre\",\n },\n \"*\",\n );\n console.log(\"Message envoyé au parent pour fermeture\");\n } catch (e) {\n console.log(\"postMessage échoué:\", e);\n }\n }\n\n // Méthode 2: Essayer window.close() avec différentes approches\n try {\n // Essayer close direct\n window.close();\n console.log(\"window.close() direct appelé\");\n } catch (e) {\n console.log(\"window.close() direct échoué:\", e);\n }\n\n // Méthode 3: Si on a un opener, essayer de se fermer via l'opener\n setTimeout(() => {\n try {\n if (window.opener) {\n window.opener.focus();\n window.close();\n console.log(\"Fermeture via opener\");\n }\n } catch (e) {\n console.log(\"Fermeture via opener échouée:\", e);\n }\n }, 100);\n\n // Méthode 4: Forcer avec self.close()\n setTimeout(() => {\n try {\n self.close();\n console.log(\"self.close() appelé\");\n } catch (e) {\n console.log(\"self.close() échoué:\", e);\n }\n }, 200);\n\n // Méthode 5: Essayer de manipuler l'historique pour forcer la fermeture\n setTimeout(() => {\n try {\n window.history.back();\n window.close();\n console.log(\"history.back() + close\");\n } catch (e) {\n console.log(\"history.back() + close échoué:\", e);\n }\n }, 300);\n\n // Méthode 6: Rediriger vers une page de fermeture personnalisée\n setTimeout(() => {\n try {\n // Créer une URL de données avec un script de fermeture automatique\n const closeScript = `\n <html>\n <head><title>Session terminée</title></head>\n <body style=\"margin:0;padding:0;background:#f0f0f0;font-family:Arial,sans-serif;\">\n <div style=\"display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;text-align:center;\">\n <h1 style=\"color:#4ade80;margin-bottom:20px;\">✅ Session terminée avec succès</h1>\n <p style=\"color:#666;margin-bottom:30px;\">Cette fenêtre va se fermer automatiquement.</p>\n <button onclick=\"attemptClose()\" style=\"background:#3b82f6;color:white;border:none;padding:12px 24px;border-radius:6px;cursor:pointer;font-size:16px;\">\n Fermer maintenant\n </button>\n </div>\n <script>\n function attemptClose() {\n try {\n window.close();\n self.close();\n if (window.opener) {\n window.opener.focus();\n window.close();\n }\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({action:'closeWindow'}, '*');\n }\n } catch(e) {\n console.log('Fermeture impossible:', e);\n document.body.innerHTML = '<div style=\"text-align:center;padding:50px;\"><h2>Veuillez fermer cette fenêtre manuellement</h2><p>Appuyez sur Alt+F4 ou cliquez sur le X</p></div>';\n }\n }\n // Essayer de fermer automatiquement après 1 seconde\n setTimeout(attemptClose, 1000);\n </script>\n </body>\n </html>\n `;\n const dataUrl =\n \"data:text/html;charset=utf-8,\" + encodeURIComponent(closeScript);\n window.location.replace(dataUrl);\n console.log(\"Redirection vers page de fermeture personnalisée\");\n } catch (e) {\n console.log(\"Redirection vers page personnalisée échouée:\", e);\n }\n }, 500);\n };\n return (\n <MobilePageLayout\n footer={\n <PageActions\n primary={\n <Button\n onClick={handleEndSession}\n disabled={isEnding || isRedirecting}\n >\n {isRedirecting\n ? t(\"session.end.button_redirecting\", \"Redirection...\")\n : isEnding\n ? t(\"session.end.button_finalizing\", \"Finalisation...\")\n : t(\"session.end.button_end\", \"Terminer\")}\n </Button>\n }\n />\n }\n >\n <div className=\"flex flex-col items-center justify-center px-4 py-8 md:px-8\">\n <div className=\"w-full max-w-md mx-auto text-center space-y-6\">\n {/* Icon - shown on top for both mobile and desktop */}\n <div className=\"flex justify-center\">\n <img\n src={checkIcon}\n alt={t(\"session.end.image_alt\", \"Vérification terminée\")}\n className=\"w-48 h-48\"\n />\n </div>\n\n {/* Text content */}\n <div className=\"space-y-4\">\n <Title className=\"text-xl md:text-2xl lg:text-3xl\">\n {t(\"session.end.title\", \"C'est tout bon !\")}\n </Title>\n <Subtitle className=\"text-sm md:text-base text-gray-600 leading-relaxed\">\n {t(\n \"session.end.subtitle\",\n \"Merci d'avoir terminé ce parcours, vous pouvez quitter cette fenêtre.\",\n )}\n </Subtitle>\n </div>\n </div>\n </div>\n </Mobil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,gBAAgB;AACtD,sBAAE;AACA,0BAAE,CAAC,CAAC,+BAA+B,EAAE,iBAAiB;AACtD,0BAAE,CAAC,CAAC,wBAAwB,EAAE,UAAU,CAAC,EAAA,CACtC,EAAA,CAEX,EAAA,QAAA,EAGJA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,6DAA6D,YAC1EC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+CAA+C,EAAA,QAAA,EAAA,CAE5DD,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAAA,QAAA,EAClCA,aACE,GAAG,EAAEE,GAAS,EACd,GAAG,EAAE,CAAC,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,EACxD,SAAS,EAAC,WAAW,EAAA,CACrB,EAAA,CACE,EAGND,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,WAAW,EAAA,QAAA,EAAA,CACxBD,IAAC,KAAK,EAAA,EAAC,SAAS,EAAC,iCAAiC,EAAA,QAAA,EAC/C,CAAC,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,EAAA,CACrC,EACRA,GAAA,CAAC,QAAQ,EAAA,EAAC,SAAS,EAAC,oDAAoD,EAAA,QAAA,EACrE,CAAC,CACA,sBAAsB,EACtB,uEAAuE,CACxE,EAAA,CACQ,CAAA,EAAA,CACP,IACF,EAAA,CACF,EAAA,CACW;AAEvB;;;;"}
1
+ {"version":3,"file":"EndFlow.js","sources":["../../../../../src/components/session/EndFlow.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport type { stepObject } from \"../../types/session\";\nimport checkIcon from \"../../assets/check.svg\";\nimport Button from \"../ui/Button\";\nimport PageActions from \"../ui/PageActions\";\nimport Title from \"../ui/Title\";\nimport Subtitle from \"../ui/Subtitle\";\nimport {\n clearSessionSensitiveData,\n updateSessionStatus,\n} from \"../../services/sessionService\";\nimport { logSessionEnded } from \"../../services/auditTrailService\";\nimport MobilePageLayout from \"../ui/MobilePageLayout\";\nimport { useI18n } from \"../../hooks/useI18n\";\n\ninterface EndFlowProps {\n sessionId: string;\n sessionStatus?: string; // Ajout du statut de session optionnel\n callbackURL?: string | null;\n endNodeId?: string; // Id du nœud `end` atteint, transmis au backend pour forcer le bon statut\n}\n\n/**\n * EndFlow Component\n *\n * Composant affiché à la fin du flux de vérification lorsque toutes les étapes ont été complétées.\n * Affiche un message de confirmation avec une icône de succès.\n *\n * @param {EndFlowProps} props - Propriétés du composant\n * @param {string} props.sessionId - L'identifiant de la session\n * @param {string} props.sessionStatus - Le statut actuel de la session\n * @returns {JSX.Element} Le composant EndFlow\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst EndFlow: React.FC<EndFlowProps> = ({\n sessionId,\n sessionStatus,\n callbackURL,\n endNodeId,\n}) => {\n const [isEnding, setIsEnding] = useState(false);\n const [isRedirecting, setIsRedirecting] = useState(false);\n const [shouldRedirect, setShouldRedirect] = useState(false);\n const { t } = useI18n();\n\n // Trigger session end as soon as the user reaches this screen,\n // regardless of whether they click the button (e.g. tab close)\n useEffect(() => {\n updateSessionStatus(sessionId, \"ended\", endNodeId)\n .then((updatedSession) => {\n if (updatedSession && updatedSession.analysisId) {\n logSessionEnded(sessionId).catch((err) => {\n console.error(\"Failed to log session end in audit trail:\", err);\n });\n }\n })\n .catch((error) => {\n console.error(\"Error updating session status on EndFlow mount:\", error);\n });\n }, []);\n\n const handleEndSession = async () => {\n setIsEnding(true);\n try {\n clearSessionSensitiveData(sessionId);\n } catch (error) {\n console.error(\"Erreur lors de la finalisation de la session:\", error);\n } finally {\n setIsEnding(false);\n if (callbackURL) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n } else {\n // Forcer la fermeture immédiatement lorsqu'aucune redirection n'est attendue\n closeWindow();\n }\n }\n };\n\n const redirectToCallback = (url: string) => {\n try {\n window.location.replace(url);\n } catch (e) {\n console.error(\"Redirection vers le callback échouée:\", e);\n setIsRedirecting(false);\n closeWindow();\n }\n };\n\n useEffect(() => {\n if (sessionStatus === \"ended\" && callbackURL && !shouldRedirect) {\n setIsRedirecting(true);\n setShouldRedirect(true);\n }\n }, [sessionStatus, callbackURL, shouldRedirect]);\n\n useEffect(() => {\n if (!shouldRedirect || !callbackURL) {\n return;\n }\n\n const REDIRECT_DELAY_MS = 2000;\n const timer = window.setTimeout(\n () => redirectToCallback(callbackURL),\n REDIRECT_DELAY_MS,\n );\n return () => window.clearTimeout(timer);\n }, [shouldRedirect, callbackURL]);\n\n const closeWindow = () => {\n console.log(\"Tentative de fermeture de la fenêtre...\");\n\n // Méthode 1: Si dans un iframe, communiquer avec le parent IMMÉDIATEMENT\n if (window.parent && window.parent !== window) {\n try {\n window.parent.postMessage(\n {\n action: \"closeSession\",\n sessionId,\n status: \"ended\",\n message: \"Session terminée, veuillez fermer cette fenêtre\",\n },\n \"*\",\n );\n console.log(\"Message envoyé au parent pour fermeture\");\n } catch (e) {\n console.log(\"postMessage échoué:\", e);\n }\n }\n\n // Méthode 2: Essayer window.close() avec différentes approches\n try {\n // Essayer close direct\n window.close();\n console.log(\"window.close() direct appelé\");\n } catch (e) {\n console.log(\"window.close() direct échoué:\", e);\n }\n\n // Méthode 3: Si on a un opener, essayer de se fermer via l'opener\n setTimeout(() => {\n try {\n if (window.opener) {\n window.opener.focus();\n window.close();\n console.log(\"Fermeture via opener\");\n }\n } catch (e) {\n console.log(\"Fermeture via opener échouée:\", e);\n }\n }, 100);\n\n // Méthode 4: Forcer avec self.close()\n setTimeout(() => {\n try {\n self.close();\n console.log(\"self.close() appelé\");\n } catch (e) {\n console.log(\"self.close() échoué:\", e);\n }\n }, 200);\n\n // Méthode 5: Essayer de manipuler l'historique pour forcer la fermeture\n setTimeout(() => {\n try {\n window.history.back();\n window.close();\n console.log(\"history.back() + close\");\n } catch (e) {\n console.log(\"history.back() + close échoué:\", e);\n }\n }, 300);\n\n // Méthode 6: Rediriger vers une page de fermeture personnalisée\n setTimeout(() => {\n try {\n // Créer une URL de données avec un script de fermeture automatique\n const closeScript = `\n <html>\n <head><title>Session terminée</title></head>\n <body style=\"margin:0;padding:0;background:#f0f0f0;font-family:Arial,sans-serif;\">\n <div style=\"display:flex;flex-direction:column;justify-content:center;align-items:center;height:100vh;text-align:center;\">\n <h1 style=\"color:#4ade80;margin-bottom:20px;\">✅ Session terminée avec succès</h1>\n <p style=\"color:#666;margin-bottom:30px;\">Cette fenêtre va se fermer automatiquement.</p>\n <button onclick=\"attemptClose()\" style=\"background:#3b82f6;color:white;border:none;padding:12px 24px;border-radius:6px;cursor:pointer;font-size:16px;\">\n Fermer maintenant\n </button>\n </div>\n <script>\n function attemptClose() {\n try {\n window.close();\n self.close();\n if (window.opener) {\n window.opener.focus();\n window.close();\n }\n if (window.parent && window.parent !== window) {\n window.parent.postMessage({action:'closeWindow'}, '*');\n }\n } catch(e) {\n console.log('Fermeture impossible:', e);\n document.body.innerHTML = '<div style=\"text-align:center;padding:50px;\"><h2>Veuillez fermer cette fenêtre manuellement</h2><p>Appuyez sur Alt+F4 ou cliquez sur le X</p></div>';\n }\n }\n // Essayer de fermer automatiquement après 1 seconde\n setTimeout(attemptClose, 1000);\n </script>\n </body>\n </html>\n `;\n const dataUrl =\n \"data:text/html;charset=utf-8,\" + encodeURIComponent(closeScript);\n window.location.replace(dataUrl);\n console.log(\"Redirection vers page de fermeture personnalisée\");\n } catch (e) {\n console.log(\"Redirection vers page personnalisée échouée:\", e);\n }\n }, 500);\n };\n return (\n <MobilePageLayout\n footer={\n <PageActions\n primary={\n <Button\n onClick={handleEndSession}\n disabled={isEnding || isRedirecting}\n >\n {isRedirecting\n ? t(\"session.end.button_redirecting\", \"Redirection...\")\n : isEnding\n ? t(\"session.end.button_finalizing\", \"Finalisation...\")\n : t(\"session.end.button_end\", \"Terminer\")}\n </Button>\n }\n />\n }\n >\n <div className=\"flex flex-col items-center justify-center px-4 py-8 md:px-8\">\n <div className=\"w-full max-w-md mx-auto text-center space-y-6\">\n {/* Icon - shown on top for both mobile and desktop */}\n <div className=\"flex justify-center\">\n <img\n src={checkIcon}\n alt={t(\"session.end.image_alt\", \"Vérification terminée\")}\n className=\"w-48 h-48\"\n />\n </div>\n\n {/* Text content */}\n <div className=\"space-y-4\">\n <Title className=\"text-xl md:text-2xl lg:text-3xl\">\n {t(\"session.end.title\", \"C'est tout bon !\")}\n </Title>\n <Subtitle className=\"text-sm md:text-base text-gray-600 leading-relaxed\">\n {t(\n \"session.end.subtitle\",\n \"Merci d'avoir terminé ce parcours, vous pouvez quitter cette fenêtre.\",\n )}\n </Subtitle>\n </div>\n </div>\n </div>\n </MobilePageLayout>\n );\n};\n\nexport default EndFlow;\n"],"names":["_jsx","_jsxs","checkIcon"],"mappings":";;;;;;;;;;;;;AAsBA;;;;;;;;;;AAUG;AACH;AACA,IAAM,OAAO,GAA2B,UAAC,EAKxC,EAAA;QAJC,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,aAAa,GAAA,EAAA,CAAA,aAAA,EACb,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,SAAS,GAAA,EAAA,CAAA,SAAA;IAEH,IAAA,EAAA,GAA0B,QAAQ,CAAC,KAAK,CAAC,EAAxC,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,WAAW,GAAA,EAAA,CAAA,CAAA,CAAmB;IACzC,IAAA,EAAA,GAAoC,QAAQ,CAAC,KAAK,CAAC,EAAlD,aAAa,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,gBAAgB,GAAA,EAAA,CAAA,CAAA,CAAmB;IACnD,IAAA,EAAA,GAAsC,QAAQ,CAAC,KAAK,CAAC,EAApD,cAAc,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,iBAAiB,GAAA,EAAA,CAAA,CAAA,CAAmB;AACnD,IAAA,IAAA,CAAC,GAAK,OAAO,EAAE,EAAd;;;AAIT,IAAA,SAAS,CAAC,YAAA;AACR,QAAA,mBAAmB,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS;aAC9C,IAAI,CAAC,UAA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CACQ,CAAA,EAAA,CACP,IACF,EAAA,CACF,EAAA,CACW;AAEvB;;;;"}
@@ -57,7 +57,7 @@ var TemplateNodeRenderer = function (_a) {
57
57
  switch (node.type) {
58
58
  case "end":
59
59
  console.log("📄 Rendering EndFlow component");
60
- return (jsx(EndFlow, { sessionId: sessionId, sessionStatus: session === null || session === void 0 ? void 0 : session.status, callbackURL: session === null || session === void 0 ? void 0 : session.callbackURL }));
60
+ return (jsx(EndFlow, { sessionId: sessionId, sessionStatus: session === null || session === void 0 ? void 0 : session.status, callbackURL: session === null || session === void 0 ? void 0 : session.callbackURL, endNodeId: node.id }));
61
61
  case "information-input": {
62
62
  // runIndex = nombre de fois que ce step a déjà été visité dans l'historique
63
63
  // (0 = premier passage, 1 = deuxième, …).
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateNodeRenderer.js","sources":["../../../../../src/components/template/TemplateNodeRenderer.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport Selfie from \"../session/Selfie\";\nimport VideoWorkInProgress from \"../session/VideoWorkInProgress\";\nimport DocumentCheck, { NodeIdentityControl } from \"../session/DocumentCheck\";\nimport DocumentCollection, {\n DocumentTypeSide,\n NodeDocumentCollection,\n} from \"../document-collection/DocumentCollection\";\nimport EndFlow from \"../session/EndFlow\";\nimport LoadingState from \"../states/LoadingState\";\nimport JDDWorkInProgress from \"../jdi/JDDWorkInProgress\";\nimport { getOrderedJourneySteps, getRunPrefillData } from \"../../services/sessionService\";\nimport type { SessionData, stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport UserInputForm from \"../session/UserInputForm\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ConditionNodeHandler from \"./ConditionNodeHandler\";\nimport SignatureElectronic from \"../signature-electronic/SignatureElectronic\";\nimport ExternalVerificationNodeHandler from \"./ExternalVerificationNodeHandler\";\nimport PdfGeneration from \"../session/PdfGeneration\";\nimport LegalConsentNode from \"../legal-consent/LegalConsentNode\";\n\ninterface TemplateNodeRendererProps {\n session: SessionData;\n sessionId: string;\n stepObject: stepObject;\n stepHistory: number[];\n templateIndex: number;\n onContinueOnPC: () => void;\n userInput: UserInput;\n setUserInput: React.Dispatch<React.SetStateAction<UserInput>>;\n contactInfo: ContactInfo;\n setContactInfo: React.Dispatch<React.SetStateAction<ContactInfo>>;\n isMobileTemplate: boolean;\n}\n\nconst TemplateNodeRenderer: React.FC<TemplateNodeRendererProps> = ({\n session,\n sessionId,\n stepObject,\n stepHistory,\n templateIndex,\n onContinueOnPC,\n userInput,\n setUserInput,\n contactInfo,\n setContactInfo,\n isMobileTemplate,\n}) => {\n const { t } = useI18n();\n\n if (!session?.template) {\n console.error(t(\"template.error.console_no_template\"));\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.configuration\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{t(\"template.error.no_template\")}</p>\n </div>\n );\n }\n\n // Check if session is ended before rendering nodes\n if (session.status === \"ended\") {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session.status}\n callbackURL={session.callbackURL}\n />\n );\n }\n\n // Use getOrderedWorkflowSteps to get sorted and filtered nodes\n const templateNodes = useMemo(\n () => getOrderedJourneySteps(session.template),\n [session.template],\n );\n\n // Check if index is valid\n if (templateNodes.length === 0) {\n console.warn(\"No valid template nodes found after filtering\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n if (templateIndex < 0 || templateIndex >= templateNodes.length) {\n console.warn(\n `Invalid template index: ${templateIndex}, max index: ${templateNodes.length - 1\n }`,\n );\n\n // If we're beyond the maximum index, it means we've completed all nodes\n if (templateIndex >= templateNodes.length) {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n // If index is negative, redirect to start\n if (templateIndex < 0) {\n setTimeout(() => stepObject.setStep(0), 0);\n return <LoadingState message={t(\"loading.step\")} subtitle=\"\" />;\n }\n }\n\n // At this point, we should have a valid node\n const node = templateNodes[templateIndex];\n if (!node) {\n console.error(\n `Node at index ${templateIndex} is undefined. Available nodes:`,\n templateNodes,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.render\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"template.error.node_not_found\")}\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n {t(\"template.buttons.restart\")}\n </button>\n </div>\n );\n }\n\n switch (node.type) {\n case \"end\":\n console.log(\"📄 Rendering EndFlow component\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n\n case \"information-input\": {\n // runIndex = nombre de fois que ce step a déjà été visité dans l'historique\n // (0 = premier passage, 1 = deuxième, …).\n // On compte les occurrences de (templateIndex + 1) dans stepHistory,\n // minus 1 car le step courant est déjà dans l'historique.\n const currentStep = templateIndex + 1;\n const visitCount = stepHistory.filter((s) => s === currentStep).length;\n const runIndex = Math.max(0, visitCount - 1);\n\n // Pré-remplissage multi-ENTITÉS : si _list présent, utiliser _list[runIndex]\n // (ou {} hors borne). L'énumération de plusieurs entités successives passe\n // exclusivement par _list (cf. docs/multi-runs.md).\n // Sans _list : on pré-remplit TOUJOURS depuis le userInput persisté — y compris\n // sur une ré-entrée (boucle condition de correction, retour arrière, bouton\n // \"Corriger ma saisie\"). Une ré-entrée sans _list = corriger les MÊMES données,\n // pas en saisir de nouvelles → on ne doit pas vider le formulaire.\n const hasList = Array.isArray(\n (session.userInput as Record<string, unknown>)?._list,\n );\n let initialUserInput: UserInput;\n if (hasList) {\n const prefill = getRunPrefillData(\n session.userInput as Record<string, unknown>,\n runIndex,\n );\n initialUserInput = (prefill ?? {}) as UserInput;\n } else {\n initialUserInput = userInput;\n }\n return (\n // key={node.id} : remonte le formulaire à chaque changement de nœud, pour\n // qu'il se ré-initialise depuis initialUserInput (comportement \"refresh sans\n // refresh\"). Évite la réutilisation d'instance qui laissait customFormData\n // périmé au retour arrière entre deux nœuds information-input.\n <UserInputForm\n key={node.id}\n stepObject={stepObject}\n node={node}\n template={session.template}\n setUserInput={setUserInput}\n initialUserInput={initialUserInput}\n contactInfo={contactInfo}\n setContactInfo={setContactInfo}\n sessionId={sessionId}\n />\n );\n }\n\n case \"document-collection\": {\n return (\n <DocumentCollection\n key={`doc-collection-${templateIndex}`}\n node={node as NodeDocumentCollection}\n stepObject={stepObject}\n sessionId={sessionId}\n template={session.template}\n onContinueOnPC={onContinueOnPC}\n allowedDocumentTypes={(node.allowedDocumentTypes || []).map(\n (docType: any) => ({\n ...docType,\n side:\n typeof docType.side === \"string\" ||\n typeof docType.side === \"number\"\n ? (docType.side as DocumentTypeSide)\n : undefined,\n }),\n )}\n allowedAddingMethods={node.allowedAddingMethods || [\"download\"]}\n introductionPage={node.introductionPage}\n documentSelection={node.documentSelection}\n allowResubmission={node.allowResubmission}\n maxResubmissionAttempts={node.maxResubmissionAttempts}\n />\n );\n }\n\n case \"document-selection\":\n case \"controle-jdi\": {\n if (!node.requiredDocumentType) {\n console.error(\n \"Missing requiredDocumentType in document-selection node:\",\n node,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n Erreur de configuration\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type de document requis n'est pas spécifié dans le template.\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n Recommencer\n </button>\n </div>\n );\n }\n\n // Determine if current device is mobile for capture method\n const isMobile =\n /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(\n navigator.userAgent,\n );\n\n return (\n <DocumentCheck\n key={`doc-check-${templateIndex}`}\n stepObject={stepObject}\n node={node as NodeIdentityControl}\n sessionId={sessionId}\n documentTypeId={node.requiredDocumentType}\n acceptedCountries={node.acceptedCountries}\n onContinueOnPC={onContinueOnPC}\n isMobileCapture={isMobileTemplate && isMobile}\n allowedAddingMethods={\n node.allowedAddingMethods || [\"download\", \"picture\"]\n }\n template={session.template}\n templateIndex={templateIndex}\n setUserInput={setUserInput}\n />\n );\n // }\n }\n\n case \"biometric-capture\":\n case \"selfie-capture\":\n return (\n <Selfie\n key={`selfie-${templateIndex}`}\n stepObject={stepObject}\n sessionId={sessionId}\n node={node}\n template={session.template}\n />\n );\n\n case \"signature-electronic\":\n return (\n <SignatureElectronic\n key={`signature-${templateIndex}`}\n sessionId={sessionId}\n stepObject={stepObject}\n title={node.title}\n description={node.description}\n // Always pass a stable node identifier so backend can resolve\n // either a static DocuSeal template OR a generated PDF source.\n external_id={node.templateId || node.external_id || node.id}\n fieldMappings={node.fieldMappings}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"video-capture\":\n console.log(\"🎥 Rendering Video Work in Progress component\");\n return <VideoWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"jdd\":\n console.log(\"🚧 Rendering JDD Work in Progress component\");\n return <JDDWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"condition\":\n console.debug(\"🔀 Rendering Condition Node Handler component and well\");\n return (\n <ConditionNodeHandler\n node={node}\n session={session}\n templateNodes={templateNodes}\n stepObject={stepObject}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"external-verification\":\n console.debug(\"🔍 Rendering External Verification Node Handler\");\n return (\n <ExternalVerificationNodeHandler\n node={node}\n session={session}\n userInput={userInput}\n setUserInput={setUserInput}\n onNext={() => stepObject.goToNextStep(node.id, session.template)}\n onPrevious={() => stepObject.goBack()}\n onNavigateToNode={(nodeId: string) => {\n const idx = templateNodes.findIndex((n: any) => n.id === nodeId);\n // idx est 0-based, les steps sont 1-based → idx + 1.\n // goBackToStep tronque l'historique pour que le nœud corrigé\n // redevienne runIndex 0 (formulaire pré-rempli).\n if (idx !== -1) stepObject.goBackToStep(idx + 1);\n else stepObject.goBack();\n }}\n />\n );\n\n case \"pdf-generation\":\n console.debug(\"📄 Rendering PDF Generation component\");\n return (\n <PdfGeneration\n key={`pdf-generation-${templateIndex}`}\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n userInput={userInput}\n />\n );\n\n case \"legal-consent\":\n return (\n <LegalConsentNode\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n />\n );\n\n case \"custom\":\n // For custom nodes, we provide a basic structure that can be extended\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-blue-500 text-4xl mb-4\">🔧</div>\n <h2 className=\"text-xl font-bold text-blue-600 mb-2\">\n Nœud personnalisé\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Implémentation personnalisée requise pour: \"{node.title || node.id}\"\n </p>\n <div className=\"bg-blue-50 border border-blue-200 rounded p-3 text-left text-sm mb-4 max-w-md\">\n <p className=\"font-semibold text-blue-700 mb-2\">\n Configuration du nœud:\n </p>\n <pre className=\"text-xs overflow-auto max-h-32\">\n {JSON.stringify(\n {\n id: node.id,\n title: node.title,\n description: node.description,\n options: node.options,\n selectedOptions: node.selectedOptions,\n },\n null,\n 2,\n )}\n </pre>\n </div>\n <button\n className=\"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors\"\n onClick={() => {\n console.log(\"Custom node action:\", node);\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n\n default:\n console.warn(`❌ Type de nœud non supporté: ${node.type}`, node);\n console.log(\"❓ Available supported types:\", [\n \"end\",\n \"information-input\",\n \"document-collection\",\n \"document-selection\",\n \"document-upload\",\n \"controle-jdi\",\n \"selfie-capture\",\n \"video-capture\",\n \"country-selection\",\n \"identity-control\",\n \"jdd\",\n \"condition\",\n \"custom\",\n ]);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-yellow-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-yellow-600 mb-2\">\n Étape non supportée\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type d'étape \"{node.type}\" n'est pas pris en charge.\n </p>\n <div className=\"bg-gray-100 p-4 rounded mb-4 text-left text-xs overflow-auto max-h-32\">\n <pre>{JSON.stringify(node, null, 2)}</pre>\n </div>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => {\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n }\n};\n\nexport default TemplateNodeRenderer;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAM,oBAAoB,GAAwC,UAAC,EAYlE,EAAA;;AAXC,IAAA,IAAA,OAAO,GAAA,EAAA,CAAA,OAAA,EACP,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,aAAa,mBAAA,EACb,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,gBAAgB,GAAA,EAAA,CAAA,gBAAA;AAER,IAAA,IAAA,CAAC,GAAK,OAAO,EAAE,EAAd;IAET,IAAI,EAAC,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,EAAE,OAAO,CAAC,QAAQ,CAAC;wBACpD,CAAC,EAAA,QAAA,EAEA,CAAC,CAAC,2BAA2B,CAAC,EAAA,CACxB,CAAA,EAAA,CACL;;AAGd;;;;"}
1
+ {"version":3,"file":"TemplateNodeRenderer.js","sources":["../../../../../src/components/template/TemplateNodeRenderer.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport Selfie from \"../session/Selfie\";\nimport VideoWorkInProgress from \"../session/VideoWorkInProgress\";\nimport DocumentCheck, { NodeIdentityControl } from \"../session/DocumentCheck\";\nimport DocumentCollection, {\n DocumentTypeSide,\n NodeDocumentCollection,\n} from \"../document-collection/DocumentCollection\";\nimport EndFlow from \"../session/EndFlow\";\nimport LoadingState from \"../states/LoadingState\";\nimport JDDWorkInProgress from \"../jdi/JDDWorkInProgress\";\nimport { getOrderedJourneySteps, getRunPrefillData } from \"../../services/sessionService\";\nimport type { SessionData, stepObject } from \"../../types/session\";\nimport type { UserInput } from \"../../types/userInput\";\nimport type { ContactInfo } from \"../../types/contactInfo\";\nimport UserInputForm from \"../session/UserInputForm\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ConditionNodeHandler from \"./ConditionNodeHandler\";\nimport SignatureElectronic from \"../signature-electronic/SignatureElectronic\";\nimport ExternalVerificationNodeHandler from \"./ExternalVerificationNodeHandler\";\nimport PdfGeneration from \"../session/PdfGeneration\";\nimport LegalConsentNode from \"../legal-consent/LegalConsentNode\";\n\ninterface TemplateNodeRendererProps {\n session: SessionData;\n sessionId: string;\n stepObject: stepObject;\n stepHistory: number[];\n templateIndex: number;\n onContinueOnPC: () => void;\n userInput: UserInput;\n setUserInput: React.Dispatch<React.SetStateAction<UserInput>>;\n contactInfo: ContactInfo;\n setContactInfo: React.Dispatch<React.SetStateAction<ContactInfo>>;\n isMobileTemplate: boolean;\n}\n\nconst TemplateNodeRenderer: React.FC<TemplateNodeRendererProps> = ({\n session,\n sessionId,\n stepObject,\n stepHistory,\n templateIndex,\n onContinueOnPC,\n userInput,\n setUserInput,\n contactInfo,\n setContactInfo,\n isMobileTemplate,\n}) => {\n const { t } = useI18n();\n\n if (!session?.template) {\n console.error(t(\"template.error.console_no_template\"));\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.configuration\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">{t(\"template.error.no_template\")}</p>\n </div>\n );\n }\n\n // Check if session is ended before rendering nodes\n if (session.status === \"ended\") {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session.status}\n callbackURL={session.callbackURL}\n />\n );\n }\n\n // Use getOrderedWorkflowSteps to get sorted and filtered nodes\n const templateNodes = useMemo(\n () => getOrderedJourneySteps(session.template),\n [session.template],\n );\n\n // Check if index is valid\n if (templateNodes.length === 0) {\n console.warn(\"No valid template nodes found after filtering\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n if (templateIndex < 0 || templateIndex >= templateNodes.length) {\n console.warn(\n `Invalid template index: ${templateIndex}, max index: ${templateNodes.length - 1\n }`,\n );\n\n // If we're beyond the maximum index, it means we've completed all nodes\n if (templateIndex >= templateNodes.length) {\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n />\n );\n }\n\n // If index is negative, redirect to start\n if (templateIndex < 0) {\n setTimeout(() => stepObject.setStep(0), 0);\n return <LoadingState message={t(\"loading.step\")} subtitle=\"\" />;\n }\n }\n\n // At this point, we should have a valid node\n const node = templateNodes[templateIndex];\n if (!node) {\n console.error(\n `Node at index ${templateIndex} is undefined. Available nodes:`,\n templateNodes,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"template.error.render\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"template.error.node_not_found\")}\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n {t(\"template.buttons.restart\")}\n </button>\n </div>\n );\n }\n\n switch (node.type) {\n case \"end\":\n console.log(\"📄 Rendering EndFlow component\");\n return (\n <EndFlow\n sessionId={sessionId}\n sessionStatus={session?.status}\n callbackURL={session?.callbackURL}\n endNodeId={node.id}\n />\n );\n\n case \"information-input\": {\n // runIndex = nombre de fois que ce step a déjà été visité dans l'historique\n // (0 = premier passage, 1 = deuxième, …).\n // On compte les occurrences de (templateIndex + 1) dans stepHistory,\n // minus 1 car le step courant est déjà dans l'historique.\n const currentStep = templateIndex + 1;\n const visitCount = stepHistory.filter((s) => s === currentStep).length;\n const runIndex = Math.max(0, visitCount - 1);\n\n // Pré-remplissage multi-ENTITÉS : si _list présent, utiliser _list[runIndex]\n // (ou {} hors borne). L'énumération de plusieurs entités successives passe\n // exclusivement par _list (cf. docs/multi-runs.md).\n // Sans _list : on pré-remplit TOUJOURS depuis le userInput persisté — y compris\n // sur une ré-entrée (boucle condition de correction, retour arrière, bouton\n // \"Corriger ma saisie\"). Une ré-entrée sans _list = corriger les MÊMES données,\n // pas en saisir de nouvelles → on ne doit pas vider le formulaire.\n const hasList = Array.isArray(\n (session.userInput as Record<string, unknown>)?._list,\n );\n let initialUserInput: UserInput;\n if (hasList) {\n const prefill = getRunPrefillData(\n session.userInput as Record<string, unknown>,\n runIndex,\n );\n initialUserInput = (prefill ?? {}) as UserInput;\n } else {\n initialUserInput = userInput;\n }\n return (\n // key={node.id} : remonte le formulaire à chaque changement de nœud, pour\n // qu'il se ré-initialise depuis initialUserInput (comportement \"refresh sans\n // refresh\"). Évite la réutilisation d'instance qui laissait customFormData\n // périmé au retour arrière entre deux nœuds information-input.\n <UserInputForm\n key={node.id}\n stepObject={stepObject}\n node={node}\n template={session.template}\n setUserInput={setUserInput}\n initialUserInput={initialUserInput}\n contactInfo={contactInfo}\n setContactInfo={setContactInfo}\n sessionId={sessionId}\n />\n );\n }\n\n case \"document-collection\": {\n return (\n <DocumentCollection\n key={`doc-collection-${templateIndex}`}\n node={node as NodeDocumentCollection}\n stepObject={stepObject}\n sessionId={sessionId}\n template={session.template}\n onContinueOnPC={onContinueOnPC}\n allowedDocumentTypes={(node.allowedDocumentTypes || []).map(\n (docType: any) => ({\n ...docType,\n side:\n typeof docType.side === \"string\" ||\n typeof docType.side === \"number\"\n ? (docType.side as DocumentTypeSide)\n : undefined,\n }),\n )}\n allowedAddingMethods={node.allowedAddingMethods || [\"download\"]}\n introductionPage={node.introductionPage}\n documentSelection={node.documentSelection}\n allowResubmission={node.allowResubmission}\n maxResubmissionAttempts={node.maxResubmissionAttempts}\n />\n );\n }\n\n case \"document-selection\":\n case \"controle-jdi\": {\n if (!node.requiredDocumentType) {\n console.error(\n \"Missing requiredDocumentType in document-selection node:\",\n node,\n );\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n Erreur de configuration\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type de document requis n'est pas spécifié dans le template.\n </p>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => stepObject.setStep(0)}\n >\n Recommencer\n </button>\n </div>\n );\n }\n\n // Determine if current device is mobile for capture method\n const isMobile =\n /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(\n navigator.userAgent,\n );\n\n return (\n <DocumentCheck\n key={`doc-check-${templateIndex}`}\n stepObject={stepObject}\n node={node as NodeIdentityControl}\n sessionId={sessionId}\n documentTypeId={node.requiredDocumentType}\n acceptedCountries={node.acceptedCountries}\n onContinueOnPC={onContinueOnPC}\n isMobileCapture={isMobileTemplate && isMobile}\n allowedAddingMethods={\n node.allowedAddingMethods || [\"download\", \"picture\"]\n }\n template={session.template}\n templateIndex={templateIndex}\n setUserInput={setUserInput}\n />\n );\n // }\n }\n\n case \"biometric-capture\":\n case \"selfie-capture\":\n return (\n <Selfie\n key={`selfie-${templateIndex}`}\n stepObject={stepObject}\n sessionId={sessionId}\n node={node}\n template={session.template}\n />\n );\n\n case \"signature-electronic\":\n return (\n <SignatureElectronic\n key={`signature-${templateIndex}`}\n sessionId={sessionId}\n stepObject={stepObject}\n title={node.title}\n description={node.description}\n // Always pass a stable node identifier so backend can resolve\n // either a static DocuSeal template OR a generated PDF source.\n external_id={node.templateId || node.external_id || node.id}\n fieldMappings={node.fieldMappings}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"video-capture\":\n console.log(\"🎥 Rendering Video Work in Progress component\");\n return <VideoWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"jdd\":\n console.log(\"🚧 Rendering JDD Work in Progress component\");\n return <JDDWorkInProgress onContinue={onContinueOnPC} />;\n\n case \"condition\":\n console.debug(\"🔀 Rendering Condition Node Handler component and well\");\n return (\n <ConditionNodeHandler\n node={node}\n session={session}\n templateNodes={templateNodes}\n stepObject={stepObject}\n userInput={userInput}\n contactInfo={contactInfo}\n />\n );\n\n case \"external-verification\":\n console.debug(\"🔍 Rendering External Verification Node Handler\");\n return (\n <ExternalVerificationNodeHandler\n node={node}\n session={session}\n userInput={userInput}\n setUserInput={setUserInput}\n onNext={() => stepObject.goToNextStep(node.id, session.template)}\n onPrevious={() => stepObject.goBack()}\n onNavigateToNode={(nodeId: string) => {\n const idx = templateNodes.findIndex((n: any) => n.id === nodeId);\n // idx est 0-based, les steps sont 1-based → idx + 1.\n // goBackToStep tronque l'historique pour que le nœud corrigé\n // redevienne runIndex 0 (formulaire pré-rempli).\n if (idx !== -1) stepObject.goBackToStep(idx + 1);\n else stepObject.goBack();\n }}\n />\n );\n\n case \"pdf-generation\":\n console.debug(\"📄 Rendering PDF Generation component\");\n return (\n <PdfGeneration\n key={`pdf-generation-${templateIndex}`}\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n userInput={userInput}\n />\n );\n\n case \"legal-consent\":\n return (\n <LegalConsentNode\n node={node}\n session={session}\n sessionId={sessionId}\n stepObject={stepObject}\n />\n );\n\n case \"custom\":\n // For custom nodes, we provide a basic structure that can be extended\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-blue-500 text-4xl mb-4\">🔧</div>\n <h2 className=\"text-xl font-bold text-blue-600 mb-2\">\n Nœud personnalisé\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Implémentation personnalisée requise pour: \"{node.title || node.id}\"\n </p>\n <div className=\"bg-blue-50 border border-blue-200 rounded p-3 text-left text-sm mb-4 max-w-md\">\n <p className=\"font-semibold text-blue-700 mb-2\">\n Configuration du nœud:\n </p>\n <pre className=\"text-xs overflow-auto max-h-32\">\n {JSON.stringify(\n {\n id: node.id,\n title: node.title,\n description: node.description,\n options: node.options,\n selectedOptions: node.selectedOptions,\n },\n null,\n 2,\n )}\n </pre>\n </div>\n <button\n className=\"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors\"\n onClick={() => {\n console.log(\"Custom node action:\", node);\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n\n default:\n console.warn(`❌ Type de nœud non supporté: ${node.type}`, node);\n console.log(\"❓ Available supported types:\", [\n \"end\",\n \"information-input\",\n \"document-collection\",\n \"document-selection\",\n \"document-upload\",\n \"controle-jdi\",\n \"selfie-capture\",\n \"video-capture\",\n \"country-selection\",\n \"identity-control\",\n \"jdd\",\n \"condition\",\n \"custom\",\n ]);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-yellow-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-yellow-600 mb-2\">\n Étape non supportée\n </h2>\n <p className=\"text-gray-600 mb-4\">\n Le type d'étape \"{node.type}\" n'est pas pris en charge.\n </p>\n <div className=\"bg-gray-100 p-4 rounded mb-4 text-left text-xs overflow-auto max-h-32\">\n <pre>{JSON.stringify(node, null, 2)}</pre>\n </div>\n <button\n className=\"px-4 py-2 bg-primary text-white rounded hover:bg-primary-dark transition-colors\"\n onClick={() => {\n stepObject.goToNextStep(node.id, session.template);\n }}\n >\n {t(\"template.buttons.continue\")}\n </button>\n </div>\n );\n }\n};\n\nexport default TemplateNodeRenderer;\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAM,oBAAoB,GAAwC,UAAC,EAYlE,EAAA;;AAXC,IAAA,IAAA,OAAO,GAAA,EAAA,CAAA,OAAA,EACP,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,aAAa,mBAAA,EACb,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,YAAY,GAAA,EAAA,CAAA,YAAA,EACZ,WAAW,GAAA,EAAA,CAAA,WAAA,EACX,cAAc,GAAA,EAAA,CAAA,cAAA,EACd,gBAAgB,GAAA,EAAA,CAAA,gBAAA;AAER,IAAA,IAAA,CAAC,GAAK,OAAO,EAAE,EAAd;IAET,IAAI,EAAC,OAAO,KAAA,IAAA,IAAP,OAAO,KAAA,MAAA,GAAA,MAAA,GAAP,OAAO,CAAE,QAAQ,CAAA,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC;AACtD,QAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC/EC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,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,IAAI,CAAE,EAAE,IAAI,CAAC;AAC/D,YAAA,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE;gBAC1C,KAAK;gBACL,mBAAmB;gBACnB,qBAAqB;gBACrB,oBAAoB;gBACpB,iBAAiB;gBACjB,cAAc;gBACd,gBAAgB;gBAChB,eAAe;gBACf,mBAAmB;gBACnB,kBAAkB;gBAClB,KAAK;gBACL,WAAW;gBACX,QAAQ;AACT,aAAA,CAAC;YACF,QACED,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,aAC/EC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,+BAA+B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACvDA,YAAI,SAAS,EAAC,wCAAwC,EAAA,QAAA,EAAA,+BAAA,EAAA,CAEjD,EACLD,IAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAA,CAAA,yBAAA,EACb,IAAI,CAAC,IAAI,oCACzB,EACJC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,uEAAuE,EAAA,QAAA,EACpFA,uBAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAA,CAAO,EAAA,CACtC,EACNA,GAAA,CAAA,QAAA,EAAA,EACE,SAAS,EAAC,iFAAiF,EAC3F,OAAO,EAAE,YAAA;4BACP,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC;wBACpD,CAAC,EAAA,QAAA,EAEA,CAAC,CAAC,2BAA2B,CAAC,EAAA,CACxB,CAAA,EAAA,CACL;;AAGd;;;;"}
@@ -1,4 +1,4 @@
1
- import { __awaiter, __generator } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __awaiter, __generator, __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { apiService } from './api.js';
3
3
  import { logStatusModified } from './auditTrailService.js';
4
4
  import { clearSessionMemory } from './sessionMemoryStore.js';
@@ -115,17 +115,17 @@ var updateSessionContactInfo = function (sessionId, contactInfo) { return __awai
115
115
  *
116
116
  * @param sessionId - The unique identifier of the session
117
117
  * @param status - The new status for the session
118
+ * @param reachedEndNodeId - Id of the end node actually reached (when status is "ended"),
119
+ * so the backend can force the correct final status with multiple end nodes.
118
120
  * @returns The updated session data
119
121
  */
120
- var updateSessionStatus = function (sessionId, status) { return __awaiter(void 0, void 0, void 0, function () {
122
+ var updateSessionStatus = function (sessionId, status, reachedEndNodeId) { return __awaiter(void 0, void 0, void 0, function () {
121
123
  var response, err_1, error_5;
122
124
  return __generator(this, function (_a) {
123
125
  switch (_a.label) {
124
126
  case 0:
125
127
  _a.trys.push([0, 6, , 7]);
126
- return [4 /*yield*/, apiService.patch("/session/sdk/".concat(sessionId), {
127
- status: status,
128
- })];
128
+ return [4 /*yield*/, apiService.patch("/session/sdk/".concat(sessionId), __assign({ status: status }, (reachedEndNodeId ? { reachedEndNodeId: reachedEndNodeId } : {})))];
129
129
  case 1:
130
130
  response = _a.sent();
131
131
  if (!(response.data && response.data.analysisId)) return [3 /*break*/, 5];
@@ -1 +1 @@
1
- {"version":3,"file":"sessionService.js","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n\n/**\n * Returns the pre-fill data for a given run index from a `userInput` object\n * that contains a `_list` array.\n *\n * Convention: when the integrator wants to pre-fill different data per run\n * (e.g. multiple persons in a loop), they pass `userInput: { _list: [...] }`\n * at session creation. Each element in `_list` corresponds to a run (0-indexed).\n *\n * @param userInput - The session's userInput object\n * @param runIndex - The current run index (0 = first pass, 1 = second pass, …)\n * @returns The pre-fill data for that run, or null if not defined\n */\nexport const getRunPrefillData = (\n userInput: Record<string, unknown>,\n runIndex: number,\n): Record<string, unknown> | null => {\n const list = userInput?._list;\n if (!Array.isArray(list)) return null;\n return (list[runIndex] as Record<string, unknown>) ?? null;\n};\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,GAAG,CAAC,uBAAgB,SAAS,CAAE,CAAC,CAAA;;AAA5D,gBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAiD;gBAClE,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,IAAI,CAAA;;;AAEpB,gBAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC;AACpD,gBAAA,MAAM,OAAK;;;;;AAIf;;;;AAIG;AACI,IAAM,cAAc,GAAG,UAC5B,SAAiB,EACjB,UAAsB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGpB,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,IAAI,CAAC,eAAA,CAAA,MAAA,CAAgB,SAAS,EAAA,cAAA,CAAc,EAAE,UAAU,CAA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AAWG;AACI,IAAM,iBAAiB,GAAG,UAC/B,SAAkC,EAClC,QAAgB,EAAA;;IAEhB,IAAM,IAAI,GAAG,SAAS,KAAA,IAAA,IAAT,SAAS,KAAA,MAAA,GAAA,MAAA,GAAT,SAAS,CAAE,KAAK;AAC7B,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AACrC,IAAA,OAAO,MAAC,IAAI,CAAC,QAAQ,CAA6B,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AAC5D;;;;"}
1
+ {"version":3,"file":"sessionService.js","sources":["../../../../src/services/sessionService.ts"],"sourcesContent":["/**\n * Session Service\n *\n * Service for interacting with the Datakeen Session API.\n * Handles fetching session data by ID.\n */\n\nimport type {\n ClientInfo,\n SessionData,\n SessionTemplate,\n SessionTemplateNode,\n} from \"../types/session\";\nimport { apiService } from \"./api\";\nimport { logStatusModified } from \"./auditTrailService\";\nimport { clearSessionMemory } from \"./sessionMemoryStore\";\n\n/**\n * Fetches session data by ID from the Datakeen backend\n *\n * @param sessionId - The unique identifier of the session\n * @returns The session data\n */\nexport const fetchSessionById = async (\n sessionId: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.get(`/session/sdk/${sessionId}`);\n return response.data;\n } catch (error) {\n console.error(\"Error fetching session data:\", error);\n throw error;\n }\n};\n\n/** Sends client information (IP, device, browser, OS) to the backend for a specific session\n *\n * @param sessionId - The unique identifier of the session\n * @param clientInfo - The client information to send\n */\nexport const sendClientInfo = async (\n sessionId: string,\n clientInfo: ClientInfo,\n): Promise<void> => {\n try {\n await apiService.post(`/session/sdk/${sessionId}/client-info`, clientInfo);\n } catch (error) {\n console.error(\"Error sending client info:\", error);\n throw error;\n }\n};\n\n/**\n * Determines if the session template has a specific type of node\n *\n * @param template - The session template\n * @param nodeType - The type of node to check for\n * @returns true if the template has a node of the specified type, false otherwise\n */\nexport const hasNodeType = (\n template: SessionTemplate,\n nodeType: string,\n): boolean => {\n return template.nodes.some((node) => node.type === nodeType);\n};\n\n/**\n * Determines if the session template has a node with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to check for\n * @returns true if the template has a node with the specified requiredDocumentType, false otherwise\n */\nexport const hasDocumentTypeNode = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): boolean => {\n return template.nodes.some(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Gets all nodes of a specific type\n *\n * @param template - The session template\n * @param nodeType - The type of node to get\n * @returns Array of nodes matching the type\n */\nexport const getNodesByType = (\n template: SessionTemplate,\n nodeType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter((node) => node.type === nodeType);\n};\n\n/**\n * Gets all nodes with a specific requiredDocumentType\n *\n * @param template - The session template\n * @param requiredDocumentType - The requiredDocumentType to get\n * @returns Array of nodes matching the requiredDocumentType\n */\nexport const getNodesByDocumentType = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): SessionTemplateNode[] => {\n return template.nodes.filter(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n};\n\n/**\n * Get document options for a specific document type\n *\n * @param template - The session template\n * @param requiredDocumentType - The document type to get options for\n * @returns Array of document options (empty if none found)\n */\nexport const getDocumentOptions = (\n template: SessionTemplate,\n requiredDocumentType: string,\n): string[] => {\n const node = template.nodes.find(\n (node) => node.requiredDocumentType === requiredDocumentType,\n );\n return node?.selectedOptions || [];\n};\n\n/**\n * Determines if the session template has a selfie step\n *\n * @param template - The session template\n * @returns true if the template has a selfie step, false otherwise\n */\nexport const hasSelfieCaptureStep = (template: SessionTemplate): boolean => {\n return hasNodeType(template, \"selfie-capture\");\n};\n\n/**\n * Determines if the session template has an ID document step\n *\n * @param template - The session template\n * @returns true if the template has an ID document step, false otherwise\n */\nexport const hasDocumentStep = (template: SessionTemplate): boolean => {\n // Check if there's any document-selection node with requiredDocumentType \"id-card\"\n // or if none specified, just check for document-selection nodes\n const hasIDCard = hasDocumentTypeNode(template, \"id-card\");\n return hasIDCard || hasNodeType(template, \"document-selection\");\n};\n\n/**\n * Determines if the session template has a JDD (proof of address) step\n *\n * @param template - The session template\n * @returns true if the template has a JDD step, false otherwise\n */\nexport const hasJDDStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"jdd\");\n};\n\n/**\n * Determines if the session template has a proof of funds step\n *\n * @param template - The session template\n * @returns true if the template has a proof of funds step, false otherwise\n */\nexport const hasProofOfFundsStep = (template: SessionTemplate): boolean => {\n return hasDocumentTypeNode(template, \"income-proof\");\n};\n\n/**\n * Determines if the session template has a document collection step\n *\n * @param template - The session template\n * @returns true if the template has a document collection step, false otherwise\n */\nexport const hasDocumentCollectionStep = (\n template: SessionTemplate,\n): boolean => {\n return hasNodeType(template, \"document-collection\");\n};\n\n/**\n * Gets all node types in the template\n *\n * @param template - The session template\n * @returns Array of node types in the template\n */\nexport const getNodeTypes = (template: SessionTemplate): string[] => {\n return Array.from(new Set(template.nodes.map((node) => node.type)));\n};\n\n/**\n * Gets all document types required in the template\n *\n * @param template - The session template\n * @returns Array of document types required in the template\n */\nexport const getRequiredDocumentTypes = (\n template: SessionTemplate,\n): string[] => {\n return Array.from(\n new Set(\n template.nodes\n .filter((node) => node.requiredDocumentType)\n .map((node) => node.requiredDocumentType!),\n ),\n );\n};\n\n/**\n * Converts template document type to internal document type\n * This helps standardize document types between the template and the application\n *\n * @param templateDocType - The document type as defined in the template\n * @returns The internal document type used by the application\n */\nexport const convertTemplateDocTypeToInternal = (\n templateDocType: string,\n): string => {\n if (!templateDocType) return \"\";\n\n // Mapping between template document types and internal document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n \"income-proof\": \"income-proof\", // Using consistent naming\n };\n\n return typeMap[templateDocType] || templateDocType;\n};\n\n/**\n * Converts internal document type to template document type\n *\n * @param internalDocType - The document type used internally by the application\n * @returns The document type as expected in the template\n */\nexport const convertInternalDocTypeToTemplate = (\n internalDocType: string,\n): string => {\n if (!internalDocType) return \"\";\n\n // Mapping between internal document types and template document types\n const typeMap: Record<string, string> = {\n \"id-card\": \"id-card\",\n jdd: \"jdd\",\n funds: \"income-proof\", // Map funds to income-proof for backwards compatibility\n \"income-proof\": \"income-proof\",\n };\n\n return typeMap[internalDocType] || internalDocType;\n};\n\n/**\n * Updates session data with user input information\n *\n * @param sessionId - The unique identifier of the session\n * @param userInput - The user input data (firstName, lastName, birthDate)\n * @returns The updated session data\n */\nexport const updateSessionUserInput = async (\n sessionId: string,\n userInput: {\n firstName?: string;\n lastName?: string;\n birthDate?: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n userInput,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session data:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session data with contact information\n *\n * @param sessionId - The unique identifier of the session\n * @param contactInfo - The contact information data (email, phoneNumber)\n * @returns The updated session data\n */\nexport const updateSessionContactInfo = async (\n sessionId: string,\n contactInfo: {\n email: string;\n phoneNumber: string;\n [key: string]: unknown;\n },\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n contactInfo,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating contact information:\", error);\n throw error;\n }\n};\n\n/**\n * Updates session status\n *\n * @param sessionId - The unique identifier of the session\n * @param status - The new status for the session\n * @param reachedEndNodeId - Id of the end node actually reached (when status is \"ended\"),\n * so the backend can force the correct final status with multiple end nodes.\n * @returns The updated session data\n */\nexport const updateSessionStatus = async (\n sessionId: string,\n status: string,\n reachedEndNodeId?: string,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n status,\n ...(reachedEndNodeId ? { reachedEndNodeId } : {}),\n });\n\n // Log status modification in audit trail\n if (response.data && response.data.analysisId) {\n try {\n await logStatusModified(\n sessionId,\n status,\n response.data.clientInfoId || undefined,\n );\n } catch (err) {\n console.error(\"Failed to log status modification in audit trail:\", err);\n // Non-blocking error - continue session\n }\n }\n\n return response.data;\n } catch (error) {\n console.error(\"Error updating session status:\", error);\n throw error;\n }\n};\n\n/**\n * Updates the current step in the session\n *\n * @param sessionId - The unique identifier of the session\n * @param currentStep - The current step index in the workflow\n * @returns The updated session data\n */\nexport const updateSessionCurrentStep = async (\n sessionId: string,\n currentStep: number,\n): Promise<SessionData> => {\n try {\n const response = await apiService.patch(`/session/sdk/${sessionId}`, {\n currentStep,\n });\n return response.data;\n } catch (error) {\n console.error(\"Error updating session current step:\", error);\n throw error;\n }\n};\n\n/**\n * Gets the journey steps from the template in order\n *\n * @param template - The session template\n * @returns Array of ordered steps\n */\nexport const getOrderedJourneySteps = (\n template: SessionTemplate,\n): SessionTemplateNode[] => {\n // Filter out only start nodes, keep end nodes for proper journey completion, then sort by order\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order);\n};\n\nconst normalizeHandle = (value?: string): string => {\n return (value || \"\").trim().toLowerCase();\n};\n\n/**\n * Finds the outgoing edge to follow from a node.\n *\n * Resolution order:\n * 1. Exact handle match via sourceHandle/conditionValue.\n * 2. For condition:false loops, fallback to targetHandle=right.\n * 3. First outgoing edge as final fallback.\n */\nexport const findOutgoingEdge = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): SessionTemplate[\"edges\"][number] | null => {\n const outgoingEdges = (template.edges || []).filter(\n (edge) => edge.source === currentNodeId,\n );\n\n if (outgoingEdges.length === 0) {\n return null;\n }\n\n if (!handle) {\n return outgoingEdges[0];\n }\n\n const normalizedHandle = normalizeHandle(handle);\n const edgeByHandle = outgoingEdges.find((edge) => {\n return (\n normalizeHandle(edge.sourceHandle) === normalizedHandle ||\n normalizeHandle(edge.conditionValue) === normalizedHandle\n );\n });\n\n if (edgeByHandle) {\n return edgeByHandle;\n }\n\n const currentNode = template.nodes.find((node) => node.id === currentNodeId);\n if (currentNode?.type === \"condition\" && normalizedHandle === \"false\") {\n const rightHandleLoopEdge = outgoingEdges.find(\n (edge) => normalizeHandle(edge.targetHandle) === \"right\",\n );\n if (rightHandleLoopEdge) {\n return rightHandleLoopEdge;\n }\n }\n\n return outgoingEdges[0];\n};\n\n/**\n * Gets the next step index by following the graph edge from the current node\n *\n * @param currentNodeId - The ID of the current node\n * @param template - The session template\n * @returns The next step index (1-based) or null if no edge found\n */\nexport const getNextStepIndex = (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n): number | null => {\n const orderedNodes = getOrderedJourneySteps(template);\n const edge = findOutgoingEdge(currentNodeId, template, handle);\n\n if (!edge) {\n console.debug(\n `[sessionService] No outgoing edge found for node ${currentNodeId}${handle ? ` with handle ${handle}` : \"\"}`,\n );\n return null;\n }\n\n const targetId = edge.target;\n const targetIndex = orderedNodes.findIndex((n) => n.id === targetId);\n\n if (targetIndex === -1) {\n console.debug(\n `[sessionService] Target node ${targetId} not found in ordered steps`,\n );\n return null;\n }\n\n // steps are 1-indexed in the SDK (0 is StartSession)\n return 1 + targetIndex;\n};\n\n/**\n * Reconstructs the navigation history by following the graph from step 0\n * up to (and including) targetStep. Returns [0, ...stepIndices].\n * If the graph path cannot reach targetStep, falls back to [0, targetStep].\n */\nexport const reconstructHistoryToStep = (\n targetStep: number,\n template: SessionTemplate,\n): number[] => {\n if (targetStep <= 0) return [0];\n\n const orderedNodes = getOrderedJourneySteps(template);\n const history: number[] = [0];\n let currentStep = 1; // first node is step 1\n\n // Follow the default (first) edge from each node in sequence\n for (let safetyLimit = 0; safetyLimit < orderedNodes.length + 1; safetyLimit++) {\n if (currentStep === targetStep) {\n history.push(currentStep);\n break;\n }\n if (currentStep > targetStep) break;\n\n const nodeIndex = currentStep - 1;\n const currentNode = orderedNodes[nodeIndex];\n if (!currentNode) break;\n\n history.push(currentStep);\n\n const nextStep = getNextStepIndex(currentNode.id, template);\n if (nextStep === null) break;\n currentStep = nextStep;\n }\n\n // Fallback: if we couldn't reach targetStep via graph, use simple seed\n if (history[history.length - 1] !== targetStep) {\n return [0, targetStep];\n }\n\n return history;\n};\n\n/**\n * Maps a template node type to a step component type\n *\n * @param node - The session template node\n * @returns The step component type\n */\nexport const getStepComponentType = (node: SessionTemplateNode): string => {\n // Map from template node types to component types\n const typeMap: Record<string, string> = {\n \"document-selection\": \"document\",\n \"document-collection\": \"document-collection\",\n \"selfie-capture\": \"selfie\",\n \"contact-info\": \"contact-info\",\n \"user-input\": \"user-input\",\n \"otp-verification\": \"otp\",\n };\n\n // First check the node type\n if (node.type in typeMap) {\n return typeMap[node.type];\n }\n\n // Then check the requiredDocumentType\n if (node.requiredDocumentType) {\n return node.requiredDocumentType;\n }\n\n // Default fallback\n return node.type;\n};\n\n/**\n * Checks if a session has expired\n *\n * @param session - The session data to check\n * @returns true if the session has expired, false otherwise\n */\nexport const isSessionExpired = (session: SessionData): boolean => {\n if (!session.expireTime) {\n return false;\n }\n\n const currentTime = Date.now();\n return currentTime > session.expireTime;\n};\n\n/**\n * Stores document options in localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @param options - The options to store\n */\nexport const storeDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n options: string[],\n): void => {\n if (!sessionId || !documentTypeId || !options || options.length === 0) {\n console.warn(\"Missing data for storeDocumentOptions:\", {\n sessionId,\n documentTypeId,\n options,\n });\n return;\n }\n\n // Create a consistent key format based on document type\n let storageKey = \"\";\n\n switch (documentTypeId) {\n case \"jdd\":\n storageKey = `jddOptions_${sessionId}`;\n break;\n case \"income-proof\":\n storageKey = `fundsOptions_${sessionId}`;\n break;\n case \"id-card\":\n storageKey = `idOptions_${sessionId}`;\n break;\n case \"document-collection\":\n storageKey = `documentCollectionOptions_${sessionId}`;\n break;\n default:\n storageKey = `${documentTypeId}Options_${sessionId}`;\n }\n\n localStorage.setItem(storageKey, JSON.stringify(options));\n};\n\n/**\n * Retrieves document options from localStorage for a specific document type\n *\n * @param sessionId - The session ID\n * @param documentTypeId - The document type ID (e.g., 'jdd', 'income-proof')\n * @returns Array of options or default options if none found\n */\nexport const retrieveDocumentOptions = (\n sessionId: string,\n documentTypeId: string,\n): string[] => {\n if (!sessionId || !documentTypeId) {\n console.warn(\"Missing data for retrieveDocumentOptions:\", {\n sessionId,\n documentTypeId,\n });\n return [];\n }\n\n // Create consistent key formats to check\n const possibleKeys = [\n `${documentTypeId}Options_${sessionId}`,\n documentTypeId === \"jdd\" ? `jddOptions_${sessionId}` : \"\",\n documentTypeId === \"income-proof\" ? `fundsOptions_${sessionId}` : \"\",\n documentTypeId === \"id-card\" ? `idOptions_${sessionId}` : \"\",\n documentTypeId === \"document-collection\"\n ? `documentCollectionOptions_${sessionId}`\n : \"\",\n ].filter(Boolean);\n\n // Try each possible key\n for (const key of possibleKeys) {\n const savedOptions = localStorage.getItem(key);\n if (savedOptions) {\n try {\n const parsedOptions = JSON.parse(savedOptions);\n\n return parsedOptions;\n } catch (e) {\n console.error(\n `Error parsing options for ${documentTypeId} with key ${key}:`,\n e,\n );\n }\n }\n }\n\n // Return default options if none found\n console.warn(`No options found for ${documentTypeId}, using defaults`);\n if (documentTypeId === \"jdd\") {\n return [\n \"Facture d'électricité (< 3 mois)\",\n \"Facture de gaz (< 3 mois)\",\n \"Facture d'eau (< 3 mois)\",\n \"Quittance de loyer (< 3 mois)\",\n \"Facture téléphone/internet (< 3 mois)\",\n \"Attestation d'assurance habitation (< 3 mois)\",\n ];\n } else if (documentTypeId === \"income-proof\") {\n return [\n \"Bulletin de salaire\",\n \"Avis d'imposition\",\n \"Relevé de compte bancaire\",\n \"Attestation de revenus\",\n \"Contrat de travail\",\n ];\n } else if (documentTypeId === \"id-card\") {\n return [\"Carte nationale d'identité\", \"Passeport\", \"Permis de conduire\"];\n } else if (documentTypeId === \"document-collection\") {\n return [\"Document administratif\", \"Justificatif\", \"Attestation\"];\n }\n\n return [];\n};\n\nconst clearStorageBySessionId = (sessionId: string): void => {\n const scopedKeys = [\n `userInput_${sessionId}`,\n `contactInfo_${sessionId}`,\n `sessionData_${sessionId}`,\n ];\n\n scopedKeys.forEach((key) => {\n localStorage.removeItem(key);\n sessionStorage.removeItem(key);\n });\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (key.endsWith(`_${sessionId}`)) {\n sessionStorage.removeItem(key);\n }\n }\n\n if (localStorage.getItem(\"sessionId\") === sessionId) {\n localStorage.removeItem(\"sessionId\");\n }\n if (sessionStorage.getItem(\"sessionId\") === sessionId) {\n sessionStorage.removeItem(\"sessionId\");\n }\n};\n\n/**\n * Clears all client-side session traces (memory + browser storage)\n * for a given session. This is intentionally aggressive for security.\n */\nexport const clearSessionSensitiveData = (sessionId?: string): void => {\n clearSessionMemory(sessionId);\n\n if (sessionId) {\n clearStorageBySessionId(sessionId);\n return;\n }\n\n localStorage.removeItem(\"sessionId\");\n sessionStorage.removeItem(\"sessionId\");\n\n for (let i = localStorage.length - 1; i >= 0; i -= 1) {\n const key = localStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n localStorage.removeItem(key);\n }\n }\n\n for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {\n const key = sessionStorage.key(i);\n if (!key) {\n continue;\n }\n if (\n key.startsWith(\"userInput_\") ||\n key.startsWith(\"contactInfo_\") ||\n key.includes(\"Options_\")\n ) {\n sessionStorage.removeItem(key);\n }\n }\n};\n\n/**\n * Returns the pre-fill data for a given run index from a `userInput` object\n * that contains a `_list` array.\n *\n * Convention: when the integrator wants to pre-fill different data per run\n * (e.g. multiple persons in a loop), they pass `userInput: { _list: [...] }`\n * at session creation. Each element in `_list` corresponds to a run (0-indexed).\n *\n * @param userInput - The session's userInput object\n * @param runIndex - The current run index (0 = first pass, 1 = second pass, …)\n * @returns The pre-fill data for that run, or null if not defined\n */\nexport const getRunPrefillData = (\n userInput: Record<string, unknown>,\n runIndex: number,\n): Record<string, unknown> | null => {\n const list = userInput?._list;\n if (!Array.isArray(list)) return null;\n return (list[runIndex] as Record<string, unknown>) ?? null;\n};\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAYH;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,GAAG,CAAC,uBAAgB,SAAS,CAAE,CAAC,CAAA;;AAA5D,gBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAiD;gBAClE,OAAA,CAAA,CAAA,aAAO,QAAQ,CAAC,IAAI,CAAA;;;AAEpB,gBAAA,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,OAAK,CAAC;AACpD,gBAAA,MAAM,OAAK;;;;;AAIf;;;;AAIG;AACI,IAAM,cAAc,GAAG,UAC5B,SAAiB,EACjB,UAAsB,EAAA,EAAA,OAAA,SAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGpB,OAAA,CAAA,CAAA,YAAM,UAAU,CAAC,IAAI,CAAC,eAAA,CAAA,MAAA,CAAgB,SAAS,EAAA,cAAA,CAAc,EAAE,UAAU,CAAC,CAAA;;AAA1E,gBAAA,EAAA,CAAA,IAAA,EAA0E;;;;AAE1E,gBAAA,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,OAAK,CAAC;AAClD,gBAAA,MAAM,OAAK;;;;;AAgNf;;;;;;AAMG;AACI,IAAM,sBAAsB,GAAG,UACpC,SAAiB,EACjB,SAKC,EAA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AT,SAAS,CAAE,KAAK;AAC7B,IAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI;AACrC,IAAA,OAAO,MAAC,IAAI,CAAC,QAAQ,CAA6B,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AAC5D;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.140-rc.67",
3
+ "version": "1.1.140-rc.68",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",