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.
@@ -1764,25 +1764,39 @@ function MobileRoute({ onClose, onNavigate } = {}) {
1764
1764
  const searchParams = new URLSearchParams(window.location.search);
1765
1765
  const sessionId = searchParams.get("sessionId");
1766
1766
  if (sessionId) {
1767
- const storedConfig = getKycConfig(sessionId);
1768
- if (storedConfig) {
1767
+ let apiBaseUrl = "";
1768
+ let serverKey = "";
1769
+ const encodedConfig = searchParams.get("config");
1770
+ if (encodedConfig) {
1771
+ try {
1772
+ const decodedConfig = JSON.parse(atob(encodedConfig));
1773
+ if (decodedConfig.apiBaseUrl && decodedConfig.serverKey) {
1774
+ apiBaseUrl = decodedConfig.apiBaseUrl;
1775
+ serverKey = decodedConfig.serverKey;
1776
+ }
1777
+ } catch (error) {
1778
+ console.error("Failed to decode config from URL:", error);
1779
+ }
1780
+ }
1781
+ if (!apiBaseUrl || !serverKey) {
1782
+ const storedConfig = getKycConfig(sessionId);
1783
+ if (storedConfig) {
1784
+ apiBaseUrl = storedConfig.apiBaseUrl;
1785
+ serverKey = storedConfig.serverKey;
1786
+ }
1787
+ }
1788
+ if (!apiBaseUrl || !serverKey) {
1789
+ apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1790
+ serverKey = searchParams.get("serverKey") || "";
1791
+ }
1792
+ if (apiBaseUrl && serverKey) {
1769
1793
  setConfig({
1770
- apiBaseUrl: storedConfig.apiBaseUrl,
1794
+ apiBaseUrl,
1771
1795
  sessionId,
1772
- serverKey: storedConfig.serverKey
1796
+ serverKey
1773
1797
  });
1774
1798
  } else {
1775
- const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1776
- const serverKey = searchParams.get("serverKey") || "";
1777
- if (apiBaseUrl && serverKey) {
1778
- setConfig({
1779
- apiBaseUrl,
1780
- sessionId,
1781
- serverKey
1782
- });
1783
- } else {
1784
- console.error("Missing required parameters: apiBaseUrl and serverKey not found in localStorage or URL");
1785
- }
1799
+ console.error("Missing required parameters: apiBaseUrl and serverKey not found in URL config, localStorage, or URL params");
1786
1800
  }
1787
1801
  } else {
1788
1802
  console.error("Missing required parameter: sessionId must be in URL");
@@ -1827,7 +1841,13 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
1827
1841
  if (sessionId && apiBaseUrl && serverKey) {
1828
1842
  storeKycConfig(sessionId, apiBaseUrl, serverKey);
1829
1843
  }
1830
- if (sessionId) {
1844
+ if (sessionId && apiBaseUrl && serverKey) {
1845
+ const mobileRoute = "/mobileroute";
1846
+ const config = JSON.stringify({ apiBaseUrl, serverKey });
1847
+ const encodedConfig = btoa(config);
1848
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}&config=${encodedConfig}`;
1849
+ setQrUrl(fullUrl);
1850
+ } else if (sessionId) {
1831
1851
  const mobileRoute = "/mobileroute";
1832
1852
  const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}`;
1833
1853
  setQrUrl(fullUrl);