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.
@@ -1223,6 +1223,29 @@ function FaceScanModal({ onComplete }) {
1223
1223
  React.useEffect(() => {
1224
1224
  setState((prev) => ({ ...prev, cameraReady }));
1225
1225
  }, [cameraReady, setState]);
1226
+ React.useEffect(() => {
1227
+ if (cameraReady && apiService) {
1228
+ const config = apiService.getConfig();
1229
+ if (config) {
1230
+ console.log("=== Camera Opened ===");
1231
+ console.log("Session ID:", config.sessionId);
1232
+ console.log("Server Key:", config.serverKey);
1233
+ console.log("API Base URL:", config.apiBaseUrl);
1234
+ console.log("Device Type:", config.deviceType || "auto-detected");
1235
+ apiService.getSessionStatus().then((statusResponse) => {
1236
+ console.log("=== Session Status API Response ===");
1237
+ console.log("Full Response:", statusResponse);
1238
+ console.log("Session Status:", statusResponse.data?.status);
1239
+ console.log("Session ID:", statusResponse.data?.session_id);
1240
+ console.log("Completed Steps:", statusResponse.data?.completed_steps);
1241
+ console.log("Next Step:", statusResponse.data?.next_step);
1242
+ }).catch((error) => {
1243
+ console.error("=== Session Status API Error ===");
1244
+ console.error("Error fetching session status:", error);
1245
+ });
1246
+ }
1247
+ }
1248
+ }, [cameraReady, apiService]);
1226
1249
  const handleRetry = () => {
1227
1250
  stopCamera();
1228
1251
  setState({
@@ -1325,12 +1348,29 @@ function FaceScanModal({ onComplete }) {
1325
1348
  ] }) });
1326
1349
  }
1327
1350
  var FaceScanModal_default = FaceScanModal;
1351
+ function MobileRouteContent({ onClose, onComplete }) {
1352
+ return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose, onComplete });
1353
+ }
1328
1354
  function MobileRoute({ onClose, onNavigate } = {}) {
1355
+ const [config, setConfig] = React.useState(null);
1329
1356
  React.useEffect(() => {
1330
1357
  if (!isMobileDevice() && onNavigate) {
1331
1358
  onNavigate("qr");
1332
1359
  return;
1333
1360
  }
1361
+ const searchParams = new URLSearchParams(window.location.search);
1362
+ const sessionId = searchParams.get("sessionId");
1363
+ const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1364
+ const serverKey = searchParams.get("serverKey") || "";
1365
+ if (sessionId && apiBaseUrl && serverKey) {
1366
+ setConfig({
1367
+ apiBaseUrl,
1368
+ sessionId,
1369
+ serverKey
1370
+ });
1371
+ } else if (sessionId) {
1372
+ console.error("Missing required parameters: apiBaseUrl and serverKey must be in URL");
1373
+ }
1334
1374
  }, [onNavigate]);
1335
1375
  const handleClose = () => {
1336
1376
  if (onClose) {
@@ -1343,20 +1383,46 @@ function MobileRoute({ onClose, onNavigate } = {}) {
1343
1383
  if (!isMobileDevice()) {
1344
1384
  return null;
1345
1385
  }
1346
- return /* @__PURE__ */ jsxRuntime.jsx(FaceScanModal_default, { onClose: handleClose, onComplete: handleComplete });
1386
+ if (config) {
1387
+ return /* @__PURE__ */ jsxRuntime.jsx(
1388
+ KycProvider,
1389
+ {
1390
+ apiBaseUrl: config.apiBaseUrl,
1391
+ sessionId: config.sessionId,
1392
+ serverKey: config.serverKey,
1393
+ deviceType: "mobile",
1394
+ children: /* @__PURE__ */ jsxRuntime.jsx(MobileRouteContent, { onClose: handleClose, onComplete: handleComplete })
1395
+ }
1396
+ );
1397
+ }
1398
+ if (onNavigate) {
1399
+ return /* @__PURE__ */ jsxRuntime.jsx(MobileRouteContent, { onClose: handleClose, onComplete: handleComplete });
1400
+ }
1401
+ 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: [
1402
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-600 mb-2", children: "Missing Configuration" }),
1403
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600", children: "Please ensure the URL includes sessionId, apiBaseUrl, and serverKey parameters." })
1404
+ ] }) });
1347
1405
  }
1348
1406
  var MobileRoute_default = MobileRoute;
1349
- function QRCodePage({ onClose, onNavigate } = {}) {
1407
+ function QRCodePage({ onClose, onNavigate, mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app", sessionId, apiBaseUrl, serverKey } = {}) {
1350
1408
  const [qrUrl, setQrUrl] = React.useState("");
1351
1409
  const [copied, setCopied] = React.useState(false);
1352
1410
  React.useEffect(() => {
1353
- const currentUrl = window.location.origin;
1354
1411
  const searchParams = new URLSearchParams(window.location.search);
1412
+ if (sessionId) {
1413
+ searchParams.set("sessionId", sessionId);
1414
+ }
1415
+ if (apiBaseUrl) {
1416
+ searchParams.set("apiBaseUrl", apiBaseUrl);
1417
+ }
1418
+ if (serverKey) {
1419
+ searchParams.set("serverKey", serverKey);
1420
+ }
1355
1421
  const mobileRoute = "/mobileroute";
1356
1422
  const queryString = searchParams.toString();
1357
- const fullUrl = `${currentUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1423
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}${queryString ? `?${queryString}` : ""}`;
1358
1424
  setQrUrl(fullUrl);
1359
- }, []);
1425
+ }, [mobileBaseUrl, sessionId, apiBaseUrl, serverKey]);
1360
1426
  const handleCopyUrl = async () => {
1361
1427
  if (qrUrl) {
1362
1428
  try {
@@ -1376,62 +1442,68 @@ function QRCodePage({ onClose, onNavigate } = {}) {
1376
1442
  const handleRefresh = () => {
1377
1443
  window.location.reload();
1378
1444
  };
1379
- 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: [
1380
- /* @__PURE__ */ jsxRuntime.jsx(
1381
- "button",
1382
- {
1383
- 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",
1384
- onClick: handleClose,
1385
- "aria-label": "Close",
1386
- children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1387
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1388
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1389
- ] })
1390
- }
1391
- ),
1392
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1393
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1394
- /* @__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" }),
1395
- 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(
1396
- qrcode_react.QRCodeSVG,
1397
- {
1398
- value: qrUrl,
1399
- size: 180,
1400
- level: "H",
1401
- includeMargin: true,
1402
- bgColor: "transparent",
1403
- fgColor: "#000000"
1404
- }
1405
- ) }),
1406
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1407
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1408
- /* @__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: [
1409
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1410
- /* @__PURE__ */ jsxRuntime.jsx(
1411
- "button",
1412
- {
1413
- 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",
1414
- onClick: handleCopyUrl,
1415
- "aria-label": "Copy URL",
1416
- title: copied ? "Copied!" : "Copy URL",
1417
- 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: [
1418
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1419
- /* @__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" })
1420
- ] })
1421
- }
1422
- )
1423
- ] })
1424
- ] }),
1445
+ 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: [
1446
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 opacity-10", style: {
1447
+ backgroundImage: `radial-gradient(circle at 2px 2px, rgba(255,255,255,0.15) 1px, transparent 0)`,
1448
+ backgroundSize: "40px 40px"
1449
+ } }),
1450
+ /* @__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: [
1425
1451
  /* @__PURE__ */ jsxRuntime.jsx(
1426
1452
  "button",
1427
1453
  {
1428
- 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",
1429
- onClick: handleRefresh,
1430
- children: "I've completed on mobile - Refresh"
1454
+ 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",
1455
+ onClick: handleClose,
1456
+ "aria-label": "Close",
1457
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1458
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1459
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1460
+ ] })
1431
1461
  }
1432
- )
1462
+ ),
1463
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 sm:gap-4 flex-1 overflow-y-auto custom__scrollbar", children: [
1464
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "m-0 text-white text-xl sm:text-2xl font-semibold leading-tight", children: "Continue on Mobile" }),
1465
+ /* @__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" }),
1466
+ 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(
1467
+ qrcode_react.QRCodeSVG,
1468
+ {
1469
+ value: qrUrl,
1470
+ size: 180,
1471
+ level: "H",
1472
+ includeMargin: true,
1473
+ bgColor: "transparent",
1474
+ fgColor: "#000000"
1475
+ }
1476
+ ) }),
1477
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full text-left mt-auto", children: [
1478
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 mb-2 text-white text-xs sm:text-sm opacity-80", children: "Or open:" }),
1479
+ /* @__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: [
1480
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "flex-1 text-white text-xs sm:text-sm break-all text-left m-0 font-mono", children: qrUrl }),
1481
+ /* @__PURE__ */ jsxRuntime.jsx(
1482
+ "button",
1483
+ {
1484
+ 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",
1485
+ onClick: handleCopyUrl,
1486
+ "aria-label": "Copy URL",
1487
+ title: copied ? "Copied!" : "Copy URL",
1488
+ 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: [
1489
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
1490
+ /* @__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" })
1491
+ ] })
1492
+ }
1493
+ )
1494
+ ] })
1495
+ ] }),
1496
+ /* @__PURE__ */ jsxRuntime.jsx(
1497
+ "button",
1498
+ {
1499
+ 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",
1500
+ onClick: handleRefresh,
1501
+ children: "I've completed on mobile - Refresh"
1502
+ }
1503
+ )
1504
+ ] })
1433
1505
  ] })
1434
- ] }) });
1506
+ ] });
1435
1507
  }
1436
1508
  var QRCodePage_default = QRCodePage;
1437
1509
  var KycFlow = ({
@@ -1440,7 +1512,8 @@ var KycFlow = ({
1440
1512
  serverKey,
1441
1513
  deviceType,
1442
1514
  startAtQr = true,
1443
- onClose
1515
+ onClose,
1516
+ mobileBaseUrl = "https://astra-sdk-rebuild.vercel.app"
1444
1517
  }) => {
1445
1518
  const [currentView, setCurrentView] = React.useState(startAtQr ? "qr" : "mobileroute");
1446
1519
  const handleNavigate = (view) => {
@@ -1458,7 +1531,17 @@ var KycFlow = ({
1458
1531
  sessionId,
1459
1532
  serverKey,
1460
1533
  deviceType,
1461
- children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(QRCodePage_default, { onClose: handleClose, onNavigate: handleNavigate }) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1534
+ children: currentView === "qr" ? /* @__PURE__ */ jsxRuntime.jsx(
1535
+ QRCodePage_default,
1536
+ {
1537
+ onClose: handleClose,
1538
+ onNavigate: handleNavigate,
1539
+ mobileBaseUrl,
1540
+ sessionId,
1541
+ apiBaseUrl,
1542
+ serverKey
1543
+ }
1544
+ ) : /* @__PURE__ */ jsxRuntime.jsx(MobileRoute_default, { onClose: handleClose, onNavigate: handleNavigate })
1462
1545
  }
1463
1546
  );
1464
1547
  };