vesant-sdk 1.6.6 → 1.7.0-dev.9f7da53
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/README.md +14 -4
- package/dist/{client-ePzhQKp9.d.mts → client-BolQlL5e.d.mts} +1 -1
- package/dist/{client-ePzhQKp9.d.ts → client-BolQlL5e.d.ts} +1 -1
- package/dist/client-C3DCmGe9.d.ts +436 -0
- package/dist/{client-C_A7QLcB.d.ts → client-DMIRx7Tu.d.mts} +5 -3
- package/dist/{client-BlCxjbY2.d.mts → client-DoMSYMMR.d.ts} +5 -3
- package/dist/client-ZNdnpWe7.d.mts +436 -0
- package/dist/compliance/index.d.mts +25 -429
- package/dist/compliance/index.d.ts +25 -429
- package/dist/compliance/index.js +187 -103
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +187 -104
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +2 -2
- package/dist/decisions/index.d.ts +2 -2
- package/dist/decisions/index.js +1 -1
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +1 -1
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +4 -4
- package/dist/geolocation/index.d.ts +4 -4
- package/dist/geolocation/index.js +7 -24
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +7 -24
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +12 -70
- package/dist/index.d.ts +12 -70
- package/dist/index.js +294 -292
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +293 -291
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +4 -4
- package/dist/kyc/core.d.ts +4 -4
- package/dist/kyc/core.js +78 -23
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +78 -24
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +269 -45
- package/dist/kyc/index.d.ts +269 -45
- package/dist/kyc/index.js +78 -23
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +78 -24
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +44 -7
- package/dist/react.d.ts +44 -7
- package/dist/react.js +880 -274
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +880 -274
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +4 -4
- package/dist/risk-profile/index.d.ts +4 -4
- package/dist/risk-profile/index.js +1 -1
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +1 -1
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +2 -2
- package/dist/scores/index.d.ts +2 -2
- package/dist/scores/index.js +1 -1
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +1 -1
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +6 -41
- package/dist/tax/index.d.ts +6 -41
- package/dist/tax/index.js +1 -36
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +1 -36
- package/dist/tax/index.mjs.map +1 -1
- package/dist/{types-1RzYeSal.d.mts → types-BOFaMQxI.d.mts} +2 -2
- package/dist/{types-B4Ezqo7V.d.mts → types-CBQRNL-l.d.mts} +14 -1
- package/dist/{types-B4Ezqo7V.d.ts → types-CBQRNL-l.d.ts} +14 -1
- package/dist/{types-X5Md_dD_.d.ts → types-UGyDl1fd.d.ts} +2 -2
- package/dist/webhooks/index.d.mts +189 -2
- package/dist/webhooks/index.d.ts +189 -2
- package/dist/webhooks/index.js +49 -7
- package/dist/webhooks/index.js.map +1 -1
- package/dist/webhooks/index.mjs +49 -7
- package/dist/webhooks/index.mjs.map +1 -1
- package/package.json +16 -13
- package/dist/fraud/index.d.mts +0 -80
- package/dist/fraud/index.d.ts +0 -80
- package/dist/fraud/index.js +0 -606
- package/dist/fraud/index.js.map +0 -1
- package/dist/fraud/index.mjs +0 -604
- package/dist/fraud/index.mjs.map +0 -1
- package/dist/index-B04H4xfJ.d.mts +0 -320
- package/dist/index-CItMPmLL.d.ts +0 -320
package/dist/react.mjs
CHANGED
|
@@ -4,7 +4,19 @@ import { createRoot } from 'react-dom/client';
|
|
|
4
4
|
// src/geolocation/hooks.ts
|
|
5
5
|
|
|
6
6
|
// src/core/version.ts
|
|
7
|
-
var SDK_VERSION = "1.
|
|
7
|
+
var SDK_VERSION = "1.7.0";
|
|
8
|
+
|
|
9
|
+
// src/core/errors.ts
|
|
10
|
+
var VesantError = class _VesantError extends Error {
|
|
11
|
+
constructor(message, code, statusCode, details) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.statusCode = statusCode;
|
|
15
|
+
this.details = details;
|
|
16
|
+
this.name = "VesantError";
|
|
17
|
+
Object.setPrototypeOf(this, _VesantError.prototype);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
8
20
|
|
|
9
21
|
// src/shared/browser-utils.ts
|
|
10
22
|
function generateUUID() {
|
|
@@ -194,7 +206,7 @@ function encodePayload(payload) {
|
|
|
194
206
|
} else if (typeof Buffer !== "undefined") {
|
|
195
207
|
return Buffer.from(json, "utf-8").toString("base64");
|
|
196
208
|
}
|
|
197
|
-
throw new
|
|
209
|
+
throw new VesantError("No base64 encoding method available", "BASE64_UNAVAILABLE");
|
|
198
210
|
}
|
|
199
211
|
async function generateCipherText(options, config) {
|
|
200
212
|
const warnings = [];
|
|
@@ -219,8 +231,9 @@ async function generateCipherText(options, config) {
|
|
|
219
231
|
if (location) {
|
|
220
232
|
locationData = location;
|
|
221
233
|
} else if (gpsRequiredByConfig) {
|
|
222
|
-
throw new
|
|
223
|
-
`GPS location is required for ${options.reason} by tenant configuration, but GPS was not available or permission was denied
|
|
234
|
+
throw new VesantError(
|
|
235
|
+
`GPS location is required for ${options.reason} by tenant configuration, but GPS was not available or permission was denied`,
|
|
236
|
+
"GPS_REQUIRED"
|
|
224
237
|
);
|
|
225
238
|
} else {
|
|
226
239
|
warnings.push("GPS location not available or permission denied");
|
|
@@ -833,7 +846,7 @@ function useCustomerProfile(client, customerId, options = {}) {
|
|
|
833
846
|
profileRef.current = profile;
|
|
834
847
|
const updateProfile = useCallback(
|
|
835
848
|
async (updates) => {
|
|
836
|
-
if (!profileRef.current) throw new
|
|
849
|
+
if (!profileRef.current) throw new VesantError("Profile not loaded", "PROFILE_NOT_LOADED");
|
|
837
850
|
setLoading(true);
|
|
838
851
|
setError(null);
|
|
839
852
|
try {
|
|
@@ -869,280 +882,863 @@ function useCustomerProfile(client, customerId, options = {}) {
|
|
|
869
882
|
var Camera = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCg0KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjAvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvMjAwMS9SRUMtU1ZHLTIwMDEwOTA0L0RURC9zdmcxMC5kdGQiPg0KPCEtLSBVcGxvYWRlZCB0bzogU1ZHIFJlcG8sIHd3dy5zdmdyZXBvLmNvbSwgR2VuZXJhdG9yOiBTVkcgUmVwbyBNaXhlciBUb29scyAtLT4NCjxzdmcgdmVyc2lvbj0iMS4wIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgDQoJIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDY0IDY0IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA2NCA2NCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8cGF0aCBmaWxsPSIjMjMxRjIwIiBkPSJNNjAsMTBINDkuNjU2bC02LjgyOC02LjgyOEM0Mi4wNzgsMi40MjIsNDEuMDYyLDIsNDAsMkgyNGMtMS4wNjIsMC0yLjA3OCwwLjQyMi0yLjgyOCwxLjE3MkwxNC4zNDQsMTBINA0KCQljLTIuMjExLDAtNCwxLjc4OS00LDR2NDRjMCwyLjIxMSwxLjc4OSw0LDQsNGg1NmMyLjIxMSwwLDQtMS43ODksNC00VjE0QzY0LDExLjc4OSw2Mi4yMTEsMTAsNjAsMTB6IE0zMiw1MA0KCQljLTguODM2LDAtMTYtNy4xNjQtMTYtMTZzNy4xNjQtMTYsMTYtMTZzMTYsNy4xNjQsMTYsMTZTNDAuODM2LDUwLDMyLDUweiIvPg0KCTxjaXJjbGUgZmlsbD0iIzIzMUYyMCIgY3g9IjMyIiBjeT0iMzQiIHI9IjgiLz4NCjwvZz4NCjwvc3ZnPg==";
|
|
870
883
|
var Done = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik04LjUgMTIuNUwxMC41IDE0LjVMMTUuNSA5LjUiIHN0cm9rZT0iIzFDMjc0QyIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPg0KPHBhdGggZD0iTTcgMy4zMzc4MkM4LjQ3MDg3IDIuNDg2OTcgMTAuMTc4NiAyIDEyIDJDMTcuNTIyOCAyIDIyIDYuNDc3MTUgMjIgMTJDMjIgMTcuNTIyOCAxNy41MjI4IDIyIDEyIDIyQzYuNDc3MTUgMjIgMiAxNy41MjI4IDIgMTJDMiAxMC4xNzg2IDIuNDg2OTcgOC40NzA4NyAzLjMzNzgyIDciIHN0cm9rZT0iIzFDMjc0QyIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIvPg0KPC9zdmc+";
|
|
871
884
|
var Close = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xNC41IDkuNTAwMDJMOS41IDE0LjVNOS40OTk5OCA5LjVMMTQuNSAxNC41IiBzdHJva2U9IiMxQzI3NEMiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiLz4NCjxwYXRoIGQ9Ik03IDMuMzM3ODJDOC40NzA4NyAyLjQ4Njk3IDEwLjE3ODYgMiAxMiAyQzE3LjUyMjggMiAyMiA2LjQ3NzE1IDIyIDEyQzIyIDE3LjUyMjggMTcuNTIyOCAyMiAxMiAyMkM2LjQ3NzE1IDIyIDIgMTcuNTIyOCAyIDEyQzIgMTAuMTc4NiAyLjQ4Njk3IDguNDcwODcgMy4zMzc4MiA3IiBzdHJva2U9IiMxQzI3NEMiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiLz4NCjwvc3ZnPg==";
|
|
872
|
-
var Upload = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xNyAxN0gxNy4wMU0xNS42IDE0SDE4QzE4LjkzMTkgMTQgMTkuMzk3OCAxNCAxOS43NjU0IDE0LjE1MjJDMjAuMjU1NCAxNC4zNTUyIDIwLjY0NDggMTQuNzQ0NiAyMC44NDc4IDE1LjIzNDZDMjEgMTUuNjAyMiAyMSAxNi4wNjgxIDIxIDE3QzIxIDE3LjkzMTkgMjEgMTguMzk3OCAyMC44NDc4IDE4Ljc2NTRDMjAuNjQ0OCAxOS4yNTU0IDIwLjI1NTQgMTkuNjQ0OCAxOS43NjU0IDE5Ljg0NzhDMTkuMzk3OCAyMCAxOC45MzE5IDIwIDE4IDIwSDZDNS4wNjgxMiAyMCA0LjYwMjE4IDIwIDQuMjM0NjMgMTkuODQ3OEMzLjc0NDU4IDE5LjY0NDggMy4zNTUyMyAxOS4yNTU0IDMuMTUyMjQgMTguNzY1NEMzIDE4LjM5NzggMyAxNy45MzE5IDMgMTdDMyAxNi4wNjgxIDMgMTUuNjAyMiAzLjE1MjI0IDE1LjIzNDZDMy4zNTUyMyAxNC43NDQ2IDMuNzQ0NTggMTQuMzU1MiA0LjIzNDYzIDE0LjE1MjJDNC42MDIxOCAxNCA1LjA2ODEyIDE0IDYgMTRIOC40TTEyIDE1VjRNMTIgNEwxNSA3TTEyIDRMOSA3IiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8L3N2Zz4=";
|
|
873
885
|
|
|
874
886
|
// src/kyc/FaceCaptureModal.tsx
|
|
875
|
-
var
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
887
|
+
var MOBILE_UA = /Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
|
|
888
|
+
var LIVENESS_MESSAGES = [
|
|
889
|
+
"Position your face inside the circle",
|
|
890
|
+
"Make sure your face is well lit",
|
|
891
|
+
"Remove glasses or hats if possible",
|
|
892
|
+
"Look straight at the camera, then tap Capture"
|
|
893
|
+
];
|
|
894
|
+
function headerSubtitle(stageKind) {
|
|
895
|
+
switch (stageKind) {
|
|
896
|
+
case "qr":
|
|
897
|
+
return "Use your phone to continue";
|
|
898
|
+
case "accepted":
|
|
899
|
+
return "All set";
|
|
900
|
+
case "declined":
|
|
901
|
+
return "Verification Declined";
|
|
902
|
+
case "max_attempts":
|
|
903
|
+
return "We couldn't verify your identity";
|
|
904
|
+
default:
|
|
905
|
+
return "Please capture a clear photo of your face";
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function defaultRenderQR(payload) {
|
|
909
|
+
const url = `https://api.qrserver.com/v1/create-qr-code/?size=220x220&data=${encodeURIComponent(payload)}`;
|
|
910
|
+
return /* @__PURE__ */ React.createElement("img", { src: url, alt: "QR code", width: 220, height: 220 });
|
|
911
|
+
}
|
|
883
912
|
function FaceCaptureModal({
|
|
884
|
-
|
|
885
|
-
|
|
913
|
+
client,
|
|
914
|
+
session,
|
|
915
|
+
onComplete,
|
|
916
|
+
onCancel,
|
|
917
|
+
defaultDevice,
|
|
918
|
+
renderQR
|
|
886
919
|
}) {
|
|
887
|
-
const
|
|
888
|
-
const
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
920
|
+
const isMobile = typeof navigator !== "undefined" && MOBILE_UA.test(navigator.userAgent);
|
|
921
|
+
const initialChoice = defaultDevice ?? (isMobile ? "this" : "ask");
|
|
922
|
+
const initialStage = (() => {
|
|
923
|
+
if (initialChoice === "this") return { kind: "capture" };
|
|
924
|
+
if (initialChoice === "mobile") return { kind: "qr", mobileConnected: false };
|
|
925
|
+
return { kind: "choose" };
|
|
926
|
+
})();
|
|
927
|
+
const hasMethodChoice = initialChoice === "ask";
|
|
928
|
+
const [stage, setStage] = useState(initialStage);
|
|
929
|
+
const [attempts, setAttempts] = useState(session.attempts);
|
|
930
|
+
const maxAttempts = session.max_attempts || 1;
|
|
931
|
+
const [qrDeclinedReason, setQrDeclinedReason] = useState(null);
|
|
932
|
+
const [captureMode, setCaptureMode] = useState("idle");
|
|
933
|
+
const [capturedPreview, setCapturedPreview] = useState(null);
|
|
934
|
+
const [capturedBase64, setCapturedBase64] = useState(null);
|
|
935
|
+
const [livenessMessage, setLivenessMessage] = useState(LIVENESS_MESSAGES[0]);
|
|
936
|
+
const qrPayload = session.link || `vesant://reuse-kyc?token=${encodeURIComponent(session.token)}`;
|
|
937
|
+
const cancelledRef = useRef(false);
|
|
938
|
+
const submittingRef = useRef(false);
|
|
939
|
+
useEffect(() => {
|
|
940
|
+
if (stage.kind !== "qr") return;
|
|
941
|
+
let stopped = false;
|
|
942
|
+
const intervalMs = 2e3;
|
|
943
|
+
const deadline = Date.now() + 15 * 60 * 1e3;
|
|
944
|
+
let mobileSeen = stage.mobileConnected;
|
|
945
|
+
const tick = async () => {
|
|
946
|
+
if (stopped || cancelledRef.current) return;
|
|
947
|
+
try {
|
|
948
|
+
if (mobileSeen) {
|
|
949
|
+
const result = await client.getReuseKycSessionStatus(session.reference);
|
|
950
|
+
if (result.status === "accepted") {
|
|
951
|
+
setStage({ kind: "accepted", result });
|
|
952
|
+
stopped = true;
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
if (result.status === "declined") {
|
|
956
|
+
setAttempts(maxAttempts - (result.data?.retries_remaining ?? 0));
|
|
957
|
+
if (result.data?.retry_limit_exceeded) {
|
|
958
|
+
setStage({ kind: "max_attempts", result });
|
|
959
|
+
stopped = true;
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
if (result.declined_reason) {
|
|
963
|
+
setQrDeclinedReason(result.declined_reason);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
} else {
|
|
967
|
+
const handoff = await client.getHandoffSession(session.token);
|
|
968
|
+
if (handoff.mobile_connected) {
|
|
969
|
+
mobileSeen = true;
|
|
970
|
+
setStage({ kind: "qr", mobileConnected: true });
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
} catch {
|
|
974
|
+
}
|
|
975
|
+
if (Date.now() < deadline) {
|
|
976
|
+
setTimeout(tick, intervalMs);
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
tick();
|
|
980
|
+
return () => {
|
|
981
|
+
stopped = true;
|
|
982
|
+
};
|
|
983
|
+
}, [stage.kind, stage.kind === "qr" ? stage.mobileConnected : false]);
|
|
984
|
+
const applyResult = (result) => {
|
|
985
|
+
if (result.status === "accepted") {
|
|
986
|
+
setStage({ kind: "accepted", result });
|
|
987
|
+
return true;
|
|
905
988
|
}
|
|
989
|
+
if (result.status === "declined") {
|
|
990
|
+
const nextAttempts = maxAttempts - (result.data?.retries_remaining ?? 0);
|
|
991
|
+
setAttempts(nextAttempts);
|
|
992
|
+
setCapturedPreview(null);
|
|
993
|
+
setCapturedBase64(null);
|
|
994
|
+
if (result.data?.retry_limit_exceeded) {
|
|
995
|
+
setStage({ kind: "max_attempts", result });
|
|
996
|
+
} else {
|
|
997
|
+
setStage({ kind: "declined", result });
|
|
998
|
+
}
|
|
999
|
+
return true;
|
|
1000
|
+
}
|
|
1001
|
+
return false;
|
|
906
1002
|
};
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
display: "flex",
|
|
974
|
-
alignItems: "center",
|
|
975
|
-
justifyContent: "center"
|
|
976
|
-
};
|
|
977
|
-
const badgeStyle = {
|
|
978
|
-
position: "absolute",
|
|
979
|
-
top: "-4px",
|
|
980
|
-
right: "-4px",
|
|
981
|
-
width: "32px",
|
|
982
|
-
height: "32px",
|
|
983
|
-
background: "#ffffff",
|
|
984
|
-
borderRadius: "50%",
|
|
985
|
-
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
|
|
986
|
-
display: "flex",
|
|
987
|
-
alignItems: "center",
|
|
988
|
-
justifyContent: "center"
|
|
989
|
-
};
|
|
990
|
-
const instructionsBoxStyle = {
|
|
991
|
-
background: "linear-gradient(135deg, #f9fafb 0%, rgba(243, 244, 246, 0.5) 100%)",
|
|
992
|
-
borderRadius: "12px",
|
|
993
|
-
padding: "16px",
|
|
994
|
-
marginBottom: "24px"
|
|
995
|
-
};
|
|
996
|
-
const instructionsTitleStyle = {
|
|
997
|
-
fontSize: "14px",
|
|
998
|
-
fontWeight: 500,
|
|
999
|
-
color: "#111827",
|
|
1000
|
-
marginBottom: "8px"
|
|
1001
|
-
};
|
|
1002
|
-
const instructionsListStyle = {
|
|
1003
|
-
fontSize: "12px",
|
|
1004
|
-
color: "#6b7280",
|
|
1005
|
-
listStyle: "none",
|
|
1006
|
-
padding: 0,
|
|
1007
|
-
margin: 0
|
|
1008
|
-
};
|
|
1009
|
-
const instructionItemStyle = {
|
|
1010
|
-
display: "flex",
|
|
1011
|
-
alignItems: "flex-start",
|
|
1012
|
-
marginBottom: "6px"
|
|
1003
|
+
const runSubmit = async (proof) => {
|
|
1004
|
+
if (submittingRef.current) return;
|
|
1005
|
+
submittingRef.current = true;
|
|
1006
|
+
setStage({ kind: "submitting" });
|
|
1007
|
+
let settled = false;
|
|
1008
|
+
const ref = session.reference;
|
|
1009
|
+
const baselineAttempts = attempts;
|
|
1010
|
+
const isFreshPollResult = (r) => {
|
|
1011
|
+
if (r.status === "accepted") return true;
|
|
1012
|
+
if (r.status === "declined") {
|
|
1013
|
+
const derivedAttempts = maxAttempts - (r.data?.retries_remaining ?? 0);
|
|
1014
|
+
return derivedAttempts > baselineAttempts;
|
|
1015
|
+
}
|
|
1016
|
+
return false;
|
|
1017
|
+
};
|
|
1018
|
+
try {
|
|
1019
|
+
const postPromise = (async () => {
|
|
1020
|
+
try {
|
|
1021
|
+
const data = await client.submitReuseKycSession({
|
|
1022
|
+
token: session.token,
|
|
1023
|
+
reference: ref,
|
|
1024
|
+
proof
|
|
1025
|
+
});
|
|
1026
|
+
return { ok: true, data };
|
|
1027
|
+
} catch (err2) {
|
|
1028
|
+
return { ok: false, error: err2 };
|
|
1029
|
+
}
|
|
1030
|
+
})();
|
|
1031
|
+
const pollPromise = (async () => {
|
|
1032
|
+
await new Promise((r) => setTimeout(r, 12e3));
|
|
1033
|
+
const deadline = Date.now() + 12e4;
|
|
1034
|
+
while (Date.now() < deadline) {
|
|
1035
|
+
if (settled || cancelledRef.current) return null;
|
|
1036
|
+
try {
|
|
1037
|
+
const r = await client.getReuseKycSessionStatus(ref);
|
|
1038
|
+
if (isFreshPollResult(r)) return r;
|
|
1039
|
+
} catch {
|
|
1040
|
+
}
|
|
1041
|
+
if (settled || cancelledRef.current) return null;
|
|
1042
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
1043
|
+
}
|
|
1044
|
+
return null;
|
|
1045
|
+
})();
|
|
1046
|
+
const winner = await Promise.race([
|
|
1047
|
+
postPromise.then(
|
|
1048
|
+
(r) => r.ok ? { from: "post", data: r.data } : { from: "post_err" }
|
|
1049
|
+
),
|
|
1050
|
+
pollPromise.then(
|
|
1051
|
+
(data) => data ? { from: "poll", data } : { from: "poll_done" }
|
|
1052
|
+
)
|
|
1053
|
+
]);
|
|
1054
|
+
settled = true;
|
|
1055
|
+
if (winner.from === "post" && applyResult(winner.data)) return;
|
|
1056
|
+
if (winner.from === "poll" && applyResult(winner.data)) return;
|
|
1057
|
+
const [postResult, pollResult] = await Promise.all([postPromise, pollPromise]);
|
|
1058
|
+
if (postResult.ok && applyResult(postResult.data)) return;
|
|
1059
|
+
if (pollResult && applyResult(pollResult)) return;
|
|
1060
|
+
const err = postResult.ok ? null : postResult.error;
|
|
1061
|
+
setStage({
|
|
1062
|
+
kind: "error",
|
|
1063
|
+
message: err instanceof Error ? err.message : "Submission failed. Please try again."
|
|
1064
|
+
});
|
|
1065
|
+
} finally {
|
|
1066
|
+
settled = true;
|
|
1067
|
+
submittingRef.current = false;
|
|
1068
|
+
}
|
|
1013
1069
|
};
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1070
|
+
const handleCameraCapture = (dataUrl) => {
|
|
1071
|
+
const raw = dataUrl.split(",")[1] ?? "";
|
|
1072
|
+
setCapturedPreview(dataUrl);
|
|
1073
|
+
setCapturedBase64(raw);
|
|
1074
|
+
setCaptureMode("preview");
|
|
1018
1075
|
};
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1076
|
+
const handleCameraCancel = () => setCaptureMode("idle");
|
|
1077
|
+
const handleRetake = () => {
|
|
1078
|
+
setCapturedPreview(null);
|
|
1079
|
+
setCapturedBase64(null);
|
|
1080
|
+
setCaptureMode("live");
|
|
1023
1081
|
};
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
color: "#ffffff",
|
|
1028
|
-
fontWeight: 500,
|
|
1029
|
-
padding: "14px 24px",
|
|
1030
|
-
borderRadius: "12px",
|
|
1031
|
-
border: "none",
|
|
1032
|
-
cursor: isProcessing ? "not-allowed" : "pointer",
|
|
1033
|
-
transition: "all 0.2s",
|
|
1034
|
-
display: "flex",
|
|
1035
|
-
alignItems: "center",
|
|
1036
|
-
justifyContent: "center",
|
|
1037
|
-
gap: "12px",
|
|
1038
|
-
boxShadow: isProcessing ? "none" : isHoveringPrimary ? "0 20px 25px -5px rgba(0, 188, 125, 0.3)" : "0 10px 15px -3px rgba(0, 188, 125, 0.2)",
|
|
1039
|
-
fontSize: "16px"
|
|
1082
|
+
const handleConfirmSubmit = () => {
|
|
1083
|
+
if (!capturedBase64) return;
|
|
1084
|
+
void runSubmit(capturedBase64);
|
|
1040
1085
|
};
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
color: "#374151",
|
|
1045
|
-
fontWeight: 500,
|
|
1046
|
-
padding: "14px 24px",
|
|
1047
|
-
borderRadius: "12px",
|
|
1048
|
-
border: "2px solid #e5e7eb",
|
|
1049
|
-
cursor: isProcessing ? "not-allowed" : "pointer",
|
|
1050
|
-
transition: "all 0.2s",
|
|
1051
|
-
fontSize: "16px"
|
|
1086
|
+
const handleOpenCamera = () => {
|
|
1087
|
+
if (submittingRef.current) return;
|
|
1088
|
+
setCaptureMode("live");
|
|
1052
1089
|
};
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1090
|
+
const handleRetakeAfterDecline = () => {
|
|
1091
|
+
setCapturedPreview(null);
|
|
1092
|
+
setCapturedBase64(null);
|
|
1093
|
+
setCaptureMode("live");
|
|
1094
|
+
setStage({ kind: "capture" });
|
|
1055
1095
|
};
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1096
|
+
useEffect(() => {
|
|
1097
|
+
if (captureMode !== "live") return;
|
|
1098
|
+
setLivenessMessage(LIVENESS_MESSAGES[0]);
|
|
1099
|
+
let i = 0;
|
|
1100
|
+
const interval = setInterval(() => {
|
|
1101
|
+
i = (i + 1) % LIVENESS_MESSAGES.length;
|
|
1102
|
+
setLivenessMessage(LIVENESS_MESSAGES[i]);
|
|
1103
|
+
}, 3e3);
|
|
1104
|
+
return () => clearInterval(interval);
|
|
1105
|
+
}, [captureMode]);
|
|
1106
|
+
const close = (result) => {
|
|
1107
|
+
cancelledRef.current = true;
|
|
1108
|
+
if (result === null && onCancel) {
|
|
1109
|
+
onCancel();
|
|
1110
|
+
}
|
|
1111
|
+
onComplete(result);
|
|
1061
1112
|
};
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1113
|
+
const renderChoose = () => /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideStyle }, /* @__PURE__ */ React.createElement("div", { style: circleStyle }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 48, height: 48 })))), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "How would you like to verify?"), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement(
|
|
1114
|
+
"button",
|
|
1115
|
+
{
|
|
1116
|
+
style: primaryButtonStyle,
|
|
1117
|
+
onClick: () => setStage({ kind: "capture" })
|
|
1118
|
+
},
|
|
1119
|
+
/* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }),
|
|
1120
|
+
/* @__PURE__ */ React.createElement("span", null, "Continue on this device")
|
|
1121
|
+
), /* @__PURE__ */ React.createElement(
|
|
1122
|
+
"button",
|
|
1123
|
+
{
|
|
1124
|
+
style: secondaryButtonStyle,
|
|
1125
|
+
onClick: () => setStage({ kind: "qr", mobileConnected: false })
|
|
1126
|
+
},
|
|
1127
|
+
"Continue on mobile (scan QR)"
|
|
1128
|
+
), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")));
|
|
1129
|
+
const renderQRStage = (mobileConnected) => /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: qrBoxStyle }, (renderQR ?? defaultRenderQR)(qrPayload)), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, mobileConnected ? "Phone connected. Complete the capture on your mobile device\u2026" : "Scan this QR with your phone camera, then complete the face capture there."), mobileConnected && /* @__PURE__ */ React.createElement("div", { style: { ...spinnerStyle, margin: "12px auto" } }), qrDeclinedReason && /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Last attempt was declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, qrDeclinedReason), /* @__PURE__ */ React.createElement("p", { style: { ...alertTextStyle, marginTop: 4 } }, "Try again on your phone. Attempt ", Math.min(attempts + 1, maxAttempts), " of ", maxAttempts, ".")), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement(
|
|
1130
|
+
"button",
|
|
1131
|
+
{
|
|
1132
|
+
style: secondaryButtonStyle,
|
|
1133
|
+
onClick: () => setStage({ kind: "capture" })
|
|
1134
|
+
},
|
|
1135
|
+
"Use this device instead"
|
|
1136
|
+
), hasMethodChoice && /* @__PURE__ */ React.createElement(
|
|
1137
|
+
"button",
|
|
1138
|
+
{
|
|
1139
|
+
style: secondaryButtonStyle,
|
|
1140
|
+
onClick: () => setStage({ kind: "choose" })
|
|
1141
|
+
},
|
|
1142
|
+
"Change verification method"
|
|
1143
|
+
), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")));
|
|
1144
|
+
const renderCapture = (declinedReason) => {
|
|
1145
|
+
if (captureMode === "live") {
|
|
1146
|
+
return /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement(
|
|
1147
|
+
LiveCamera,
|
|
1148
|
+
{
|
|
1149
|
+
onCapture: handleCameraCapture,
|
|
1150
|
+
onCancel: handleCameraCancel,
|
|
1151
|
+
message: livenessMessage
|
|
1152
|
+
}
|
|
1153
|
+
), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", attempts + 1, " of ", maxAttempts));
|
|
1154
|
+
}
|
|
1155
|
+
if (captureMode === "preview" && capturedPreview) {
|
|
1156
|
+
return /* @__PURE__ */ React.createElement("div", { style: contentStyle }, declinedReason && /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Verification declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, declinedReason)), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "Looks good? Submit this selfie or retake it."), /* @__PURE__ */ React.createElement("div", { style: previewBoxStyle }, /* @__PURE__ */ React.createElement("img", { src: capturedPreview, alt: "Captured selfie preview", style: previewImgStyle })), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleConfirmSubmit }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, "Submit")), /* @__PURE__ */ React.createElement("button", { style: secondaryButtonStyle, onClick: handleRetake }, "Retake"), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", attempts + 1, " of ", maxAttempts));
|
|
1157
|
+
}
|
|
1158
|
+
return /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideStyle }, /* @__PURE__ */ React.createElement("div", { style: circleStyle }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 48, height: 48 })), /* @__PURE__ */ React.createElement("div", { style: badgeStyle }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 16, height: 16 })))), declinedReason && /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Verification declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, declinedReason)), /* @__PURE__ */ React.createElement("div", { style: instructionsBoxStyle }, /* @__PURE__ */ React.createElement("h3", { style: instructionsTitleStyle }, "Tips for best results:"), /* @__PURE__ */ React.createElement("ul", { style: instructionsListStyle }, /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Ensure good lighting on your face")), /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Remove glasses or accessories if possible")), /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Look directly at the camera")))), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleOpenCamera }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, declinedReason ? "Try again" : "Open Camera")), hasMethodChoice && /* @__PURE__ */ React.createElement(
|
|
1159
|
+
"button",
|
|
1160
|
+
{
|
|
1161
|
+
style: secondaryButtonStyle,
|
|
1162
|
+
onClick: () => setStage({ kind: "choose" })
|
|
1163
|
+
},
|
|
1164
|
+
"Change verification method"
|
|
1165
|
+
), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", attempts + 1, " of ", maxAttempts));
|
|
1069
1166
|
};
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1167
|
+
const renderSubmitting = () => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: { ...spinnerStyle, margin: "24px auto", width: 32, height: 32 } }), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "Verifying your photo\u2026"), /* @__PURE__ */ React.createElement("p", { style: { ...attemptsTextStyle, marginTop: 8 } }, "This usually takes a few seconds."));
|
|
1168
|
+
const renderAccepted = (result) => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: successCircleStyle }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 48, height: 48 })), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Verified"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "Your identity has been confirmed. You can continue."), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => close(result) }, "Continue")));
|
|
1169
|
+
const renderDeclined = (result) => /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, result.declined_reason ?? "We couldn't match your selfie. Please take a new one.")), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleRetakeAfterDecline }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, "Retake")), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(result) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", Math.min(attempts + 1, maxAttempts), " of ", maxAttempts));
|
|
1170
|
+
const renderMaxAttempts = (result) => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Maximum Attempts Reached"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, result.declined_reason ?? "We couldn't verify your identity after several attempts."), result.data?.freeze_account && /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, "For your security, your account has been temporarily restricted", result.data.freeze_duration_minutes ? ` for ${result.data.freeze_duration_minutes} minutes` : "", ". Please contact support if you need immediate help."), result.data?.enforce_logout && /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, "You will be signed out of your session."), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => close(result) }, "Close")));
|
|
1171
|
+
const renderError = (message) => {
|
|
1172
|
+
const sessionExpired = /session\s+expired/i.test(message);
|
|
1173
|
+
return /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, sessionExpired ? "Session expired" : "Something went wrong"), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, sessionExpired ? "Your verification session is no longer valid. Please start a new verification from the beginning." : message), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, !sessionExpired && /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => setStage({ kind: "capture" }) }, "Try again"), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, sessionExpired ? "Close" : "Cancel")));
|
|
1072
1174
|
};
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
@keyframes spin {
|
|
1095
|
-
from {
|
|
1096
|
-
transform: rotate(0deg);
|
|
1097
|
-
}
|
|
1098
|
-
to {
|
|
1099
|
-
transform: rotate(360deg);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
`);
|
|
1103
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, styleTag, /* @__PURE__ */ React.createElement("div", { style: overlayStyle }, /* @__PURE__ */ React.createElement("div", { style: modalStyle }, /* @__PURE__ */ React.createElement("div", { style: headerStyle }, /* @__PURE__ */ React.createElement(
|
|
1175
|
+
const body = (() => {
|
|
1176
|
+
switch (stage.kind) {
|
|
1177
|
+
case "choose":
|
|
1178
|
+
return renderChoose();
|
|
1179
|
+
case "qr":
|
|
1180
|
+
return renderQRStage(stage.mobileConnected);
|
|
1181
|
+
case "capture":
|
|
1182
|
+
return renderCapture(stage.declinedReason);
|
|
1183
|
+
case "submitting":
|
|
1184
|
+
return renderSubmitting();
|
|
1185
|
+
case "accepted":
|
|
1186
|
+
return renderAccepted(stage.result);
|
|
1187
|
+
case "declined":
|
|
1188
|
+
return renderDeclined(stage.result);
|
|
1189
|
+
case "max_attempts":
|
|
1190
|
+
return renderMaxAttempts(stage.result);
|
|
1191
|
+
case "error":
|
|
1192
|
+
return renderError(stage.message);
|
|
1193
|
+
}
|
|
1194
|
+
})();
|
|
1195
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("style", null, keyframes), /* @__PURE__ */ React.createElement("div", { style: overlayStyle }, /* @__PURE__ */ React.createElement("div", { style: modalStyle }, /* @__PURE__ */ React.createElement("div", { style: headerStyle }, /* @__PURE__ */ React.createElement(
|
|
1104
1196
|
"button",
|
|
1105
1197
|
{
|
|
1106
|
-
onClick:
|
|
1107
|
-
onMouseEnter: () => setIsHoveringClose(true),
|
|
1108
|
-
onMouseLeave: () => setIsHoveringClose(false),
|
|
1198
|
+
onClick: () => close(null),
|
|
1109
1199
|
style: closeButtonStyle,
|
|
1110
1200
|
"aria-label": "Close"
|
|
1111
1201
|
},
|
|
1112
|
-
/* @__PURE__ */ React.createElement("img", { src: Close, alt: "
|
|
1113
|
-
), /* @__PURE__ */ React.createElement("h2", { style: titleStyle }, "Face Verification"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle },
|
|
1114
|
-
|
|
1202
|
+
/* @__PURE__ */ React.createElement("img", { src: Close, alt: "", width: 16, height: 16 })
|
|
1203
|
+
), /* @__PURE__ */ React.createElement("h2", { style: titleStyle }, "Face Verification"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, headerSubtitle(stage.kind))), body, /* @__PURE__ */ React.createElement("div", { style: footerStyle }, /* @__PURE__ */ React.createElement("p", { style: footerTextStyle }, "Your photo is securely processed and used only for verification.")))));
|
|
1204
|
+
}
|
|
1205
|
+
var keyframes = `
|
|
1206
|
+
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
|
|
1207
|
+
@keyframes zoomIn { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }
|
|
1208
|
+
@keyframes spin { to { transform: rotate(360deg) } }
|
|
1209
|
+
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .5 } }
|
|
1210
|
+
`;
|
|
1211
|
+
var overlayStyle = {
|
|
1212
|
+
position: "fixed",
|
|
1213
|
+
inset: 0,
|
|
1214
|
+
background: "rgba(0,0,0,.6)",
|
|
1215
|
+
backdropFilter: "blur(4px)",
|
|
1216
|
+
display: "flex",
|
|
1217
|
+
alignItems: "center",
|
|
1218
|
+
justifyContent: "center",
|
|
1219
|
+
zIndex: 999999,
|
|
1220
|
+
padding: 16,
|
|
1221
|
+
animation: "fadeIn .2s ease-out"
|
|
1222
|
+
};
|
|
1223
|
+
var modalStyle = {
|
|
1224
|
+
background: "#fff",
|
|
1225
|
+
borderRadius: 16,
|
|
1226
|
+
boxShadow: "0 25px 50px -12px rgba(0,0,0,.25)",
|
|
1227
|
+
width: "100%",
|
|
1228
|
+
maxWidth: 448,
|
|
1229
|
+
animation: "zoomIn .2s ease-out"
|
|
1230
|
+
};
|
|
1231
|
+
var headerStyle = {
|
|
1232
|
+
position: "relative",
|
|
1233
|
+
padding: "24px 24px 16px",
|
|
1234
|
+
borderBottom: "1px solid #f3f4f6"
|
|
1235
|
+
};
|
|
1236
|
+
var closeButtonStyle = {
|
|
1237
|
+
position: "absolute",
|
|
1238
|
+
top: 16,
|
|
1239
|
+
right: 16,
|
|
1240
|
+
padding: 8,
|
|
1241
|
+
background: "transparent",
|
|
1242
|
+
border: "none",
|
|
1243
|
+
borderRadius: 8,
|
|
1244
|
+
cursor: "pointer"
|
|
1245
|
+
};
|
|
1246
|
+
var titleStyle = { margin: "0 0 4px", fontSize: 18, fontWeight: 600, color: "#111827" };
|
|
1247
|
+
var subtitleStyle = { margin: 0, fontSize: 14, color: "#6b7280" };
|
|
1248
|
+
var contentStyle = {
|
|
1249
|
+
padding: 24,
|
|
1250
|
+
display: "flex",
|
|
1251
|
+
flexDirection: "column",
|
|
1252
|
+
gap: 16
|
|
1253
|
+
};
|
|
1254
|
+
var visualGuideContainerStyle = { display: "flex", justifyContent: "center" };
|
|
1255
|
+
var visualGuideStyle = { position: "relative" };
|
|
1256
|
+
var circleStyle = {
|
|
1257
|
+
width: 96,
|
|
1258
|
+
height: 96,
|
|
1259
|
+
borderRadius: "50%",
|
|
1260
|
+
background: "linear-gradient(135deg, rgba(0, 188, 125, 0.2) 0%, rgba(0, 188, 125, 0.05) 100%)",
|
|
1261
|
+
display: "flex",
|
|
1262
|
+
alignItems: "center",
|
|
1263
|
+
justifyContent: "center"
|
|
1264
|
+
};
|
|
1265
|
+
var badgeStyle = {
|
|
1266
|
+
position: "absolute",
|
|
1267
|
+
bottom: -4,
|
|
1268
|
+
right: -4,
|
|
1269
|
+
width: 28,
|
|
1270
|
+
height: 28,
|
|
1271
|
+
borderRadius: "50%",
|
|
1272
|
+
background: "#ffffff",
|
|
1273
|
+
border: "2px solid #00bc7d",
|
|
1274
|
+
display: "flex",
|
|
1275
|
+
alignItems: "center",
|
|
1276
|
+
justifyContent: "center"
|
|
1277
|
+
};
|
|
1278
|
+
var successCircleStyle = {
|
|
1279
|
+
...circleStyle,
|
|
1280
|
+
background: "linear-gradient(135deg, rgba(0, 188, 125, 0.25) 0%, rgba(0, 188, 125, 0.1) 100%)",
|
|
1281
|
+
margin: "0 auto"
|
|
1282
|
+
};
|
|
1283
|
+
var errorCircleStyle = {
|
|
1284
|
+
width: 64,
|
|
1285
|
+
height: 64,
|
|
1286
|
+
borderRadius: "50%",
|
|
1287
|
+
background: "#fee2e2",
|
|
1288
|
+
color: "#b91c1c",
|
|
1289
|
+
fontSize: 32,
|
|
1290
|
+
fontWeight: 700,
|
|
1291
|
+
display: "flex",
|
|
1292
|
+
alignItems: "center",
|
|
1293
|
+
justifyContent: "center",
|
|
1294
|
+
margin: "0 auto"
|
|
1295
|
+
};
|
|
1296
|
+
var qrBoxStyle = {
|
|
1297
|
+
display: "flex",
|
|
1298
|
+
justifyContent: "center",
|
|
1299
|
+
padding: 12,
|
|
1300
|
+
background: "linear-gradient(135deg, #f9fafb 0%, rgba(243, 244, 246, 0.5) 100%)",
|
|
1301
|
+
borderRadius: 12
|
|
1302
|
+
};
|
|
1303
|
+
var alertBoxStyle = {
|
|
1304
|
+
background: "#fef3c7",
|
|
1305
|
+
border: "1px solid #fde68a",
|
|
1306
|
+
color: "#92400e",
|
|
1307
|
+
borderRadius: 8,
|
|
1308
|
+
padding: 12,
|
|
1309
|
+
fontSize: 14
|
|
1310
|
+
};
|
|
1311
|
+
var alertTextStyle = { margin: "4px 0 0", fontSize: 13, color: "#92400e" };
|
|
1312
|
+
var instructionsBoxStyle = {
|
|
1313
|
+
background: "linear-gradient(135deg, #f9fafb 0%, rgba(243, 244, 246, 0.5) 100%)",
|
|
1314
|
+
borderRadius: 8,
|
|
1315
|
+
padding: 16
|
|
1316
|
+
};
|
|
1317
|
+
var instructionsTitleStyle = { margin: "0 0 8px", fontSize: 14, fontWeight: 600, color: "#374151" };
|
|
1318
|
+
var instructionsListStyle = { margin: 0, padding: 0, listStyle: "none" };
|
|
1319
|
+
var instructionItemStyle = { display: "flex", gap: 8, fontSize: 13, color: "#4b5563", lineHeight: 1.5 };
|
|
1320
|
+
var bulletStyle = { color: "#00bc7d" };
|
|
1321
|
+
var previewBoxStyle = {
|
|
1322
|
+
borderRadius: 12,
|
|
1323
|
+
overflow: "hidden",
|
|
1324
|
+
border: "2px solid rgba(0, 188, 125, 0.4)",
|
|
1325
|
+
background: "#0f172a",
|
|
1326
|
+
display: "flex",
|
|
1327
|
+
justifyContent: "center"
|
|
1328
|
+
};
|
|
1329
|
+
var previewImgStyle = {
|
|
1330
|
+
width: "100%",
|
|
1331
|
+
maxHeight: 320,
|
|
1332
|
+
objectFit: "contain",
|
|
1333
|
+
background: "#0f172a"
|
|
1334
|
+
};
|
|
1335
|
+
var buttonsContainerStyle = {
|
|
1336
|
+
display: "flex",
|
|
1337
|
+
flexDirection: "column",
|
|
1338
|
+
gap: 8
|
|
1339
|
+
};
|
|
1340
|
+
var primaryButtonStyle = {
|
|
1341
|
+
display: "flex",
|
|
1342
|
+
alignItems: "center",
|
|
1343
|
+
justifyContent: "center",
|
|
1344
|
+
gap: 8,
|
|
1345
|
+
padding: "12px 16px",
|
|
1346
|
+
background: "#00bc7d",
|
|
1347
|
+
color: "#ffffff",
|
|
1348
|
+
border: "none",
|
|
1349
|
+
borderRadius: 8,
|
|
1350
|
+
fontSize: 14,
|
|
1351
|
+
fontWeight: 600,
|
|
1352
|
+
cursor: "pointer"
|
|
1353
|
+
};
|
|
1354
|
+
var secondaryButtonStyle = {
|
|
1355
|
+
...primaryButtonStyle,
|
|
1356
|
+
background: "#ffffff",
|
|
1357
|
+
color: "#374151",
|
|
1358
|
+
border: "2px solid #e5e7eb"
|
|
1359
|
+
};
|
|
1360
|
+
var cancelButtonStyle = {
|
|
1361
|
+
...primaryButtonStyle,
|
|
1362
|
+
background: "transparent",
|
|
1363
|
+
color: "#6b7280",
|
|
1364
|
+
border: "none"
|
|
1365
|
+
};
|
|
1366
|
+
var spinnerStyle = {
|
|
1367
|
+
width: 16,
|
|
1368
|
+
height: 16,
|
|
1369
|
+
border: "2px solid rgba(0, 188, 125, 0.25)",
|
|
1370
|
+
borderTopColor: "#00bc7d",
|
|
1371
|
+
borderRadius: "50%",
|
|
1372
|
+
animation: "spin .8s linear infinite"
|
|
1373
|
+
};
|
|
1374
|
+
var attemptsTextStyle = {
|
|
1375
|
+
margin: "8px 0 0",
|
|
1376
|
+
fontSize: 12,
|
|
1377
|
+
color: "#9ca3af",
|
|
1378
|
+
textAlign: "center"
|
|
1379
|
+
};
|
|
1380
|
+
var footerStyle = { padding: "12px 24px 16px", borderTop: "1px solid #f3f4f6" };
|
|
1381
|
+
var footerTextStyle = { margin: 0, fontSize: 12, color: "#9ca3af", textAlign: "center" };
|
|
1382
|
+
var FACE_MESSAGES = {
|
|
1383
|
+
idle: "Initializing camera...",
|
|
1384
|
+
loading: "Loading face detection...",
|
|
1385
|
+
scanning: "Position your face in the circle",
|
|
1386
|
+
too_far: "Face too far. Please move closer to the camera",
|
|
1387
|
+
too_close: "Too close. Please move back a little",
|
|
1388
|
+
off_center: "Center your face in the circle",
|
|
1389
|
+
ok: "Looking great! Tap the button to capture"
|
|
1390
|
+
};
|
|
1391
|
+
var FACE_COLORS = {
|
|
1392
|
+
idle: "#9ca3af",
|
|
1393
|
+
loading: "#3b82f6",
|
|
1394
|
+
scanning: "#3b82f6",
|
|
1395
|
+
too_far: "#ef4444",
|
|
1396
|
+
too_close: "#f59e0b",
|
|
1397
|
+
off_center: "#f59e0b",
|
|
1398
|
+
ok: "#10b981"
|
|
1399
|
+
};
|
|
1400
|
+
var MEDIAPIPE_BASE = "https://cdn.jsdelivr.net/npm/@mediapipe/face_detection";
|
|
1401
|
+
var mediapipeLoaderPromise = null;
|
|
1402
|
+
function loadMediaPipeFaceDetection() {
|
|
1403
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1404
|
+
return Promise.reject(new Error("MediaPipe requires a browser environment"));
|
|
1405
|
+
}
|
|
1406
|
+
const w = window;
|
|
1407
|
+
if (w.FaceDetection) {
|
|
1408
|
+
return Promise.resolve(w.FaceDetection);
|
|
1409
|
+
}
|
|
1410
|
+
if (mediapipeLoaderPromise) return mediapipeLoaderPromise;
|
|
1411
|
+
mediapipeLoaderPromise = new Promise((resolve, reject) => {
|
|
1412
|
+
const script = document.createElement("script");
|
|
1413
|
+
script.src = `${MEDIAPIPE_BASE}/face_detection.js`;
|
|
1414
|
+
script.async = true;
|
|
1415
|
+
script.crossOrigin = "anonymous";
|
|
1416
|
+
script.onload = () => {
|
|
1417
|
+
if (w.FaceDetection) {
|
|
1418
|
+
resolve(w.FaceDetection);
|
|
1419
|
+
} else {
|
|
1420
|
+
mediapipeLoaderPromise = null;
|
|
1421
|
+
reject(new Error("MediaPipe loaded but FaceDetection global is missing"));
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
script.onerror = () => {
|
|
1425
|
+
mediapipeLoaderPromise = null;
|
|
1426
|
+
reject(new Error("Failed to load MediaPipe face_detection script"));
|
|
1427
|
+
};
|
|
1428
|
+
document.head.appendChild(script);
|
|
1429
|
+
});
|
|
1430
|
+
return mediapipeLoaderPromise;
|
|
1431
|
+
}
|
|
1432
|
+
function LiveCamera({ onCapture, onCancel, message }) {
|
|
1433
|
+
const videoRef = useRef(null);
|
|
1434
|
+
const streamRef = useRef(null);
|
|
1435
|
+
const [ready, setReady] = useState(false);
|
|
1436
|
+
const [error, setError] = useState(null);
|
|
1437
|
+
const [faceStatus, setFaceStatus] = useState("idle");
|
|
1438
|
+
const [faceDetectionFailed, setFaceDetectionFailed] = useState(false);
|
|
1439
|
+
useEffect(() => {
|
|
1440
|
+
let cancelled = false;
|
|
1441
|
+
async function init() {
|
|
1442
|
+
try {
|
|
1443
|
+
if (typeof navigator === "undefined" || !navigator.mediaDevices?.getUserMedia) {
|
|
1444
|
+
throw new Error("Camera is not available in this browser");
|
|
1445
|
+
}
|
|
1446
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1447
|
+
video: {
|
|
1448
|
+
facingMode: "user",
|
|
1449
|
+
width: { ideal: 1280 },
|
|
1450
|
+
height: { ideal: 1280 }
|
|
1451
|
+
},
|
|
1452
|
+
audio: false
|
|
1453
|
+
});
|
|
1454
|
+
if (cancelled) {
|
|
1455
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
streamRef.current = stream;
|
|
1459
|
+
const video = videoRef.current;
|
|
1460
|
+
if (video) {
|
|
1461
|
+
video.srcObject = stream;
|
|
1462
|
+
video.onloadedmetadata = () => {
|
|
1463
|
+
video.play().catch(() => {
|
|
1464
|
+
});
|
|
1465
|
+
setReady(true);
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
} catch (err) {
|
|
1469
|
+
setError(err instanceof Error ? err.message : "Unable to access camera");
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
init();
|
|
1473
|
+
return () => {
|
|
1474
|
+
cancelled = true;
|
|
1475
|
+
streamRef.current?.getTracks().forEach((t) => t.stop());
|
|
1476
|
+
streamRef.current = null;
|
|
1477
|
+
};
|
|
1478
|
+
}, []);
|
|
1479
|
+
useEffect(() => {
|
|
1480
|
+
if (!ready) {
|
|
1481
|
+
setFaceStatus("idle");
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
let cancelled = false;
|
|
1485
|
+
let rafId = null;
|
|
1486
|
+
let detector = null;
|
|
1487
|
+
setFaceStatus("loading");
|
|
1488
|
+
setFaceDetectionFailed(false);
|
|
1489
|
+
(async () => {
|
|
1490
|
+
try {
|
|
1491
|
+
const FaceDetection = await loadMediaPipeFaceDetection();
|
|
1492
|
+
if (cancelled) return;
|
|
1493
|
+
const d = new FaceDetection({
|
|
1494
|
+
locateFile: (f) => `${MEDIAPIPE_BASE}/${f}`
|
|
1495
|
+
});
|
|
1496
|
+
d.setOptions({ model: "short", minDetectionConfidence: 0.5 });
|
|
1497
|
+
d.onResults((results) => {
|
|
1498
|
+
if (cancelled) return;
|
|
1499
|
+
const detections = results.detections ?? [];
|
|
1500
|
+
let next;
|
|
1501
|
+
if (detections.length === 0) {
|
|
1502
|
+
next = "scanning";
|
|
1503
|
+
} else {
|
|
1504
|
+
const bb = detections[0].boundingBox;
|
|
1505
|
+
if (bb.width < 0.18) next = "too_far";
|
|
1506
|
+
else if (bb.width > 0.72) next = "too_close";
|
|
1507
|
+
else if (bb.xCenter < 0.28 || bb.xCenter > 0.72 || bb.yCenter < 0.28 || bb.yCenter > 0.72) {
|
|
1508
|
+
next = "off_center";
|
|
1509
|
+
} else {
|
|
1510
|
+
next = "ok";
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
setFaceStatus(next);
|
|
1514
|
+
});
|
|
1515
|
+
await d.initialize();
|
|
1516
|
+
if (cancelled) return;
|
|
1517
|
+
detector = d;
|
|
1518
|
+
setFaceStatus("scanning");
|
|
1519
|
+
const tick = async () => {
|
|
1520
|
+
if (cancelled) return;
|
|
1521
|
+
const v = videoRef.current;
|
|
1522
|
+
if (v?.readyState === 4 && detector) {
|
|
1523
|
+
try {
|
|
1524
|
+
await detector.send({ image: v });
|
|
1525
|
+
} catch {
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
if (!cancelled) {
|
|
1529
|
+
rafId = requestAnimationFrame(tick);
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
tick();
|
|
1533
|
+
} catch (err) {
|
|
1534
|
+
console.error("Face detection failed to initialize:", err);
|
|
1535
|
+
if (!cancelled) {
|
|
1536
|
+
setFaceDetectionFailed(true);
|
|
1537
|
+
setFaceStatus("scanning");
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
})();
|
|
1541
|
+
return () => {
|
|
1542
|
+
cancelled = true;
|
|
1543
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
1544
|
+
try {
|
|
1545
|
+
detector?.close?.();
|
|
1546
|
+
} catch {
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
}, [ready]);
|
|
1550
|
+
const capture = () => {
|
|
1551
|
+
const video = videoRef.current;
|
|
1552
|
+
if (!video || !video.videoWidth) return;
|
|
1553
|
+
const size = Math.min(video.videoWidth, video.videoHeight);
|
|
1554
|
+
const sx = (video.videoWidth - size) / 2;
|
|
1555
|
+
const sy = (video.videoHeight - size) / 2;
|
|
1556
|
+
const canvas = document.createElement("canvas");
|
|
1557
|
+
canvas.width = size;
|
|
1558
|
+
canvas.height = size;
|
|
1559
|
+
const ctx = canvas.getContext("2d");
|
|
1560
|
+
if (!ctx) return;
|
|
1561
|
+
ctx.translate(size, 0);
|
|
1562
|
+
ctx.scale(-1, 1);
|
|
1563
|
+
ctx.drawImage(video, sx, sy, size, size, 0, 0, size, size);
|
|
1564
|
+
streamRef.current?.getTracks().forEach((t) => t.stop());
|
|
1565
|
+
streamRef.current = null;
|
|
1566
|
+
onCapture(canvas.toDataURL("image/jpeg", 0.9));
|
|
1567
|
+
};
|
|
1568
|
+
if (error) {
|
|
1569
|
+
return /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center", padding: 0 } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Camera unavailable"), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, error), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: secondaryButtonStyle, onClick: onCancel }, "Back")));
|
|
1570
|
+
}
|
|
1571
|
+
const detectionActive = ready && !faceDetectionFailed;
|
|
1572
|
+
const liveMessage = detectionActive ? FACE_MESSAGES[faceStatus] : message;
|
|
1573
|
+
const liveFaceColor = detectionActive ? FACE_COLORS[faceStatus] : void 0;
|
|
1574
|
+
const captureDisabled = !ready || detectionActive && faceStatus !== "ok";
|
|
1575
|
+
const ringPulse = detectionActive && (faceStatus === "too_far" || faceStatus === "too_close") ? "pulse 1.5s ease-in-out infinite" : void 0;
|
|
1576
|
+
const dynamicCircleStyle = {
|
|
1577
|
+
...faceCircleStyle,
|
|
1578
|
+
...liveFaceColor ? { borderColor: liveFaceColor } : null,
|
|
1579
|
+
...ringPulse ? { animation: ringPulse } : null
|
|
1580
|
+
};
|
|
1581
|
+
return /* @__PURE__ */ React.createElement("div", { style: videoFrameStyle }, /* @__PURE__ */ React.createElement(
|
|
1582
|
+
"video",
|
|
1115
1583
|
{
|
|
1116
|
-
ref:
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
style:
|
|
1121
|
-
onChange: handleFileChange,
|
|
1122
|
-
disabled: isProcessing
|
|
1584
|
+
ref: videoRef,
|
|
1585
|
+
playsInline: true,
|
|
1586
|
+
muted: true,
|
|
1587
|
+
autoPlay: true,
|
|
1588
|
+
style: videoStyle
|
|
1123
1589
|
}
|
|
1124
|
-
), /* @__PURE__ */ React.createElement("div", { style:
|
|
1590
|
+
), /* @__PURE__ */ React.createElement("div", { style: faceOverlayContainerStyle, "aria-hidden": "true" }, /* @__PURE__ */ React.createElement("div", { style: faceRingWrapStyle }, /* @__PURE__ */ React.createElement("div", { style: faceDashedRingStyle }), /* @__PURE__ */ React.createElement("div", { style: dynamicCircleStyle }))), liveMessage && /* @__PURE__ */ React.createElement("div", { style: liveMessagePillContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: liveMessagePillStyle }, /* @__PURE__ */ React.createElement("span", { style: liveMessagePillTextStyle }, liveMessage))), /* @__PURE__ */ React.createElement(
|
|
1125
1591
|
"button",
|
|
1126
1592
|
{
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
style: primaryButtonStyle
|
|
1593
|
+
type: "button",
|
|
1594
|
+
onClick: onCancel,
|
|
1595
|
+
"aria-label": "Close camera",
|
|
1596
|
+
style: overlayCloseButtonStyle
|
|
1132
1597
|
},
|
|
1133
|
-
|
|
1134
|
-
), /* @__PURE__ */ React.createElement(
|
|
1598
|
+
/* @__PURE__ */ React.createElement("img", { src: Close, alt: "", width: 16, height: 16 })
|
|
1599
|
+
), !ready && /* @__PURE__ */ React.createElement("div", { style: videoLoadingStyle }, "Starting camera\u2026"), /* @__PURE__ */ React.createElement("div", { style: bottomGradientStyle }, /* @__PURE__ */ React.createElement(
|
|
1135
1600
|
"button",
|
|
1136
1601
|
{
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
style:
|
|
1602
|
+
type: "button",
|
|
1603
|
+
onClick: capture,
|
|
1604
|
+
disabled: captureDisabled,
|
|
1605
|
+
"aria-label": "Capture",
|
|
1606
|
+
style: captureDisabled ? { ...shutterButtonStyle, opacity: 0.5, cursor: "not-allowed" } : shutterButtonStyle
|
|
1142
1607
|
},
|
|
1143
|
-
"
|
|
1144
|
-
)))
|
|
1608
|
+
/* @__PURE__ */ React.createElement("span", { style: shutterInnerStyle })
|
|
1609
|
+
)));
|
|
1145
1610
|
}
|
|
1611
|
+
var videoFrameStyle = {
|
|
1612
|
+
position: "relative",
|
|
1613
|
+
width: "100%",
|
|
1614
|
+
aspectRatio: "3 / 4",
|
|
1615
|
+
borderRadius: 24,
|
|
1616
|
+
overflow: "hidden",
|
|
1617
|
+
background: "#000000",
|
|
1618
|
+
border: "4px solid rgba(255, 255, 255, 0.08)",
|
|
1619
|
+
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)"
|
|
1620
|
+
};
|
|
1621
|
+
var overlayCloseButtonStyle = {
|
|
1622
|
+
position: "absolute",
|
|
1623
|
+
top: 12,
|
|
1624
|
+
right: 12,
|
|
1625
|
+
width: 32,
|
|
1626
|
+
height: 32,
|
|
1627
|
+
display: "inline-flex",
|
|
1628
|
+
alignItems: "center",
|
|
1629
|
+
justifyContent: "center",
|
|
1630
|
+
padding: 0,
|
|
1631
|
+
border: "none",
|
|
1632
|
+
borderRadius: "50%",
|
|
1633
|
+
background: "rgba(0, 0, 0, 0.4)",
|
|
1634
|
+
backdropFilter: "blur(6px)",
|
|
1635
|
+
color: "#ffffff",
|
|
1636
|
+
cursor: "pointer",
|
|
1637
|
+
zIndex: 10
|
|
1638
|
+
};
|
|
1639
|
+
var bottomGradientStyle = {
|
|
1640
|
+
position: "absolute",
|
|
1641
|
+
bottom: 0,
|
|
1642
|
+
left: 0,
|
|
1643
|
+
right: 0,
|
|
1644
|
+
padding: "16px",
|
|
1645
|
+
background: "linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%)",
|
|
1646
|
+
display: "flex",
|
|
1647
|
+
alignItems: "center",
|
|
1648
|
+
justifyContent: "center",
|
|
1649
|
+
zIndex: 10
|
|
1650
|
+
};
|
|
1651
|
+
var shutterButtonStyle = {
|
|
1652
|
+
width: 64,
|
|
1653
|
+
height: 64,
|
|
1654
|
+
borderRadius: "50%",
|
|
1655
|
+
background: "rgba(255, 255, 255, 0.15)",
|
|
1656
|
+
backdropFilter: "blur(6px)",
|
|
1657
|
+
border: "2px solid rgba(255, 255, 255, 0.7)",
|
|
1658
|
+
display: "inline-flex",
|
|
1659
|
+
alignItems: "center",
|
|
1660
|
+
justifyContent: "center",
|
|
1661
|
+
cursor: "pointer",
|
|
1662
|
+
padding: 0,
|
|
1663
|
+
transition: "transform 120ms ease-out, background 120ms"
|
|
1664
|
+
};
|
|
1665
|
+
var shutterInnerStyle = {
|
|
1666
|
+
display: "block",
|
|
1667
|
+
width: 44,
|
|
1668
|
+
height: 44,
|
|
1669
|
+
borderRadius: "50%",
|
|
1670
|
+
background: "rgba(255, 255, 255, 0.85)"
|
|
1671
|
+
};
|
|
1672
|
+
var videoStyle = {
|
|
1673
|
+
width: "100%",
|
|
1674
|
+
height: "100%",
|
|
1675
|
+
objectFit: "cover",
|
|
1676
|
+
transform: "scaleX(-1)"
|
|
1677
|
+
// mirror so the preview matches the user's POV
|
|
1678
|
+
};
|
|
1679
|
+
var faceOverlayContainerStyle = {
|
|
1680
|
+
position: "absolute",
|
|
1681
|
+
inset: 0,
|
|
1682
|
+
pointerEvents: "none",
|
|
1683
|
+
display: "flex",
|
|
1684
|
+
alignItems: "center",
|
|
1685
|
+
justifyContent: "center"
|
|
1686
|
+
};
|
|
1687
|
+
var faceRingWrapStyle = {
|
|
1688
|
+
position: "relative",
|
|
1689
|
+
width: "72%",
|
|
1690
|
+
aspectRatio: "1 / 1"
|
|
1691
|
+
};
|
|
1692
|
+
var faceDashedRingStyle = {
|
|
1693
|
+
position: "absolute",
|
|
1694
|
+
inset: -6,
|
|
1695
|
+
borderRadius: "50%",
|
|
1696
|
+
border: "6px dashed rgba(255, 255, 255, 0.4)",
|
|
1697
|
+
animation: "spin 10s linear infinite"
|
|
1698
|
+
};
|
|
1699
|
+
var faceCircleStyle = {
|
|
1700
|
+
position: "absolute",
|
|
1701
|
+
inset: 0,
|
|
1702
|
+
borderRadius: "50%",
|
|
1703
|
+
border: "4px solid #00bc7d",
|
|
1704
|
+
boxShadow: "0 0 0 1000px rgba(0, 0, 0, 0.5)"
|
|
1705
|
+
};
|
|
1706
|
+
var videoLoadingStyle = {
|
|
1707
|
+
position: "absolute",
|
|
1708
|
+
inset: 0,
|
|
1709
|
+
display: "flex",
|
|
1710
|
+
alignItems: "center",
|
|
1711
|
+
justifyContent: "center",
|
|
1712
|
+
color: "#e5e7eb",
|
|
1713
|
+
fontSize: 14,
|
|
1714
|
+
fontWeight: 500,
|
|
1715
|
+
background: "rgba(0, 0, 0, 0.4)",
|
|
1716
|
+
zIndex: 5
|
|
1717
|
+
};
|
|
1718
|
+
var liveMessagePillContainerStyle = {
|
|
1719
|
+
position: "absolute",
|
|
1720
|
+
top: 12,
|
|
1721
|
+
left: "50%",
|
|
1722
|
+
transform: "translateX(-50%)",
|
|
1723
|
+
maxWidth: "84%",
|
|
1724
|
+
pointerEvents: "none"
|
|
1725
|
+
};
|
|
1726
|
+
var liveMessagePillStyle = {
|
|
1727
|
+
background: "rgba(0, 0, 0, 0.7)",
|
|
1728
|
+
backdropFilter: "blur(6px)",
|
|
1729
|
+
border: "1px solid rgba(255, 255, 255, 0.2)",
|
|
1730
|
+
borderRadius: 999,
|
|
1731
|
+
padding: "6px 12px",
|
|
1732
|
+
textAlign: "center",
|
|
1733
|
+
boxShadow: "0 10px 25px -5px rgba(0,0,0,.3)"
|
|
1734
|
+
};
|
|
1735
|
+
var liveMessagePillTextStyle = {
|
|
1736
|
+
margin: 0,
|
|
1737
|
+
fontSize: 12,
|
|
1738
|
+
fontWeight: 500,
|
|
1739
|
+
color: "#ffffff",
|
|
1740
|
+
animation: "pulse 2s ease-in-out infinite"
|
|
1741
|
+
};
|
|
1146
1742
|
var FaceCaptureModal_default = FaceCaptureModal;
|
|
1147
1743
|
|
|
1148
1744
|
// src/kyc/hooks.ts
|
|
@@ -1426,7 +2022,7 @@ function useKycPreferences(client, autoFetch = true) {
|
|
|
1426
2022
|
refresh: fetchPreferences
|
|
1427
2023
|
};
|
|
1428
2024
|
}
|
|
1429
|
-
function
|
|
2025
|
+
function fileToBase64(file) {
|
|
1430
2026
|
return new Promise((resolve, reject) => {
|
|
1431
2027
|
const reader = new FileReader();
|
|
1432
2028
|
reader.onload = () => {
|
|
@@ -1483,41 +2079,51 @@ function getRiskColor(risk) {
|
|
|
1483
2079
|
return colorMap[risk] || "#6b7280";
|
|
1484
2080
|
}
|
|
1485
2081
|
function useReuseKYCSubmission(client) {
|
|
1486
|
-
const
|
|
1487
|
-
|
|
2082
|
+
const startSession = useCallback(
|
|
2083
|
+
(request) => client.createReuseKycSession(request),
|
|
2084
|
+
[client]
|
|
2085
|
+
);
|
|
2086
|
+
const verifyFace = useCallback(
|
|
2087
|
+
(session, opts = {}) => new Promise((resolve) => {
|
|
1488
2088
|
const container = document.createElement("div");
|
|
1489
2089
|
document.body.appendChild(container);
|
|
1490
2090
|
const root = createRoot(container);
|
|
1491
2091
|
const cleanup = () => {
|
|
1492
2092
|
root.unmount();
|
|
1493
|
-
|
|
2093
|
+
container.remove();
|
|
1494
2094
|
};
|
|
1495
2095
|
const modal = createElement(FaceCaptureModal_default, {
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
});
|
|
1503
|
-
resolve(resp);
|
|
1504
|
-
} catch (error) {
|
|
1505
|
-
reject(error instanceof Error ? error : new Error("Face verification failed"));
|
|
1506
|
-
} finally {
|
|
1507
|
-
cleanup();
|
|
1508
|
-
}
|
|
1509
|
-
},
|
|
1510
|
-
onCancel: () => {
|
|
2096
|
+
client,
|
|
2097
|
+
session,
|
|
2098
|
+
defaultDevice: opts.defaultDevice,
|
|
2099
|
+
renderQR: opts.renderQR,
|
|
2100
|
+
onCancel: opts.onCancel,
|
|
2101
|
+
onComplete: (result) => {
|
|
1511
2102
|
cleanup();
|
|
1512
|
-
resolve(
|
|
2103
|
+
resolve(result);
|
|
1513
2104
|
}
|
|
1514
2105
|
});
|
|
1515
2106
|
root.render(modal);
|
|
1516
|
-
})
|
|
1517
|
-
|
|
1518
|
-
|
|
2107
|
+
}),
|
|
2108
|
+
[client]
|
|
2109
|
+
);
|
|
2110
|
+
const runFlow = useCallback(
|
|
2111
|
+
async (request, opts = {}) => {
|
|
2112
|
+
const session = await startSession(request);
|
|
2113
|
+
if (!session.is_required) {
|
|
2114
|
+
return { kind: "not_required", session };
|
|
2115
|
+
}
|
|
2116
|
+
const result = await verifyFace(session, opts);
|
|
2117
|
+
if (result === null) {
|
|
2118
|
+
return { kind: "cancelled", session };
|
|
2119
|
+
}
|
|
2120
|
+
return { kind: "completed", session, result };
|
|
2121
|
+
},
|
|
2122
|
+
[startSession, verifyFace]
|
|
2123
|
+
);
|
|
2124
|
+
return { startSession, verifyFace, runFlow };
|
|
1519
2125
|
}
|
|
1520
2126
|
|
|
1521
|
-
export { createDeviceFingerprint,
|
|
2127
|
+
export { createDeviceFingerprint, fileToBase64, formatKycStatus, getBrowserInfo, getRiskColor, getStatusColor, isValidFileSize, isValidFileType, useCipherText, useCustomerProfile, useGeolocation, useKycAlerts, useKycOverview, useKycPreferences, useKycRequests, useKycSubmission, useLocationCapture, useLocationRequests, useLoginVerification, useRegistration, useReuseKYCSubmission, useTransactionVerification };
|
|
1522
2128
|
//# sourceMappingURL=react.mjs.map
|
|
1523
2129
|
//# sourceMappingURL=react.mjs.map
|