AuthProvider.getAuthCode has no window object

We have an authenticated Web Messenger JS SDK implemented in a SPA with react.

We have an internal authentication provider we use to retrieve the brand code that we need to load in an IFrame at the moment.

This works for us on first page load and authenticating with our app registering our AuthProvider and the command getAuthCode.

AuthProvider.registerCommand('getAuthCode', e => {

      const urlParams = new URLSearchParams(window.location.search);

      const code = urlParams.get('code');

      e.resolve({
        authCode: code,
        redirectUri: env.REACT_APP_GENESYS_REDIRECT_URI,
        codeVerifier: localStorage.getItem('genesys-oauth-code-verifier')
      });
    });

    /* Subscribe to Auth plugin events - optional */

    AuthProvider.ready();
  });

getAuthCode has no issues referencing localStorage keys and window.location.search query params the first time on registering.

In a scenario where we log out of our app & web messenger and log back in without any full page load, to avoid running into an error of re-registering AuthProvider, we retrieve a new brand code and call the Auth.getTokens() command but now runs into an issue where localStorage or URLSearchParams cannot be used resulting in errors like

typeError: URLSearchParams is not a constructor

or

Cannot read properties of null (reading 'getItem')