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.
@@ -1530,19 +1530,16 @@ function FaceScanModal({ onComplete }) {
1530
1530
  ] }) });
1531
1531
  }
1532
1532
  var FaceScanModal_default = FaceScanModal;
1533
- function MobileRoute({ onClose } = {}) {
1534
- const navigate = reactRouterDom.useNavigate();
1533
+ function MobileRoute({ onClose, onNavigate } = {}) {
1535
1534
  React.useEffect(() => {
1536
- if (!isMobileDevice()) {
1537
- navigate("/qr", { replace: true });
1535
+ if (!isMobileDevice() && onNavigate) {
1536
+ onNavigate("qr");
1538
1537
  return;
1539
1538
  }
1540
- }, [navigate]);
1539
+ }, [onNavigate]);
1541
1540
  const handleClose = () => {
1542
1541
  if (onClose) {
1543
1542
  onClose();
1544
- } else {
1545
- navigate(-1);
1546
1543
  }
1547
1544
  };
1548
1545
  const handleComplete = (capturedImage) => {
@@ -1554,22 +1551,19 @@ function MobileRoute({ onClose } = {}) {
1554
1551
  return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose: handleClose, onComplete: handleComplete });
1555
1552
  }
1556
1553
  var MobileRoute_default = MobileRoute;
1557
- function QRCodePage({ onClose } = {}) {
1558
- const [searchParams] = reactRouterDom.useSearchParams();
1559
- const navigate = reactRouterDom.useNavigate();
1554
+ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app", sessionId } = {}) {
1560
1555
  const [qrUrl, setQrUrl] = React.useState("");
1561
1556
  const [copied, setCopied] = React.useState(false);
1562
1557
  React.useEffect(() => {
1563
- const currentUrl = window.location.origin;
1564
- const params = {};
1565
- searchParams.forEach((value, key) => {
1566
- params[key] = value;
1567
- });
1558
+ const searchParams = new URLSearchParams(window.location.search);
1559
+ if (sessionId) {
1560
+ searchParams.set("sessionId", sessionId);
1561
+ }
1568
1562
  const mobileRoute = "/mobileroute";
1569
- const queryString = new URLSearchParams(params).toString();
1570
- const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1563
+ const queryString = searchParams.toString();
1564
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1571
1565
  setQrUrl(fullUrl);
1572
- }, [searchParams]);
1566
+ }, [mobileBaseUrl, sessionId]);
1573
1567
  const handleCopyUrl = async () => {
1574
1568
  if (qrUrl) {
1575
1569
  try {
@@ -1584,69 +1578,73 @@ function QRCodePage({ onClose } = {}) {
1584
1578
  const handleClose = () => {
1585
1579
  if (onClose) {
1586
1580
  onClose();
1587
- } else {
1588
- navigate(-1);
1589
1581
  }
1590
1582
  };
1591
1583
  const handleRefresh = () => {
1592
1584
  window.location.reload();
1593
1585
  };
1594
- 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: [
1595
- /* @__PURE__ */ jsxRuntime.jsx(
1596
- "button",
1597
- {
1598
- 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",
1599
- onClick: handleClose,
1600
- "aria-label": "Close",
1601
- children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1602
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1603
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1604
- ] })
1605
- }
1606
- ),
1607
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1608
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1609
- /* @__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" }),
1610
- 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(
1611
- qrcode_react.QRCodeSVG,
1612
- {
1613
- value: qrUrl,
1614
- size: 180,
1615
- level: "H",
1616
- includeMargin: true,
1617
- bgColor: "transparent",
1618
- fgColor: "#000000"
1619
- }
1620
- ) }),
1621
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1622
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1623
- /* @__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: [
1624
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1625
- /* @__PURE__ */ jsxRuntime.jsx(
1626
- "button",
1627
- {
1628
- 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",
1629
- onClick: handleCopyUrl,
1630
- "aria-label": "Copy URL",
1631
- title: copied ? "Copied!" : "Copy URL",
1632
- 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: [
1633
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1634
- /* @__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" })
1635
- ] })
1636
- }
1637
- )
1638
- ] })
1639
- ] }),
1586
+ 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: [
1587
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 opacity-10", style: {
1588
+ backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,
1589
+ backgroundSize: "40px 40px"
1590
+ } }),
1591
+ /* @__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: [
1640
1592
  /* @__PURE__ */ jsxRuntime.jsx(
1641
1593
  "button",
1642
1594
  {
1643
- 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",
1644
- onClick: handleRefresh,
1645
- children: "I've completed on mobile - Refresh"
1595
+ 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",
1596
+ onClick: handleClose,
1597
+ "aria-label": "Close",
1598
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1599
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1600
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1601
+ ] })
1646
1602
  }
1647
- )
1603
+ ),
1604
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1605
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1606
+ /* @__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" }),
1607
+ 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(
1608
+ qrcode_react.QRCodeSVG,
1609
+ {
1610
+ value: qrUrl,
1611
+ size: 180,
1612
+ level: "H",
1613
+ includeMargin: true,
1614
+ bgColor: "transparent",
1615
+ fgColor: "#000000"
1616
+ }
1617
+ ) }),
1618
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1619
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1620
+ /* @__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: [
1621
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1622
+ /* @__PURE__ */ jsxRuntime.jsx(
1623
+ "button",
1624
+ {
1625
+ 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",
1626
+ onClick: handleCopyUrl,
1627
+ "aria-label": "Copy URL",
1628
+ title: copied ? "Copied!" : "Copy URL",
1629
+ 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: [
1630
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1631
+ /* @__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" })
1632
+ ] })
1633
+ }
1634
+ )
1635
+ ] })
1636
+ ] }),
1637
+ /* @__PURE__ */ jsxRuntime.jsx(
1638
+ "button",
1639
+ {
1640
+ 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",
1641
+ onClick: handleRefresh,
1642
+ children: "I've completed on mobile - Refresh"
1643
+ }
1644
+ )
1645
+ ] })
1648
1646
  ] })
1649
- ] }) });
1647
+ ] });
1650
1648
  }
1651
1649
  var QRCodePage_default = QRCodePage;
1652
1650
  var KycFlow = ({
@@ -1655,8 +1653,18 @@ var KycFlow = ({
1655
1653
  serverKey,
1656
1654
  deviceType,
1657
1655
  startAtQr = true,
1658
- onClose
1656
+ onClose,
1657
+ mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app"
1659
1658
  }) => {
1659
+ const [currentView, setCurrentView] = React.useState(startAtQr ? "qr" : "mobileroute");
1660
+ const handleNavigate = (view) => {
1661
+ setCurrentView(view);
1662
+ };
1663
+ const handleClose = () => {
1664
+ if (onClose) {
1665
+ onClose();
1666
+ }
1667
+ };
1660
1668
  return /* @__PURE__ */ jsxRuntime.jsx(
1661
1669
  KycProvider,
1662
1670
  {
@@ -1664,11 +1672,15 @@ var KycFlow = ({
1664
1672
  sessionId,
1665
1673
  serverKey,
1666
1674
  deviceType,
1667
- children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.MemoryRouter, { initialEntries: [startAtQr ? "/qr" : "/mobileroute"], children: /* @__PURE__ */ jsxRuntime.jsxs(reactRouterDom.Routes, { children: [
1668
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/", element: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: startAtQr ? "/qr" : "/mobileroute", replace: true }) }),
1669
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/qr", element: /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose }) }),
1670
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/mobileroute", element: /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose }) })
1671
- ] }) })
1675
+ children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(
1676
+ QRCodePage_default,
1677
+ {
1678
+ onClose: handleClose,
1679
+ onNavigate: handleNavigate,
1680
+ mobileBaseUrl,
1681
+ sessionId
1682
+ }
1683
+ ) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1672
1684
  }
1673
1685
  );
1674
1686
  };