astra-sdk-web 1.1.28 → 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.
- package/dist/astra-sdk.cjs.js +23 -106
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.css.map +1 -1
- package/dist/astra-sdk.es.js +23 -106
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +23 -106
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.css.map +1 -1
- package/dist/components.es.js +23 -106
- package/dist/components.es.js.map +1 -1
- package/package.json +1 -1
- package/src/index.css +0 -5
- package/src/pages/MobileRoute.tsx +14 -33
- package/src/pages/QRCodePage.tsx +17 -10
- package/src/utils/kycConfigStorage.ts +0 -125
package/dist/astra-sdk.cjs.js
CHANGED
|
@@ -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,36 +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
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
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");
|
|
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");
|
|
2000
1911
|
}
|
|
2001
1912
|
}, [onNavigate]);
|
|
2002
1913
|
const handleClose = () => {
|
|
@@ -2027,7 +1938,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
2027
1938
|
}
|
|
2028
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: [
|
|
2029
1940
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
|
|
2030
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId
|
|
1941
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId, apiBaseUrl, and serverKey parameters." })
|
|
2031
1942
|
] }) });
|
|
2032
1943
|
}
|
|
2033
1944
|
var MobileRoute_default = MobileRoute;
|
|
@@ -2035,14 +1946,20 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
|
|
|
2035
1946
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
2036
1947
|
const [copied, setCopied] = React.useState(false);
|
|
2037
1948
|
React.useEffect(() => {
|
|
2038
|
-
|
|
2039
|
-
storeKycConfig(sessionId, apiBaseUrl, serverKey);
|
|
2040
|
-
}
|
|
1949
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
2041
1950
|
if (sessionId) {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
1951
|
+
searchParams.set("sessionId", sessionId);
|
|
1952
|
+
}
|
|
1953
|
+
if (apiBaseUrl) {
|
|
1954
|
+
searchParams.set("apiBaseUrl", apiBaseUrl);
|
|
1955
|
+
}
|
|
1956
|
+
if (serverKey) {
|
|
1957
|
+
searchParams.set("serverKey", serverKey);
|
|
2045
1958
|
}
|
|
1959
|
+
const mobileRoute = "/mobileroute";
|
|
1960
|
+
const queryString = searchParams.toString();
|
|
1961
|
+
const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
|
|
1962
|
+
setQrUrl(fullUrl);
|
|
2046
1963
|
}, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
|
|
2047
1964
|
const handleCopyUrl = async () => {
|
|
2048
1965
|
if (qrUrl) {
|