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/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,36 +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
|
-
const serverKey = searchParams.get("serverKey") || "";
|
|
1783
|
-
if (apiBaseUrl && serverKey) {
|
|
1784
|
-
setConfig({
|
|
1785
|
-
apiBaseUrl,
|
|
1786
|
-
sessionId,
|
|
1787
|
-
serverKey
|
|
1788
|
-
});
|
|
1789
|
-
} else {
|
|
1790
|
-
console.error("Missing required parameters: apiBaseUrl and serverKey not found in localStorage or URL");
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
} else {
|
|
1794
|
-
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");
|
|
1795
1706
|
}
|
|
1796
1707
|
}, [onNavigate]);
|
|
1797
1708
|
const handleClose = () => {
|
|
@@ -1822,7 +1733,7 @@ function MobileRoute({ onClose, onNavigate } = {}) {
|
|
|
1822
1733
|
}
|
|
1823
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: [
|
|
1824
1735
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
|
|
1825
|
-
/* @__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." })
|
|
1826
1737
|
] }) });
|
|
1827
1738
|
}
|
|
1828
1739
|
var MobileRoute_default = MobileRoute;
|
|
@@ -1830,14 +1741,20 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
|
|
|
1830
1741
|
const [qrUrl, setQrUrl] = React.useState("");
|
|
1831
1742
|
const [copied, setCopied] = React.useState(false);
|
|
1832
1743
|
React.useEffect(() => {
|
|
1833
|
-
|
|
1834
|
-
storeKycConfig(sessionId, apiBaseUrl, serverKey);
|
|
1835
|
-
}
|
|
1744
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
1836
1745
|
if (sessionId) {
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1746
|
+
searchParams.set("sessionId", sessionId);
|
|
1747
|
+
}
|
|
1748
|
+
if (apiBaseUrl) {
|
|
1749
|
+
searchParams.set("apiBaseUrl", apiBaseUrl);
|
|
1750
|
+
}
|
|
1751
|
+
if (serverKey) {
|
|
1752
|
+
searchParams.set("serverKey", serverKey);
|
|
1840
1753
|
}
|
|
1754
|
+
const mobileRoute = "/mobileroute";
|
|
1755
|
+
const queryString = searchParams.toString();
|
|
1756
|
+
const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
|
|
1757
|
+
setQrUrl(fullUrl);
|
|
1841
1758
|
}, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
|
|
1842
1759
|
const handleCopyUrl = async () => {
|
|
1843
1760
|
if (qrUrl) {
|