datakeen-session-react 1.1.202-dev.13 → 1.1.202-dev.15

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 (31) hide show
  1. package/dist/cjs/components/DatakeenSession.js +14 -2
  2. package/dist/cjs/components/session/ContinuedElsewhere.js +9 -5
  3. package/dist/cjs/components/session/ContinuedElsewhereIllustration.js +37 -0
  4. package/dist/cjs/components/session/SessionContent.js +3 -3
  5. package/dist/cjs/hooks/useActiveDevice.js +171 -0
  6. package/dist/cjs/hooks/useRemoteSessionSync.js +32 -12
  7. package/dist/cjs/hooks/useUserInputForm.js +14 -1
  8. package/dist/cjs/i18n/en.json.js +5 -3
  9. package/dist/cjs/i18n/es.json.js +5 -3
  10. package/dist/cjs/i18n/fr.json.js +5 -3
  11. package/dist/cjs/index.css.js +1 -1
  12. package/dist/cjs/services/api.js +4 -1
  13. package/dist/cjs/services/realtime/sessionSyncReducer.js +14 -3
  14. package/dist/cjs/services/sessionCredentials.js +23 -2
  15. package/dist/cjs/services/sessionService.js +35 -0
  16. package/dist/esm/components/DatakeenSession.js +14 -2
  17. package/dist/esm/components/session/ContinuedElsewhere.js +10 -6
  18. package/dist/esm/components/session/ContinuedElsewhereIllustration.js +33 -0
  19. package/dist/esm/components/session/SessionContent.js +3 -3
  20. package/dist/esm/hooks/useActiveDevice.js +166 -0
  21. package/dist/esm/hooks/useRemoteSessionSync.js +32 -12
  22. package/dist/esm/hooks/useUserInputForm.js +14 -1
  23. package/dist/esm/i18n/en.json.js +5 -3
  24. package/dist/esm/i18n/es.json.js +5 -3
  25. package/dist/esm/i18n/fr.json.js +5 -3
  26. package/dist/esm/index.css.js +1 -1
  27. package/dist/esm/services/api.js +5 -2
  28. package/dist/esm/services/realtime/sessionSyncReducer.js +14 -4
  29. package/dist/esm/services/sessionCredentials.js +22 -3
  30. package/dist/esm/services/sessionService.js +36 -2
  31. package/package.json +1 -1
@@ -19,7 +19,16 @@ var COMMITTED_NODE_TYPES = new Set(["selfie-capture", "biometric-capture"]);
19
19
  * demande caméra, audit d'ouverture DocuSeal). L'appareil passif les rejoint en attente
20
20
  * (« poursuivi sur un autre appareil ») et ne les monte que si l'usager le demande.
21
21
  */
22
- var STANDBY_NODE_TYPES = new Set(["selfie-capture", "biometric-capture", "signature-electronic", "video-capture"]);
22
+ var STANDBY_NODE_TYPES = new Set([
23
+ "selfie-capture",
24
+ "biometric-capture",
25
+ "signature-electronic",
26
+ "video-capture",
27
+ // Upload + analyse (ou dépôt) : un seul appareil à la fois (QA APP3-2030).
28
+ "controle-jdi",
29
+ "document-selection",
30
+ "document-collection",
31
+ ]);
23
32
  /** Seuls ces types sont traités ; un type ajouté plus tard au contrat est ignoré par ce SDK. */
24
33
  var HANDLED_EVENT_TYPES = new Set(["session.snapshot", "session.progress.updated", "session.status.changed", "session.deleted"]);
25
34
  var ignore = function (reason) { return ({ action: "ignore", reason: reason }); };
@@ -60,7 +69,8 @@ function decideRemoteSync(state, event, template) {
60
69
  return { action: "defer" };
61
70
  if (event.type === "session.deleted")
62
71
  return { action: "close" };
63
- if (event.type === "session.nfc.updated" || !event.data)
72
+ // Appareil actif : traité par useActiveDevice, pas par la navigation.
73
+ if (event.type === "session.nfc.updated" || event.type === "session.device.claimed" || event.type === "session.control.updated" || !event.data)
64
74
  return ignore("unsupported");
65
75
  var status = event.data.status;
66
76
  var target = resolveTarget(event.data, template);
@@ -94,10 +104,10 @@ function decideRemoteSync(state, event, template) {
94
104
  function isTerminalSessionEvent(event) {
95
105
  if (event.type === "session.deleted")
96
106
  return true;
97
- if (event.type === "session.nfc.updated" || !HANDLED_EVENT_TYPES.has(event.type) || !event.data)
107
+ if (event.type === "session.nfc.updated" || event.type === "session.device.claimed" || event.type === "session.control.updated" || !HANDLED_EVENT_TYPES.has(event.type) || !event.data)
98
108
  return false;
99
109
  var status = event.data.status;
100
110
  return status === "ended" || status === "expired" || status === "abandoned";
101
111
  }
102
112
 
103
- export { decideRemoteSync, isTerminalSessionEvent };
113
+ export { STANDBY_NODE_TYPES, decideRemoteSync, isTerminalSessionEvent };
@@ -9,12 +9,31 @@ function setSessionCredential(sessionId, token) {
9
9
  function getSessionCredential(sessionId) {
10
10
  return credentials.get(sessionId);
11
11
  }
12
- function credentialForRequest(url) {
12
+ function sessionIdOfRequest(url) {
13
13
  if (/^[a-z]+:/i.test(url) || url.startsWith('//'))
14
14
  return undefined;
15
15
  // Routes SDK et biométrie Unissey : toutes adressent une seule session par son id.
16
16
  var match = url.match(/^\/?session\/(?:sdk|unissey)\/([^/?]+)/);
17
- return match ? credentials.get(decodeURIComponent(match[1])) : undefined;
17
+ return match ? decodeURIComponent(match[1]) : undefined;
18
+ }
19
+ function credentialForRequest(url) {
20
+ var sessionId = sessionIdOfRequest(url);
21
+ return sessionId ? credentials.get(sessionId) : undefined;
22
+ }
23
+ /**
24
+ * APP3-2030 — identifiant aléatoire de l'onglet, envoyé en `X-Device-Id` sur les routes de la
25
+ * session : l'appareil qui lance une analyse devient l'appareil actif du nœud côté serveur.
26
+ */
27
+ var deviceIds = new Map();
28
+ function setSessionDeviceId(sessionId, deviceId) {
29
+ if (deviceId)
30
+ deviceIds.set(sessionId, deviceId);
31
+ else
32
+ deviceIds.delete(sessionId);
33
+ }
34
+ function deviceIdForRequest(url) {
35
+ var sessionId = sessionIdOfRequest(url);
36
+ return sessionId ? deviceIds.get(sessionId) : undefined;
18
37
  }
19
38
 
20
- export { credentialForRequest, getSessionCredential, setSessionCredential };
39
+ export { credentialForRequest, deviceIdForRequest, getSessionCredential, setSessionCredential, setSessionDeviceId };
@@ -1,4 +1,4 @@
1
- import { __awaiter, __generator, __assign } from '../node_modules/tslib/tslib.es6.js';
1
+ import { __awaiter, __generator, __assign, __spreadArray } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { apiService } from './api.js';
3
3
  import { logStatusModified } from './auditTrailService.js';
4
4
  import { clearSessionMemory } from './sessionMemoryStore.js';
@@ -222,6 +222,40 @@ var updateSessionCurrentStep = function (sessionId, currentStep, currentNodeId)
222
222
  }
223
223
  });
224
224
  }); };
225
+ /**
226
+ * APP3-2030 — cet appareil prend la main sur un nœud de capture/upload ; les autres appareils
227
+ * passent en attente. `control-in-progress` : une analyse lancée sur l'autre appareil n'est pas
228
+ * encore revenue, réessayer plus tard.
229
+ */
230
+ var claimActiveDevice = function (sessionId_1, deviceId_1, nodeId_1) {
231
+ var args_1 = [];
232
+ for (var _i = 3; _i < arguments.length; _i++) {
233
+ args_1[_i - 3] = arguments[_i];
234
+ }
235
+ return __awaiter(void 0, __spreadArray([sessionId_1, deviceId_1, nodeId_1], args_1, true), void 0, function (sessionId, deviceId, nodeId, takeover) {
236
+ var error_7, response;
237
+ var _a;
238
+ if (takeover === void 0) { takeover = false; }
239
+ return __generator(this, function (_b) {
240
+ switch (_b.label) {
241
+ case 0:
242
+ _b.trys.push([0, 2, , 3]);
243
+ return [4 /*yield*/, apiService.post("/session/sdk/".concat(sessionId, "/active-device"), __assign({ deviceId: deviceId, nodeId: nodeId }, (takeover ? { takeover: true } : {})))];
244
+ case 1:
245
+ _b.sent();
246
+ return [2 /*return*/, "claimed"];
247
+ case 2:
248
+ error_7 = _b.sent();
249
+ response = error_7 === null || error_7 === void 0 ? void 0 : error_7.response;
250
+ if ((response === null || response === void 0 ? void 0 : response.status) === 409 && ((_a = response.data) === null || _a === void 0 ? void 0 : _a.code) === "CONTROL_IN_PROGRESS")
251
+ return [2 /*return*/, "control-in-progress"];
252
+ console.error("Failed to claim the active device:", error_7);
253
+ return [2 /*return*/, "failed"];
254
+ case 3: return [2 /*return*/];
255
+ }
256
+ });
257
+ });
258
+ };
225
259
  /**
226
260
  * Gets the journey steps from the template in order
227
261
  *
@@ -515,4 +549,4 @@ function checkComplementaryMandate(sessionId, nodeId) {
515
549
  return request;
516
550
  }
517
551
 
518
- export { checkComplementaryMandate, clearSessionSensitiveData, fetchSessionById, findOutgoingEdge, getNextStepIndex, getOrderedJourneySteps, getRunPrefillData, hasOutgoingEdgeForHandle, isSessionExpired, reconstructHistoryToStep, reportCaptureDiagnostics, reportSelfieFailure, resetNfcScan, sendClientInfo, skipNfcWithReason, storeDocumentOptions, updateSessionContactInfo, updateSessionCurrentStep, updateSessionStatus, updateSessionUserInput };
552
+ export { checkComplementaryMandate, claimActiveDevice, clearSessionSensitiveData, fetchSessionById, findOutgoingEdge, getNextStepIndex, getOrderedJourneySteps, getRunPrefillData, hasOutgoingEdgeForHandle, isSessionExpired, reconstructHistoryToStep, reportCaptureDiagnostics, reportSelfieFailure, resetNfcScan, sendClientInfo, skipNfcWithReason, storeDocumentOptions, updateSessionContactInfo, updateSessionCurrentStep, updateSessionStatus, updateSessionUserInput };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datakeen-session-react",
3
- "version": "1.1.202-dev.13",
3
+ "version": "1.1.202-dev.15",
4
4
  "description": "React SDK component to manage and render Datakeen session experiences easily.",
5
5
  "publishConfig": {
6
6
  "access": "public",