astra-sdk-web 1.1.28 → 1.1.29

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.
@@ -1770,25 +1770,39 @@ function MobileRoute({ onClose, onNavigate } = {}) {
1770
1770
  const searchParams = new URLSearchParams(window.location.search);
1771
1771
  const sessionId = searchParams.get("sessionId");
1772
1772
  if (sessionId) {
1773
- const storedConfig = getKycConfig(sessionId);
1774
- if (storedConfig) {
1773
+ let apiBaseUrl = "";
1774
+ let serverKey = "";
1775
+ const encodedConfig = searchParams.get("config");
1776
+ if (encodedConfig) {
1777
+ try {
1778
+ const decodedConfig = JSON.parse(atob(encodedConfig));
1779
+ if (decodedConfig.apiBaseUrl && decodedConfig.serverKey) {
1780
+ apiBaseUrl = decodedConfig.apiBaseUrl;
1781
+ serverKey = decodedConfig.serverKey;
1782
+ }
1783
+ } catch (error) {
1784
+ console.error("Failed to decode config from URL:", error);
1785
+ }
1786
+ }
1787
+ if (!apiBaseUrl || !serverKey) {
1788
+ const storedConfig = getKycConfig(sessionId);
1789
+ if (storedConfig) {
1790
+ apiBaseUrl = storedConfig.apiBaseUrl;
1791
+ serverKey = storedConfig.serverKey;
1792
+ }
1793
+ }
1794
+ if (!apiBaseUrl || !serverKey) {
1795
+ apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1796
+ serverKey = searchParams.get("serverKey") || "";
1797
+ }
1798
+ if (apiBaseUrl && serverKey) {
1775
1799
  setConfig({
1776
- apiBaseUrl: storedConfig.apiBaseUrl,
1800
+ apiBaseUrl,
1777
1801
  sessionId,
1778
- serverKey: storedConfig.serverKey
1802
+ serverKey
1779
1803
  });
1780
1804
  } else {
1781
- const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1782
- const serverKey = searchParams.get("serverKey") || "";
1783
- if (apiBaseUrl && serverKey) {
1784
- setConfig({
1785
- apiBaseUrl,
1786
- sessionId,
1787
- serverKey
1788
- });
1789
- } else {
1790
- console.error("Missing required parameters: apiBaseUrl and serverKey not found in localStorage or URL");
1791
- }
1805
+ console.error("Missing required parameters: apiBaseUrl and serverKey not found in URL config, localStorage, or URL params");
1792
1806
  }
1793
1807
  } else {
1794
1808
  console.error("Missing required parameter: sessionId must be in URL");
@@ -1833,7 +1847,13 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
1833
1847
  if (sessionId && apiBaseUrl && serverKey) {
1834
1848
  storeKycConfig(sessionId, apiBaseUrl, serverKey);
1835
1849
  }
1836
- if (sessionId) {
1850
+ if (sessionId && apiBaseUrl && serverKey) {
1851
+ const mobileRoute = "/mobileroute";
1852
+ const config = JSON.stringify({ apiBaseUrl, serverKey });
1853
+ const encodedConfig = btoa(config);
1854
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}&config=${encodedConfig}`;
1855
+ setQrUrl(fullUrl);
1856
+ } else if (sessionId) {
1837
1857
  const mobileRoute = "/mobileroute";
1838
1858
  const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}`;
1839
1859
  setQrUrl(fullUrl);