datakeen-session-react 1.1.197 → 1.1.198-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/cjs/components/session/EndFlow.js +15 -5
  2. package/dist/cjs/components/session/EndFlow.js.map +1 -1
  3. package/dist/cjs/components/session/SessionContent.js +5 -3
  4. package/dist/cjs/components/session/SessionContent.js.map +1 -1
  5. package/dist/cjs/components/start-flow/Start.js +1 -0
  6. package/dist/cjs/components/start-flow/Start.js.map +1 -1
  7. package/dist/cjs/components/template/ComplementaryMandateNodeHandler.js +36 -0
  8. package/dist/cjs/components/template/ComplementaryMandateNodeHandler.js.map +1 -0
  9. package/dist/cjs/components/template/TemplateNodeRenderer.js +8 -3
  10. package/dist/cjs/components/template/TemplateNodeRenderer.js.map +1 -1
  11. package/dist/cjs/hooks/useSessionData.js +10 -5
  12. package/dist/cjs/hooks/useSessionData.js.map +1 -1
  13. package/dist/cjs/hooks/useStepNavigation.js +7 -5
  14. package/dist/cjs/hooks/useStepNavigation.js.map +1 -1
  15. package/dist/cjs/hooks/useUserInputForm.js +27 -6
  16. package/dist/cjs/hooks/useUserInputForm.js.map +1 -1
  17. package/dist/cjs/i18n/en.json.js +22 -1
  18. package/dist/cjs/i18n/en.json.js.map +1 -1
  19. package/dist/cjs/i18n/es.json.js +22 -1
  20. package/dist/cjs/i18n/es.json.js.map +1 -1
  21. package/dist/cjs/i18n/fr.json.js +22 -1
  22. package/dist/cjs/i18n/fr.json.js.map +1 -1
  23. package/dist/cjs/services/sessionService.js +33 -6
  24. package/dist/cjs/services/sessionService.js.map +1 -1
  25. package/dist/cjs/types/session.js.map +1 -1
  26. package/dist/cjs/utils/customFieldValidation.js +44 -1
  27. package/dist/cjs/utils/customFieldValidation.js.map +1 -1
  28. package/dist/cjs/utils/sessionStatus.js +28 -0
  29. package/dist/cjs/utils/sessionStatus.js.map +1 -0
  30. package/dist/esm/components/session/EndFlow.js +15 -5
  31. package/dist/esm/components/session/EndFlow.js.map +1 -1
  32. package/dist/esm/components/session/SessionContent.js +5 -3
  33. package/dist/esm/components/session/SessionContent.js.map +1 -1
  34. package/dist/esm/components/start-flow/Start.js +1 -0
  35. package/dist/esm/components/start-flow/Start.js.map +1 -1
  36. package/dist/esm/components/template/ComplementaryMandateNodeHandler.js +32 -0
  37. package/dist/esm/components/template/ComplementaryMandateNodeHandler.js.map +1 -0
  38. package/dist/esm/components/template/TemplateNodeRenderer.js +8 -3
  39. package/dist/esm/components/template/TemplateNodeRenderer.js.map +1 -1
  40. package/dist/esm/hooks/useSessionData.js +10 -5
  41. package/dist/esm/hooks/useSessionData.js.map +1 -1
  42. package/dist/esm/hooks/useStepNavigation.js +5 -3
  43. package/dist/esm/hooks/useStepNavigation.js.map +1 -1
  44. package/dist/esm/hooks/useUserInputForm.js +28 -7
  45. package/dist/esm/hooks/useUserInputForm.js.map +1 -1
  46. package/dist/esm/i18n/en.json.js +22 -2
  47. package/dist/esm/i18n/en.json.js.map +1 -1
  48. package/dist/esm/i18n/es.json.js +22 -2
  49. package/dist/esm/i18n/es.json.js.map +1 -1
  50. package/dist/esm/i18n/fr.json.js +22 -2
  51. package/dist/esm/i18n/fr.json.js.map +1 -1
  52. package/dist/esm/services/sessionService.js +33 -7
  53. package/dist/esm/services/sessionService.js.map +1 -1
  54. package/dist/esm/types/session.js.map +1 -1
  55. package/dist/esm/utils/customFieldValidation.js +44 -2
  56. package/dist/esm/utils/customFieldValidation.js.map +1 -1
  57. package/dist/esm/utils/sessionStatus.js +26 -0
  58. package/dist/esm/utils/sessionStatus.js.map +1 -0
  59. package/docs/COMPLEMENTARY_MANDATE.md +22 -0
  60. package/docs/JOURNEY_NODE_BUILDER.md +15 -0
  61. package/docs/navigation-history.md +8 -0
  62. package/package.json +1 -1
@@ -1085,6 +1085,25 @@ var signed_document = {
1085
1085
  declined: "You declined to sign this document.",
1086
1086
  expired: "The signing link has expired."
1087
1087
  };
1088
+ var complementary_mandate = {
1089
+ title: "Complementary mandate",
1090
+ description: "Reuse an approved mandate for the same SIREN",
1091
+ source: "Source journey",
1092
+ current: "This journey",
1093
+ age: "Mandate validity (months)",
1094
+ excluded: "Fields excluded from inheritance (comma separated)",
1095
+ risk: "First and last names are sufficient to skip a new identity check. This information may be public; no OTP is verified.",
1096
+ same_signer: "Same signer",
1097
+ new_signer: "New signer",
1098
+ no_mandate: "No mandate",
1099
+ checked: "Complementary mandate checked",
1100
+ validation_outputs: "Connect all three complementary mandate outputs.",
1101
+ validation_identity: "A form requiring first and last names must precede the complementary mandate on every branch.",
1102
+ validation_age: "Validity must be a whole number of months between 1 and 1200.",
1103
+ loading: "Checking mandate…",
1104
+ error: "The mandate check failed. Please try again.",
1105
+ retry: "Try again"
1106
+ };
1088
1107
  var enTranslations = {
1089
1108
  start: start,
1090
1109
  user_input_form: user_input_form,
@@ -1142,7 +1161,8 @@ var enTranslations = {
1142
1161
  signature: signature,
1143
1162
  nfc_scan: nfc_scan,
1144
1163
  inpi_verification: inpi_verification,
1145
- signed_document: signed_document
1164
+ signed_document: signed_document,
1165
+ complementary_mandate: complementary_mandate
1146
1166
  };
1147
1167
 
1148
1168
  exports.LEGAL_CONSENT = LEGAL_CONSENT;
@@ -1150,6 +1170,7 @@ exports.before = before;
1150
1170
  exports.before_verso = before_verso;
1151
1171
  exports.buttons = buttons;
1152
1172
  exports.camera = camera;
1173
+ exports.complementary_mandate = complementary_mandate;
1153
1174
  exports.custom_form = custom_form;
1154
1175
  exports.default = enTranslations;
1155
1176
  exports.documentTypes = documentTypes;
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1085,6 +1085,25 @@ var signed_document = {
1085
1085
  declined: "Ha rechazado firmar este documento.",
1086
1086
  expired: "El enlace de firma ha caducado."
1087
1087
  };
1088
+ var complementary_mandate = {
1089
+ title: "Mandato complementario",
1090
+ description: "Reutilizar un mandato aprobado para el mismo SIREN",
1091
+ source: "Recorrido de origen",
1092
+ current: "Este recorrido",
1093
+ age: "Validez del mandato (meses)",
1094
+ excluded: "Campos excluidos de la herencia (separados por comas)",
1095
+ risk: "El nombre y el apellido bastan para omitir una nueva verificación de identidad. Esta información puede ser pública; no se verifica ningún OTP.",
1096
+ same_signer: "Mismo firmante",
1097
+ new_signer: "Nuevo firmante",
1098
+ no_mandate: "Sin mandato",
1099
+ checked: "Mandato complementario verificado",
1100
+ validation_outputs: "Conecte las tres salidas del mandato complementario.",
1101
+ validation_identity: "Un formulario con nombre y apellido obligatorios debe preceder al mandato complementario en cada rama.",
1102
+ validation_age: "La validez debe ser un número entero de meses entre 1 y 1200.",
1103
+ loading: "Verificando el mandato…",
1104
+ error: "La verificación del mandato ha fallado. Inténtelo de nuevo.",
1105
+ retry: "Reintentar"
1106
+ };
1088
1107
  var esTranslations = {
1089
1108
  start: start,
1090
1109
  user_input_form: user_input_form,
@@ -1142,7 +1161,8 @@ var esTranslations = {
1142
1161
  signature: signature,
1143
1162
  nfc_scan: nfc_scan,
1144
1163
  inpi_verification: inpi_verification,
1145
- signed_document: signed_document
1164
+ signed_document: signed_document,
1165
+ complementary_mandate: complementary_mandate
1146
1166
  };
1147
1167
 
1148
1168
  exports.LEGAL_CONSENT = LEGAL_CONSENT;
@@ -1150,6 +1170,7 @@ exports.before = before;
1150
1170
  exports.before_verso = before_verso;
1151
1171
  exports.buttons = buttons;
1152
1172
  exports.camera = camera;
1173
+ exports.complementary_mandate = complementary_mandate;
1153
1174
  exports.custom_form = custom_form;
1154
1175
  exports.default = esTranslations;
1155
1176
  exports.documentTypes = documentTypes;
@@ -1 +1 @@
1
- {"version":3,"file":"es.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1085,6 +1085,25 @@ var signed_document = {
1085
1085
  declined: "Vous avez refusé de signer ce document.",
1086
1086
  expired: "Le lien de signature a expiré."
1087
1087
  };
1088
+ var complementary_mandate = {
1089
+ title: "Mandat complémentaire",
1090
+ description: "Réutiliser un mandat approuvé pour le même SIREN",
1091
+ source: "Parcours source",
1092
+ current: "Ce parcours",
1093
+ age: "Validité du mandat (mois)",
1094
+ excluded: "Champs exclus de l’héritage (séparés par des virgules)",
1095
+ risk: "Le nom et le prénom suffisent à éviter un nouveau contrôle d’identité. Ces informations peuvent être publiques ; aucun OTP n’est vérifié.",
1096
+ same_signer: "Même signataire",
1097
+ new_signer: "Nouveau signataire",
1098
+ no_mandate: "Aucun mandat",
1099
+ checked: "Mandat complémentaire vérifié",
1100
+ validation_outputs: "Reliez les trois sorties du mandat complémentaire.",
1101
+ validation_identity: "Un formulaire avec prénom et nom obligatoires doit précéder le mandat complémentaire sur chaque branche.",
1102
+ validation_age: "La validité doit être un nombre entier de mois entre 1 et 1200.",
1103
+ loading: "Vérification du mandat…",
1104
+ error: "La vérification du mandat a échoué. Veuillez réessayer.",
1105
+ retry: "Réessayer"
1106
+ };
1088
1107
  var frTranslations = {
1089
1108
  start: start,
1090
1109
  user_input_form: user_input_form,
@@ -1142,7 +1161,8 @@ var frTranslations = {
1142
1161
  signature: signature,
1143
1162
  nfc_scan: nfc_scan,
1144
1163
  inpi_verification: inpi_verification,
1145
- signed_document: signed_document
1164
+ signed_document: signed_document,
1165
+ complementary_mandate: complementary_mandate
1146
1166
  };
1147
1167
 
1148
1168
  exports.LEGAL_CONSENT = LEGAL_CONSENT;
@@ -1150,6 +1170,7 @@ exports.before = before;
1150
1170
  exports.before_verso = before_verso;
1151
1171
  exports.buttons = buttons;
1152
1172
  exports.camera = camera;
1173
+ exports.complementary_mandate = complementary_mandate;
1153
1174
  exports.custom_form = custom_form;
1154
1175
  exports.default = frTranslations;
1155
1176
  exports.documentTypes = documentTypes;
@@ -1 +1 @@
1
- {"version":3,"file":"fr.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,12 +5,6 @@ var api = require('./api.js');
5
5
  var auditTrailService = require('./auditTrailService.js');
6
6
  var sessionMemoryStore = require('./sessionMemoryStore.js');
7
7
 
8
- /**
9
- * Session Service
10
- *
11
- * Service for interacting with the Datakeen Session API.
12
- * Handles fetching session data by ID.
13
- */
14
8
  /**
15
9
  * Fetches session data by ID from the Datakeen backend
16
10
  *
@@ -481,7 +475,40 @@ var getRunPrefillData = function (userInput, runIndex) {
481
475
  return null;
482
476
  return (_a = list[runIndex]) !== null && _a !== void 0 ? _a : null;
483
477
  };
478
+ /**
479
+ * Checks en cours par nœud : un double montage (StrictMode, remontage) partage
480
+ * la même requête au lieu d'en lancer une seconde qui entrerait en concurrence
481
+ * avec la première côté serveur. L'entrée est libérée dès que l'appel aboutit,
482
+ * pour qu'un réessai reparte bien du serveur.
483
+ */
484
+ var pendingMandateChecks = new Map();
485
+ /** The server reads persisted identity; no identity or verdict is submitted. */
486
+ function checkComplementaryMandate(sessionId, nodeId) {
487
+ var _this = this;
488
+ var key = "".concat(sessionId, ":").concat(nodeId);
489
+ var pending = pendingMandateChecks.get(key);
490
+ if (pending)
491
+ return pending;
492
+ var request = (function () { return tslib_es6.__awaiter(_this, void 0, void 0, function () {
493
+ var response, outcome;
494
+ var _a;
495
+ return tslib_es6.__generator(this, function (_b) {
496
+ switch (_b.label) {
497
+ case 0: return [4 /*yield*/, api.apiService.post("/session/sdk/".concat(sessionId, "/complementary-mandate/").concat(encodeURIComponent(nodeId)))];
498
+ case 1:
499
+ response = _b.sent();
500
+ outcome = (_a = response.data) === null || _a === void 0 ? void 0 : _a.outcome;
501
+ if (!['same_signer', 'new_signer', 'no_mandate'].includes(outcome))
502
+ throw new Error('Invalid complementary mandate outcome');
503
+ return [2 /*return*/, { outcome: outcome }];
504
+ }
505
+ });
506
+ }); })().finally(function () { return pendingMandateChecks.delete(key); });
507
+ pendingMandateChecks.set(key, request);
508
+ return request;
509
+ }
484
510
 
511
+ exports.checkComplementaryMandate = checkComplementaryMandate;
485
512
  exports.clearSessionSensitiveData = clearSessionSensitiveData;
486
513
  exports.fetchSessionById = fetchSessionById;
487
514
  exports.findOutgoingEdge = findOutgoingEdge;
@@ -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 * Records the NFC fallback reason when the user declares they cannot use the\n * contactless scan, and marks the NFC scan as skipped server-side.\n *\n * @param sessionId - The unique identifier of the session\n * @param payload - The selected reason (technical key), its human-readable label,\n * and an optional free-text comment.\n */\nexport const skipNfcWithReason = async (\n sessionId: string,\n payload: { reason: string; label: string; comment?: string },\n): Promise<void> => {\n await apiService.post(`/session/sdk/${sessionId}/nfc-skip`, payload);\n};\n\nexport type SelfieFailureReason =\n | \"timeout\"\n | \"network_error\"\n | \"api_error\"\n | \"user_bypassed\";\n\nexport interface SelfieFailurePayload {\n nodeId: string;\n reason?: SelfieFailureReason;\n conformityCode?: string;\n bypassed?: boolean;\n}\n\nexport const reportSelfieFailure = async (\n sessionId: string,\n payload: SelfieFailurePayload,\n): Promise<void> => {\n await apiService.post(`/session/sdk/${sessionId}/selfie-failed`, payload);\n};\n\n/**\n * Resets a terminal NFC failure before the user starts again with another\n * document. The backend keeps completed scans immutable and treats this call\n * as a no-op when the status is not terminal.\n */\nexport const resetNfcScan = async (sessionId: string): Promise<void> => {\n await apiService.post(`/session/sdk/${sessionId}/nfc-reset`);\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 // Tiebreaker on id keeps the ordering deterministic when several nodes share the same `order`\n // (e.g. parallel branches of a condition), independently of their position in template.nodes.\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));\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 * Strict existence check for a named outgoing edge — unlike `findOutgoingEdge`,\n * this does NOT fall back to the first outgoing edge when no edge matches the\n * handle. Used by controle-jdi to decide whether a node is \"new-style\" (author\n * explicitly wired a \"false\" edge, enabling automatic true/false routing) or\n * \"legacy\" (single edge, preserve the existing manual continue/retry UX).\n */\nexport const hasOutgoingEdgeForHandle = (\n currentNodeId: string,\n template: SessionTemplate,\n handle: string,\n): boolean => {\n const normalizedHandle = normalizeHandle(handle);\n return (template.edges || []).some(\n (edge) =>\n edge.source === currentNodeId &&\n normalizeHandle(edge.sourceHandle) === normalizedHandle,\n );\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[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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":["import type { ComplementaryMandateOutcome } from '../types/session';\n/**\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 * Records the NFC fallback reason when the user declares they cannot use the\n * contactless scan, and marks the NFC scan as skipped server-side.\n *\n * @param sessionId - The unique identifier of the session\n * @param payload - The selected reason (technical key), its human-readable label,\n * and an optional free-text comment.\n */\nexport const skipNfcWithReason = async (\n sessionId: string,\n payload: { reason: string; label: string; comment?: string },\n): Promise<void> => {\n await apiService.post(`/session/sdk/${sessionId}/nfc-skip`, payload);\n};\n\nexport type SelfieFailureReason =\n | \"timeout\"\n | \"network_error\"\n | \"api_error\"\n | \"user_bypassed\";\n\nexport interface SelfieFailurePayload {\n nodeId: string;\n reason?: SelfieFailureReason;\n conformityCode?: string;\n bypassed?: boolean;\n}\n\nexport const reportSelfieFailure = async (\n sessionId: string,\n payload: SelfieFailurePayload,\n): Promise<void> => {\n await apiService.post(`/session/sdk/${sessionId}/selfie-failed`, payload);\n};\n\n/**\n * Resets a terminal NFC failure before the user starts again with another\n * document. The backend keeps completed scans immutable and treats this call\n * as a no-op when the status is not terminal.\n */\nexport const resetNfcScan = async (sessionId: string): Promise<void> => {\n await apiService.post(`/session/sdk/${sessionId}/nfc-reset`);\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 // Tiebreaker on id keeps the ordering deterministic when several nodes share the same `order`\n // (e.g. parallel branches of a condition), independently of their position in template.nodes.\n return template.nodes\n .filter((node) => node.type !== \"start\")\n .sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));\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 * Strict existence check for a named outgoing edge — unlike `findOutgoingEdge`,\n * this does NOT fall back to the first outgoing edge when no edge matches the\n * handle. Used by controle-jdi to decide whether a node is \"new-style\" (author\n * explicitly wired a \"false\" edge, enabling automatic true/false routing) or\n * \"legacy\" (single edge, preserve the existing manual continue/retry UX).\n */\nexport const hasOutgoingEdgeForHandle = (\n currentNodeId: string,\n template: SessionTemplate,\n handle: string,\n): boolean => {\n const normalizedHandle = normalizeHandle(handle);\n return (template.edges || []).some(\n (edge) =>\n edge.source === currentNodeId &&\n normalizeHandle(edge.sourceHandle) === normalizedHandle,\n );\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\n/**\n * Checks en cours par nœud : un double montage (StrictMode, remontage) partage\n * la même requête au lieu d'en lancer une seconde qui entrerait en concurrence\n * avec la première côté serveur. L'entrée est libérée dès que l'appel aboutit,\n * pour qu'un réessai reparte bien du serveur.\n */\nconst pendingMandateChecks = new Map<string, Promise<{ outcome: ComplementaryMandateOutcome }>>();\n\n/** The server reads persisted identity; no identity or verdict is submitted. */\nexport function checkComplementaryMandate(sessionId: string, nodeId: string): Promise<{ outcome: ComplementaryMandateOutcome }> {\n const key = `${sessionId}:${nodeId}`;\n const pending = pendingMandateChecks.get(key);\n if (pending) return pending;\n const request = (async () => {\n const response = await apiService.post(`/session/sdk/${sessionId}/complementary-mandate/${encodeURIComponent(nodeId)}`);\n const outcome = response.data?.outcome;\n if (!['same_signer', 'new_signer', 'no_mandate'].includes(outcome)) throw new Error('Invalid complementary mandate outcome');\n return { outcome };\n })().finally(() => pendingMandateChecks.delete(key));\n pendingMandateChecks.set(key, request);\n return request;\n}\n"],"names":["__awaiter","apiService","__assign","logStatusModified","clearSessionMemory"],"mappings":";;;;;;;AAkBA;;;;;AAKG;AACI,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EAAA,EAAA,OAAAA,mBAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,YAAA;;;;;;gBAGE,OAAA,CAAA,CAAA,YAAMC,cAAU,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,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AAA,EAAA,MAAA,EAAA,YAAA;;;;;AACE,gBAAA,KAAA,CAAA,EAAA,OAAA,CAAA,CAAA,YAAMC,cAAU,CAAC,IAAI,CAAC,eAAA,CAAA,MAAA,CAAgB,SAAS,EAAA,yBAAA,CAAA,CAAA,MAAA,CAA0B,kBAAkB,CAAC,MAAM,CAAC,CAAE,CAAC,CAAA;;AAAjH,oBAAA,QAAQ,GAAG,EAAA,CAAA,IAAA,EAAsG;AACjH,oBAAA,OAAO,GAAG,CAAA,EAAA,GAAA,QAAQ,CAAC,IAAI,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,OAAO;AACtC,oBAAA,IAAI,CAAC,CAAC,aAAa,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;AAAE,wBAAA,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC;AAC5H,oBAAA,OAAA,CAAA,CAAA,aAAO,EAAE,OAAO,EAAA,OAAA,EAAE,CAAA;;;AACnB,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAG,CAAC,OAAO,CAAC,cAAM,OAAA,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA,CAAhC,CAAgC,CAAC;AACpD,IAAA,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC;AACtC,IAAA,OAAO,OAAO;AAChB;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n sessionToken?: string;\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n /** Session credential returned by server-side session creation. Required by secured backends. */\n sessionToken?: string;\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number, skipHistory?: boolean) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n /** Avance via le graphe et tronque l'historique au nœud d'arrivée. */\n goToNextStepCommitted: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n /** Absent means personal data. Lists are classified as a whole, not per column. */\n containsPersonalData?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n editableIfMissing?: boolean; // soft lock — éditable si la valeur API est absente\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n cguLinkLabel?: string;\n privacyLinkLabel?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n nfcEnabled?: boolean;\n // \"nfcAndApi\" reste accepté pour rétrocompat (parcours legacy) ; à normaliser à la lecture.\n nfcMode?: \"nfcOnly\" | \"nfcOrPhoto\" | \"nfcAndApi\";\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n // Undefined is treated as \"loop\" by the SDK for legacy templates.\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\" | \"INPI_RBE\";\n /** INPI_RBE only. Opt-in: retry against the RNA (associations) when the RNE finds nothing. */\n rnaFallbackEnabled?: boolean;\n /**\n * INPI_RBE only. Opt-in: retry against INSEE (Sirene) when the RNE finds\n * nothing. Tried before the RNA fallback when both are enabled.\n */\n enableInseeFallback?: boolean;\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n /** Écran affiché après la signature. Valeurs vides : textes standard traduits. */\n signedScreenTitle?: string;\n signedScreenDescription?: string;\n signedScreenDownloadHint?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n\n /**\n * Paramétrable par nœud depuis le journey builder : autorise ou non le\n * bouton \"Poursuivre quand même\" en cas d'échec. S'applique aux nœuds\n * identity-control, document-collection, biometric-capture (selfie/video)\n * et external-verification. Absent/true = comportement actuel inchangé\n * (bouton proposé), false = masqué.\n *\n * Déprécié pour controle-jdi/identity-control quand une sortie \"false\" est\n * câblée : dans ce cas le routage automatique (blockingCodes +\n * maxResubmissionAction) prend le relais et ce bouton disparaît. Reste lu\n * tel quel pour les nœuds legacy sans sortie \"false\" (rétrocompat).\n */\n allowContinueOnFailure?: boolean;\n\n /**\n * Codes JDI exacts considérés comme bloquants pour ce nœud controle-jdi\n * (déclenchent la boucle de resoumission). Absent = DEFAULT_BLOCKING_CODES\n * (utils/jdiCodes.ts) — comportement legacy inchangé. Le code 8.0 est\n * toujours bloquant indépendamment de cette liste.\n */\n blockingCodes?: string[];\n\n /**\n * Action suivie quand les resoumissions sont épuisées sur un code bloquant\n * ET qu'une sortie \"false\" est câblée sur ce nœud controle-jdi (miroir de\n * conditionMaxRetryAction sur le nœud condition). Défaut \"end-journey\".\n */\n maxResubmissionAction?: \"end-journey\" | \"force-true\";\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n nfcStatus?: \"pending\" | \"opened\" | \"completed\" | \"skipped\" | \"failed\";\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n"],"names":[],"mappings":";;AA0EO,IAAM,2BAA2B,GAAsB;;;;"}
1
+ {"version":3,"file":"session.js","sources":["../../../../src/types/session.ts"],"sourcesContent":["import type React from \"react\";\n\nexport interface SessionConfig {\n sessionToken?: string;\n selfie?: boolean;\n requireMobile?: boolean;\n}\n\nexport interface DatakeenSessionProps {\n /** Session credential returned by server-side session creation. Required by secured backends. */\n sessionToken?: string;\n sessionId: string;\n sessionConfig?: SessionConfig;\n apiBaseUrl?: string; // Optional API base URL for dynamic environment configuration\n}\n\nexport interface UseSessionReturn {\n SessionComponent: React.ReactElement;\n}\n\nexport type stepObject = {\n setStep: (step: number, skipHistory?: boolean) => void;\n goBack: () => void;\n /** Retour arrière vers un nœud précis (ex: \"Corriger ma saisie\") :\n * tronque l'historique jusqu'à `targetStep` au lieu de l'empiler. */\n goBackToStep: (targetStep: number) => void;\n goToNextStep: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n /** Avance via le graphe et tronque l'historique au nœud d'arrivée. */\n goToNextStepCommitted: (\n currentNodeId: string,\n template: SessionTemplate,\n handle?: string,\n ) => void;\n step: number;\n canGoBack: boolean;\n};\n\nexport interface ProcessingStep {\n title: string;\n subtitle: string;\n hasError?: boolean;\n}\n\nexport type ConditionTokenType = \"variable\" | \"control\" | \"operator\" | \"input\";\n\nexport interface ConditionToken {\n type: ConditionTokenType;\n value: string;\n label?: string;\n sourceNodeId?: string;\n}\n\n/**\n * Type for custom field value types\n */\nexport type CustomFieldValueType =\n | \"text\"\n | \"enum\"\n | \"number\"\n | \"boolean\"\n | \"date\"\n | \"email\"\n | \"address\"\n | \"list\";\n\n/**\n * Display formats supported for date fields (top-level and list columns).\n */\nexport type DateDisplayFormat = \"dd/mm/yyyy\" | \"mm/dd/yyyy\" | \"yyyy-mm-dd\";\n\nexport const DEFAULT_DATE_DISPLAY_FORMAT: DateDisplayFormat = \"dd/mm/yyyy\";\n\n/** Un cas de la règle : une option du pilote → un regex. */\nexport interface ListColumnRegexCase {\n value: string; // valeur exacte d'une option du pilote\n regex: string; // source JS sans slashes ; vide = pas de contrainte\n errorMessage?: string; // message spécifique à ce cas\n}\n\n/** Regex conditionnelle pilotée par une autre colonne enum de la même ligne. */\nexport interface ListColumnRegexRules {\n /** Builder-only explicit opt-out for uncovered text options. */\n allowUnconstrained?: boolean;\n sourceColumn: string; // label de la colonne enum pilote\n cases: ListColumnRegexCase[]; // une entrée par option couverte\n}\n\n/**\n * Column definition for a list-type custom field\n */\nexport interface ListColumn {\n label: string;\n type: \"text\" | \"enum\" | \"date\" | \"email\";\n options?: string[]; // required when type === 'enum'\n placeholder?: string; // text/email/date — shown to the end user\n regex?: string; // text/email — JS regex source (without slashes)\n regexErrorMessage?: string; // text/email — message displayed when regex fails\n regexRules?: ListColumnRegexRules; // text/email — conditional regex rules\n dateFormat?: DateDisplayFormat; // date — display format expected\n}\n\n/**\n * Interface for custom field definition\n */\nexport interface CustomField {\n id: string;\n label: string;\n placeholder?: string;\n description?: string;\n valueType: CustomFieldValueType;\n enumOptions?: string[];\n listColumns?: ListColumn[]; // for list type: column definitions\n minRows?: number; // for list type: minimum rows expected\n required?: boolean;\n /** Absent means personal data. Lists are classified as a whole, not per column. */\n containsPersonalData?: boolean;\n regex?: string; // text — JS regex source (without slashes)\n regexErrorMessage?: string; // text — message displayed when regex fails\n dateFormat?: DateDisplayFormat; // date — display format expected\n lockedFromApi?: boolean;\n editableIfMissing?: boolean; // soft lock — éditable si la valeur API est absente\n userInputKey?: string;\n}\n\n/**\n * Interface for session template node\n */\nexport interface SessionTemplateNode {\n id: string;\n type: string;\n title: string;\n description: string;\n informationType?:\n | \"identity\"\n | \"identity-legal\"\n | \"contact\"\n | \"address\"\n | \"nationality\"\n | \"custom\";\n position: {\n x: number;\n y: number;\n };\n options: unknown[];\n selectedOptions: string[];\n requiredDocumentType?: string;\n isRequired: boolean;\n order: number;\n optionalFields?: string[];\n requiredFields?: string[];\n pageTitle?: string;\n pageDescription?: string;\n // Properties for document-collection node type\n allowedDocumentTypes?: Array<{\n id: string;\n name: string;\n /**\n * Optional side information coming from the template.\n * When provided and equals to two (\"two\", 2, \"double\", \"recto-verso\"),\n * consumers should allow uploading two sides (front/back).\n */\n side?: string | number;\n }>;\n allowedAddingMethods?: string[];\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n // Start node specific properties\n welcomeTitle?: string;\n welcomeSubtitle?: string;\n welcomeDescription?: string;\n welcomeImage?: string;\n qrCodeTitle?: string;\n qrCodeDescription?: string;\n\n // Legal consent node specific properties\n consentDescription?: string;\n consentDescription2?: string;\n cguUrl?: string;\n privacyPolicyUrl?: string;\n cguLinkLabel?: string;\n privacyLinkLabel?: string;\n checkboxText?: string;\n // Identity control specific properties\n automaticPhotoCapture?: boolean;\n nfcEnabled?: boolean;\n // \"nfcAndApi\" reste accepté pour rétrocompat (parcours legacy) ; à normaliser à la lecture.\n nfcMode?: \"nfcOnly\" | \"nfcOrPhoto\" | \"nfcAndApi\";\n acceptedCountries?: AcceptedCountry[];\n // End node specific properties\n callbackURL?: string | null;\n // Résultat forcé par le nœud `end` (configuré dans le builder). Sert au SDK à\n // afficher la variante « erreur conservée » de l'écran de fin quand la branche\n // fausse d'une condition pointe directement vers un end non_compliant.\n expectedResult?: string;\n // Condition node specific properties\n conditionExpression?: string;\n conditionTokens?: ConditionToken[];\n conditionFalseErrorMessage?: string;\n conditionMaxRetries?: number;\n conditionMaxRetryAction?: \"end-journey\" | \"force-true\";\n // Undefined is treated as \"loop\" by the SDK for legacy templates.\n conditionFalseMode?: \"retry\" | \"loop\";\n\n // External verification specific properties\n targetApi?: \"INSEE\" | \"INPI_RBE\";\n /** INPI_RBE only. Opt-in: retry against the RNA (associations) when the RNE finds nothing. */\n rnaFallbackEnabled?: boolean;\n /**\n * INPI_RBE only. Opt-in: retry against INSEE (Sirene) when the RNE finds\n * nothing. Tried before the RNA fallback when both are enabled.\n */\n enableInseeFallback?: boolean;\n referenceNodeId?: string;\n referenceNodeType?:\n | \"information-input\"\n | \"document-collection\"\n | \"identity-control\";\n referenceField?: \"siren\" | \"siret\";\n referenceVariable?: string;\n // Custom form fields (for information-input with type 'custom')\n customFields?: CustomField[];\n\n // Electronic signature specific properties\n templateId?: string;\n external_id?: string;\n /** Écran affiché après la signature. Valeurs vides : textes standard traduits. */\n signedScreenTitle?: string;\n signedScreenDescription?: string;\n signedScreenDownloadHint?: string;\n fieldMappings?: Array<{\n sourceFieldId: string;\n label: string;\n docusealType: string;\n readonly: boolean;\n role?: string;\n sourceNodeId?: string;\n }>;\n /** If set, the generated PDF from this upstream pdf-generation node will be used as the document to sign */\n sourcePdfNodeId?: string;\n\n // PDF generation node specific properties\n // Note: htmlTemplate is intentionally NOT included — it is server-side only and never sent to the client\n pdfMode?: \"upload\" | \"html-template\";\n sourceNodeIds?: string[];\n\n // retry properties\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n\n /**\n * Paramétrable par nœud depuis le journey builder : autorise ou non le\n * bouton \"Poursuivre quand même\" en cas d'échec. S'applique aux nœuds\n * identity-control, document-collection, biometric-capture (selfie/video)\n * et external-verification. Absent/true = comportement actuel inchangé\n * (bouton proposé), false = masqué.\n *\n * Déprécié pour controle-jdi/identity-control quand une sortie \"false\" est\n * câblée : dans ce cas le routage automatique (blockingCodes +\n * maxResubmissionAction) prend le relais et ce bouton disparaît. Reste lu\n * tel quel pour les nœuds legacy sans sortie \"false\" (rétrocompat).\n */\n allowContinueOnFailure?: boolean;\n\n /**\n * Codes JDI exacts considérés comme bloquants pour ce nœud controle-jdi\n * (déclenchent la boucle de resoumission). Absent = DEFAULT_BLOCKING_CODES\n * (utils/jdiCodes.ts) — comportement legacy inchangé. Le code 8.0 est\n * toujours bloquant indépendamment de cette liste.\n */\n blockingCodes?: string[];\n\n /**\n * Action suivie quand les resoumissions sont épuisées sur un code bloquant\n * ET qu'une sortie \"false\" est câblée sur ce nœud controle-jdi (miroir de\n * conditionMaxRetryAction sur le nœud condition). Défaut \"end-journey\".\n */\n maxResubmissionAction?: \"end-journey\" | \"force-true\";\n}\n\n/**\n * Interface for accepted countries\n */\nexport interface AcceptedCountry {\n code: string;\n documents: {\n passport: string[];\n idCard: string[];\n driverLicense: string[];\n residencePermit: string[];\n pinkDriverLicense: string[];\n };\n}\n\n/**\n * Interface for session template edge\n */\nexport interface SessionTemplateEdge {\n id: string;\n source: string;\n target: string;\n sourceHandle?: string;\n targetHandle?: string;\n conditionValue?: string;\n}\n\n/**\n * Interface for platform information\n */\nexport interface PlatformInfo {\n mobile: boolean;\n desktop: boolean;\n backoffice: boolean;\n}\n\n/**\n * Interface for session template\n */\n/** Clé du catalogue d'icônes des écrans de fin (mappée vers lucide-react au rendu). */\nexport type EndScreenIcon =\n | \"thanks\"\n | \"send\"\n | \"mail\"\n | \"check\"\n | \"clock\"\n | \"shield\"\n | \"user\"\n | \"info\";\n\nexport interface EndScreenItem {\n icon: EndScreenIcon;\n text: string;\n}\n\nexport interface EndScreenCase {\n title?: string;\n items: EndScreenItem[];\n}\n\n/** Textes de fin personnalisés (config globale du journey). Vide → fallback standard. */\nexport interface EndScreenConfig {\n compliant?: EndScreenCase;\n nonCompliant?: EndScreenCase;\n}\n\nexport interface SessionTemplate {\n id: string;\n name: string;\n description: string;\n version: string;\n languages: string[];\n nodes: SessionTemplateNode[];\n edges: SessionTemplateEdge[];\n groupId: string;\n userId: string | null;\n created_at: string;\n updated_at: string;\n platforms?: PlatformInfo;\n logo?: string;\n showQRCode?: boolean;\n buttonBgColor?: string;\n buttonTextColor?: string;\n endScreenConfig?: EndScreenConfig;\n}\n\n/**\n * Interface for session data\n */\nexport interface SessionData {\n id: string;\n userId: string | null;\n token: string;\n templateId: string;\n templateKey: string;\n expireTime: number;\n status: string;\n result: Record<string, unknown>;\n landingPage: unknown;\n withSelfie: boolean | null;\n groupId: string | null;\n userInput: Record<string, unknown>;\n contactInfo?: {\n email: string;\n phoneNumber: string;\n };\n callbackURL?: string | null;\n webhookURL: string;\n analysisTemplateId: string | null;\n userAgent: unknown[];\n mobile: boolean;\n analysisId: string | null;\n currentStep?: number;\n nfcStatus?: \"pending\" | \"opened\" | \"completed\" | \"skipped\" | \"failed\";\n createdAt: string;\n updatedAt: string;\n auditTrail: unknown[];\n user: unknown | null;\n analysis: unknown[];\n documents: unknown[];\n template: SessionTemplate;\n retryCounts?: Record<string, number>; // nodeId -> retry count\n}\n\nexport interface ClientInfo {\n ip?: string;\n location?: string;\n device: string;\n browser: string;\n os: string;\n}\n\nexport type ComplementaryMandateOutcome = 'same_signer' | 'new_signer' | 'no_mandate';\nexport interface ComplementaryMandateNode extends SessionTemplateNode {\n type: 'complementary-mandate';\n sourceJourneyId?: string;\n maxAgeMonths?: number;\n excludedInheritedFields?: string[];\n}\n"],"names":[],"mappings":";;AA0EO,IAAM,2BAA2B,GAAsB;;;;"}
@@ -15,7 +15,9 @@ var DATE_FORMAT_SPECS = {
15
15
  "yyyy-mm-dd": { re: ISO_DATE_RE, order: ["year", "month", "day"] },
16
16
  };
17
17
  var isValidDateParts = function (year, month, day) {
18
- if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {
18
+ if (!Number.isInteger(year) ||
19
+ !Number.isInteger(month) ||
20
+ !Number.isInteger(day)) {
19
21
  return false;
20
22
  }
21
23
  if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31)
@@ -55,6 +57,46 @@ var isRegexMatch = function (value, source) {
55
57
  return true;
56
58
  }
57
59
  };
60
+ /**
61
+ * Resolves the regex for a list cell from another enum cell in the same row.
62
+ * Malformed or incomplete conditional rules deliberately fall back to the
63
+ * column regex so legacy configurations remain usable.
64
+ */
65
+ var resolveColumnRegex = function (col, row) {
66
+ var fallback = {
67
+ regex: typeof col.regex === "string" ? col.regex : "",
68
+ errorMessage: typeof col.regexErrorMessage === "string"
69
+ ? col.regexErrorMessage
70
+ : undefined,
71
+ };
72
+ var rules = col.regexRules;
73
+ if (!rules ||
74
+ typeof rules.sourceColumn !== "string" ||
75
+ !rules.sourceColumn ||
76
+ !Array.isArray(rules.cases) ||
77
+ !row) {
78
+ return fallback;
79
+ }
80
+ var sourceValue = row[rules.sourceColumn];
81
+ if (typeof sourceValue !== "string" || !sourceValue)
82
+ return fallback;
83
+ var matchingCase = rules.cases.find(function (candidate) {
84
+ return candidate &&
85
+ typeof candidate.value === "string" &&
86
+ candidate.value === sourceValue;
87
+ });
88
+ if (!matchingCase || typeof matchingCase.regex !== "string")
89
+ return fallback;
90
+ var regex = matchingCase.regex.trim();
91
+ if (!regex)
92
+ return fallback;
93
+ return {
94
+ regex: regex,
95
+ errorMessage: typeof matchingCase.errorMessage === "string"
96
+ ? matchingCase.errorMessage
97
+ : fallback.errorMessage,
98
+ };
99
+ };
58
100
  var cellErrorKey = function (rowIndex, columnLabel) {
59
101
  return "".concat(rowIndex, "::").concat(columnLabel);
60
102
  };
@@ -64,4 +106,5 @@ exports.cellErrorKey = cellErrorKey;
64
106
  exports.isDateValid = isDateValid;
65
107
  exports.isEmailValid = isEmailValid;
66
108
  exports.isRegexMatch = isRegexMatch;
109
+ exports.resolveColumnRegex = resolveColumnRegex;
67
110
  //# sourceMappingURL=customFieldValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customFieldValidation.js","sources":["../../../../src/utils/customFieldValidation.ts"],"sourcesContent":["import type { DateDisplayFormat } from \"../types/session\";\nimport { DEFAULT_DATE_DISPLAY_FORMAT } from \"../types/session\";\n\nexport const EMAIL_REGEX = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst warnedInvalidRegexSources = new Set<string>();\n\nexport const isEmailValid = (value: string): boolean =>\n EMAIL_REGEX.test(String(value).trim());\n\nconst SLASH_DATE_RE = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/;\nconst ISO_DATE_RE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\n\ntype DatePart = \"day\" | \"month\" | \"year\";\n\nconst DATE_FORMAT_SPECS: Record<\n DateDisplayFormat,\n { re: RegExp; order: [DatePart, DatePart, DatePart] }\n> = {\n \"dd/mm/yyyy\": { re: SLASH_DATE_RE, order: [\"day\", \"month\", \"year\"] },\n \"mm/dd/yyyy\": { re: SLASH_DATE_RE, order: [\"month\", \"day\", \"year\"] },\n \"yyyy-mm-dd\": { re: ISO_DATE_RE, order: [\"year\", \"month\", \"day\"] },\n};\n\nconst isValidDateParts = (year: number, month: number, day: number): boolean => {\n if (!Number.isInteger(year) || !Number.isInteger(month) || !Number.isInteger(day)) {\n return false;\n }\n if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31) return false;\n const d = new Date(Date.UTC(year, month - 1, day));\n return (\n d.getUTCFullYear() === year &&\n d.getUTCMonth() === month - 1 &&\n d.getUTCDate() === day\n );\n};\n\nexport const isDateValid = (\n value: string,\n format: DateDisplayFormat = DEFAULT_DATE_DISPLAY_FORMAT,\n): boolean => {\n const v = String(value || \"\").trim();\n if (!v) return false;\n const spec = DATE_FORMAT_SPECS[format] ?? DATE_FORMAT_SPECS[DEFAULT_DATE_DISPLAY_FORMAT];\n const m = v.match(spec.re);\n if (!m) return false;\n const parts: Record<DatePart, number> = { day: 0, month: 0, year: 0 };\n spec.order.forEach((part, i) => {\n parts[part] = Number(m[i + 1]);\n });\n return isValidDateParts(parts.year, parts.month, parts.day);\n};\n\nexport const isRegexMatch = (value: string, source: string): boolean => {\n if (!source) return true;\n try {\n return new RegExp(source).test(String(value));\n } catch (error) {\n if (!warnedInvalidRegexSources.has(source)) {\n warnedInvalidRegexSources.add(source);\n console.warn(\n \"[customFieldValidation] Invalid regex; validation was skipped.\",\n source,\n error,\n );\n }\n return true;\n }\n};\n\nexport const cellErrorKey = (rowIndex: number, columnLabel: string): string =>\n `${rowIndex}::${columnLabel}`;\n"],"names":["DEFAULT_DATE_DISPLAY_FORMAT"],"mappings":";;;;AAGO,IAAM,WAAW,GAAG;AAE3B,IAAM,yBAAyB,GAAG,IAAI,GAAG,EAAU;AAE5C,IAAM,YAAY,GAAG,UAAC,KAAa,EAAA;IACxC,OAAA,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AAAtC;AAEF,IAAM,aAAa,GAAG,6BAA6B;AACnD,IAAM,WAAW,GAAG,2BAA2B;AAI/C,IAAM,iBAAiB,GAGnB;AACF,IAAA,YAAY,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE;AACpE,IAAA,YAAY,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,KAA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;;"}
1
+ {"version":3,"file":"customFieldValidation.js","sources":["../../../../src/utils/customFieldValidation.ts"],"sourcesContent":["import type { DateDisplayFormat, ListColumn } from \"../types/session\";\nimport { DEFAULT_DATE_DISPLAY_FORMAT } from \"../types/session\";\n\nexport const EMAIL_REGEX = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst warnedInvalidRegexSources = new Set<string>();\n\nexport const isEmailValid = (value: string): boolean =>\n EMAIL_REGEX.test(String(value).trim());\n\nconst SLASH_DATE_RE = /^(\\d{2})\\/(\\d{2})\\/(\\d{4})$/;\nconst ISO_DATE_RE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\n\ntype DatePart = \"day\" | \"month\" | \"year\";\n\nconst DATE_FORMAT_SPECS: Record<\n DateDisplayFormat,\n { re: RegExp; order: [DatePart, DatePart, DatePart] }\n> = {\n \"dd/mm/yyyy\": { re: SLASH_DATE_RE, order: [\"day\", \"month\", \"year\"] },\n \"mm/dd/yyyy\": { re: SLASH_DATE_RE, order: [\"month\", \"day\", \"year\"] },\n \"yyyy-mm-dd\": { re: ISO_DATE_RE, order: [\"year\", \"month\", \"day\"] },\n};\n\nconst isValidDateParts = (\n year: number,\n month: number,\n day: number,\n): boolean => {\n if (\n !Number.isInteger(year) ||\n !Number.isInteger(month) ||\n !Number.isInteger(day)\n ) {\n return false;\n }\n if (year < 1 || month < 1 || month > 12 || day < 1 || day > 31) return false;\n const d = new Date(Date.UTC(year, month - 1, day));\n return (\n d.getUTCFullYear() === year &&\n d.getUTCMonth() === month - 1 &&\n d.getUTCDate() === day\n );\n};\n\nexport const isDateValid = (\n value: string,\n format: DateDisplayFormat = DEFAULT_DATE_DISPLAY_FORMAT,\n): boolean => {\n const v = String(value || \"\").trim();\n if (!v) return false;\n const spec =\n DATE_FORMAT_SPECS[format] ?? DATE_FORMAT_SPECS[DEFAULT_DATE_DISPLAY_FORMAT];\n const m = v.match(spec.re);\n if (!m) return false;\n const parts: Record<DatePart, number> = { day: 0, month: 0, year: 0 };\n spec.order.forEach((part, i) => {\n parts[part] = Number(m[i + 1]);\n });\n return isValidDateParts(parts.year, parts.month, parts.day);\n};\n\nexport const isRegexMatch = (value: string, source: string): boolean => {\n if (!source) return true;\n try {\n return new RegExp(source).test(String(value));\n } catch (error) {\n if (!warnedInvalidRegexSources.has(source)) {\n warnedInvalidRegexSources.add(source);\n console.warn(\n \"[customFieldValidation] Invalid regex; validation was skipped.\",\n source,\n error,\n );\n }\n return true;\n }\n};\n\n/**\n * Resolves the regex for a list cell from another enum cell in the same row.\n * Malformed or incomplete conditional rules deliberately fall back to the\n * column regex so legacy configurations remain usable.\n */\nexport const resolveColumnRegex = (\n col: ListColumn,\n row: Record<string, string> | undefined,\n): { regex: string; errorMessage?: string } => {\n const fallback = {\n regex: typeof col.regex === \"string\" ? col.regex : \"\",\n errorMessage:\n typeof col.regexErrorMessage === \"string\"\n ? col.regexErrorMessage\n : undefined,\n };\n const rules = col.regexRules;\n\n if (\n !rules ||\n typeof rules.sourceColumn !== \"string\" ||\n !rules.sourceColumn ||\n !Array.isArray(rules.cases) ||\n !row\n ) {\n return fallback;\n }\n\n const sourceValue = row[rules.sourceColumn];\n if (typeof sourceValue !== \"string\" || !sourceValue) return fallback;\n\n const matchingCase = rules.cases.find(\n (candidate) =>\n candidate &&\n typeof candidate.value === \"string\" &&\n candidate.value === sourceValue,\n );\n if (!matchingCase || typeof matchingCase.regex !== \"string\") return fallback;\n\n const regex = matchingCase.regex.trim();\n if (!regex) return fallback;\n\n return {\n regex,\n errorMessage:\n typeof matchingCase.errorMessage === \"string\"\n ? matchingCase.errorMessage\n : fallback.errorMessage,\n };\n};\n\nexport const cellErrorKey = (rowIndex: number, columnLabel: string): string =>\n `${rowIndex}::${columnLabel}`;\n"],"names":["DEFAULT_DATE_DISPLAY_FORMAT"],"mappings":";;;;AAGO,IAAM,WAAW,GAAG;AAE3B,IAAM,yBAAyB,GAAG,IAAI,GAAG,EAAU;AAE5C,IAAM,YAAY,G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CAAC,KAAK,KAAK,QAAQ;AAAE,QAAA,OAAO,QAAQ;IAE5E,IAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE;AACvC,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,QAAQ;IAE3B,OAAO;AACL,QAAA,KAAK,EAAA,KAAA;AACL,QAAA,YAAY,EACV,OAAO,YAAY,CAAC,YAAY,KAAK;cACjC,YAAY,CAAC;cACb,QAAQ,CAAC,YAAY;KAC5B;AACH;AAEO,IAAM,YAAY,GAAG,UAAC,QAAgB,EAAE,WAAmB,EAAA;AAChE,IAAA,OAAA,EAAA,CAAA,MAAA,CAAG,QAAQ,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,WAAW,CAAE;AAA7B;;;;;;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // Statuts de résultat consolidé : le backend réécrit sessions.status avec le
4
+ // résultat consolidé une fois la session terminale (voir
5
+ // ResultUpdaterHelper.updateResult côté backend). Une session rouverte après
6
+ // coup porte donc l'un de ces statuts en base, pas "ended".
7
+ var CONSOLIDATED_RESULT_STATUSES = new Set([
8
+ "verify",
9
+ "ai_approved",
10
+ "ai_rejected",
11
+ "user_approved",
12
+ "user_rejected",
13
+ ]);
14
+ /**
15
+ * true si la session est terminée (écran de fin), qu'elle porte encore le
16
+ * statut brut "ended" ou déjà un statut de résultat consolidé.
17
+ *
18
+ * Ne PAS confondre avec "conform" : posé par SignatureElectronic juste après
19
+ * la signature, avant le vrai nœud "end" — ce n'est pas une fin de parcours.
20
+ */
21
+ var isSessionFinished = function (status) {
22
+ if (!status)
23
+ return false;
24
+ return status === "ended" || CONSOLIDATED_RESULT_STATUSES.has(status);
25
+ };
26
+
27
+ exports.isSessionFinished = isSessionFinished;
28
+ //# sourceMappingURL=sessionStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionStatus.js","sources":["../../../../src/utils/sessionStatus.ts"],"sourcesContent":["// Statuts de résultat consolidé : le backend réécrit sessions.status avec le\n// résultat consolidé une fois la session terminale (voir\n// ResultUpdaterHelper.updateResult côté backend). Une session rouverte après\n// coup porte donc l'un de ces statuts en base, pas \"ended\".\nconst CONSOLIDATED_RESULT_STATUSES = new Set([\n \"verify\",\n \"ai_approved\",\n \"ai_rejected\",\n \"user_approved\",\n \"user_rejected\",\n]);\n\n/**\n * true si la session est terminée (écran de fin), qu'elle porte encore le\n * statut brut \"ended\" ou déjà un statut de résultat consolidé.\n *\n * Ne PAS confondre avec \"conform\" : posé par SignatureElectronic juste après\n * la signature, avant le vrai nœud \"end\" — ce n'est pas une fin de parcours.\n */\nexport const isSessionFinished = (status?: string | null): boolean => {\n if (!status) return false;\n return status === \"ended\" || CONSOLIDATED_RESULT_STATUSES.has(status);\n};\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA,IAAM,4BAA4B,GAAG,IAAI,GAAG,CAAC;IAC3C,QAAQ;IACR,aAAa;IACb,aAAa;IACb,eAAe;IACf,eAAe;AAChB,CAAA,CAAC;AAEF;;;;;;AAMG;AACI,IAAM,iBAAiB,GAAG,UAAC,MAAsB,EAAA;AACtD,IAAA,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,KAAK;IACzB,OAAO,MAAM,KAAK,OAAO,IAAI,4BAA4B,CAAC,GAAG,CAAC,MAAM,CAAC;AACvE;;;;"}