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.
@@ -14,6 +14,12 @@ var React__default = /*#__PURE__*/_interopDefault(React);
14
14
  // src/components/KycFlow.tsx
15
15
 
16
16
  // src/services/kycApiService.ts
17
+ var COMPLETED_STEPS = {
18
+ INITIATED: "initiated",
19
+ FACE: "face_scan",
20
+ DOCS: "document_upload",
21
+ COMPLETED: "completed"
22
+ };
17
23
  var KycApiService = class {
18
24
  config;
19
25
  constructor(config) {
@@ -436,7 +442,17 @@ function DocumentUploadModal({ onComplete }) {
436
442
  const checkSession = async () => {
437
443
  if (!apiService) return;
438
444
  try {
439
- await apiService.checkSessionActive();
445
+ const statusResponse = await apiService.getSessionStatus();
446
+ const { completed_steps, next_step, status } = statusResponse.data;
447
+ if (status !== "ACTIVE") {
448
+ throw new Error("Session expired or inactive");
449
+ }
450
+ if (completed_steps.includes(COMPLETED_STEPS.DOCS)) {
451
+ console.log("Document already uploaded");
452
+ }
453
+ if (next_step === COMPLETED_STEPS.FACE && !completed_steps.includes(COMPLETED_STEPS.FACE)) {
454
+ console.warn("Face scan not completed, but in document upload modal");
455
+ }
440
456
  setSessionError(null);
441
457
  } catch (error) {
442
458
  const message = error.message || "Session expired or inactive";
@@ -882,7 +898,8 @@ var FaceMeshService = class {
882
898
  }
883
899
  }
884
900
  } else if (state.stage === "DONE") {
885
- if (absYaw < centerThreshold && insideGuide) {
901
+ const reducedThreshold = 0.08;
902
+ if (absYaw < reducedThreshold) {
886
903
  state.centerHold += 1;
887
904
  if (state.centerHold >= holdFramesCenter && !state.snapTriggered) {
888
905
  state.snapTriggered = true;
@@ -896,11 +913,7 @@ var FaceMeshService = class {
896
913
  } else {
897
914
  state.centerHold = 0;
898
915
  if (this.callbacks.onLivenessUpdate) {
899
- if (!insideGuide) {
900
- this.callbacks.onLivenessUpdate(state.stage, "Center your face inside the circle");
901
- } else {
902
- this.callbacks.onLivenessUpdate(state.stage, "Please look straight at the camera");
903
- }
916
+ this.callbacks.onLivenessUpdate(state.stage, "Please look straight at the camera");
904
917
  }
905
918
  }
906
919
  }
@@ -1062,7 +1075,7 @@ function useFaceScan(videoRef, canvasRef, callbacks) {
1062
1075
  }, []);
1063
1076
  const handleFaceCapture = React.useCallback(async () => {
1064
1077
  if (!videoRef.current) return;
1065
- const centerThreshold = 0.05;
1078
+ const reducedThreshold = 0.08;
1066
1079
  const currentAbsYaw = livenessStateRef.current.currentAbsYaw;
1067
1080
  if (currentAbsYaw === null || currentAbsYaw === void 0) {
1068
1081
  setState((prev) => ({
@@ -1071,7 +1084,7 @@ function useFaceScan(videoRef, canvasRef, callbacks) {
1071
1084
  }));
1072
1085
  return;
1073
1086
  }
1074
- if (currentAbsYaw >= centerThreshold) {
1087
+ if (currentAbsYaw >= reducedThreshold) {
1075
1088
  setState((prev) => ({
1076
1089
  ...prev,
1077
1090
  livenessInstruction: "Please look straight at the camera before capturing"
@@ -1318,7 +1331,21 @@ function FaceScanModal({ onComplete }) {
1318
1331
  const checkSession = async () => {
1319
1332
  if (!apiService) return;
1320
1333
  try {
1321
- await apiService.checkSessionActive();
1334
+ const statusResponse = await apiService.getSessionStatus();
1335
+ const { completed_steps, next_step, status } = statusResponse.data;
1336
+ if (status !== "ACTIVE") {
1337
+ throw new Error("Session expired or inactive");
1338
+ }
1339
+ if (completed_steps.includes(COMPLETED_STEPS.FACE)) {
1340
+ setState((prev) => ({ ...prev, showDocumentUpload: true }));
1341
+ return;
1342
+ }
1343
+ if (next_step !== COMPLETED_STEPS.FACE && next_step !== COMPLETED_STEPS.INITIATED) {
1344
+ if (next_step === COMPLETED_STEPS.DOCS) {
1345
+ setState((prev) => ({ ...prev, showDocumentUpload: true }));
1346
+ return;
1347
+ }
1348
+ }
1322
1349
  setSessionError(null);
1323
1350
  } catch (error) {
1324
1351
  const message = error.message || "Session expired or inactive";
@@ -1329,7 +1356,7 @@ function FaceScanModal({ onComplete }) {
1329
1356
  }
1330
1357
  };
1331
1358
  checkSession();
1332
- }, [apiService, navigate]);
1359
+ }, [apiService, navigate, setState]);
1333
1360
  React.useEffect(() => {
1334
1361
  setState((prev) => ({ ...prev, cameraReady }));
1335
1362
  }, [cameraReady, setState]);