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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/components/document-collection/DocumentError.js +18 -14
  2. package/dist/cjs/components/document-collection/DocumentProcessing.js +3 -1
  3. package/dist/cjs/components/jdi/JDIError.js +16 -12
  4. package/dist/cjs/components/jdi/JDIProcessing.js +6 -1
  5. package/dist/cjs/components/nfc-scan/NfcScanNode.js +3 -4
  6. package/dist/cjs/components/session/DocumentCheck.js +25 -9
  7. package/dist/cjs/components/session/controleJdiPolicy.js +6 -1
  8. package/dist/cjs/components/signature-electronic/SignatureElectronic.js +13 -30
  9. package/dist/cjs/components/template/ExternalVerificationNodeHandler.js +94 -63
  10. package/dist/cjs/hooks/useStepNavigation.js +9 -1
  11. package/dist/cjs/hooks/useUserInputForm.js +42 -0
  12. package/dist/cjs/services/analysis.js +7 -0
  13. package/dist/cjs/services/pollingService.js +4 -1
  14. package/dist/cjs/services/sessionService.js +4 -4
  15. package/dist/cjs/utils/analysisErrors.js +11 -0
  16. package/dist/cjs/utils/sessionStatus.js +3 -2
  17. package/dist/esm/components/document-collection/DocumentError.js +18 -14
  18. package/dist/esm/components/document-collection/DocumentProcessing.js +4 -2
  19. package/dist/esm/components/jdi/JDIError.js +16 -12
  20. package/dist/esm/components/jdi/JDIProcessing.js +7 -2
  21. package/dist/esm/components/nfc-scan/NfcScanNode.js +3 -4
  22. package/dist/esm/components/session/DocumentCheck.js +25 -9
  23. package/dist/esm/components/session/controleJdiPolicy.js +6 -1
  24. package/dist/esm/components/signature-electronic/SignatureElectronic.js +13 -30
  25. package/dist/esm/components/template/ExternalVerificationNodeHandler.js +94 -63
  26. package/dist/esm/hooks/useStepNavigation.js +9 -1
  27. package/dist/esm/hooks/useUserInputForm.js +42 -0
  28. package/dist/esm/services/analysis.js +7 -0
  29. package/dist/esm/services/pollingService.js +4 -1
  30. package/dist/esm/services/sessionService.js +4 -4
  31. package/dist/esm/utils/analysisErrors.js +10 -1
  32. package/dist/esm/utils/sessionStatus.js +3 -2
  33. package/package.json +2 -1
@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import sdkI18n from '../../i18n/index.js';
6
6
  import { apiService } from '../../services/api.js';
7
+ import { fetchSessionById } from '../../services/sessionService.js';
7
8
  import checkIcon from '../../assets/check.svg.js';
8
9
  import LoadingState from '../states/LoadingState.js';
9
10
  import Title from '../ui/Title.js';
@@ -189,10 +190,10 @@ var ExternalVerificationNodeHandler = function (_a) {
189
190
  useEffect(function () {
190
191
  var abortController = new AbortController();
191
192
  var run = function () { return __awaiter(void 0, void 0, void 0, function () {
192
- var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personNodeInput, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
193
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
194
- return __generator(this, function (_w) {
195
- switch (_w.label) {
193
+ var result, referenceField, referenceValueMasked, resolvedReferenceValue, referenceNodeId, referenceVariable, submittedFirstName, submittedLastName, submittedSiren, nodeInput, userInputFlat, nodeScopedKeys, lookupKeys, referenceValue, allCustomFields, _i, _a, _b, value, str, comparisonConfig, cfg, personRefId_1, personNodeInput_1, fromIdentityCopy, fresh, error_1, flat, isPersonneMorale, sirenKeys, firstNameKeys, lastNameKeys, birthDateKeys, dateOfBirth, response, res, apiErr_1, apiResult, inpi, cfg, isPersonneMorale_1;
194
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
195
+ return __generator(this, function (_y) {
196
+ switch (_y.label) {
196
197
  case 0:
197
198
  result = {
198
199
  isVerified: false,
@@ -206,9 +207,9 @@ var ExternalVerificationNodeHandler = function (_a) {
206
207
  submittedFirstName = '';
207
208
  submittedLastName = '';
208
209
  submittedSiren = '';
209
- _w.label = 1;
210
+ _y.label = 1;
210
211
  case 1:
211
- _w.trys.push([1, 9, , 10]);
212
+ _y.trys.push([1, 15, , 16]);
212
213
  if (!(session === null || session === void 0 ? void 0 : session.id))
213
214
  throw new Error('Session ID is missing');
214
215
  referenceField = normalizeReferenceField(String(nodeData.referenceField || referenceVariable || ''));
@@ -219,7 +220,7 @@ var ExternalVerificationNodeHandler = function (_a) {
219
220
  message: 'External verification node is missing reference configuration.',
220
221
  errorCode: 'MISSING_REFERENCE_CONFIG',
221
222
  };
222
- return [3 /*break*/, 8];
223
+ return [3 /*break*/, 14];
223
224
  case 2:
224
225
  nodeInput = userInput[referenceNodeId];
225
226
  userInputFlat = userInput;
@@ -262,71 +263,101 @@ var ExternalVerificationNodeHandler = function (_a) {
262
263
  message: 'No SIREN/SIRET value found in source node data.',
263
264
  errorCode: 'REFERENCE_VALUE_NOT_FOUND',
264
265
  };
265
- return [3 /*break*/, 8];
266
+ return [3 /*break*/, 14];
266
267
  case 3:
267
268
  resolvedReferenceValue = referenceValue;
268
269
  referenceValueMasked = maskReferenceValue(referenceValue);
269
270
  comparisonConfig = void 0;
270
- if (isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId)) {
271
- cfg = nodeData.comparisonConfig;
272
- personNodeInput = (_e = userInput[cfg.personReferenceNodeId]) !== null && _e !== void 0 ? _e : {};
273
- flat = userInput;
274
- isPersonneMorale = cfg.personType === 'MORALE';
275
- if (isPersonneMorale) {
276
- sirenKeys = expandFieldKey((_f = cfg.personSirenField) !== null && _f !== void 0 ? _f : '').filter(Boolean);
277
- submittedSiren = (_g = resolveFieldValue(personNodeInput, flat, sirenKeys)) !== null && _g !== void 0 ? _g : '';
278
- if (submittedSiren) {
279
- comparisonConfig = {
280
- personType: 'MORALE',
281
- siren: submittedSiren,
282
- // Un RBE est toujours une personne physique en droit
283
- // français : forcé à 'mandataires' quel que soit le
284
- // contenu de cfg.compareTargets (défense en profondeur).
285
- compareTargets: ['mandataires'],
286
- };
287
- }
271
+ if (!(isInpiRbe && ((_d = nodeData.comparisonConfig) === null || _d === void 0 ? void 0 : _d.personReferenceNodeId))) return [3 /*break*/, 9];
272
+ cfg = nodeData.comparisonConfig;
273
+ personRefId_1 = cfg.personReferenceNodeId;
274
+ personNodeInput_1 = userInput[personRefId_1];
275
+ fromIdentityCopy = ((_f = (_e = session.template) === null || _e === void 0 ? void 0 : _e.nodes) !== null && _f !== void 0 ? _f : []).some(function (n) { return n.id === personRefId_1 &&
276
+ (n.type === 'controle-jdi' || n.type === 'identity-control') &&
277
+ n.copyIdentityToUserInput === true; });
278
+ if (!(fromIdentityCopy && !personNodeInput_1)) return [3 /*break*/, 8];
279
+ _y.label = 4;
280
+ case 4:
281
+ _y.trys.push([4, 6, , 7]);
282
+ return [4 /*yield*/, fetchSessionById(session.id)];
283
+ case 5:
284
+ fresh = _y.sent();
285
+ personNodeInput_1 = (_g = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) === null || _g === void 0 ? void 0 : _g[personRefId_1];
286
+ if (personNodeInput_1) {
287
+ setUserInput(function (prev) {
288
+ var _a;
289
+ return (__assign(__assign({}, prev), (_a = {}, _a[personRefId_1] = personNodeInput_1, _a)));
290
+ });
291
+ }
292
+ return [3 /*break*/, 7];
293
+ case 6:
294
+ error_1 = _y.sent();
295
+ console.warn('[ExternalVerification] Identité reportée indisponible', error_1);
296
+ return [3 /*break*/, 7];
297
+ case 7:
298
+ if (abortController.signal.aborted)
299
+ return [2 /*return*/];
300
+ _y.label = 8;
301
+ case 8:
302
+ personNodeInput_1 = personNodeInput_1 !== null && personNodeInput_1 !== void 0 ? personNodeInput_1 : {};
303
+ flat = fromIdentityCopy ? {} : userInput;
304
+ isPersonneMorale = cfg.personType === 'MORALE';
305
+ if (isPersonneMorale) {
306
+ sirenKeys = expandFieldKey((_h = cfg.personSirenField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
307
+ submittedSiren = (_j = resolveFieldValue(personNodeInput_1, flat, sirenKeys)) !== null && _j !== void 0 ? _j : '';
308
+ if (submittedSiren) {
309
+ comparisonConfig = {
310
+ personType: 'MORALE',
311
+ siren: submittedSiren,
312
+ // Un RBE est toujours une personne physique en droit
313
+ // français : forcé à 'mandataires' quel que soit le
314
+ // contenu de cfg.compareTargets (défense en profondeur).
315
+ compareTargets: ['mandataires'],
316
+ };
288
317
  }
289
- else {
290
- firstNameKeys = expandFieldKey((_h = cfg.personFirstNameField) !== null && _h !== void 0 ? _h : '').filter(Boolean);
291
- lastNameKeys = expandFieldKey((_j = cfg.personLastNameField) !== null && _j !== void 0 ? _j : '').filter(Boolean);
292
- birthDateKeys = cfg.personBirthDateField
293
- ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
294
- : [];
295
- submittedFirstName = (_k = resolveFieldValue(personNodeInput, flat, firstNameKeys)) !== null && _k !== void 0 ? _k : '';
296
- submittedLastName = (_l = resolveFieldValue(personNodeInput, flat, lastNameKeys)) !== null && _l !== void 0 ? _l : '';
297
- dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
298
- ? resolveFieldValue(personNodeInput, flat, birthDateKeys)
299
- : undefined;
300
- if (submittedFirstName && submittedLastName) {
301
- comparisonConfig = __assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_m = cfg.compareTargets) !== null && _m !== void 0 ? _m : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
302
- }
318
+ }
319
+ else {
320
+ firstNameKeys = expandFieldKey((_k = cfg.personFirstNameField) !== null && _k !== void 0 ? _k : '').filter(Boolean);
321
+ lastNameKeys = expandFieldKey((_l = cfg.personLastNameField) !== null && _l !== void 0 ? _l : '').filter(Boolean);
322
+ birthDateKeys = cfg.personBirthDateField
323
+ ? expandFieldKey(cfg.personBirthDateField).filter(Boolean)
324
+ : [];
325
+ submittedFirstName = (_m = resolveFieldValue(personNodeInput_1, flat, firstNameKeys)) !== null && _m !== void 0 ? _m : '';
326
+ submittedLastName = (_o = resolveFieldValue(personNodeInput_1, flat, lastNameKeys)) !== null && _o !== void 0 ? _o : '';
327
+ dateOfBirth = cfg.compareBirthDate && birthDateKeys.length
328
+ ? resolveFieldValue(personNodeInput_1, flat, birthDateKeys)
329
+ : undefined;
330
+ if (submittedFirstName && submittedLastName) {
331
+ comparisonConfig = __assign({ firstName: submittedFirstName, lastName: submittedLastName, compareTargets: (_p = cfg.compareTargets) !== null && _p !== void 0 ? _p : ['mandataires'] }, (dateOfBirth ? { dateOfBirth: dateOfBirth } : {}));
303
332
  }
304
333
  }
334
+ _y.label = 9;
335
+ case 9:
305
336
  if (isInpiRbe)
306
337
  advanceStep(1);
307
- _w.label = 4;
308
- case 4:
309
- _w.trys.push([4, 7, , 8]);
338
+ _y.label = 10;
339
+ case 10:
340
+ _y.trys.push([10, 13, , 14]);
310
341
  return [4 /*yield*/, apiService.post("/session/sdk/".concat(session.id, "/verify-external/").concat(node.id), __assign({ apiType: apiType, referenceValue: referenceValue, referenceField: referenceField, enableRnaFallback: isInpiRbe && nodeData.rnaFallbackEnabled === true, enableInseeFallback: isInpiRbe && nodeData.enableInseeFallback === true }, (comparisonConfig ? { comparisonConfig: comparisonConfig } : {})), { signal: abortController.signal })];
311
- case 5:
312
- response = _w.sent();
342
+ case 11:
343
+ response = _y.sent();
313
344
  if (isInpiRbe)
314
345
  advanceStep(2);
315
346
  return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 600); })];
316
- case 6:
317
- _w.sent();
318
- res = (_o = response.data) === null || _o === void 0 ? void 0 : _o.data;
347
+ case 12:
348
+ _y.sent();
349
+ res = (_q = response.data) === null || _q === void 0 ? void 0 : _q.data;
319
350
  if (res && typeof res.isVerified === 'boolean') {
320
351
  result = res;
321
352
  }
322
- return [3 /*break*/, 8];
323
- case 7:
324
- apiErr_1 = _w.sent();
353
+ return [3 /*break*/, 14];
354
+ case 13:
355
+ apiErr_1 = _y.sent();
325
356
  if (abortController.signal.aborted)
326
357
  return [2 /*return*/];
327
358
  if (isInpiRbe)
328
359
  advanceStep(2);
329
- apiResult = (_q = (_p = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.data;
360
+ apiResult = (_s = (_r = apiErr_1 === null || apiErr_1 === void 0 ? void 0 : apiErr_1.response) === null || _r === void 0 ? void 0 : _r.data) === null || _s === void 0 ? void 0 : _s.data;
330
361
  if (apiResult && typeof apiResult.isVerified === 'boolean') {
331
362
  result = apiResult;
332
363
  }
@@ -338,18 +369,18 @@ var ExternalVerificationNodeHandler = function (_a) {
338
369
  errorCode: 'REQUEST_FAILED',
339
370
  };
340
371
  }
341
- return [3 /*break*/, 8];
342
- case 8: return [3 /*break*/, 10];
343
- case 9:
344
- _w.sent();
372
+ return [3 /*break*/, 14];
373
+ case 14: return [3 /*break*/, 16];
374
+ case 15:
375
+ _y.sent();
345
376
  result = {
346
377
  isVerified: false,
347
378
  status: 'external_error',
348
379
  message: 'Unexpected error during verification.',
349
380
  errorCode: 'UNEXPECTED_ERROR',
350
381
  };
351
- return [3 /*break*/, 10];
352
- case 10:
382
+ return [3 /*break*/, 16];
383
+ case 16:
353
384
  if (abortController.signal.aborted)
354
385
  return [2 /*return*/];
355
386
  completeSteps();
@@ -381,13 +412,13 @@ var ExternalVerificationNodeHandler = function (_a) {
381
412
  // physique, tous les mandataires sont listés : une société
382
413
  // mandataire (ex. holding présidente) explique pourquoi la
383
414
  // personne saisie n'apparaît pas en direct au RNE.
384
- mandataires: ((_r = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _r !== void 0 ? _r : []).filter(function (m) {
415
+ mandataires: ((_t = inpi === null || inpi === void 0 ? void 0 : inpi.mandataires) !== null && _t !== void 0 ? _t : []).filter(function (m) {
385
416
  return isPersonneMorale_1 ? m.type === 'personne_morale' : true;
386
417
  }),
387
- beneficiairesEffectifs: (_s = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _s !== void 0 ? _s : [],
388
- compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_t = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _t !== void 0 ? _t : ['mandataires']),
389
- personNodeId: (_u = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _u !== void 0 ? _u : '',
390
- targetDenomination: (_v = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _v === void 0 ? void 0 : _v.denomination,
418
+ beneficiairesEffectifs: (_u = inpi === null || inpi === void 0 ? void 0 : inpi.beneficiairesEffectifs) !== null && _u !== void 0 ? _u : [],
419
+ compareTargets: isPersonneMorale_1 ? ['mandataires'] : ((_v = cfg === null || cfg === void 0 ? void 0 : cfg.compareTargets) !== null && _v !== void 0 ? _v : ['mandataires']),
420
+ personNodeId: (_w = cfg === null || cfg === void 0 ? void 0 : cfg.personReferenceNodeId) !== null && _w !== void 0 ? _w : '',
421
+ targetDenomination: (_x = inpi === null || inpi === void 0 ? void 0 : inpi.identite) === null || _x === void 0 ? void 0 : _x.denomination,
391
422
  siren: resolvedReferenceValue,
392
423
  sirenNodeId: referenceNodeId,
393
424
  source: inpi === null || inpi === void 0 ? void 0 : inpi.source,
@@ -40,6 +40,7 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
40
40
  var hasInitialized = useRef(false);
41
41
  var committedNavigationPending = useRef(false);
42
42
  var setStep = function (newStep, skipHistory) {
43
+ var _a;
43
44
  if (skipHistory === void 0) { skipHistory = false; }
44
45
  if (!skipHistory && newStep !== step) {
45
46
  setHistory(function (prev) {
@@ -51,7 +52,14 @@ var useStepNavigation = function (sessionId, sessionStatus, initialStep, templat
51
52
  setStepState(newStep);
52
53
  // Update current step in database
53
54
  if (sessionId) {
54
- updateSessionCurrentStep(sessionId, newStep).catch(function (error) {
55
+ // APP3-1999 : id stable du nœud atteint (aucun pour l'accueil 0 et le QR 0.5).
56
+ var nodeId = template && Number.isInteger(newStep) && newStep >= 1
57
+ ? (_a = getOrderedJourneySteps(template)[newStep - 1]) === null || _a === void 0 ? void 0 : _a.id
58
+ : undefined;
59
+ var update = nodeId
60
+ ? updateSessionCurrentStep(sessionId, newStep, nodeId)
61
+ : updateSessionCurrentStep(sessionId, newStep);
62
+ update.catch(function (error) {
55
63
  console.error("Failed to update current step in database:", error);
56
64
  // Non-blocking error - the step is still updated locally
57
65
  });
@@ -11,6 +11,7 @@ import { labelToKey } from '../utils/labelToKey.js';
11
11
  import { DEFAULT_DATE_DISPLAY_FORMAT } from '../types/session.js';
12
12
  import { useI18n } from './useI18n.js';
13
13
  import { logFormValidated } from '../services/auditTrailService.js';
14
+ import { fetchSessionById } from '../services/sessionService.js';
14
15
 
15
16
  var useUserInputForm = function (_a) {
16
17
  var stepObject = _a.stepObject, setUserInput = _a.setUserInput, initialUserInput = _a.initialUserInput, node = _a.node, template = _a.template, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo, onContinueCallback = _a.onContinueCallback, sessionId = _a.sessionId;
@@ -267,6 +268,47 @@ var useUserInputForm = function (_a) {
267
268
  form.phoneNumber,
268
269
  form.companyName,
269
270
  ]);
271
+ // APP3-2020 — le serveur reporte prénom, nom et date de naissance lus sur la pièce
272
+ // à la racine de userInput après l'analyse : absents de la mémoire du SDK, on les
273
+ // relit à l'ouverture du formulaire personne physique (une fois par nœud, remount
274
+ // par key). Seules les clés vides sont complétées ; l'effet ci-dessus re-synchronise.
275
+ useEffect(function () {
276
+ var _a;
277
+ if (informationType !== "identity" ||
278
+ !sessionId ||
279
+ (initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.firstName) ||
280
+ (initialUserInput === null || initialUserInput === void 0 ? void 0 : initialUserInput.lastName) ||
281
+ !((_a = template === null || template === void 0 ? void 0 : template.nodes) !== null && _a !== void 0 ? _a : []).some(function (n) {
282
+ return (n.type === "controle-jdi" || n.type === "identity-control") &&
283
+ n.copyIdentityToUserInput === true;
284
+ })) {
285
+ return;
286
+ }
287
+ var cancelled = false;
288
+ fetchSessionById(sessionId)
289
+ .then(function (fresh) {
290
+ var _a;
291
+ var server = ((_a = fresh === null || fresh === void 0 ? void 0 : fresh.userInput) !== null && _a !== void 0 ? _a : {});
292
+ var fill = ["firstName", "lastName", "birthDate"].filter(function (key) { return typeof server[key] === "string" && server[key]; });
293
+ if (cancelled || !fill.length)
294
+ return;
295
+ setUserInput(function (prev) {
296
+ var next = __assign({}, prev);
297
+ for (var _i = 0, fill_1 = fill; _i < fill_1.length; _i++) {
298
+ var key = fill_1[_i];
299
+ if (!next[key])
300
+ next[key] = server[key];
301
+ }
302
+ return next;
303
+ });
304
+ })
305
+ .catch(function (error) {
306
+ console.warn("[UserInputForm] Identité reportée indisponible", error);
307
+ });
308
+ return function () {
309
+ cancelled = true;
310
+ };
311
+ }, []); // Une seule relecture à l'ouverture du nœud.
270
312
  // Re-synchronise customFormData depuis initialUserInput quand on (ré)affiche un
271
313
  // nœud DIFFÉRENT sur une instance réutilisée (retour arrière sans remount).
272
314
  // Le champ form standard a déjà son propre effet de re-sync ci-dessus ; le
@@ -5,6 +5,7 @@ import { apiService } from './api.js';
5
5
  import { getSessionMemoryUserInput } from './sessionMemoryStore.js';
6
6
  import { logAiControlled, logDocumentUploaded, logStatusModified, logSelfieCaptured } from './auditTrailService.js';
7
7
  import { stopPolling, pollAnalysisStatus } from './pollingService.js';
8
+ import { isAnalysisFailedError } from '../utils/analysisErrors.js';
8
9
 
9
10
  // Timeout configurations (in milliseconds)
10
11
  var ANALYSIS_TIMEOUT = 600000; // 10 minutes for document analysis (increased for large files + ML processing)
@@ -246,6 +247,10 @@ function analyzeFiles(sessionId_1, nodeId_1, files_1, documentTypeId_1) {
246
247
  return [2 /*return*/, pollingResult];
247
248
  case 7:
248
249
  pollError_1 = _a.sent();
250
+ // Une analyse terminée en erreur doit bloquer le nœud : seule une
251
+ // panne du polling (timeout, réseau) laisse le backend finir.
252
+ if (isAnalysisFailedError(pollError_1))
253
+ throw pollError_1;
249
254
  console.warn("⚠️ Polling error (analysis may still be processing):", pollError_1);
250
255
  // Don't throw - polling error shouldn't fail the analysis submission
251
256
  // The backend is still processing even if polling fails
@@ -507,6 +512,8 @@ function analyzeDocumentVideo(sessionId_1, nodeId_1, videoData_1, previews_1, do
507
512
  return [2 /*return*/, pollingResult];
508
513
  case 5:
509
514
  pollError_2 = _k.sent();
515
+ if (isAnalysisFailedError(pollError_2))
516
+ throw pollError_2;
510
517
  console.warn("⚠️ Polling error (document-video may still be processing):", pollError_2);
511
518
  return [3 /*break*/, 6];
512
519
  case 6:
@@ -1,5 +1,6 @@
1
1
  import { __awaiter, __generator, __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { apiService } from './api.js';
3
+ import { ANALYSIS_FAILED_CODE } from '../utils/analysisErrors.js';
3
4
 
4
5
  var pollingTimeoutId = null;
5
6
  var pollingStartTime = 0;
@@ -105,7 +106,9 @@ function pollAnalysisStatus(sessionId_1) {
105
106
  }
106
107
  isPollingActive = false;
107
108
  pollingTimeoutId = null;
108
- reject(new Error("Analysis failed: ".concat(userMessage)));
109
+ reject(Object.assign(new Error("Analysis failed: ".concat(userMessage)), {
110
+ code: ANALYSIS_FAILED_CODE,
111
+ }));
109
112
  return [2 /*return*/];
110
113
  }
111
114
  // Analysis completed successfully (approved, rejected, to_verify, or completed)
@@ -200,17 +200,17 @@ var updateSessionStatus = function (sessionId, status, reachedEndNodeId) { retur
200
200
  *
201
201
  * @param sessionId - The unique identifier of the session
202
202
  * @param currentStep - The current step index in the workflow
203
+ * @param currentNodeId - Stable id of the journey node at this step, when there is one
204
+ * (none for the welcome and QR screens). The backend timestamps the node entry.
203
205
  * @returns The updated session data
204
206
  */
205
- var updateSessionCurrentStep = function (sessionId, currentStep) { return __awaiter(void 0, void 0, void 0, function () {
207
+ var updateSessionCurrentStep = function (sessionId, currentStep, currentNodeId) { return __awaiter(void 0, void 0, void 0, function () {
206
208
  var response, error_6;
207
209
  return __generator(this, function (_a) {
208
210
  switch (_a.label) {
209
211
  case 0:
210
212
  _a.trys.push([0, 2, , 3]);
211
- return [4 /*yield*/, apiService.patch("/session/sdk/".concat(sessionId), {
212
- currentStep: currentStep,
213
- })];
213
+ return [4 /*yield*/, apiService.patch("/session/sdk/".concat(sessionId), __assign({ currentStep: currentStep }, (currentNodeId ? { currentNodeId: currentNodeId } : {})))];
214
214
  case 1:
215
215
  response = _a.sent();
216
216
  return [2 /*return*/, response.data];
@@ -14,6 +14,15 @@ var isS3UploadNotConfirmedError = function (error) {
14
14
  return (apiError.details.code ===
15
15
  S3_UPLOAD_NOT_CONFIRMED_CODE);
16
16
  };
17
+ // Code SDK interne : l'analyse s'est terminée en `error`/`failed` côté moteur
18
+ // (posé par pollingService). Distinct d'un simple timeout de polling, où le
19
+ // backend peut encore produire un résultat.
20
+ var ANALYSIS_FAILED_CODE = "ANALYSIS_FAILED";
21
+ var isAnalysisFailedError = function (error) {
22
+ return typeof error === "object" &&
23
+ error !== null &&
24
+ error.code === ANALYSIS_FAILED_CODE;
25
+ };
17
26
  // Must stay aligned with QUOTA_EXCEEDED_CODE in the backend
18
27
  // (src/common/constants/quota-exceeded.constant.ts).
19
28
  var QUOTA_EXCEEDED_CODE = "QUOTA_EXCEEDED";
@@ -49,4 +58,4 @@ var isServiceErrorCode = function (code) {
49
58
  /** Same as getServiceErrorCode, from the polled fallback document codeName. */
50
59
  var getServiceErrorCodeFromCodeName = function (codeName) { var _a; return typeof codeName === "string" ? (_a = SERVICE_ERROR_CODE_NAMES[codeName]) !== null && _a !== void 0 ? _a : null : null; };
51
60
 
52
- export { INSUFFICIENT_CREDITS_CODE, QUOTA_EXCEEDED_CODE, S3_UPLOAD_NOT_CONFIRMED_CODE, getServiceErrorCode, getServiceErrorCodeFromCodeName, isS3UploadNotConfirmedError, isServiceErrorCode };
61
+ export { ANALYSIS_FAILED_CODE, INSUFFICIENT_CREDITS_CODE, QUOTA_EXCEEDED_CODE, S3_UPLOAD_NOT_CONFIRMED_CODE, getServiceErrorCode, getServiceErrorCodeFromCodeName, isAnalysisFailedError, isS3UploadNotConfirmedError, isServiceErrorCode };
@@ -13,8 +13,9 @@ var CONSOLIDATED_RESULT_STATUSES = new Set([
13
13
  * true si la session est terminée (écran de fin), qu'elle porte encore le
14
14
  * statut brut "ended" ou déjà un statut de résultat consolidé.
15
15
  *
16
- * Ne PAS confondre avec "conform" : posé par SignatureElectronic juste après
17
- * la signature, avant le vrai nœud "end" — ce n'est pas une fin de parcours.
16
+ * Ne PAS confondre avec "conform" : posé juste après la signature par les
17
+ * anciennes versions du SDK (la signature ne modifie plus le statut depuis
18
+ * APP3-1996), avant le vrai nœud "end" — ce n'est pas une fin de parcours.
18
19
  */
19
20
  var isSessionFinished = function (status) {
20
21
  if (!status)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.202-dev.1",
3
+ "version": "1.1.202-dev.11",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -131,6 +131,7 @@
131
131
  "pnpm": {
132
132
  "overrides": {
133
133
  "tar": ">=7.5.11",
134
+ "handlebars": ">=4.7.10",
134
135
  "minimatch@<3.1.4": "3.1.4",
135
136
  "minimatch@>=9.0.0 <9.0.7": "9.0.7",
136
137
  "minimatch@>=10.0.0 <10.2.3": "10.2.3",