Skip to content

Conversation

@amircheikh
Copy link
Contributor

@amircheikh amircheikh commented Nov 21, 2025

Summary & Motivation

  • Added autoFetchWalletKitConfig option to the TurnkeyProvider config. Setting this to false will disable the initial walletKitConfig fetch, saving on initialization time. If this is disabled and you want to use the handleLogin modal with Turnkey's Auth Proxy, you must pass in the enabled auth methods manually into the TurnkeyProvider config.

  • Fixed refreshWallets and refreshUser not working when autoRefreshManagedState is disabled.

How I Tested These Changes

with-sdk-js and react-wallet-kit examples

Did you add a changeset?

yes

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 21, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f22b75f:

Sandbox Source
@turnkey/example-react-components Configuration

Copy link
Contributor

@moeodeh3 moeodeh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all comments apply for both RN and React. This is okay for now until we restructure our config :)

Record<string, Session> | undefined
>(undefined);

const shouldFetchWalletKitConfig =
Copy link
Contributor

@moeodeh3 moeodeh3 Nov 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can simplify, also worth commenting when its enabled or disabled:

 // if there is no authProxyConfigId or if autoFetchWalletKitConfig is specifically
 // set to false, we don't need to fetch the config
const shouldFetchWalletKitConfig =
    !!config.authProxyConfigId &&
    (config.autoFetchWalletKitConfig ?? true);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do this since I want empty string to be treated as null too:

const shouldFetchWalletKitConfig =
  config.authProxyConfigId != null &&
  config.authProxyConfigId !== "" &&
  (config.autoFetchWalletKitConfig !== false);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both treat "" as nullish (false)


// Warn if they are trying to set auth proxy only settings directly
if (config.auth?.sessionExpirationSeconds) {
if (config.auth?.sessionExpirationSeconds && shouldFetchWalletKitConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding this in a condition in each if statement its probably cleaner to extract it out into its own if statement:

if (shouldFetchWalletKitConfig) {
      if (config.auth?.sessionExpirationSeconds) {
        console.warn(
          "Turnkey SDK warning. You have set sessionExpirationSeconds directly in the TurnkeyProvider. This setting will be ignored because you are using an auth proxy. Please configure session expiration in the Turnkey dashboard.",
        );
      }
      if (config.auth?.otpAlphanumeric !== undefined) {
        console.warn(
          "Turnkey SDK warning. You have set otpAlphanumeric directly in the TurnkeyProvider. This setting will be ignored because you are using an auth proxy. Please configure OTP settings in the Turnkey dashboard.",
        );
      }
      if (config.auth?.otpLength) {
        console.warn(
          "Turnkey SDK warning. You have set otpLength directly in the TurnkeyProvider. This setting will be ignored because you are using an auth proxy. Please configure OTP settings in the Turnkey dashboard.",
        );
      }
    }

// These are settings that can only be set via the auth proxy config
const authProxyOnlySettings = {
sessionExpirationSeconds: proxyAuthConfig?.sessionExpirationSeconds,
const authProxyPrioSettings = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m a bit confused about why we need to check shouldFetchWalletKitConfig at all

this actually makes me question the purpose of shouldFetchWalletKitConfig in buildConfig(). We shouldn’t need to check that flag here - why not treat the presence or absence of authProxyConfig as the source of truth?

if fetching is disabled, we simply keep authProxyConfig as undefined. When we call buildConfig(), it receives undefined, and that alone should tell us the fetch was skipped. No extra conditional needed

given that, instead of doing something like:

sessionExpirationSeconds: shouldFetchWalletKitConfig
  ? proxyAuthConfig?.sessionExpirationSeconds
  : config.auth?.sessionExpirationSeconds

we could instead do this:

sessionExpirationSeconds:
  proxyAuthConfig?.sessionExpirationSeconds ??
  config.auth?.sessionExpirationSeconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I see you define shouldFetchWalletKitConfig as a global var - I think we should only use this locally in fetchProxyAuthConfig() and make buildConfig()just use whether the config is defined or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant define locally. used in "re-build" useEffect too

"Failed to verify app proofs",
);
const maybeRefreshUser = useCallback(
// Auto-refresh user only if enabled in config. This is only used internally
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: weird placement of a comment here - can we just have an internal comment header to follow our convention?

);

const maybeRefreshWallets = useCallback(
// Auto-refresh wallets only if enabled in config. This is only used internally
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here

}

if (evt?.type === "initialized") {
console.log("WalletConnect initialized event received");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this ones is a mb - but can we remove this 🙏

@moeodeh3 moeodeh3 merged commit 2d698d6 into main Nov 26, 2025
8 checks passed
@moeodeh3 moeodeh3 deleted the amir/disable-fetch branch November 26, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants