@incodetech/core 0.0.0-dev-20260223-138ae97 → 0.0.0-dev-20260224-1accab3

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.
@@ -926,6 +926,11 @@ function performResetForBackCapture(context) {
926
926
  if (context.stream) stopStream(context.stream);
927
927
  context.provider?.reset();
928
928
  }
929
+ function performResetForFrontCapture(context) {
930
+ context.frameCapturer?.dispose();
931
+ if (context.stream) stopStream(context.stream);
932
+ context.provider?.reset();
933
+ }
929
934
  function performResetDetection(context) {
930
935
  context.resetDetection?.();
931
936
  }
@@ -954,7 +959,7 @@ function getFrameCapturerFromEvent(event) {
954
959
  }
955
960
  function getResetContextValues(context) {
956
961
  context.provider?.reset();
957
- const currentMode = context.config.onlyBack ? "back" : !context.config.enableId && context.config.enablePassport ? "passport" : "front";
962
+ const currentMode = context.config.onlyBack ? "back" : !context.config.enableId && context.config.enablePassport ? "passport" : context.config.usSmartCapture ? "back" : "front";
958
963
  return {
959
964
  stream: void 0,
960
965
  provider: context.provider,
@@ -1127,7 +1132,7 @@ function getDetectionStatusFromSideChange(context, side) {
1127
1132
  function getCurrentModeFromEvent(context, event) {
1128
1133
  if ("documentType" in event) {
1129
1134
  if (event.documentType === "passport") return "passport";
1130
- return "front";
1135
+ return context.config.usSmartCapture ? "back" : "front";
1131
1136
  }
1132
1137
  if (event.type === "FRONT_COMPLETE") return "back";
1133
1138
  return context.currentMode;
@@ -1166,9 +1171,11 @@ const shouldContinueToBackGuard = ({ context }) => {
1166
1171
  if (context.currentMode !== "front" && context.currentMode !== "passport") return false;
1167
1172
  if (context.config.onlyFront) return false;
1168
1173
  if (context.config.onlyBack) return false;
1174
+ if (context.config.usSmartCapture) return false;
1169
1175
  if (context.uploadResponse?.skipBackIdCapture) return false;
1170
1176
  return true;
1171
1177
  };
1178
+ const shouldContinueToFrontGuard = ({ context }) => context.config.usSmartCapture === true && context.currentMode === "back" && context.uploadResponse?.forceFrontIdCapture === true;
1172
1179
  const isDeepsightEnabledGuard = ({ context }) => context.dependencies !== void 0;
1173
1180
  const isDeepsightReadyGuard = ({ context }) => context.deepsightService !== void 0;
1174
1181
  const needsDeepsightInitGuard = ({ context }) => context.dependencies !== void 0 && context.deepsightService === void 0 && !context.deepsightInitAttempted;
@@ -1231,6 +1238,24 @@ const _idCaptureMachine = setup({
1231
1238
  manualCaptureTriggered: false
1232
1239
  };
1233
1240
  }),
1241
+ resetForFrontCapture: assign(({ context }) => {
1242
+ performResetForFrontCapture(context);
1243
+ return {
1244
+ stream: void 0,
1245
+ frameCapturer: void 0,
1246
+ detectionStatus: "idle",
1247
+ counterValue: 0,
1248
+ orientation: void 0,
1249
+ resetDetection: void 0,
1250
+ idType: void 0,
1251
+ qualityElements: void 0,
1252
+ debugFrame: void 0,
1253
+ frameRect: void 0,
1254
+ previewImageUrl: void 0,
1255
+ uploadProgress: void 0,
1256
+ manualCaptureTriggered: false
1257
+ };
1258
+ }),
1234
1259
  prepareForBackCapture: assign(({ context }) => {
1235
1260
  context.provider?.reset();
1236
1261
  return {
@@ -1316,6 +1341,7 @@ const _idCaptureMachine = setup({
1316
1341
  isFrontMode: isFrontModeGuard,
1317
1342
  isOnlyFront: isOnlyFrontGuard,
1318
1343
  shouldContinueToBack: shouldContinueToBackGuard,
1344
+ shouldContinueToFront: shouldContinueToFrontGuard,
1319
1345
  isDeepsightEnabled: isDeepsightEnabledGuard,
1320
1346
  isDeepsightReady: isDeepsightReadyGuard,
1321
1347
  needsDeepsightInit: needsDeepsightInitGuard
@@ -1324,7 +1350,7 @@ const _idCaptureMachine = setup({
1324
1350
  id: "idCapture",
1325
1351
  initial: "idle",
1326
1352
  context: ({ input }) => {
1327
- const currentMode = input.config.onlyBack ? "back" : !input.config.enableId && input.config.enablePassport ? "passport" : "front";
1353
+ const currentMode = input.config.onlyBack ? "back" : !input.config.enableId && input.config.enablePassport ? "passport" : input.config.usSmartCapture ? "back" : "front";
1328
1354
  return {
1329
1355
  config: input.config,
1330
1356
  currentMode,
@@ -1822,12 +1848,23 @@ const _idCaptureMachine = setup({
1822
1848
  target: "#idCapture.frontFinished",
1823
1849
  guard: "shouldContinueToBack"
1824
1850
  },
1851
+ {
1852
+ target: "#idCapture.backFinished",
1853
+ guard: "shouldContinueToFront"
1854
+ },
1825
1855
  { target: "#idCapture.finished" }
1826
1856
  ] } },
1827
- success: { on: { NEXT_STEP: [{
1828
- target: "#idCapture.frontFinished",
1829
- guard: "shouldContinueToBack"
1830
- }, { target: "#idCapture.processing" }] } }
1857
+ success: { on: { NEXT_STEP: [
1858
+ {
1859
+ target: "#idCapture.frontFinished",
1860
+ guard: "shouldContinueToBack"
1861
+ },
1862
+ {
1863
+ target: "#idCapture.backFinished",
1864
+ guard: "shouldContinueToFront"
1865
+ },
1866
+ { target: "#idCapture.processing" }
1867
+ ] } }
1831
1868
  }
1832
1869
  },
1833
1870
  frontFinished: {
@@ -1878,6 +1915,54 @@ const _idCaptureMachine = setup({
1878
1915
  guard: "hasStream"
1879
1916
  }, { target: "#idCapture.capture" }]
1880
1917
  },
1918
+ backFinished: {
1919
+ entry: ["stopMediaRecording", "resetForFrontCapture"],
1920
+ type: "parallel",
1921
+ states: {
1922
+ cameraInit: {
1923
+ initial: "checking",
1924
+ states: {
1925
+ checking: { always: [{
1926
+ target: "ready",
1927
+ guard: "hasStream"
1928
+ }, { target: "initializingStream" }] },
1929
+ initializingStream: { invoke: {
1930
+ id: "backFinishedInitCamera",
1931
+ src: "initializeCamera",
1932
+ input: ({ context }) => ({
1933
+ config: context.config,
1934
+ deepsightService: context.deepsightService
1935
+ }),
1936
+ onDone: {
1937
+ target: "ready",
1938
+ actions: "setStreamAndCapturer"
1939
+ },
1940
+ onError: {
1941
+ target: "ready",
1942
+ actions: () => {
1943
+ console.warn("Camera initialization failed during flip transition");
1944
+ }
1945
+ }
1946
+ } },
1947
+ ready: { type: "final" }
1948
+ }
1949
+ },
1950
+ userIntent: {
1951
+ initial: "waiting",
1952
+ states: {
1953
+ waiting: { on: { CONTINUE_TO_FRONT: {
1954
+ target: "clicked",
1955
+ actions: assign({ currentMode: () => "front" })
1956
+ } } },
1957
+ clicked: { type: "final" }
1958
+ }
1959
+ }
1960
+ },
1961
+ onDone: [{
1962
+ target: "#idCapture.capture.detecting",
1963
+ guard: "hasStream"
1964
+ }, { target: "#idCapture.capture" }]
1965
+ },
1881
1966
  processing: {
1882
1967
  entry: "stopMediaStream",
1883
1968
  invoke: {
@@ -2026,7 +2111,8 @@ function mapState(snapshot) {
2026
2111
  if (snapshot.matches("loading")) return { status: "loading" };
2027
2112
  if (snapshot.matches("tutorial")) return {
2028
2113
  status: "tutorial",
2029
- selectedDocumentType: context.selectedDocumentType
2114
+ selectedDocumentType: context.selectedDocumentType,
2115
+ currentMode: context.currentMode
2030
2116
  };
2031
2117
  if (snapshot.matches("closed")) return { status: "closed" };
2032
2118
  if (snapshot.matches("permissions")) {
@@ -2042,7 +2128,8 @@ function mapState(snapshot) {
2042
2128
  }
2043
2129
  if (snapshot.matches("capture")) {
2044
2130
  const captureStatus = getCaptureStatus(snapshot);
2045
- const needsBackCapture = (context.currentMode === "front" || context.currentMode === "passport") && !context.config.onlyFront && !context.config.onlyBack && !context.uploadResponse?.skipBackIdCapture;
2131
+ const needsBackCapture = (context.currentMode === "front" || context.currentMode === "passport") && !context.config.onlyFront && !context.config.onlyBack && !context.uploadResponse?.skipBackIdCapture && !(context.config.usSmartCapture && context.currentMode === "front");
2132
+ const needsFrontCapture = context.config.usSmartCapture === true && context.currentMode === "back" && context.uploadResponse?.forceFrontIdCapture === true;
2046
2133
  return {
2047
2134
  status: "capture",
2048
2135
  captureStatus: captureStatus ?? "initializing",
@@ -2060,11 +2147,13 @@ function mapState(snapshot) {
2060
2147
  uploadErrorMessage: context.uploadError ? getErrorMessage(context.uploadError) : void 0,
2061
2148
  uploadErrorDescription: context.uploadError ? getErrorDescription(context.uploadError, context.uploadResponse) : void 0,
2062
2149
  needsBackCapture,
2150
+ needsFrontCapture,
2063
2151
  showCaptureButtonInAuto: context.config.showCaptureButtonInAuto ?? false,
2064
2152
  canRetry: context.attemptsRemaining > 0
2065
2153
  };
2066
2154
  }
2067
2155
  if (snapshot.matches("frontFinished")) return { status: "frontFinished" };
2156
+ if (snapshot.matches("backFinished")) return { status: "backFinished" };
2068
2157
  if (snapshot.matches("processing")) return { status: "processing" };
2069
2158
  if (snapshot.matches("expired")) return { status: "expired" };
2070
2159
  if (snapshot.matches("finished")) return { status: "finished" };
@@ -2118,6 +2207,9 @@ function createApi({ actor }) {
2118
2207
  continueToBack() {
2119
2208
  actor.send({ type: "CONTINUE_TO_BACK" });
2120
2209
  },
2210
+ continueToFront() {
2211
+ actor.send({ type: "CONTINUE_TO_FRONT" });
2212
+ },
2121
2213
  skipBack() {
2122
2214
  actor.send({ type: "SKIP_BACK" });
2123
2215
  },
package/dist/id.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as IdCaptureGeometry, B as DetectionOrientation, C as DetectionArea, D as IdCaptureContext, E as IdCaptureConfig, F as IdError, I as IdErrorCode, L as IdFlowStep, M as IdCaptureMode, N as IdCaptureThresholds, O as IdCaptureDependencies, P as IdDocumentType, R as RecordingSession, S as CapturedImage, T as ID_ERROR_CODES, V as IdCaptureSettings, _ as IdCaptureActor, a as InitializeIdCaptureParams, b as idCaptureMachine, c as ValidationError, d as startRecordingSession, f as stopRecording, g as CreateIdCaptureActorOptions, h as validateUploadResponse, i as IdCaptureInitResult, j as IdCaptureInput, k as IdCaptureEvent, l as initializeIdCapture, m as uploadIdImage, n as IdCaptureState, o as StartRecordingParams, p as stopStream, r as createIdCaptureManager, s as UploadIdImageParams, t as IdCaptureManager, u as processId, v as createIdCaptureActor, w as DetectionStatus, x as CaptureIdResponse, y as IdCaptureMachine, z as UploadIdResponse } from "./index-CODMcUEs.js";
1
+ import { A as IdCaptureGeometry, B as DetectionOrientation, C as DetectionArea, D as IdCaptureContext, E as IdCaptureConfig, F as IdError, I as IdErrorCode, L as IdFlowStep, M as IdCaptureMode, N as IdCaptureThresholds, O as IdCaptureDependencies, P as IdDocumentType, R as RecordingSession, S as CapturedImage, T as ID_ERROR_CODES, V as IdCaptureSettings, _ as IdCaptureActor, a as InitializeIdCaptureParams, b as idCaptureMachine, c as ValidationError, d as startRecordingSession, f as stopRecording, g as CreateIdCaptureActorOptions, h as validateUploadResponse, i as IdCaptureInitResult, j as IdCaptureInput, k as IdCaptureEvent, l as initializeIdCapture, m as uploadIdImage, n as IdCaptureState, o as StartRecordingParams, p as stopStream, r as createIdCaptureManager, s as UploadIdImageParams, t as IdCaptureManager, u as processId, v as createIdCaptureActor, w as DetectionStatus, x as CaptureIdResponse, y as IdCaptureMachine, z as UploadIdResponse } from "./index-O5gB82Up.js";
2
2
  import "./deepsightService-Un1ZwAHH.js";
3
3
  import { n as PermissionStatus, r as CameraStream, t as PermissionResult } from "./types-ee3LkWku.js";
4
4
  import "./Manager-DM1NlCX4.js";
package/dist/id.esm.js CHANGED
@@ -4,7 +4,7 @@ import "./src-t0pt3B2r.esm.js";
4
4
  import "./endpoints-DXp63GM6.esm.js";
5
5
  import "./deepsightService-Bn05rSAa.esm.js";
6
6
  import "./api-DlSxxyGw.esm.js";
7
- import { a as processId, c as stopStream, d as ID_ERROR_CODES, i as initializeIdCapture, l as uploadIdImage, n as createIdCaptureActor, o as startRecordingSession, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-C4pbzOLZ.esm.js";
7
+ import { a as processId, c as stopStream, d as ID_ERROR_CODES, i as initializeIdCapture, l as uploadIdImage, n as createIdCaptureActor, o as startRecordingSession, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-DCe_Br2-.esm.js";
8
8
  import "./stats-GJMiTm5k.esm.js";
9
9
 
10
10
  export { ID_ERROR_CODES, createIdCaptureActor, createIdCaptureManager, idCaptureMachine, initializeIdCapture, processId, startRecordingSession, stopRecording, stopStream, uploadIdImage, validateUploadResponse };
@@ -165,7 +165,7 @@ interface IIdCaptureCapability extends IMLProviderCapability<IdCaptureConfig$1>
165
165
  //#region src/modules/id/types.d.ts
166
166
  type IdCaptureMode = 'front' | 'back' | 'passport';
167
167
  type IdDocumentType = 'id' | 'passport';
168
- type IdFlowStep = 'chooser' | 'tutorial' | 'permissions' | 'capture' | 'frontFinished' | 'success' | 'processing' | 'expired' | 'finished' | 'error' | 'closed' | 'manualIdUpload' | 'digitalIdUpload';
168
+ type IdFlowStep = 'chooser' | 'tutorial' | 'permissions' | 'capture' | 'frontFinished' | 'backFinished' | 'success' | 'processing' | 'expired' | 'finished' | 'error' | 'closed' | 'manualIdUpload' | 'digitalIdUpload';
169
169
  type DetectionStatus = 'idle' | 'detecting' | 'farAway' | 'blur' | 'glare' | 'wrongSide' | 'capturing' | 'manualCapture' | 'idNotDetected' | 'offline';
170
170
  /**
171
171
  * Represents the detection area dimensions in pixels.
@@ -388,6 +388,8 @@ type IdCaptureEvent = {
388
388
  type: 'FRONT_COMPLETE';
389
389
  } | {
390
390
  type: 'CONTINUE_TO_BACK';
391
+ } | {
392
+ type: 'CONTINUE_TO_FRONT';
391
393
  } | {
392
394
  type: 'PROCESS_COMPLETE';
393
395
  } | {
@@ -508,6 +510,7 @@ type IdCaptureLoadingState = {
508
510
  type IdCaptureTutorialState = {
509
511
  status: 'tutorial';
510
512
  selectedDocumentType: IdDocumentType | undefined;
513
+ currentMode: IdCaptureMode;
511
514
  };
512
515
  type IdCapturePermissionsState = {
513
516
  status: 'permissions';
@@ -531,6 +534,8 @@ type IdCaptureCaptureState = {
531
534
  uploadErrorDescription?: string;
532
535
  /** Whether back capture is needed after front capture completes */
533
536
  needsBackCapture: boolean;
537
+ /** Whether front capture is needed after back capture (usSmartCapture + forceFrontIdCapture) */
538
+ needsFrontCapture: boolean;
534
539
  showCaptureButtonInAuto: boolean;
535
540
  /** Whether retry is available (attemptsRemaining > 0) */
536
541
  canRetry: boolean;
@@ -538,6 +543,9 @@ type IdCaptureCaptureState = {
538
543
  type IdCaptureFrontFinishedState = {
539
544
  status: 'frontFinished';
540
545
  };
546
+ type IdCaptureBackFinishedState = {
547
+ status: 'backFinished';
548
+ };
541
549
  type IdCaptureProcessingState = {
542
550
  status: 'processing';
543
551
  };
@@ -554,7 +562,7 @@ type IdCaptureErrorState = {
554
562
  status: 'error';
555
563
  error: string;
556
564
  };
557
- type IdCaptureState = IdCaptureIdleState | IdCaptureChooserState | IdCaptureLoadingState | IdCaptureTutorialState | IdCapturePermissionsState | IdCaptureCaptureState | IdCaptureFrontFinishedState | IdCaptureProcessingState | IdCaptureExpiredState | IdCaptureFinishedState | IdCaptureClosedState | IdCaptureErrorState;
565
+ type IdCaptureState = IdCaptureIdleState | IdCaptureChooserState | IdCaptureLoadingState | IdCaptureTutorialState | IdCapturePermissionsState | IdCaptureCaptureState | IdCaptureFrontFinishedState | IdCaptureBackFinishedState | IdCaptureProcessingState | IdCaptureExpiredState | IdCaptureFinishedState | IdCaptureClosedState | IdCaptureErrorState;
558
566
  declare function createIdCaptureManager(options: CreateIdCaptureActorOptions): Manager<IdCaptureState> & {
559
567
  load(): void;
560
568
  selectDocument(documentType: IdDocumentType): void;
@@ -569,6 +577,7 @@ declare function createIdCaptureManager(options: CreateIdCaptureActorOptions): M
569
577
  capture(): void;
570
578
  switchToManualCapture(): void;
571
579
  continueToBack(): void;
580
+ continueToFront(): void;
572
581
  skipBack(): void;
573
582
  /**
574
583
  * Updates the detection area used for WASM geometry calculation.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as IdCaptureGeometry, B as DetectionOrientation, C as DetectionArea, D as IdCaptureContext, E as IdCaptureConfig, F as IdError, I as IdErrorCode, L as IdFlowStep, M as IdCaptureMode, N as IdCaptureThresholds, O as IdCaptureDependencies, P as IdDocumentType, R as RecordingSession, S as CapturedImage, T as ID_ERROR_CODES, V as IdCaptureSettings, _ as IdCaptureActor, a as InitializeIdCaptureParams, b as idCaptureMachine, c as ValidationError, d as startRecordingSession, f as stopRecording, g as CreateIdCaptureActorOptions, h as validateUploadResponse, i as IdCaptureInitResult, j as IdCaptureInput, k as IdCaptureEvent, l as initializeIdCapture, m as uploadIdImage, n as IdCaptureState, o as StartRecordingParams, p as stopStream, r as createIdCaptureManager, s as UploadIdImageParams, t as IdCaptureManager, u as processId, v as createIdCaptureActor, w as DetectionStatus, x as CaptureIdResponse, y as IdCaptureMachine, z as UploadIdResponse } from "./index-CODMcUEs.js";
1
+ import { A as IdCaptureGeometry, B as DetectionOrientation, C as DetectionArea, D as IdCaptureContext, E as IdCaptureConfig, F as IdError, I as IdErrorCode, L as IdFlowStep, M as IdCaptureMode, N as IdCaptureThresholds, O as IdCaptureDependencies, P as IdDocumentType, R as RecordingSession, S as CapturedImage, T as ID_ERROR_CODES, V as IdCaptureSettings, _ as IdCaptureActor, a as InitializeIdCaptureParams, b as idCaptureMachine, c as ValidationError, d as startRecordingSession, f as stopRecording, g as CreateIdCaptureActorOptions, h as validateUploadResponse, i as IdCaptureInitResult, j as IdCaptureInput, k as IdCaptureEvent, l as initializeIdCapture, m as uploadIdImage, n as IdCaptureState, o as StartRecordingParams, p as stopStream, r as createIdCaptureManager, s as UploadIdImageParams, t as IdCaptureManager, u as processId, v as createIdCaptureActor, w as DetectionStatus, x as CaptureIdResponse, y as IdCaptureMachine, z as UploadIdResponse } from "./index-O5gB82Up.js";
2
2
  import "./deepsightService-Un1ZwAHH.js";
3
3
  import { n as PermissionStatus, r as CameraStream, t as PermissionResult } from "./types-ee3LkWku.js";
4
4
  import { n as warmupWasm, t as WasmPipeline } from "./warmup-BUv67ifS.js";
package/dist/index.esm.js CHANGED
@@ -4,7 +4,7 @@ import { O as createApi_default, o as warmupWasm, r as WasmUtilProvider } from "
4
4
  import "./endpoints-DXp63GM6.esm.js";
5
5
  import "./deepsightService-Bn05rSAa.esm.js";
6
6
  import { a as resetApi, n as getApi, o as setClient, s as setToken, t as api } from "./api-DlSxxyGw.esm.js";
7
- import { _ as createSession, a as processId, c as stopStream, d as ID_ERROR_CODES, f as getDisableIpify, g as resetSessionInit, h as isSessionInitialized, i as initializeIdCapture, l as uploadIdImage, m as initializeSession, n as createIdCaptureActor, o as startRecordingSession, p as getSessionFeatures, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-C4pbzOLZ.esm.js";
7
+ import { _ as createSession, a as processId, c as stopStream, d as ID_ERROR_CODES, f as getDisableIpify, g as resetSessionInit, h as isSessionInitialized, i as initializeIdCapture, l as uploadIdImage, m as initializeSession, n as createIdCaptureActor, o as startRecordingSession, p as getSessionFeatures, r as idCaptureMachine, s as stopRecording, t as createIdCaptureManager, u as validateUploadResponse } from "./id-DCe_Br2-.esm.js";
8
8
  import "./stats-GJMiTm5k.esm.js";
9
9
 
10
10
  //#region src/setup.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incodetech/core",
3
- "version": "0.0.0-dev-20260223-138ae97",
3
+ "version": "0.0.0-dev-20260224-1accab3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",