datakeen-session-react 1.1.140-dev.97 → 1.1.140-oid4vp-demo.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +37 -0
- package/dist/cjs/components/document-collection/DocumentCollection.js +132 -22
- package/dist/cjs/components/document-collection/DocumentCollection.js.map +1 -1
- package/dist/cjs/components/session/DocumentCheck.js +112 -15
- package/dist/cjs/components/session/DocumentCheck.js.map +1 -1
- package/dist/cjs/components/template/TemplateNodeRenderer.js +5 -1
- package/dist/cjs/components/template/TemplateNodeRenderer.js.map +1 -1
- package/dist/cjs/components/wallet/AgeControl.js +75 -0
- package/dist/cjs/components/wallet/AgeControl.js.map +1 -0
- package/dist/cjs/components/wallet/WalletProposal.js +27 -0
- package/dist/cjs/components/wallet/WalletProposal.js.map +1 -0
- package/dist/cjs/components/wallet/WalletSuccessAnimation.js +37 -0
- package/dist/cjs/components/wallet/WalletSuccessAnimation.js.map +1 -0
- package/dist/cjs/components/wallet/WalletVerificationStep.js +132 -0
- package/dist/cjs/components/wallet/WalletVerificationStep.js.map +1 -0
- package/dist/cjs/hooks/useWalletSseStatus.js +67 -0
- package/dist/cjs/hooks/useWalletSseStatus.js.map +1 -0
- package/dist/cjs/i18n/en.json.js +34 -1
- package/dist/cjs/i18n/en.json.js.map +1 -1
- package/dist/cjs/i18n/fr.json.js +34 -1
- package/dist/cjs/i18n/fr.json.js.map +1 -1
- package/dist/cjs/services/sessionService.js +57 -0
- package/dist/cjs/services/sessionService.js.map +1 -1
- package/dist/cjs/types/session.js.map +1 -1
- package/dist/esm/components/document-collection/DocumentCollection.js +132 -22
- package/dist/esm/components/document-collection/DocumentCollection.js.map +1 -1
- package/dist/esm/components/session/DocumentCheck.js +113 -16
- package/dist/esm/components/session/DocumentCheck.js.map +1 -1
- package/dist/esm/components/template/TemplateNodeRenderer.js +5 -1
- package/dist/esm/components/template/TemplateNodeRenderer.js.map +1 -1
- package/dist/esm/components/wallet/AgeControl.js +71 -0
- package/dist/esm/components/wallet/AgeControl.js.map +1 -0
- package/dist/esm/components/wallet/WalletProposal.js +23 -0
- package/dist/esm/components/wallet/WalletProposal.js.map +1 -0
- package/dist/esm/components/wallet/WalletSuccessAnimation.js +33 -0
- package/dist/esm/components/wallet/WalletSuccessAnimation.js.map +1 -0
- package/dist/esm/components/wallet/WalletVerificationStep.js +128 -0
- package/dist/esm/components/wallet/WalletVerificationStep.js.map +1 -0
- package/dist/esm/hooks/useWalletSseStatus.js +65 -0
- package/dist/esm/hooks/useWalletSseStatus.js.map +1 -0
- package/dist/esm/i18n/en.json.js +33 -2
- package/dist/esm/i18n/en.json.js.map +1 -1
- package/dist/esm/i18n/fr.json.js +33 -2
- package/dist/esm/i18n/fr.json.js.map +1 -1
- package/dist/esm/services/sessionService.js +55 -1
- package/dist/esm/services/sessionService.js.map +1 -1
- package/dist/esm/types/session.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,28 @@ import { analyzeFiles } from '../../services/analysis.js';
|
|
|
19
19
|
import { getNodeRetryCount, incrementNodeRetryCount } from '../../services/retryService.js';
|
|
20
20
|
import { getSession } from '../../context/SessionContext.js';
|
|
21
21
|
import { blobToDataUrl, dataUrlToBlob, resizeAfterCapture } from '../../utils/imageProcessing.js';
|
|
22
|
+
import { fetchWallets, skipWalletWithReason } from '../../services/sessionService.js';
|
|
23
|
+
import WalletProposal from '../wallet/WalletProposal.js';
|
|
24
|
+
import WalletVerificationStep from '../wallet/WalletVerificationStep.js';
|
|
22
25
|
|
|
26
|
+
var normalizeWalletMode = function (mode) {
|
|
27
|
+
return mode === "walletOnly" ? "walletOnly" : "walletOrPhoto";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Heuristic mapping from a document-collection template's id/name to the
|
|
31
|
+
* wallet credential it corresponds to. `allowedDocumentTypes` are arbitrary,
|
|
32
|
+
* backend-template-driven strings (no fixed enum), so this is name-based —
|
|
33
|
+
* cf. docs/WALLET_OID4VP_IMPLEMENTATION_PLAN.md §7 ("option wallet quand le
|
|
34
|
+
* type collecté ∈ {permis, carte grise}").
|
|
35
|
+
*/
|
|
36
|
+
var resolveWalletCredentialType = function (docTypeIdOrName) {
|
|
37
|
+
var normalized = docTypeIdOrName.toLowerCase();
|
|
38
|
+
if (/(licence|license|permis|driving)/.test(normalized))
|
|
39
|
+
return "driving_license";
|
|
40
|
+
if (/(grise|registration|immatriculation|vehicle)/.test(normalized))
|
|
41
|
+
return "vehicle_registration";
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
23
44
|
/**
|
|
24
45
|
* DocumentCollection component manages the multi-step document collection flow.
|
|
25
46
|
* It handles document type selection, document upload, processing, and error/success handling.
|
|
@@ -44,21 +65,23 @@ import { blobToDataUrl, dataUrlToBlob, resizeAfterCapture } from '../../utils/im
|
|
|
44
65
|
*/
|
|
45
66
|
var DocumentCollection = function (_a) {
|
|
46
67
|
var _b, _c;
|
|
47
|
-
var stepObject = _a.stepObject, sessionId = _a.sessionId, node = _a.node, template = _a.template, onContinueOnPC = _a.onContinueOnPC, allowedDocumentTypes = _a.allowedDocumentTypes, allowedAddingMethods = _a.allowedAddingMethods, introductionPage = _a.introductionPage, documentSelection = _a.documentSelection, allowResubmission = _a.allowResubmission, maxResubmissionAttempts = _a.maxResubmissionAttempts;
|
|
68
|
+
var stepObject = _a.stepObject, sessionId = _a.sessionId, node = _a.node, template = _a.template, onContinueOnPC = _a.onContinueOnPC, allowedDocumentTypes = _a.allowedDocumentTypes, allowedAddingMethods = _a.allowedAddingMethods, introductionPage = _a.introductionPage, documentSelection = _a.documentSelection, allowResubmission = _a.allowResubmission, maxResubmissionAttempts = _a.maxResubmissionAttempts, countryCode = _a.countryCode;
|
|
48
69
|
var t = useI18n().t;
|
|
49
70
|
var session = getSession().session;
|
|
50
71
|
var _d = useState((introductionPage === null || introductionPage === void 0 ? void 0 : introductionPage.title) ? 0 : 1), currentStep = _d[0], setCurrentStep = _d[1];
|
|
51
|
-
var _e = useState(
|
|
52
|
-
var _f = useState(
|
|
53
|
-
var _g = useState(null),
|
|
54
|
-
var _h = useState(
|
|
55
|
-
var _j = useState(null),
|
|
56
|
-
var _k = useState(
|
|
57
|
-
var _l = useState(
|
|
72
|
+
var _e = useState(false), walletDeclined = _e[0], setWalletDeclined = _e[1];
|
|
73
|
+
var _f = useState(null), pendingWalletCredentialType = _f[0], setPendingWalletCredentialType = _f[1];
|
|
74
|
+
var _g = useState(null), fileUploaded = _g[0], setFileUploaded = _g[1];
|
|
75
|
+
var _h = useState(""), selectedDocumentType = _h[0], setSelectedDocumentType = _h[1];
|
|
76
|
+
var _j = useState(null), analysisData = _j[0], setAnalysisData = _j[1];
|
|
77
|
+
var _k = useState(null), errorCode = _k[0], setErrorCode = _k[1];
|
|
78
|
+
var _l = useState(null), selectedMethod = _l[0], setSelectedMethod = _l[1];
|
|
79
|
+
var _m = useState("before-recto"), photoSubStep = _m[0], setPhotoSubStep = _m[1];
|
|
80
|
+
var _o = useState({}), capturedImages = _o[0], setCapturedImages = _o[1];
|
|
58
81
|
// Initialize retry count from session data
|
|
59
|
-
var
|
|
82
|
+
var _p = useState(function () {
|
|
60
83
|
return getNodeRetryCount(session, node.id);
|
|
61
|
-
}), retryCount =
|
|
84
|
+
}), retryCount = _p[0], setRetryCount = _p[1];
|
|
62
85
|
// Update retry count when session loads/changes
|
|
63
86
|
useEffect(function () {
|
|
64
87
|
if (session) {
|
|
@@ -82,12 +105,43 @@ var DocumentCollection = function (_a) {
|
|
|
82
105
|
var handleContinueFromIntroduction = function () {
|
|
83
106
|
setCurrentStep(1);
|
|
84
107
|
};
|
|
85
|
-
var handleDocumentTypeSelect = function (docType, files) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
var handleDocumentTypeSelect = function (docType, files) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
+
var selectedDoc, credentialType, wallets, error_1;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
setSelectedDocumentType(docType);
|
|
114
|
+
if (files) {
|
|
115
|
+
handleDocumentUpload(files);
|
|
116
|
+
return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
if (!(node.walletEnabled === true && !walletDeclined && countryCode)) return [3 /*break*/, 4];
|
|
119
|
+
selectedDoc = allowedDocumentTypes.find(function (d) { return d.id === docType; });
|
|
120
|
+
credentialType = resolveWalletCredentialType((selectedDoc === null || selectedDoc === void 0 ? void 0 : selectedDoc.name) || docType);
|
|
121
|
+
if (!credentialType) return [3 /*break*/, 4];
|
|
122
|
+
_a.label = 1;
|
|
123
|
+
case 1:
|
|
124
|
+
_a.trys.push([1, 3, , 4]);
|
|
125
|
+
return [4 /*yield*/, fetchWallets(countryCode, credentialType)];
|
|
126
|
+
case 2:
|
|
127
|
+
wallets = _a.sent();
|
|
128
|
+
if (wallets.length > 0) {
|
|
129
|
+
setPendingWalletCredentialType(credentialType);
|
|
130
|
+
setCurrentStep(-10);
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
}
|
|
133
|
+
return [3 /*break*/, 4];
|
|
134
|
+
case 3:
|
|
135
|
+
error_1 = _a.sent();
|
|
136
|
+
console.error("Failed to check wallet availability:", error_1);
|
|
137
|
+
return [3 /*break*/, 4];
|
|
138
|
+
case 4:
|
|
139
|
+
proceedToMethodOrUpload();
|
|
140
|
+
return [2 /*return*/];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}); };
|
|
144
|
+
var proceedToMethodOrUpload = function () {
|
|
91
145
|
var isPictureAllowed = allowedAddingMethods.includes("picture");
|
|
92
146
|
var isDownloadAllowed = allowedAddingMethods.includes("download");
|
|
93
147
|
if (isPictureAllowed && isDownloadAllowed) {
|
|
@@ -98,6 +152,58 @@ var DocumentCollection = function (_a) {
|
|
|
98
152
|
handleMethodSelect(method);
|
|
99
153
|
}
|
|
100
154
|
};
|
|
155
|
+
// Le wallet a été décliné (WalletProposal) ou a échoué (WalletVerificationStep).
|
|
156
|
+
var handleWalletDeclineOrFail = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
157
|
+
var error_2;
|
|
158
|
+
return __generator(this, function (_a) {
|
|
159
|
+
switch (_a.label) {
|
|
160
|
+
case 0:
|
|
161
|
+
setWalletDeclined(true);
|
|
162
|
+
_a.label = 1;
|
|
163
|
+
case 1:
|
|
164
|
+
_a.trys.push([1, 3, , 4]);
|
|
165
|
+
return [4 /*yield*/, skipWalletWithReason(sessionId, {
|
|
166
|
+
nodeId: node.id,
|
|
167
|
+
reason: "wallet_declined_or_failed",
|
|
168
|
+
label: "Wallet non utilisé",
|
|
169
|
+
})];
|
|
170
|
+
case 2:
|
|
171
|
+
_a.sent();
|
|
172
|
+
return [3 /*break*/, 4];
|
|
173
|
+
case 3:
|
|
174
|
+
error_2 = _a.sent();
|
|
175
|
+
console.error("Failed to persist wallet skip reason:", error_2);
|
|
176
|
+
return [3 /*break*/, 4];
|
|
177
|
+
case 4:
|
|
178
|
+
if (normalizeWalletMode(node.walletMode) === "walletOnly") {
|
|
179
|
+
if (template) {
|
|
180
|
+
stepObject.goToNextStep(node.id, template);
|
|
181
|
+
}
|
|
182
|
+
else if (onContinueOnPC) {
|
|
183
|
+
onContinueOnPC();
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
stepObject.setStep(stepObject.step + 1);
|
|
187
|
+
}
|
|
188
|
+
return [2 /*return*/];
|
|
189
|
+
}
|
|
190
|
+
proceedToMethodOrUpload();
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); };
|
|
195
|
+
// Vérification par wallet aboutie : le document est confirmé, on saute la collecte photo.
|
|
196
|
+
var handleWalletVerificationCompleted = function () {
|
|
197
|
+
if (template) {
|
|
198
|
+
stepObject.goToNextStep(node.id, template);
|
|
199
|
+
}
|
|
200
|
+
else if (onContinueOnPC) {
|
|
201
|
+
onContinueOnPC();
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
stepObject.setStep(stepObject.step + 1);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
101
207
|
var handleMethodSelect = function (method) {
|
|
102
208
|
setSelectedMethod(method);
|
|
103
209
|
if (method === "picture") {
|
|
@@ -107,7 +213,7 @@ var DocumentCollection = function (_a) {
|
|
|
107
213
|
setCurrentStep(3); // Go to action (Upload screen or Photo flow)
|
|
108
214
|
};
|
|
109
215
|
var handlePhotoCapture = function (imageData, side) { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
|
-
var imageBlob, processedBlob, processedDataUrl_1,
|
|
216
|
+
var imageBlob, processedBlob, processedDataUrl_1, error_3;
|
|
111
217
|
return __generator(this, function (_a) {
|
|
112
218
|
switch (_a.label) {
|
|
113
219
|
case 0:
|
|
@@ -125,8 +231,8 @@ var DocumentCollection = function (_a) {
|
|
|
125
231
|
});
|
|
126
232
|
return [3 /*break*/, 4];
|
|
127
233
|
case 3:
|
|
128
|
-
|
|
129
|
-
console.error("[DocumentCollection] Failed to process photo for ".concat(side, ":"),
|
|
234
|
+
error_3 = _a.sent();
|
|
235
|
+
console.error("[DocumentCollection] Failed to process photo for ".concat(side, ":"), error_3);
|
|
130
236
|
setCapturedImages(function (prev) {
|
|
131
237
|
var _a;
|
|
132
238
|
return (__assign(__assign({}, prev), (_a = {}, _a[side] = imageData, _a)));
|
|
@@ -196,7 +302,7 @@ var DocumentCollection = function (_a) {
|
|
|
196
302
|
}
|
|
197
303
|
};
|
|
198
304
|
var handleCollectOnlyUpload = function (files) { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
-
var
|
|
305
|
+
var error_4;
|
|
200
306
|
return __generator(this, function (_a) {
|
|
201
307
|
switch (_a.label) {
|
|
202
308
|
case 0:
|
|
@@ -211,8 +317,8 @@ var DocumentCollection = function (_a) {
|
|
|
211
317
|
handleProcessingComplete(true, retryCount, null);
|
|
212
318
|
return [3 /*break*/, 3];
|
|
213
319
|
case 2:
|
|
214
|
-
|
|
215
|
-
console.error("[DocumentCollection] collectOnly upload failed:",
|
|
320
|
+
error_4 = _a.sent();
|
|
321
|
+
console.error("[DocumentCollection] collectOnly upload failed:", error_4);
|
|
216
322
|
handleProcessingComplete(false, retryCount, null);
|
|
217
323
|
return [3 /*break*/, 3];
|
|
218
324
|
case 3: return [2 /*return*/];
|
|
@@ -271,6 +377,10 @@ var DocumentCollection = function (_a) {
|
|
|
271
377
|
}
|
|
272
378
|
};
|
|
273
379
|
switch (currentStep) {
|
|
380
|
+
case -10:
|
|
381
|
+
return (jsx(WalletProposal, { walletMode: normalizeWalletMode(node.walletMode), onUseWallet: function () { return setCurrentStep(-11); }, onDecline: handleWalletDeclineOrFail }));
|
|
382
|
+
case -11:
|
|
383
|
+
return (jsx(WalletVerificationStep, { sessionId: sessionId, nodeId: node.id, credentialType: pendingWalletCredentialType !== null && pendingWalletCredentialType !== void 0 ? pendingWalletCredentialType : "driving_license", walletMode: normalizeWalletMode(node.walletMode), onCompleted: handleWalletVerificationCompleted, onFailedOrDeclined: handleWalletDeclineOrFail }));
|
|
274
384
|
case 0:
|
|
275
385
|
return (jsx(DocumentCollectionIntroduction, { onContinue: handleContinueFromIntroduction, onBack: handleBack, introductionPage: introductionPage }));
|
|
276
386
|
case 1:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentCollection.js","sources":["../../../../../src/components/document-collection/DocumentCollection.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\nimport {\n SessionTemplate,\n SessionTemplateNode,\n stepObject,\n} from \"../../types/session\";\nimport type { onUploadFiles } from \"../../types/uploadFiles\";\nimport type { Prediction } from \"../../utils/apiAnalysis\";\nimport DocumentCollectionIntroduction from \"./DocumentCollectionIntroduction\";\nimport DocumentCollectionSelection from \"./DocumentCollectionSelection\";\nimport DocumentCollectionUpload from \"./DocumentCollectionUpload\";\nimport DocumentCollectionMethodSelection from \"./DocumentCollectionMethodSelection\";\nimport { DocumentError, DocumentProcessing, DocumentSuccess } from \".\";\nimport JDIProcessing from \"../jdi/JDIProcessing\";\nimport JDISuccess from \"../jdi/JDISuccess\";\nimport JDIError from \"../jdi/JDIError\";\nimport BeforePhoto from \"../id-check/BeforePhoto\";\nimport BeforeVersoPhoto from \"../id-check/BeforeVersoPhoto\";\nimport Photo from \"../id-check/Photo\";\nimport PhotoPreview from \"../id-check/PhotoPreview\";\nimport PhotoConfirmation from \"../id-check/PhotoConfirmation\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ButtonDesktop from \"../ui/ButtonDesktop\";\nimport { updateSessionCurrentStep } from \"../../services/sessionService\";\nimport { analyzeFiles } from \"../../services/analysis\";\nimport {\n getNodeRetryCount,\n incrementNodeRetryCount,\n} from \"../../services/retryService\";\nimport { getSession } from \"../../context/SessionContext\";\nimport {\n resizeAfterCapture,\n dataUrlToBlob,\n blobToDataUrl,\n} from \"../../utils/imageProcessing\";\n\nexport type DocumentTypeSide = \"ONE_FILE\" | \"RECTO_VERSO\";\n\nexport interface NodeDocumentCollection {\n id: string;\n allowedDocumentTypes: Array<{\n name: string;\n id: string;\n collectOnly?: boolean;\n }>;\n allowedAddingMethods: Array<'download' | 'picture'>;\n introductionPage: {\n title: string;\n description: string;\n };\n documentSelection: {\n title: string;\n description: string;\n };\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n}\n\ninterface AllowedDocumentType {\n id: string;\n name: string;\n side?: DocumentTypeSide;\n collectOnly?: boolean;\n}\n\ninterface DocumentCollectionProps {\n stepObject: stepObject;\n sessionId: string;\n node: NodeDocumentCollection;\n onContinueOnPC?: () => void;\n allowedDocumentTypes: AllowedDocumentType[];\n allowedAddingMethods: string[];\n template?: SessionTemplate;\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n allowResubmission?: boolean;\n maxResubmissionAttempts?: number;\n}\n\n/**\n * DocumentCollection component manages the multi-step document collection flow.\n * It handles document type selection, document upload, processing, and error/success handling.\n *\n * @component\n * @param {Object} props - Component props.\n * @param {stepObject} props.stepObject - Object managing the current step in the parent flow, with setStep and step properties.\n * @param {string} props.sessionId - Unique identifier for the current session.\n * @param {NodeDocumentCollection} props.node - Node configuration containing allowed document types and page content.\n * @param {() => void} [props.onContinueOnPC] - Optional callback to continue the process on a PC.\n * @param {AllowedDocumentType[]} props.allowedDocumentTypes - List of document types accepted for collection.\n * @param {string[]} props.allowedAddingMethods - List of allowed methods for adding documents (download, picture, etc.).\n * @param {Object} [props.introductionPage] - Optional introduction page configuration with title and description.\n * @param {Object} [props.documentSelection] - Optional document selection page configuration with title and description.\n *\n * @returns {JSX.Element} Multi-step document collection UI, rendering different subcomponents based on the current step.\n *\n * @remarks\n * - Manages internal state for step navigation, document selection, file uploads, and error handling.\n * - Displays error messages and fallback UI for invalid navigation.\n * - Uses translation hooks for internationalization support.\n */\nconst DocumentCollection = ({\n stepObject,\n sessionId,\n node,\n template,\n onContinueOnPC,\n allowedDocumentTypes,\n allowedAddingMethods,\n introductionPage,\n documentSelection,\n allowResubmission,\n maxResubmissionAttempts,\n}: DocumentCollectionProps) => {\n const { t } = useI18n();\n const { session } = getSession();\n\n const [currentStep, setCurrentStep] = useState(introductionPage?.title ? 0 : 1);\n const [fileUploaded, setFileUploaded] = useState<onUploadFiles | null>(null);\n const [selectedDocumentType, setSelectedDocumentType] = useState<string>(\"\");\n const [analysisData, setAnalysisData] = useState<Prediction[] | null>(null);\n const [errorCode, setErrorCode] = useState<string | null>(null);\n const [selectedMethod, setSelectedMethod] = useState<\"download\" | \"picture\" | null>(null);\n const [photoSubStep, setPhotoSubStep] = useState<\"before-recto\" | \"recto\" | \"preview-recto\" | \"before-verso\" | \"verso\" | \"preview-verso\" | \"confirmation\">(\"before-recto\");\n const [capturedImages, setCapturedImages] = useState<Record<string, string>>({});\n\n // Initialize retry count from session data\n const [retryCount, setRetryCount] = useState(() => {\n return getNodeRetryCount(session, node.id);\n });\n\n // Update retry count when session loads/changes\n useEffect(() => {\n if (session) {\n const sessionRetryCount = getNodeRetryCount(session, node.id);\n setRetryCount(sessionRetryCount);\n }\n }, [session, node.id]);\n\n // Check retry limits on mount/reload - if retries exhausted, show error page\n useEffect(() => {\n // Special case: if allowResubmission is false and retryCount > 0, show error immediately\n if (allowResubmission === false && retryCount > 0) {\n setCurrentStep(6);\n return;\n }\n\n // Normal case: check against maxResubmissionAttempts\n if (retryCount > 0 && !isRetryAllowed()) {\n // User has exhausted retries, redirect to error page\n setCurrentStep(6);\n }\n }, [retryCount, allowResubmission]);\n\n const handleContinueFromIntroduction = () => {\n setCurrentStep(1);\n };\n\n const handleDocumentTypeSelect = (docType: string, files?: onUploadFiles) => {\n setSelectedDocumentType(docType);\n\n if (files) {\n handleDocumentUpload(files);\n return;\n }\n\n const isPictureAllowed = allowedAddingMethods.includes(\"picture\");\n const isDownloadAllowed = allowedAddingMethods.includes(\"download\");\n\n if (isPictureAllowed && isDownloadAllowed) {\n setCurrentStep(2); // Method selection\n } else {\n const method = isPictureAllowed ? \"picture\" : \"download\";\n handleMethodSelect(method);\n }\n };\n\n const handleMethodSelect = (method: \"download\" | \"picture\") => {\n setSelectedMethod(method);\n if (method === \"picture\") {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }\n setCurrentStep(3); // Go to action (Upload screen or Photo flow)\n };\n\n const handlePhotoCapture = async (imageData: string, side: \"recto\" | \"verso\") => {\n try {\n const imageBlob = dataUrlToBlob(imageData);\n const processedBlob = await resizeAfterCapture(imageBlob);\n const processedDataUrl = await blobToDataUrl(processedBlob);\n setCapturedImages((prev) => ({ ...prev, [side]: processedDataUrl }));\n } catch (error) {\n console.error(`[DocumentCollection] Failed to process photo for ${side}:`, error);\n setCapturedImages((prev) => ({ ...prev, [side]: imageData }));\n }\n setPhotoSubStep(side === \"recto\" ? \"preview-recto\" : \"preview-verso\");\n };\n\n const handlePhotoConfirmation = () => {\n if (capturedImages.recto) {\n const files: onUploadFiles = {\n front: capturedImages.recto,\n back: capturedImages.verso || null,\n };\n setFileUploaded(files);\n setCurrentStep(4);\n }\n };\n\n const handleDocumentUpload = (files: onUploadFiles) => {\n setFileUploaded(files);\n\n // Check if the selected document type is collectOnly — skip processing step\n const selectedDoc = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n if (selectedDoc?.collectOnly) {\n handleCollectOnlyUpload(files);\n return;\n }\n\n // Check if retry limit is reached before processing\n if (!isRetryAllowed() && retryCount > 0) {\n // Skip processing and go directly to error page\n setCurrentStep(6);\n } else {\n // Proceed to processing\n setCurrentStep(4);\n }\n };\n\n const handleProcessingComplete = (\n success: boolean,\n currentRetryCount?: number,\n apiAnalysisData?: Prediction[] | null\n ) => {\n if (apiAnalysisData) {\n setAnalysisData(apiAnalysisData);\n if (apiAnalysisData.length > 0) {\n setErrorCode(apiAnalysisData[0].code);\n }\n }\n\n if (success) {\n // Always follow the graph edges. Arithmetic fallback only when no template is available\n // (out of the normal TemplateNodeRenderer flow).\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n setCurrentStep(5);\n } else {\n setRetryCount((prev) => {\n const newCount = prev + 1;\n incrementNodeRetryCount(sessionId, node.id, prev).catch((error) => {\n console.error(\"Failed to update retry count in session:\", error);\n });\n return newCount;\n });\n setCurrentStep(6);\n }\n };\n\n const handleCollectOnlyUpload = async (files: onUploadFiles) => {\n try {\n await analyzeFiles(sessionId, node.id, files, selectedDocumentType, {\n documentTypeKey: selectedDocumentType,\n collectOnly: true,\n enablePolling: false,\n });\n handleProcessingComplete(true, retryCount, null);\n } catch (error) {\n console.error(\"[DocumentCollection] collectOnly upload failed:\", error);\n handleProcessingComplete(false, retryCount, null);\n }\n };\n\n const handleRetryFromError = () => {\n setCurrentStep(1);\n setSelectedMethod(null);\n setCapturedImages({});\n setFileUploaded(null);\n };\n\n // Check if retry is allowed based on configuration\n const isRetryAllowed = () => {\n if (allowResubmission === undefined) return true;\n if (!allowResubmission) return false;\n if (maxResubmissionAttempts !== undefined) {\n return retryCount <= maxResubmissionAttempts;\n }\n return true;\n };\n\n // Node progression must follow the graph edges. `onContinueOnPC` is reserved for the\n // QR / mobile→PC redirection and must NOT drive node progression (it navigates by raw step\n // arithmetic, which breaks when several nodes share the same `order`).\n const handleContinueAnyway = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleSuccessContinue = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleBack = () => {\n if (currentStep === 0) {\n // Inter-node back navigation goes through the history-aware goBack(), never raw arithmetic.\n stepObject.goBack();\n } else {\n setCurrentStep(currentStep - 1);\n }\n };\n\n switch (currentStep) {\n case 0:\n return (\n <DocumentCollectionIntroduction\n onContinue={handleContinueFromIntroduction}\n onBack={handleBack}\n introductionPage={introductionPage}\n />\n );\n case 1:\n return (\n <DocumentCollectionSelection\n onContinue={handleDocumentTypeSelect}\n onBack={handleBack}\n allowedDocumentTypes={allowedDocumentTypes}\n allowedAddingMethods={allowedAddingMethods}\n stepObject={stepObject}\n documentSelection={documentSelection}\n />\n );\n case 2:\n return (\n <DocumentCollectionMethodSelection\n onMethodSelect={handleMethodSelect}\n onBack={handleBack}\n title={documentSelection?.title}\n description={documentSelection?.description}\n />\n );\n case 3:\n if (selectedMethod === \"download\") {\n return (\n <DocumentCollectionUpload\n selectedDocumentType={selectedDocumentType}\n allowedDocumentTypes={allowedDocumentTypes}\n onUpload={handleDocumentUpload}\n onBack={handleBack}\n documentSelection={documentSelection}\n sessionId={sessionId}\n />\n );\n } else {\n // Photo flow\n const requiresTwoSides = allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.side === \"RECTO_VERSO\";\n\n switch (photoSubStep) {\n case \"before-recto\":\n return <BeforePhoto setStep={() => setPhotoSubStep(\"recto\")} isSingleSided={!requiresTwoSides} onBack={handleBack} />;\n case \"recto\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"recto\")} automaticCapture={false} maskType=\"document\" />;\n case \"preview-recto\":\n return (\n <PhotoPreview\n imageUrl={capturedImages.recto}\n side=\"recto\"\n isSingleSided={!requiresTwoSides}\n onValidate={() => setPhotoSubStep(requiresTwoSides ? \"before-verso\" : \"confirmation\")}\n onRetake={() => {\n setCapturedImages((prev) => { const next = { ...prev }; delete next.recto; return next; });\n setPhotoSubStep(\"recto\");\n }}\n />\n );\n case \"before-verso\":\n return <BeforeVersoPhoto setStep={() => setPhotoSubStep(\"verso\")} />;\n case \"verso\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"verso\")} automaticCapture={false} maskType=\"document\" />;\n case \"preview-verso\":\n return (\n <PhotoPreview\n imageUrl={capturedImages.verso}\n side=\"verso\"\n onValidate={() => setPhotoSubStep(\"confirmation\")}\n onRetake={() => {\n setCapturedImages((prev) => { const next = { ...prev }; delete next.verso; return next; });\n setPhotoSubStep(\"verso\");\n }}\n />\n );\n case \"confirmation\":\n return (\n <PhotoConfirmation\n imageUrl={capturedImages.recto}\n versoImageUrl={capturedImages.verso}\n requiresTwoSides={requiresTwoSides}\n onConfirm={handlePhotoConfirmation}\n onRetry={() => {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n onRetryAfterProcessing={() => {\n setCurrentStep(1);\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n fileUploaded={fileUploaded}\n isSingleSided={!requiresTwoSides}\n />\n );\n }\n }\n return null;\n\n case 4:\n return (\n <DocumentProcessing\n documentType={selectedDocumentType}\n onProcessingComplete={handleProcessingComplete}\n fileUploaded={fileUploaded}\n documentTypeId={selectedDocumentType}\n retryCount={retryCount}\n nodeId={node.id}\n />\n );\n case 5:\n return (\n <DocumentSuccess\n documentType={selectedDocumentType}\n documentTypeLabel={t(allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.name || \"\")}\n onContinue={handleSuccessContinue}\n errorCode={errorCode || undefined}\n successDetails={{\n nextSteps: {\n title: t(\"success.next_steps\", \"Prochaines étapes\"),\n description: t(\n \"success.next_steps_description\",\n \"Vous pouvez maintenant continuer le processus de vérification en suivant les instructions à l'écran.\"\n ),\n },\n }}\n />\n );\n case 6:\n return (\n <DocumentError\n documentType={selectedDocumentType}\n onRetry={handleRetryFromError}\n onContinueAnyway={handleContinueAnyway}\n retryCount={retryCount}\n predictions={analysisData || undefined}\n errorCode={errorCode || undefined}\n allowResubmission={allowResubmission}\n maxResubmissionAttempts={maxResubmissionAttempts}\n isRetryAllowed={isRetryAllowed()}\n />\n );\n\n default:\n console.error(`Invalid document collection step: ${currentStep} `);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"document_collection.navigation_error.title\", \"Erreur de navigation\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"document_collection.navigation_error.description\", \"Étape non valide. Veuillez recommencer.\")}\n </p>\n <ButtonDesktop\n type=\"back\"\n className=\"w-full\"\n onClick={() => setCurrentStep(0)}\n >\n {t(\"document_collection.navigation_error.back\", \"Retour au début\")}\n </ButtonDesktop>\n </div>\n );\n }\n};\n\nexport default DocumentCollection;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqFA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACH,IAAM,kBAAkB,GAAG,UAAC,EAYF,EAAA;;AAXxB,IAAA,IAAA,UAAU,GAAA,EAAA,CAAA,UAAA,EACV,SAAS,GAAA,EAAA,CAAA,SAAA,EACT,IAAI,GAAA,EAAA,CAAA,IAAA,EACJ,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,cAAc,oBAAA,EACd,oBAAoB,GAAA,EAAA,CAAA,oBAAA,EACpB,o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E,SAAS,IAAI,SAAS,EACjC,iBAAiB,EAAE,iBAAiB,EACpC,uBAAuB,EAAE,uBAAuB,EAChD,cAAc,EAAE,cAAc,EAAE,EAAA,CAChC;AAGN,QAAA;AACE,YAAA,OAAO,CAAC,KAAK,CAAC,4CAAqC,WAAW,EAAA,GAAA,CAAG,CAAC;AAClE,YAAA,QACEC,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kEAAkE,EAAA,QAAA,EAAA,CAC/ED,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,cAAA,EAAA,CAAS,EACpDA,GAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,qCAAqC,EAAA,QAAA,EAChD,CAAC,CAAC,4CAA4C,EAAE,sBAAsB,CAAC,EAAA,CACrE,EACLA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC9B,CAAC,CAAC,kDAAkD,EAAE,yCAAyC,CAAC,EAAA,CAC/F,EACJA,GAAA,CAAC,aAAa,IACZ,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,YAAA,EAAM,OAAA,cAAc,CAAC,CAAC,CAAC,CAAA,CAAjB,CAAiB,EAAA,QAAA,EAE/B,CAAC,CAAC,2CAA2C,EAAE,iBAAiB,CAAC,EAAA,CACpD,CAAA,EAAA,CACZ;;AAGd;;;;"}
|
|
1
|
+
{"version":3,"file":"DocumentCollection.js","sources":["../../../../../src/components/document-collection/DocumentCollection.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\nimport {\n SessionTemplate,\n SessionTemplateNode,\n stepObject,\n} from \"../../types/session\";\nimport type { onUploadFiles } from \"../../types/uploadFiles\";\nimport type { Prediction } from \"../../utils/apiAnalysis\";\nimport DocumentCollectionIntroduction from \"./DocumentCollectionIntroduction\";\nimport DocumentCollectionSelection from \"./DocumentCollectionSelection\";\nimport DocumentCollectionUpload from \"./DocumentCollectionUpload\";\nimport DocumentCollectionMethodSelection from \"./DocumentCollectionMethodSelection\";\nimport { DocumentError, DocumentProcessing, DocumentSuccess } from \".\";\nimport JDIProcessing from \"../jdi/JDIProcessing\";\nimport JDISuccess from \"../jdi/JDISuccess\";\nimport JDIError from \"../jdi/JDIError\";\nimport BeforePhoto from \"../id-check/BeforePhoto\";\nimport BeforeVersoPhoto from \"../id-check/BeforeVersoPhoto\";\nimport Photo from \"../id-check/Photo\";\nimport PhotoPreview from \"../id-check/PhotoPreview\";\nimport PhotoConfirmation from \"../id-check/PhotoConfirmation\";\nimport { useI18n } from \"../../hooks/useI18n\";\nimport ButtonDesktop from \"../ui/ButtonDesktop\";\nimport { updateSessionCurrentStep } from \"../../services/sessionService\";\nimport { analyzeFiles } from \"../../services/analysis\";\nimport {\n getNodeRetryCount,\n incrementNodeRetryCount,\n} from \"../../services/retryService\";\nimport { getSession } from \"../../context/SessionContext\";\nimport {\n resizeAfterCapture,\n dataUrlToBlob,\n blobToDataUrl,\n} from \"../../utils/imageProcessing\";\nimport { fetchWallets, skipWalletWithReason } from \"../../services/sessionService\";\nimport WalletProposal from \"../wallet/WalletProposal\";\nimport WalletVerificationStep from \"../wallet/WalletVerificationStep\";\n\nexport type DocumentTypeSide = \"ONE_FILE\" | \"RECTO_VERSO\";\n\nexport interface NodeDocumentCollection {\n id: string;\n allowedDocumentTypes: Array<{\n name: string;\n id: string;\n collectOnly?: boolean;\n }>;\n allowedAddingMethods: Array<'download' | 'picture'>;\n introductionPage: {\n title: string;\n description: string;\n };\n documentSelection: {\n title: string;\n description: string;\n };\n allowResubmission: boolean;\n maxResubmissionAttempts?: number;\n walletEnabled?: boolean;\n walletMode?: \"walletOnly\" | \"walletOrPhoto\";\n}\n\nconst normalizeWalletMode = (mode?: string): \"walletOnly\" | \"walletOrPhoto\" =>\n mode === \"walletOnly\" ? \"walletOnly\" : \"walletOrPhoto\";\n\n/**\n * Heuristic mapping from a document-collection template's id/name to the\n * wallet credential it corresponds to. `allowedDocumentTypes` are arbitrary,\n * backend-template-driven strings (no fixed enum), so this is name-based —\n * cf. docs/WALLET_OID4VP_IMPLEMENTATION_PLAN.md §7 (\"option wallet quand le\n * type collecté ∈ {permis, carte grise}\").\n */\nconst resolveWalletCredentialType = (\n docTypeIdOrName: string,\n): \"driving_license\" | \"vehicle_registration\" | null => {\n const normalized = docTypeIdOrName.toLowerCase();\n if (/(licence|license|permis|driving)/.test(normalized)) return \"driving_license\";\n if (/(grise|registration|immatriculation|vehicle)/.test(normalized)) return \"vehicle_registration\";\n return null;\n};\n\ninterface AllowedDocumentType {\n id: string;\n name: string;\n side?: DocumentTypeSide;\n collectOnly?: boolean;\n}\n\ninterface DocumentCollectionProps {\n stepObject: stepObject;\n sessionId: string;\n node: NodeDocumentCollection;\n onContinueOnPC?: () => void;\n allowedDocumentTypes: AllowedDocumentType[];\n allowedAddingMethods: string[];\n template?: SessionTemplate;\n introductionPage?: {\n title?: string;\n description?: string;\n };\n documentSelection?: {\n title?: string;\n description?: string;\n };\n allowResubmission?: boolean;\n maxResubmissionAttempts?: number;\n /** Pays de l'utilisateur, connu si un nœud identity-control précède ce nœud dans le parcours. */\n countryCode?: string;\n}\n\n/**\n * DocumentCollection component manages the multi-step document collection flow.\n * It handles document type selection, document upload, processing, and error/success handling.\n *\n * @component\n * @param {Object} props - Component props.\n * @param {stepObject} props.stepObject - Object managing the current step in the parent flow, with setStep and step properties.\n * @param {string} props.sessionId - Unique identifier for the current session.\n * @param {NodeDocumentCollection} props.node - Node configuration containing allowed document types and page content.\n * @param {() => void} [props.onContinueOnPC] - Optional callback to continue the process on a PC.\n * @param {AllowedDocumentType[]} props.allowedDocumentTypes - List of document types accepted for collection.\n * @param {string[]} props.allowedAddingMethods - List of allowed methods for adding documents (download, picture, etc.).\n * @param {Object} [props.introductionPage] - Optional introduction page configuration with title and description.\n * @param {Object} [props.documentSelection] - Optional document selection page configuration with title and description.\n *\n * @returns {JSX.Element} Multi-step document collection UI, rendering different subcomponents based on the current step.\n *\n * @remarks\n * - Manages internal state for step navigation, document selection, file uploads, and error handling.\n * - Displays error messages and fallback UI for invalid navigation.\n * - Uses translation hooks for internationalization support.\n */\nconst DocumentCollection = ({\n stepObject,\n sessionId,\n node,\n template,\n onContinueOnPC,\n allowedDocumentTypes,\n allowedAddingMethods,\n introductionPage,\n documentSelection,\n allowResubmission,\n maxResubmissionAttempts,\n countryCode,\n}: DocumentCollectionProps) => {\n const { t } = useI18n();\n const { session } = getSession();\n\n const [currentStep, setCurrentStep] = useState(introductionPage?.title ? 0 : 1);\n const [walletDeclined, setWalletDeclined] = useState(false);\n const [pendingWalletCredentialType, setPendingWalletCredentialType] = useState<\n \"driving_license\" | \"vehicle_registration\" | null\n >(null);\n const [fileUploaded, setFileUploaded] = useState<onUploadFiles | null>(null);\n const [selectedDocumentType, setSelectedDocumentType] = useState<string>(\"\");\n const [analysisData, setAnalysisData] = useState<Prediction[] | null>(null);\n const [errorCode, setErrorCode] = useState<string | null>(null);\n const [selectedMethod, setSelectedMethod] = useState<\"download\" | \"picture\" | null>(null);\n const [photoSubStep, setPhotoSubStep] = useState<\"before-recto\" | \"recto\" | \"preview-recto\" | \"before-verso\" | \"verso\" | \"preview-verso\" | \"confirmation\">(\"before-recto\");\n const [capturedImages, setCapturedImages] = useState<Record<string, string>>({});\n\n // Initialize retry count from session data\n const [retryCount, setRetryCount] = useState(() => {\n return getNodeRetryCount(session, node.id);\n });\n\n // Update retry count when session loads/changes\n useEffect(() => {\n if (session) {\n const sessionRetryCount = getNodeRetryCount(session, node.id);\n setRetryCount(sessionRetryCount);\n }\n }, [session, node.id]);\n\n // Check retry limits on mount/reload - if retries exhausted, show error page\n useEffect(() => {\n // Special case: if allowResubmission is false and retryCount > 0, show error immediately\n if (allowResubmission === false && retryCount > 0) {\n setCurrentStep(6);\n return;\n }\n\n // Normal case: check against maxResubmissionAttempts\n if (retryCount > 0 && !isRetryAllowed()) {\n // User has exhausted retries, redirect to error page\n setCurrentStep(6);\n }\n }, [retryCount, allowResubmission]);\n\n const handleContinueFromIntroduction = () => {\n setCurrentStep(1);\n };\n\n const handleDocumentTypeSelect = async (docType: string, files?: onUploadFiles) => {\n setSelectedDocumentType(docType);\n\n if (files) {\n handleDocumentUpload(files);\n return;\n }\n\n // Wallet gate first, NFC/photo as fallback (cf. WALLET_OID4VP_IMPLEMENTATION_PLAN.md §7) —\n // seulement si le type sélectionné a un équivalent wallet (permis, carte grise).\n if (node.walletEnabled === true && !walletDeclined && countryCode) {\n const selectedDoc = allowedDocumentTypes.find((d) => d.id === docType);\n const credentialType = resolveWalletCredentialType(selectedDoc?.name || docType);\n if (credentialType) {\n try {\n const wallets = await fetchWallets(countryCode, credentialType);\n if (wallets.length > 0) {\n setPendingWalletCredentialType(credentialType);\n setCurrentStep(-10);\n return;\n }\n } catch (error) {\n console.error(\"Failed to check wallet availability:\", error);\n }\n }\n }\n\n proceedToMethodOrUpload();\n };\n\n const proceedToMethodOrUpload = () => {\n const isPictureAllowed = allowedAddingMethods.includes(\"picture\");\n const isDownloadAllowed = allowedAddingMethods.includes(\"download\");\n\n if (isPictureAllowed && isDownloadAllowed) {\n setCurrentStep(2); // Method selection\n } else {\n const method = isPictureAllowed ? \"picture\" : \"download\";\n handleMethodSelect(method);\n }\n };\n\n // Le wallet a été décliné (WalletProposal) ou a échoué (WalletVerificationStep).\n const handleWalletDeclineOrFail = async () => {\n setWalletDeclined(true);\n try {\n await skipWalletWithReason(sessionId, {\n nodeId: node.id,\n reason: \"wallet_declined_or_failed\",\n label: \"Wallet non utilisé\",\n });\n } catch (error) {\n console.error(\"Failed to persist wallet skip reason:\", error);\n }\n\n if (normalizeWalletMode(node.walletMode) === \"walletOnly\") {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n return;\n }\n\n proceedToMethodOrUpload();\n };\n\n // Vérification par wallet aboutie : le document est confirmé, on saute la collecte photo.\n const handleWalletVerificationCompleted = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleMethodSelect = (method: \"download\" | \"picture\") => {\n setSelectedMethod(method);\n if (method === \"picture\") {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }\n setCurrentStep(3); // Go to action (Upload screen or Photo flow)\n };\n\n const handlePhotoCapture = async (imageData: string, side: \"recto\" | \"verso\") => {\n try {\n const imageBlob = dataUrlToBlob(imageData);\n const processedBlob = await resizeAfterCapture(imageBlob);\n const processedDataUrl = await blobToDataUrl(processedBlob);\n setCapturedImages((prev) => ({ ...prev, [side]: processedDataUrl }));\n } catch (error) {\n console.error(`[DocumentCollection] Failed to process photo for ${side}:`, error);\n setCapturedImages((prev) => ({ ...prev, [side]: imageData }));\n }\n setPhotoSubStep(side === \"recto\" ? \"preview-recto\" : \"preview-verso\");\n };\n\n const handlePhotoConfirmation = () => {\n if (capturedImages.recto) {\n const files: onUploadFiles = {\n front: capturedImages.recto,\n back: capturedImages.verso || null,\n };\n setFileUploaded(files);\n setCurrentStep(4);\n }\n };\n\n const handleDocumentUpload = (files: onUploadFiles) => {\n setFileUploaded(files);\n\n // Check if the selected document type is collectOnly — skip processing step\n const selectedDoc = allowedDocumentTypes.find((d) => d.id === selectedDocumentType);\n if (selectedDoc?.collectOnly) {\n handleCollectOnlyUpload(files);\n return;\n }\n\n // Check if retry limit is reached before processing\n if (!isRetryAllowed() && retryCount > 0) {\n // Skip processing and go directly to error page\n setCurrentStep(6);\n } else {\n // Proceed to processing\n setCurrentStep(4);\n }\n };\n\n const handleProcessingComplete = (\n success: boolean,\n currentRetryCount?: number,\n apiAnalysisData?: Prediction[] | null\n ) => {\n if (apiAnalysisData) {\n setAnalysisData(apiAnalysisData);\n if (apiAnalysisData.length > 0) {\n setErrorCode(apiAnalysisData[0].code);\n }\n }\n\n if (success) {\n // Always follow the graph edges. Arithmetic fallback only when no template is available\n // (out of the normal TemplateNodeRenderer flow).\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n setCurrentStep(5);\n } else {\n setRetryCount((prev) => {\n const newCount = prev + 1;\n incrementNodeRetryCount(sessionId, node.id, prev).catch((error) => {\n console.error(\"Failed to update retry count in session:\", error);\n });\n return newCount;\n });\n setCurrentStep(6);\n }\n };\n\n const handleCollectOnlyUpload = async (files: onUploadFiles) => {\n try {\n await analyzeFiles(sessionId, node.id, files, selectedDocumentType, {\n documentTypeKey: selectedDocumentType,\n collectOnly: true,\n enablePolling: false,\n });\n handleProcessingComplete(true, retryCount, null);\n } catch (error) {\n console.error(\"[DocumentCollection] collectOnly upload failed:\", error);\n handleProcessingComplete(false, retryCount, null);\n }\n };\n\n const handleRetryFromError = () => {\n setCurrentStep(1);\n setSelectedMethod(null);\n setCapturedImages({});\n setFileUploaded(null);\n };\n\n // Check if retry is allowed based on configuration\n const isRetryAllowed = () => {\n if (allowResubmission === undefined) return true;\n if (!allowResubmission) return false;\n if (maxResubmissionAttempts !== undefined) {\n return retryCount <= maxResubmissionAttempts;\n }\n return true;\n };\n\n // Node progression must follow the graph edges. `onContinueOnPC` is reserved for the\n // QR / mobile→PC redirection and must NOT drive node progression (it navigates by raw step\n // arithmetic, which breaks when several nodes share the same `order`).\n const handleContinueAnyway = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleSuccessContinue = () => {\n if (template) {\n stepObject.goToNextStep(node.id, template);\n } else if (onContinueOnPC) {\n onContinueOnPC();\n } else {\n stepObject.setStep(stepObject.step + 1);\n }\n };\n\n const handleBack = () => {\n if (currentStep === 0) {\n // Inter-node back navigation goes through the history-aware goBack(), never raw arithmetic.\n stepObject.goBack();\n } else {\n setCurrentStep(currentStep - 1);\n }\n };\n\n switch (currentStep) {\n case -10:\n return (\n <WalletProposal\n walletMode={normalizeWalletMode(node.walletMode)}\n onUseWallet={() => setCurrentStep(-11)}\n onDecline={handleWalletDeclineOrFail}\n />\n );\n case -11:\n return (\n <WalletVerificationStep\n sessionId={sessionId}\n nodeId={node.id}\n credentialType={pendingWalletCredentialType ?? \"driving_license\"}\n walletMode={normalizeWalletMode(node.walletMode)}\n onCompleted={handleWalletVerificationCompleted}\n onFailedOrDeclined={handleWalletDeclineOrFail}\n />\n );\n case 0:\n return (\n <DocumentCollectionIntroduction\n onContinue={handleContinueFromIntroduction}\n onBack={handleBack}\n introductionPage={introductionPage}\n />\n );\n case 1:\n return (\n <DocumentCollectionSelection\n onContinue={handleDocumentTypeSelect}\n onBack={handleBack}\n allowedDocumentTypes={allowedDocumentTypes}\n allowedAddingMethods={allowedAddingMethods}\n stepObject={stepObject}\n documentSelection={documentSelection}\n />\n );\n case 2:\n return (\n <DocumentCollectionMethodSelection\n onMethodSelect={handleMethodSelect}\n onBack={handleBack}\n title={documentSelection?.title}\n description={documentSelection?.description}\n />\n );\n case 3:\n if (selectedMethod === \"download\") {\n return (\n <DocumentCollectionUpload\n selectedDocumentType={selectedDocumentType}\n allowedDocumentTypes={allowedDocumentTypes}\n onUpload={handleDocumentUpload}\n onBack={handleBack}\n documentSelection={documentSelection}\n sessionId={sessionId}\n />\n );\n } else {\n // Photo flow\n const requiresTwoSides = allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.side === \"RECTO_VERSO\";\n\n switch (photoSubStep) {\n case \"before-recto\":\n return <BeforePhoto setStep={() => setPhotoSubStep(\"recto\")} isSingleSided={!requiresTwoSides} onBack={handleBack} />;\n case \"recto\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"recto\")} automaticCapture={false} maskType=\"document\" />;\n case \"preview-recto\":\n return (\n <PhotoPreview\n imageUrl={capturedImages.recto}\n side=\"recto\"\n isSingleSided={!requiresTwoSides}\n onValidate={() => setPhotoSubStep(requiresTwoSides ? \"before-verso\" : \"confirmation\")}\n onRetake={() => {\n setCapturedImages((prev) => { const next = { ...prev }; delete next.recto; return next; });\n setPhotoSubStep(\"recto\");\n }}\n />\n );\n case \"before-verso\":\n return <BeforeVersoPhoto setStep={() => setPhotoSubStep(\"verso\")} />;\n case \"verso\":\n return <Photo onCapture={(img) => handlePhotoCapture(img, \"verso\")} automaticCapture={false} maskType=\"document\" />;\n case \"preview-verso\":\n return (\n <PhotoPreview\n imageUrl={capturedImages.verso}\n side=\"verso\"\n onValidate={() => setPhotoSubStep(\"confirmation\")}\n onRetake={() => {\n setCapturedImages((prev) => { const next = { ...prev }; delete next.verso; return next; });\n setPhotoSubStep(\"verso\");\n }}\n />\n );\n case \"confirmation\":\n return (\n <PhotoConfirmation\n imageUrl={capturedImages.recto}\n versoImageUrl={capturedImages.verso}\n requiresTwoSides={requiresTwoSides}\n onConfirm={handlePhotoConfirmation}\n onRetry={() => {\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n onRetryAfterProcessing={() => {\n setCurrentStep(1);\n setPhotoSubStep(\"before-recto\");\n setCapturedImages({});\n }}\n fileUploaded={fileUploaded}\n isSingleSided={!requiresTwoSides}\n />\n );\n }\n }\n return null;\n\n case 4:\n return (\n <DocumentProcessing\n documentType={selectedDocumentType}\n onProcessingComplete={handleProcessingComplete}\n fileUploaded={fileUploaded}\n documentTypeId={selectedDocumentType}\n retryCount={retryCount}\n nodeId={node.id}\n />\n );\n case 5:\n return (\n <DocumentSuccess\n documentType={selectedDocumentType}\n documentTypeLabel={t(allowedDocumentTypes.find((dt) => dt.id === selectedDocumentType)?.name || \"\")}\n onContinue={handleSuccessContinue}\n errorCode={errorCode || undefined}\n successDetails={{\n nextSteps: {\n title: t(\"success.next_steps\", \"Prochaines étapes\"),\n description: t(\n \"success.next_steps_description\",\n \"Vous pouvez maintenant continuer le processus de vérification en suivant les instructions à l'écran.\"\n ),\n },\n }}\n />\n );\n case 6:\n return (\n <DocumentError\n documentType={selectedDocumentType}\n onRetry={handleRetryFromError}\n onContinueAnyway={handleContinueAnyway}\n retryCount={retryCount}\n predictions={analysisData || undefined}\n errorCode={errorCode || undefined}\n allowResubmission={allowResubmission}\n maxResubmissionAttempts={maxResubmissionAttempts}\n isRetryAllowed={isRetryAllowed()}\n />\n );\n\n default:\n console.error(`Invalid document collection step: ${currentStep} `);\n return (\n <div className=\"flex flex-col items-center justify-center h-full p-4 text-center\">\n <div className=\"text-red-500 text-4xl mb-4\">⚠️</div>\n <h2 className=\"text-xl font-bold text-red-600 mb-2\">\n {t(\"document_collection.navigation_error.title\", \"Erreur de navigation\")}\n </h2>\n <p className=\"text-gray-600 mb-4\">\n {t(\"document_collection.navigation_error.description\", \"Étape non valide. Veuillez recommencer.\")}\n </p>\n <ButtonDesktop\n type=\"back\"\n className=\"w-full\"\n onClick={() => setCurrentStep(0)}\n >\n {t(\"document_collection.navigation_error.back\", \"Retour au début\")}\n </ButtonDesktop>\n </div>\n );\n }\n};\n\nexport default DocumentCollection;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,IAAM,mBAAmB,GAAG,UAAC,IAAa,EAAA;IACxC,OAAA,IAAI,KAAK,YAAY,GAAG,YAAY,GAAG,eAAe;AAAtD,CAAsD;AAExD;;;;;;AAMG;AACH,IAAM,2BAA2B,GAAG,UAClC,eAAuB,EAAA;AAEvB,IAAA,IAAM,UAAU,GAAG,eAAe,CAAC,WAAW,EAAE;AAChD,IAAA,IAAI,kCAAkC,CAAC,IAAI,CAAC,UAAU,CAAC;AAAE,QAAA,OAAO,iBAAiB;AACjF,IAAA,IAAI,8CAA8C,CAAC,IAAI,CAAC,UAAU,CAAC;AAAE,QAAA,OAAO,sBAAsB;AAClG,IAAA,OAAO,IAAI;AACb,CAAC;AA+BD;;;;;;;;;;;;;;;;;;;;;AAqBG;AACH,IAAM,kBAAkB,GAAG,UAAC,EAaF,EAAA;;AAZxB,IAAA,IAAA,UAAU,GAA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A,QAAA,EAChD,CAAC,CAAC,4CAA4C,EAAE,sBAAsB,CAAC,EAAA,CACrE,EACLA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC9B,CAAC,CAAC,kDAAkD,EAAE,yCAAyC,CAAC,EAAA,CAC/F,EACJA,GAAA,CAAC,aAAa,IACZ,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,YAAA,EAAM,OAAA,cAAc,CAAC,CAAC,CAAC,CAAA,CAAjB,CAAiB,EAAA,QAAA,EAE/B,CAAC,CAAC,2CAA2C,EAAE,iBAAiB,CAAC,EAAA,CACpD,CAAA,EAAA,CACZ;;AAGd;;;;"}
|
|
@@ -26,10 +26,12 @@ import { getAllDocumentTemplates, getDocumentTemplateId, getDocTypeKey } from '.
|
|
|
26
26
|
import { blobToDataUrl, dataUrlToBlob, resizeAfterCapture } from '../../utils/imageProcessing.js';
|
|
27
27
|
import { getNodeRetryCount, incrementNodeRetryCount } from '../../services/retryService.js';
|
|
28
28
|
import { getSession } from '../../context/SessionContext.js';
|
|
29
|
-
import {
|
|
29
|
+
import { fetchWallets, skipNfcWithReason, skipWalletWithReason, updateSessionUserInput } from '../../services/sessionService.js';
|
|
30
30
|
import NfcScanStep from '../nfc-scan/NfcScanNode.js';
|
|
31
31
|
import NfcChipGate from '../nfc-scan/NfcChipGate.js';
|
|
32
32
|
import NfcFallbackSurvey from '../nfc-scan/NfcFallbackSurvey.js';
|
|
33
|
+
import WalletProposal from '../wallet/WalletProposal.js';
|
|
34
|
+
import WalletVerificationStep from '../wallet/WalletVerificationStep.js';
|
|
33
35
|
import { EUROPEAN_COUNTRY_CODES } from '../../utils/europeanCountries.js';
|
|
34
36
|
|
|
35
37
|
var NFC_ELIGIBLE_DOCUMENT_TYPES = new Set([
|
|
@@ -45,6 +47,9 @@ var NFC_ELIGIBLE_DOCUMENT_TYPES = new Set([
|
|
|
45
47
|
var normalizeNfcMode = function (mode) {
|
|
46
48
|
return mode === "nfcAndApi" || mode === "nfcOrPhoto" ? "nfcOrPhoto" : "nfcOnly";
|
|
47
49
|
};
|
|
50
|
+
var normalizeWalletMode = function (mode) {
|
|
51
|
+
return mode === "walletOnly" ? "walletOnly" : "walletOrPhoto";
|
|
52
|
+
};
|
|
48
53
|
/**
|
|
49
54
|
* DocumentCheck component manages the multi-step document verification flow for a session.
|
|
50
55
|
* It handles country and document type selection, document upload or photo capture, processing, and error/success handling.
|
|
@@ -127,10 +132,13 @@ var DocumentCheck = function (_a) {
|
|
|
127
132
|
// Quand l'utilisateur déclare ne pas avoir de puce (questionnaire de fallback),
|
|
128
133
|
// on ne doit plus le réorienter vers le scan NFC (ni avant, ni après l'analyse API).
|
|
129
134
|
var _z = useState(false), nfcSkipped = _z[0], setNfcSkipped = _z[1];
|
|
135
|
+
// Idem pour le wallet : une fois décliné/échoué, on ne re-propose plus le wallet
|
|
136
|
+
// sur ce nœud (mais le NFC, s'il est également activé, reste tenté ensuite).
|
|
137
|
+
var _0 = useState(false), walletDeclined = _0[0], setWalletDeclined = _0[1];
|
|
130
138
|
// Initialize retry count from session data
|
|
131
|
-
var
|
|
139
|
+
var _1 = useState(function () {
|
|
132
140
|
return getNodeRetryCount(session, node.id);
|
|
133
|
-
}), retryCount =
|
|
141
|
+
}), retryCount = _1[0], setRetryCount = _1[1];
|
|
134
142
|
// Update retry count when session loads/changes
|
|
135
143
|
useEffect(function () {
|
|
136
144
|
if (session) {
|
|
@@ -185,10 +193,10 @@ var DocumentCheck = function (_a) {
|
|
|
185
193
|
setDocStep(6);
|
|
186
194
|
}
|
|
187
195
|
}, [retryCount, node.allowResubmission, node.maxResubmissionAttempts]);
|
|
188
|
-
var
|
|
189
|
-
var
|
|
190
|
-
var
|
|
191
|
-
var
|
|
196
|
+
var _2 = useState({}), capturedImages = _2[0], setCapturedImages = _2[1];
|
|
197
|
+
var _3 = useState("before-recto"), currentPhotoStep = _3[0], setCurrentPhotoStep = _3[1];
|
|
198
|
+
var _4 = useState("photo"), videoFlowPhase = _4[0], setVideoFlowPhase = _4[1];
|
|
199
|
+
var _5 = useDocumentContext(), selectedDocumentType = _5.selectedDocumentType, setSelectedDocumentType = _5.setSelectedDocumentType;
|
|
192
200
|
var finalAcceptedCountries = useMemo(function () {
|
|
193
201
|
if (loadingTemplates)
|
|
194
202
|
return acceptedCountries;
|
|
@@ -376,10 +384,9 @@ var DocumentCheck = function (_a) {
|
|
|
376
384
|
handleProcessingComplete(success, undefined, analysisData);
|
|
377
385
|
};
|
|
378
386
|
var handleDocumentTypeSelect = function (documentId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
379
|
-
var documentLabel, documentTemplateID, selectedDoc, selectedCountryCode, selectedDocumentInput,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
switch (_b.label) {
|
|
387
|
+
var documentLabel, documentTemplateID, selectedDoc, selectedCountryCode, selectedDocumentInput, wallets, error_2;
|
|
388
|
+
return __generator(this, function (_a) {
|
|
389
|
+
switch (_a.label) {
|
|
383
390
|
case 0:
|
|
384
391
|
documentLabel = t("documentTypes.".concat(documentId), documentId);
|
|
385
392
|
logDocumentTypeSelected(sessionId, documentId, documentLabel);
|
|
@@ -412,6 +419,37 @@ var DocumentCheck = function (_a) {
|
|
|
412
419
|
setCapturedImages({});
|
|
413
420
|
setCurrentPhotoStep("before-recto");
|
|
414
421
|
setVideoFlowPhase("photo");
|
|
422
|
+
if (!(node.walletEnabled === true && !walletDeclined)) return [3 /*break*/, 4];
|
|
423
|
+
_a.label = 1;
|
|
424
|
+
case 1:
|
|
425
|
+
_a.trys.push([1, 3, , 4]);
|
|
426
|
+
return [4 /*yield*/, fetchWallets(selectedCountryCode, "pid")];
|
|
427
|
+
case 2:
|
|
428
|
+
wallets = _a.sent();
|
|
429
|
+
if (wallets.length > 0) {
|
|
430
|
+
setDocStep(-10);
|
|
431
|
+
return [2 /*return*/];
|
|
432
|
+
}
|
|
433
|
+
return [3 /*break*/, 4];
|
|
434
|
+
case 3:
|
|
435
|
+
error_2 = _a.sent();
|
|
436
|
+
console.error("Failed to check wallet availability:", error_2);
|
|
437
|
+
return [3 /*break*/, 4];
|
|
438
|
+
case 4: return [4 /*yield*/, proceedWithNfcOrPhoto(documentId, selectedDocumentInput)];
|
|
439
|
+
case 5:
|
|
440
|
+
_a.sent();
|
|
441
|
+
return [2 /*return*/];
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}); };
|
|
445
|
+
// Logique NFC-ou-photo existante, factorisée pour être rejouable après un
|
|
446
|
+
// refus/échec du wallet (le wallet est tenté avant, cf. handleDocumentTypeSelect).
|
|
447
|
+
var proceedWithNfcOrPhoto = function (documentId, selectedDocumentInput) { return __awaiter(void 0, void 0, void 0, function () {
|
|
448
|
+
var nfcMode, error_3;
|
|
449
|
+
var _a;
|
|
450
|
+
return __generator(this, function (_b) {
|
|
451
|
+
switch (_b.label) {
|
|
452
|
+
case 0:
|
|
415
453
|
if (!(node.nfcEnabled === true &&
|
|
416
454
|
!nfcSkipped &&
|
|
417
455
|
NFC_ELIGIBLE_DOCUMENT_TYPES.has(documentId))) return [3 /*break*/, 5];
|
|
@@ -424,8 +462,8 @@ var DocumentCheck = function (_a) {
|
|
|
424
462
|
_b.sent();
|
|
425
463
|
return [3 /*break*/, 4];
|
|
426
464
|
case 3:
|
|
427
|
-
|
|
428
|
-
console.error("Failed to persist NFC document selection:",
|
|
465
|
+
error_3 = _b.sent();
|
|
466
|
+
console.error("Failed to persist NFC document selection:", error_3);
|
|
429
467
|
setNfcPreparationError(t("nfc_scan.preparation_failed", "Impossible de préparer le scan NFC. Veuillez réessayer."));
|
|
430
468
|
return [3 /*break*/, 4];
|
|
431
469
|
case 4:
|
|
@@ -437,6 +475,61 @@ var DocumentCheck = function (_a) {
|
|
|
437
475
|
}
|
|
438
476
|
});
|
|
439
477
|
}); };
|
|
478
|
+
// Le wallet a été décliné (WalletProposal) ou a échoué (WalletVerificationStep).
|
|
479
|
+
// walletOnly : pas d'alternative photo/NFC → on saute le nœud, comme le NFC en mode nfcOnly.
|
|
480
|
+
// walletOrPhoto : on rejoue la logique NFC-ou-photo normale.
|
|
481
|
+
var handleWalletDeclineOrFail = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
482
|
+
var error_4, selectedDocumentInput;
|
|
483
|
+
return __generator(this, function (_a) {
|
|
484
|
+
switch (_a.label) {
|
|
485
|
+
case 0:
|
|
486
|
+
setWalletDeclined(true);
|
|
487
|
+
_a.label = 1;
|
|
488
|
+
case 1:
|
|
489
|
+
_a.trys.push([1, 3, , 4]);
|
|
490
|
+
return [4 /*yield*/, skipWalletWithReason(sessionId, {
|
|
491
|
+
nodeId: node.id,
|
|
492
|
+
reason: "wallet_declined_or_failed",
|
|
493
|
+
label: "Wallet non utilisé",
|
|
494
|
+
})];
|
|
495
|
+
case 2:
|
|
496
|
+
_a.sent();
|
|
497
|
+
return [3 /*break*/, 4];
|
|
498
|
+
case 3:
|
|
499
|
+
error_4 = _a.sent();
|
|
500
|
+
console.error("Failed to persist wallet skip reason:", error_4);
|
|
501
|
+
return [3 /*break*/, 4];
|
|
502
|
+
case 4:
|
|
503
|
+
if (normalizeWalletMode(node.walletMode) === "walletOnly") {
|
|
504
|
+
if (template) {
|
|
505
|
+
stepObject.goToNextStep(node.id, template);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
stepObject.setStep(stepObject.step + 1);
|
|
509
|
+
}
|
|
510
|
+
return [2 /*return*/];
|
|
511
|
+
}
|
|
512
|
+
selectedDocumentInput = {
|
|
513
|
+
countryCode: selectedCountry.toUpperCase(),
|
|
514
|
+
identityDocumentType: selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id,
|
|
515
|
+
identityDocumentTemplateId: selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.documentTemplateId,
|
|
516
|
+
};
|
|
517
|
+
return [4 /*yield*/, proceedWithNfcOrPhoto((selectedDocumentType === null || selectedDocumentType === void 0 ? void 0 : selectedDocumentType.id) || "", selectedDocumentInput)];
|
|
518
|
+
case 5:
|
|
519
|
+
_a.sent();
|
|
520
|
+
return [2 /*return*/];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}); };
|
|
524
|
+
// Vérification par wallet aboutie : l'identité est confirmée, on saute la capture photo.
|
|
525
|
+
var handleWalletVerificationCompleted = function () {
|
|
526
|
+
if (template) {
|
|
527
|
+
stepObject.goToNextStep(node.id, template);
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
stepObject.setStep(stepObject.step + 1);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
440
533
|
var handleDocumentUpload = function (files) {
|
|
441
534
|
logDocumentLoaded(sessionId, "recto");
|
|
442
535
|
if (files.back) {
|
|
@@ -560,7 +653,7 @@ var DocumentCheck = function (_a) {
|
|
|
560
653
|
// - nfcOrPhoto → flux photo/API du même nœud (intro/pays → upload → analyse), sans scan NFC
|
|
561
654
|
// - nfcOnly → on saute le nœud (nœud suivant)
|
|
562
655
|
var handleNfcFallback = function (reason, label, comment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
563
|
-
var
|
|
656
|
+
var error_5, nfcMode, hasIntroduction;
|
|
564
657
|
var _a, _b;
|
|
565
658
|
return __generator(this, function (_c) {
|
|
566
659
|
switch (_c.label) {
|
|
@@ -574,8 +667,8 @@ var DocumentCheck = function (_a) {
|
|
|
574
667
|
_c.sent();
|
|
575
668
|
return [3 /*break*/, 4];
|
|
576
669
|
case 3:
|
|
577
|
-
|
|
578
|
-
console.error("Failed to persist NFC fallback reason:",
|
|
670
|
+
error_5 = _c.sent();
|
|
671
|
+
console.error("Failed to persist NFC fallback reason:", error_5);
|
|
579
672
|
return [3 /*break*/, 4];
|
|
580
673
|
case 4:
|
|
581
674
|
nfcMode = normalizeNfcMode(node.nfcMode);
|
|
@@ -618,6 +711,10 @@ var DocumentCheck = function (_a) {
|
|
|
618
711
|
}
|
|
619
712
|
};
|
|
620
713
|
switch (docStep) {
|
|
714
|
+
case -10:
|
|
715
|
+
return (jsx(WalletProposal, { walletMode: normalizeWalletMode(node.walletMode), onUseWallet: function () { return setDocStep(-11); }, onDecline: handleWalletDeclineOrFail }));
|
|
716
|
+
case -11:
|
|
717
|
+
return (jsx(WalletVerificationStep, { sessionId: sessionId, nodeId: node.id, credentialType: "pid", walletMode: normalizeWalletMode(node.walletMode), onCompleted: handleWalletVerificationCompleted, onFailedOrDeclined: handleWalletDeclineOrFail }));
|
|
621
718
|
case -1: {
|
|
622
719
|
var hasIntroduction_1 = ((_f = node.introductionPage) === null || _f === void 0 ? void 0 : _f.title) !== undefined ||
|
|
623
720
|
((_g = node.introductionPage) === null || _g === void 0 ? void 0 : _g.description) !== undefined;
|