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.
- package/dist/astra-sdk.cjs.js +38 -11
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.d.cts +0 -4
- package/dist/astra-sdk.es.js +38 -11
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +38 -11
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.es.js +38 -11
- package/dist/components.es.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/package.json +1 -1
- package/src/features/faceScan/hooks/useFaceScan.ts +3 -3
- package/src/pages/DocumentUploadModal.tsx +21 -1
- package/src/pages/FaceScanModal.tsx +24 -2
- package/src/services/faceMeshService.ts +5 -7
- package/src/services/kycApiService.ts +7 -0
package/dist/astra-sdk.d.cts
CHANGED
|
@@ -76,10 +76,6 @@ declare class ApiClient {
|
|
|
76
76
|
getConfig(): Required<AstraSDKConfig>;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* KYC API Service
|
|
81
|
-
* Handles all KYC-related API calls (face scan, document upload, status check)
|
|
82
|
-
*/
|
|
83
79
|
interface KycApiConfig {
|
|
84
80
|
apiBaseUrl: string;
|
|
85
81
|
sessionId: string;
|
package/dist/astra-sdk.es.js
CHANGED
|
@@ -211,6 +211,12 @@ function mergeConfig(userConfig) {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
// src/services/kycApiService.ts
|
|
214
|
+
var COMPLETED_STEPS = {
|
|
215
|
+
INITIATED: "initiated",
|
|
216
|
+
FACE: "face_scan",
|
|
217
|
+
DOCS: "document_upload",
|
|
218
|
+
COMPLETED: "completed"
|
|
219
|
+
};
|
|
214
220
|
var KycApiService = class {
|
|
215
221
|
config;
|
|
216
222
|
constructor(config) {
|
|
@@ -633,7 +639,17 @@ function DocumentUploadModal({ onComplete }) {
|
|
|
633
639
|
const checkSession = async () => {
|
|
634
640
|
if (!apiService) return;
|
|
635
641
|
try {
|
|
636
|
-
await apiService.
|
|
642
|
+
const statusResponse = await apiService.getSessionStatus();
|
|
643
|
+
const { completed_steps, next_step, status } = statusResponse.data;
|
|
644
|
+
if (status !== "ACTIVE") {
|
|
645
|
+
throw new Error("Session expired or inactive");
|
|
646
|
+
}
|
|
647
|
+
if (completed_steps.includes(COMPLETED_STEPS.DOCS)) {
|
|
648
|
+
console.log("Document already uploaded");
|
|
649
|
+
}
|
|
650
|
+
if (next_step === COMPLETED_STEPS.FACE && !completed_steps.includes(COMPLETED_STEPS.FACE)) {
|
|
651
|
+
console.warn("Face scan not completed, but in document upload modal");
|
|
652
|
+
}
|
|
637
653
|
setSessionError(null);
|
|
638
654
|
} catch (error) {
|
|
639
655
|
const message = error.message || "Session expired or inactive";
|
|
@@ -1079,7 +1095,8 @@ var FaceMeshService = class {
|
|
|
1079
1095
|
}
|
|
1080
1096
|
}
|
|
1081
1097
|
} else if (state.stage === "DONE") {
|
|
1082
|
-
|
|
1098
|
+
const reducedThreshold = 0.08;
|
|
1099
|
+
if (absYaw < reducedThreshold) {
|
|
1083
1100
|
state.centerHold += 1;
|
|
1084
1101
|
if (state.centerHold >= holdFramesCenter && !state.snapTriggered) {
|
|
1085
1102
|
state.snapTriggered = true;
|
|
@@ -1093,11 +1110,7 @@ var FaceMeshService = class {
|
|
|
1093
1110
|
} else {
|
|
1094
1111
|
state.centerHold = 0;
|
|
1095
1112
|
if (this.callbacks.onLivenessUpdate) {
|
|
1096
|
-
|
|
1097
|
-
this.callbacks.onLivenessUpdate(state.stage, "Center your face inside the circle");
|
|
1098
|
-
} else {
|
|
1099
|
-
this.callbacks.onLivenessUpdate(state.stage, "Please look straight at the camera");
|
|
1100
|
-
}
|
|
1113
|
+
this.callbacks.onLivenessUpdate(state.stage, "Please look straight at the camera");
|
|
1101
1114
|
}
|
|
1102
1115
|
}
|
|
1103
1116
|
}
|
|
@@ -1259,7 +1272,7 @@ function useFaceScan(videoRef, canvasRef, callbacks) {
|
|
|
1259
1272
|
}, []);
|
|
1260
1273
|
const handleFaceCapture = useCallback(async () => {
|
|
1261
1274
|
if (!videoRef.current) return;
|
|
1262
|
-
const
|
|
1275
|
+
const reducedThreshold = 0.08;
|
|
1263
1276
|
const currentAbsYaw = livenessStateRef.current.currentAbsYaw;
|
|
1264
1277
|
if (currentAbsYaw === null || currentAbsYaw === void 0) {
|
|
1265
1278
|
setState((prev) => ({
|
|
@@ -1268,7 +1281,7 @@ function useFaceScan(videoRef, canvasRef, callbacks) {
|
|
|
1268
1281
|
}));
|
|
1269
1282
|
return;
|
|
1270
1283
|
}
|
|
1271
|
-
if (currentAbsYaw >=
|
|
1284
|
+
if (currentAbsYaw >= reducedThreshold) {
|
|
1272
1285
|
setState((prev) => ({
|
|
1273
1286
|
...prev,
|
|
1274
1287
|
livenessInstruction: "Please look straight at the camera before capturing"
|
|
@@ -1515,7 +1528,21 @@ function FaceScanModal({ onComplete }) {
|
|
|
1515
1528
|
const checkSession = async () => {
|
|
1516
1529
|
if (!apiService) return;
|
|
1517
1530
|
try {
|
|
1518
|
-
await apiService.
|
|
1531
|
+
const statusResponse = await apiService.getSessionStatus();
|
|
1532
|
+
const { completed_steps, next_step, status } = statusResponse.data;
|
|
1533
|
+
if (status !== "ACTIVE") {
|
|
1534
|
+
throw new Error("Session expired or inactive");
|
|
1535
|
+
}
|
|
1536
|
+
if (completed_steps.includes(COMPLETED_STEPS.FACE)) {
|
|
1537
|
+
setState((prev) => ({ ...prev, showDocumentUpload: true }));
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
if (next_step !== COMPLETED_STEPS.FACE && next_step !== COMPLETED_STEPS.INITIATED) {
|
|
1541
|
+
if (next_step === COMPLETED_STEPS.DOCS) {
|
|
1542
|
+
setState((prev) => ({ ...prev, showDocumentUpload: true }));
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1519
1546
|
setSessionError(null);
|
|
1520
1547
|
} catch (error) {
|
|
1521
1548
|
const message = error.message || "Session expired or inactive";
|
|
@@ -1526,7 +1553,7 @@ function FaceScanModal({ onComplete }) {
|
|
|
1526
1553
|
}
|
|
1527
1554
|
};
|
|
1528
1555
|
checkSession();
|
|
1529
|
-
}, [apiService, navigate]);
|
|
1556
|
+
}, [apiService, navigate, setState]);
|
|
1530
1557
|
useEffect(() => {
|
|
1531
1558
|
setState((prev) => ({ ...prev, cameraReady }));
|
|
1532
1559
|
}, [cameraReady, setState]);
|