astra-sdk-web 1.1.26 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/astra-sdk.cjs.js +108 -25
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.css +0 -3
- package/dist/astra-sdk.css.map +1 -1
- package/dist/astra-sdk.es.js +108 -25
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +108 -25
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.css +0 -3
- package/dist/components.css.map +1 -1
- package/dist/components.es.js +108 -25
- package/dist/components.es.js.map +1 -1
- package/package.json +1 -1
- package/src/pages/MobileRoute.tsx +33 -14
- package/src/pages/QRCodePage.tsx +12 -19
- package/src/utils/kycConfigStorage.ts +125 -0
package/dist/astra-sdk.cjs.js
CHANGED
|
@@ -485,6 +485,81 @@ 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
|
+
}
|
|
488
563
|
function useDocumentUpload(callbacks) {
|
|
489
564
|
const [state, setState] = React.useState({
|
|
490
565
|
docType: "CNIC",
|
|
@@ -1892,22 +1967,36 @@ function MobileRouteContent({ onClose, onComplete }) {
|
|
|
1892
1967
|
function MobileRoute({ onClose, onNavigate } = {}) {
|
|
1893
1968
|
const [config, setConfig] = React.useState(null);
|
|
1894
1969
|
React.useEffect(() => {
|
|
1970
|
+
clearExpiredConfigs();
|
|
1895
1971
|
if (!isMobileDevice() && onNavigate) {
|
|
1896
1972
|
onNavigate("qr");
|
|
1897
1973
|
return;
|
|
1898
1974
|
}
|
|
1899
1975
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1900
1976
|
const sessionId = searchParams.get("sessionId");
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1977
|
+
if (sessionId) {
|
|
1978
|
+
const storedConfig = getKycConfig(sessionId);
|
|
1979
|
+
if (storedConfig) {
|
|
1980
|
+
setConfig({
|
|
1981
|
+
apiBaseUrl: storedConfig.apiBaseUrl,
|
|
1982
|
+
sessionId,
|
|
1983
|
+
serverKey: storedConfig.serverKey
|
|
1984
|
+
});
|
|
1985
|
+
} else {
|
|
1986
|
+
const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
|
|
1987
|
+
const serverKey = searchParams.get("serverKey") || "";
|
|
1988
|
+
if (apiBaseUrl && serverKey) {
|
|
1989
|
+
setConfig({
|
|
1990
|
+
apiBaseUrl,
|
|
1991
|
+
sessionId,
|
|
1992
|
+
serverKey
|
|
1993
|
+
});
|
|
1994
|
+
} else {
|
|
1995
|
+
console.error("Missing required parameters: apiBaseUrl and serverKey not found in localStorage or URL");
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
} else {
|
|
1999
|
+
console.error("Missing required parameter: sessionId must be in URL");
|
|
1911
2000
|
}
|
|
1912
2001
|
}, [onNavigate]);
|
|
1913
2002
|
const handleClose = () => {
|
|
@@ -1938,7 +2027,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1938
2027
|
}
|
|
1939
2028
|
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: [
|
|
1940
2029
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
|
|
1941
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId
|
|
2030
|
+
/* @__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." })
|
|
1942
2031
|
] }) });
|
|
1943
2032
|
}
|
|
1944
2033
|
var MobileRoute_default = MobileRoute;
|
|
@@ -1946,20 +2035,14 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
|
|
|
1946
2035
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
1947
2036
|
const [copied, setCopied] = React.useState(false);
|
|
1948
2037
|
React.useEffect(() => {
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
searchParams.set("sessionId", sessionId);
|
|
1952
|
-
}
|
|
1953
|
-
if (apiBaseUrl) {
|
|
1954
|
-
searchParams.set("apiBaseUrl", apiBaseUrl);
|
|
2038
|
+
if (sessionId && apiBaseUrl && serverKey) {
|
|
2039
|
+
storeKycConfig(sessionId, apiBaseUrl, serverKey);
|
|
1955
2040
|
}
|
|
1956
|
-
if (
|
|
1957
|
-
|
|
2041
|
+
if (sessionId) {
|
|
2042
|
+
const mobileRoute = "/mobileroute";
|
|
2043
|
+
const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}`;
|
|
2044
|
+
setQrUrl(fullUrl);
|
|
1958
2045
|
}
|
|
1959
|
-
const mobileRoute = "/mobileroute";
|
|
1960
|
-
const queryString = searchParams.toString();
|
|
1961
|
-
const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
|
|
1962
|
-
setQrUrl(fullUrl);
|
|
1963
2046
|
}, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
|
|
1964
2047
|
const handleCopyUrl = async () => {
|
|
1965
2048
|
if (qrUrl) {
|
|
@@ -2001,7 +2084,7 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
|
|
|
2001
2084
|
backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,
|
|
2002
2085
|
backgroundSize: "40px 40px"
|
|
2003
2086
|
} }),
|
|
2004
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative bg-[rgba(20,20,20,0.95)] backdrop-blur-sm rounded-2xl p-5 sm:p-6 md:p-7 max-w-[450px] w-full h-[80vh] flex flex-col text-center shadow-[0_8px_32px_rgba(0,0,0,0.5)]
|
|
2087
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative bg-[rgba(20,20,20,0.95)] backdrop-blur-sm rounded-2xl p-5 sm:p-6 md:p-7 max-w-[450px] w-full h-[80vh] flex flex-col text-center shadow-[0_8px_32px_rgba(0,0,0,0.5)]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
|
|
2005
2088
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
|
|
2006
2089
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 text-white text-sm sm:text-base opacity-90 leading-relaxed", children: "Scan this QR on your phone to capture your face and document" }),
|
|
2007
2090
|
qrUrl && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center p-3 sm:p-4 bg-black rounded-xl border-2 border-white shadow-lg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2018,7 +2101,7 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
|
|
|
2018
2101
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
|
|
2019
2102
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
|
|
2020
2103
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row items-start sm:items-center gap-2 p-2 sm:p-3 bg-white/10 rounded-lg border border-white/20", children: [
|
|
2021
|
-
/* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono line-clamp-1", children: qrUrl }),
|
|
2104
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono line-clamp-1 ", children: qrUrl }),
|
|
2022
2105
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2023
2106
|
"button",
|
|
2024
2107
|
{
|