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.
@@ -1967,25 +1967,39 @@ function MobileRoute({ onClose, onNavigate } = {}) {
1967
1967
  const searchParams = new URLSearchParams(window.location.search);
1968
1968
  const sessionId = searchParams.get("sessionId");
1969
1969
  if (sessionId) {
1970
- const storedConfig = getKycConfig(sessionId);
1971
- if (storedConfig) {
1970
+ let apiBaseUrl = "";
1971
+ let serverKey = "";
1972
+ const encodedConfig = searchParams.get("config");
1973
+ if (encodedConfig) {
1974
+ try {
1975
+ const decodedConfig = JSON.parse(atob(encodedConfig));
1976
+ if (decodedConfig.apiBaseUrl && decodedConfig.serverKey) {
1977
+ apiBaseUrl = decodedConfig.apiBaseUrl;
1978
+ serverKey = decodedConfig.serverKey;
1979
+ }
1980
+ } catch (error) {
1981
+ console.error("Failed to decode config from URL:", error);
1982
+ }
1983
+ }
1984
+ if (!apiBaseUrl || !serverKey) {
1985
+ const storedConfig = getKycConfig(sessionId);
1986
+ if (storedConfig) {
1987
+ apiBaseUrl = storedConfig.apiBaseUrl;
1988
+ serverKey = storedConfig.serverKey;
1989
+ }
1990
+ }
1991
+ if (!apiBaseUrl || !serverKey) {
1992
+ apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1993
+ serverKey = searchParams.get("serverKey") || "";
1994
+ }
1995
+ if (apiBaseUrl && serverKey) {
1972
1996
  setConfig({
1973
- apiBaseUrl: storedConfig.apiBaseUrl,
1997
+ apiBaseUrl,
1974
1998
  sessionId,
1975
- serverKey: storedConfig.serverKey
1999
+ serverKey
1976
2000
  });
1977
2001
  } else {
1978
- const apiBaseUrl = searchParams.get("apiBaseUrl") || searchParams.get("apiUrl") || "";
1979
- const serverKey = searchParams.get("serverKey") || "";
1980
- if (apiBaseUrl && serverKey) {
1981
- setConfig({
1982
- apiBaseUrl,
1983
- sessionId,
1984
- serverKey
1985
- });
1986
- } else {
1987
- console.error("Missing required parameters: apiBaseUrl and serverKey not found in localStorage or URL");
1988
- }
2002
+ console.error("Missing required parameters: apiBaseUrl and serverKey not found in URL config, localStorage, or URL params");
1989
2003
  }
1990
2004
  } else {
1991
2005
  console.error("Missing required parameter: sessionId must be in URL");
@@ -2030,7 +2044,13 @@ function QRCodePage({ onClose, mobileBaseUrl = "https://kyc-sdk.astraprotocol.co
2030
2044
  if (sessionId && apiBaseUrl && serverKey) {
2031
2045
  storeKycConfig(sessionId, apiBaseUrl, serverKey);
2032
2046
  }
2033
- if (sessionId) {
2047
+ if (sessionId && apiBaseUrl && serverKey) {
2048
+ const mobileRoute = "/mobileroute";
2049
+ const config = JSON.stringify({ apiBaseUrl, serverKey });
2050
+ const encodedConfig = btoa(config);
2051
+ const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}&config=${encodedConfig}`;
2052
+ setQrUrl(fullUrl);
2053
+ } else if (sessionId) {
2034
2054
  const mobileRoute = "/mobileroute";
2035
2055
  const fullUrl = `${mobileBaseUrl}${mobileRoute}?sessionId=${sessionId}`;
2036
2056
  setQrUrl(fullUrl);