@incodetech/core 0.0.0-dev-20260918-5cab0f73 → 0.0.0-dev-20260921-b7e58eb5
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/{BrowserDiagnosticsCryptoProvider-YzSTx645.esm.js → BrowserDiagnosticsCryptoProvider-Bh5BLVQ8.esm.js} +1 -1
- package/dist/{FaceDetectionProvider-BGdxN0Zs.esm.js → FaceDetectionProvider-JgulaYPT.esm.js} +4 -4
- package/dist/ae-signature.esm.js +1 -1
- package/dist/{apiError-D7MNCAJk.esm.js → apiError-BI_DIL8-.esm.js} +1 -1
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-BzD0aGAV.d.ts → authenticationManager-BK2M68y1.d.ts} +1 -7
- package/dist/{authenticationManager-5H2-DxBi.esm.js → authenticationManager-CuUtDrlp.esm.js} +3 -3
- package/dist/{authenticationStateMachine-BGEwZIOs.esm.js → authenticationStateMachine-5jWG5IWN.esm.js} +3 -3
- package/dist/{createCameraCycleOwnership-UAS1fFZF.esm.js → createCameraCycleOwnership-BjoMVvya.esm.js} +1 -55
- package/dist/curp-validation.d.ts +1 -1
- package/dist/{curpValidationManager-BJZ96KwC.d.ts → curpValidationManager-Ca_hyfn8.d.ts} +1 -1
- package/dist/{deepsightLoader-ClS4buil.esm.js → deepsightLoader-_UsfC4N5.esm.js} +3 -3
- package/dist/document-capture.d.ts +1 -1
- package/dist/{documentCaptureManager-CbAGkHWh.d.ts → documentCaptureManager-C8eO0hbv.d.ts} +1 -1
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-CJXEcdgp.esm.js → dynamicFormsManager-DnLPFgpo.esm.js} +1 -1
- package/dist/{dynamicFormsStateMachine-BCIETgMA.esm.js → dynamicFormsStateMachine-DZMvXU5C.esm.js} +1 -1
- package/dist/ekyb.d.ts +1 -1
- package/dist/ekyb.esm.js +3 -3
- package/dist/{ekybManager-BXBQElBA.esm.js → ekybManager-wxfTuhMw.esm.js} +1 -1
- package/dist/{ekybStateMachine-G_Nc0Ivr.esm.js → ekybStateMachine-CJekohHm.esm.js} +1 -1
- package/dist/electronic-signature.esm.js +1 -1
- package/dist/{electronicSignatureManager-BfRaSEfH.esm.js → electronicSignatureManager-B2s_UpGX.esm.js} +1 -1
- package/dist/extensibility.d.ts +10 -10
- package/dist/extensibility.esm.js +10 -10
- package/dist/{faceCaptureManagerFactory-OT8cpWWg.esm.js → faceCaptureManagerFactory-B3i_gukQ.esm.js} +3 -48
- package/dist/{faceCaptureManagerFactory-Cd48RMoz.d.ts → faceCaptureManagerFactory-BbD7mKqo.d.ts} +4 -43
- package/dist/{faceCaptureSetup-BYnRHKy-.esm.js → faceCaptureSetup-nNxycISh.esm.js} +5 -271
- package/dist/{feature-management-fKRm2ALz.esm.js → feature-management-79K7xbqh.esm.js} +1 -1
- package/dist/feature-management.esm.js +1 -1
- package/dist/flow-events.d.ts +1 -1
- package/dist/flow.d.ts +5 -5
- package/dist/flow.esm.js +3 -3
- package/dist/{flowCompletionService-DyteW8N2.esm.js → flowCompletionService-rS_YFQ6t.esm.js} +1 -1
- package/dist/{flowServices-JxDEQEvw.esm.js → flowServices-U9b0ahPM.esm.js} +4 -4
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-CQfmoTDc.esm.js → geolocationManager-B9IuSkTU.esm.js} +1 -1
- package/dist/{geolocationStateMachine-CfZw2p6n.esm.js → geolocationStateMachine-TAJQ1khU.esm.js} +1 -1
- package/dist/home.d.ts +1 -1
- package/dist/id-selfie-flow.d.ts +1 -1
- package/dist/id-selfie-flow.esm.js +8 -8
- package/dist/id.d.ts +3 -3
- package/dist/id.esm.js +4 -5
- package/dist/{idCaptureDefaults-CCDNrEyH.esm.js → idCaptureDefaults-mlWsFVol.esm.js} +1 -1
- package/dist/{idCaptureManager-D1eI8wto.esm.js → idCaptureManager--1kTG7zh.esm.js} +3 -149
- package/dist/{idCaptureManager-BwgZAxRm.d.ts → idCaptureManager-x8HYtbU_.d.ts} +4 -77
- package/dist/{idCaptureServices-ugA6g9lm.esm.js → idCaptureServices-C-kakh6D.esm.js} +4 -31
- package/dist/{idCaptureStateMachine-BzSjOmhQ.esm.js → idCaptureStateMachine-B12AOO3l.esm.js} +317 -788
- package/dist/identity-reuse.d.ts +1 -1
- package/dist/{identityReuseManager-x2QG6QAm.d.ts → identityReuseManager-D30b2UEC.d.ts} +4 -4
- package/dist/{index-1E8g-2g7.d.ts → index-CB9o8nNO.d.ts} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/{mandatoryConsentManager-BF3b2SF-.d.ts → mandatoryConsentManager-BEg7LM9Y.d.ts} +5 -5
- package/dist/personhood.d.ts +1 -1
- package/dist/personhood.esm.js +4 -4
- package/dist/qe-signature.esm.js +1 -1
- package/dist/{runChildModule-ClkAUc6x.esm.js → runChildModule-Cik6cSGU.esm.js} +1 -1
- package/dist/{sdkVersion-BCY7wMPM.esm.js → sdkVersion-BaqyXxtV.esm.js} +1 -1
- package/dist/selfie.d.ts +3 -3
- package/dist/selfie.esm.js +7 -7
- package/dist/{selfieErrorUtils-UiQ46EBa.esm.js → selfieErrorUtils-yjRptLFi.esm.js} +1 -27
- package/dist/{selfieManager-2XhaWSPN.esm.js → selfieManager-B-joeD7D.esm.js} +3 -3
- package/dist/{selfieManager-CDEI-0sG.d.ts → selfieManager-BYY1eWDa.d.ts} +1 -7
- package/dist/selfieStateMachine-BtJHDS_g.esm.js +40 -0
- package/dist/{session-CTNuAH2T.esm.js → session-IbTLb79e.esm.js} +3 -3
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +4 -4
- package/dist/{sessionInitializer-CsXOAxxm.esm.js → sessionInitializer-Bw1QJcYn.esm.js} +3 -3
- package/dist/{setup-BUHgnW1t.esm.js → setup--3OJBjl-.esm.js} +4 -4
- package/dist/{trueSightService-C4pbgK2N.esm.js → trueSightService-WChjnB6y.esm.js} +2 -2
- package/dist/{types-ExpE7pl7.d.ts → types-BtX86Xl6.d.ts} +1 -1
- package/dist/{types-B-yKe-iB.d.ts → types-C--rKe_Y.d.ts} +1 -1
- package/dist/{types-BJ5OoZiu2.d.ts → types-DBu4S_vo2.d.ts} +8 -50
- package/dist/{types-COFO2tJb.d.ts → types-DvZVYbHR.d.ts} +2 -4
- package/dist/{types-BlTGii11.d.ts → types-Ijf6vvwm.d.ts} +1 -2
- package/dist/types-ixFGXL3F.d.ts +6 -0
- package/dist/video-selfie.d.ts +1 -1
- package/dist/video-selfie.esm.js +4 -4
- package/dist/{videoSelfieCameraWarmer-DYhJLlU-.esm.js → videoSelfieCameraWarmer-Cksm9p7e.esm.js} +4 -4
- package/dist/{videoSelfieStepDetector-D9BB7QLa.d.ts → videoSelfieStepDetector-Apm7Puet.d.ts} +2 -2
- package/dist/wasm.esm.js +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.esm.js +14 -14
- package/package.json +1 -1
- package/dist/selfieStateMachine-C5_lbUwS.esm.js +0 -69
- package/dist/types-DzX4bQBH.d.ts +0 -6
package/dist/{idCaptureStateMachine-BzSjOmhQ.esm.js → idCaptureStateMachine-B12AOO3l.esm.js}
RENAMED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { l as BrowserStorageProvider } from "./setup
|
|
1
|
+
import { l as BrowserStorageProvider } from "./setup--3OJBjl-.esm.js";
|
|
2
2
|
import { r as WasmUtilProvider } from "./safeStorage-C511Hltw.esm.js";
|
|
3
3
|
import { t as BrowserTimerProvider } from "./BrowserTimerProvider-BXhgNxLt.esm.js";
|
|
4
|
-
import { s as exposeExperimentOnce } from "./feature-management-
|
|
4
|
+
import { s as exposeExperimentOnce } from "./feature-management-79K7xbqh.esm.js";
|
|
5
5
|
import { n as revokeObjectURL, t as getTimestamp } from "./IBrowserEnvironmentCapability-DEaRRk-R.esm.js";
|
|
6
6
|
import { r as getToken, t as api } from "./api-Bx3gKW_y.esm.js";
|
|
7
|
-
import { c as trueSightHintTransition, l as trueSightLog, m as isTrueSightTesting, r as noteTrueSightCaptureActivity } from "./trueSightService-
|
|
7
|
+
import { c as trueSightHintTransition, l as trueSightLog, m as isTrueSightTesting, r as noteTrueSightCaptureActivity } from "./trueSightService-WChjnB6y.esm.js";
|
|
8
8
|
import { n as eventModuleNames, s as recordExperimentAssignmentOnce } from "./events-ijlbX_Wx.esm.js";
|
|
9
|
-
import { t as getDisableIpify } from "./sessionInitializer-
|
|
9
|
+
import { t as getDisableIpify } from "./sessionInitializer-Bw1QJcYn.esm.js";
|
|
10
10
|
import { t as endpoints } from "./endpoints-B-3Q-LUw.esm.js";
|
|
11
11
|
import { t as addDeviceStats } from "./stats-CZcy2J53.esm.js";
|
|
12
12
|
import { a as isIOS, s as isIPad, t as isAndroid, u as isMacOsSafari } from "./platform-DkcRc9JV.esm.js";
|
|
13
|
-
import "./session-
|
|
13
|
+
import "./session-IbTLb79e.esm.js";
|
|
14
14
|
import { c as not, i as assign, l as raise, n as enqueueActions, o as and, r as sendTo, t as setup } from "./xstate.esm-Bg3FuvIs.esm.js";
|
|
15
15
|
import { n as fromPromise, t as fromCallback } from "./xstate-actors.esm-Ccyzgxj1.esm.js";
|
|
16
16
|
import { n as getUrlSearchParam, t as buildUrlWithSearchParams } from "./urlUtils-D6phjq1-.esm.js";
|
|
17
17
|
import { r as getCameraReacquisitionConstraints } from "./camera-sIa9ceW2.esm.js";
|
|
18
18
|
import { n as invokeRequestPermissionActor, t as checkPermission } from "./permissionServices-C8DqhjX7.esm.js";
|
|
19
|
-
import {
|
|
19
|
+
import { a as flagIdManualReview, n as runProtectedAttempt, o as PROTECTED_CAPTURE_TARGET, r as cameraCycleProvider, t as createCameraCycleOwnership } from "./createCameraCycleOwnership-BjoMVvya.esm.js";
|
|
20
20
|
import { t as IncodeCanvas } from "./canvas-BxFzWTt-.esm.js";
|
|
21
21
|
import { n as needsMotionPrimeOnlyFromPermission, r as resolveStoredPermissionResult, t as isReadyForCaptureFromPermission } from "./permissionGuards-3_AT5BY5.esm.js";
|
|
22
22
|
import { t as StreamCanvasProcessingSession } from "./StreamCanvasProcessingSession-CBnbTnOr.esm.js";
|
|
@@ -24,8 +24,8 @@ import { t as sleep } from "./ITimerCapability-DgdDzp8G.esm.js";
|
|
|
24
24
|
import { t as getBrowser } from "./getBrowser-Cbe1C4Tn.esm.js";
|
|
25
25
|
import { n as getWindowDimensions } from "./getDeviceClass-CeBiEayS.esm.js";
|
|
26
26
|
import { n as runVirtualCameraCheck, t as frameSources } from "./virtualCameraCheck-Cjab7FTI.esm.js";
|
|
27
|
-
import { n as DEFAULT_ID_CAPTURE_THRESHOLDS, r as IdCaptureProvider } from "./idCaptureDefaults-
|
|
28
|
-
import { a as getRealQualityValue, b as
|
|
27
|
+
import { n as DEFAULT_ID_CAPTURE_THRESHOLDS, r as IdCaptureProvider } from "./idCaptureDefaults-mlWsFVol.esm.js";
|
|
28
|
+
import { _ as resolveIdCaptureThresholds, a as getRealQualityValue, b as getIdCameraStream, c as prepareRecordingForCameraRetry, d as stopRecording, f as stopStream, h as ID_ERROR_CODES, i as finalizeRecordingSession, l as processId, m as validateUploadResponse, o as initializeIdCapture, p as uploadIdImage, r as disposeRecordingSession, t as addBarcode, u as startRecordingSession, v as CAPTURE_OPTIMIZING, y as OPTIMIZING_WATCHDOG_MARGIN_MS } from "./idCaptureServices-C-kakh6D.esm.js";
|
|
29
29
|
import { t as StreamCanvasCapture } from "./StreamCanvasCapture-C9jtgBdT.esm.js";
|
|
30
30
|
//#region src/modules/id/digitalUpload/digitalUploadErrors.ts
|
|
31
31
|
const TERMINAL_FAIL_REASONS = /* @__PURE__ */ new Set(["DIGITAL_ID_REQUESTED_BUT_OTHER_PROVIDED", "ID_TYPE_UNACCEPTABLE"]);
|
|
@@ -89,7 +89,7 @@ const uploadDigitalIdActor = fromPromise(async ({ input, signal }) => {
|
|
|
89
89
|
extractIdFace: input.extractIdFace
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
|
-
const getUploadResponseFromEvent
|
|
92
|
+
const getUploadResponseFromEvent = (event) => {
|
|
93
93
|
if (!("output" in event)) return;
|
|
94
94
|
return event.output;
|
|
95
95
|
};
|
|
@@ -153,10 +153,10 @@ const digitalUploadMachine = setup({
|
|
|
153
153
|
isSelectedFileTooLarge: ({ event }) => event.type === "FILE_PICKED" && event.file.size > 5242880,
|
|
154
154
|
isSelectedFileMimeInvalid: ({ event }) => event.type === "FILE_PICKED" && !DIGITAL_UPLOAD_ALLOWED_MIME_TYPES.includes(event.file.type),
|
|
155
155
|
hasSelectedFile: ({ context }) => context.file !== null,
|
|
156
|
-
responseHasFailReason: ({ event }) => mapDigitalIdFailReason(getUploadResponseFromEvent
|
|
156
|
+
responseHasFailReason: ({ event }) => mapDigitalIdFailReason(getUploadResponseFromEvent(event)) !== null,
|
|
157
157
|
hasAttemptsRemaining: ({ context }) => context.attemptsRemaining > 0,
|
|
158
158
|
isTerminalFailReason: ({ event }) => {
|
|
159
|
-
return isTerminalDigitalIdFailReason(getUploadResponseFromEvent
|
|
159
|
+
return isTerminalDigitalIdFailReason(getUploadResponseFromEvent(event));
|
|
160
160
|
},
|
|
161
161
|
isCurrentFailReasonTerminal: ({ context }) => {
|
|
162
162
|
const terminalReasons = /* @__PURE__ */ new Set(["DIGITAL_ID_REQUESTED_BUT_OTHER_PROVIDED", "ID_TYPE_UNACCEPTABLE"]);
|
|
@@ -529,409 +529,6 @@ function resolveWalletPlatform(provider) {
|
|
|
529
529
|
return isIOS() || isMacOsSafari() || isIPad() ? "ios" : "android";
|
|
530
530
|
}
|
|
531
531
|
//#endregion
|
|
532
|
-
//#region src/modules/id/manualUpload/manualUploadErrors.ts
|
|
533
|
-
/**
|
|
534
|
-
* i18n keys for manual-upload user-facing error copy.
|
|
535
|
-
* Keep in sync with `packages/ui/src/i18n/**.json` under the `manualIdUpload.*` namespace.
|
|
536
|
-
*/
|
|
537
|
-
const MANUAL_UPLOAD_ERROR_KEYS = {
|
|
538
|
-
wrongSide: "manualIdUpload.wrongSide",
|
|
539
|
-
wrongDocument: "manualIdUpload.wrongDocument",
|
|
540
|
-
fileTooBig: "manualIdUpload.fileTooBig",
|
|
541
|
-
generic: "manualIdUpload.generic",
|
|
542
|
-
lowSharpness: "manualIdUpload.lowSharpness",
|
|
543
|
-
glareDetected: "manualIdUpload.glareDetected",
|
|
544
|
-
readabilityIssue: "manualIdUpload.readabilityIssue"
|
|
545
|
-
};
|
|
546
|
-
/**
|
|
547
|
-
* Map the server's `failReason` (plus client-side passport/ID tab mismatch and
|
|
548
|
-
* per-image quality flags) onto an i18n key. Mirrors v1's `shouldUploadAgain`
|
|
549
|
-
* branch logic in
|
|
550
|
-
* `ms-incodesmile-web/packages/incode-welcome/src/manualIdUpload/manuaIdUpload.tsx`,
|
|
551
|
-
* extended to also reject responses where the backend flagged a per-image
|
|
552
|
-
* quality issue (`correctSharpness`, `correctGlare`, or `readability`).
|
|
553
|
-
* `idQualityAttemptApproved` is intentionally ignored — v1 did not treat it
|
|
554
|
-
* as a manual-upload rejection signal.
|
|
555
|
-
*
|
|
556
|
-
* Quality flags are checked with `=== false` so missing/undefined values
|
|
557
|
-
* (older backends, partial payloads) keep the legacy "trust the server"
|
|
558
|
-
* behaviour and do not produce false positives.
|
|
559
|
-
*
|
|
560
|
-
* Returns `null` when the response represents a successful upload — the caller
|
|
561
|
-
* should treat `null` as "no error, advance to next slot".
|
|
562
|
-
*/
|
|
563
|
-
function mapFailReasonToErrorKey(response, expectedTab) {
|
|
564
|
-
const failReason = response.failReason;
|
|
565
|
-
if (failReason === "WRONG_DOCUMENT_SIDE") return MANUAL_UPLOAD_ERROR_KEYS.wrongSide;
|
|
566
|
-
if (failReason === "WRONG_ONE_SIDED_DOCUMENT" || failReason === "UNKNOWN_DOCUMENT_TYPE") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
567
|
-
if (failReason === "ID_TYPE_UNACCEPTABLE") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
568
|
-
if (expectedTab === "passport" && response.typeOfId && response.typeOfId.toLowerCase() !== "passport") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
569
|
-
if (expectedTab === "id" && response.typeOfId?.toLowerCase() === "passport") return MANUAL_UPLOAD_ERROR_KEYS.wrongDocument;
|
|
570
|
-
if (response.correctSharpness === false) return MANUAL_UPLOAD_ERROR_KEYS.lowSharpness;
|
|
571
|
-
if (response.correctGlare === false) return MANUAL_UPLOAD_ERROR_KEYS.glareDetected;
|
|
572
|
-
if (response.readability === false) return MANUAL_UPLOAD_ERROR_KEYS.readabilityIssue;
|
|
573
|
-
return null;
|
|
574
|
-
}
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region src/modules/id/manualUpload/types.ts
|
|
577
|
-
const MANUAL_UPLOAD_MAX_RETRIES = 3;
|
|
578
|
-
const MANUAL_UPLOAD_MAX_FILE_SIZE_BYTES = 5 * 1024 * 1024;
|
|
579
|
-
const MANUAL_UPLOAD_EXHAUSTION_FORWARD_MS = 5e3;
|
|
580
|
-
//#endregion
|
|
581
|
-
//#region src/modules/id/manualUpload/manualUploadServices.ts
|
|
582
|
-
const stripDataUrlPrefix = (dataUrl) => {
|
|
583
|
-
const commaIndex = dataUrl.indexOf(",");
|
|
584
|
-
return commaIndex === -1 ? dataUrl : dataUrl.slice(commaIndex + 1);
|
|
585
|
-
};
|
|
586
|
-
const getBase64PayloadByteLength = (payload) => {
|
|
587
|
-
const normalized = payload.replace(/\s/g, "");
|
|
588
|
-
let padding = 0;
|
|
589
|
-
if (normalized.endsWith("==")) padding = 2;
|
|
590
|
-
else if (normalized.endsWith("=")) padding = 1;
|
|
591
|
-
return Math.max(0, Math.floor(normalized.length * 3 / 4) - padding);
|
|
592
|
-
};
|
|
593
|
-
const isBase64PayloadWithinSize = (payload, maxBytes) => getBase64PayloadByteLength(payload) <= maxBytes;
|
|
594
|
-
const fileToBase64Payload = async (file) => {
|
|
595
|
-
const dataUrl = await imageFileToDataUrl(file);
|
|
596
|
-
return stripDataUrlPrefix(dataUrl);
|
|
597
|
-
};
|
|
598
|
-
//#endregion
|
|
599
|
-
//#region src/modules/id/manualUpload/manualUploadStateMachine.ts
|
|
600
|
-
const uploadManualFileActor = fromPromise(async ({ input, signal }) => {
|
|
601
|
-
const base64Image = await fileToBase64Payload(input.file);
|
|
602
|
-
if (!isBase64PayloadWithinSize(base64Image, 5242880)) return { type: "fileTooLarge" };
|
|
603
|
-
return {
|
|
604
|
-
type: "uploaded",
|
|
605
|
-
response: await uploadManualIdFile({
|
|
606
|
-
side: input.side,
|
|
607
|
-
base64Image,
|
|
608
|
-
retry: input.retry,
|
|
609
|
-
onlyFront: input.onlyFront,
|
|
610
|
-
isSecondId: input.isSecondId,
|
|
611
|
-
extractIdFace: input.extractIdFace,
|
|
612
|
-
signal
|
|
613
|
-
})
|
|
614
|
-
};
|
|
615
|
-
});
|
|
616
|
-
const getUploadOutputFromEvent = (event) => {
|
|
617
|
-
if ("output" in event) return event.output;
|
|
618
|
-
};
|
|
619
|
-
const getUploadResponseFromEvent = (event) => {
|
|
620
|
-
const output = getUploadOutputFromEvent(event);
|
|
621
|
-
return output?.type === "uploaded" ? output.response : void 0;
|
|
622
|
-
};
|
|
623
|
-
const manualUploadMachine = setup({
|
|
624
|
-
types: {
|
|
625
|
-
context: {},
|
|
626
|
-
events: {},
|
|
627
|
-
input: {},
|
|
628
|
-
output: {}
|
|
629
|
-
},
|
|
630
|
-
actors: { uploadManualFile: uploadManualFileActor },
|
|
631
|
-
actions: {
|
|
632
|
-
setManualUploadActiveTab: assign(({ context, event }) => {
|
|
633
|
-
if (event.type !== "MANUAL_UPLOAD_TAB_CHANGED") return {};
|
|
634
|
-
return {
|
|
635
|
-
activeTab: event.tab,
|
|
636
|
-
errorMessage: null,
|
|
637
|
-
errorSide: null,
|
|
638
|
-
retriesLeft: context.captureAttempts
|
|
639
|
-
};
|
|
640
|
-
}),
|
|
641
|
-
resetManualUpload: assign(({ context }) => ({
|
|
642
|
-
frontFile: null,
|
|
643
|
-
backFile: null,
|
|
644
|
-
passportFile: null,
|
|
645
|
-
frontUploaded: false,
|
|
646
|
-
backUploaded: false,
|
|
647
|
-
passportUploaded: false,
|
|
648
|
-
skipBackFromServer: false,
|
|
649
|
-
errorMessage: null,
|
|
650
|
-
errorSide: null,
|
|
651
|
-
retriesLeft: context.captureAttempts
|
|
652
|
-
})),
|
|
653
|
-
storeSelectedFile: assign(({ event }) => {
|
|
654
|
-
if (event.type !== "MANUAL_UPLOAD_FILE_SELECTED") return {};
|
|
655
|
-
const updated = {
|
|
656
|
-
errorMessage: null,
|
|
657
|
-
errorSide: null
|
|
658
|
-
};
|
|
659
|
-
if (event.side === "front") updated.frontFile = event.file;
|
|
660
|
-
else if (event.side === "back") updated.backFile = event.file;
|
|
661
|
-
else updated.passportFile = event.file;
|
|
662
|
-
return updated;
|
|
663
|
-
}),
|
|
664
|
-
markFrontUploaded: assign(() => ({
|
|
665
|
-
frontUploaded: true,
|
|
666
|
-
errorMessage: null,
|
|
667
|
-
errorSide: null
|
|
668
|
-
})),
|
|
669
|
-
markBackUploaded: assign(() => ({
|
|
670
|
-
backUploaded: true,
|
|
671
|
-
errorMessage: null,
|
|
672
|
-
errorSide: null
|
|
673
|
-
})),
|
|
674
|
-
markPassportUploaded: assign(() => ({
|
|
675
|
-
passportUploaded: true,
|
|
676
|
-
errorMessage: null,
|
|
677
|
-
errorSide: null
|
|
678
|
-
})),
|
|
679
|
-
recordSkipBackFromResponse: assign(({ event }) => {
|
|
680
|
-
const response = getUploadResponseFromEvent(event);
|
|
681
|
-
if (!response) return {};
|
|
682
|
-
if (!response.skipBackIdCapture) return {};
|
|
683
|
-
return { skipBackFromServer: true };
|
|
684
|
-
}),
|
|
685
|
-
decrementManualUploadRetries: assign(({ context }) => ({ retriesLeft: Math.max(0, context.retriesLeft - 1) })),
|
|
686
|
-
setManualUploadErrorFromResponse: assign(({ context, event }) => {
|
|
687
|
-
const response = getUploadResponseFromEvent(event);
|
|
688
|
-
if (!response) return {};
|
|
689
|
-
return { errorMessage: mapFailReasonToErrorKey(response, context.activeTab) ?? "manualIdUpload.generic" };
|
|
690
|
-
}),
|
|
691
|
-
setManualUploadGenericError: assign(() => ({ errorMessage: "manualIdUpload.generic" })),
|
|
692
|
-
setManualUploadFileTooLargeError: assign(({ event }) => {
|
|
693
|
-
return {
|
|
694
|
-
errorMessage: "manualIdUpload.fileTooBig",
|
|
695
|
-
errorSide: event.type === "MANUAL_UPLOAD_FILE_SELECTED" ? event.side : null
|
|
696
|
-
};
|
|
697
|
-
}),
|
|
698
|
-
markErrorSideFront: assign(() => ({ errorSide: "front" })),
|
|
699
|
-
markErrorSideBack: assign(() => ({ errorSide: "back" })),
|
|
700
|
-
markErrorSidePassport: assign(() => ({ errorSide: "passport" })),
|
|
701
|
-
clearManualUploadError: assign(() => ({
|
|
702
|
-
errorMessage: null,
|
|
703
|
-
errorSide: null
|
|
704
|
-
}))
|
|
705
|
-
},
|
|
706
|
-
guards: {
|
|
707
|
-
isAllowedTabChange: ({ context, event }) => event.type === "MANUAL_UPLOAD_TAB_CHANGED" && (!context.onlyBack || event.tab === "id"),
|
|
708
|
-
isSelectedFileTooLarge: ({ context, event }) => {
|
|
709
|
-
if (event.type !== "MANUAL_UPLOAD_FILE_SELECTED") return false;
|
|
710
|
-
if (context.onlyBack && event.side !== "back") return false;
|
|
711
|
-
return event.file.size > MANUAL_UPLOAD_MAX_FILE_SIZE_BYTES;
|
|
712
|
-
},
|
|
713
|
-
isFrontFileSelection: ({ context, event }) => !context.onlyBack && event.type === "MANUAL_UPLOAD_FILE_SELECTED" && event.side === "front",
|
|
714
|
-
isBackFileSelection: ({ event }) => event.type === "MANUAL_UPLOAD_FILE_SELECTED" && event.side === "back",
|
|
715
|
-
isPassportFileSelection: ({ context, event }) => !context.onlyBack && event.type === "MANUAL_UPLOAD_FILE_SELECTED" && event.side === "passport",
|
|
716
|
-
manualUploadRetriesExhausted: ({ context }) => context.retriesLeft <= 0,
|
|
717
|
-
canContinueFromIdTab: ({ context }) => {
|
|
718
|
-
if (context.activeTab !== "id") return false;
|
|
719
|
-
if (context.onlyBack) return context.backUploaded;
|
|
720
|
-
if (!context.frontUploaded) return false;
|
|
721
|
-
if (context.onlyFront) return true;
|
|
722
|
-
if (context.skipBackFromServer) return true;
|
|
723
|
-
return context.backUploaded;
|
|
724
|
-
},
|
|
725
|
-
canContinueFromPassportTab: ({ context }) => !context.onlyBack && context.activeTab === "passport" && context.passportUploaded,
|
|
726
|
-
manualUploadResponseHasError: ({ context, event }) => {
|
|
727
|
-
const response = getUploadResponseFromEvent(event);
|
|
728
|
-
if (!response) return false;
|
|
729
|
-
return mapFailReasonToErrorKey(response, context.activeTab) !== null;
|
|
730
|
-
},
|
|
731
|
-
manualUploadPayloadTooLarge: ({ event }) => getUploadOutputFromEvent(event)?.type === "fileTooLarge"
|
|
732
|
-
}
|
|
733
|
-
}).createMachine({
|
|
734
|
-
id: "manualUpload",
|
|
735
|
-
initial: "selecting",
|
|
736
|
-
context: ({ input }) => ({
|
|
737
|
-
onlyFront: input.onlyFront,
|
|
738
|
-
onlyBack: input.onlyBack ?? false,
|
|
739
|
-
isSecondId: input.isSecondId,
|
|
740
|
-
captureAttempts: input.captureAttempts,
|
|
741
|
-
extractIdFace: input.extractIdFace,
|
|
742
|
-
frontFile: null,
|
|
743
|
-
backFile: null,
|
|
744
|
-
passportFile: null,
|
|
745
|
-
activeTab: "id",
|
|
746
|
-
retriesLeft: input.captureAttempts,
|
|
747
|
-
errorMessage: null,
|
|
748
|
-
errorSide: null,
|
|
749
|
-
skipBackFromServer: false,
|
|
750
|
-
frontUploaded: false,
|
|
751
|
-
backUploaded: false,
|
|
752
|
-
passportUploaded: false
|
|
753
|
-
}),
|
|
754
|
-
on: {
|
|
755
|
-
MANUAL_UPLOAD_TAB_CHANGED: {
|
|
756
|
-
guard: "isAllowedTabChange",
|
|
757
|
-
target: ".selecting",
|
|
758
|
-
actions: ["setManualUploadActiveTab"]
|
|
759
|
-
},
|
|
760
|
-
MANUAL_UPLOAD_RESET: {
|
|
761
|
-
target: ".selecting",
|
|
762
|
-
actions: ["resetManualUpload"]
|
|
763
|
-
}
|
|
764
|
-
},
|
|
765
|
-
states: {
|
|
766
|
-
selecting: { on: {
|
|
767
|
-
MANUAL_UPLOAD_FILE_SELECTED: [
|
|
768
|
-
{
|
|
769
|
-
guard: "isSelectedFileTooLarge",
|
|
770
|
-
actions: ["setManualUploadFileTooLargeError"]
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
guard: "isFrontFileSelection",
|
|
774
|
-
target: "uploadingFront",
|
|
775
|
-
actions: ["storeSelectedFile"]
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
guard: "isBackFileSelection",
|
|
779
|
-
target: "uploadingBack",
|
|
780
|
-
actions: ["storeSelectedFile"]
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
guard: "isPassportFileSelection",
|
|
784
|
-
target: "uploadingPassport",
|
|
785
|
-
actions: ["storeSelectedFile"]
|
|
786
|
-
}
|
|
787
|
-
],
|
|
788
|
-
MANUAL_UPLOAD_CONTINUE: [{
|
|
789
|
-
guard: "canContinueFromIdTab",
|
|
790
|
-
target: "finished"
|
|
791
|
-
}, {
|
|
792
|
-
guard: "canContinueFromPassportTab",
|
|
793
|
-
target: "finished"
|
|
794
|
-
}]
|
|
795
|
-
} },
|
|
796
|
-
uploadingFront: { invoke: {
|
|
797
|
-
id: "uploadManualFile",
|
|
798
|
-
src: "uploadManualFile",
|
|
799
|
-
input: ({ context }) => ({
|
|
800
|
-
side: "front",
|
|
801
|
-
file: context.frontFile,
|
|
802
|
-
retry: context.retriesLeft < context.captureAttempts,
|
|
803
|
-
onlyFront: context.onlyFront,
|
|
804
|
-
isSecondId: context.isSecondId,
|
|
805
|
-
extractIdFace: context.extractIdFace
|
|
806
|
-
}),
|
|
807
|
-
onDone: [
|
|
808
|
-
{
|
|
809
|
-
guard: "manualUploadPayloadTooLarge",
|
|
810
|
-
target: "selecting",
|
|
811
|
-
actions: ["setManualUploadFileTooLargeError", "markErrorSideFront"]
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
guard: "manualUploadResponseHasError",
|
|
815
|
-
target: "checkRetries",
|
|
816
|
-
actions: [
|
|
817
|
-
"decrementManualUploadRetries",
|
|
818
|
-
"setManualUploadErrorFromResponse",
|
|
819
|
-
"markErrorSideFront"
|
|
820
|
-
]
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
target: "selecting",
|
|
824
|
-
actions: [
|
|
825
|
-
"markFrontUploaded",
|
|
826
|
-
"recordSkipBackFromResponse",
|
|
827
|
-
"clearManualUploadError"
|
|
828
|
-
]
|
|
829
|
-
}
|
|
830
|
-
],
|
|
831
|
-
onError: {
|
|
832
|
-
target: "checkRetries",
|
|
833
|
-
actions: [
|
|
834
|
-
"decrementManualUploadRetries",
|
|
835
|
-
"setManualUploadGenericError",
|
|
836
|
-
"markErrorSideFront"
|
|
837
|
-
]
|
|
838
|
-
}
|
|
839
|
-
} },
|
|
840
|
-
uploadingBack: { invoke: {
|
|
841
|
-
id: "uploadManualFile",
|
|
842
|
-
src: "uploadManualFile",
|
|
843
|
-
input: ({ context }) => ({
|
|
844
|
-
side: "back",
|
|
845
|
-
file: context.backFile,
|
|
846
|
-
retry: context.retriesLeft < context.captureAttempts,
|
|
847
|
-
onlyFront: false,
|
|
848
|
-
isSecondId: context.isSecondId
|
|
849
|
-
}),
|
|
850
|
-
onDone: [
|
|
851
|
-
{
|
|
852
|
-
guard: "manualUploadPayloadTooLarge",
|
|
853
|
-
target: "selecting",
|
|
854
|
-
actions: ["setManualUploadFileTooLargeError", "markErrorSideBack"]
|
|
855
|
-
},
|
|
856
|
-
{
|
|
857
|
-
guard: "manualUploadResponseHasError",
|
|
858
|
-
target: "checkRetries",
|
|
859
|
-
actions: [
|
|
860
|
-
"decrementManualUploadRetries",
|
|
861
|
-
"setManualUploadErrorFromResponse",
|
|
862
|
-
"markErrorSideBack"
|
|
863
|
-
]
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
target: "selecting",
|
|
867
|
-
actions: ["markBackUploaded", "clearManualUploadError"]
|
|
868
|
-
}
|
|
869
|
-
],
|
|
870
|
-
onError: {
|
|
871
|
-
target: "checkRetries",
|
|
872
|
-
actions: [
|
|
873
|
-
"decrementManualUploadRetries",
|
|
874
|
-
"setManualUploadGenericError",
|
|
875
|
-
"markErrorSideBack"
|
|
876
|
-
]
|
|
877
|
-
}
|
|
878
|
-
} },
|
|
879
|
-
uploadingPassport: { invoke: {
|
|
880
|
-
id: "uploadManualFile",
|
|
881
|
-
src: "uploadManualFile",
|
|
882
|
-
input: ({ context }) => ({
|
|
883
|
-
side: "passport",
|
|
884
|
-
file: context.passportFile,
|
|
885
|
-
retry: context.retriesLeft < context.captureAttempts,
|
|
886
|
-
onlyFront: false,
|
|
887
|
-
isSecondId: context.isSecondId,
|
|
888
|
-
extractIdFace: context.extractIdFace
|
|
889
|
-
}),
|
|
890
|
-
onDone: [
|
|
891
|
-
{
|
|
892
|
-
guard: "manualUploadPayloadTooLarge",
|
|
893
|
-
target: "selecting",
|
|
894
|
-
actions: ["setManualUploadFileTooLargeError", "markErrorSidePassport"]
|
|
895
|
-
},
|
|
896
|
-
{
|
|
897
|
-
guard: "manualUploadResponseHasError",
|
|
898
|
-
target: "checkRetries",
|
|
899
|
-
actions: [
|
|
900
|
-
"decrementManualUploadRetries",
|
|
901
|
-
"setManualUploadErrorFromResponse",
|
|
902
|
-
"markErrorSidePassport"
|
|
903
|
-
]
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
target: "selecting",
|
|
907
|
-
actions: ["markPassportUploaded", "clearManualUploadError"]
|
|
908
|
-
}
|
|
909
|
-
],
|
|
910
|
-
onError: {
|
|
911
|
-
target: "checkRetries",
|
|
912
|
-
actions: [
|
|
913
|
-
"decrementManualUploadRetries",
|
|
914
|
-
"setManualUploadGenericError",
|
|
915
|
-
"markErrorSidePassport"
|
|
916
|
-
]
|
|
917
|
-
}
|
|
918
|
-
} },
|
|
919
|
-
checkRetries: { always: [{
|
|
920
|
-
guard: "manualUploadRetriesExhausted",
|
|
921
|
-
target: "retriesExhausted"
|
|
922
|
-
}, { target: "selecting" }] },
|
|
923
|
-
retriesExhausted: { after: { [MANUAL_UPLOAD_EXHAUSTION_FORWARD_MS]: { target: "exhausted" } } },
|
|
924
|
-
exhausted: {
|
|
925
|
-
type: "final",
|
|
926
|
-
output: { result: "exhausted" }
|
|
927
|
-
},
|
|
928
|
-
finished: {
|
|
929
|
-
type: "final",
|
|
930
|
-
output: { result: "success" }
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
//#endregion
|
|
935
532
|
//#region src/modules/id/idCaptureGuards.ts
|
|
936
533
|
function getPermissionOutput(event) {
|
|
937
534
|
if (!("output" in event)) return;
|
|
@@ -941,7 +538,7 @@ function getPermissionOutput(event) {
|
|
|
941
538
|
}
|
|
942
539
|
const hasShowTutorialGuard = ({ context }) => context.config.showTutorial;
|
|
943
540
|
const hasAgeAssuranceGuard = ({ context }) => context.config.ageAssurance === true;
|
|
944
|
-
const hasShowDocumentChooserGuard = ({ context }) =>
|
|
541
|
+
const hasShowDocumentChooserGuard = ({ context }) => !context.config.onlyBack && (context.config.showDocumentChooserScreen ?? false);
|
|
945
542
|
const isPermissionGrantedGuard = ({ event }) => {
|
|
946
543
|
return getPermissionOutput(event) === "granted";
|
|
947
544
|
};
|
|
@@ -994,11 +591,9 @@ const isFrontModeGuard = ({ context }) => context.currentMode === "front" || con
|
|
|
994
591
|
* server answer exists, and
|
|
995
592
|
* 2. where you do, still self-correct once the answer arrives.
|
|
996
593
|
*
|
|
997
|
-
*
|
|
998
|
-
*
|
|
999
|
-
*
|
|
1000
|
-
* `skipBackFromServer` afterwards to satisfy (2)). This guard is on neither
|
|
1001
|
-
* path — the answer is already in hand by the time it runs.
|
|
594
|
+
* The captureOnly machine qualifies under (1) because it has no upload and no
|
|
595
|
+
* server answer. This guard is not on that path, so the answer is already in
|
|
596
|
+
* hand by the time it runs.
|
|
1002
597
|
*/
|
|
1003
598
|
const shouldContinueToBackGuard = ({ context }) => {
|
|
1004
599
|
if (context.currentMode !== "front" && context.currentMode !== "passport") return false;
|
|
@@ -1038,10 +633,8 @@ const supportsOptimizingStatusGuard = ({ context }) => context.config.supportsOp
|
|
|
1038
633
|
const isDeepsightEnabledGuard = ({ context }) => context.dependencies !== void 0;
|
|
1039
634
|
const isDeepsightReadyGuard = ({ context }) => context.deepsightService !== void 0;
|
|
1040
635
|
const needsDeepsightInitGuard = ({ context }) => context.dependencies !== void 0 && context.deepsightService === void 0 && !context.deepsightInitAttempted;
|
|
1041
|
-
const hasOnlyManualUploadAvailableGuard = ({ context }) => context.availableDocumentTypes.length === 1 && context.availableDocumentTypes[0] === "manualIdUpload";
|
|
1042
636
|
/** No capture option is enabled — the ID module is misconfigured. */
|
|
1043
637
|
const hasNoDocumentTypesAvailableGuard = ({ context }) => context.availableDocumentTypes.length === 0;
|
|
1044
|
-
const isManualIdUploadSelectedGuard = ({ event }) => event.type === "SELECT_DOCUMENT" && event.documentType === "manualIdUpload";
|
|
1045
638
|
const isDigitalIdUploadSelectedGuard = ({ event }) => event.type === "SELECT_DOCUMENT" && event.documentType === "digitalIdUpload";
|
|
1046
639
|
const isDigitalIdRedirectSelectedGuard = ({ event }) => event.type === "SELECT_DOCUMENT" && event.documentType === "digitalIdRedirect";
|
|
1047
640
|
/** The Digital ID (device wallet) chooser tile was picked. */
|
|
@@ -1132,285 +725,6 @@ const isBackModeInMultiSideFlowGuard = ({ context }) => context.currentMode ===
|
|
|
1132
725
|
const wasExpiredRedirectedGuard = ({ context }) => context.expiredRedirected === true;
|
|
1133
726
|
const hasManualCaptureTriggeredGuard = ({ context }) => context.manualCaptureTriggered;
|
|
1134
727
|
//#endregion
|
|
1135
|
-
//#region src/modules/id/digitalIdRegistry.ts
|
|
1136
|
-
/**
|
|
1137
|
-
* True when a digital-ID method uses a full-page web-redirect flow (Trinsic
|
|
1138
|
-
* iDIN/FTN). Accepts both the module `FlowType` value (`REDIRECT`) and the
|
|
1139
|
-
* backend value (`WEB_REDIRECT`). (Lives here rather than in
|
|
1140
|
-
* `idCaptureHelpers` to keep the registry free of circular imports; the
|
|
1141
|
-
* helpers re-export it.)
|
|
1142
|
-
*/
|
|
1143
|
-
function isRedirectFlowType(flowType) {
|
|
1144
|
-
return flowType === "REDIRECT" || flowType === "WEB_REDIRECT";
|
|
1145
|
-
}
|
|
1146
|
-
const DIGITAL_ID_REGISTRY = {
|
|
1147
|
-
mDL: [{
|
|
1148
|
-
kind: "incodeWallet",
|
|
1149
|
-
documentType: "digitalId"
|
|
1150
|
-
}, {
|
|
1151
|
-
kind: "trinsicRedirect",
|
|
1152
|
-
documentType: "digitalIdRedirect",
|
|
1153
|
-
providerId: "trinsic_mdl_placeholder",
|
|
1154
|
-
method: "MDL"
|
|
1155
|
-
}],
|
|
1156
|
-
iDIN: [{
|
|
1157
|
-
kind: "trinsicRedirect",
|
|
1158
|
-
documentType: "digitalIdRedirect",
|
|
1159
|
-
providerId: "trinsic_netherlands_idin",
|
|
1160
|
-
method: "IDIN"
|
|
1161
|
-
}],
|
|
1162
|
-
FTN: [{
|
|
1163
|
-
kind: "trinsicRedirect",
|
|
1164
|
-
documentType: "digitalIdRedirect",
|
|
1165
|
-
providerId: "trinsic_finnish_trust_network",
|
|
1166
|
-
method: "FTN"
|
|
1167
|
-
}]
|
|
1168
|
-
};
|
|
1169
|
-
const DIGITAL_ID_DOCUMENT_TYPES = Object.keys(DIGITAL_ID_REGISTRY);
|
|
1170
|
-
/**
|
|
1171
|
-
* Single place that widens `config.digitalIds` to the shapes the backend
|
|
1172
|
-
* actually sends — the mapped array or the raw `{ enabled, methods }` object.
|
|
1173
|
-
* Shared so the cast is written once.
|
|
1174
|
-
*/
|
|
1175
|
-
function asDigitalIdsConfig(config) {
|
|
1176
|
-
return config.digitalIds;
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Tolerant view over `config.digitalIds`: accepts both the mapped array
|
|
1180
|
-
* (`IdCaptureDigitalIdMethod[]`) and the raw backend object
|
|
1181
|
-
* (`{ enabled, methods: [...] }`). Extracted from the old
|
|
1182
|
-
* `getDigitalIdRedirectMethod` cast so every consumer parses it the same way.
|
|
1183
|
-
*/
|
|
1184
|
-
function normalizeDigitalIdMethods(config) {
|
|
1185
|
-
const raw = asDigitalIdsConfig(config);
|
|
1186
|
-
return Array.isArray(raw) ? raw : raw?.methods ?? [];
|
|
1187
|
-
}
|
|
1188
|
-
/**
|
|
1189
|
-
* Persisted method names of the Incode-native device wallets — the backend
|
|
1190
|
-
* `DigitalIdMethodCatalog` entries of type `MDL`. A catalog-enriched method
|
|
1191
|
-
* carries `type: 'MDL'` instead of relying on the name; both are honoured.
|
|
1192
|
-
*/
|
|
1193
|
-
const DEVICE_WALLET_METHODS = /* @__PURE__ */ new Set([
|
|
1194
|
-
"APPLE_WALLET",
|
|
1195
|
-
"GOOGLE_WALLET",
|
|
1196
|
-
"CA_DMV_WALLET"
|
|
1197
|
-
]);
|
|
1198
|
-
/**
|
|
1199
|
-
* True for a configured method the native device-wallet handshake can fulfil.
|
|
1200
|
-
* Redirect methods (iDIN, FTN) never count, whatever their name or type — they
|
|
1201
|
-
* must not surface a wallet tile with no wallet behind it.
|
|
1202
|
-
*
|
|
1203
|
-
* Honors the method's own dashboard toggle: `enabled: false` is off, absent
|
|
1204
|
-
* counts as on. The container's `digitalIds.enabled` switch is checked by
|
|
1205
|
-
* `hasEnabledDeviceWalletMethod` before the list is walked.
|
|
1206
|
-
*/
|
|
1207
|
-
function isEnabledDeviceWalletMethod(method) {
|
|
1208
|
-
if (method.enabled === false) return false;
|
|
1209
|
-
if (method.flowType && isRedirectFlowType(method.flowType)) return false;
|
|
1210
|
-
if (method.type?.toUpperCase() === "MDL") return true;
|
|
1211
|
-
return method.method !== void 0 && DEVICE_WALLET_METHODS.has(method.method.toUpperCase());
|
|
1212
|
-
}
|
|
1213
|
-
/**
|
|
1214
|
-
* Whether a device wallet is enabled for this ID-capture config: the coarse
|
|
1215
|
-
* `deviceWallet` flag, or an enabled wallet method in `config.digitalIds`.
|
|
1216
|
-
*
|
|
1217
|
-
* The dashboard persists a wallet only in `digitalIds.methods` and leaves the
|
|
1218
|
-
* legacy `deviceWallet` / `appleWallet` booleans at their stored `false`. The
|
|
1219
|
-
* backend derives the booleans from `digitalIds` for the flow response, but
|
|
1220
|
-
* the workflow-node response historically shipped them raw — so a workflow
|
|
1221
|
-
* with Apple Wallet enabled arrived here as `deviceWallet: false`, and the
|
|
1222
|
-
* tile was dropped while SDK 1 (which reads `digitalIds` itself) showed it.
|
|
1223
|
-
* Mirrors the backend's own `deriveDeviceWalletFlag`, minus its "unknown
|
|
1224
|
-
* method counts as a wallet" fallback: an unrecognised method must not
|
|
1225
|
-
* launch a handshake that cannot know what to request.
|
|
1226
|
-
*/
|
|
1227
|
-
function isDeviceWalletEnabled(config) {
|
|
1228
|
-
if (config.deviceWallet === true) return true;
|
|
1229
|
-
return hasEnabledDeviceWalletMethod(config);
|
|
1230
|
-
}
|
|
1231
|
-
/** Whether a funnel entry is activated by config + platform capabilities. */
|
|
1232
|
-
function isEntryActive(entry, config, platform) {
|
|
1233
|
-
if (entry.kind === "incodeWallet") return isDeviceWalletEnabled(config) && platform.credentialsAvailable;
|
|
1234
|
-
return findConfiguredMethod(entry, config) !== void 0;
|
|
1235
|
-
}
|
|
1236
|
-
/**
|
|
1237
|
-
* The configured `digitalIds` method matching a Trinsic funnel entry — by
|
|
1238
|
-
* persisted method name, or (mapped shape) by provider id on a redirect
|
|
1239
|
-
* flowType. Mirrors the old first-match semantics; `methods[].enabled` is
|
|
1240
|
-
* deliberately still not consulted (pre-existing behavior).
|
|
1241
|
-
*/
|
|
1242
|
-
function findConfiguredMethod(entry, config) {
|
|
1243
|
-
return normalizeDigitalIdMethods(config).find((method) => method.method?.toUpperCase() === entry.method || method.provider === entry.providerId && !!method.flowType && isRedirectFlowType(method.flowType));
|
|
1244
|
-
}
|
|
1245
|
-
/** Normalizes a raw configured method into the mapped shape for the child input. */
|
|
1246
|
-
function toMappedMethod(entry, method) {
|
|
1247
|
-
if (method.flowType && isRedirectFlowType(method.flowType)) return method;
|
|
1248
|
-
return {
|
|
1249
|
-
method: method.method,
|
|
1250
|
-
provider: entry.providerId,
|
|
1251
|
-
flowType: "WEB_REDIRECT",
|
|
1252
|
-
country: method.country ?? method.countries?.[0],
|
|
1253
|
-
displayName: method.displayName
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
|
-
/**
|
|
1257
|
-
* True when `config.digitalIds` carries a device-wallet method that is switched
|
|
1258
|
-
* on, honouring both dashboard toggles: the `digitalIds.enabled` master switch
|
|
1259
|
-
* and each method's own `enabled` flag. An absent `enabled` counts as on, the
|
|
1260
|
-
* tolerant reading the rest of this module uses.
|
|
1261
|
-
*
|
|
1262
|
-
* The toggles are applied here rather than inside `normalizeDigitalIdMethods`
|
|
1263
|
-
* because that helper also feeds the redirect funnel, which today deliberately
|
|
1264
|
-
* ignores `methods[].enabled`; widening it would change redirect behaviour as a
|
|
1265
|
-
* side effect of a wallet fix. Fold this into `normalizeDigitalIdMethods` once
|
|
1266
|
-
* every consumer is meant to skip disabled methods.
|
|
1267
|
-
*/
|
|
1268
|
-
function hasEnabledDeviceWalletMethod(config) {
|
|
1269
|
-
const raw = asDigitalIdsConfig(config);
|
|
1270
|
-
if (!Array.isArray(raw) && raw?.enabled === false) return false;
|
|
1271
|
-
return normalizeDigitalIdMethods(config).some(isEnabledDeviceWalletMethod);
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* Resolves the implementation that should fulfil a digital-ID document type:
|
|
1275
|
-
* the first funnel entry that is active under the given config and platform.
|
|
1276
|
-
* `undefined` when nothing can run it (the chooser then shows no tile for it).
|
|
1277
|
-
*/
|
|
1278
|
-
function resolveDigitalIdImplementation(docType, config, platform) {
|
|
1279
|
-
for (const entry of DIGITAL_ID_REGISTRY[docType]) {
|
|
1280
|
-
if (!isEntryActive(entry, config, platform)) continue;
|
|
1281
|
-
if (entry.kind === "incodeWallet") return { kind: "incodeWallet" };
|
|
1282
|
-
const method = findConfiguredMethod(entry, config);
|
|
1283
|
-
return {
|
|
1284
|
-
kind: "trinsicRedirect",
|
|
1285
|
-
providerId: entry.providerId,
|
|
1286
|
-
method: method ? toMappedMethod(entry, method) : void 0
|
|
1287
|
-
};
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
//#endregion
|
|
1291
|
-
//#region src/modules/id/idCaptureHelpers.ts
|
|
1292
|
-
/**
|
|
1293
|
-
* Persisted method name → catalog provider id, derived from the digital-ID
|
|
1294
|
-
* registry's Trinsic entries (single source of truth — was a hardcoded map
|
|
1295
|
-
* here before the registry existed).
|
|
1296
|
-
*/
|
|
1297
|
-
const REDIRECT_PROVIDER_BY_METHOD = (() => {
|
|
1298
|
-
const map = {};
|
|
1299
|
-
for (const docType of DIGITAL_ID_DOCUMENT_TYPES) for (const entry of DIGITAL_ID_REGISTRY[docType]) if (entry.kind === "trinsicRedirect") map[entry.method] = entry.providerId;
|
|
1300
|
-
return map;
|
|
1301
|
-
})();
|
|
1302
|
-
/**
|
|
1303
|
-
* The first enabled web-redirect digital-ID method (iDIN-only for now), or
|
|
1304
|
-
* `undefined` when none is configured. Drives both the `digitalIdRedirect`
|
|
1305
|
-
* chooser option and the provider passed to the `digitalIdRedirectMachine`.
|
|
1306
|
-
*
|
|
1307
|
-
* Accepts both the mapped array (`IdCaptureDigitalIdMethod[]`) and the raw
|
|
1308
|
-
* backend `configuration.digitalIds` object (`{ enabled, methods: [...] }`);
|
|
1309
|
-
* for the raw shape it derives `provider`/`flowType` from the persisted method
|
|
1310
|
-
* name via the digital-ID registry (`IDIN` → `trinsic_netherlands_idin`,
|
|
1311
|
-
* `WEB_REDIRECT`).
|
|
1312
|
-
*/
|
|
1313
|
-
function getDigitalIdRedirectMethod(config) {
|
|
1314
|
-
for (const method of normalizeDigitalIdMethods(config)) {
|
|
1315
|
-
if (method.flowType && isRedirectFlowType(method.flowType)) return method;
|
|
1316
|
-
const provider = method.method ? REDIRECT_PROVIDER_BY_METHOD[method.method.toUpperCase()] : void 0;
|
|
1317
|
-
if (provider) return {
|
|
1318
|
-
method: method.method,
|
|
1319
|
-
provider,
|
|
1320
|
-
flowType: "WEB_REDIRECT",
|
|
1321
|
-
country: method.country ?? method.countries?.[0],
|
|
1322
|
-
displayName: method.displayName
|
|
1323
|
-
};
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
/**
|
|
1327
|
-
* Map of config properties received from the backend to adjusted, internal document types.
|
|
1328
|
-
*/
|
|
1329
|
-
const DOCUMENT_TYPES_CONFIG_TO_ADJUSTED_MAP = [
|
|
1330
|
-
["enableId", "id"],
|
|
1331
|
-
["enablePassport", "passport"],
|
|
1332
|
-
["manualUploadIdCapture", "manualIdUpload"],
|
|
1333
|
-
["digitalIdsUpload", "digitalIdUpload"]
|
|
1334
|
-
];
|
|
1335
|
-
/**
|
|
1336
|
-
* Returns the list of document types enabled by config for the chooser screen, in display order.
|
|
1337
|
-
* Used to populate chooser state so UI and headless consumers can render the correct options.
|
|
1338
|
-
*
|
|
1339
|
-
* Digital-ID document types (device wallet, Trinsic web-redirect) come from
|
|
1340
|
-
* the digital-ID registry funnel: each registry document type contributes the
|
|
1341
|
-
* tile of its first active implementation. A `deviceWallet: true` config on a
|
|
1342
|
-
* platform without the Credentials API therefore shows the Trinsic fallback
|
|
1343
|
-
* tile when one is configured — or no tile at all, instead of a dead-end one.
|
|
1344
|
-
*
|
|
1345
|
-
* @param config - ID capture configuration (from flow or init)
|
|
1346
|
-
* @param platform - Platform capabilities consulted by the digital-ID funnel.
|
|
1347
|
-
* Defaults to no Credentials API for pure-node callers; the machine passes
|
|
1348
|
-
* the real capability check.
|
|
1349
|
-
* @returns Array of IdDocumentType values that should be shown in the document type chooser
|
|
1350
|
-
*/
|
|
1351
|
-
function getAvailableDocumentTypes(config, platform = { credentialsAvailable: false }) {
|
|
1352
|
-
if (config.onlyBack && config.manualUploadIdCapture) return config.enableId ? ["id", "manualIdUpload"] : ["manualIdUpload"];
|
|
1353
|
-
const adjustedDocumentTypes = [];
|
|
1354
|
-
for (const [configProperty, adjustedType] of DOCUMENT_TYPES_CONFIG_TO_ADJUSTED_MAP) if (config[configProperty]) adjustedDocumentTypes.push(adjustedType);
|
|
1355
|
-
for (const docType of DIGITAL_ID_DOCUMENT_TYPES) {
|
|
1356
|
-
const route = resolveDigitalIdImplementation(docType, config, platform);
|
|
1357
|
-
if (!route) continue;
|
|
1358
|
-
const documentType = route.kind === "incodeWallet" ? "digitalId" : "digitalIdRedirect";
|
|
1359
|
-
if (!adjustedDocumentTypes.includes(documentType)) adjustedDocumentTypes.push(documentType);
|
|
1360
|
-
}
|
|
1361
|
-
return adjustedDocumentTypes;
|
|
1362
|
-
}
|
|
1363
|
-
/**
|
|
1364
|
-
* Which manual-upload tabs to show. Falls back to both tabs when neither
|
|
1365
|
-
* `enableId` nor `enablePassport` is set (no accepted documents).
|
|
1366
|
-
*/
|
|
1367
|
-
function getManualUploadTabs(config) {
|
|
1368
|
-
if (config.onlyBack) return {
|
|
1369
|
-
showIdTab: true,
|
|
1370
|
-
showPassportTab: false
|
|
1371
|
-
};
|
|
1372
|
-
const showIdTab = !!config.enableId;
|
|
1373
|
-
const showPassportTab = !!config.enablePassport;
|
|
1374
|
-
if (!showIdTab && !showPassportTab) return {
|
|
1375
|
-
showIdTab: true,
|
|
1376
|
-
showPassportTab: true
|
|
1377
|
-
};
|
|
1378
|
-
return {
|
|
1379
|
-
showIdTab,
|
|
1380
|
-
showPassportTab
|
|
1381
|
-
};
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Computes `idCaptureMachine`'s terminal output — the downstream module-skip
|
|
1385
|
-
* signal read by the Flow orchestrator (via `runChildModule`'s `MODULE_COMPLETE`).
|
|
1386
|
-
*
|
|
1387
|
-
* `skipFaceMatch` is set ONLY for the US Smart Capture *camera back-only* path:
|
|
1388
|
-
* a back image was captured on-device (`capturedImages.back`) and no front was
|
|
1389
|
-
* (`!capturedImages.front`) — "no front, no ID face, no match".
|
|
1390
|
-
*
|
|
1391
|
-
* Requiring a captured back is deliberate and load-bearing: the manual-upload
|
|
1392
|
-
* and digital-ID-upload paths submit a full ID (front face present) but do NOT
|
|
1393
|
-
* populate `capturedImages` (only the camera path does). Gating on a captured
|
|
1394
|
-
* back excludes those upload paths so a real ID-vs-selfie match is never
|
|
1395
|
-
* silently skipped. `capturedImages.front`/`forceFrontIdCapture` alone are not
|
|
1396
|
-
* enough (a later front upload clears the request; uploads set neither field).
|
|
1397
|
-
*
|
|
1398
|
-
* Always `false` outside US Smart Capture. The selfie/face capture itself is
|
|
1399
|
-
* unaffected — only the ID-vs-selfie match is skipped.
|
|
1400
|
-
*
|
|
1401
|
-
* Also `true` on the Digital ID web-redirect (Trinsic iDIN/FTN) COMPLETED path
|
|
1402
|
-
* when the scheme returned no portrait (`isDigitalIdRedirect && !portraitPresent`,
|
|
1403
|
-
* FM-1/FM-2): there is no ID face to match the selfie against.
|
|
1404
|
-
*/
|
|
1405
|
-
function computeIdCaptureOutput(context) {
|
|
1406
|
-
const frontIdCaptured = Boolean(context.capturedImages.front);
|
|
1407
|
-
const backIdCaptured = Boolean(context.capturedImages.back);
|
|
1408
|
-
return {
|
|
1409
|
-
frontIdCaptured,
|
|
1410
|
-
skipFaceMatch: context.isDigitalIdRedirect === true && context.portraitPresent !== true || context.config.usSmartCapture === true && backIdCaptured && !frontIdCaptured
|
|
1411
|
-
};
|
|
1412
|
-
}
|
|
1413
|
-
//#endregion
|
|
1414
728
|
//#region src/modules/id/idDetectionNotificationController.ts
|
|
1415
729
|
const NOTIFICATION_DURATION_MS = 500;
|
|
1416
730
|
function isReportedIdSideWrong(currentMode, reportedSide) {
|
|
@@ -1848,7 +1162,7 @@ fromPromise(async ({ input }) => {
|
|
|
1848
1162
|
});
|
|
1849
1163
|
fromPromise(async ({ input }) => {
|
|
1850
1164
|
if (!input.dependencies) return;
|
|
1851
|
-
const { loadDeepsightSession } = await import("./deepsightLoader-
|
|
1165
|
+
const { loadDeepsightSession } = await import("./deepsightLoader-_UsfC4N5.esm.js");
|
|
1852
1166
|
return loadDeepsightSession({
|
|
1853
1167
|
ds: input.ds,
|
|
1854
1168
|
storage: input.dependencies.storage,
|
|
@@ -2291,7 +1605,7 @@ function cleanup(service) {
|
|
|
2291
1605
|
service.cleanup();
|
|
2292
1606
|
} catch {}
|
|
2293
1607
|
}
|
|
2294
|
-
function createIdMetadataPreparationCoordinator(load = async (input) => (await import("./deepsightLoader-
|
|
1608
|
+
function createIdMetadataPreparationCoordinator(load = async (input) => (await import("./deepsightLoader-_UsfC4N5.esm.js")).loadDeepsightSession(input)) {
|
|
2295
1609
|
let disposed = false;
|
|
2296
1610
|
let preparation;
|
|
2297
1611
|
let service;
|
|
@@ -3143,52 +2457,309 @@ function createProtectedIdAttemptInput(input) {
|
|
|
3143
2457
|
}
|
|
3144
2458
|
};
|
|
3145
2459
|
}
|
|
3146
|
-
function protectedIdResultToCaptureResponse(result) {
|
|
3147
|
-
const regulationType = result.regulationType === "US" || result.regulationType === "Worldwide" || result.regulationType === "Other" || result.regulationType === "US_Illinois" || result.regulationType === "US_Texas" || result.regulationType === "US_California" || result.regulationType === "US_Washington" ? result.regulationType : void 0;
|
|
2460
|
+
function protectedIdResultToCaptureResponse(result) {
|
|
2461
|
+
const regulationType = result.regulationType === "US" || result.regulationType === "Worldwide" || result.regulationType === "Other" || result.regulationType === "US_Illinois" || result.regulationType === "US_Texas" || result.regulationType === "US_California" || result.regulationType === "US_Washington" ? result.regulationType : void 0;
|
|
2462
|
+
return {
|
|
2463
|
+
sharpness: result.sharpness ?? 0,
|
|
2464
|
+
correctSharpness: result.sharpness != null && result.sharpness >= 10,
|
|
2465
|
+
glare: result.glare ?? 0,
|
|
2466
|
+
correctGlare: result.glare != null && result.glare >= 10,
|
|
2467
|
+
horizontalResolution: 0,
|
|
2468
|
+
classification: result.classification === true,
|
|
2469
|
+
readability: result.readability === true,
|
|
2470
|
+
typeOfId: result.typeOfId ?? "",
|
|
2471
|
+
issueYear: 0,
|
|
2472
|
+
issueName: "",
|
|
2473
|
+
sessionStatus: result.sessionStatus ?? "",
|
|
2474
|
+
countryCode: result.countryCode ?? "",
|
|
2475
|
+
skipBackIdCapture: result.skipBackIdCapture,
|
|
2476
|
+
skipGlareFront: result.skipGlareFront,
|
|
2477
|
+
skipGlareBack: result.skipGlareBack,
|
|
2478
|
+
acceptedDocuments: result.acceptedDocuments ? [...result.acceptedDocuments] : void 0,
|
|
2479
|
+
forceFrontIdCapture: result.forceFrontIdCapture,
|
|
2480
|
+
idValidationCompleted: result.idValidationCompleted,
|
|
2481
|
+
showMandatoryConsent: result.showMandatoryConsent,
|
|
2482
|
+
regulationType,
|
|
2483
|
+
failReason: result.failReason,
|
|
2484
|
+
side: result.side,
|
|
2485
|
+
idQualityAttemptApproved: result.idQualityAttemptApproved,
|
|
2486
|
+
isDocumentExpired: result.isDocumentExpired,
|
|
2487
|
+
success: result.success
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
function getProtectedIdUploadRequest(context, sessionToken = getToken()) {
|
|
2491
|
+
const target = resolveProtectedIdTarget(context.config, context.currentMode);
|
|
2492
|
+
const front = context.currentMode !== "back";
|
|
2493
|
+
const params = {};
|
|
2494
|
+
if (front && context.config.onlyFront === true) params.onlyFront = true;
|
|
2495
|
+
if (front && context.config.extractIdFace === false) params.extractIdFace = false;
|
|
2496
|
+
const sharpness = context.qualityElements?.sharpness;
|
|
2497
|
+
if (sharpness !== void 0 && sharpness !== 0 && Number.isFinite(sharpness)) params.sharpness = getRealQualityValue(sharpness);
|
|
2498
|
+
const config = {
|
|
2499
|
+
...sessionToken ? { headers: { "X-Incode-Hardware-Id": sessionToken } } : {},
|
|
2500
|
+
...Object.keys(params).length > 0 ? { params } : {}
|
|
2501
|
+
};
|
|
2502
|
+
return Object.keys(config).length > 0 ? {
|
|
2503
|
+
target,
|
|
2504
|
+
config
|
|
2505
|
+
} : { target };
|
|
2506
|
+
}
|
|
2507
|
+
//#endregion
|
|
2508
|
+
//#region src/modules/id/digitalIdRegistry.ts
|
|
2509
|
+
/**
|
|
2510
|
+
* True when a digital-ID method uses a full-page web-redirect flow (Trinsic
|
|
2511
|
+
* iDIN/FTN). Accepts both the module `FlowType` value (`REDIRECT`) and the
|
|
2512
|
+
* backend value (`WEB_REDIRECT`). (Lives here rather than in
|
|
2513
|
+
* `idCaptureHelpers` to keep the registry free of circular imports; the
|
|
2514
|
+
* helpers re-export it.)
|
|
2515
|
+
*/
|
|
2516
|
+
function isRedirectFlowType(flowType) {
|
|
2517
|
+
return flowType === "REDIRECT" || flowType === "WEB_REDIRECT";
|
|
2518
|
+
}
|
|
2519
|
+
const DIGITAL_ID_REGISTRY = {
|
|
2520
|
+
mDL: [{
|
|
2521
|
+
kind: "incodeWallet",
|
|
2522
|
+
documentType: "digitalId"
|
|
2523
|
+
}, {
|
|
2524
|
+
kind: "trinsicRedirect",
|
|
2525
|
+
documentType: "digitalIdRedirect",
|
|
2526
|
+
providerId: "trinsic_mdl_placeholder",
|
|
2527
|
+
method: "MDL"
|
|
2528
|
+
}],
|
|
2529
|
+
iDIN: [{
|
|
2530
|
+
kind: "trinsicRedirect",
|
|
2531
|
+
documentType: "digitalIdRedirect",
|
|
2532
|
+
providerId: "trinsic_netherlands_idin",
|
|
2533
|
+
method: "IDIN"
|
|
2534
|
+
}],
|
|
2535
|
+
FTN: [{
|
|
2536
|
+
kind: "trinsicRedirect",
|
|
2537
|
+
documentType: "digitalIdRedirect",
|
|
2538
|
+
providerId: "trinsic_finnish_trust_network",
|
|
2539
|
+
method: "FTN"
|
|
2540
|
+
}]
|
|
2541
|
+
};
|
|
2542
|
+
const DIGITAL_ID_DOCUMENT_TYPES = Object.keys(DIGITAL_ID_REGISTRY);
|
|
2543
|
+
/**
|
|
2544
|
+
* Single place that widens `config.digitalIds` to the shapes the backend
|
|
2545
|
+
* actually sends — the mapped array or the raw `{ enabled, methods }` object.
|
|
2546
|
+
* Shared so the cast is written once.
|
|
2547
|
+
*/
|
|
2548
|
+
function asDigitalIdsConfig(config) {
|
|
2549
|
+
return config.digitalIds;
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Tolerant view over `config.digitalIds`: accepts both the mapped array
|
|
2553
|
+
* (`IdCaptureDigitalIdMethod[]`) and the raw backend object
|
|
2554
|
+
* (`{ enabled, methods: [...] }`). Extracted from the old
|
|
2555
|
+
* `getDigitalIdRedirectMethod` cast so every consumer parses it the same way.
|
|
2556
|
+
*/
|
|
2557
|
+
function normalizeDigitalIdMethods(config) {
|
|
2558
|
+
const raw = asDigitalIdsConfig(config);
|
|
2559
|
+
return Array.isArray(raw) ? raw : raw?.methods ?? [];
|
|
2560
|
+
}
|
|
2561
|
+
/**
|
|
2562
|
+
* Persisted method names of the Incode-native device wallets — the backend
|
|
2563
|
+
* `DigitalIdMethodCatalog` entries of type `MDL`. A catalog-enriched method
|
|
2564
|
+
* carries `type: 'MDL'` instead of relying on the name; both are honoured.
|
|
2565
|
+
*/
|
|
2566
|
+
const DEVICE_WALLET_METHODS = /* @__PURE__ */ new Set([
|
|
2567
|
+
"APPLE_WALLET",
|
|
2568
|
+
"GOOGLE_WALLET",
|
|
2569
|
+
"CA_DMV_WALLET"
|
|
2570
|
+
]);
|
|
2571
|
+
/**
|
|
2572
|
+
* True for a configured method the native device-wallet handshake can fulfil.
|
|
2573
|
+
* Redirect methods (iDIN, FTN) never count, whatever their name or type — they
|
|
2574
|
+
* must not surface a wallet tile with no wallet behind it.
|
|
2575
|
+
*
|
|
2576
|
+
* Honors the method's own dashboard toggle: `enabled: false` is off, absent
|
|
2577
|
+
* counts as on. The container's `digitalIds.enabled` switch is checked by
|
|
2578
|
+
* `hasEnabledDeviceWalletMethod` before the list is walked.
|
|
2579
|
+
*/
|
|
2580
|
+
function isEnabledDeviceWalletMethod(method) {
|
|
2581
|
+
if (method.enabled === false) return false;
|
|
2582
|
+
if (method.flowType && isRedirectFlowType(method.flowType)) return false;
|
|
2583
|
+
if (method.type?.toUpperCase() === "MDL") return true;
|
|
2584
|
+
return method.method !== void 0 && DEVICE_WALLET_METHODS.has(method.method.toUpperCase());
|
|
2585
|
+
}
|
|
2586
|
+
/**
|
|
2587
|
+
* Whether a device wallet is enabled for this ID-capture config: the coarse
|
|
2588
|
+
* `deviceWallet` flag, or an enabled wallet method in `config.digitalIds`.
|
|
2589
|
+
*
|
|
2590
|
+
* The dashboard persists a wallet only in `digitalIds.methods` and leaves the
|
|
2591
|
+
* legacy `deviceWallet` / `appleWallet` booleans at their stored `false`. The
|
|
2592
|
+
* backend derives the booleans from `digitalIds` for the flow response, but
|
|
2593
|
+
* the workflow-node response historically shipped them raw — so a workflow
|
|
2594
|
+
* with Apple Wallet enabled arrived here as `deviceWallet: false`, and the
|
|
2595
|
+
* tile was dropped while SDK 1 (which reads `digitalIds` itself) showed it.
|
|
2596
|
+
* Mirrors the backend's own `deriveDeviceWalletFlag`, minus its "unknown
|
|
2597
|
+
* method counts as a wallet" fallback: an unrecognised method must not
|
|
2598
|
+
* launch a handshake that cannot know what to request.
|
|
2599
|
+
*/
|
|
2600
|
+
function isDeviceWalletEnabled(config) {
|
|
2601
|
+
if (config.deviceWallet === true) return true;
|
|
2602
|
+
return hasEnabledDeviceWalletMethod(config);
|
|
2603
|
+
}
|
|
2604
|
+
/** Whether a funnel entry is activated by config + platform capabilities. */
|
|
2605
|
+
function isEntryActive(entry, config, platform) {
|
|
2606
|
+
if (entry.kind === "incodeWallet") return isDeviceWalletEnabled(config) && platform.credentialsAvailable;
|
|
2607
|
+
return findConfiguredMethod(entry, config) !== void 0;
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* The configured `digitalIds` method matching a Trinsic funnel entry — by
|
|
2611
|
+
* persisted method name, or (mapped shape) by provider id on a redirect
|
|
2612
|
+
* flowType. Mirrors the old first-match semantics; `methods[].enabled` is
|
|
2613
|
+
* deliberately still not consulted (pre-existing behavior).
|
|
2614
|
+
*/
|
|
2615
|
+
function findConfiguredMethod(entry, config) {
|
|
2616
|
+
return normalizeDigitalIdMethods(config).find((method) => method.method?.toUpperCase() === entry.method || method.provider === entry.providerId && !!method.flowType && isRedirectFlowType(method.flowType));
|
|
2617
|
+
}
|
|
2618
|
+
/** Normalizes a raw configured method into the mapped shape for the child input. */
|
|
2619
|
+
function toMappedMethod(entry, method) {
|
|
2620
|
+
if (method.flowType && isRedirectFlowType(method.flowType)) return method;
|
|
3148
2621
|
return {
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
classification: result.classification === true,
|
|
3155
|
-
readability: result.readability === true,
|
|
3156
|
-
typeOfId: result.typeOfId ?? "",
|
|
3157
|
-
issueYear: 0,
|
|
3158
|
-
issueName: "",
|
|
3159
|
-
sessionStatus: result.sessionStatus ?? "",
|
|
3160
|
-
countryCode: result.countryCode ?? "",
|
|
3161
|
-
skipBackIdCapture: result.skipBackIdCapture,
|
|
3162
|
-
skipGlareFront: result.skipGlareFront,
|
|
3163
|
-
skipGlareBack: result.skipGlareBack,
|
|
3164
|
-
acceptedDocuments: result.acceptedDocuments ? [...result.acceptedDocuments] : void 0,
|
|
3165
|
-
forceFrontIdCapture: result.forceFrontIdCapture,
|
|
3166
|
-
idValidationCompleted: result.idValidationCompleted,
|
|
3167
|
-
showMandatoryConsent: result.showMandatoryConsent,
|
|
3168
|
-
regulationType,
|
|
3169
|
-
failReason: result.failReason,
|
|
3170
|
-
side: result.side,
|
|
3171
|
-
idQualityAttemptApproved: result.idQualityAttemptApproved,
|
|
3172
|
-
isDocumentExpired: result.isDocumentExpired,
|
|
3173
|
-
success: result.success
|
|
2622
|
+
method: method.method,
|
|
2623
|
+
provider: entry.providerId,
|
|
2624
|
+
flowType: "WEB_REDIRECT",
|
|
2625
|
+
country: method.country ?? method.countries?.[0],
|
|
2626
|
+
displayName: method.displayName
|
|
3174
2627
|
};
|
|
3175
2628
|
}
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
2629
|
+
/**
|
|
2630
|
+
* True when `config.digitalIds` carries a device-wallet method that is switched
|
|
2631
|
+
* on, honouring both dashboard toggles: the `digitalIds.enabled` master switch
|
|
2632
|
+
* and each method's own `enabled` flag. An absent `enabled` counts as on, the
|
|
2633
|
+
* tolerant reading the rest of this module uses.
|
|
2634
|
+
*
|
|
2635
|
+
* The toggles are applied here rather than inside `normalizeDigitalIdMethods`
|
|
2636
|
+
* because that helper also feeds the redirect funnel, which today deliberately
|
|
2637
|
+
* ignores `methods[].enabled`; widening it would change redirect behaviour as a
|
|
2638
|
+
* side effect of a wallet fix. Fold this into `normalizeDigitalIdMethods` once
|
|
2639
|
+
* every consumer is meant to skip disabled methods.
|
|
2640
|
+
*/
|
|
2641
|
+
function hasEnabledDeviceWalletMethod(config) {
|
|
2642
|
+
const raw = asDigitalIdsConfig(config);
|
|
2643
|
+
if (!Array.isArray(raw) && raw?.enabled === false) return false;
|
|
2644
|
+
return normalizeDigitalIdMethods(config).some(isEnabledDeviceWalletMethod);
|
|
2645
|
+
}
|
|
2646
|
+
/**
|
|
2647
|
+
* Resolves the implementation that should fulfil a digital-ID document type:
|
|
2648
|
+
* the first funnel entry that is active under the given config and platform.
|
|
2649
|
+
* `undefined` when nothing can run it (the chooser then shows no tile for it).
|
|
2650
|
+
*/
|
|
2651
|
+
function resolveDigitalIdImplementation(docType, config, platform) {
|
|
2652
|
+
for (const entry of DIGITAL_ID_REGISTRY[docType]) {
|
|
2653
|
+
if (!isEntryActive(entry, config, platform)) continue;
|
|
2654
|
+
if (entry.kind === "incodeWallet") return { kind: "incodeWallet" };
|
|
2655
|
+
const method = findConfiguredMethod(entry, config);
|
|
2656
|
+
return {
|
|
2657
|
+
kind: "trinsicRedirect",
|
|
2658
|
+
providerId: entry.providerId,
|
|
2659
|
+
method: method ? toMappedMethod(entry, method) : void 0
|
|
2660
|
+
};
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
//#endregion
|
|
2664
|
+
//#region src/modules/id/idCaptureHelpers.ts
|
|
2665
|
+
/**
|
|
2666
|
+
* Persisted method name → catalog provider id, derived from the digital-ID
|
|
2667
|
+
* registry's Trinsic entries (single source of truth — was a hardcoded map
|
|
2668
|
+
* here before the registry existed).
|
|
2669
|
+
*/
|
|
2670
|
+
const REDIRECT_PROVIDER_BY_METHOD = (() => {
|
|
2671
|
+
const map = {};
|
|
2672
|
+
for (const docType of DIGITAL_ID_DOCUMENT_TYPES) for (const entry of DIGITAL_ID_REGISTRY[docType]) if (entry.kind === "trinsicRedirect") map[entry.method] = entry.providerId;
|
|
2673
|
+
return map;
|
|
2674
|
+
})();
|
|
2675
|
+
/**
|
|
2676
|
+
* The first enabled web-redirect digital-ID method (iDIN-only for now), or
|
|
2677
|
+
* `undefined` when none is configured. Drives both the `digitalIdRedirect`
|
|
2678
|
+
* chooser option and the provider passed to the `digitalIdRedirectMachine`.
|
|
2679
|
+
*
|
|
2680
|
+
* Accepts both the mapped array (`IdCaptureDigitalIdMethod[]`) and the raw
|
|
2681
|
+
* backend `configuration.digitalIds` object (`{ enabled, methods: [...] }`);
|
|
2682
|
+
* for the raw shape it derives `provider`/`flowType` from the persisted method
|
|
2683
|
+
* name via the digital-ID registry (`IDIN` → `trinsic_netherlands_idin`,
|
|
2684
|
+
* `WEB_REDIRECT`).
|
|
2685
|
+
*/
|
|
2686
|
+
function getDigitalIdRedirectMethod(config) {
|
|
2687
|
+
for (const method of normalizeDigitalIdMethods(config)) {
|
|
2688
|
+
if (method.flowType && isRedirectFlowType(method.flowType)) return method;
|
|
2689
|
+
const provider = method.method ? REDIRECT_PROVIDER_BY_METHOD[method.method.toUpperCase()] : void 0;
|
|
2690
|
+
if (provider) return {
|
|
2691
|
+
method: method.method,
|
|
2692
|
+
provider,
|
|
2693
|
+
flowType: "WEB_REDIRECT",
|
|
2694
|
+
country: method.country ?? method.countries?.[0],
|
|
2695
|
+
displayName: method.displayName
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
/**
|
|
2700
|
+
* Map of config properties received from the backend to adjusted, internal document types.
|
|
2701
|
+
*/
|
|
2702
|
+
const DOCUMENT_TYPES_CONFIG_TO_ADJUSTED_MAP = [
|
|
2703
|
+
["enableId", "id"],
|
|
2704
|
+
["enablePassport", "passport"],
|
|
2705
|
+
["digitalIdsUpload", "digitalIdUpload"]
|
|
2706
|
+
];
|
|
2707
|
+
/**
|
|
2708
|
+
* Returns the list of document types enabled by config for the chooser screen, in display order.
|
|
2709
|
+
* Used to populate chooser state so UI and headless consumers can render the correct options.
|
|
2710
|
+
*
|
|
2711
|
+
* Digital-ID document types (device wallet, Trinsic web-redirect) come from
|
|
2712
|
+
* the digital-ID registry funnel: each registry document type contributes the
|
|
2713
|
+
* tile of its first active implementation. A `deviceWallet: true` config on a
|
|
2714
|
+
* platform without the Credentials API therefore shows the Trinsic fallback
|
|
2715
|
+
* tile when one is configured — or no tile at all, instead of a dead-end one.
|
|
2716
|
+
*
|
|
2717
|
+
* @param config - ID capture configuration (from flow or init)
|
|
2718
|
+
* @param platform - Platform capabilities consulted by the digital-ID funnel.
|
|
2719
|
+
* Defaults to no Credentials API for pure-node callers; the machine passes
|
|
2720
|
+
* the real capability check.
|
|
2721
|
+
* @returns Array of IdDocumentType values that should be shown in the document type chooser
|
|
2722
|
+
*/
|
|
2723
|
+
function getAvailableDocumentTypes(config, platform = { credentialsAvailable: false }) {
|
|
2724
|
+
const adjustedDocumentTypes = [];
|
|
2725
|
+
for (const [configProperty, adjustedType] of DOCUMENT_TYPES_CONFIG_TO_ADJUSTED_MAP) if (config[configProperty]) adjustedDocumentTypes.push(adjustedType);
|
|
2726
|
+
for (const docType of DIGITAL_ID_DOCUMENT_TYPES) {
|
|
2727
|
+
const route = resolveDigitalIdImplementation(docType, config, platform);
|
|
2728
|
+
if (!route) continue;
|
|
2729
|
+
const documentType = route.kind === "incodeWallet" ? "digitalId" : "digitalIdRedirect";
|
|
2730
|
+
if (!adjustedDocumentTypes.includes(documentType)) adjustedDocumentTypes.push(documentType);
|
|
2731
|
+
}
|
|
2732
|
+
return adjustedDocumentTypes;
|
|
2733
|
+
}
|
|
2734
|
+
/**
|
|
2735
|
+
* Computes `idCaptureMachine`'s terminal output — the downstream module-skip
|
|
2736
|
+
* signal read by the Flow orchestrator (via `runChildModule`'s `MODULE_COMPLETE`).
|
|
2737
|
+
*
|
|
2738
|
+
* `skipFaceMatch` is set ONLY for the US Smart Capture *camera back-only* path:
|
|
2739
|
+
* a back image was captured on-device (`capturedImages.back`) and no front was
|
|
2740
|
+
* (`!capturedImages.front`) — "no front, no ID face, no match".
|
|
2741
|
+
*
|
|
2742
|
+
* Requiring a captured back is deliberate and load-bearing: the digital-ID
|
|
2743
|
+
* upload path submits a full ID (front face present) but does NOT
|
|
2744
|
+
* populate `capturedImages` (only the camera path does). Gating on a captured
|
|
2745
|
+
* back excludes those upload paths so a real ID-vs-selfie match is never
|
|
2746
|
+
* silently skipped. `capturedImages.front`/`forceFrontIdCapture` alone are not
|
|
2747
|
+
* enough (a later front upload clears the request; uploads set neither field).
|
|
2748
|
+
*
|
|
2749
|
+
* Always `false` outside US Smart Capture. The selfie/face capture itself is
|
|
2750
|
+
* unaffected — only the ID-vs-selfie match is skipped.
|
|
2751
|
+
*
|
|
2752
|
+
* Also `true` on the Digital ID web-redirect (Trinsic iDIN/FTN) COMPLETED path
|
|
2753
|
+
* when the scheme returned no portrait (`isDigitalIdRedirect && !portraitPresent`,
|
|
2754
|
+
* FM-1/FM-2): there is no ID face to match the selfie against.
|
|
2755
|
+
*/
|
|
2756
|
+
function computeIdCaptureOutput(context) {
|
|
2757
|
+
const frontIdCaptured = Boolean(context.capturedImages.front);
|
|
2758
|
+
const backIdCaptured = Boolean(context.capturedImages.back);
|
|
2759
|
+
return {
|
|
2760
|
+
frontIdCaptured,
|
|
2761
|
+
skipFaceMatch: context.isDigitalIdRedirect === true && context.portraitPresent !== true || context.config.usSmartCapture === true && backIdCaptured && !frontIdCaptured
|
|
3187
2762
|
};
|
|
3188
|
-
return Object.keys(config).length > 0 ? {
|
|
3189
|
-
target,
|
|
3190
|
-
config
|
|
3191
|
-
} : { target };
|
|
3192
2763
|
}
|
|
3193
2764
|
//#endregion
|
|
3194
2765
|
//#region src/modules/digital-id-redirect/pollCadence.ts
|
|
@@ -3731,7 +3302,6 @@ const idCaptureMachine = setup({
|
|
|
3731
3302
|
uploadProgressTicker: uploadProgressTickerActor,
|
|
3732
3303
|
processId: processIdActor,
|
|
3733
3304
|
submitBarcode: submitBarcodeActor,
|
|
3734
|
-
manualUploadMachine,
|
|
3735
3305
|
digitalUploadMachine,
|
|
3736
3306
|
digitalIdRedirectMachine,
|
|
3737
3307
|
deviceWalletMachine,
|
|
@@ -4158,9 +3728,7 @@ const idCaptureMachine = setup({
|
|
|
4158
3728
|
isDeepsightEnabled: isDeepsightEnabledGuard,
|
|
4159
3729
|
isDeepsightReady: isDeepsightReadyGuard,
|
|
4160
3730
|
needsDeepsightInit: needsDeepsightInitGuard,
|
|
4161
|
-
hasOnlyManualUploadAvailable: hasOnlyManualUploadAvailableGuard,
|
|
4162
3731
|
hasNoDocumentTypesAvailable: hasNoDocumentTypesAvailableGuard,
|
|
4163
|
-
isManualIdUploadSelected: ({ event }) => isManualIdUploadSelectedGuard({ event: asPublicIdEvent(event) }),
|
|
4164
3732
|
isDigitalIdUploadSelected: ({ event }) => isDigitalIdUploadSelectedGuard({ event: asPublicIdEvent(event) }),
|
|
4165
3733
|
isDigitalIdRedirectSelected: ({ event }) => isDigitalIdRedirectSelectedGuard({ event: asPublicIdEvent(event) }),
|
|
4166
3734
|
isDigitalIdSelected: ({ event }) => isDigitalIdSelectedGuard({ event: asPublicIdEvent(event) }),
|
|
@@ -4183,7 +3751,6 @@ const idCaptureMachine = setup({
|
|
|
4183
3751
|
forceFinishAfterProcessing: forceFinishAfterProcessingGuard,
|
|
4184
3752
|
isBackModeInMultiSideFlow: isBackModeInMultiSideFlowGuard,
|
|
4185
3753
|
wasExpiredRedirected: wasExpiredRedirectedGuard,
|
|
4186
|
-
isManualUploadExhausted: ({ event }) => event.output?.result === "exhausted",
|
|
4187
3754
|
isDigitalUploadExhausted: ({ event }) => event.output?.result === "exhausted",
|
|
4188
3755
|
isDigitalUploadSuccessful: ({ event }) => event.output?.result === "success",
|
|
4189
3756
|
isDigitalIdRedirectCompleted: ({ event }) => event.output?.status === "COMPLETED",
|
|
@@ -4308,10 +3875,6 @@ const idCaptureMachine = setup({
|
|
|
4308
3875
|
guard: "hasNoDocumentTypesAvailable",
|
|
4309
3876
|
actions: [() => console.error(ID_CAPTURE_NO_DOCUMENT_TYPES_ERROR), assign({ error: () => ID_CAPTURE_NO_DOCUMENT_TYPES_ERROR })]
|
|
4310
3877
|
},
|
|
4311
|
-
{
|
|
4312
|
-
target: "manualIdUpload",
|
|
4313
|
-
guard: "hasOnlyManualUploadAvailable"
|
|
4314
|
-
},
|
|
4315
3878
|
{
|
|
4316
3879
|
target: "chooser",
|
|
4317
3880
|
guard: "hasShowDocumentChooser"
|
|
@@ -4342,11 +3905,6 @@ const idCaptureMachine = setup({
|
|
|
4342
3905
|
guard: "isDigitalIdUploadSelected",
|
|
4343
3906
|
actions: ["setSelectedDocument"]
|
|
4344
3907
|
},
|
|
4345
|
-
{
|
|
4346
|
-
target: "manualIdUpload",
|
|
4347
|
-
guard: "isManualIdUploadSelected",
|
|
4348
|
-
actions: ["setSelectedDocument"]
|
|
4349
|
-
},
|
|
4350
3908
|
{
|
|
4351
3909
|
target: "ageVerification",
|
|
4352
3910
|
guard: "hasAgeAssurance",
|
|
@@ -5182,35 +4740,6 @@ const idCaptureMachine = setup({
|
|
|
5182
4740
|
actions: "resetContext"
|
|
5183
4741
|
} }
|
|
5184
4742
|
},
|
|
5185
|
-
manualIdUpload: {
|
|
5186
|
-
invoke: {
|
|
5187
|
-
id: "manualIdUpload",
|
|
5188
|
-
src: "manualUploadMachine",
|
|
5189
|
-
input: ({ context }) => ({
|
|
5190
|
-
isSecondId: context.config.isSecondId ?? false,
|
|
5191
|
-
onlyFront: context.config.onlyFront ?? false,
|
|
5192
|
-
onlyBack: context.config.onlyBack ?? false,
|
|
5193
|
-
captureAttempts: context.config.captureAttempts,
|
|
5194
|
-
extractIdFace: context.config.extractIdFace
|
|
5195
|
-
}),
|
|
5196
|
-
onSnapshot: { actions: () => {} },
|
|
5197
|
-
onDone: [{
|
|
5198
|
-
guard: "isManualUploadExhausted",
|
|
5199
|
-
target: "#idCapture.finished"
|
|
5200
|
-
}, { target: "#idCapture.processing" }],
|
|
5201
|
-
onError: {
|
|
5202
|
-
target: "#idCapture.error",
|
|
5203
|
-
actions: assign({ error: ({ event }) => String(event.error) })
|
|
5204
|
-
}
|
|
5205
|
-
},
|
|
5206
|
-
on: {
|
|
5207
|
-
QUIT: { target: "closed" },
|
|
5208
|
-
MANUAL_UPLOAD_TAB_CHANGED: { actions: sendTo("manualIdUpload", ({ event }) => event) },
|
|
5209
|
-
MANUAL_UPLOAD_FILE_SELECTED: { actions: sendTo("manualIdUpload", ({ event }) => event) },
|
|
5210
|
-
MANUAL_UPLOAD_CONTINUE: { actions: sendTo("manualIdUpload", ({ event }) => event) },
|
|
5211
|
-
MANUAL_UPLOAD_RESET: { actions: sendTo("manualIdUpload", ({ event }) => event) }
|
|
5212
|
-
}
|
|
5213
|
-
},
|
|
5214
4743
|
digitalIdUpload: {
|
|
5215
4744
|
invoke: {
|
|
5216
4745
|
id: "digitalIdUpload",
|
|
@@ -5397,4 +4926,4 @@ function provideIdProtectedCaptureController(machine, controller) {
|
|
|
5397
4926
|
});
|
|
5398
4927
|
}
|
|
5399
4928
|
//#endregion
|
|
5400
|
-
export {
|
|
4929
|
+
export { isRedirectFlowType as a, createIdCaptureOnlyDeliveryActor as c, resolveWalletPlatform as d, DIGITAL_ID_REGISTRY as i, createIdProtectedCaptureController as l, provideIdProtectedCaptureController as n, resolveDigitalIdImplementation as o, DIGITAL_ID_DOCUMENT_TYPES as r, attachIdProtectedCaptureController as s, idCaptureMachine as t, findIdProtectedCaptureController as u };
|