astra-sdk-web 1.1.8 → 1.1.9

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.
@@ -219,6 +219,12 @@ function mergeConfig(userConfig) {
219
219
  }
220
220
 
221
221
  // src/services/kycApiService.ts
222
+ var COMPLETED_STEPS = {
223
+ INITIATED: "initiated",
224
+ FACE: "face_scan",
225
+ DOCS: "document_upload",
226
+ COMPLETED: "completed"
227
+ };
222
228
  var KycApiService = class {
223
229
  config;
224
230
  constructor(config) {
@@ -641,7 +647,17 @@ function DocumentUploadModal({ onComplete }) {
641
647
  const checkSession = async () => {
642
648
  if (!apiService) return;
643
649
  try {
644
- await apiService.checkSessionActive();
650
+ const statusResponse = await apiService.getSessionStatus();
651
+ const { completed_steps, next_step, status } = statusResponse.data;
652
+ if (status !== "ACTIVE") {
653
+ throw new Error("Session expired or inactive");
654
+ }
655
+ if (completed_steps.includes(COMPLETED_STEPS.DOCS)) {
656
+ console.log("Document already uploaded");
657
+ }
658
+ if (next_step === COMPLETED_STEPS.FACE && !completed_steps.includes(COMPLETED_STEPS.FACE)) {
659
+ console.warn("Face scan not completed, but in document upload modal");
660
+ }
645
661
  setSessionError(null);
646
662
  } catch (error) {
647
663
  const message = error.message || "Session expired or inactive";
@@ -1087,7 +1103,8 @@ var FaceMeshService = class {
1087
1103
  }
1088
1104
  }
1089
1105
  } else if (state.stage === "DONE") {
1090
- if (absYaw < centerThreshold && insideGuide) {
1106
+ const reducedThreshold = 0.08;
1107
+ if (absYaw < reducedThreshold) {
1091
1108
  state.centerHold += 1;
1092
1109
  if (state.centerHold >= holdFramesCenter && !state.snapTriggered) {
1093
1110
  state.snapTriggered = true;
@@ -1101,11 +1118,7 @@ var FaceMeshService = class {
1101
1118
  } else {
1102
1119
  state.centerHold = 0;
1103
1120
  if (this.callbacks.onLivenessUpdate) {
1104
- if (!insideGuide) {
1105
- this.callbacks.onLivenessUpdate(state.stage, "Center your face inside the circle");
1106
- } else {
1107
- this.callbacks.onLivenessUpdate(state.stage, "Please look straight at the camera");
1108
- }
1121
+ this.callbacks.onLivenessUpdate(state.stage, "Please look straight at the camera");
1109
1122
  }
1110
1123
  }
1111
1124
  }
@@ -1267,7 +1280,7 @@ function useFaceScan(videoRef, canvasRef, callbacks) {
1267
1280
  }, []);
1268
1281
  const handleFaceCapture = React.useCallback(async () => {
1269
1282
  if (!videoRef.current) return;
1270
- const centerThreshold = 0.05;
1283
+ const reducedThreshold = 0.08;
1271
1284
  const currentAbsYaw = livenessStateRef.current.currentAbsYaw;
1272
1285
  if (currentAbsYaw === null || currentAbsYaw === void 0) {
1273
1286
  setState((prev) => ({
@@ -1276,7 +1289,7 @@ function useFaceScan(videoRef, canvasRef, callbacks) {
1276
1289
  }));
1277
1290
  return;
1278
1291
  }
1279
- if (currentAbsYaw >= centerThreshold) {
1292
+ if (currentAbsYaw >= reducedThreshold) {
1280
1293
  setState((prev) => ({
1281
1294
  ...prev,
1282
1295
  livenessInstruction: "Please look straight at the camera before capturing"
@@ -1523,7 +1536,21 @@ function FaceScanModal({ onComplete }) {
1523
1536
  const checkSession = async () => {
1524
1537
  if (!apiService) return;
1525
1538
  try {
1526
- await apiService.checkSessionActive();
1539
+ const statusResponse = await apiService.getSessionStatus();
1540
+ const { completed_steps, next_step, status } = statusResponse.data;
1541
+ if (status !== "ACTIVE") {
1542
+ throw new Error("Session expired or inactive");
1543
+ }
1544
+ if (completed_steps.includes(COMPLETED_STEPS.FACE)) {
1545
+ setState((prev) => ({ ...prev, showDocumentUpload: true }));
1546
+ return;
1547
+ }
1548
+ if (next_step !== COMPLETED_STEPS.FACE && next_step !== COMPLETED_STEPS.INITIATED) {
1549
+ if (next_step === COMPLETED_STEPS.DOCS) {
1550
+ setState((prev) => ({ ...prev, showDocumentUpload: true }));
1551
+ return;
1552
+ }
1553
+ }
1527
1554
  setSessionError(null);
1528
1555
  } catch (error) {
1529
1556
  const message = error.message || "Session expired or inactive";
@@ -1534,7 +1561,7 @@ function FaceScanModal({ onComplete }) {
1534
1561
  }
1535
1562
  };
1536
1563
  checkSession();
1537
- }, [apiService, navigate]);
1564
+ }, [apiService, navigate, setState]);
1538
1565
  React.useEffect(() => {
1539
1566
  setState((prev) => ({ ...prev, cameraReady }));
1540
1567
  }, [cameraReady, setState]);