@turnkey/react-wallet-kit 2.1.1 → 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.
- package/dist/components/auth/Email.d.ts +1 -0
- package/dist/components/auth/Email.d.ts.map +1 -1
- package/dist/components/auth/Email.js +1 -1
- package/dist/components/auth/Email.js.map +1 -1
- package/dist/components/auth/Email.mjs +2 -2
- package/dist/components/auth/Email.mjs.map +1 -1
- package/dist/components/auth/OAuth.d.ts +1 -0
- package/dist/components/auth/OAuth.d.ts.map +1 -1
- package/dist/components/auth/OAuth.js +3 -1
- package/dist/components/auth/OAuth.js.map +1 -1
- package/dist/components/auth/OAuth.mjs +3 -1
- package/dist/components/auth/OAuth.mjs.map +1 -1
- package/dist/components/auth/OTP.d.ts.map +1 -1
- package/dist/components/auth/OTP.js +22 -6
- package/dist/components/auth/OTP.js.map +1 -1
- package/dist/components/auth/OTP.mjs +37 -17
- package/dist/components/auth/OTP.mjs.map +1 -1
- package/dist/components/auth/Passkey.d.ts +1 -0
- package/dist/components/auth/Passkey.d.ts.map +1 -1
- package/dist/components/auth/Passkey.js +2 -0
- package/dist/components/auth/Passkey.js.map +1 -1
- package/dist/components/auth/Passkey.mjs +3 -0
- package/dist/components/auth/Passkey.mjs.map +1 -1
- package/dist/components/auth/Phone.d.ts +1 -0
- package/dist/components/auth/Phone.d.ts.map +1 -1
- package/dist/components/auth/Phone.js +1 -1
- package/dist/components/auth/Phone.js.map +1 -1
- package/dist/components/auth/Phone.mjs +2 -2
- package/dist/components/auth/Phone.mjs.map +1 -1
- package/dist/components/auth/Turnstile.d.ts +10 -0
- package/dist/components/auth/Turnstile.d.ts.map +1 -0
- package/dist/components/auth/Turnstile.js +13 -0
- package/dist/components/auth/Turnstile.js.map +1 -0
- package/dist/components/auth/Turnstile.mjs +11 -0
- package/dist/components/auth/Turnstile.mjs.map +1 -0
- package/dist/components/auth/TurnstileWidget.d.ts +26 -0
- package/dist/components/auth/TurnstileWidget.d.ts.map +1 -0
- package/dist/components/auth/TurnstileWidget.js +113 -0
- package/dist/components/auth/TurnstileWidget.js.map +1 -0
- package/dist/components/auth/TurnstileWidget.mjs +146 -0
- package/dist/components/auth/TurnstileWidget.mjs.map +1 -0
- package/dist/components/auth/index.d.ts.map +1 -1
- package/dist/components/auth/index.js +52 -23
- package/dist/components/auth/index.js.map +1 -1
- package/dist/components/auth/index.mjs +238 -114
- package/dist/components/auth/index.mjs.map +1 -1
- package/dist/components/auth/wallet/WalletAuthButton.d.ts +1 -0
- package/dist/components/auth/wallet/WalletAuthButton.d.ts.map +1 -1
- package/dist/components/auth/wallet/WalletAuthButton.js +1 -0
- package/dist/components/auth/wallet/WalletAuthButton.js.map +1 -1
- package/dist/components/auth/wallet/WalletAuthButton.mjs +2 -0
- package/dist/components/auth/wallet/WalletAuthButton.mjs.map +1 -1
- package/dist/providers/client/Provider.d.ts.map +1 -1
- package/dist/providers/client/Provider.js +151 -40
- package/dist/providers/client/Provider.js.map +1 -1
- package/dist/providers/client/Provider.mjs +173 -85
- package/dist/providers/client/Provider.mjs.map +1 -1
- package/dist/providers/client/Types.d.ts +4 -0
- package/dist/providers/client/Types.d.ts.map +1 -1
- package/dist/providers/client/Types.js.map +1 -1
- package/dist/providers/client/Types.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tests/captcha-test.d.ts +2 -0
- package/dist/tests/captcha-test.d.ts.map +1 -0
- package/dist/types/base.d.ts +2 -0
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/base.js.map +1 -1
- package/dist/types/base.mjs.map +1 -1
- package/dist/types/method-types.d.ts +5 -0
- package/dist/types/method-types.d.ts.map +1 -1
- package/dist/utils/captcha.d.ts +16 -0
- package/dist/utils/captcha.d.ts.map +1 -0
- package/dist/utils/captcha.js +47 -0
- package/dist/utils/captcha.js.map +1 -0
- package/dist/utils/captcha.mjs +64 -0
- package/dist/utils/captcha.mjs.map +1 -0
- package/dist/utils/oauth/completion.d.ts +10 -1
- package/dist/utils/oauth/completion.d.ts.map +1 -1
- package/dist/utils/oauth/completion.js +9 -0
- package/dist/utils/oauth/completion.js.map +1 -1
- package/dist/utils/oauth/completion.mjs +12 -7
- package/dist/utils/oauth/completion.mjs.map +1 -1
- package/dist/utils/oauth/storage.d.ts +10 -0
- package/dist/utils/oauth/storage.d.ts.map +1 -1
- package/dist/utils/oauth/storage.js +20 -0
- package/dist/utils/oauth/storage.js.map +1 -1
- package/dist/utils/oauth/storage.mjs +18 -1
- package/dist/utils/oauth/storage.mjs.map +1 -1
- package/dist/utils/oauth/url.d.ts +2 -0
- package/dist/utils/oauth/url.d.ts.map +1 -1
- package/dist/utils/oauth/url.js +2 -1
- package/dist/utils/oauth/url.js.map +1 -1
- package/dist/utils/oauth/url.mjs +3 -2
- package/dist/utils/oauth/url.mjs.map +1 -1
- 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
|
/**
|
|
@@ -941,7 +954,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
941
954
|
var walletEvents = provider === null || provider === void 0 ? void 0 : (_provider$features = provider.features) === null || _provider$features === void 0 ? void 0 : _provider$features["standard:events"];
|
|
942
955
|
if (walletEvents !== null && walletEvents !== void 0 && walletEvents.on) {
|
|
943
956
|
var offChange = walletEvents.on("change", /*#__PURE__*/function () {
|
|
944
|
-
var
|
|
957
|
+
var _ref166 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(_evt) {
|
|
945
958
|
return _regenerator().w(function (_context140) {
|
|
946
959
|
while (1) switch (_context140.n) {
|
|
947
960
|
case 0:
|
|
@@ -953,7 +966,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
953
966
|
}, _callee140);
|
|
954
967
|
}));
|
|
955
968
|
return function (_x118) {
|
|
956
|
-
return
|
|
969
|
+
return _ref166.apply(this, arguments);
|
|
957
970
|
};
|
|
958
971
|
}());
|
|
959
972
|
cleanups.push(offChange);
|
|
@@ -967,7 +980,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
967
980
|
attachEthereumListeners = function _attachEthereumListen(provider, onUpdateState) {
|
|
968
981
|
if (typeof provider.on !== "function") return;
|
|
969
982
|
var handleChainChanged = /*#__PURE__*/function () {
|
|
970
|
-
var
|
|
983
|
+
var _ref164 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(_chainId) {
|
|
971
984
|
return _regenerator().w(function (_context138) {
|
|
972
985
|
while (1) switch (_context138.n) {
|
|
973
986
|
case 0:
|
|
@@ -976,11 +989,11 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
976
989
|
}, _callee138);
|
|
977
990
|
}));
|
|
978
991
|
return function handleChainChanged(_x116) {
|
|
979
|
-
return
|
|
992
|
+
return _ref164.apply(this, arguments);
|
|
980
993
|
};
|
|
981
994
|
}();
|
|
982
995
|
var handleAccountsChanged = /*#__PURE__*/function () {
|
|
983
|
-
var
|
|
996
|
+
var _ref165 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(accounts) {
|
|
984
997
|
return _regenerator().w(function (_context139) {
|
|
985
998
|
while (1) switch (_context139.n) {
|
|
986
999
|
case 0:
|
|
@@ -991,7 +1004,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
991
1004
|
}, _callee139);
|
|
992
1005
|
}));
|
|
993
1006
|
return function handleAccountsChanged(_x117) {
|
|
994
|
-
return
|
|
1007
|
+
return _ref165.apply(this, arguments);
|
|
995
1008
|
};
|
|
996
1009
|
}();
|
|
997
1010
|
var handleDisconnect = function handleDisconnect() {
|
|
@@ -1048,7 +1061,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
1048
1061
|
if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
|
|
1049
1062
|
if (standardEvents !== null && standardEvents !== void 0 && standardEvents.on) {
|
|
1050
1063
|
unsubscribe = standardEvents.on("change", /*#__PURE__*/function () {
|
|
1051
|
-
var
|
|
1064
|
+
var _ref167 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(evt) {
|
|
1052
1065
|
var _callbacks$onError10, providers, currentSession, _wcProviders, wcWallets;
|
|
1053
1066
|
return _regenerator().w(function (_context141) {
|
|
1054
1067
|
while (1) switch (_context141.n) {
|
|
@@ -1110,7 +1123,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
1110
1123
|
}, _callee141);
|
|
1111
1124
|
}));
|
|
1112
1125
|
return function (_x119) {
|
|
1113
|
-
return
|
|
1126
|
+
return _ref167.apply(this, arguments);
|
|
1114
1127
|
};
|
|
1115
1128
|
}());
|
|
1116
1129
|
cleanups.push(unsubscribe);
|
|
@@ -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)); //
|
|
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)); //
|
|
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) {
|
|
@@ -6369,7 +6407,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6369
6407
|
return _context129.a(2, new Promise(function (resolve, reject) {
|
|
6370
6408
|
var action = /*#__PURE__*/function () {
|
|
6371
6409
|
var _ref151 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128() {
|
|
6372
|
-
var
|
|
6410
|
+
var _ref154, _txDetails$eth$txHash, _txDetails$eth, _txDetails$solana;
|
|
6373
6411
|
var sendTransactionStatusId, pollResult, txDetails, txHash, _t28;
|
|
6374
6412
|
return _regenerator().w(function (_context128) {
|
|
6375
6413
|
while (1) switch (_context128.n) {
|
|
@@ -6391,22 +6429,20 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6391
6429
|
case 2:
|
|
6392
6430
|
_context128.n = 3;
|
|
6393
6431
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127() {
|
|
6394
|
-
var
|
|
6432
|
+
var ethTx, cleanData, from, sponsor, nonce, gasLimit, maxFeePerGas, maxPriorityFeePerGas, commonFields, tx, cleanedData;
|
|
6395
6433
|
return _regenerator().w(function (_context127) {
|
|
6396
6434
|
while (1) switch (_context127.n) {
|
|
6397
6435
|
case 0:
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6436
|
+
ethTx = transaction; // Drop empty/no-op calldata ("0x" or "") so it isn't sent.
|
|
6437
|
+
cleanData = function cleanData(data) {
|
|
6438
|
+
return data && data !== "0x" && data !== "" ? data : undefined;
|
|
6439
|
+
}; // Shared fee/nonce fields, present on both the V1 and V2 intents.
|
|
6440
|
+
from = ethTx.from, sponsor = ethTx.sponsor, nonce = ethTx.nonce, gasLimit = ethTx.gasLimit, maxFeePerGas = ethTx.maxFeePerGas, maxPriorityFeePerGas = ethTx.maxPriorityFeePerGas;
|
|
6441
|
+
commonFields = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
6401
6442
|
from: from,
|
|
6402
|
-
|
|
6403
|
-
caip2: caip2,
|
|
6443
|
+
caip2: ethTx.caip2,
|
|
6404
6444
|
sponsor: sponsor !== null && sponsor !== void 0 ? sponsor : false
|
|
6405
|
-
},
|
|
6406
|
-
value: value
|
|
6407
|
-
} : {}), cleanedData ? {
|
|
6408
|
-
data: cleanedData
|
|
6409
|
-
} : {}), nonce ? {
|
|
6445
|
+
}, nonce ? {
|
|
6410
6446
|
nonce: nonce
|
|
6411
6447
|
} : {}), gasLimit ? {
|
|
6412
6448
|
gasLimit: gasLimit
|
|
@@ -6414,7 +6450,34 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6414
6450
|
maxFeePerGas: maxFeePerGas
|
|
6415
6451
|
} : {}), maxPriorityFeePerGas ? {
|
|
6416
6452
|
maxPriorityFeePerGas: maxPriorityFeePerGas
|
|
6417
|
-
} : {});
|
|
6453
|
+
} : {}); // V2 multi-call intent vs. legacy single-call (V1) intent.
|
|
6454
|
+
// TODO (breaking change): eventually, we wont generate the v1 activity at all, remove this check and update the intent.
|
|
6455
|
+
if ("calls" in ethTx) {
|
|
6456
|
+
tx = _objectSpread2(_objectSpread2({}, commonFields), {}, {
|
|
6457
|
+
calls: ethTx.calls.map(function (_ref153) {
|
|
6458
|
+
var to = _ref153.to,
|
|
6459
|
+
value = _ref153.value,
|
|
6460
|
+
data = _ref153.data;
|
|
6461
|
+
var cleanedData = cleanData(data);
|
|
6462
|
+
return _objectSpread2(_objectSpread2({
|
|
6463
|
+
to: to
|
|
6464
|
+
}, value ? {
|
|
6465
|
+
value: value
|
|
6466
|
+
} : {}), cleanedData ? {
|
|
6467
|
+
data: cleanedData
|
|
6468
|
+
} : {});
|
|
6469
|
+
})
|
|
6470
|
+
});
|
|
6471
|
+
} else {
|
|
6472
|
+
cleanedData = cleanData(ethTx.data);
|
|
6473
|
+
tx = _objectSpread2(_objectSpread2(_objectSpread2({}, commonFields), {}, {
|
|
6474
|
+
to: ethTx.to
|
|
6475
|
+
}, ethTx.value ? {
|
|
6476
|
+
value: ethTx.value
|
|
6477
|
+
} : {}), cleanedData ? {
|
|
6478
|
+
data: cleanedData
|
|
6479
|
+
} : {});
|
|
6480
|
+
}
|
|
6418
6481
|
return _context127.a(2, ethSendTransaction({
|
|
6419
6482
|
organizationId: organizationId,
|
|
6420
6483
|
transaction: tx,
|
|
@@ -6441,7 +6504,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6441
6504
|
case 6:
|
|
6442
6505
|
pollResult = _context128.v;
|
|
6443
6506
|
txDetails = pollResult;
|
|
6444
|
-
txHash = (
|
|
6507
|
+
txHash = (_ref154 = (_txDetails$eth$txHash = (_txDetails$eth = txDetails.eth) === null || _txDetails$eth === void 0 ? void 0 : _txDetails$eth.txHash) !== null && _txDetails$eth$txHash !== void 0 ? _txDetails$eth$txHash : (_txDetails$solana = txDetails.solana) === null || _txDetails$solana === void 0 ? void 0 : _txDetails$solana.signature) !== null && _ref154 !== void 0 ? _ref154 : txDetails.txHash;
|
|
6445
6508
|
return _context128.a(2, txHash ? {
|
|
6446
6509
|
txHash: txHash
|
|
6447
6510
|
} : {});
|
|
@@ -6481,7 +6544,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6481
6544
|
};
|
|
6482
6545
|
}(), [ethSendTransaction, getSession, pollTransactionStatus, pushPage, solSendTransaction]);
|
|
6483
6546
|
var handleSendErc20Transfer = useCallback(/*#__PURE__*/function () {
|
|
6484
|
-
var
|
|
6547
|
+
var _ref155 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(params) {
|
|
6485
6548
|
var session, organizationId, transfer, icon, stampWith, _params$successPageDu6, successPageDuration, caip2;
|
|
6486
6549
|
return _regenerator().w(function (_context131) {
|
|
6487
6550
|
while (1) switch (_context131.n) {
|
|
@@ -6501,7 +6564,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6501
6564
|
caip2 = transfer.caip2;
|
|
6502
6565
|
return _context131.a(2, new Promise(function (resolve, reject) {
|
|
6503
6566
|
var action = /*#__PURE__*/function () {
|
|
6504
|
-
var
|
|
6567
|
+
var _ref156 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130() {
|
|
6505
6568
|
var _pollResult$eth$txHas, _pollResult$eth;
|
|
6506
6569
|
var sendTransactionStatusId, pollResult, txHash;
|
|
6507
6570
|
return _regenerator().w(function (_context130) {
|
|
@@ -6536,7 +6599,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6536
6599
|
}, _callee130);
|
|
6537
6600
|
}));
|
|
6538
6601
|
return function action() {
|
|
6539
|
-
return
|
|
6602
|
+
return _ref156.apply(this, arguments);
|
|
6540
6603
|
};
|
|
6541
6604
|
}();
|
|
6542
6605
|
pushPage({
|
|
@@ -6564,11 +6627,11 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6564
6627
|
}, _callee131);
|
|
6565
6628
|
}));
|
|
6566
6629
|
return function (_x113) {
|
|
6567
|
-
return
|
|
6630
|
+
return _ref155.apply(this, arguments);
|
|
6568
6631
|
};
|
|
6569
6632
|
}(), [ethSendErc20Transfer, getSession, pollTransactionStatus, pushPage]);
|
|
6570
6633
|
var handleOnRamp = useCallback(/*#__PURE__*/function () {
|
|
6571
|
-
var
|
|
6634
|
+
var _ref157 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(params) {
|
|
6572
6635
|
var _walletAccount$addres;
|
|
6573
6636
|
var walletAccount, fiatCurrencyAmount, fiatCurrencyCode, paymentMethod, countrySubdivisionCode, urlForSignature, countryCode, _params$onrampProvide, onrampProvider, _params$sandboxMode, sandboxMode, _params$successPageDu7, successPageDuration, _params$openInNewTab, openInNewTab, s, organizationId, cryptoCurrencyCode, network, openNewTab, _t31;
|
|
6574
6637
|
return _regenerator().w(function (_context134) {
|
|
@@ -6628,7 +6691,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6628
6691
|
};
|
|
6629
6692
|
}, []);
|
|
6630
6693
|
var action = /*#__PURE__*/function () {
|
|
6631
|
-
var
|
|
6694
|
+
var _ref158 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133() {
|
|
6632
6695
|
var _client$httpClient, onRampWindow, result, popupWidth, popupHeight, left, top, onRampTransactionId, _t30;
|
|
6633
6696
|
return _regenerator().w(function (_context133) {
|
|
6634
6697
|
while (1) switch (_context133.p = _context133.n) {
|
|
@@ -6771,7 +6834,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6771
6834
|
}, _callee133, null, [[0, 7]]);
|
|
6772
6835
|
}));
|
|
6773
6836
|
return function action() {
|
|
6774
|
-
return
|
|
6837
|
+
return _ref158.apply(this, arguments);
|
|
6775
6838
|
};
|
|
6776
6839
|
}();
|
|
6777
6840
|
return jsx(OnRampPage, {
|
|
@@ -6807,16 +6870,16 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6807
6870
|
}, _callee134);
|
|
6808
6871
|
}));
|
|
6809
6872
|
return function (_x114) {
|
|
6810
|
-
return
|
|
6873
|
+
return _ref157.apply(this, arguments);
|
|
6811
6874
|
};
|
|
6812
6875
|
}(), [getSession, client, pushPage]);
|
|
6813
6876
|
var handleVerifyAppProofs = useCallback(/*#__PURE__*/function () {
|
|
6814
|
-
var
|
|
6815
|
-
var
|
|
6877
|
+
var _ref160 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(params) {
|
|
6878
|
+
var _ref161, appProofs, _ref161$successPageDu, successPageDuration, stampWith, s, organizationId, _t32;
|
|
6816
6879
|
return _regenerator().w(function (_context135) {
|
|
6817
6880
|
while (1) switch (_context135.p = _context135.n) {
|
|
6818
6881
|
case 0:
|
|
6819
|
-
|
|
6882
|
+
_ref161 = params || {}, appProofs = _ref161.appProofs, _ref161$successPageDu = _ref161.successPageDuration, successPageDuration = _ref161$successPageDu === void 0 ? 3000 : _ref161$successPageDu, stampWith = _ref161.stampWith;
|
|
6820
6883
|
_context135.n = 1;
|
|
6821
6884
|
return getSession();
|
|
6822
6885
|
case 1:
|
|
@@ -6870,45 +6933,53 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6870
6933
|
}, _callee135, null, [[2, 3]]);
|
|
6871
6934
|
}));
|
|
6872
6935
|
return function (_x115) {
|
|
6873
|
-
return
|
|
6936
|
+
return _ref160.apply(this, arguments);
|
|
6874
6937
|
};
|
|
6875
6938
|
}(), [getSession, pushPage]);
|
|
6876
6939
|
useEffect(function () {
|
|
6877
6940
|
if (proxyAuthConfigRef.current) return;
|
|
6878
|
-
//
|
|
6941
|
+
// Fetch proxy auth config and client params once. Use both to build the master config.
|
|
6879
6942
|
var fetchProxyAuthConfig = /*#__PURE__*/function () {
|
|
6880
|
-
var
|
|
6881
|
-
var proxyAuthConfig;
|
|
6943
|
+
var _ref162 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136() {
|
|
6944
|
+
var proxyAuthConfig, clientParams, promises;
|
|
6882
6945
|
return _regenerator().w(function (_context136) {
|
|
6883
6946
|
while (1) switch (_context136.p = _context136.n) {
|
|
6884
6947
|
case 0:
|
|
6885
6948
|
_context136.p = 0;
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
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
|
+
}));
|
|
6889
6959
|
}
|
|
6890
6960
|
_context136.n = 1;
|
|
6891
|
-
return
|
|
6892
|
-
// Can assert safely. See shouldFetchWalletKitConfig definition.
|
|
6893
|
-
config.authProxyUrl);
|
|
6961
|
+
return Promise.all(promises);
|
|
6894
6962
|
case 1:
|
|
6895
|
-
proxyAuthConfig
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
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;
|
|
6900
6971
|
break;
|
|
6901
|
-
case
|
|
6902
|
-
_context136.p =
|
|
6972
|
+
case 2:
|
|
6973
|
+
_context136.p = 2;
|
|
6903
6974
|
_context136.v;
|
|
6904
6975
|
setClientState(ClientState.Error);
|
|
6905
|
-
case
|
|
6976
|
+
case 3:
|
|
6906
6977
|
return _context136.a(2);
|
|
6907
6978
|
}
|
|
6908
|
-
}, _callee136, null, [[0,
|
|
6979
|
+
}, _callee136, null, [[0, 2]]);
|
|
6909
6980
|
}));
|
|
6910
6981
|
return function fetchProxyAuthConfig() {
|
|
6911
|
-
return
|
|
6982
|
+
return _ref162.apply(this, arguments);
|
|
6912
6983
|
};
|
|
6913
6984
|
}();
|
|
6914
6985
|
fetchProxyAuthConfig();
|
|
@@ -6919,13 +6990,13 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6919
6990
|
initializeClient();
|
|
6920
6991
|
}, [masterConfig]);
|
|
6921
6992
|
useEffect(function () {
|
|
6922
|
-
var _proxyAuthConfigRef$c;
|
|
6993
|
+
var _proxyAuthConfigRef$c, _clientParamsRef$curr;
|
|
6923
6994
|
// Handle changes to the passed in config prop -- update the master config
|
|
6924
6995
|
// Rebuild the master config with the updated config and stored proxyAuthConfig
|
|
6925
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.
|
|
6926
6997
|
// If shouldFetchWalletKitConfig is false, we'll never have a proxyAuthConfig to build the master config with, so this useEffect should always run.
|
|
6927
6998
|
if (!proxyAuthConfigRef.current && shouldFetchWalletKitConfig) return;
|
|
6928
|
-
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));
|
|
6929
7000
|
}, [config, proxyAuthConfigRef.current]);
|
|
6930
7001
|
/**
|
|
6931
7002
|
* @internal
|
|
@@ -6941,7 +7012,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6941
7012
|
var debouncedFetchWalletProviders = useDebouncedCallback(fetchWalletProviders, 100);
|
|
6942
7013
|
useEffect(function () {
|
|
6943
7014
|
var handleUpdateState = /*#__PURE__*/function () {
|
|
6944
|
-
var
|
|
7015
|
+
var _ref163 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137() {
|
|
6945
7016
|
var currentSession;
|
|
6946
7017
|
return _regenerator().w(function (_context137) {
|
|
6947
7018
|
while (1) switch (_context137.n) {
|
|
@@ -6968,7 +7039,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
6968
7039
|
}, _callee137);
|
|
6969
7040
|
}));
|
|
6970
7041
|
return function handleUpdateState() {
|
|
6971
|
-
return
|
|
7042
|
+
return _ref163.apply(this, arguments);
|
|
6972
7043
|
};
|
|
6973
7044
|
}();
|
|
6974
7045
|
var cleanup = function cleanup() {};
|
|
@@ -7010,7 +7081,7 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
7010
7081
|
clearSessionTimeouts();
|
|
7011
7082
|
};
|
|
7012
7083
|
}, [client]);
|
|
7013
|
-
return
|
|
7084
|
+
return jsxs(ClientContext.Provider, {
|
|
7014
7085
|
value: {
|
|
7015
7086
|
session: session,
|
|
7016
7087
|
allSessions: allSessions,
|
|
@@ -7118,9 +7189,26 @@ var ClientProvider = function ClientProvider(_ref) {
|
|
|
7118
7189
|
handleVerifyAppProofs: handleVerifyAppProofs,
|
|
7119
7190
|
handleOnRamp: handleOnRamp,
|
|
7120
7191
|
handleSendTransaction: handleSendTransaction,
|
|
7121
|
-
handleSendErc20Transfer: handleSendErc20Transfer
|
|
7192
|
+
handleSendErc20Transfer: handleSendErc20Transfer,
|
|
7193
|
+
getTurnstileToken: getTurnstileToken,
|
|
7194
|
+
setTurnstileToken: setTurnstileToken
|
|
7122
7195
|
},
|
|
7123
|
-
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]
|
|
7124
7212
|
});
|
|
7125
7213
|
};
|
|
7126
7214
|
|