@turnkey/react-wallet-kit 2.3.1 → 2.3.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/providers/client/Provider.tsx"],"names":[],"mappings":"AAmIA,OAAO,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAC;AAyB5E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAM3B,MAAM,kBAAkB,CAAC;AA0D1B;;GAEG;AACH,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwoMxD,CAAC"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/providers/client/Provider.tsx"],"names":[],"mappings":"AAqIA,OAAO,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAC;AAyB5E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAM3B,MAAM,kBAAkB,CAAC;AA0D1B;;GAEG;AACH,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAsqMxD,CAAC"}
@@ -5,7 +5,7 @@ var jsxRuntime = require('react/jsx-runtime');
5
5
  var sha2 = require('@noble/hashes/sha2');
6
6
  var utils$1 = require('@noble/hashes/utils');
7
7
  var storage = require('../../utils/oauth/storage.js');
8
- require('../../utils/oauth/config.js');
8
+ var config = require('../../utils/oauth/config.js');
9
9
  var url = require('../../utils/oauth/url.js');
10
10
  var completion = require('../../utils/oauth/completion.js');
11
11
  var pkce = require('../../utils/oauth/pkce.js');
@@ -69,7 +69,7 @@ var Turnstile = require('../../components/auth/Turnstile.js');
69
69
  * @returns A React context provider exposing authentication, wallet, and user management methods and state.
70
70
  */
71
71
  const ClientProvider = ({
72
- config,
72
+ config: config$1,
73
73
  children,
74
74
  callbacks
75
75
  }) => {
@@ -88,7 +88,7 @@ const ClientProvider = ({
88
88
  }, []);
89
89
  // if there is no authProxyConfigId or if autoFetchWalletKitConfig is specifically
90
90
  // set to false, we don't need to fetch the config
91
- const shouldFetchWalletKitConfig = !!config.authProxyConfigId && (config.autoFetchWalletKitConfig ?? true);
91
+ const shouldFetchWalletKitConfig = !!config$1.authProxyConfigId && (config$1.autoFetchWalletKitConfig ?? true);
92
92
  // we use this custom hook to only update the state if the value is different
93
93
  // this is so our useEffect that calls `initializeWalletProviderListeners()` only runs when it needs to
94
94
  const [walletProviders, setWalletProviders] = utils.useWalletProviderState();
@@ -410,115 +410,115 @@ const ClientProvider = ({
410
410
  const buildConfig = (proxyAuthConfig, clientParams) => {
411
411
  // Juggle the local overrides with the values set in the dashboard (proxyAuthConfig).
412
412
  const resolvedMethods = {
413
- emailOtpAuthEnabled: config.ui?.authModal?.methods?.emailOtpAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("email"),
414
- smsOtpAuthEnabled: config.ui?.authModal?.methods?.smsOtpAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("sms"),
415
- passkeyAuthEnabled: config.ui?.authModal?.methods?.passkeyAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("passkey"),
416
- walletAuthEnabled: config.ui?.authModal?.methods?.walletAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("wallet"),
417
- googleOauthEnabled: config.ui?.authModal?.methods?.googleOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("google"),
418
- xOauthEnabled: config.ui?.authModal?.methods?.xOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("x"),
419
- discordOauthEnabled: config.ui?.authModal?.methods?.discordOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("discord"),
420
- appleOauthEnabled: config.ui?.authModal?.methods?.appleOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("apple"),
421
- facebookOauthEnabled: config.ui?.authModal?.methods?.facebookOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("facebook")
413
+ emailOtpAuthEnabled: config$1.ui?.authModal?.methods?.emailOtpAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("email"),
414
+ smsOtpAuthEnabled: config$1.ui?.authModal?.methods?.smsOtpAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("sms"),
415
+ passkeyAuthEnabled: config$1.ui?.authModal?.methods?.passkeyAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("passkey"),
416
+ walletAuthEnabled: config$1.ui?.authModal?.methods?.walletAuthEnabled ?? proxyAuthConfig?.enabledProviders.includes("wallet"),
417
+ googleOauthEnabled: config$1.ui?.authModal?.methods?.googleOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("google"),
418
+ xOauthEnabled: config$1.ui?.authModal?.methods?.xOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("x"),
419
+ discordOauthEnabled: config$1.ui?.authModal?.methods?.discordOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("discord"),
420
+ appleOauthEnabled: config$1.ui?.authModal?.methods?.appleOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("apple"),
421
+ facebookOauthEnabled: config$1.ui?.authModal?.methods?.facebookOauthEnabled ?? proxyAuthConfig?.enabledProviders.includes("facebook")
422
422
  };
423
423
  const resolvedOauthProviders = {
424
424
  google: {
425
- primaryClientId: config.auth?.oauthConfig?.google?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.google,
426
- secondaryClientIds: config.auth?.oauthConfig?.google?.secondaryClientIds ?? []
425
+ primaryClientId: config$1.auth?.oauthConfig?.google?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.google,
426
+ secondaryClientIds: config$1.auth?.oauthConfig?.google?.secondaryClientIds ?? []
427
427
  },
428
428
  apple: {
429
- primaryClientId: config.auth?.oauthConfig?.apple?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.apple,
430
- secondaryClientIds: config.auth?.oauthConfig?.apple?.secondaryClientIds ?? []
429
+ primaryClientId: config$1.auth?.oauthConfig?.apple?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.apple,
430
+ secondaryClientIds: config$1.auth?.oauthConfig?.apple?.secondaryClientIds ?? []
431
431
  },
432
432
  facebook: {
433
- primaryClientId: config.auth?.oauthConfig?.facebook?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.facebook,
434
- secondaryClientIds: config.auth?.oauthConfig?.facebook?.secondaryClientIds ?? []
433
+ primaryClientId: config$1.auth?.oauthConfig?.facebook?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.facebook,
434
+ secondaryClientIds: config$1.auth?.oauthConfig?.facebook?.secondaryClientIds ?? []
435
435
  },
436
436
  x: {
437
- primaryClientId: config.auth?.oauthConfig?.x?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.x,
438
- secondaryClientIds: config.auth?.oauthConfig?.x?.secondaryClientIds ?? []
437
+ primaryClientId: config$1.auth?.oauthConfig?.x?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.x,
438
+ secondaryClientIds: config$1.auth?.oauthConfig?.x?.secondaryClientIds ?? []
439
439
  },
440
440
  discord: {
441
- primaryClientId: config.auth?.oauthConfig?.discord?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.discord,
442
- secondaryClientIds: config.auth?.oauthConfig?.discord?.secondaryClientIds ?? []
441
+ primaryClientId: config$1.auth?.oauthConfig?.discord?.primaryClientId ?? proxyAuthConfig?.oauthClientIds?.discord,
442
+ secondaryClientIds: config$1.auth?.oauthConfig?.discord?.secondaryClientIds ?? []
443
443
  }
444
444
  };
445
- const redirectUrl = config.auth?.oauthConfig?.oauthRedirectUri ?? proxyAuthConfig?.oauthRedirectUrl;
445
+ const redirectUrl = config$1.auth?.oauthConfig?.oauthRedirectUri ?? proxyAuthConfig?.oauthRedirectUrl;
446
446
  // Set a default ordering for the oAuth methods
447
- const oauthOrder = config.ui?.authModal?.oauthOrder ?? ["google", "apple", "x", "discord", "facebook"].filter(provider => resolvedMethods[`${provider}OauthEnabled`]);
447
+ const oauthOrder = config$1.ui?.authModal?.oauthOrder ?? ["google", "apple", "x", "discord", "facebook"].filter(provider => resolvedMethods[`${provider}OauthEnabled`]);
448
448
  // Set a default ordering for the overall auth methods
449
- const methodOrder = config.ui?.authModal?.methodOrder ?? [oauthOrder.length > 0 ? "socials" : null, resolvedMethods.emailOtpAuthEnabled ? "email" : null, resolvedMethods.smsOtpAuthEnabled ? "sms" : null, resolvedMethods.passkeyAuthEnabled ? "passkey" : null, resolvedMethods.walletAuthEnabled ? "wallet" : null].filter(Boolean);
449
+ const methodOrder = config$1.ui?.authModal?.methodOrder ?? [oauthOrder.length > 0 ? "socials" : null, resolvedMethods.emailOtpAuthEnabled ? "email" : null, resolvedMethods.smsOtpAuthEnabled ? "sms" : null, resolvedMethods.passkeyAuthEnabled ? "passkey" : null, resolvedMethods.walletAuthEnabled ? "wallet" : null].filter(Boolean);
450
450
  // Warn if they are trying to set auth proxy only settings directly
451
451
  if (proxyAuthConfig) {
452
- if (config.auth?.sessionExpirationSeconds) {
452
+ if (config$1.auth?.sessionExpirationSeconds) {
453
453
  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.");
454
454
  }
455
- if (config.auth?.otpAlphanumeric !== undefined) {
455
+ if (config$1.auth?.otpAlphanumeric !== undefined) {
456
456
  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.");
457
457
  }
458
- if (config.auth?.otpLength) {
458
+ if (config$1.auth?.otpLength) {
459
459
  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.");
460
460
  }
461
461
  }
462
462
  // These are settings that, if using the auth proxy, must be set in the dashboard. They override any local settings unless they are not using auth proxy or are not fetching the auth proxy config.
463
463
  const authProxyPrioSettings = {
464
- sessionExpirationSeconds: proxyAuthConfig?.sessionExpirationSeconds ?? config.auth?.sessionExpirationSeconds,
465
- otpAlphanumeric: proxyAuthConfig?.otpAlphanumeric ?? config.auth?.otpAlphanumeric ?? true,
466
- otpLength: proxyAuthConfig?.otpLength ?? config.auth?.otpLength ?? "6"
464
+ sessionExpirationSeconds: proxyAuthConfig?.sessionExpirationSeconds ?? config$1.auth?.sessionExpirationSeconds,
465
+ otpAlphanumeric: proxyAuthConfig?.otpAlphanumeric ?? config$1.auth?.otpAlphanumeric ?? true,
466
+ otpLength: proxyAuthConfig?.otpLength ?? config$1.auth?.otpLength ?? "6"
467
467
  };
468
- const scopePasskeyToUser = config.auth?.scopePasskeyToUser ?? true;
468
+ const scopePasskeyToUser = config$1.auth?.scopePasskeyToUser ?? true;
469
469
  return {
470
- ...config,
470
+ ...config$1,
471
471
  scopePasskeyToUser,
472
472
  // Overrides:
473
473
  auth: {
474
- ...config.auth,
474
+ ...config$1.auth,
475
475
  ...authProxyPrioSettings,
476
476
  oauthConfig: {
477
- ...config.auth?.oauthConfig,
477
+ ...config$1.auth?.oauthConfig,
478
478
  ...resolvedOauthProviders,
479
479
  oauthRedirectUri: redirectUrl,
480
480
  // on mobile we default to true since many mobile browsers
481
481
  // (e.g. Safari) block popups
482
- openOauthInPage: isMobile ? true : config.auth?.oauthConfig?.openOauthInPage
482
+ openOauthInPage: isMobile ? true : config$1.auth?.oauthConfig?.openOauthInPage
483
483
  },
484
- autoRefreshSession: config.auth?.autoRefreshSession ?? true,
484
+ autoRefreshSession: config$1.auth?.autoRefreshSession ?? true,
485
485
  scopePasskeyToUser
486
486
  },
487
487
  ui: {
488
- ...config.ui,
488
+ ...config$1.ui,
489
489
  authModal: {
490
- ...config.ui?.authModal,
490
+ ...config$1.ui?.authModal,
491
491
  methods: resolvedMethods,
492
492
  methodOrder,
493
493
  oauthOrder
494
494
  }
495
495
  },
496
- autoRefreshManagedState: config.autoRefreshManagedState ?? true,
496
+ autoRefreshManagedState: config$1.autoRefreshManagedState ?? true,
497
497
  walletConfig: {
498
- ...config.walletConfig,
498
+ ...config$1.walletConfig,
499
499
  features: {
500
- ...config.walletConfig?.features,
500
+ ...config$1.walletConfig?.features,
501
501
  auth:
502
502
  // If walletAuthEnabled is not set, default to true. Wallet auth can be enabled/disabled in the dashboard or by explicitly changing the walletAuthEnabled / walletConfig auth feature.
503
- resolvedMethods.walletAuthEnabled ?? config.walletConfig?.features?.auth ?? true,
504
- connecting: config.walletConfig?.features?.connecting ?? true // Default connecting to true if not set. We don't care about auth settings here.
503
+ resolvedMethods.walletAuthEnabled ?? config$1.walletConfig?.features?.auth ?? true,
504
+ connecting: config$1.walletConfig?.features?.connecting ?? true // Default connecting to true if not set. We don't care about auth settings here.
505
505
  },
506
506
  chains: {
507
- ...config.walletConfig?.chains,
507
+ ...config$1.walletConfig?.chains,
508
508
  ethereum: {
509
- ...config.walletConfig?.chains?.ethereum,
509
+ ...config$1.walletConfig?.chains?.ethereum,
510
510
  // keep user's value if provided; default only when undefined
511
- native: config.walletConfig?.chains?.ethereum?.native ?? true
511
+ native: config$1.walletConfig?.chains?.ethereum?.native ?? true
512
512
  },
513
513
  solana: {
514
- ...config.walletConfig?.chains?.solana,
514
+ ...config$1.walletConfig?.chains?.solana,
515
515
  // keep user's value if provided; default only when undefined
516
- native: config.walletConfig?.chains?.solana?.native ?? true
516
+ native: config$1.walletConfig?.chains?.solana?.native ?? true
517
517
  }
518
518
  }
519
519
  },
520
- importIframeUrl: config.importIframeUrl ?? "https://import.turnkey.com",
521
- exportIframeUrl: config.exportIframeUrl ?? "https://export.turnkey.com",
520
+ importIframeUrl: config$1.importIframeUrl ?? "https://import.turnkey.com",
521
+ exportIframeUrl: config$1.exportIframeUrl ?? "https://export.turnkey.com",
522
522
  turnstileSiteKey: clientParams?.turnstileSiteKey
523
523
  };
524
524
  };
@@ -1953,7 +1953,7 @@ const ClientProvider = ({
1953
1953
  return;
1954
1954
  }
1955
1955
  const url$1 = authWindow.location.href || "";
1956
- if (url$1.startsWith(window.location.origin)) {
1956
+ if (url.isExpectedOAuthRedirectUrl(url$1, redirectUri, config.OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
1957
1957
  const result = url.parseOAuthResponse(url$1, provider);
1958
1958
  if (result) {
1959
1959
  authWindow.close();
@@ -2070,7 +2070,7 @@ const ClientProvider = ({
2070
2070
  return;
2071
2071
  }
2072
2072
  const url$1 = authWindow.location.href || "";
2073
- if (url$1.startsWith(window.location.origin)) {
2073
+ if (url.isExpectedOAuthRedirectUrl(url$1, redirectUri, config.OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
2074
2074
  const result = url.parseOAuthResponse(url$1, provider);
2075
2075
  if (result) {
2076
2076
  authWindow.close();
@@ -2181,7 +2181,7 @@ const ClientProvider = ({
2181
2181
  return;
2182
2182
  }
2183
2183
  const url$1 = authWindow.location.href || "";
2184
- if (url$1.startsWith(window.location.origin)) {
2184
+ if (url.isExpectedOAuthRedirectUrl(url$1, redirectUri, config.OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
2185
2185
  const result = url.parseOAuthResponse(url$1, provider);
2186
2186
  if (result) {
2187
2187
  authWindow.close();
@@ -2281,7 +2281,7 @@ const ClientProvider = ({
2281
2281
  return;
2282
2282
  }
2283
2283
  const url$1 = authWindow.location.href || "";
2284
- if (url$1.startsWith(window.location.origin)) {
2284
+ if (url.isExpectedOAuthRedirectUrl(url$1, redirectUri, config.OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
2285
2285
  const result = url.parseOAuthResponse(url$1, provider);
2286
2286
  if (result) {
2287
2287
  authWindow.close();
@@ -2387,7 +2387,7 @@ const ClientProvider = ({
2387
2387
  return;
2388
2388
  }
2389
2389
  const url$1 = authWindow.location.href || "";
2390
- if (url$1.startsWith(window.location.origin)) {
2390
+ if (url.isExpectedOAuthRedirectUrl(url$1, redirectUri, config.OAUTH_PROVIDER_CONFIGS[provider].expectedResponseMode)) {
2391
2391
  const result = url.parseOAuthResponse(url$1, provider);
2392
2392
  if (result) {
2393
2393
  authWindow.close();
@@ -3975,12 +3975,12 @@ const ClientProvider = ({
3975
3975
  let clientParams;
3976
3976
  const promises = [];
3977
3977
  if (shouldFetchWalletKitConfig) {
3978
- promises.push(core.getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl).then(result => {
3978
+ promises.push(core.getAuthProxyConfig(config$1.authProxyConfigId, config$1.authProxyUrl).then(result => {
3979
3979
  proxyAuthConfig = result;
3980
3980
  }));
3981
3981
  }
3982
- if (config.authProxyConfigId) {
3983
- promises.push(core.getClientParams(config.authProxyConfigId, config.authProxyUrl).then(result => {
3982
+ if (config$1.authProxyConfigId) {
3983
+ promises.push(core.getClientParams(config$1.authProxyConfigId, config$1.authProxyUrl).then(result => {
3984
3984
  clientParams = result;
3985
3985
  }));
3986
3986
  }
@@ -4010,7 +4010,7 @@ const ClientProvider = ({
4010
4010
  // If shouldFetchWalletKitConfig is false, we'll never have a proxyAuthConfig to build the master config with, so this useEffect should always run.
4011
4011
  if (!proxyAuthConfigRef.current && shouldFetchWalletKitConfig) return;
4012
4012
  setMasterConfig(buildConfig(proxyAuthConfigRef.current ?? undefined, clientParamsRef.current ?? undefined));
4013
- }, [config, proxyAuthConfigRef.current]);
4013
+ }, [config$1, proxyAuthConfigRef.current]);
4014
4014
  /**
4015
4015
  * @internal
4016
4016
  * We create `debouncedRefreshWallets()` so that multiple rapid wallet events