vesant-sdk 1.3.0 → 1.3.1

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/react.js CHANGED
@@ -1,6 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var react = require('react');
3
+ var React = require('react');
4
+ var client = require('react-dom/client');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefault(React);
4
9
 
5
10
  // src/geolocation/hooks.ts
6
11
 
@@ -259,12 +264,12 @@ async function generateCipherText(options, config) {
259
264
 
260
265
  // src/geolocation/hooks.ts
261
266
  function useGeolocation(client, options = {}) {
262
- const [verification, setVerification] = react.useState(null);
263
- const [loading, setLoading] = react.useState(false);
264
- const [error, setError] = react.useState(null);
265
- const optionsRef = react.useRef(options);
267
+ const [verification, setVerification] = React.useState(null);
268
+ const [loading, setLoading] = React.useState(false);
269
+ const [error, setError] = React.useState(null);
270
+ const optionsRef = React.useRef(options);
266
271
  optionsRef.current = options;
267
- const verifyIP = react.useCallback(
272
+ const verifyIP = React.useCallback(
268
273
  async (request) => {
269
274
  setLoading(true);
270
275
  setError(null);
@@ -282,7 +287,7 @@ function useGeolocation(client, options = {}) {
282
287
  },
283
288
  [client]
284
289
  );
285
- const checkCompliance = react.useCallback(
290
+ const checkCompliance = React.useCallback(
286
291
  async (countryISO) => {
287
292
  setLoading(true);
288
293
  setError(null);
@@ -299,7 +304,7 @@ function useGeolocation(client, options = {}) {
299
304
  },
300
305
  [client]
301
306
  );
302
- const refresh = react.useCallback(async () => {
307
+ const refresh = React.useCallback(async () => {
303
308
  if (verification) {
304
309
  await verifyIP({
305
310
  ip_address: verification.ip_address,
@@ -308,7 +313,7 @@ function useGeolocation(client, options = {}) {
308
313
  });
309
314
  }
310
315
  }, [verification, verifyIP]);
311
- react.useEffect(() => {
316
+ React.useEffect(() => {
312
317
  if (optionsRef.current.autoVerify) {
313
318
  const detectAndVerify = async () => {
314
319
  try {
@@ -369,12 +374,12 @@ function createDeviceFingerprint() {
369
374
  };
370
375
  }
371
376
  function useCipherText(client) {
372
- const [config, setConfig] = react.useState(void 0);
373
- const [configLoading, setConfigLoading] = react.useState(!!client);
374
- const [configError, setConfigError] = react.useState(null);
375
- const configRef = react.useRef(void 0);
377
+ const [config, setConfig] = React.useState(void 0);
378
+ const [configLoading, setConfigLoading] = React.useState(!!client);
379
+ const [configError, setConfigError] = React.useState(null);
380
+ const configRef = React.useRef(void 0);
376
381
  configRef.current = config;
377
- react.useEffect(() => {
382
+ React.useEffect(() => {
378
383
  if (!client) return;
379
384
  let cancelled = false;
380
385
  setConfigLoading(true);
@@ -393,7 +398,7 @@ function useCipherText(client) {
393
398
  cancelled = true;
394
399
  };
395
400
  }, [client]);
396
- const generate = react.useCallback(
401
+ const generate = React.useCallback(
397
402
  async (options) => {
398
403
  try {
399
404
  return await generateCipherText(options, configRef.current);
@@ -407,16 +412,16 @@ function useCipherText(client) {
407
412
  return { generate, configLoading, configError };
408
413
  }
409
414
  function useLocationRequests(client, options = {}) {
410
- const [requests, setRequests] = react.useState([]);
411
- const [total, setTotal] = react.useState(0);
412
- const [page, setPage] = react.useState(1);
413
- const [totalPages, setTotalPages] = react.useState(0);
414
- const [loading, setLoading] = react.useState(false);
415
- const [error, setError] = react.useState(null);
416
- const pollIntervalRef = react.useRef();
417
- const optionsRef = react.useRef(options);
415
+ const [requests, setRequests] = React.useState([]);
416
+ const [total, setTotal] = React.useState(0);
417
+ const [page, setPage] = React.useState(1);
418
+ const [totalPages, setTotalPages] = React.useState(0);
419
+ const [loading, setLoading] = React.useState(false);
420
+ const [error, setError] = React.useState(null);
421
+ const pollIntervalRef = React.useRef();
422
+ const optionsRef = React.useRef(options);
418
423
  optionsRef.current = options;
419
- const fetchRequests = react.useCallback(
424
+ const fetchRequests = React.useCallback(
420
425
  async (filters, pagination) => {
421
426
  setLoading(true);
422
427
  setError(null);
@@ -439,7 +444,7 @@ function useLocationRequests(client, options = {}) {
439
444
  },
440
445
  [client]
441
446
  );
442
- const createRequest = react.useCallback(
447
+ const createRequest = React.useCallback(
443
448
  async (request) => {
444
449
  setError(null);
445
450
  try {
@@ -455,7 +460,7 @@ function useLocationRequests(client, options = {}) {
455
460
  },
456
461
  [client]
457
462
  );
458
- const getRequest = react.useCallback(
463
+ const getRequest = React.useCallback(
459
464
  async (requestId) => {
460
465
  try {
461
466
  return await client.getLocationRequest(requestId);
@@ -467,7 +472,7 @@ function useLocationRequests(client, options = {}) {
467
472
  },
468
473
  [client]
469
474
  );
470
- const cancelRequest = react.useCallback(
475
+ const cancelRequest = React.useCallback(
471
476
  async (requestId) => {
472
477
  try {
473
478
  await client.cancelLocationRequest(requestId);
@@ -484,7 +489,7 @@ function useLocationRequests(client, options = {}) {
484
489
  },
485
490
  [client]
486
491
  );
487
- const resendRequest = react.useCallback(
492
+ const resendRequest = React.useCallback(
488
493
  async (requestId, contact) => {
489
494
  try {
490
495
  await client.resendLocationRequest(requestId, contact);
@@ -496,15 +501,15 @@ function useLocationRequests(client, options = {}) {
496
501
  },
497
502
  [client]
498
503
  );
499
- const refresh = react.useCallback(async () => {
504
+ const refresh = React.useCallback(async () => {
500
505
  await fetchRequests();
501
506
  }, [fetchRequests]);
502
- react.useEffect(() => {
507
+ React.useEffect(() => {
503
508
  if (optionsRef.current.autoFetch) {
504
509
  fetchRequests();
505
510
  }
506
511
  }, [fetchRequests]);
507
- react.useEffect(() => {
512
+ React.useEffect(() => {
508
513
  const pollInterval = optionsRef.current.pollInterval;
509
514
  if (pollInterval && pollInterval > 0) {
510
515
  pollIntervalRef.current = setInterval(() => {
@@ -534,14 +539,14 @@ function useLocationRequests(client, options = {}) {
534
539
  };
535
540
  }
536
541
  function useLocationCapture(client, options) {
537
- const [shareInfo, setShareInfo] = react.useState(null);
538
- const [captureResponse, setCaptureResponse] = react.useState(null);
539
- const [loading, setLoading] = react.useState(false);
540
- const [submitting, setSubmitting] = react.useState(false);
541
- const [error, setError] = react.useState(null);
542
+ const [shareInfo, setShareInfo] = React.useState(null);
543
+ const [captureResponse, setCaptureResponse] = React.useState(null);
544
+ const [loading, setLoading] = React.useState(false);
545
+ const [submitting, setSubmitting] = React.useState(false);
546
+ const [error, setError] = React.useState(null);
542
547
  const isExpired = shareInfo?.is_expired ?? false;
543
548
  const isCompleted = shareInfo?.is_completed ?? false;
544
- const fetchShareInfo = react.useCallback(async () => {
549
+ const fetchShareInfo = React.useCallback(async () => {
545
550
  setLoading(true);
546
551
  setError(null);
547
552
  try {
@@ -556,7 +561,7 @@ function useLocationCapture(client, options) {
556
561
  setLoading(false);
557
562
  }
558
563
  }, [client, options.token]);
559
- const submitLocation = react.useCallback(
564
+ const submitLocation = React.useCallback(
560
565
  async (capture) => {
561
566
  setSubmitting(true);
562
567
  setError(null);
@@ -579,7 +584,7 @@ function useLocationCapture(client, options) {
579
584
  },
580
585
  [client, options.token]
581
586
  );
582
- const captureAndSubmitGPS = react.useCallback(async () => {
587
+ const captureAndSubmitGPS = React.useCallback(async () => {
583
588
  setSubmitting(true);
584
589
  setError(null);
585
590
  try {
@@ -647,12 +652,12 @@ function useLocationCapture(client, options) {
647
652
  setSubmitting(false);
648
653
  }
649
654
  }, [submitLocation]);
650
- react.useEffect(() => {
655
+ React.useEffect(() => {
651
656
  if (options.autoFetch && options.token) {
652
657
  fetchShareInfo();
653
658
  }
654
659
  }, [options.autoFetch, options.token, fetchShareInfo]);
655
- react.useEffect(() => {
660
+ React.useEffect(() => {
656
661
  if (options.autoRequestGPS && shareInfo && !isExpired && !isCompleted) {
657
662
  captureAndSubmitGPS().catch(() => {
658
663
  });
@@ -672,12 +677,12 @@ function useLocationCapture(client, options) {
672
677
  };
673
678
  }
674
679
  function useRegistration(client, options = {}) {
675
- const [verification, setVerification] = react.useState(null);
676
- const [loading, setLoading] = react.useState(false);
677
- const [error, setError] = react.useState(null);
678
- const optionsRef = react.useRef(options);
680
+ const [verification, setVerification] = React.useState(null);
681
+ const [loading, setLoading] = React.useState(false);
682
+ const [error, setError] = React.useState(null);
683
+ const optionsRef = React.useRef(options);
679
684
  optionsRef.current = options;
680
- const verifyRegistration = react.useCallback(
685
+ const verifyRegistration = React.useCallback(
681
686
  async (request) => {
682
687
  setLoading(true);
683
688
  setError(null);
@@ -712,12 +717,12 @@ function useRegistration(client, options = {}) {
712
717
  };
713
718
  }
714
719
  function useLoginVerification(client, options = {}) {
715
- const [verification, setVerification] = react.useState(null);
716
- const [loading, setLoading] = react.useState(false);
717
- const [error, setError] = react.useState(null);
718
- const optionsRef = react.useRef(options);
720
+ const [verification, setVerification] = React.useState(null);
721
+ const [loading, setLoading] = React.useState(false);
722
+ const [error, setError] = React.useState(null);
723
+ const optionsRef = React.useRef(options);
719
724
  optionsRef.current = options;
720
- const verifyLogin = react.useCallback(
725
+ const verifyLogin = React.useCallback(
721
726
  async (request) => {
722
727
  setLoading(true);
723
728
  setError(null);
@@ -755,12 +760,12 @@ function useLoginVerification(client, options = {}) {
755
760
  };
756
761
  }
757
762
  function useTransactionVerification(client, options = {}) {
758
- const [verification, setVerification] = react.useState(null);
759
- const [loading, setLoading] = react.useState(false);
760
- const [error, setError] = react.useState(null);
761
- const optionsRef = react.useRef(options);
763
+ const [verification, setVerification] = React.useState(null);
764
+ const [loading, setLoading] = React.useState(false);
765
+ const [error, setError] = React.useState(null);
766
+ const optionsRef = React.useRef(options);
762
767
  optionsRef.current = options;
763
- const verifyTransaction = react.useCallback(
768
+ const verifyTransaction = React.useCallback(
764
769
  async (request) => {
765
770
  setLoading(true);
766
771
  setError(null);
@@ -796,10 +801,10 @@ function useTransactionVerification(client, options = {}) {
796
801
  };
797
802
  }
798
803
  function useCustomerProfile(client, customerId, options = {}) {
799
- const [profile, setProfile] = react.useState(null);
800
- const [loading, setLoading] = react.useState(false);
801
- const [error, setError] = react.useState(null);
802
- const fetchProfile = react.useCallback(async () => {
804
+ const [profile, setProfile] = React.useState(null);
805
+ const [loading, setLoading] = React.useState(false);
806
+ const [error, setError] = React.useState(null);
807
+ const fetchProfile = React.useCallback(async () => {
803
808
  setLoading(true);
804
809
  setError(null);
805
810
  try {
@@ -814,9 +819,9 @@ function useCustomerProfile(client, customerId, options = {}) {
814
819
  setLoading(false);
815
820
  }
816
821
  }, [client, customerId]);
817
- const profileRef = react.useRef(profile);
822
+ const profileRef = React.useRef(profile);
818
823
  profileRef.current = profile;
819
- const updateProfile = react.useCallback(
824
+ const updateProfile = React.useCallback(
820
825
  async (updates) => {
821
826
  if (!profileRef.current) throw new Error("Profile not loaded");
822
827
  setLoading(true);
@@ -835,7 +840,7 @@ function useCustomerProfile(client, customerId, options = {}) {
835
840
  },
836
841
  [client]
837
842
  );
838
- react.useEffect(() => {
843
+ React.useEffect(() => {
839
844
  if (options.autoFetch && customerId) {
840
845
  fetchProfile();
841
846
  }
@@ -849,16 +854,298 @@ function useCustomerProfile(client, customerId, options = {}) {
849
854
  refresh: fetchProfile
850
855
  };
851
856
  }
857
+
858
+ // src/kyc/images.ts
859
+ var Camera = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCg0KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjAvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvMjAwMS9SRUMtU1ZHLTIwMDEwOTA0L0RURC9zdmcxMC5kdGQiPg0KPCEtLSBVcGxvYWRlZCB0bzogU1ZHIFJlcG8sIHd3dy5zdmdyZXBvLmNvbSwgR2VuZXJhdG9yOiBTVkcgUmVwbyBNaXhlciBUb29scyAtLT4NCjxzdmcgdmVyc2lvbj0iMS4wIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgDQoJIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0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DIxOCAxNCA1LjA2ODEyIDE0IDYgMTRIOC40TTEyIDE1VjRNMTIgNEwxNSA3TTEyIDRMOSA3IiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8L3N2Zz4=";
863
+
864
+ // src/kyc/FaceCaptureModal.tsx
865
+ var fileToBase64 = (file) => {
866
+ return new Promise((resolve, reject) => {
867
+ const reader = new FileReader();
868
+ reader.readAsDataURL(file);
869
+ reader.onload = () => resolve(reader.result);
870
+ reader.onerror = (error) => reject(error);
871
+ });
872
+ };
873
+ function FaceCaptureModal({
874
+ onCapture,
875
+ onCancel
876
+ }) {
877
+ const inputRef = React.useRef(null);
878
+ const [isProcessing, setIsProcessing] = React.useState(false);
879
+ const [isHoveringPrimary, setIsHoveringPrimary] = React.useState(false);
880
+ const [isHoveringCancel, setIsHoveringCancel] = React.useState(false);
881
+ const [isHoveringClose, setIsHoveringClose] = React.useState(false);
882
+ const isMobile = /Mobi|Android/i.test(navigator.userAgent);
883
+ const handleFileChange = async (e) => {
884
+ const file = e.target.files?.[0];
885
+ if (!file) return;
886
+ setIsProcessing(true);
887
+ try {
888
+ const base64 = await fileToBase64(file);
889
+ setTimeout(() => {
890
+ onCapture(base64);
891
+ }, 300);
892
+ } catch (error) {
893
+ console.error("Error processing image:", error);
894
+ setIsProcessing(false);
895
+ }
896
+ };
897
+ const overlayStyle = {
898
+ position: "fixed",
899
+ inset: 0,
900
+ background: "rgba(0, 0, 0, 0.6)",
901
+ backdropFilter: "blur(4px)",
902
+ display: "flex",
903
+ alignItems: "center",
904
+ justifyContent: "center",
905
+ zIndex: 999999,
906
+ padding: "16px",
907
+ animation: "fadeIn 0.2s ease-out"
908
+ };
909
+ const modalStyle = {
910
+ background: "#ffffff",
911
+ borderRadius: "16px",
912
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
913
+ width: "100%",
914
+ maxWidth: "448px",
915
+ animation: "zoomIn 0.2s ease-out"
916
+ };
917
+ const headerStyle = {
918
+ position: "relative",
919
+ padding: "24px 24px 16px",
920
+ borderBottom: "1px solid #f3f4f6"
921
+ };
922
+ const closeButtonStyle = {
923
+ position: "absolute",
924
+ top: "16px",
925
+ right: "16px",
926
+ padding: "8px",
927
+ background: isHoveringClose ? "#f3f4f6" : "transparent",
928
+ border: "none",
929
+ borderRadius: "9999px",
930
+ cursor: "pointer",
931
+ transition: "background-color 0.2s",
932
+ display: "flex",
933
+ alignItems: "center",
934
+ justifyContent: "center"
935
+ };
936
+ const titleStyle = {
937
+ fontSize: "24px",
938
+ fontWeight: 600,
939
+ color: "#111827",
940
+ margin: 0
941
+ };
942
+ const subtitleStyle = {
943
+ fontSize: "14px",
944
+ color: "#6b7280",
945
+ marginTop: "4px"
946
+ };
947
+ const contentStyle = {
948
+ padding: "32px 24px"
949
+ };
950
+ const visualGuideContainerStyle = {
951
+ marginBottom: "32px",
952
+ display: "flex",
953
+ justifyContent: "center"
954
+ };
955
+ const visualGuideStyle = {
956
+ position: "relative"
957
+ };
958
+ const circleStyle = {
959
+ width: "128px",
960
+ height: "128px",
961
+ borderRadius: "50%",
962
+ background: "linear-gradient(135deg, rgba(0, 188, 125, 0.2) 0%, rgba(0, 188, 125, 0.05) 100%)",
963
+ display: "flex",
964
+ alignItems: "center",
965
+ justifyContent: "center"
966
+ };
967
+ const badgeStyle = {
968
+ position: "absolute",
969
+ top: "-4px",
970
+ right: "-4px",
971
+ width: "32px",
972
+ height: "32px",
973
+ background: "#ffffff",
974
+ borderRadius: "50%",
975
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
976
+ display: "flex",
977
+ alignItems: "center",
978
+ justifyContent: "center"
979
+ };
980
+ const instructionsBoxStyle = {
981
+ background: "linear-gradient(135deg, #f9fafb 0%, rgba(243, 244, 246, 0.5) 100%)",
982
+ borderRadius: "12px",
983
+ padding: "16px",
984
+ marginBottom: "24px"
985
+ };
986
+ const instructionsTitleStyle = {
987
+ fontSize: "14px",
988
+ fontWeight: 500,
989
+ color: "#111827",
990
+ marginBottom: "8px"
991
+ };
992
+ const instructionsListStyle = {
993
+ fontSize: "12px",
994
+ color: "#6b7280",
995
+ listStyle: "none",
996
+ padding: 0,
997
+ margin: 0
998
+ };
999
+ const instructionItemStyle = {
1000
+ display: "flex",
1001
+ alignItems: "flex-start",
1002
+ marginBottom: "6px"
1003
+ };
1004
+ const bulletStyle = {
1005
+ color: "#00bc7d",
1006
+ marginRight: "8px",
1007
+ flexShrink: 0
1008
+ };
1009
+ const buttonsContainerStyle = {
1010
+ display: "flex",
1011
+ flexDirection: "column",
1012
+ gap: "12px"
1013
+ };
1014
+ const primaryButtonStyle = {
1015
+ width: "100%",
1016
+ background: isProcessing ? "#d1d5db" : isHoveringPrimary ? "#00a86d" : "#00bc7d",
1017
+ color: "#ffffff",
1018
+ fontWeight: 500,
1019
+ padding: "14px 24px",
1020
+ borderRadius: "12px",
1021
+ border: "none",
1022
+ cursor: isProcessing ? "not-allowed" : "pointer",
1023
+ transition: "all 0.2s",
1024
+ display: "flex",
1025
+ alignItems: "center",
1026
+ justifyContent: "center",
1027
+ gap: "12px",
1028
+ boxShadow: isProcessing ? "none" : isHoveringPrimary ? "0 20px 25px -5px rgba(0, 188, 125, 0.3)" : "0 10px 15px -3px rgba(0, 188, 125, 0.2)",
1029
+ fontSize: "16px"
1030
+ };
1031
+ const cancelButtonStyle = {
1032
+ width: "100%",
1033
+ background: isProcessing ? "#f3f4f6" : isHoveringCancel ? "#f9fafb" : "#ffffff",
1034
+ color: "#374151",
1035
+ fontWeight: 500,
1036
+ padding: "14px 24px",
1037
+ borderRadius: "12px",
1038
+ border: "2px solid #e5e7eb",
1039
+ cursor: isProcessing ? "not-allowed" : "pointer",
1040
+ transition: "all 0.2s",
1041
+ fontSize: "16px"
1042
+ };
1043
+ const footerStyle = {
1044
+ padding: "0 24px 24px"
1045
+ };
1046
+ const footerTextStyle = {
1047
+ fontSize: "12px",
1048
+ textAlign: "center",
1049
+ color: "#9ca3af",
1050
+ margin: 0
1051
+ };
1052
+ const spinnerStyle = {
1053
+ width: "20px",
1054
+ height: "20px",
1055
+ border: "2px solid rgba(255, 255, 255, 0.3)",
1056
+ borderTopColor: "#ffffff",
1057
+ borderRadius: "50%",
1058
+ animation: "spin 0.6s linear infinite"
1059
+ };
1060
+ const hiddenInputStyle = {
1061
+ display: "none"
1062
+ };
1063
+ const styleTag = /* @__PURE__ */ React__default.default.createElement("style", null, `
1064
+ @keyframes fadeIn {
1065
+ from {
1066
+ opacity: 0;
1067
+ }
1068
+ to {
1069
+ opacity: 1;
1070
+ }
1071
+ }
1072
+
1073
+ @keyframes zoomIn {
1074
+ from {
1075
+ opacity: 0;
1076
+ transform: scale(0.95);
1077
+ }
1078
+ to {
1079
+ opacity: 1;
1080
+ transform: scale(1);
1081
+ }
1082
+ }
1083
+
1084
+ @keyframes spin {
1085
+ from {
1086
+ transform: rotate(0deg);
1087
+ }
1088
+ to {
1089
+ transform: rotate(360deg);
1090
+ }
1091
+ }
1092
+ `);
1093
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, styleTag, /* @__PURE__ */ React__default.default.createElement("div", { style: overlayStyle }, /* @__PURE__ */ React__default.default.createElement("div", { style: modalStyle }, /* @__PURE__ */ React__default.default.createElement("div", { style: headerStyle }, /* @__PURE__ */ React__default.default.createElement(
1094
+ "button",
1095
+ {
1096
+ onClick: onCancel,
1097
+ onMouseEnter: () => setIsHoveringClose(true),
1098
+ onMouseLeave: () => setIsHoveringClose(false),
1099
+ style: closeButtonStyle,
1100
+ "aria-label": "Close"
1101
+ },
1102
+ /* @__PURE__ */ React__default.default.createElement("img", { src: Close, alt: "Close Icon", width: 16, height: 16 })
1103
+ ), /* @__PURE__ */ React__default.default.createElement("h2", { style: titleStyle }, "Face Verification"), /* @__PURE__ */ React__default.default.createElement("p", { style: subtitleStyle }, "Please capture or upload a clear photo of your face")), /* @__PURE__ */ React__default.default.createElement("div", { style: contentStyle }, /* @__PURE__ */ React__default.default.createElement("div", { style: visualGuideContainerStyle }, /* @__PURE__ */ React__default.default.createElement("div", { style: visualGuideStyle }, /* @__PURE__ */ React__default.default.createElement("div", { style: circleStyle }, /* @__PURE__ */ React__default.default.createElement("img", { src: Camera, alt: "Camera Icon", width: 48, height: 48 })), /* @__PURE__ */ React__default.default.createElement("div", { style: badgeStyle }, /* @__PURE__ */ React__default.default.createElement("img", { src: Done, alt: "Check Icon", width: 16, height: 16 })))), /* @__PURE__ */ React__default.default.createElement("div", { style: instructionsBoxStyle }, /* @__PURE__ */ React__default.default.createElement("h3", { style: instructionsTitleStyle }, "Tips for best results:"), /* @__PURE__ */ React__default.default.createElement("ul", { style: instructionsListStyle }, /* @__PURE__ */ React__default.default.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React__default.default.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React__default.default.createElement("span", null, "Ensure good lighting on your face")), /* @__PURE__ */ React__default.default.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React__default.default.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React__default.default.createElement("span", null, "Remove glasses or accessories if possible")), /* @__PURE__ */ React__default.default.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React__default.default.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React__default.default.createElement("span", null, "Look directly at the camera")))), /* @__PURE__ */ React__default.default.createElement(
1104
+ "input",
1105
+ {
1106
+ ref: inputRef,
1107
+ type: "file",
1108
+ accept: "image/*",
1109
+ capture: isMobile ? "user" : void 0,
1110
+ style: hiddenInputStyle,
1111
+ onChange: handleFileChange,
1112
+ disabled: isProcessing
1113
+ }
1114
+ ), /* @__PURE__ */ React__default.default.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React__default.default.createElement(
1115
+ "button",
1116
+ {
1117
+ onClick: () => inputRef.current?.click(),
1118
+ onMouseEnter: () => setIsHoveringPrimary(true),
1119
+ onMouseLeave: () => setIsHoveringPrimary(false),
1120
+ disabled: isProcessing,
1121
+ style: primaryButtonStyle
1122
+ },
1123
+ isProcessing ? /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement("div", { style: spinnerStyle }), /* @__PURE__ */ React__default.default.createElement("span", null, "Processing...")) : /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, isMobile ? /* @__PURE__ */ React__default.default.createElement("img", { src: Camera, alt: "Camera Icon", width: 20, height: 20 }) : /* @__PURE__ */ React__default.default.createElement("img", { src: Upload, alt: "Upload Icon", width: 20, height: 20 }), /* @__PURE__ */ React__default.default.createElement("span", null, isMobile ? "Capture Photo" : "Upload Photo"))
1124
+ ), /* @__PURE__ */ React__default.default.createElement(
1125
+ "button",
1126
+ {
1127
+ onClick: onCancel,
1128
+ onMouseEnter: () => setIsHoveringCancel(true),
1129
+ onMouseLeave: () => setIsHoveringCancel(false),
1130
+ disabled: isProcessing,
1131
+ style: cancelButtonStyle
1132
+ },
1133
+ "Cancel"
1134
+ ))), /* @__PURE__ */ React__default.default.createElement("div", { style: footerStyle }, /* @__PURE__ */ React__default.default.createElement("p", { style: footerTextStyle }, "Your photo will be securely processed and used only for verification purposes")))));
1135
+ }
1136
+ var FaceCaptureModal_default = FaceCaptureModal;
1137
+
1138
+ // src/kyc/hooks.ts
852
1139
  function useAutoFetch(autoFetch, fetchFn) {
853
- react.useEffect(() => {
1140
+ React.useEffect(() => {
854
1141
  if (autoFetch) {
855
1142
  fetchFn();
856
1143
  }
857
1144
  }, [autoFetch, fetchFn]);
858
1145
  }
859
1146
  function usePolling(pollInterval, fetchFn) {
860
- const pollIntervalRef = react.useRef();
861
- react.useEffect(() => {
1147
+ const pollIntervalRef = React.useRef();
1148
+ React.useEffect(() => {
862
1149
  if (pollInterval && pollInterval > 0) {
863
1150
  pollIntervalRef.current = setInterval(fetchFn, pollInterval);
864
1151
  return () => {
@@ -871,10 +1158,10 @@ function usePolling(pollInterval, fetchFn) {
871
1158
  }, [pollInterval, fetchFn]);
872
1159
  }
873
1160
  function useKycSubmission(client, options = {}) {
874
- const [submission, setSubmission] = react.useState(null);
875
- const [loading, setLoading] = react.useState(false);
876
- const [error, setError] = react.useState(null);
877
- const submit = react.useCallback(
1161
+ const [submission, setSubmission] = React.useState(null);
1162
+ const [loading, setLoading] = React.useState(false);
1163
+ const [error, setError] = React.useState(null);
1164
+ const submit = React.useCallback(
878
1165
  async (request) => {
879
1166
  setLoading(true);
880
1167
  setError(null);
@@ -894,7 +1181,7 @@ function useKycSubmission(client, options = {}) {
894
1181
  },
895
1182
  [client, options]
896
1183
  );
897
- const reset = react.useCallback(() => {
1184
+ const reset = React.useCallback(() => {
898
1185
  setSubmission(null);
899
1186
  setError(null);
900
1187
  setLoading(false);
@@ -908,11 +1195,11 @@ function useKycSubmission(client, options = {}) {
908
1195
  };
909
1196
  }
910
1197
  function useKycRequests(client, options = {}) {
911
- const [requests, setRequests] = react.useState([]);
912
- const [pagination, setPagination] = react.useState(null);
913
- const [loading, setLoading] = react.useState(false);
914
- const [error, setError] = react.useState(null);
915
- const fetchRequests = react.useCallback(
1198
+ const [requests, setRequests] = React.useState([]);
1199
+ const [pagination, setPagination] = React.useState(null);
1200
+ const [loading, setLoading] = React.useState(false);
1201
+ const [error, setError] = React.useState(null);
1202
+ const fetchRequests = React.useCallback(
916
1203
  async (filters, paginationParams) => {
917
1204
  setLoading(true);
918
1205
  setError(null);
@@ -933,7 +1220,7 @@ function useKycRequests(client, options = {}) {
933
1220
  },
934
1221
  [client, options.filters, options.pagination]
935
1222
  );
936
- const getRequest = react.useCallback(
1223
+ const getRequest = React.useCallback(
937
1224
  async (id) => {
938
1225
  try {
939
1226
  return await client.getKycRequest(id);
@@ -945,7 +1232,7 @@ function useKycRequests(client, options = {}) {
945
1232
  },
946
1233
  [client]
947
1234
  );
948
- const updateStatus = react.useCallback(
1235
+ const updateStatus = React.useCallback(
949
1236
  async (reference, status, reason) => {
950
1237
  try {
951
1238
  await client.updateKycStatus({ reference, status, reason });
@@ -966,7 +1253,7 @@ function useKycRequests(client, options = {}) {
966
1253
  },
967
1254
  [client]
968
1255
  );
969
- const refresh = react.useCallback(async () => {
1256
+ const refresh = React.useCallback(async () => {
970
1257
  await fetchRequests();
971
1258
  }, [fetchRequests]);
972
1259
  useAutoFetch(options.autoFetch, fetchRequests);
@@ -983,11 +1270,11 @@ function useKycRequests(client, options = {}) {
983
1270
  };
984
1271
  }
985
1272
  function useKycAlerts(client, options = {}) {
986
- const [alerts, setAlerts] = react.useState([]);
987
- const [pagination, setPagination] = react.useState(null);
988
- const [loading, setLoading] = react.useState(false);
989
- const [error, setError] = react.useState(null);
990
- const fetchAlerts = react.useCallback(
1273
+ const [alerts, setAlerts] = React.useState([]);
1274
+ const [pagination, setPagination] = React.useState(null);
1275
+ const [loading, setLoading] = React.useState(false);
1276
+ const [error, setError] = React.useState(null);
1277
+ const fetchAlerts = React.useCallback(
991
1278
  async (filters, paginationParams) => {
992
1279
  setLoading(true);
993
1280
  setError(null);
@@ -1008,7 +1295,7 @@ function useKycAlerts(client, options = {}) {
1008
1295
  },
1009
1296
  [client, options.filters, options.pagination]
1010
1297
  );
1011
- const getAlert = react.useCallback(
1298
+ const getAlert = React.useCallback(
1012
1299
  async (id) => {
1013
1300
  try {
1014
1301
  return await client.getAlert(id);
@@ -1020,7 +1307,7 @@ function useKycAlerts(client, options = {}) {
1020
1307
  },
1021
1308
  [client]
1022
1309
  );
1023
- const updateAlert = react.useCallback(
1310
+ const updateAlert = React.useCallback(
1024
1311
  async (id, update) => {
1025
1312
  try {
1026
1313
  await client.updateAlert(id, update);
@@ -1037,7 +1324,7 @@ function useKycAlerts(client, options = {}) {
1037
1324
  },
1038
1325
  [client]
1039
1326
  );
1040
- const refresh = react.useCallback(async () => {
1327
+ const refresh = React.useCallback(async () => {
1041
1328
  await fetchAlerts();
1042
1329
  }, [fetchAlerts]);
1043
1330
  useAutoFetch(options.autoFetch, fetchAlerts);
@@ -1054,10 +1341,10 @@ function useKycAlerts(client, options = {}) {
1054
1341
  };
1055
1342
  }
1056
1343
  function useKycOverview(client, options = {}) {
1057
- const [overview, setOverview] = react.useState(null);
1058
- const [loading, setLoading] = react.useState(false);
1059
- const [error, setError] = react.useState(null);
1060
- const fetchOverview = react.useCallback(
1344
+ const [overview, setOverview] = React.useState(null);
1345
+ const [loading, setLoading] = React.useState(false);
1346
+ const [error, setError] = React.useState(null);
1347
+ const fetchOverview = React.useCallback(
1061
1348
  async (fromDate, toDate) => {
1062
1349
  setLoading(true);
1063
1350
  setError(null);
@@ -1086,10 +1373,10 @@ function useKycOverview(client, options = {}) {
1086
1373
  };
1087
1374
  }
1088
1375
  function useKycPreferences(client, autoFetch = true) {
1089
- const [preferences, setPreferences] = react.useState(null);
1090
- const [loading, setLoading] = react.useState(false);
1091
- const [error, setError] = react.useState(null);
1092
- const fetchPreferences = react.useCallback(async () => {
1376
+ const [preferences, setPreferences] = React.useState(null);
1377
+ const [loading, setLoading] = React.useState(false);
1378
+ const [error, setError] = React.useState(null);
1379
+ const fetchPreferences = React.useCallback(async () => {
1093
1380
  setLoading(true);
1094
1381
  setError(null);
1095
1382
  try {
@@ -1103,7 +1390,7 @@ function useKycPreferences(client, autoFetch = true) {
1103
1390
  setLoading(false);
1104
1391
  }
1105
1392
  }, [client]);
1106
- const updatePreferences = react.useCallback(
1393
+ const updatePreferences = React.useCallback(
1107
1394
  async (update) => {
1108
1395
  setLoading(true);
1109
1396
  setError(null);
@@ -1129,7 +1416,7 @@ function useKycPreferences(client, autoFetch = true) {
1129
1416
  refresh: fetchPreferences
1130
1417
  };
1131
1418
  }
1132
- function fileToBase64(file) {
1419
+ function fileToBase642(file) {
1133
1420
  return new Promise((resolve, reject) => {
1134
1421
  const reader = new FileReader();
1135
1422
  reader.onload = () => {
@@ -1185,9 +1472,44 @@ function getRiskColor(risk) {
1185
1472
  };
1186
1473
  return colorMap[risk] || "#6b7280";
1187
1474
  }
1475
+ function useReuseKYCSubmission(client$1) {
1476
+ const verifyFace = (reference, token) => {
1477
+ return new Promise((resolve, reject) => {
1478
+ const container = document.createElement("div");
1479
+ document.body.appendChild(container);
1480
+ const root = client.createRoot(container);
1481
+ const cleanup = () => {
1482
+ root.unmount();
1483
+ document.body.removeChild(container);
1484
+ };
1485
+ const modal = React.createElement(FaceCaptureModal_default, {
1486
+ onCapture: async (base64) => {
1487
+ try {
1488
+ const resp = await client$1.submitReuseKycSession({
1489
+ proof: base64,
1490
+ reference,
1491
+ token
1492
+ });
1493
+ resolve(resp);
1494
+ } catch (error) {
1495
+ reject(error instanceof Error ? error : new Error("Face verification failed"));
1496
+ } finally {
1497
+ cleanup();
1498
+ }
1499
+ },
1500
+ onCancel: () => {
1501
+ cleanup();
1502
+ resolve(null);
1503
+ }
1504
+ });
1505
+ root.render(modal);
1506
+ });
1507
+ };
1508
+ return { verifyFace };
1509
+ }
1188
1510
 
1189
1511
  exports.createDeviceFingerprint = createDeviceFingerprint;
1190
- exports.fileToBase64 = fileToBase64;
1512
+ exports.fileToBase64 = fileToBase642;
1191
1513
  exports.formatKycStatus = formatKycStatus;
1192
1514
  exports.getBrowserInfo = getBrowserInfo;
1193
1515
  exports.getRiskColor = getRiskColor;
@@ -1206,6 +1528,7 @@ exports.useLocationCapture = useLocationCapture;
1206
1528
  exports.useLocationRequests = useLocationRequests;
1207
1529
  exports.useLoginVerification = useLoginVerification;
1208
1530
  exports.useRegistration = useRegistration;
1531
+ exports.useReuseKYCSubmission = useReuseKYCSubmission;
1209
1532
  exports.useTransactionVerification = useTransactionVerification;
1210
1533
  //# sourceMappingURL=react.js.map
1211
1534
  //# sourceMappingURL=react.js.map