astra-sdk-web 1.1.2 → 1.1.4

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.
@@ -1325,19 +1325,16 @@ function FaceScanModal({ onComplete }) {
1325
1325
  ] }) });
1326
1326
  }
1327
1327
  var FaceScanModal_default = FaceScanModal;
1328
- function MobileRoute({ onClose } = {}) {
1329
- const navigate = reactRouterDom.useNavigate();
1328
+ function MobileRoute({ onClose, onNavigate } = {}) {
1330
1329
  React.useEffect(() => {
1331
- if (!isMobileDevice()) {
1332
- navigate("/qr", { replace: true });
1330
+ if (!isMobileDevice() && onNavigate) {
1331
+ onNavigate("qr");
1333
1332
  return;
1334
1333
  }
1335
- }, [navigate]);
1334
+ }, [onNavigate]);
1336
1335
  const handleClose = () => {
1337
1336
  if (onClose) {
1338
1337
  onClose();
1339
- } else {
1340
- navigate(-1);
1341
1338
  }
1342
1339
  };
1343
1340
  const handleComplete = (capturedImage) => {
@@ -1349,22 +1346,19 @@ function MobileRoute({ onClose } = {}) {
1349
1346
  return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose: handleClose, onComplete: handleComplete });
1350
1347
  }
1351
1348
  var MobileRoute_default = MobileRoute;
1352
- function QRCodePage({ onClose } = {}) {
1353
- const [searchParams] = reactRouterDom.useSearchParams();
1354
- const navigate = reactRouterDom.useNavigate();
1349
+ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app", sessionId } = {}) {
1355
1350
  const [qrUrl, setQrUrl] = React.useState("");
1356
1351
  const [copied, setCopied] = React.useState(false);
1357
1352
  React.useEffect(() => {
1358
- const currentUrl = window.location.origin;
1359
- const params = {};
1360
- searchParams.forEach((value, key) => {
1361
- params[key] = value;
1362
- });
1353
+ const searchParams = new URLSearchParams(window.location.search);
1354
+ if (sessionId) {
1355
+ searchParams.set("sessionId", sessionId);
1356
+ }
1363
1357
  const mobileRoute = "/mobileroute";
1364
- const queryString = new URLSearchParams(params).toString();
1365
- const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1358
+ const queryString = searchParams.toString();
1359
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1366
1360
  setQrUrl(fullUrl);
1367
- }, [searchParams]);
1361
+ }, [mobileBaseUrl, sessionId]);
1368
1362
  const handleCopyUrl = async () => {
1369
1363
  if (qrUrl) {
1370
1364
  try {
@@ -1379,69 +1373,73 @@ function QRCodePage({ onClose } = {}) {
1379
1373
  const handleClose = () => {
1380
1374
  if (onClose) {
1381
1375
  onClose();
1382
- } else {
1383
- navigate(-1);
1384
1376
  }
1385
1377
  };
1386
1378
  const handleRefresh = () => {
1387
1379
  window.location.reload();
1388
1380
  };
1389
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 flex items-center justify-center bg-black p-4 sm:p-6 md:p-8 z-[1000]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative bg-[rgba(20,20,20,0.95)] 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: [
1390
- /* @__PURE__ */ jsxRuntime.jsx(
1391
- "button",
1392
- {
1393
- className: "absolute top-5 right-5 bg-transparent border-none text-white cursor-pointer p-2 flex items-center justify-center rounded transition-colors hover:bg-white/10 active:bg-white/20",
1394
- onClick: handleClose,
1395
- "aria-label": "Close",
1396
- children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1397
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1398
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1399
- ] })
1400
- }
1401
- ),
1402
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1403
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1404
- /* @__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" }),
1405
- qrUrl && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center p-3 sm:p-4 bg-white rounded-xl border-2 border-white", children: /* @__PURE__ */ jsxRuntime.jsx(
1406
- qrcode_react.QRCodeSVG,
1407
- {
1408
- value: qrUrl,
1409
- size: 180,
1410
- level: "H",
1411
- includeMargin: true,
1412
- bgColor: "transparent",
1413
- fgColor: "#000000"
1414
- }
1415
- ) }),
1416
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1417
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1418
- /* @__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: [
1419
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1420
- /* @__PURE__ */ jsxRuntime.jsx(
1421
- "button",
1422
- {
1423
- className: "bg-transparent border-none text-white cursor-pointer p-1.5 flex items-center justify-center rounded transition-colors flex-shrink-0 hover:bg-white/10 active:bg-white/20 self-end sm:self-auto",
1424
- onClick: handleCopyUrl,
1425
- "aria-label": "Copy URL",
1426
- title: copied ? "Copied!" : "Copy URL",
1427
- children: copied ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "20 6 9 17 4 12" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1428
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1429
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1430
- ] })
1431
- }
1432
- )
1433
- ] })
1434
- ] }),
1381
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed inset-0 flex items-center justify-center bg-gradient-to-br from-gray-900 via-gray-800 to-black p-4 sm:p-6 md:p-8 z-[1000]", children: [
1382
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 opacity-10", style: {
1383
+ backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,
1384
+ backgroundSize: "40px 40px"
1385
+ } }),
1386
+ /* @__PURE__ */ jsxRuntime.jsxs("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)] border border-white/10", children: [
1435
1387
  /* @__PURE__ */ jsxRuntime.jsx(
1436
1388
  "button",
1437
1389
  {
1438
- className: "w-full py-3 sm:py-4 px-6 bg-gradient-to-r from-[#FF842D] to-[#FF2D55] border-none rounded-lg text-white text-sm sm:text-base font-semibold cursor-pointer transition-all hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(255,107,53,0.4)] active:translate-y-0",
1439
- onClick: handleRefresh,
1440
- children: "I've completed on mobile - Refresh"
1390
+ className: "absolute top-5 right-5 bg-transparent border-none text-white cursor-pointer p-2 flex items-center justify-center rounded transition-colors hover:bg-white/10 active:bg-white/20",
1391
+ onClick: handleClose,
1392
+ "aria-label": "Close",
1393
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1394
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1395
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1396
+ ] })
1441
1397
  }
1442
- )
1398
+ ),
1399
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1400
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1401
+ /* @__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" }),
1402
+ qrUrl && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center p-3 sm:p-4 bg-white rounded-xl border-2 border-white", children: /* @__PURE__ */ jsxRuntime.jsx(
1403
+ qrcode_react.QRCodeSVG,
1404
+ {
1405
+ value: qrUrl,
1406
+ size: 180,
1407
+ level: "H",
1408
+ includeMargin: true,
1409
+ bgColor: "transparent",
1410
+ fgColor: "#000000"
1411
+ }
1412
+ ) }),
1413
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1414
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1415
+ /* @__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: [
1416
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1417
+ /* @__PURE__ */ jsxRuntime.jsx(
1418
+ "button",
1419
+ {
1420
+ className: "bg-transparent border-none text-white cursor-pointer p-1.5 flex items-center justify-center rounded transition-colors flex-shrink-0 hover:bg-white/10 active:bg-white/20 self-end sm:self-auto",
1421
+ onClick: handleCopyUrl,
1422
+ "aria-label": "Copy URL",
1423
+ title: copied ? "Copied!" : "Copy URL",
1424
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "20 6 9 17 4 12" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1425
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1426
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1427
+ ] })
1428
+ }
1429
+ )
1430
+ ] })
1431
+ ] }),
1432
+ /* @__PURE__ */ jsxRuntime.jsx(
1433
+ "button",
1434
+ {
1435
+ className: "w-full py-3 sm:py-4 px-6 bg-gradient-to-r from-[#FF842D] to-[#FF2D55] border-none rounded-lg text-white text-sm sm:text-base font-semibold cursor-pointer transition-all hover:-translate-y-0.5 hover:shadow-[0_4px_12px_rgba(255,107,53,0.4)] active:translate-y-0",
1436
+ onClick: handleRefresh,
1437
+ children: "I've completed on mobile - Refresh"
1438
+ }
1439
+ )
1440
+ ] })
1443
1441
  ] })
1444
- ] }) });
1442
+ ] });
1445
1443
  }
1446
1444
  var QRCodePage_default = QRCodePage;
1447
1445
  var KycFlow = ({
@@ -1450,8 +1448,18 @@ var KycFlow = ({
1450
1448
  serverKey,
1451
1449
  deviceType,
1452
1450
  startAtQr = true,
1453
- onClose
1451
+ onClose,
1452
+ mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app"
1454
1453
  }) => {
1454
+ const [currentView, setCurrentView] = React.useState(startAtQr ? "qr" : "mobileroute");
1455
+ const handleNavigate = (view) => {
1456
+ setCurrentView(view);
1457
+ };
1458
+ const handleClose = () => {
1459
+ if (onClose) {
1460
+ onClose();
1461
+ }
1462
+ };
1455
1463
  return /* @__PURE__ */ jsxRuntime.jsx(
1456
1464
  KycProvider,
1457
1465
  {
@@ -1459,11 +1467,15 @@ var KycFlow = ({
1459
1467
  sessionId,
1460
1468
  serverKey,
1461
1469
  deviceType,
1462
- children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.MemoryRouter, { initialEntries: [startAtQr ? "/qr" : "/mobileroute"], children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
1463
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/", element: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: startAtQr ? "/qr" : "/mobileroute", replace: true }) }),
1464
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/qr", element: /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose }) }),
1465
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/mobileroute", element: /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose }) })
1466
- ] }) })
1470
+ children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(
1471
+ QRCodePage_default,
1472
+ {
1473
+ onClose: handleClose,
1474
+ onNavigate: handleNavigate,
1475
+ mobileBaseUrl,
1476
+ sessionId
1477
+ }
1478
+ ) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1467
1479
  }
1468
1480
  );
1469
1481
  };