astra-sdk-web 1.1.3 → 1.1.5

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.
@@ -1428,6 +1428,29 @@ function FaceScanModal({ onComplete }) {
1428
1428
  React.useEffect(() => {
1429
1429
  setState((prev) => ({ ...prev, cameraReady }));
1430
1430
  }, [cameraReady, setState]);
1431
+ React.useEffect(() => {
1432
+ if (cameraReady && apiService) {
1433
+ const config = apiService.getConfig();
1434
+ if (config) {
1435
+ console.log("=== Camera Opened ===");
1436
+ console.log("Session ID:", config.sessionId);
1437
+ console.log("Server Key:", config.serverKey);
1438
+ console.log("API Base URL:", config.apiBaseUrl);
1439
+ console.log("Device Type:", config.deviceType || "auto-detected");
1440
+ apiService.getSessionStatus().then((statusResponse) => {
1441
+ console.log("=== Session Status API Response ===");
1442
+ console.log("Full Response:", statusResponse);
1443
+ console.log("Session Status:", statusResponse.data?.status);
1444
+ console.log("Session ID:", statusResponse.data?.session_id);
1445
+ console.log("Completed Steps:", statusResponse.data?.completed_steps);
1446
+ console.log("Next Step:", statusResponse.data?.next_step);
1447
+ }).catch((error) => {
1448
+ console.error("=== Session Status API Error ===");
1449
+ console.error("Error fetching session status:", error);
1450
+ });
1451
+ }
1452
+ }
1453
+ }, [cameraReady, apiService]);
1431
1454
  const handleRetry = () => {
1432
1455
  stopCamera();
1433
1456
  setState({
@@ -1530,12 +1553,29 @@ function FaceScanModal({ onComplete }) {
1530
1553
  ] }) });
1531
1554
  }
1532
1555
  var FaceScanModal_default = FaceScanModal;
1556
+ function MobileRouteContent({ onClose, onComplete }) {
1557
+ return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose, onComplete });
1558
+ }
1533
1559
  function MobileRoute({ onClose, onNavigate } = {}) {
1560
+ const [config, setConfig] = React.useState(null);
1534
1561
  React.useEffect(() => {
1535
1562
  if (!isMobileDevice() && onNavigate) {
1536
1563
  onNavigate("qr");
1537
1564
  return;
1538
1565
  }
1566
+ const searchParams = new URLSearchParams(window.location.search);
1567
+ const sessionId = searchParams.get("sessionId");
1568
+ const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1569
+ const serverKey = searchParams.get("serverKey") || "";
1570
+ if (sessionId && apiBaseUrl && serverKey) {
1571
+ setConfig({
1572
+ apiBaseUrl,
1573
+ sessionId,
1574
+ serverKey
1575
+ });
1576
+ } else if (sessionId) {
1577
+ console.error("Missing required parameters: apiBaseUrl and serverKey must be in URL");
1578
+ }
1539
1579
  }, [onNavigate]);
1540
1580
  const handleClose = () => {
1541
1581
  if (onClose) {
@@ -1548,20 +1588,46 @@ function MobileRoute({ onClose, onNavigate } = {}) {
1548
1588
  if (!isMobileDevice()) {
1549
1589
  return null;
1550
1590
  }
1551
- return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose: handleClose, onComplete: handleComplete });
1591
+ if (config) {
1592
+ return /* @__PURE__ */ jsxRuntime.jsx(
1593
+ KycProvider,
1594
+ {
1595
+ apiBaseUrl: config.apiBaseUrl,
1596
+ sessionId: config.sessionId,
1597
+ serverKey: config.serverKey,
1598
+ deviceType: "mobile",
1599
+ children: /* @__PURE__ */ jsxRuntime.jsx(MobileRouteContent, { onClose: handleClose, onComplete: handleComplete })
1600
+ }
1601
+ );
1602
+ }
1603
+ if (onNavigate) {
1604
+ return /* @__PURE__ */ jsxRuntime.jsx(MobileRouteContent, { onClose: handleClose, onComplete: handleComplete });
1605
+ }
1606
+ 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: [
1607
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
1608
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId, apiBaseUrl, and serverKey parameters." })
1609
+ ] }) });
1552
1610
  }
1553
1611
  var MobileRoute_default = MobileRoute;
1554
- function QRCodePage({ onClose, onNavigate } = {}) {
1612
+ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app", sessionId, apiBaseUrl, serverKey } = {}) {
1555
1613
  const [qrUrl, setQrUrl] = React.useState("");
1556
1614
  const [copied, setCopied] = React.useState(false);
1557
1615
  React.useEffect(() => {
1558
- const currentUrl = window.location.origin;
1559
1616
  const searchParams = new URLSearchParams(window.location.search);
1617
+ if (sessionId) {
1618
+ searchParams.set("sessionId", sessionId);
1619
+ }
1620
+ if (apiBaseUrl) {
1621
+ searchParams.set("apiBaseUrl", apiBaseUrl);
1622
+ }
1623
+ if (serverKey) {
1624
+ searchParams.set("serverKey", serverKey);
1625
+ }
1560
1626
  const mobileRoute = "/mobileroute";
1561
1627
  const queryString = searchParams.toString();
1562
- const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1628
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1563
1629
  setQrUrl(fullUrl);
1564
- }, []);
1630
+ }, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
1565
1631
  const handleCopyUrl = async () => {
1566
1632
  if (qrUrl) {
1567
1633
  try {
@@ -1581,62 +1647,68 @@ function QRCodePage({ onClose, onNavigate } = {}) {
1581
1647
  const handleRefresh = () => {
1582
1648
  window.location.reload();
1583
1649
  };
1584
- 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: [
1585
- /* @__PURE__ */ jsxRuntime.jsx(
1586
- "button",
1587
- {
1588
- 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",
1589
- onClick: handleClose,
1590
- "aria-label": "Close",
1591
- children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1592
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1593
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1594
- ] })
1595
- }
1596
- ),
1597
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1598
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1599
- /* @__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" }),
1600
- 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(
1601
- qrcode_react.QRCodeSVG,
1602
- {
1603
- value: qrUrl,
1604
- size: 180,
1605
- level: "H",
1606
- includeMargin: true,
1607
- bgColor: "transparent",
1608
- fgColor: "#000000"
1609
- }
1610
- ) }),
1611
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1612
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1613
- /* @__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: [
1614
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1615
- /* @__PURE__ */ jsxRuntime.jsx(
1616
- "button",
1617
- {
1618
- 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",
1619
- onClick: handleCopyUrl,
1620
- "aria-label": "Copy URL",
1621
- title: copied ? "Copied!" : "Copy URL",
1622
- 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: [
1623
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1624
- /* @__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" })
1625
- ] })
1626
- }
1627
- )
1628
- ] })
1629
- ] }),
1650
+ 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: [
1651
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 opacity-10", style: {
1652
+ backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,
1653
+ backgroundSize: "40px 40px"
1654
+ } }),
1655
+ /* @__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: [
1630
1656
  /* @__PURE__ */ jsxRuntime.jsx(
1631
1657
  "button",
1632
1658
  {
1633
- 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",
1634
- onClick: handleRefresh,
1635
- children: "I've completed on mobile - Refresh"
1659
+ 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",
1660
+ onClick: handleClose,
1661
+ "aria-label": "Close",
1662
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1663
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1664
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1665
+ ] })
1636
1666
  }
1637
- )
1667
+ ),
1668
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1669
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1670
+ /* @__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" }),
1671
+ 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(
1672
+ qrcode_react.QRCodeSVG,
1673
+ {
1674
+ value: qrUrl,
1675
+ size: 180,
1676
+ level: "H",
1677
+ includeMargin: true,
1678
+ bgColor: "transparent",
1679
+ fgColor: "#000000"
1680
+ }
1681
+ ) }),
1682
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1683
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1684
+ /* @__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: [
1685
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1686
+ /* @__PURE__ */ jsxRuntime.jsx(
1687
+ "button",
1688
+ {
1689
+ 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",
1690
+ onClick: handleCopyUrl,
1691
+ "aria-label": "Copy URL",
1692
+ title: copied ? "Copied!" : "Copy URL",
1693
+ 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: [
1694
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1695
+ /* @__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" })
1696
+ ] })
1697
+ }
1698
+ )
1699
+ ] })
1700
+ ] }),
1701
+ /* @__PURE__ */ jsxRuntime.jsx(
1702
+ "button",
1703
+ {
1704
+ 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",
1705
+ onClick: handleRefresh,
1706
+ children: "I've completed on mobile - Refresh"
1707
+ }
1708
+ )
1709
+ ] })
1638
1710
  ] })
1639
- ] }) });
1711
+ ] });
1640
1712
  }
1641
1713
  var QRCodePage_default = QRCodePage;
1642
1714
  var KycFlow = ({
@@ -1645,7 +1717,8 @@ var KycFlow = ({
1645
1717
  serverKey,
1646
1718
  deviceType,
1647
1719
  startAtQr = true,
1648
- onClose
1720
+ onClose,
1721
+ mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app"
1649
1722
  }) => {
1650
1723
  const [currentView, setCurrentView] = React.useState(startAtQr ? "qr" : "mobileroute");
1651
1724
  const handleNavigate = (view) => {
@@ -1663,7 +1736,17 @@ var KycFlow = ({
1663
1736
  sessionId,
1664
1737
  serverKey,
1665
1738
  deviceType,
1666
- children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose: handleClose, onNavigate: handleNavigate }) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1739
+ children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(
1740
+ QRCodePage_default,
1741
+ {
1742
+ onClose: handleClose,
1743
+ onNavigate: handleNavigate,
1744
+ mobileBaseUrl,
1745
+ sessionId,
1746
+ apiBaseUrl,
1747
+ serverKey
1748
+ }
1749
+ ) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1667
1750
  }
1668
1751
  );
1669
1752
  };