@incodetech/core 0.0.0-dev-20260421-3ad52f4 → 0.0.0-dev-20260421-c950692
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/dist/ae-signature.d.ts +1 -1
- package/dist/consent.d.ts +50 -50
- package/dist/document-capture.d.ts +70 -70
- package/dist/document-upload.d.ts +46 -46
- package/dist/electronic-signature.d.ts +1 -1
- package/dist/extensibility.d.ts +1 -1
- package/dist/extensibility.esm.js +2 -2
- package/dist/home.d.ts +10 -10
- package/dist/id.d.ts +2 -2
- package/dist/id.esm.js +3 -3
- package/dist/{idCaptureManager-CfHYOEgl.esm.js → idCaptureManager-B-rA65qY.esm.js} +58 -1
- package/dist/{idCaptureManager-eoc0PvFh.d.ts → idCaptureManager-DaqJk3sg.d.ts} +108 -3
- package/dist/{idCaptureStateMachine-BFSvu5or.esm.js → idCaptureStateMachine-BBf5lODM.esm.js} +425 -15
- package/dist/identity-reuse.d.ts +47 -47
- package/dist/{index-D98KKBR4.d.ts → index-Crq0BK0w.d.ts} +119 -119
- package/dist/mandatory-consent.d.ts +50 -50
- package/dist/qe-signature.d.ts +1 -1
- package/dist/workflow.d.ts +82 -82
- package/dist/workflow.esm.js +1 -1
- package/package.json +1 -1
package/dist/{idCaptureStateMachine-BFSvu5or.esm.js → idCaptureStateMachine-BBf5lODM.esm.js}
RENAMED
|
@@ -215,6 +215,9 @@ const ID_ERROR_CODES = {
|
|
|
215
215
|
USER_CANCELLED: "USER_CANCELLED",
|
|
216
216
|
SERVER: "SERVER_ERROR"
|
|
217
217
|
};
|
|
218
|
+
const MANUAL_UPLOAD_MAX_RETRIES = 3;
|
|
219
|
+
const MANUAL_UPLOAD_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
|
220
|
+
const MANUAL_UPLOAD_EXHAUSTION_FORWARD_MS = 5e3;
|
|
218
221
|
|
|
219
222
|
//#endregion
|
|
220
223
|
//#region src/modules/id/idCaptureServices.ts
|
|
@@ -471,6 +474,31 @@ async function processId(isSecondId = false, queueName = "", signal) {
|
|
|
471
474
|
const url = queueName ? `${endpoint}?queueName=${queueName}` : endpoint;
|
|
472
475
|
return { isDocumentExpired: (await api.post(url, {}, { signal })).data?.isDocumentExpired ?? false };
|
|
473
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Upload a user-selected image as front / back / passport ID.
|
|
479
|
+
*
|
|
480
|
+
* Uses the same request shape as the live-camera path (`uploadIdImage`):
|
|
481
|
+
* JSON body `{ base64Image }` with default application/json Content-Type,
|
|
482
|
+
* `captureType=UPLOAD` query param, `retry=true` when retrying.
|
|
483
|
+
* Back is POSTed to `/omni/add/back-id/v2`; front and passport both go to
|
|
484
|
+
* `/omni/add/front-id/v2` — the server distinguishes by session state.
|
|
485
|
+
*
|
|
486
|
+
* The v2 endpoints reject raw `image/jpeg` bodies with 415, so the caller
|
|
487
|
+
* must convert the File to base64 before calling this service.
|
|
488
|
+
*/
|
|
489
|
+
async function uploadManualIdFile(params) {
|
|
490
|
+
const { side, base64Image, retry, onlyFront, signal } = params;
|
|
491
|
+
const endpoint = side === "back" ? endpoints.backId : endpoints.frontId;
|
|
492
|
+
const queryParams = { captureType: "UPLOAD" };
|
|
493
|
+
if (retry) queryParams.retry = true;
|
|
494
|
+
if (onlyFront && side === "front") queryParams.onlyFront = true;
|
|
495
|
+
const res = await api.post(endpoint, { base64Image }, {
|
|
496
|
+
signal,
|
|
497
|
+
query: queryParams
|
|
498
|
+
});
|
|
499
|
+
if (!res.ok) throw new Error(`POST ${endpoint} failed: ${res.status} ${res.statusText}`);
|
|
500
|
+
return res.data;
|
|
501
|
+
}
|
|
474
502
|
|
|
475
503
|
//#endregion
|
|
476
504
|
//#region ../infra/src/wasm/idCaptureDefaults.ts
|
|
@@ -522,7 +550,16 @@ const runDetectionActor = fromCallback(({ input, sendBack }) => {
|
|
|
522
550
|
const timer = BrowserTimerProvider.getInstance();
|
|
523
551
|
let notificationTimeout = null;
|
|
524
552
|
let currentNotificationStatus = null;
|
|
553
|
+
let lastReportedSide = null;
|
|
525
554
|
const NOTIFICATION_DURATION_MS = 500;
|
|
555
|
+
const isReportedSideWrong = () => {
|
|
556
|
+
if (!lastReportedSide) return false;
|
|
557
|
+
const detectedSide = lastReportedSide.toLowerCase();
|
|
558
|
+
if (detectedSide === "wrong") return true;
|
|
559
|
+
const isBackDetected = detectedSide.includes("back") && !detectedSide.includes("front");
|
|
560
|
+
const isFrontDetected = detectedSide.includes("front") && !detectedSide.includes("back");
|
|
561
|
+
return input.currentMode === "front" && isBackDetected || input.currentMode === "back" && isFrontDetected;
|
|
562
|
+
};
|
|
526
563
|
const clearNotificationTimeout = () => {
|
|
527
564
|
if (notificationTimeout) {
|
|
528
565
|
timer.clearTimeout(notificationTimeout);
|
|
@@ -531,6 +568,7 @@ const runDetectionActor = fromCallback(({ input, sendBack }) => {
|
|
|
531
568
|
}
|
|
532
569
|
};
|
|
533
570
|
const sendNotification = (status) => {
|
|
571
|
+
if (isReportedSideWrong()) return;
|
|
534
572
|
if (notificationTimeout && currentNotificationStatus !== status) return;
|
|
535
573
|
if (notificationTimeout && currentNotificationStatus === status) timer.clearTimeout(notificationTimeout);
|
|
536
574
|
currentNotificationStatus = status;
|
|
@@ -622,6 +660,7 @@ const runDetectionActor = fromCallback(({ input, sendBack }) => {
|
|
|
622
660
|
},
|
|
623
661
|
onCapturing: () => {
|
|
624
662
|
clearNotificationTimeout();
|
|
663
|
+
lastReportedSide = null;
|
|
625
664
|
isCapturing = true;
|
|
626
665
|
sendBack({
|
|
627
666
|
type: "DETECTION_UPDATE",
|
|
@@ -662,6 +701,8 @@ const runDetectionActor = fromCallback(({ input, sendBack }) => {
|
|
|
662
701
|
},
|
|
663
702
|
onIdSideChange: (side) => {
|
|
664
703
|
if (isCapturing) return;
|
|
704
|
+
lastReportedSide = side;
|
|
705
|
+
if (isReportedSideWrong()) clearNotificationTimeout();
|
|
665
706
|
sendBack({
|
|
666
707
|
type: "ID_SIDE_CHANGE",
|
|
667
708
|
side
|
|
@@ -699,6 +740,7 @@ const runDetectionActor = fromCallback(({ input, sendBack }) => {
|
|
|
699
740
|
bestCanvas = null;
|
|
700
741
|
storedQualityElements = {};
|
|
701
742
|
isCapturing = false;
|
|
743
|
+
lastReportedSide = null;
|
|
702
744
|
provider.reset();
|
|
703
745
|
}
|
|
704
746
|
},
|
|
@@ -812,6 +854,87 @@ const checkVirtualCameraActor = fromPromise(async ({ input }) => {
|
|
|
812
854
|
if (!videoTrack) return false;
|
|
813
855
|
return input.deepsightService.checkVirtualCamera(videoTrack);
|
|
814
856
|
});
|
|
857
|
+
/**
|
|
858
|
+
* Read a File's bytes and return the raw base64 payload (the portion after
|
|
859
|
+
* `data:<mime>;base64,`). The backend's `/omni/add/*-id/v2` endpoints reject
|
|
860
|
+
* full data-URLs with `IllegalArgumentException: Illegal base64 character 3a`,
|
|
861
|
+
* so the prefix must be stripped before posting. Mirrors the live-camera
|
|
862
|
+
* path in `packages/infra/src/media/canvas.ts:getBase64Image()`.
|
|
863
|
+
*/
|
|
864
|
+
function fileToBase64Payload(file) {
|
|
865
|
+
return new Promise((resolve, reject) => {
|
|
866
|
+
const reader = new FileReader();
|
|
867
|
+
reader.onload = () => {
|
|
868
|
+
const result = reader.result;
|
|
869
|
+
if (typeof result !== "string") {
|
|
870
|
+
reject(/* @__PURE__ */ new Error("FileReader produced non-string result"));
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
const commaIndex = result.indexOf(",");
|
|
874
|
+
resolve(commaIndex === -1 ? result : result.slice(commaIndex + 1));
|
|
875
|
+
};
|
|
876
|
+
reader.onerror = () => {
|
|
877
|
+
reject(reader.error ?? /* @__PURE__ */ new Error("FileReader failed"));
|
|
878
|
+
};
|
|
879
|
+
reader.readAsDataURL(file);
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
const uploadManualFileActor = fromPromise(async ({ input, signal }) => {
|
|
883
|
+
const base64Image = await fileToBase64Payload(input.file);
|
|
884
|
+
return uploadManualIdFile({
|
|
885
|
+
side: input.side,
|
|
886
|
+
base64Image,
|
|
887
|
+
retry: input.retry,
|
|
888
|
+
onlyFront: input.onlyFront,
|
|
889
|
+
signal
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
//#endregion
|
|
894
|
+
//#region src/modules/id/manualUploadErrors.ts
|
|
895
|
+
/**
|
|
896
|
+
* i18n keys for manual-upload user-facing error copy.
|
|
897
|
+
* Keep in sync with `packages/ui/src/i18n/**.json` under the `manualIdUpload.*` namespace.
|
|
898
|
+
*/
|
|
899
|
+
const MANUAL_UPLOAD_ERROR_KEYS = {
|
|
900
|
+
wrongSide: "manualIdUpload.wrongSide",
|
|
901
|
+
wrongDocument: "manualIdUpload.wrongDocument",
|
|
902
|
+
fileTooBig: "manualIdUpload.fileTooBig",
|
|
903
|
+
generic: "manualIdUpload.generic",
|
|
904
|
+
lowSharpness: "manualIdUpload.lowSharpness",
|
|
905
|
+
glareDetected: "manualIdUpload.glareDetected",
|
|
906
|
+
readabilityIssue: "manualIdUpload.readabilityIssue",
|
|
907
|
+
qualityRejected: "manualIdUpload.qualityRejected"
|
|
908
|
+
};
|
|
909
|
+
/**
|
|
910
|
+
* Map the server's `failReason` (plus client-side passport/ID tab mismatch and
|
|
911
|
+
* per-image quality flags) onto an i18n key. Mirrors v1's `shouldUploadAgain`
|
|
912
|
+
* branch logic in
|
|
913
|
+
* `ms-incodesmile-web/packages/incode-welcome/src/manualIdUpload/manuaIdUpload.tsx`,
|
|
914
|
+
* extended to also reject responses where the backend flagged a per-image
|
|
915
|
+
* quality issue (`correctSharpness`, `correctGlare`, `readability`, or
|
|
916
|
+
* `idQualityAttemptApproved` set to `false`).
|
|
917
|
+
*
|
|
918
|
+
* Quality flags are checked with `=== false` so missing/undefined values
|
|
919
|
+
* (older backends, partial payloads) keep the legacy "trust the server"
|
|
920
|
+
* behaviour and do not produce false positives.
|
|
921
|
+
*
|
|
922
|
+
* Returns `null` when the response represents a successful upload — the caller
|
|
923
|
+
* should treat `null` as "no error, advance to next slot".
|
|
924
|
+
*/
|
|
925
|
+
function mapFailReasonToErrorKey(response, expectedTab) {
|
|
926
|
+
const failReason = response.failReason;
|
|
927
|
+
if (failReason === "WRONG_DOCUMENT_SIDE") return MANUAL_UPLOAD_ERROR_KEYS.wrongSide;
|
|
928
|
+
if (failReason === "WRONG_ONE_SIDED_DOCUMENT" || failReason === "UNKNOWN_DOCUMENT_TYPE") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
929
|
+
if (failReason === "ID_TYPE_UNACCEPTABLE") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
930
|
+
if (expectedTab === "passport" && response.typeOfId && response.typeOfId.toLowerCase() !== "passport") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
931
|
+
if (expectedTab === "id" && response.typeOfId?.toLowerCase() === "passport") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
932
|
+
if (response.correctSharpness === false) return MANUAL_UPLOAD_ERROR_KEYS.lowSharpness;
|
|
933
|
+
if (response.correctGlare === false) return MANUAL_UPLOAD_ERROR_KEYS.glareDetected;
|
|
934
|
+
if (response.readability === false) return MANUAL_UPLOAD_ERROR_KEYS.readabilityIssue;
|
|
935
|
+
if (response.idQualityAttemptApproved === false) return MANUAL_UPLOAD_ERROR_KEYS.qualityRejected;
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
815
938
|
|
|
816
939
|
//#endregion
|
|
817
940
|
//#region src/modules/id/idCaptureActions.ts
|
|
@@ -1020,7 +1143,11 @@ function getDetectionStatusFromUpdate(context, event) {
|
|
|
1020
1143
|
if (event.type === "DETECTION_UPDATE") {
|
|
1021
1144
|
const newStatus = event.status;
|
|
1022
1145
|
const currentStatus = context.detectionStatus;
|
|
1023
|
-
if (
|
|
1146
|
+
if (currentStatus === "wrongSide") {
|
|
1147
|
+
if (!(newStatus === "capturing" || newStatus === "manualCapture" || newStatus === "offline")) return currentStatus;
|
|
1148
|
+
return newStatus;
|
|
1149
|
+
}
|
|
1150
|
+
if ((newStatus === "blur" || newStatus === "glare") && currentStatus === "farAway") return currentStatus;
|
|
1024
1151
|
if ((newStatus === "wrongSide" || newStatus === "farAway") && (currentStatus === "blur" || currentStatus === "glare")) return newStatus;
|
|
1025
1152
|
return newStatus;
|
|
1026
1153
|
}
|
|
@@ -1089,6 +1216,47 @@ const hasMandatoryConsentGuard = ({ context }) => context.uploadResponse?.showMa
|
|
|
1089
1216
|
const isDeepsightEnabledGuard = ({ context }) => context.dependencies !== void 0;
|
|
1090
1217
|
const isDeepsightReadyGuard = ({ context }) => context.deepsightService !== void 0;
|
|
1091
1218
|
const needsDeepsightInitGuard = ({ context }) => context.dependencies !== void 0 && context.deepsightService === void 0 && !context.deepsightInitAttempted;
|
|
1219
|
+
const getFileFromEvent = (event) => {
|
|
1220
|
+
if (event.type === "MANUAL_UPLOAD_FILE_SELECTED") return event.file;
|
|
1221
|
+
};
|
|
1222
|
+
const getSideFromEvent = (event) => {
|
|
1223
|
+
if (event.type === "MANUAL_UPLOAD_FILE_SELECTED") return event.side;
|
|
1224
|
+
};
|
|
1225
|
+
const isSelectedFileTooLargeGuard = ({ event }) => {
|
|
1226
|
+
const file = getFileFromEvent(event);
|
|
1227
|
+
return file ? file.size > MANUAL_UPLOAD_MAX_FILE_SIZE_BYTES : false;
|
|
1228
|
+
};
|
|
1229
|
+
const isFrontFileSelectionGuard = ({ event }) => getSideFromEvent(event) === "front";
|
|
1230
|
+
const isBackFileSelectionGuard = ({ event }) => getSideFromEvent(event) === "back";
|
|
1231
|
+
const isPassportFileSelectionGuard = ({ event }) => getSideFromEvent(event) === "passport";
|
|
1232
|
+
/**
|
|
1233
|
+
* True once `retriesLeft` has been decremented to 0 — evaluated from the
|
|
1234
|
+
* `checkRetries` state after the decrement action runs.
|
|
1235
|
+
*/
|
|
1236
|
+
const manualUploadRetriesExhaustedGuard = ({ context }) => context.manualUpload.retriesLeft <= 0;
|
|
1237
|
+
const canContinueFromIdTabGuard = ({ context }) => {
|
|
1238
|
+
if (context.manualUpload.activeTab !== "id") return false;
|
|
1239
|
+
if (!context.manualUpload.frontUploaded) return false;
|
|
1240
|
+
if (context.config.onlyFront) return true;
|
|
1241
|
+
if (context.manualUpload.skipBackFromServer) return true;
|
|
1242
|
+
return context.manualUpload.backUploaded;
|
|
1243
|
+
};
|
|
1244
|
+
const canContinueFromPassportTabGuard = ({ context }) => context.manualUpload.activeTab === "passport" && context.manualUpload.passportUploaded;
|
|
1245
|
+
const getUploadResponseFromEvent = (event) => {
|
|
1246
|
+
if ("output" in event) return event.output;
|
|
1247
|
+
};
|
|
1248
|
+
/**
|
|
1249
|
+
* True when the server-side upload response contains a failReason or type
|
|
1250
|
+
* mismatch that should be surfaced to the user and counted against retries.
|
|
1251
|
+
* Evaluated by the actor's `onDone`, so the response lives on `event.output`.
|
|
1252
|
+
*/
|
|
1253
|
+
const manualUploadResponseHasErrorGuard = ({ context, event }) => {
|
|
1254
|
+
const response = getUploadResponseFromEvent(event);
|
|
1255
|
+
if (!response) return false;
|
|
1256
|
+
return mapFailReasonToErrorKey(response, context.manualUpload.activeTab) !== null;
|
|
1257
|
+
};
|
|
1258
|
+
const hasOnlyManualUploadAvailableGuard = ({ context }) => context.availableDocumentTypes.length === 1 && context.availableDocumentTypes[0] === "manualIdUpload";
|
|
1259
|
+
const isManualIdUploadSelectedGuard = ({ event }) => event.type === "SELECT_DOCUMENT" && event.documentType === "manualIdUpload";
|
|
1092
1260
|
|
|
1093
1261
|
//#endregion
|
|
1094
1262
|
//#region src/modules/id/idCaptureStateMachine.ts
|
|
@@ -1114,7 +1282,8 @@ const _idCaptureMachine = setup({
|
|
|
1114
1282
|
startRecording: startRecordingActor,
|
|
1115
1283
|
checkMotionSensor: checkMotionSensorActor,
|
|
1116
1284
|
initializeDeepsightSession: initializeDeepsightSessionActor,
|
|
1117
|
-
checkVirtualCamera: checkVirtualCameraActor
|
|
1285
|
+
checkVirtualCamera: checkVirtualCameraActor,
|
|
1286
|
+
uploadManualFile: uploadManualFileActor
|
|
1118
1287
|
},
|
|
1119
1288
|
actions: {
|
|
1120
1289
|
stopMediaStream: assign(({ context }) => {
|
|
@@ -1266,7 +1435,94 @@ const _idCaptureMachine = setup({
|
|
|
1266
1435
|
} }),
|
|
1267
1436
|
setMotionStatus: assign({ motionStatus: ({ event }) => {
|
|
1268
1437
|
if ("status" in event && event.type === "MOTION_STATUS") return event.status;
|
|
1269
|
-
} })
|
|
1438
|
+
} }),
|
|
1439
|
+
setManualUploadActiveTab: assign(({ context, event }) => {
|
|
1440
|
+
if (event.type !== "MANUAL_UPLOAD_TAB_CHANGED") return {};
|
|
1441
|
+
return { manualUpload: {
|
|
1442
|
+
...context.manualUpload,
|
|
1443
|
+
activeTab: event.tab,
|
|
1444
|
+
frontFile: null,
|
|
1445
|
+
backFile: null,
|
|
1446
|
+
passportFile: null,
|
|
1447
|
+
frontUploaded: false,
|
|
1448
|
+
backUploaded: false,
|
|
1449
|
+
passportUploaded: false,
|
|
1450
|
+
skipBackFromServer: false,
|
|
1451
|
+
errorMessage: null,
|
|
1452
|
+
retriesLeft: MANUAL_UPLOAD_MAX_RETRIES
|
|
1453
|
+
} };
|
|
1454
|
+
}),
|
|
1455
|
+
resetManualUpload: assign(({ context }) => ({ manualUpload: {
|
|
1456
|
+
...context.manualUpload,
|
|
1457
|
+
frontFile: null,
|
|
1458
|
+
backFile: null,
|
|
1459
|
+
passportFile: null,
|
|
1460
|
+
frontUploaded: false,
|
|
1461
|
+
backUploaded: false,
|
|
1462
|
+
passportUploaded: false,
|
|
1463
|
+
skipBackFromServer: false,
|
|
1464
|
+
errorMessage: null,
|
|
1465
|
+
retriesLeft: MANUAL_UPLOAD_MAX_RETRIES
|
|
1466
|
+
} })),
|
|
1467
|
+
storeSelectedFile: assign(({ context, event }) => {
|
|
1468
|
+
if (event.type !== "MANUAL_UPLOAD_FILE_SELECTED") return {};
|
|
1469
|
+
const updated = {
|
|
1470
|
+
...context.manualUpload,
|
|
1471
|
+
errorMessage: null
|
|
1472
|
+
};
|
|
1473
|
+
if (event.side === "front") updated.frontFile = event.file;
|
|
1474
|
+
else if (event.side === "back") updated.backFile = event.file;
|
|
1475
|
+
else updated.passportFile = event.file;
|
|
1476
|
+
return { manualUpload: updated };
|
|
1477
|
+
}),
|
|
1478
|
+
markFrontUploaded: assign(({ context }) => ({ manualUpload: {
|
|
1479
|
+
...context.manualUpload,
|
|
1480
|
+
frontUploaded: true,
|
|
1481
|
+
errorMessage: null
|
|
1482
|
+
} })),
|
|
1483
|
+
markBackUploaded: assign(({ context }) => ({ manualUpload: {
|
|
1484
|
+
...context.manualUpload,
|
|
1485
|
+
backUploaded: true,
|
|
1486
|
+
errorMessage: null
|
|
1487
|
+
} })),
|
|
1488
|
+
markPassportUploaded: assign(({ context }) => ({ manualUpload: {
|
|
1489
|
+
...context.manualUpload,
|
|
1490
|
+
passportUploaded: true,
|
|
1491
|
+
errorMessage: null
|
|
1492
|
+
} })),
|
|
1493
|
+
recordSkipBackFromResponse: assign(({ context, event }) => {
|
|
1494
|
+
if (!("output" in event)) return {};
|
|
1495
|
+
if (!event.output.skipBackIdCapture) return {};
|
|
1496
|
+
return { manualUpload: {
|
|
1497
|
+
...context.manualUpload,
|
|
1498
|
+
skipBackFromServer: true
|
|
1499
|
+
} };
|
|
1500
|
+
}),
|
|
1501
|
+
decrementManualUploadRetries: assign(({ context }) => ({ manualUpload: {
|
|
1502
|
+
...context.manualUpload,
|
|
1503
|
+
retriesLeft: Math.max(0, context.manualUpload.retriesLeft - 1)
|
|
1504
|
+
} })),
|
|
1505
|
+
setManualUploadErrorFromResponse: assign(({ context, event }) => {
|
|
1506
|
+
if (!("output" in event)) return {};
|
|
1507
|
+
const response = event.output;
|
|
1508
|
+
const errorKey = mapFailReasonToErrorKey(response, context.manualUpload.activeTab);
|
|
1509
|
+
return { manualUpload: {
|
|
1510
|
+
...context.manualUpload,
|
|
1511
|
+
errorMessage: errorKey ?? "manualIdUpload.generic"
|
|
1512
|
+
} };
|
|
1513
|
+
}),
|
|
1514
|
+
setManualUploadGenericError: assign(({ context }) => ({ manualUpload: {
|
|
1515
|
+
...context.manualUpload,
|
|
1516
|
+
errorMessage: "manualIdUpload.generic"
|
|
1517
|
+
} })),
|
|
1518
|
+
setManualUploadFileTooLargeError: assign(({ context }) => ({ manualUpload: {
|
|
1519
|
+
...context.manualUpload,
|
|
1520
|
+
errorMessage: "manualIdUpload.fileTooBig"
|
|
1521
|
+
} })),
|
|
1522
|
+
clearManualUploadError: assign(({ context }) => ({ manualUpload: {
|
|
1523
|
+
...context.manualUpload,
|
|
1524
|
+
errorMessage: null
|
|
1525
|
+
} }))
|
|
1270
1526
|
},
|
|
1271
1527
|
guards: {
|
|
1272
1528
|
hasShowTutorial: hasShowTutorialGuard,
|
|
@@ -1284,7 +1540,17 @@ const _idCaptureMachine = setup({
|
|
|
1284
1540
|
hasMandatoryConsent: hasMandatoryConsentGuard,
|
|
1285
1541
|
isDeepsightEnabled: isDeepsightEnabledGuard,
|
|
1286
1542
|
isDeepsightReady: isDeepsightReadyGuard,
|
|
1287
|
-
needsDeepsightInit: needsDeepsightInitGuard
|
|
1543
|
+
needsDeepsightInit: needsDeepsightInitGuard,
|
|
1544
|
+
isSelectedFileTooLarge: isSelectedFileTooLargeGuard,
|
|
1545
|
+
isFrontFileSelection: isFrontFileSelectionGuard,
|
|
1546
|
+
isBackFileSelection: isBackFileSelectionGuard,
|
|
1547
|
+
isPassportFileSelection: isPassportFileSelectionGuard,
|
|
1548
|
+
manualUploadRetriesExhausted: manualUploadRetriesExhaustedGuard,
|
|
1549
|
+
canContinueFromIdTab: canContinueFromIdTabGuard,
|
|
1550
|
+
canContinueFromPassportTab: canContinueFromPassportTabGuard,
|
|
1551
|
+
manualUploadResponseHasError: manualUploadResponseHasErrorGuard,
|
|
1552
|
+
hasOnlyManualUploadAvailable: hasOnlyManualUploadAvailableGuard,
|
|
1553
|
+
isManualIdUploadSelected: isManualIdUploadSelectedGuard
|
|
1288
1554
|
}
|
|
1289
1555
|
}).createMachine({
|
|
1290
1556
|
id: "idCapture",
|
|
@@ -1325,7 +1591,19 @@ const _idCaptureMachine = setup({
|
|
|
1325
1591
|
deepsightInitAttempted: false,
|
|
1326
1592
|
availableDocumentTypes: getAvailableDocumentTypes(input.config),
|
|
1327
1593
|
captureResolution: void 0,
|
|
1328
|
-
cameraFallbackLevel: void 0
|
|
1594
|
+
cameraFallbackLevel: void 0,
|
|
1595
|
+
manualUpload: {
|
|
1596
|
+
frontFile: null,
|
|
1597
|
+
backFile: null,
|
|
1598
|
+
passportFile: null,
|
|
1599
|
+
activeTab: "id",
|
|
1600
|
+
retriesLeft: MANUAL_UPLOAD_MAX_RETRIES,
|
|
1601
|
+
errorMessage: null,
|
|
1602
|
+
skipBackFromServer: false,
|
|
1603
|
+
frontUploaded: false,
|
|
1604
|
+
backUploaded: false,
|
|
1605
|
+
passportUploaded: false
|
|
1606
|
+
}
|
|
1329
1607
|
};
|
|
1330
1608
|
},
|
|
1331
1609
|
on: {
|
|
@@ -1334,6 +1612,10 @@ const _idCaptureMachine = setup({
|
|
|
1334
1612
|
},
|
|
1335
1613
|
states: {
|
|
1336
1614
|
idle: { on: { LOAD: [
|
|
1615
|
+
{
|
|
1616
|
+
target: "manualIdUpload",
|
|
1617
|
+
guard: "hasOnlyManualUploadAvailable"
|
|
1618
|
+
},
|
|
1337
1619
|
{
|
|
1338
1620
|
target: "chooser",
|
|
1339
1621
|
guard: "hasShowDocumentChooser"
|
|
@@ -1344,14 +1626,22 @@ const _idCaptureMachine = setup({
|
|
|
1344
1626
|
},
|
|
1345
1627
|
{ target: "loading" }
|
|
1346
1628
|
] } },
|
|
1347
|
-
chooser: { on: { SELECT_DOCUMENT: [
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1629
|
+
chooser: { on: { SELECT_DOCUMENT: [
|
|
1630
|
+
{
|
|
1631
|
+
target: "manualIdUpload",
|
|
1632
|
+
guard: "isManualIdUploadSelected",
|
|
1633
|
+
actions: ["setSelectedDocument"]
|
|
1634
|
+
},
|
|
1635
|
+
{
|
|
1636
|
+
target: "tutorial",
|
|
1637
|
+
guard: "hasShowTutorial",
|
|
1638
|
+
actions: ["setSelectedDocument", "setCurrentMode"]
|
|
1639
|
+
},
|
|
1640
|
+
{
|
|
1641
|
+
target: "loading",
|
|
1642
|
+
actions: ["setSelectedDocument", "setCurrentMode"]
|
|
1643
|
+
}
|
|
1644
|
+
] } },
|
|
1355
1645
|
loading: {
|
|
1356
1646
|
entry: "preloadRecordingProvider",
|
|
1357
1647
|
type: "parallel",
|
|
@@ -1983,11 +2273,131 @@ const _idCaptureMachine = setup({
|
|
|
1983
2273
|
actions: "resetContext"
|
|
1984
2274
|
} }
|
|
1985
2275
|
},
|
|
1986
|
-
manualIdUpload: {
|
|
2276
|
+
manualIdUpload: {
|
|
2277
|
+
initial: "selecting",
|
|
2278
|
+
on: {
|
|
2279
|
+
QUIT: { target: "closed" },
|
|
2280
|
+
MANUAL_UPLOAD_TAB_CHANGED: {
|
|
2281
|
+
target: ".selecting",
|
|
2282
|
+
actions: ["setManualUploadActiveTab"]
|
|
2283
|
+
},
|
|
2284
|
+
MANUAL_UPLOAD_RESET: {
|
|
2285
|
+
target: ".selecting",
|
|
2286
|
+
actions: ["resetManualUpload"]
|
|
2287
|
+
}
|
|
2288
|
+
},
|
|
2289
|
+
states: {
|
|
2290
|
+
selecting: { on: {
|
|
2291
|
+
MANUAL_UPLOAD_FILE_SELECTED: [
|
|
2292
|
+
{
|
|
2293
|
+
guard: "isSelectedFileTooLarge",
|
|
2294
|
+
actions: ["setManualUploadFileTooLargeError"]
|
|
2295
|
+
},
|
|
2296
|
+
{
|
|
2297
|
+
guard: "isFrontFileSelection",
|
|
2298
|
+
target: "uploadingFront",
|
|
2299
|
+
actions: ["storeSelectedFile"]
|
|
2300
|
+
},
|
|
2301
|
+
{
|
|
2302
|
+
guard: "isBackFileSelection",
|
|
2303
|
+
target: "uploadingBack",
|
|
2304
|
+
actions: ["storeSelectedFile"]
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
guard: "isPassportFileSelection",
|
|
2308
|
+
target: "uploadingPassport",
|
|
2309
|
+
actions: ["storeSelectedFile"]
|
|
2310
|
+
}
|
|
2311
|
+
],
|
|
2312
|
+
MANUAL_UPLOAD_CONTINUE: [{
|
|
2313
|
+
guard: "canContinueFromIdTab",
|
|
2314
|
+
target: "#idCapture.processing"
|
|
2315
|
+
}, {
|
|
2316
|
+
guard: "canContinueFromPassportTab",
|
|
2317
|
+
target: "#idCapture.processing"
|
|
2318
|
+
}]
|
|
2319
|
+
} },
|
|
2320
|
+
uploadingFront: { invoke: {
|
|
2321
|
+
id: "uploadManualFile",
|
|
2322
|
+
src: "uploadManualFile",
|
|
2323
|
+
input: ({ context }) => ({
|
|
2324
|
+
side: "front",
|
|
2325
|
+
file: context.manualUpload.frontFile,
|
|
2326
|
+
retry: context.manualUpload.retriesLeft < MANUAL_UPLOAD_MAX_RETRIES,
|
|
2327
|
+
onlyFront: context.config.onlyFront ?? false
|
|
2328
|
+
}),
|
|
2329
|
+
onDone: [{
|
|
2330
|
+
guard: "manualUploadResponseHasError",
|
|
2331
|
+
target: "checkRetries",
|
|
2332
|
+
actions: ["decrementManualUploadRetries", "setManualUploadErrorFromResponse"]
|
|
2333
|
+
}, {
|
|
2334
|
+
target: "selecting",
|
|
2335
|
+
actions: [
|
|
2336
|
+
"markFrontUploaded",
|
|
2337
|
+
"recordSkipBackFromResponse",
|
|
2338
|
+
"clearManualUploadError"
|
|
2339
|
+
]
|
|
2340
|
+
}],
|
|
2341
|
+
onError: {
|
|
2342
|
+
target: "checkRetries",
|
|
2343
|
+
actions: ["decrementManualUploadRetries", "setManualUploadGenericError"]
|
|
2344
|
+
}
|
|
2345
|
+
} },
|
|
2346
|
+
uploadingBack: { invoke: {
|
|
2347
|
+
id: "uploadManualFile",
|
|
2348
|
+
src: "uploadManualFile",
|
|
2349
|
+
input: ({ context }) => ({
|
|
2350
|
+
side: "back",
|
|
2351
|
+
file: context.manualUpload.backFile,
|
|
2352
|
+
retry: context.manualUpload.retriesLeft < MANUAL_UPLOAD_MAX_RETRIES,
|
|
2353
|
+
onlyFront: false
|
|
2354
|
+
}),
|
|
2355
|
+
onDone: [{
|
|
2356
|
+
guard: "manualUploadResponseHasError",
|
|
2357
|
+
target: "checkRetries",
|
|
2358
|
+
actions: ["decrementManualUploadRetries", "setManualUploadErrorFromResponse"]
|
|
2359
|
+
}, {
|
|
2360
|
+
target: "selecting",
|
|
2361
|
+
actions: ["markBackUploaded", "clearManualUploadError"]
|
|
2362
|
+
}],
|
|
2363
|
+
onError: {
|
|
2364
|
+
target: "checkRetries",
|
|
2365
|
+
actions: ["decrementManualUploadRetries", "setManualUploadGenericError"]
|
|
2366
|
+
}
|
|
2367
|
+
} },
|
|
2368
|
+
uploadingPassport: { invoke: {
|
|
2369
|
+
id: "uploadManualFile",
|
|
2370
|
+
src: "uploadManualFile",
|
|
2371
|
+
input: ({ context }) => ({
|
|
2372
|
+
side: "passport",
|
|
2373
|
+
file: context.manualUpload.passportFile,
|
|
2374
|
+
retry: context.manualUpload.retriesLeft < MANUAL_UPLOAD_MAX_RETRIES,
|
|
2375
|
+
onlyFront: false
|
|
2376
|
+
}),
|
|
2377
|
+
onDone: [{
|
|
2378
|
+
guard: "manualUploadResponseHasError",
|
|
2379
|
+
target: "checkRetries",
|
|
2380
|
+
actions: ["decrementManualUploadRetries", "setManualUploadErrorFromResponse"]
|
|
2381
|
+
}, {
|
|
2382
|
+
target: "selecting",
|
|
2383
|
+
actions: ["markPassportUploaded", "clearManualUploadError"]
|
|
2384
|
+
}],
|
|
2385
|
+
onError: {
|
|
2386
|
+
target: "checkRetries",
|
|
2387
|
+
actions: ["decrementManualUploadRetries", "setManualUploadGenericError"]
|
|
2388
|
+
}
|
|
2389
|
+
} },
|
|
2390
|
+
checkRetries: { always: [{
|
|
2391
|
+
guard: "manualUploadRetriesExhausted",
|
|
2392
|
+
target: "retriesExhausted"
|
|
2393
|
+
}, { target: "selecting" }] },
|
|
2394
|
+
retriesExhausted: { after: { [MANUAL_UPLOAD_EXHAUSTION_FORWARD_MS]: { target: "#idCapture.finished" } } }
|
|
2395
|
+
}
|
|
2396
|
+
},
|
|
1987
2397
|
digitalIdUpload: { on: { QUIT: { target: "closed" } } }
|
|
1988
2398
|
}
|
|
1989
2399
|
});
|
|
1990
2400
|
const idCaptureMachine = _idCaptureMachine;
|
|
1991
2401
|
|
|
1992
2402
|
//#endregion
|
|
1993
|
-
export { startRecordingSession as a, uploadIdImage as c, processId as i,
|
|
2403
|
+
export { startRecordingSession as a, uploadIdImage as c, ID_ERROR_CODES as d, MANUAL_UPLOAD_EXHAUSTION_FORWARD_MS as f, processId as i, uploadManualIdFile as l, MANUAL_UPLOAD_MAX_RETRIES as m, initializeIdCapture as n, stopRecording as o, MANUAL_UPLOAD_MAX_FILE_SIZE_BYTES as p, preloadIdRecordingProvider as r, stopStream as s, idCaptureMachine as t, validateUploadResponse as u };
|