astra-sdk-web 1.1.4 → 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,10 +1588,28 @@ 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, mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app", sessionId } = {}) {
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(() => {
@@ -1559,11 +1617,17 @@ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://astra-sdk-re
1559
1617
  if (sessionId) {
1560
1618
  searchParams.set("sessionId", sessionId);
1561
1619
  }
1620
+ if (apiBaseUrl) {
1621
+ searchParams.set("apiBaseUrl", apiBaseUrl);
1622
+ }
1623
+ if (serverKey) {
1624
+ searchParams.set("serverKey", serverKey);
1625
+ }
1562
1626
  const mobileRoute = "/mobileroute";
1563
1627
  const queryString = searchParams.toString();
1564
1628
  const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1565
1629
  setQrUrl(fullUrl);
1566
- }, [mobileBaseUrl, sessionId]);
1630
+ }, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
1567
1631
  const handleCopyUrl = async () => {
1568
1632
  if (qrUrl) {
1569
1633
  try {
@@ -1678,7 +1742,9 @@ var KycFlow = ({
1678
1742
  onClose: handleClose,
1679
1743
  onNavigate: handleNavigate,
1680
1744
  mobileBaseUrl,
1681
- sessionId
1745
+ sessionId,
1746
+ apiBaseUrl,
1747
+ serverKey
1682
1748
  }
1683
1749
  ) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1684
1750
  }