astra-sdk-web 1.1.29 → 1.1.30

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.
@@ -485,81 +485,6 @@ function isMobileDevice() {
485
485
  const hasTouchScreen = "ontouchstart" in window || navigator.maxTouchPoints > 0;
486
486
  return mobileRegex.test(userAgent) || isSmallScreen && hasTouchScreen;
487
487
  }
488
-
489
- // src/utils/kycConfigStorage.ts
490
- var STORAGE_PREFIX = "kyc_config_";
491
- var STORAGE_EXPIRY_MS = 24 * 60 * 60 * 1e3;
492
- function storeKycConfig(sessionId, apiBaseUrl, serverKey) {
493
- if (!sessionId || !apiBaseUrl || !serverKey) {
494
- console.warn("Cannot store KYC config: missing required parameters");
495
- return;
496
- }
497
- try {
498
- const config = {
499
- apiBaseUrl,
500
- serverKey,
501
- sessionId
502
- };
503
- const storageKey = `${STORAGE_PREFIX}${sessionId}`;
504
- const data = {
505
- config,
506
- timestamp: Date.now()
507
- };
508
- localStorage.setItem(storageKey, JSON.stringify(data));
509
- } catch (error) {
510
- console.error("Failed to store KYC config:", error);
511
- }
512
- }
513
- function getKycConfig(sessionId) {
514
- if (!sessionId) {
515
- return null;
516
- }
517
- try {
518
- const storageKey = `${STORAGE_PREFIX}${sessionId}`;
519
- const stored = localStorage.getItem(storageKey);
520
- if (!stored) {
521
- return null;
522
- }
523
- const data = JSON.parse(stored);
524
- if (data.timestamp && Date.now() - data.timestamp > STORAGE_EXPIRY_MS) {
525
- localStorage.removeItem(storageKey);
526
- return null;
527
- }
528
- if (data.config && data.config.apiBaseUrl && data.config.serverKey) {
529
- return {
530
- apiBaseUrl: data.config.apiBaseUrl,
531
- serverKey: data.config.serverKey
532
- };
533
- }
534
- return null;
535
- } catch (error) {
536
- console.error("Failed to retrieve KYC config:", error);
537
- return null;
538
- }
539
- }
540
- function clearExpiredConfigs() {
541
- try {
542
- const keys = Object.keys(localStorage);
543
- const now = Date.now();
544
- keys.forEach((key) => {
545
- if (key.startsWith(STORAGE_PREFIX)) {
546
- try {
547
- const stored = localStorage.getItem(key);
548
- if (stored) {
549
- const data = JSON.parse(stored);
550
- if (data.timestamp && now - data.timestamp > STORAGE_EXPIRY_MS) {
551
- localStorage.removeItem(key);
552
- }
553
- }
554
- } catch (error) {
555
- localStorage.removeItem(key);
556
- }
557
- }
558
- });
559
- } catch (error) {
560
- console.error("Failed to clear expired configs:", error);
561
- }
562
- }
563
488
  function useDocumentUpload(callbacks) {
564
489
  const [state, setState] = React.useState({
565
490
  docType: "CNIC",
@@ -1967,50 +1892,22 @@ function MobileRouteContent({ onClose, onComplete }) {
1967
1892
  function MobileRoute({ onClose, onNavigate } = {}) {
1968
1893
  const [config, setConfig] = React.useState(null);
1969
1894
  React.useEffect(() => {
1970
- clearExpiredConfigs();
1971
1895
  if (!isMobileDevice() && onNavigate) {
1972
1896
  onNavigate("qr");
1973
1897
  return;
1974
1898
  }
1975
1899
  const searchParams = new URLSearchParams(window.location.search);
1976
1900
  const sessionId = searchParams.get("sessionId");
1977
- if (sessionId) {
1978
- let apiBaseUrl = "";
1979
- let serverKey = "";
1980
- const encodedConfig = searchParams.get("config");
1981
- if (encodedConfig) {
1982
- try {
1983
- const decodedConfig = JSON.parse(atob(encodedConfig));
1984
- if (decodedConfig.apiBaseUrl && decodedConfig.serverKey) {
1985
- apiBaseUrl = decodedConfig.apiBaseUrl;
1986
- serverKey = decodedConfig.serverKey;
1987
- }
1988
- } catch (error) {
1989
- console.error("Failed to decode config from URL:", error);
1990
- }
1991
- }
1992
- if (!apiBaseUrl || !serverKey) {
1993
- const storedConfig = getKycConfig(sessionId);
1994
- if (storedConfig) {
1995
- apiBaseUrl = storedConfig.apiBaseUrl;
1996
- serverKey = storedConfig.serverKey;
1997
- }
1998
- }
1999
- if (!apiBaseUrl || !serverKey) {
2000
- apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
2001
- serverKey = searchParams.get("serverKey") || "";
2002
- }
2003
- if (apiBaseUrl && serverKey) {
2004
- setConfig({
2005
- apiBaseUrl,
2006
- sessionId,
2007
- serverKey
2008
- });
2009
- } else {
2010
- console.error("Missing required parameters: apiBaseUrl and serverKey not found in URL config, localStorage, or URL params");
2011
- }
2012
- } else {
2013
- console.error("Missing required parameter: sessionId must be in URL");
1901
+ const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1902
+ const serverKey = searchParams.get("serverKey") || "";
1903
+ if (sessionId && apiBaseUrl && serverKey) {
1904
+ setConfig({
1905
+ apiBaseUrl,
1906
+ sessionId,
1907
+ serverKey
1908
+ });
1909
+ } else if (sessionId) {
1910
+ console.error("Missing required parameters: apiBaseUrl and serverKey must be in URL");
2014
1911
  }
2015
1912
  }, [onNavigate]);
2016
1913
  const handleClose = () => {
@@ -2041,7 +1938,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
2041
1938
  }
2042
1939
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 flex items-center justify-center bg-black/50 z-[1000]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white p-6 rounded-lg text-center max-w-md mx-4", children: [
2043
1940
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
2044
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId parameter. The configuration should be stored automatically when scanning the QR code." })
1941
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId, apiBaseUrl, and serverKey parameters." })
2045
1942
  ] }) });
2046
1943
  }
2047
1944
  var MobileRoute_default = MobileRoute;
@@ -2049,20 +1946,20 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
2049
1946
  const [qrUrl, setQrUrl] = React.useState("");
2050
1947
  const [copied, setCopied] = React.useState(false);
2051
1948
  React.useEffect(() => {
2052
- if (sessionId && apiBaseUrl && serverKey) {
2053
- storeKycConfig(sessionId, apiBaseUrl, serverKey);
1949
+ const searchParams = new URLSearchParams(window.location.search);
1950
+ if (sessionId) {
1951
+ searchParams.set("sessionId", sessionId);
2054
1952
  }
2055
- if (sessionId && apiBaseUrl && serverKey) {
2056
- const mobileRoute = "/mobileroute";
2057
- const config = JSON.stringify({ apiBaseUrl, serverKey });
2058
- const encodedConfig = btoa(config);
2059
- const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}&config=${encodedConfig}`;
2060
- setQrUrl(fullUrl);
2061
- } else if (sessionId) {
2062
- const mobileRoute = "/mobileroute";
2063
- const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}`;
2064
- setQrUrl(fullUrl);
1953
+ if (apiBaseUrl) {
1954
+ searchParams.set("apiBaseUrl", apiBaseUrl);
1955
+ }
1956
+ if (serverKey) {
1957
+ searchParams.set("serverKey", serverKey);
2065
1958
  }
1959
+ const mobileRoute = "/mobileroute";
1960
+ const queryString = searchParams.toString();
1961
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1962
+ setQrUrl(fullUrl);
2066
1963
  }, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
2067
1964
  const handleCopyUrl = async () => {
2068
1965
  if (qrUrl) {