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.
- package/dist/astra-sdk.cjs.js +23 -126
- package/dist/astra-sdk.cjs.js.map +1 -1
- package/dist/astra-sdk.css.map +1 -1
- package/dist/astra-sdk.es.js +23 -126
- package/dist/astra-sdk.es.js.map +1 -1
- package/dist/components.cjs.js +23 -126
- package/dist/components.cjs.js.map +1 -1
- package/dist/components.css.map +1 -1
- package/dist/components.es.js +23 -126
- package/dist/components.es.js.map +1 -1
- package/package.json +1 -1
- package/src/index.css +0 -5
- package/src/pages/MobileRoute.tsx +15 -51
- package/src/pages/QRCodePage.tsx +17 -18
- package/src/utils/kycConfigStorage.ts +0 -125
package/dist/components.cjs.js
CHANGED
|
@@ -280,81 +280,6 @@ function isMobileDevice() {
|
|
|
280
280
|
const hasTouchScreen = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
281
281
|
return mobileRegex.test(userAgent) || isSmallScreen && hasTouchScreen;
|
|
282
282
|
}
|
|
283
|
-
|
|
284
|
-
// src/utils/kycConfigStorage.ts
|
|
285
|
-
var STORAGE_PREFIX = "kyc_config_";
|
|
286
|
-
var STORAGE_EXPIRY_MS = 24 * 60 * 60 * 1e3;
|
|
287
|
-
function storeKycConfig(sessionId, apiBaseUrl, serverKey) {
|
|
288
|
-
if (!sessionId || !apiBaseUrl || !serverKey) {
|
|
289
|
-
console.warn("Cannot store KYC config: missing required parameters");
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
try {
|
|
293
|
-
const config = {
|
|
294
|
-
apiBaseUrl,
|
|
295
|
-
serverKey,
|
|
296
|
-
sessionId
|
|
297
|
-
};
|
|
298
|
-
const storageKey = `${STORAGE_PREFIX}${sessionId}`;
|
|
299
|
-
const data = {
|
|
300
|
-
config,
|
|
301
|
-
timestamp: Date.now()
|
|
302
|
-
};
|
|
303
|
-
localStorage.setItem(storageKey, JSON.stringify(data));
|
|
304
|
-
} catch (error) {
|
|
305
|
-
console.error("Failed to store KYC config:", error);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function getKycConfig(sessionId) {
|
|
309
|
-
if (!sessionId) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
try {
|
|
313
|
-
const storageKey = `${STORAGE_PREFIX}${sessionId}`;
|
|
314
|
-
const stored = localStorage.getItem(storageKey);
|
|
315
|
-
if (!stored) {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
const data = JSON.parse(stored);
|
|
319
|
-
if (data.timestamp && Date.now() - data.timestamp > STORAGE_EXPIRY_MS) {
|
|
320
|
-
localStorage.removeItem(storageKey);
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
if (data.config && data.config.apiBaseUrl && data.config.serverKey) {
|
|
324
|
-
return {
|
|
325
|
-
apiBaseUrl: data.config.apiBaseUrl,
|
|
326
|
-
serverKey: data.config.serverKey
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
return null;
|
|
330
|
-
} catch (error) {
|
|
331
|
-
console.error("Failed to retrieve KYC config:", error);
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function clearExpiredConfigs() {
|
|
336
|
-
try {
|
|
337
|
-
const keys = Object.keys(localStorage);
|
|
338
|
-
const now = Date.now();
|
|
339
|
-
keys.forEach((key) => {
|
|
340
|
-
if (key.startsWith(STORAGE_PREFIX)) {
|
|
341
|
-
try {
|
|
342
|
-
const stored = localStorage.getItem(key);
|
|
343
|
-
if (stored) {
|
|
344
|
-
const data = JSON.parse(stored);
|
|
345
|
-
if (data.timestamp && now - data.timestamp > STORAGE_EXPIRY_MS) {
|
|
346
|
-
localStorage.removeItem(key);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
} catch (error) {
|
|
350
|
-
localStorage.removeItem(key);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
} catch (error) {
|
|
355
|
-
console.error("Failed to clear expired configs:", error);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
283
|
function useDocumentUpload(callbacks) {
|
|
359
284
|
const [state, setState] = React.useState({
|
|
360
285
|
docType: "CNIC",
|
|
@@ -1762,50 +1687,22 @@ function MobileRouteContent({ onClose, onComplete }) {
|
|
|
1762
1687
|
function MobileRoute({ onClose, onNavigate } = {}) {
|
|
1763
1688
|
const [config, setConfig] = React.useState(null);
|
|
1764
1689
|
React.useEffect(() => {
|
|
1765
|
-
clearExpiredConfigs();
|
|
1766
1690
|
if (!isMobileDevice() && onNavigate) {
|
|
1767
1691
|
onNavigate("qr");
|
|
1768
1692
|
return;
|
|
1769
1693
|
}
|
|
1770
1694
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1771
1695
|
const sessionId = searchParams.get("sessionId");
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
}
|
|
1783
|
-
} catch (error) {
|
|
1784
|
-
console.error("Failed to decode config from URL:", error);
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
if (!apiBaseUrl || !serverKey) {
|
|
1788
|
-
const storedConfig = getKycConfig(sessionId);
|
|
1789
|
-
if (storedConfig) {
|
|
1790
|
-
apiBaseUrl = storedConfig.apiBaseUrl;
|
|
1791
|
-
serverKey = storedConfig.serverKey;
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
if (!apiBaseUrl || !serverKey) {
|
|
1795
|
-
apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
|
|
1796
|
-
serverKey = searchParams.get("serverKey") || "";
|
|
1797
|
-
}
|
|
1798
|
-
if (apiBaseUrl && serverKey) {
|
|
1799
|
-
setConfig({
|
|
1800
|
-
apiBaseUrl,
|
|
1801
|
-
sessionId,
|
|
1802
|
-
serverKey
|
|
1803
|
-
});
|
|
1804
|
-
} else {
|
|
1805
|
-
console.error("Missing required parameters: apiBaseUrl and serverKey not found in URL config, localStorage, or URL params");
|
|
1806
|
-
}
|
|
1807
|
-
} else {
|
|
1808
|
-
console.error("Missing required parameter: sessionId must be in URL");
|
|
1696
|
+
const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
|
|
1697
|
+
const serverKey = searchParams.get("serverKey") || "";
|
|
1698
|
+
if (sessionId && apiBaseUrl && serverKey) {
|
|
1699
|
+
setConfig({
|
|
1700
|
+
apiBaseUrl,
|
|
1701
|
+
sessionId,
|
|
1702
|
+
serverKey
|
|
1703
|
+
});
|
|
1704
|
+
} else if (sessionId) {
|
|
1705
|
+
console.error("Missing required parameters: apiBaseUrl and serverKey must be in URL");
|
|
1809
1706
|
}
|
|
1810
1707
|
}, [onNavigate]);
|
|
1811
1708
|
const handleClose = () => {
|
|
@@ -1836,7 +1733,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1836
1733
|
}
|
|
1837
1734
|
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: [
|
|
1838
1735
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
|
|
1839
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId
|
|
1736
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId, apiBaseUrl, and serverKey parameters." })
|
|
1840
1737
|
] }) });
|
|
1841
1738
|
}
|
|
1842
1739
|
var MobileRoute_default = MobileRoute;
|
|
@@ -1844,20 +1741,20 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
|
|
|
1844
1741
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
1845
1742
|
const [copied, setCopied] = React.useState(false);
|
|
1846
1743
|
React.useEffect(() => {
|
|
1847
|
-
|
|
1848
|
-
|
|
1744
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
1745
|
+
if (sessionId) {
|
|
1746
|
+
searchParams.set("sessionId", sessionId);
|
|
1849
1747
|
}
|
|
1850
|
-
if (
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
setQrUrl(fullUrl);
|
|
1856
|
-
} else if (sessionId) {
|
|
1857
|
-
const mobileRoute = "/mobileroute";
|
|
1858
|
-
const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}`;
|
|
1859
|
-
setQrUrl(fullUrl);
|
|
1748
|
+
if (apiBaseUrl) {
|
|
1749
|
+
searchParams.set("apiBaseUrl", apiBaseUrl);
|
|
1750
|
+
}
|
|
1751
|
+
if (serverKey) {
|
|
1752
|
+
searchParams.set("serverKey", serverKey);
|
|
1860
1753
|
}
|
|
1754
|
+
const mobileRoute = "/mobileroute";
|
|
1755
|
+
const queryString = searchParams.toString();
|
|
1756
|
+
const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
|
|
1757
|
+
setQrUrl(fullUrl);
|
|
1861
1758
|
}, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
|
|
1862
1759
|
const handleCopyUrl = async () => {
|
|
1863
1760
|
if (qrUrl) {
|