@turnkey/react-wallet-kit 2.2.0 → 2.3.0

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.
Files changed (95) hide show
  1. package/dist/components/auth/Email.d.ts +1 -0
  2. package/dist/components/auth/Email.d.ts.map +1 -1
  3. package/dist/components/auth/Email.js +1 -1
  4. package/dist/components/auth/Email.js.map +1 -1
  5. package/dist/components/auth/Email.mjs +2 -2
  6. package/dist/components/auth/Email.mjs.map +1 -1
  7. package/dist/components/auth/OAuth.d.ts +1 -0
  8. package/dist/components/auth/OAuth.d.ts.map +1 -1
  9. package/dist/components/auth/OAuth.js +3 -1
  10. package/dist/components/auth/OAuth.js.map +1 -1
  11. package/dist/components/auth/OAuth.mjs +3 -1
  12. package/dist/components/auth/OAuth.mjs.map +1 -1
  13. package/dist/components/auth/OTP.d.ts.map +1 -1
  14. package/dist/components/auth/OTP.js +22 -6
  15. package/dist/components/auth/OTP.js.map +1 -1
  16. package/dist/components/auth/OTP.mjs +37 -17
  17. package/dist/components/auth/OTP.mjs.map +1 -1
  18. package/dist/components/auth/Passkey.d.ts +1 -0
  19. package/dist/components/auth/Passkey.d.ts.map +1 -1
  20. package/dist/components/auth/Passkey.js +2 -0
  21. package/dist/components/auth/Passkey.js.map +1 -1
  22. package/dist/components/auth/Passkey.mjs +3 -0
  23. package/dist/components/auth/Passkey.mjs.map +1 -1
  24. package/dist/components/auth/Phone.d.ts +1 -0
  25. package/dist/components/auth/Phone.d.ts.map +1 -1
  26. package/dist/components/auth/Phone.js +1 -1
  27. package/dist/components/auth/Phone.js.map +1 -1
  28. package/dist/components/auth/Phone.mjs +2 -2
  29. package/dist/components/auth/Phone.mjs.map +1 -1
  30. package/dist/components/auth/Turnstile.d.ts +10 -0
  31. package/dist/components/auth/Turnstile.d.ts.map +1 -0
  32. package/dist/components/auth/Turnstile.js +13 -0
  33. package/dist/components/auth/Turnstile.js.map +1 -0
  34. package/dist/components/auth/Turnstile.mjs +11 -0
  35. package/dist/components/auth/Turnstile.mjs.map +1 -0
  36. package/dist/components/auth/TurnstileWidget.d.ts +26 -0
  37. package/dist/components/auth/TurnstileWidget.d.ts.map +1 -0
  38. package/dist/components/auth/TurnstileWidget.js +113 -0
  39. package/dist/components/auth/TurnstileWidget.js.map +1 -0
  40. package/dist/components/auth/TurnstileWidget.mjs +146 -0
  41. package/dist/components/auth/TurnstileWidget.mjs.map +1 -0
  42. package/dist/components/auth/index.d.ts.map +1 -1
  43. package/dist/components/auth/index.js +52 -23
  44. package/dist/components/auth/index.js.map +1 -1
  45. package/dist/components/auth/index.mjs +238 -114
  46. package/dist/components/auth/index.mjs.map +1 -1
  47. package/dist/components/auth/wallet/WalletAuthButton.d.ts +1 -0
  48. package/dist/components/auth/wallet/WalletAuthButton.d.ts.map +1 -1
  49. package/dist/components/auth/wallet/WalletAuthButton.js +1 -0
  50. package/dist/components/auth/wallet/WalletAuthButton.js.map +1 -1
  51. package/dist/components/auth/wallet/WalletAuthButton.mjs +2 -0
  52. package/dist/components/auth/wallet/WalletAuthButton.mjs.map +1 -1
  53. package/dist/providers/client/Provider.d.ts.map +1 -1
  54. package/dist/providers/client/Provider.js +106 -24
  55. package/dist/providers/client/Provider.js.map +1 -1
  56. package/dist/providers/client/Provider.mjs +110 -47
  57. package/dist/providers/client/Provider.mjs.map +1 -1
  58. package/dist/providers/client/Types.d.ts +4 -0
  59. package/dist/providers/client/Types.d.ts.map +1 -1
  60. package/dist/providers/client/Types.js.map +1 -1
  61. package/dist/providers/client/Types.mjs.map +1 -1
  62. package/dist/styles.css +1 -1
  63. package/dist/tests/captcha-test.d.ts +2 -0
  64. package/dist/tests/captcha-test.d.ts.map +1 -0
  65. package/dist/types/base.d.ts +2 -0
  66. package/dist/types/base.d.ts.map +1 -1
  67. package/dist/types/base.js.map +1 -1
  68. package/dist/types/base.mjs.map +1 -1
  69. package/dist/types/method-types.d.ts +5 -0
  70. package/dist/types/method-types.d.ts.map +1 -1
  71. package/dist/utils/captcha.d.ts +16 -0
  72. package/dist/utils/captcha.d.ts.map +1 -0
  73. package/dist/utils/captcha.js +47 -0
  74. package/dist/utils/captcha.js.map +1 -0
  75. package/dist/utils/captcha.mjs +64 -0
  76. package/dist/utils/captcha.mjs.map +1 -0
  77. package/dist/utils/oauth/completion.d.ts +10 -1
  78. package/dist/utils/oauth/completion.d.ts.map +1 -1
  79. package/dist/utils/oauth/completion.js +9 -0
  80. package/dist/utils/oauth/completion.js.map +1 -1
  81. package/dist/utils/oauth/completion.mjs +12 -7
  82. package/dist/utils/oauth/completion.mjs.map +1 -1
  83. package/dist/utils/oauth/storage.d.ts +10 -0
  84. package/dist/utils/oauth/storage.d.ts.map +1 -1
  85. package/dist/utils/oauth/storage.js +20 -0
  86. package/dist/utils/oauth/storage.js.map +1 -1
  87. package/dist/utils/oauth/storage.mjs +18 -1
  88. package/dist/utils/oauth/storage.mjs.map +1 -1
  89. package/dist/utils/oauth/url.d.ts +2 -0
  90. package/dist/utils/oauth/url.d.ts.map +1 -1
  91. package/dist/utils/oauth/url.js +2 -1
  92. package/dist/utils/oauth/url.js.map +1 -1
  93. package/dist/utils/oauth/url.mjs +3 -2
  94. package/dist/utils/oauth/url.mjs.map +1 -1
  95. package/package.json +4 -3
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.mjs';
3
- import { jsx } from 'react/jsx-runtime';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
4
  import { sha256 } from '@noble/hashes/sha2';
5
5
  import { bytesToHex } from '@noble/hashes/utils';
6
- import { storePKCEVerifier, storeOAuthAddProviderMetadata, clearAllOAuthData, getOAuthAddProviderMetadata, hasPKCEVerifier, OAUTH_INTENT_ADD_PROVIDER } from '../../utils/oauth/storage.mjs';
6
+ import { storePKCEVerifier, storeOAuthCaptchaToken, storeOAuthAddProviderMetadata, clearAllOAuthData, getOAuthAddProviderMetadata, hasPKCEVerifier, OAUTH_INTENT_ADD_PROVIDER } from '../../utils/oauth/storage.mjs';
7
7
  import '../../utils/oauth/config.mjs';
8
8
  import { parseOAuthResponse, openOAuthPopup, buildOAuthUrl, redirectToOAuthProvider, cleanupOAuthUrlPreserveSearch, cleanupOAuthUrl } from '../../utils/oauth/url.mjs';
9
9
  import { completeOAuthPopup, completeOAuthFlow, completePKCEFlow } from '../../utils/oauth/completion.mjs';
@@ -11,7 +11,7 @@ import { generateChallengePair, exchangeFacebookCodeForToken } from '../../utils
11
11
  import { capitalizeProviderName, getProviderIcon } from '../../utils/oauth/helpers.mjs';
12
12
  import { useWalletProviderState, useDebouncedCallback, isValidSession, withTurnkeyErrorHandling, SESSION_WARNING_THRESHOLD_MS, mergeWalletsWithoutDuplicates } from '../../utils/utils.mjs';
13
13
  import { clearKeys, clearAll, setCappedTimeoutInMap, clearKey, setTimeoutInMap } from '../../utils/timers.mjs';
14
- import { resetPasskeyScope, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, OtpType, applyPasskeyScope, buildSecondaryOauthProviders, TurnkeyClient, Chain, WalletInterfaceType, getAuthProxyConfig, WalletSource, buildSecondaryOidcClaims } from '@turnkey/core';
14
+ import { resetPasskeyScope, DEFAULT_SESSION_EXPIRATION_IN_SECONDS, OtpType, applyPasskeyScope, buildSecondaryOauthProviders, TurnkeyClient, Chain, WalletInterfaceType, getAuthProxyConfig, getClientParams, WalletSource, buildSecondaryOidcClaims } from '@turnkey/core';
15
15
  import { useState, useRef, useCallback, useEffect } from 'react';
16
16
  import { TurnkeyError, TurnkeyErrorCodes, TurnkeyNetworkError, AuthAction, OAuthProviders, FiatOnRampCryptoCurrency, FiatOnRampBlockchainNetwork } from '@turnkey/sdk-types';
17
17
  import { useModal } from '../modal/Hook.mjs';
@@ -39,6 +39,7 @@ import { OnRampPage } from '../../components/onramp/OnRamp.mjs';
39
39
  import { CoinbaseLogo, MoonPayLogo } from '../../components/design/Svg.mjs';
40
40
  import { SendTransactionPage } from '../../components/send-transaction/SendTransaction.mjs';
41
41
  import { getChainLogo } from '../../components/send-transaction/helpers.mjs';
42
+ import { Turnstile } from '../../components/auth/Turnstile.mjs';
42
43
 
43
44
  /**
44
45
  * Provides Turnkey client authentication, session management, wallet operations, and user profile management
@@ -99,6 +100,14 @@ var ClientProvider = function ClientProvider(_ref) {
99
100
  _useState12 = _slicedToArray(_useState11, 2),
100
101
  authState = _useState12[0],
101
102
  setAuthState = _useState12[1];
103
+ // Turnstile state: pre-warm the challenge in the background
104
+ var turnstileTokenRef = useRef(null);
105
+ var getTurnstileToken = useCallback(function () {
106
+ return turnstileTokenRef.current;
107
+ }, []);
108
+ var setTurnstileToken = useCallback(function (token) {
109
+ turnstileTokenRef.current = token;
110
+ }, []);
102
111
  // if there is no authProxyConfigId or if autoFetchWalletKitConfig is specifically
103
112
  // set to false, we don't need to fetch the config
104
113
  var shouldFetchWalletKitConfig = !!config.authProxyConfigId && ((_config$autoFetchWall = config.autoFetchWalletKitConfig) !== null && _config$autoFetchWall !== void 0 ? _config$autoFetchWall : true);
@@ -110,6 +119,7 @@ var ClientProvider = function ClientProvider(_ref) {
110
119
  setWalletProviders = _useWalletProviderSta2[1];
111
120
  var expiryTimeoutsRef = useRef({});
112
121
  var proxyAuthConfigRef = useRef(null);
122
+ var clientParamsRef = useRef(null);
113
123
  var _useState13 = useState(undefined),
114
124
  _useState14 = _slicedToArray(_useState13, 2),
115
125
  allSessions = _useState14[0],
@@ -121,7 +131,7 @@ var ClientProvider = function ClientProvider(_ref) {
121
131
  closeModal = _useModal.closeModal;
122
132
  var completeRedirectOauth = /*#__PURE__*/function () {
123
133
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
124
- var withModalWrapper, result, code, provider, publicKey, oauthIntent, sessionKey, nonce, openModal, isAddProvider, metadata, completePKCERedirect, _masterConfig$auth2, _masterConfig$auth2$o, _masterConfig$auth2$o2, _masterConfig$auth$oa, _masterConfig$auth3, _masterConfig$auth3$o, _masterConfig$auth3$o2, _masterConfig$auth4, _masterConfig$auth4$o, clientId, secondaryClientIds, redirectURI, hasVerifier, _masterConfig$auth5, _masterConfig$auth5$o, _masterConfig$auth5$o2, _masterConfig$auth$oa2, _masterConfig$auth6, _masterConfig$auth6$o, _masterConfig$auth6$o2, _masterConfig$auth7, _masterConfig$auth7$o, _clientId, _secondaryClientIds, _redirectURI, _hasVerifier, _masterConfig$auth8, _masterConfig$auth8$o, _masterConfig$auth8$o2, _masterConfig$auth$oa3, _masterConfig$auth9, _masterConfig$auth9$o, _masterConfig$auth9$o2, _masterConfig$auth0, _masterConfig$auth0$o, _clientId2, _secondaryClientIds2, _redirectURI2, _hasVerifier2, _ref0, _masterConfig$auth1, _masterConfig$auth1$o, _masterConfig$auth1$o2, _masterConfig$auth10, _masterConfig$auth10$, _masterConfig$auth10$2, _result, idToken, _provider, _publicKey, _openModal, _sessionKey, _oauthIntent, _isAddProvider, _metadata, resolvedProvider, _secondaryClientIds3, action;
134
+ var withModalWrapper, result, code, provider, publicKey, oauthIntent, sessionKey, nonce, openModal, captchaToken, isAddProvider, metadata, completePKCERedirect, _masterConfig$auth2, _masterConfig$auth2$o, _masterConfig$auth2$o2, _masterConfig$auth$oa, _masterConfig$auth3, _masterConfig$auth3$o, _masterConfig$auth3$o2, _masterConfig$auth4, _masterConfig$auth4$o, clientId, secondaryClientIds, redirectURI, hasVerifier, _masterConfig$auth5, _masterConfig$auth5$o, _masterConfig$auth5$o2, _masterConfig$auth$oa2, _masterConfig$auth6, _masterConfig$auth6$o, _masterConfig$auth6$o2, _masterConfig$auth7, _masterConfig$auth7$o, _clientId, _secondaryClientIds, _redirectURI, _hasVerifier, _masterConfig$auth8, _masterConfig$auth8$o, _masterConfig$auth8$o2, _masterConfig$auth$oa3, _masterConfig$auth9, _masterConfig$auth9$o, _masterConfig$auth9$o2, _masterConfig$auth0, _masterConfig$auth0$o, _clientId2, _secondaryClientIds2, _redirectURI2, _hasVerifier2, _ref0, _masterConfig$auth1, _masterConfig$auth1$o, _masterConfig$auth1$o2, _masterConfig$auth10, _masterConfig$auth10$, _masterConfig$auth10$2, _result, idToken, _provider, _publicKey, _openModal, _sessionKey, _oauthIntent, _captchaToken, _isAddProvider, _metadata, resolvedProvider, _secondaryClientIds3, action;
125
135
  return _regenerator().w(function (_context1) {
126
136
  while (1) switch (_context1.p = _context1.n) {
127
137
  case 0:
@@ -245,7 +255,7 @@ var ClientProvider = function ClientProvider(_ref) {
245
255
  }
246
256
  return _context1.a(2);
247
257
  case 3:
248
- code = result.authCode, provider = result.provider, publicKey = result.publicKey, oauthIntent = result.oauthIntent, sessionKey = result.sessionKey, nonce = result.nonce, openModal = result.openModal;
258
+ code = result.authCode, provider = result.provider, publicKey = result.publicKey, oauthIntent = result.oauthIntent, sessionKey = result.sessionKey, nonce = result.nonce, openModal = result.openModal, captchaToken = result.captchaToken;
249
259
  isAddProvider = oauthIntent === OAUTH_INTENT_ADD_PROVIDER;
250
260
  metadata = isAddProvider ? getOAuthAddProviderMetadata() : null;
251
261
  /**
@@ -271,6 +281,7 @@ var ClientProvider = function ClientProvider(_ref) {
271
281
  publicKey: publicKey,
272
282
  providerName: providerName,
273
283
  sessionKey: sessionKey !== null && sessionKey !== void 0 ? sessionKey : undefined,
284
+ captchaToken: captchaToken !== null && captchaToken !== void 0 ? captchaToken : undefined,
274
285
  callbacks: callbacks,
275
286
  completeOauth: function completeOauth(completionParams) {
276
287
  var _masterConfig$auth, _masterConfig$auth$cr, _completionParams$pro, _existingCreateSubOrg;
@@ -503,7 +514,7 @@ var ClientProvider = function ClientProvider(_ref) {
503
514
  }
504
515
  return _context1.a(2);
505
516
  case 10:
506
- idToken = _result.idToken, _provider = _result.provider, _publicKey = _result.publicKey, _openModal = _result.openModal, _sessionKey = _result.sessionKey, _oauthIntent = _result.oauthIntent;
517
+ idToken = _result.idToken, _provider = _result.provider, _publicKey = _result.publicKey, _openModal = _result.openModal, _sessionKey = _result.sessionKey, _oauthIntent = _result.oauthIntent, _captchaToken = _result.captchaToken;
507
518
  _isAddProvider = _oauthIntent === OAUTH_INTENT_ADD_PROVIDER;
508
519
  _metadata = _isAddProvider ? getOAuthAddProviderMetadata() : null;
509
520
  resolvedProvider = _provider || OAuthProviders.GOOGLE; // Grab Google/Apple secondary client IDs from config for use in completion
@@ -519,6 +530,7 @@ var ClientProvider = function ClientProvider(_ref) {
519
530
  publicKey: _publicKey,
520
531
  oidcToken: idToken,
521
532
  sessionKey: _sessionKey !== null && _sessionKey !== void 0 ? _sessionKey : undefined,
533
+ captchaToken: _captchaToken !== null && _captchaToken !== void 0 ? _captchaToken : undefined,
522
534
  callbacks: callbacks,
523
535
  completeOauth: function completeOauth(completionParams) {
524
536
  var _masterConfig$auth11, _masterConfig$auth11$, _completionParams$pro2, _existingCreateSubOrg2;
@@ -592,7 +604,7 @@ var ClientProvider = function ClientProvider(_ref) {
592
604
  return _ref2.apply(this, arguments);
593
605
  };
594
606
  }();
595
- var buildConfig = function buildConfig(proxyAuthConfig) {
607
+ var buildConfig = function buildConfig(proxyAuthConfig, clientParams) {
596
608
  var _config$ui$authModal$, _config$ui, _config$ui$authModal, _config$ui$authModal$2, _config$ui$authModal$3, _config$ui2, _config$ui2$authModal, _config$ui2$authModal2, _config$ui$authModal$4, _config$ui3, _config$ui3$authModal, _config$ui3$authModal2, _config$ui$authModal$5, _config$ui4, _config$ui4$authModal, _config$ui4$authModal2, _config$ui$authModal$6, _config$ui5, _config$ui5$authModal, _config$ui5$authModal2, _config$ui$authModal$7, _config$ui6, _config$ui6$authModal, _config$ui6$authModal2, _config$ui$authModal$8, _config$ui7, _config$ui7$authModal, _config$ui7$authModal2, _config$ui$authModal$9, _config$ui8, _config$ui8$authModal, _config$ui8$authModal2, _config$ui$authModal$0, _config$ui9, _config$ui9$authModal, _config$ui9$authModal2, _config$auth$oauthCon, _config$auth, _config$auth$oauthCon2, _config$auth$oauthCon3, _proxyAuthConfig$oaut, _config$auth$oauthCon4, _config$auth2, _config$auth2$oauthCo, _config$auth2$oauthCo2, _config$auth$oauthCon5, _config$auth3, _config$auth3$oauthCo, _config$auth3$oauthCo2, _proxyAuthConfig$oaut2, _config$auth$oauthCon6, _config$auth4, _config$auth4$oauthCo, _config$auth4$oauthCo2, _config$auth$oauthCon7, _config$auth5, _config$auth5$oauthCo, _config$auth5$oauthCo2, _proxyAuthConfig$oaut3, _config$auth$oauthCon8, _config$auth6, _config$auth6$oauthCo, _config$auth6$oauthCo2, _config$auth$oauthCon9, _config$auth7, _config$auth7$oauthCo, _config$auth7$oauthCo2, _proxyAuthConfig$oaut4, _config$auth$oauthCon0, _config$auth8, _config$auth8$oauthCo, _config$auth8$oauthCo2, _config$auth$oauthCon1, _config$auth9, _config$auth9$oauthCo, _config$auth9$oauthCo2, _proxyAuthConfig$oaut5, _config$auth$oauthCon10, _config$auth0, _config$auth0$oauthCo, _config$auth0$oauthCo2, _config$auth$oauthCon11, _config$auth1, _config$auth1$oauthCo, _config$ui$authModal$1, _config$ui0, _config$ui0$authModal, _config$ui$authModal$10, _config$ui1, _config$ui1$authModal, _proxyAuthConfig$sess, _config$auth13, _ref11, _proxyAuthConfig$otpA, _config$auth14, _ref12, _proxyAuthConfig$otpL, _config$auth15, _config$auth$scopePas, _config$auth16, _config$auth17, _config$auth18, _config$auth18$oauthC, _config$auth$autoRefr, _config$auth19, _config$ui10, _config$autoRefreshMa, _config$walletConfig, _ref13, _resolvedMethods$wall, _config$walletConfig2, _config$walletConfig3, _config$walletConfig$, _config$walletConfig4, _config$walletConfig5, _config$walletConfig6, _config$walletConfig7, _config$walletConfig8, _config$walletConfig$2, _config$walletConfig9, _config$walletConfig0, _config$walletConfig1, _config$walletConfig10, _config$walletConfig11, _config$walletConfig$3, _config$walletConfig12, _config$walletConfig13, _config$walletConfig14, _config$importIframeU, _config$exportIframeU;
597
609
  // Juggle the local overrides with the values set in the dashboard (proxyAuthConfig).
598
610
  var resolvedMethods = {
@@ -694,7 +706,8 @@ var ClientProvider = function ClientProvider(_ref) {
694
706
  })
695
707
  }),
696
708
  importIframeUrl: (_config$importIframeU = config.importIframeUrl) !== null && _config$importIframeU !== void 0 ? _config$importIframeU : "https://import.turnkey.com",
697
- exportIframeUrl: (_config$exportIframeU = config.exportIframeUrl) !== null && _config$exportIframeU !== void 0 ? _config$exportIframeU : "https://export.turnkey.com"
709
+ exportIframeUrl: (_config$exportIframeU = config.exportIframeUrl) !== null && _config$exportIframeU !== void 0 ? _config$exportIframeU : "https://export.turnkey.com",
710
+ turnstileSiteKey: clientParams === null || clientParams === void 0 ? void 0 : clientParams.turnstileSiteKey
698
711
  });
699
712
  };
700
713
  /**
@@ -4003,11 +4016,11 @@ var ClientProvider = function ClientProvider(_ref) {
4003
4016
  var handleDiscordOauth = useCallback(/*#__PURE__*/function () {
4004
4017
  var _ref108 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(params) {
4005
4018
  var _masterConfig$auth36, _masterConfig$auth36$, _masterConfig$auth36$2, _masterConfig$auth$oa4, _masterConfig$auth37, _masterConfig$auth37$, _masterConfig$auth37$2, _masterConfig$auth$oa5, _masterConfig$auth38, _masterConfig$auth38$, _masterConfig$auth39, _masterConfig$auth39$, _masterConfig$auth40;
4006
- var _ref109, _ref109$primaryClient, primaryClientId, _ref109$secondaryClie, secondaryClientIds, _ref109$openInPage, openInPage, additionalParameters, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
4019
+ var _ref109, _ref109$primaryClient, primaryClientId, _ref109$secondaryClie, secondaryClientIds, _ref109$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle, verifier, codeChallenge, authUrl, authWindow;
4007
4020
  return _regenerator().w(function (_context96) {
4008
4021
  while (1) switch (_context96.n) {
4009
4022
  case 0:
4010
- _ref109 = params || {}, _ref109$primaryClient = _ref109.primaryClientId, primaryClientId = _ref109$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) === null || _masterConfig$auth36$ === void 0 ? void 0 : (_masterConfig$auth36$2 = _masterConfig$auth36$.discord) === null || _masterConfig$auth36$2 === void 0 ? void 0 : _masterConfig$auth36$2.primaryClientId : _ref109$primaryClient, _ref109$secondaryClie = _ref109.secondaryClientIds, secondaryClientIds = _ref109$secondaryClie === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) === null || _masterConfig$auth37$ === void 0 ? void 0 : (_masterConfig$auth37$2 = _masterConfig$auth37$.discord) === null || _masterConfig$auth37$2 === void 0 ? void 0 : _masterConfig$auth37$2.secondaryClientIds) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : [] : _ref109$secondaryClie, _ref109$openInPage = _ref109.openInPage, openInPage = _ref109$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) === null || _masterConfig$auth38$ === void 0 ? void 0 : _masterConfig$auth38$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref109$openInPage, additionalParameters = _ref109.additionalState;
4023
+ _ref109 = params || {}, _ref109$primaryClient = _ref109.primaryClientId, primaryClientId = _ref109$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth36 = masterConfig.auth) === null || _masterConfig$auth36 === void 0 ? void 0 : (_masterConfig$auth36$ = _masterConfig$auth36.oauthConfig) === null || _masterConfig$auth36$ === void 0 ? void 0 : (_masterConfig$auth36$2 = _masterConfig$auth36$.discord) === null || _masterConfig$auth36$2 === void 0 ? void 0 : _masterConfig$auth36$2.primaryClientId : _ref109$primaryClient, _ref109$secondaryClie = _ref109.secondaryClientIds, secondaryClientIds = _ref109$secondaryClie === void 0 ? (_masterConfig$auth$oa4 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth37 = masterConfig.auth) === null || _masterConfig$auth37 === void 0 ? void 0 : (_masterConfig$auth37$ = _masterConfig$auth37.oauthConfig) === null || _masterConfig$auth37$ === void 0 ? void 0 : (_masterConfig$auth37$2 = _masterConfig$auth37$.discord) === null || _masterConfig$auth37$2 === void 0 ? void 0 : _masterConfig$auth37$2.secondaryClientIds) !== null && _masterConfig$auth$oa4 !== void 0 ? _masterConfig$auth$oa4 : [] : _ref109$secondaryClie, _ref109$openInPage = _ref109.openInPage, openInPage = _ref109$openInPage === void 0 ? (_masterConfig$auth$oa5 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth38 = masterConfig.auth) === null || _masterConfig$auth38 === void 0 ? void 0 : (_masterConfig$auth38$ = _masterConfig$auth38.oauthConfig) === null || _masterConfig$auth38$ === void 0 ? void 0 : _masterConfig$auth38$.openOauthInPage) !== null && _masterConfig$auth$oa5 !== void 0 ? _masterConfig$auth$oa5 : false : _ref109$openInPage, additionalParameters = _ref109.additionalState, captchaToken = _ref109.captchaToken;
4011
4024
  clientId = primaryClientId;
4012
4025
  provider = OAuthProviders.DISCORD;
4013
4026
  if (masterConfig) {
@@ -4048,6 +4061,10 @@ var ClientProvider = function ClientProvider(_ref) {
4048
4061
  verifier = _yield$generateChalle.verifier;
4049
4062
  codeChallenge = _yield$generateChalle.codeChallenge;
4050
4063
  storePKCEVerifier(provider, verifier);
4064
+ // Persist captcha out of the redirect URL (same pattern as PKCE verifier)
4065
+ if (openInPage && captchaToken) {
4066
+ storeOAuthCaptchaToken(captchaToken);
4067
+ }
4051
4068
  // Build OAuth URL
4052
4069
  authUrl = buildOAuthUrl({
4053
4070
  provider: provider,
@@ -4057,7 +4074,7 @@ var ClientProvider = function ClientProvider(_ref) {
4057
4074
  nonce: nonce,
4058
4075
  flow: flow,
4059
4076
  codeChallenge: codeChallenge,
4060
- additionalState: additionalParameters
4077
+ additionalState: _objectSpread2({}, additionalParameters)
4061
4078
  });
4062
4079
  if (!openInPage) {
4063
4080
  _context96.n = 7;
@@ -4103,6 +4120,7 @@ var ClientProvider = function ClientProvider(_ref) {
4103
4120
  })
4104
4121
  }));
4105
4122
  },
4123
+ captchaToken: captchaToken,
4106
4124
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4107
4125
  exchangeCodeForToken: function () {
4108
4126
  var _exchangeCodeForToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(codeVerifier) {
@@ -4154,11 +4172,11 @@ var ClientProvider = function ClientProvider(_ref) {
4154
4172
  var handleXOauth = useCallback(/*#__PURE__*/function () {
4155
4173
  var _ref110 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(params) {
4156
4174
  var _masterConfig$auth42, _masterConfig$auth42$, _masterConfig$auth42$2, _masterConfig$auth$oa6, _masterConfig$auth43, _masterConfig$auth43$, _masterConfig$auth43$2, _masterConfig$auth$oa7, _masterConfig$auth44, _masterConfig$auth44$, _masterConfig$auth45, _masterConfig$auth45$, _masterConfig$auth46;
4157
- var _ref111, _ref111$primaryClient, primaryClientId, _ref111$secondaryClie, secondaryClientIds, _ref111$openInPage, openInPage, additionalParameters, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
4175
+ var _ref111, _ref111$primaryClient, primaryClientId, _ref111$secondaryClie, secondaryClientIds, _ref111$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle2, verifier, codeChallenge, authUrl, authWindow;
4158
4176
  return _regenerator().w(function (_context98) {
4159
4177
  while (1) switch (_context98.n) {
4160
4178
  case 0:
4161
- _ref111 = params || {}, _ref111$primaryClient = _ref111.primaryClientId, primaryClientId = _ref111$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : (_masterConfig$auth42$ = _masterConfig$auth42.oauthConfig) === null || _masterConfig$auth42$ === void 0 ? void 0 : (_masterConfig$auth42$2 = _masterConfig$auth42$.x) === null || _masterConfig$auth42$2 === void 0 ? void 0 : _masterConfig$auth42$2.primaryClientId : _ref111$primaryClient, _ref111$secondaryClie = _ref111.secondaryClientIds, secondaryClientIds = _ref111$secondaryClie === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : (_masterConfig$auth43$ = _masterConfig$auth43.oauthConfig) === null || _masterConfig$auth43$ === void 0 ? void 0 : (_masterConfig$auth43$2 = _masterConfig$auth43$.x) === null || _masterConfig$auth43$2 === void 0 ? void 0 : _masterConfig$auth43$2.secondaryClientIds) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : [] : _ref111$secondaryClie, _ref111$openInPage = _ref111.openInPage, openInPage = _ref111$openInPage === void 0 ? (_masterConfig$auth$oa7 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : (_masterConfig$auth44$ = _masterConfig$auth44.oauthConfig) === null || _masterConfig$auth44$ === void 0 ? void 0 : _masterConfig$auth44$.openOauthInPage) !== null && _masterConfig$auth$oa7 !== void 0 ? _masterConfig$auth$oa7 : false : _ref111$openInPage, additionalParameters = _ref111.additionalState;
4179
+ _ref111 = params || {}, _ref111$primaryClient = _ref111.primaryClientId, primaryClientId = _ref111$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth42 = masterConfig.auth) === null || _masterConfig$auth42 === void 0 ? void 0 : (_masterConfig$auth42$ = _masterConfig$auth42.oauthConfig) === null || _masterConfig$auth42$ === void 0 ? void 0 : (_masterConfig$auth42$2 = _masterConfig$auth42$.x) === null || _masterConfig$auth42$2 === void 0 ? void 0 : _masterConfig$auth42$2.primaryClientId : _ref111$primaryClient, _ref111$secondaryClie = _ref111.secondaryClientIds, secondaryClientIds = _ref111$secondaryClie === void 0 ? (_masterConfig$auth$oa6 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth43 = masterConfig.auth) === null || _masterConfig$auth43 === void 0 ? void 0 : (_masterConfig$auth43$ = _masterConfig$auth43.oauthConfig) === null || _masterConfig$auth43$ === void 0 ? void 0 : (_masterConfig$auth43$2 = _masterConfig$auth43$.x) === null || _masterConfig$auth43$2 === void 0 ? void 0 : _masterConfig$auth43$2.secondaryClientIds) !== null && _masterConfig$auth$oa6 !== void 0 ? _masterConfig$auth$oa6 : [] : _ref111$secondaryClie, _ref111$openInPage = _ref111.openInPage, openInPage = _ref111$openInPage === void 0 ? (_masterConfig$auth$oa7 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth44 = masterConfig.auth) === null || _masterConfig$auth44 === void 0 ? void 0 : (_masterConfig$auth44$ = _masterConfig$auth44.oauthConfig) === null || _masterConfig$auth44$ === void 0 ? void 0 : _masterConfig$auth44$.openOauthInPage) !== null && _masterConfig$auth$oa7 !== void 0 ? _masterConfig$auth$oa7 : false : _ref111$openInPage, additionalParameters = _ref111.additionalState, captchaToken = _ref111.captchaToken;
4162
4180
  clientId = primaryClientId;
4163
4181
  provider = OAuthProviders.X;
4164
4182
  if (masterConfig) {
@@ -4199,6 +4217,10 @@ var ClientProvider = function ClientProvider(_ref) {
4199
4217
  verifier = _yield$generateChalle2.verifier;
4200
4218
  codeChallenge = _yield$generateChalle2.codeChallenge;
4201
4219
  storePKCEVerifier(provider, verifier);
4220
+ // Persist captcha out of the redirect URL (same pattern as PKCE verifier)
4221
+ if (openInPage && captchaToken) {
4222
+ storeOAuthCaptchaToken(captchaToken);
4223
+ }
4202
4224
  // Build OAuth URL
4203
4225
  authUrl = buildOAuthUrl({
4204
4226
  provider: provider,
@@ -4208,7 +4230,7 @@ var ClientProvider = function ClientProvider(_ref) {
4208
4230
  nonce: nonce,
4209
4231
  flow: flow,
4210
4232
  codeChallenge: codeChallenge,
4211
- additionalState: additionalParameters
4233
+ additionalState: _objectSpread2({}, additionalParameters)
4212
4234
  });
4213
4235
  if (!openInPage) {
4214
4236
  _context98.n = 7;
@@ -4254,6 +4276,7 @@ var ClientProvider = function ClientProvider(_ref) {
4254
4276
  })
4255
4277
  }));
4256
4278
  },
4279
+ captchaToken: captchaToken,
4257
4280
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4258
4281
  exchangeCodeForToken: function () {
4259
4282
  var _exchangeCodeForToken2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(codeVerifier) {
@@ -4305,11 +4328,11 @@ var ClientProvider = function ClientProvider(_ref) {
4305
4328
  var handleGoogleOauth = useCallback(/*#__PURE__*/function () {
4306
4329
  var _ref112 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(params) {
4307
4330
  var _masterConfig$auth48, _masterConfig$auth48$, _masterConfig$auth48$2, _masterConfig$auth$oa8, _masterConfig$auth49, _masterConfig$auth49$, _masterConfig$auth49$2, _masterConfig$auth$oa9, _masterConfig$auth50, _masterConfig$auth50$, _masterConfig$auth51, _masterConfig$auth51$, _masterConfig$auth52;
4308
- var _ref113, _ref113$primaryClient, primaryClientId, _ref113$secondaryClie, secondaryClientIds, _ref113$openInPage, openInPage, additionalParameters, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4331
+ var _ref113, _ref113$primaryClient, primaryClientId, _ref113$secondaryClie, secondaryClientIds, _ref113$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4309
4332
  return _regenerator().w(function (_context99) {
4310
4333
  while (1) switch (_context99.n) {
4311
4334
  case 0:
4312
- _ref113 = params || {}, _ref113$primaryClient = _ref113.primaryClientId, primaryClientId = _ref113$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : (_masterConfig$auth48$ = _masterConfig$auth48.oauthConfig) === null || _masterConfig$auth48$ === void 0 ? void 0 : (_masterConfig$auth48$2 = _masterConfig$auth48$.google) === null || _masterConfig$auth48$2 === void 0 ? void 0 : _masterConfig$auth48$2.primaryClientId : _ref113$primaryClient, _ref113$secondaryClie = _ref113.secondaryClientIds, secondaryClientIds = _ref113$secondaryClie === void 0 ? (_masterConfig$auth$oa8 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : (_masterConfig$auth49$ = _masterConfig$auth49.oauthConfig) === null || _masterConfig$auth49$ === void 0 ? void 0 : (_masterConfig$auth49$2 = _masterConfig$auth49$.google) === null || _masterConfig$auth49$2 === void 0 ? void 0 : _masterConfig$auth49$2.secondaryClientIds) !== null && _masterConfig$auth$oa8 !== void 0 ? _masterConfig$auth$oa8 : [] : _ref113$secondaryClie, _ref113$openInPage = _ref113.openInPage, openInPage = _ref113$openInPage === void 0 ? (_masterConfig$auth$oa9 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : (_masterConfig$auth50$ = _masterConfig$auth50.oauthConfig) === null || _masterConfig$auth50$ === void 0 ? void 0 : _masterConfig$auth50$.openOauthInPage) !== null && _masterConfig$auth$oa9 !== void 0 ? _masterConfig$auth$oa9 : false : _ref113$openInPage, additionalParameters = _ref113.additionalState;
4335
+ _ref113 = params || {}, _ref113$primaryClient = _ref113.primaryClientId, primaryClientId = _ref113$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth48 = masterConfig.auth) === null || _masterConfig$auth48 === void 0 ? void 0 : (_masterConfig$auth48$ = _masterConfig$auth48.oauthConfig) === null || _masterConfig$auth48$ === void 0 ? void 0 : (_masterConfig$auth48$2 = _masterConfig$auth48$.google) === null || _masterConfig$auth48$2 === void 0 ? void 0 : _masterConfig$auth48$2.primaryClientId : _ref113$primaryClient, _ref113$secondaryClie = _ref113.secondaryClientIds, secondaryClientIds = _ref113$secondaryClie === void 0 ? (_masterConfig$auth$oa8 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth49 = masterConfig.auth) === null || _masterConfig$auth49 === void 0 ? void 0 : (_masterConfig$auth49$ = _masterConfig$auth49.oauthConfig) === null || _masterConfig$auth49$ === void 0 ? void 0 : (_masterConfig$auth49$2 = _masterConfig$auth49$.google) === null || _masterConfig$auth49$2 === void 0 ? void 0 : _masterConfig$auth49$2.secondaryClientIds) !== null && _masterConfig$auth$oa8 !== void 0 ? _masterConfig$auth$oa8 : [] : _ref113$secondaryClie, _ref113$openInPage = _ref113.openInPage, openInPage = _ref113$openInPage === void 0 ? (_masterConfig$auth$oa9 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth50 = masterConfig.auth) === null || _masterConfig$auth50 === void 0 ? void 0 : (_masterConfig$auth50$ = _masterConfig$auth50.oauthConfig) === null || _masterConfig$auth50$ === void 0 ? void 0 : _masterConfig$auth50$.openOauthInPage) !== null && _masterConfig$auth$oa9 !== void 0 ? _masterConfig$auth$oa9 : false : _ref113$openInPage, additionalParameters = _ref113.additionalState, captchaToken = _ref113.captchaToken;
4313
4336
  clientId = primaryClientId;
4314
4337
  provider = OAuthProviders.GOOGLE;
4315
4338
  if (masterConfig) {
@@ -4342,7 +4365,11 @@ var ClientProvider = function ClientProvider(_ref) {
4342
4365
  }
4343
4366
  throw new Error("Failed to create public key for OAuth.");
4344
4367
  case 5:
4345
- nonce = bytesToHex(sha256(publicKey)); // Build OAuth URL
4368
+ nonce = bytesToHex(sha256(publicKey)); // Persist captcha out of the redirect URL (same pattern as PKCE verifier)
4369
+ if (openInPage && captchaToken) {
4370
+ storeOAuthCaptchaToken(captchaToken);
4371
+ }
4372
+ // Build OAuth URL
4346
4373
  authUrl = buildOAuthUrl({
4347
4374
  provider: provider,
4348
4375
  clientId: clientId,
@@ -4350,7 +4377,7 @@ var ClientProvider = function ClientProvider(_ref) {
4350
4377
  publicKey: publicKey,
4351
4378
  nonce: nonce,
4352
4379
  flow: flow,
4353
- additionalState: additionalParameters
4380
+ additionalState: _objectSpread2({}, additionalParameters)
4354
4381
  });
4355
4382
  if (!openInPage) {
4356
4383
  _context99.n = 6;
@@ -4396,6 +4423,7 @@ var ClientProvider = function ClientProvider(_ref) {
4396
4423
  })
4397
4424
  }));
4398
4425
  },
4426
+ captchaToken: captchaToken,
4399
4427
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess
4400
4428
  }).then(function () {
4401
4429
  return resolve();
@@ -4420,11 +4448,11 @@ var ClientProvider = function ClientProvider(_ref) {
4420
4448
  var handleAppleOauth = useCallback(/*#__PURE__*/function () {
4421
4449
  var _ref114 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(params) {
4422
4450
  var _masterConfig$auth54, _masterConfig$auth54$, _masterConfig$auth54$2, _masterConfig$auth$oa0, _masterConfig$auth55, _masterConfig$auth55$, _masterConfig$auth55$2, _masterConfig$auth$oa1, _masterConfig$auth56, _masterConfig$auth56$, _masterConfig$auth57, _masterConfig$auth57$, _masterConfig$auth58;
4423
- var _ref115, _ref115$primaryClient, primaryClientId, _ref115$secondaryClie, secondaryClientIds, _ref115$openInPage, openInPage, additionalParameters, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4451
+ var _ref115, _ref115$primaryClient, primaryClientId, _ref115$secondaryClie, secondaryClientIds, _ref115$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, authUrl, authWindow;
4424
4452
  return _regenerator().w(function (_context100) {
4425
4453
  while (1) switch (_context100.n) {
4426
4454
  case 0:
4427
- _ref115 = params || {}, _ref115$primaryClient = _ref115.primaryClientId, primaryClientId = _ref115$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth54 = masterConfig.auth) === null || _masterConfig$auth54 === void 0 ? void 0 : (_masterConfig$auth54$ = _masterConfig$auth54.oauthConfig) === null || _masterConfig$auth54$ === void 0 ? void 0 : (_masterConfig$auth54$2 = _masterConfig$auth54$.apple) === null || _masterConfig$auth54$2 === void 0 ? void 0 : _masterConfig$auth54$2.primaryClientId : _ref115$primaryClient, _ref115$secondaryClie = _ref115.secondaryClientIds, secondaryClientIds = _ref115$secondaryClie === void 0 ? (_masterConfig$auth$oa0 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth55 = masterConfig.auth) === null || _masterConfig$auth55 === void 0 ? void 0 : (_masterConfig$auth55$ = _masterConfig$auth55.oauthConfig) === null || _masterConfig$auth55$ === void 0 ? void 0 : (_masterConfig$auth55$2 = _masterConfig$auth55$.apple) === null || _masterConfig$auth55$2 === void 0 ? void 0 : _masterConfig$auth55$2.secondaryClientIds) !== null && _masterConfig$auth$oa0 !== void 0 ? _masterConfig$auth$oa0 : [] : _ref115$secondaryClie, _ref115$openInPage = _ref115.openInPage, openInPage = _ref115$openInPage === void 0 ? (_masterConfig$auth$oa1 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth56 = masterConfig.auth) === null || _masterConfig$auth56 === void 0 ? void 0 : (_masterConfig$auth56$ = _masterConfig$auth56.oauthConfig) === null || _masterConfig$auth56$ === void 0 ? void 0 : _masterConfig$auth56$.openOauthInPage) !== null && _masterConfig$auth$oa1 !== void 0 ? _masterConfig$auth$oa1 : false : _ref115$openInPage, additionalParameters = _ref115.additionalState;
4455
+ _ref115 = params || {}, _ref115$primaryClient = _ref115.primaryClientId, primaryClientId = _ref115$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth54 = masterConfig.auth) === null || _masterConfig$auth54 === void 0 ? void 0 : (_masterConfig$auth54$ = _masterConfig$auth54.oauthConfig) === null || _masterConfig$auth54$ === void 0 ? void 0 : (_masterConfig$auth54$2 = _masterConfig$auth54$.apple) === null || _masterConfig$auth54$2 === void 0 ? void 0 : _masterConfig$auth54$2.primaryClientId : _ref115$primaryClient, _ref115$secondaryClie = _ref115.secondaryClientIds, secondaryClientIds = _ref115$secondaryClie === void 0 ? (_masterConfig$auth$oa0 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth55 = masterConfig.auth) === null || _masterConfig$auth55 === void 0 ? void 0 : (_masterConfig$auth55$ = _masterConfig$auth55.oauthConfig) === null || _masterConfig$auth55$ === void 0 ? void 0 : (_masterConfig$auth55$2 = _masterConfig$auth55$.apple) === null || _masterConfig$auth55$2 === void 0 ? void 0 : _masterConfig$auth55$2.secondaryClientIds) !== null && _masterConfig$auth$oa0 !== void 0 ? _masterConfig$auth$oa0 : [] : _ref115$secondaryClie, _ref115$openInPage = _ref115.openInPage, openInPage = _ref115$openInPage === void 0 ? (_masterConfig$auth$oa1 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth56 = masterConfig.auth) === null || _masterConfig$auth56 === void 0 ? void 0 : (_masterConfig$auth56$ = _masterConfig$auth56.oauthConfig) === null || _masterConfig$auth56$ === void 0 ? void 0 : _masterConfig$auth56$.openOauthInPage) !== null && _masterConfig$auth$oa1 !== void 0 ? _masterConfig$auth$oa1 : false : _ref115$openInPage, additionalParameters = _ref115.additionalState, captchaToken = _ref115.captchaToken;
4428
4456
  clientId = primaryClientId;
4429
4457
  provider = OAuthProviders.APPLE;
4430
4458
  if (masterConfig) {
@@ -4457,7 +4485,11 @@ var ClientProvider = function ClientProvider(_ref) {
4457
4485
  }
4458
4486
  throw new Error("Failed to create public key for OAuth.");
4459
4487
  case 5:
4460
- nonce = bytesToHex(sha256(publicKey)); // Build OAuth URL
4488
+ nonce = bytesToHex(sha256(publicKey)); // Persist captcha out of the redirect URL (same pattern as PKCE verifier)
4489
+ if (openInPage && captchaToken) {
4490
+ storeOAuthCaptchaToken(captchaToken);
4491
+ }
4492
+ // Build OAuth URL
4461
4493
  authUrl = buildOAuthUrl({
4462
4494
  provider: provider,
4463
4495
  clientId: clientId,
@@ -4465,7 +4497,7 @@ var ClientProvider = function ClientProvider(_ref) {
4465
4497
  publicKey: publicKey,
4466
4498
  nonce: nonce,
4467
4499
  flow: flow,
4468
- additionalState: additionalParameters
4500
+ additionalState: _objectSpread2({}, additionalParameters)
4469
4501
  });
4470
4502
  if (!openInPage) {
4471
4503
  _context100.n = 6;
@@ -4511,6 +4543,7 @@ var ClientProvider = function ClientProvider(_ref) {
4511
4543
  })
4512
4544
  }));
4513
4545
  },
4546
+ captchaToken: captchaToken,
4514
4547
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess
4515
4548
  }).then(function () {
4516
4549
  return resolve();
@@ -4535,11 +4568,11 @@ var ClientProvider = function ClientProvider(_ref) {
4535
4568
  var handleFacebookOauth = useCallback(/*#__PURE__*/function () {
4536
4569
  var _ref116 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(params) {
4537
4570
  var _masterConfig$auth60, _masterConfig$auth60$, _masterConfig$auth60$2, _masterConfig$auth$oa10, _masterConfig$auth61, _masterConfig$auth61$, _masterConfig$auth61$2, _masterConfig$auth$oa11, _masterConfig$auth62, _masterConfig$auth62$, _masterConfig$auth63, _masterConfig$auth63$, _masterConfig$auth64;
4538
- var _ref117, _ref117$primaryClient, primaryClientId, _ref117$secondaryClie, secondaryClientIds, _ref117$openInPage, openInPage, additionalParameters, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4571
+ var _ref117, _ref117$primaryClient, primaryClientId, _ref117$secondaryClie, secondaryClientIds, _ref117$openInPage, openInPage, additionalParameters, captchaToken, clientId, provider, flow, redirectUri, publicKey, nonce, _yield$generateChalle3, verifier, codeChallenge, authUrl, authWindow;
4539
4572
  return _regenerator().w(function (_context102) {
4540
4573
  while (1) switch (_context102.n) {
4541
4574
  case 0:
4542
- _ref117 = params || {}, _ref117$primaryClient = _ref117.primaryClientId, primaryClientId = _ref117$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth60 = masterConfig.auth) === null || _masterConfig$auth60 === void 0 ? void 0 : (_masterConfig$auth60$ = _masterConfig$auth60.oauthConfig) === null || _masterConfig$auth60$ === void 0 ? void 0 : (_masterConfig$auth60$2 = _masterConfig$auth60$.facebook) === null || _masterConfig$auth60$2 === void 0 ? void 0 : _masterConfig$auth60$2.primaryClientId : _ref117$primaryClient, _ref117$secondaryClie = _ref117.secondaryClientIds, secondaryClientIds = _ref117$secondaryClie === void 0 ? (_masterConfig$auth$oa10 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth61 = masterConfig.auth) === null || _masterConfig$auth61 === void 0 ? void 0 : (_masterConfig$auth61$ = _masterConfig$auth61.oauthConfig) === null || _masterConfig$auth61$ === void 0 ? void 0 : (_masterConfig$auth61$2 = _masterConfig$auth61$.facebook) === null || _masterConfig$auth61$2 === void 0 ? void 0 : _masterConfig$auth61$2.secondaryClientIds) !== null && _masterConfig$auth$oa10 !== void 0 ? _masterConfig$auth$oa10 : [] : _ref117$secondaryClie, _ref117$openInPage = _ref117.openInPage, openInPage = _ref117$openInPage === void 0 ? (_masterConfig$auth$oa11 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth62 = masterConfig.auth) === null || _masterConfig$auth62 === void 0 ? void 0 : (_masterConfig$auth62$ = _masterConfig$auth62.oauthConfig) === null || _masterConfig$auth62$ === void 0 ? void 0 : _masterConfig$auth62$.openOauthInPage) !== null && _masterConfig$auth$oa11 !== void 0 ? _masterConfig$auth$oa11 : false : _ref117$openInPage, additionalParameters = _ref117.additionalState;
4575
+ _ref117 = params || {}, _ref117$primaryClient = _ref117.primaryClientId, primaryClientId = _ref117$primaryClient === void 0 ? masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth60 = masterConfig.auth) === null || _masterConfig$auth60 === void 0 ? void 0 : (_masterConfig$auth60$ = _masterConfig$auth60.oauthConfig) === null || _masterConfig$auth60$ === void 0 ? void 0 : (_masterConfig$auth60$2 = _masterConfig$auth60$.facebook) === null || _masterConfig$auth60$2 === void 0 ? void 0 : _masterConfig$auth60$2.primaryClientId : _ref117$primaryClient, _ref117$secondaryClie = _ref117.secondaryClientIds, secondaryClientIds = _ref117$secondaryClie === void 0 ? (_masterConfig$auth$oa10 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth61 = masterConfig.auth) === null || _masterConfig$auth61 === void 0 ? void 0 : (_masterConfig$auth61$ = _masterConfig$auth61.oauthConfig) === null || _masterConfig$auth61$ === void 0 ? void 0 : (_masterConfig$auth61$2 = _masterConfig$auth61$.facebook) === null || _masterConfig$auth61$2 === void 0 ? void 0 : _masterConfig$auth61$2.secondaryClientIds) !== null && _masterConfig$auth$oa10 !== void 0 ? _masterConfig$auth$oa10 : [] : _ref117$secondaryClie, _ref117$openInPage = _ref117.openInPage, openInPage = _ref117$openInPage === void 0 ? (_masterConfig$auth$oa11 = masterConfig === null || masterConfig === void 0 ? void 0 : (_masterConfig$auth62 = masterConfig.auth) === null || _masterConfig$auth62 === void 0 ? void 0 : (_masterConfig$auth62$ = _masterConfig$auth62.oauthConfig) === null || _masterConfig$auth62$ === void 0 ? void 0 : _masterConfig$auth62$.openOauthInPage) !== null && _masterConfig$auth$oa11 !== void 0 ? _masterConfig$auth$oa11 : false : _ref117$openInPage, additionalParameters = _ref117.additionalState, captchaToken = _ref117.captchaToken;
4543
4576
  clientId = primaryClientId;
4544
4577
  provider = OAuthProviders.FACEBOOK;
4545
4578
  if (masterConfig) {
@@ -4580,6 +4613,10 @@ var ClientProvider = function ClientProvider(_ref) {
4580
4613
  verifier = _yield$generateChalle3.verifier;
4581
4614
  codeChallenge = _yield$generateChalle3.codeChallenge;
4582
4615
  storePKCEVerifier(provider, verifier);
4616
+ // Persist captcha out of the redirect URL (same pattern as PKCE verifier)
4617
+ if (openInPage && captchaToken) {
4618
+ storeOAuthCaptchaToken(captchaToken);
4619
+ }
4583
4620
  // Build OAuth URL
4584
4621
  authUrl = buildOAuthUrl({
4585
4622
  provider: provider,
@@ -4589,7 +4626,7 @@ var ClientProvider = function ClientProvider(_ref) {
4589
4626
  nonce: nonce,
4590
4627
  flow: flow,
4591
4628
  codeChallenge: codeChallenge,
4592
- additionalState: additionalParameters
4629
+ additionalState: _objectSpread2({}, additionalParameters)
4593
4630
  });
4594
4631
  if (!openInPage) {
4595
4632
  _context102.n = 7;
@@ -4635,6 +4672,7 @@ var ClientProvider = function ClientProvider(_ref) {
4635
4672
  })
4636
4673
  }));
4637
4674
  },
4675
+ captchaToken: captchaToken,
4638
4676
  onOauthSuccess: params === null || params === void 0 ? void 0 : params.onOauthSuccess,
4639
4677
  exchangeCodeForToken: function () {
4640
4678
  var _exchangeCodeForToken3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(codeVerifier) {
@@ -6900,37 +6938,45 @@ var ClientProvider = function ClientProvider(_ref) {
6900
6938
  }(), [getSession, pushPage]);
6901
6939
  useEffect(function () {
6902
6940
  if (proxyAuthConfigRef.current) return;
6903
- // Only fetch the proxy auth config once. Use that to build the master config.
6941
+ // Fetch proxy auth config and client params once. Use both to build the master config.
6904
6942
  var fetchProxyAuthConfig = /*#__PURE__*/function () {
6905
6943
  var _ref162 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
6906
- var proxyAuthConfig;
6944
+ var proxyAuthConfig, clientParams, promises;
6907
6945
  return _regenerator().w(function (_context136) {
6908
6946
  while (1) switch (_context136.p = _context136.n) {
6909
6947
  case 0:
6910
6948
  _context136.p = 0;
6911
- if (!shouldFetchWalletKitConfig) {
6912
- _context136.n = 2;
6913
- break;
6949
+ promises = [];
6950
+ if (shouldFetchWalletKitConfig) {
6951
+ promises.push(getAuthProxyConfig(config.authProxyConfigId, config.authProxyUrl).then(function (result) {
6952
+ proxyAuthConfig = result;
6953
+ }));
6954
+ }
6955
+ if (config.authProxyConfigId) {
6956
+ promises.push(getClientParams(config.authProxyConfigId, config.authProxyUrl).then(function (result) {
6957
+ clientParams = result;
6958
+ }));
6914
6959
  }
6915
6960
  _context136.n = 1;
6916
- return getAuthProxyConfig(config.authProxyConfigId,
6917
- // Can assert safely. See shouldFetchWalletKitConfig definition.
6918
- config.authProxyUrl);
6961
+ return Promise.all(promises);
6919
6962
  case 1:
6920
- proxyAuthConfig = _context136.v;
6921
- proxyAuthConfigRef.current = proxyAuthConfig;
6922
- case 2:
6923
- setMasterConfig(buildConfig(proxyAuthConfig));
6924
- _context136.n = 4;
6963
+ if (proxyAuthConfig) {
6964
+ proxyAuthConfigRef.current = proxyAuthConfig;
6965
+ }
6966
+ if (clientParams) {
6967
+ clientParamsRef.current = clientParams;
6968
+ }
6969
+ setMasterConfig(buildConfig(proxyAuthConfig, clientParams));
6970
+ _context136.n = 3;
6925
6971
  break;
6926
- case 3:
6927
- _context136.p = 3;
6972
+ case 2:
6973
+ _context136.p = 2;
6928
6974
  _context136.v;
6929
6975
  setClientState(ClientState.Error);
6930
- case 4:
6976
+ case 3:
6931
6977
  return _context136.a(2);
6932
6978
  }
6933
- }, _callee136, null, [[0, 3]]);
6979
+ }, _callee136, null, [[0, 2]]);
6934
6980
  }));
6935
6981
  return function fetchProxyAuthConfig() {
6936
6982
  return _ref162.apply(this, arguments);
@@ -6944,13 +6990,13 @@ var ClientProvider = function ClientProvider(_ref) {
6944
6990
  initializeClient();
6945
6991
  }, [masterConfig]);
6946
6992
  useEffect(function () {
6947
- var _proxyAuthConfigRef$c;
6993
+ var _proxyAuthConfigRef$c, _clientParamsRef$curr;
6948
6994
  // Handle changes to the passed in config prop -- update the master config
6949
6995
  // Rebuild the master config with the updated config and stored proxyAuthConfig
6950
6996
  // If we don't have a stored proxyAuthConfig and we need to fetch it, we wait until that fetch is done in the other useEffect.
6951
6997
  // If shouldFetchWalletKitConfig is false, we'll never have a proxyAuthConfig to build the master config with, so this useEffect should always run.
6952
6998
  if (!proxyAuthConfigRef.current && shouldFetchWalletKitConfig) return;
6953
- setMasterConfig(buildConfig((_proxyAuthConfigRef$c = proxyAuthConfigRef.current) !== null && _proxyAuthConfigRef$c !== void 0 ? _proxyAuthConfigRef$c : undefined));
6999
+ setMasterConfig(buildConfig((_proxyAuthConfigRef$c = proxyAuthConfigRef.current) !== null && _proxyAuthConfigRef$c !== void 0 ? _proxyAuthConfigRef$c : undefined, (_clientParamsRef$curr = clientParamsRef.current) !== null && _clientParamsRef$curr !== void 0 ? _clientParamsRef$curr : undefined));
6954
7000
  }, [config, proxyAuthConfigRef.current]);
6955
7001
  /**
6956
7002
  * @internal
@@ -7035,7 +7081,7 @@ var ClientProvider = function ClientProvider(_ref) {
7035
7081
  clearSessionTimeouts();
7036
7082
  };
7037
7083
  }, [client]);
7038
- return jsx(ClientContext.Provider, {
7084
+ return jsxs(ClientContext.Provider, {
7039
7085
  value: {
7040
7086
  session: session,
7041
7087
  allSessions: allSessions,
@@ -7143,9 +7189,26 @@ var ClientProvider = function ClientProvider(_ref) {
7143
7189
  handleVerifyAppProofs: handleVerifyAppProofs,
7144
7190
  handleOnRamp: handleOnRamp,
7145
7191
  handleSendTransaction: handleSendTransaction,
7146
- handleSendErc20Transfer: handleSendErc20Transfer
7192
+ handleSendErc20Transfer: handleSendErc20Transfer,
7193
+ getTurnstileToken: getTurnstileToken,
7194
+ setTurnstileToken: setTurnstileToken
7147
7195
  },
7148
- children: children
7196
+ children: [(masterConfig === null || masterConfig === void 0 ? void 0 : masterConfig.turnstileSiteKey) && authState !== AuthState.Authenticated && !getTurnstileToken() && jsx(Turnstile, {
7197
+ siteKey: masterConfig.turnstileSiteKey,
7198
+ onSuccess: function onSuccess(token) {
7199
+ setTurnstileToken(token);
7200
+ },
7201
+ onError: function onError() {
7202
+ setTurnstileToken(null);
7203
+ },
7204
+ onExpire: function onExpire() {
7205
+ setTurnstileToken(null);
7206
+ },
7207
+ options: {
7208
+ size: "invisible",
7209
+ appearance: "execute"
7210
+ }
7211
+ }), children]
7149
7212
  });
7150
7213
  };
7151
7214