@dynamic-labs/sdk-react-core 1.1.0-alpha.20 → 1.1.0-alpha.22
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/CHANGELOG.md +21 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -2
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -2
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +2 -53
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +2 -53
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.cjs +40 -0
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.d.ts +10 -0
- package/src/lib/context/PhantomRedirectContext/PhantomRedirectContext.js +35 -0
- package/src/lib/context/PhantomRedirectContext/index.d.ts +1 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +124 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.d.ts +5 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +120 -0
- package/src/lib/shared/types/index.d.ts +2 -0
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.cjs +18 -1
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.d.ts +10 -6
- package/src/lib/utils/functions/getVerifyArgs/getVerifyArgs.js +18 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +9 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +9 -3
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.cjs +2 -1
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.d.ts +2 -1
- package/src/lib/utils/hooks/useWalletConnectorOptions/useWalletConnectorOptions.js +2 -1
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +4 -4
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +4 -4
- package/src/lib/utils/functions/isPasskeyEnabled/isPasskeyEnabled.cjs +0 -22
- package/src/lib/utils/functions/isPasskeyEnabled/isPasskeyEnabled.js +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
|
|
2
|
+
## [1.1.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.21...v1.1.0-alpha.22) (2024-02-01)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* onAuthFlowClose not being called ([#4563](https://github.com/dynamic-labs/DynamicAuth/issues/4563)) ([c4b2648](https://github.com/dynamic-labs/DynamicAuth/commit/c4b264885b7dba6e204ef49bf642d25c7d287b04))
|
|
8
|
+
|
|
9
|
+
## [1.1.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.20...v1.1.0-alpha.21) (2024-02-01)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add phantom redirect handling context ([#4479](https://github.com/dynamic-labs/DynamicAuth/issues/4479)) ([e0218ee](https://github.com/dynamic-labs/DynamicAuth/commit/e0218eec1a67787f5c0e7483d542a5f773e911ef))
|
|
15
|
+
* add signPsbt method to bitcoin wallet connectors ([dfdc0fe](https://github.com/dynamic-labs/DynamicAuth/commit/dfdc0fe0e6894c1307b286e89b43a4c58a8808f3))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* relax passkey feature detection check in sdk to avoid false nega… ([#4556](https://github.com/dynamic-labs/DynamicAuth/issues/4556)) ([4554f7d](https://github.com/dynamic-labs/DynamicAuth/commit/4554f7d7c5339859481cdecca95a9c07fae4ba5c))
|
|
21
|
+
* workaround braavos undefined selectedWallet on chainChange event ([#4552](https://github.com/dynamic-labs/DynamicAuth/issues/4552)) ([aa35df0](https://github.com/dynamic-labs/DynamicAuth/commit/aa35df0e894feafa0606aa1c87bd3d3879ebc594))
|
|
22
|
+
|
|
2
23
|
## [1.1.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.19...v1.1.0-alpha.20) (2024-01-31)
|
|
3
24
|
|
|
4
25
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.22",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"react-focus-lock": "2.9.2",
|
|
18
18
|
"react-i18next": "^13.2.0",
|
|
19
19
|
"yup": "0.32.11",
|
|
20
|
-
"@dynamic-labs/ethereum": "1.1.0-alpha.
|
|
21
|
-
"@dynamic-labs/logger": "1.1.0-alpha.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "1.1.0-alpha.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "1.1.0-alpha.
|
|
24
|
-
"@dynamic-labs/types": "1.1.0-alpha.
|
|
25
|
-
"@dynamic-labs/utils": "1.1.0-alpha.
|
|
26
|
-
"@dynamic-labs/viem-utils": "1.1.0-alpha.
|
|
27
|
-
"@dynamic-labs/wallet-book": "1.1.0-alpha.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "1.1.0-alpha.
|
|
20
|
+
"@dynamic-labs/ethereum": "1.1.0-alpha.22",
|
|
21
|
+
"@dynamic-labs/logger": "1.1.0-alpha.22",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "1.1.0-alpha.22",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "1.1.0-alpha.22",
|
|
24
|
+
"@dynamic-labs/types": "1.1.0-alpha.22",
|
|
25
|
+
"@dynamic-labs/utils": "1.1.0-alpha.22",
|
|
26
|
+
"@dynamic-labs/viem-utils": "1.1.0-alpha.22",
|
|
27
|
+
"@dynamic-labs/wallet-book": "1.1.0-alpha.22",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "1.1.0-alpha.22",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -102,6 +102,7 @@ var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs')
|
|
|
102
102
|
var UseNetworkValidation = require('../UseNetworkValidation/UseNetworkValidation.cjs');
|
|
103
103
|
var UserWalletsContext = require('../UserWalletsContext/UserWalletsContext.cjs');
|
|
104
104
|
var WalletContext = require('../WalletContext/WalletContext.cjs');
|
|
105
|
+
var PhantomRedirectContext = require('../PhantomRedirectContext/PhantomRedirectContext.cjs');
|
|
105
106
|
var handleDisconnectWallet = require('./handleDisconnectWallet/handleDisconnectWallet.cjs');
|
|
106
107
|
var helpers = require('./helpers/helpers.cjs');
|
|
107
108
|
var useDisplayOrderState = require('./hooks/useDisplayOrderState/useDisplayOrderState.cjs');
|
|
@@ -123,7 +124,7 @@ const DynamicContext = React.createContext(undefined);
|
|
|
123
124
|
/** The context provider itself we only use internally */
|
|
124
125
|
const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale$1, }) => {
|
|
125
126
|
var _a, _b, _c, _d, _e, _f;
|
|
126
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, enableConnectOnlyFallback = false, enableForcedNetworkValidation: enableForcedNetworkValidationProp = false, deepLinkPreference = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, } = settings;
|
|
127
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, enableConnectOnlyFallback = false, enableForcedNetworkValidation: enableForcedNetworkValidationProp = false, deepLinkPreference = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = values.DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, } = settings;
|
|
127
128
|
let enableForcedNetworkValidation = enableForcedNetworkValidationProp;
|
|
128
129
|
if (bridgeChains) {
|
|
129
130
|
enableForcedNetworkValidation = true;
|
|
@@ -196,6 +197,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
196
197
|
appName,
|
|
197
198
|
deepLinkPreference,
|
|
198
199
|
flowNetwork,
|
|
200
|
+
mobileExperience,
|
|
199
201
|
networkConfigurations: serverNetworkConfigurations,
|
|
200
202
|
projectSettings,
|
|
201
203
|
walletBook: walletBook$1,
|
|
@@ -695,7 +697,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale: locale
|
|
|
695
697
|
isBridgeFlow,
|
|
696
698
|
isFullyConnected,
|
|
697
699
|
isMultiWalletEnabled: multiWallet,
|
|
698
|
-
}), children: [enableForcedNetworkValidation && jsxRuntime.jsx(UseNetworkValidation.UseNetworkValidation, {}), jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, { canSync: didConnectedStateLoad, children: jsxRuntime.jsx(PasskeyContext.PasskeyContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsx(WalletGroupContext.WalletGroupContextProvider, { children: jsxRuntime.jsx(UserFieldEditorContext.UserFieldEditorContextProvider, { children: jsxRuntime.
|
|
700
|
+
}), children: [enableForcedNetworkValidation && jsxRuntime.jsx(UseNetworkValidation.UseNetworkValidation, {}), jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, { canSync: didConnectedStateLoad, children: jsxRuntime.jsx(PasskeyContext.PasskeyContextProvider, { children: jsxRuntime.jsx(EmailVerificationContext.EmailVerificationContextProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsx(WalletGroupContext.WalletGroupContextProvider, { children: jsxRuntime.jsx(UserFieldEditorContext.UserFieldEditorContextProvider, { children: jsxRuntime.jsx(ConnectWithEmailOtpProvider.ConnectWithEmailOtpProvider, { children: jsxRuntime.jsxs(PhantomRedirectContext.PhantomRedirectContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), jsxRuntime.jsx(SyncPasskeyFlow.SyncPasskeyFlow, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
699
701
|
};
|
|
700
702
|
/** The context provider you need to have access too all of Dynamic's hooks */
|
|
701
703
|
const DynamicContextProvider = (props) => (jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(UserWalletsContext.UserWalletsProvider, { children: jsxRuntime.jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }));
|
|
@@ -50,6 +50,7 @@ export interface DynamicContextProps {
|
|
|
50
50
|
*/
|
|
51
51
|
logLevel?: keyof typeof LogLevel;
|
|
52
52
|
showLockedWalletView?: boolean;
|
|
53
|
+
mobileExperience?: 'in-app-browser' | 'redirect';
|
|
53
54
|
newToWeb3WalletChainMap?: ChainToWalletMap;
|
|
54
55
|
notInTheListImageUrl?: string;
|
|
55
56
|
onboardingImageUrl?: string;
|
|
@@ -98,6 +98,7 @@ import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceCon
|
|
|
98
98
|
import { UseNetworkValidation } from '../UseNetworkValidation/UseNetworkValidation.js';
|
|
99
99
|
import { UserWalletsProvider } from '../UserWalletsContext/UserWalletsContext.js';
|
|
100
100
|
import { WalletContextProvider } from '../WalletContext/WalletContext.js';
|
|
101
|
+
import { PhantomRedirectContextProvider } from '../PhantomRedirectContext/PhantomRedirectContext.js';
|
|
101
102
|
import { handleDisconnectWallet } from './handleDisconnectWallet/handleDisconnectWallet.js';
|
|
102
103
|
import { initExpirationTime, getInitialView } from './helpers/helpers.js';
|
|
103
104
|
import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
|
|
@@ -119,7 +120,7 @@ const DynamicContext = createContext(undefined);
|
|
|
119
120
|
/** The context provider itself we only use internally */
|
|
120
121
|
const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) => {
|
|
121
122
|
var _a, _b, _c, _d, _e, _f;
|
|
122
|
-
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, enableConnectOnlyFallback = false, enableForcedNetworkValidation: enableForcedNetworkValidationProp = false, deepLinkPreference = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, } = settings;
|
|
123
|
+
const { accessDeniedMessagePrimary, accessDeniedMessageSecondary, accessDeniedButton, apiBaseUrl, enableConnectOnlyFallback = false, enableForcedNetworkValidation: enableForcedNetworkValidationProp = false, deepLinkPreference = 'native', bridgeChains, cssOverrides, defaultNumberOfWalletsToShow = DEFAULT_NUMBER_OF_WALLETS_TO_SHOW, flowNetwork, initialAuthenticationMode = 'connect-and-sign', debugError = false, displaySiweStatement = true, newToWeb3WalletChainMap, enableVisitTrackingOnConnectOnly = true, environmentId, localStorageSuffix, eventsCallbacks, evmNetworks, walletsFilter, logLevel = 'WARN', mobileExperience = 'in-app-browser', notInTheListImageUrl, onboardingImageUrl, policiesConsentInnerComponent, customPrivacyPolicy, privacyPolicyUrl, signWithEmailWalletName, socialMediaLinkText, socialMediaIconUrl, socialMediaUrl, customTermsOfServices, termsOfServiceUrl, toolkitEnabled, siweStatement, shadowDOMEnabled = true, walletConnectors: walletConnectorsProp, socialProvidersFilter, showLockedWalletView = false, walletConnectPreferredChains, walletConnectorExtensions, } = settings;
|
|
123
124
|
let enableForcedNetworkValidation = enableForcedNetworkValidationProp;
|
|
124
125
|
if (bridgeChains) {
|
|
125
126
|
enableForcedNetworkValidation = true;
|
|
@@ -192,6 +193,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
192
193
|
appName,
|
|
193
194
|
deepLinkPreference,
|
|
194
195
|
flowNetwork,
|
|
196
|
+
mobileExperience,
|
|
195
197
|
networkConfigurations: serverNetworkConfigurations,
|
|
196
198
|
projectSettings,
|
|
197
199
|
walletBook,
|
|
@@ -691,7 +693,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
691
693
|
isBridgeFlow,
|
|
692
694
|
isFullyConnected,
|
|
693
695
|
isMultiWalletEnabled: multiWallet,
|
|
694
|
-
}), children: [enableForcedNetworkValidation && jsx(UseNetworkValidation, {}), jsx(CaptchaContextProvider, { children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, { canSync: didConnectedStateLoad, children: jsx(PasskeyContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsx(WalletGroupContextProvider, { children: jsx(UserFieldEditorContextProvider, { children:
|
|
696
|
+
}), children: [enableForcedNetworkValidation && jsx(UseNetworkValidation, {}), jsx(CaptchaContextProvider, { children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, { canSync: didConnectedStateLoad, children: jsx(PasskeyContextProvider, { children: jsx(EmailVerificationContextProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsx(WalletGroupContextProvider, { children: jsx(UserFieldEditorContextProvider, { children: jsx(ConnectWithEmailOtpProvider, { children: jsxs(PhantomRedirectContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), jsx(SyncPasskeyFlow, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
695
697
|
};
|
|
696
698
|
/** The context provider you need to have access too all of Dynamic's hooks */
|
|
697
699
|
const DynamicContextProvider = (props) => (jsx(ErrorContextProvider, { children: jsx(UserWalletsProvider, { children: jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }));
|
|
@@ -17,56 +17,7 @@ require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
|
17
17
|
require('viem');
|
|
18
18
|
require('@dynamic-labs/utils');
|
|
19
19
|
require('../../../../shared/consts/index.cjs');
|
|
20
|
-
require('../../../../../../_virtual/_tslib.cjs');
|
|
21
|
-
require('../../DynamicContext.cjs');
|
|
22
|
-
require('../../../CaptchaContext/CaptchaContext.cjs');
|
|
23
20
|
var ErrorContext = require('../../../ErrorContext/ErrorContext.cjs');
|
|
24
|
-
require('@dynamic-labs/multi-wallet');
|
|
25
|
-
require('viem/chains');
|
|
26
|
-
require('../../../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
27
|
-
require('../../../AccountExistsContext/AccountExistsContext.cjs');
|
|
28
|
-
require('../../../../config/ApiEndpoint.cjs');
|
|
29
|
-
require('../../../EmailVerificationContext/EmailVerificationContext.cjs');
|
|
30
|
-
require('react-dom');
|
|
31
|
-
require('../../../ThemeContext/ThemeContext.cjs');
|
|
32
|
-
var usePrevious = require('../../../../utils/hooks/usePrevious/usePrevious.cjs');
|
|
33
|
-
require('@dynamic-labs/types');
|
|
34
|
-
require('yup');
|
|
35
|
-
require('react-i18next');
|
|
36
|
-
require('../../../MockContext/MockContext.cjs');
|
|
37
|
-
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
38
|
-
require('../../../UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
39
|
-
require('@dynamic-labs/rpc-providers');
|
|
40
|
-
require('../../../UserWalletsContext/UserWalletsContext.cjs');
|
|
41
|
-
require('../../../../components/Alert/Alert.cjs');
|
|
42
|
-
require('../../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
43
|
-
require('../../../../components/IconButton/IconButton.cjs');
|
|
44
|
-
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
45
|
-
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
46
|
-
require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
47
|
-
require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
48
|
-
require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
49
|
-
require('../../../../components/Popper/Popper/Popper.cjs');
|
|
50
|
-
require('../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
51
|
-
require('react-focus-lock');
|
|
52
|
-
require('formik');
|
|
53
|
-
require('i18next');
|
|
54
|
-
require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
55
|
-
require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
56
|
-
require('../../../../views/WalletList/WalletList.cjs');
|
|
57
|
-
require('qrcode');
|
|
58
|
-
require('@hcaptcha/react-hcaptcha');
|
|
59
|
-
require('../../../LoadingContext/LoadingContext.cjs');
|
|
60
|
-
require('../../../SocialRedirectContext/SocialRedirectContext.cjs');
|
|
61
|
-
require('../../../WalletGroupContext/WalletGroupContext.cjs');
|
|
62
|
-
require('../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
63
|
-
require('../../../FooterAnimationContext/index.cjs');
|
|
64
|
-
require('../../../PasskeyContext/PasskeyContext.cjs');
|
|
65
|
-
require('../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
66
|
-
require('../../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
67
|
-
require('../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
68
|
-
require('@dynamic-labs/viem-utils');
|
|
69
|
-
require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
70
21
|
|
|
71
22
|
/**
|
|
72
23
|
* There are a multitude of scenarios where we want to ignore or insert functionality to calls
|
|
@@ -76,15 +27,14 @@ require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/Passke
|
|
|
76
27
|
*/
|
|
77
28
|
const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMultiWalletEnabled, walletConnectorOptions, }) => {
|
|
78
29
|
const [showAuthFlow, _setShowAuthFlow] = React.useState(false);
|
|
79
|
-
const prevShowAuthFlow = usePrevious.usePrevious(showAuthFlow);
|
|
80
30
|
const { setError } = ErrorContext.useErrorContext();
|
|
81
31
|
const setShowAuthFlow = React.useCallback((value, options = {}) => {
|
|
82
32
|
var _a;
|
|
83
33
|
const { emitCancelAuth, ignoreIfIsEmbeddedWidget, initializeWalletConnect, performMultiWalletChecks, clearErrors, } = Object.assign({ clearErrors: true, emitCancelAuth: false, ignoreIfIsEmbeddedWidget: true, initializeWalletConnect: true, performMultiWalletChecks: false }, options);
|
|
84
|
-
if (!
|
|
34
|
+
if (!showAuthFlow && value) {
|
|
85
35
|
dynamicEvents.dynamicEvents.emit('authFlowOpen');
|
|
86
36
|
}
|
|
87
|
-
else if (
|
|
37
|
+
else if (showAuthFlow && !value) {
|
|
88
38
|
dynamicEvents.dynamicEvents.emit('authFlowClose');
|
|
89
39
|
}
|
|
90
40
|
if (value) {
|
|
@@ -114,7 +64,6 @@ const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMulti
|
|
|
114
64
|
setError,
|
|
115
65
|
showAuthFlow,
|
|
116
66
|
walletConnectorOptions,
|
|
117
|
-
prevShowAuthFlow,
|
|
118
67
|
]);
|
|
119
68
|
return [showAuthFlow, setShowAuthFlow];
|
|
120
69
|
};
|
|
@@ -13,56 +13,7 @@ import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
|
13
13
|
import 'viem';
|
|
14
14
|
import '@dynamic-labs/utils';
|
|
15
15
|
import '../../../../shared/consts/index.js';
|
|
16
|
-
import '../../../../../../_virtual/_tslib.js';
|
|
17
|
-
import '../../DynamicContext.js';
|
|
18
|
-
import '../../../CaptchaContext/CaptchaContext.js';
|
|
19
16
|
import { useErrorContext } from '../../../ErrorContext/ErrorContext.js';
|
|
20
|
-
import '@dynamic-labs/multi-wallet';
|
|
21
|
-
import 'viem/chains';
|
|
22
|
-
import '../../../AccessDeniedContext/AccessDeniedContext.js';
|
|
23
|
-
import '../../../AccountExistsContext/AccountExistsContext.js';
|
|
24
|
-
import '../../../../config/ApiEndpoint.js';
|
|
25
|
-
import '../../../EmailVerificationContext/EmailVerificationContext.js';
|
|
26
|
-
import 'react-dom';
|
|
27
|
-
import '../../../ThemeContext/ThemeContext.js';
|
|
28
|
-
import { usePrevious } from '../../../../utils/hooks/usePrevious/usePrevious.js';
|
|
29
|
-
import '@dynamic-labs/types';
|
|
30
|
-
import 'yup';
|
|
31
|
-
import 'react-i18next';
|
|
32
|
-
import '../../../MockContext/MockContext.js';
|
|
33
|
-
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
34
|
-
import '../../../UserFieldEditorContext/UserFieldEditorContext.js';
|
|
35
|
-
import '@dynamic-labs/rpc-providers';
|
|
36
|
-
import '../../../UserWalletsContext/UserWalletsContext.js';
|
|
37
|
-
import '../../../../components/Alert/Alert.js';
|
|
38
|
-
import '../../../../components/ShadowDOM/ShadowDOM.js';
|
|
39
|
-
import '../../../../components/IconButton/IconButton.js';
|
|
40
|
-
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
41
|
-
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
42
|
-
import '../../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
43
|
-
import '../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
44
|
-
import '../../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
45
|
-
import '../../../../components/Popper/Popper/Popper.js';
|
|
46
|
-
import '../../../../components/Popper/PopperContext/PopperContext.js';
|
|
47
|
-
import 'react-focus-lock';
|
|
48
|
-
import 'formik';
|
|
49
|
-
import 'i18next';
|
|
50
|
-
import '../../../../components/OverlayCard/OverlayCard.context.js';
|
|
51
|
-
import '../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
52
|
-
import '../../../../views/WalletList/WalletList.js';
|
|
53
|
-
import 'qrcode';
|
|
54
|
-
import '@hcaptcha/react-hcaptcha';
|
|
55
|
-
import '../../../LoadingContext/LoadingContext.js';
|
|
56
|
-
import '../../../SocialRedirectContext/SocialRedirectContext.js';
|
|
57
|
-
import '../../../WalletGroupContext/WalletGroupContext.js';
|
|
58
|
-
import '../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
59
|
-
import '../../../FooterAnimationContext/index.js';
|
|
60
|
-
import '../../../PasskeyContext/PasskeyContext.js';
|
|
61
|
-
import '../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
62
|
-
import '../../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
63
|
-
import '../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
64
|
-
import '@dynamic-labs/viem-utils';
|
|
65
|
-
import '../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
66
17
|
|
|
67
18
|
/**
|
|
68
19
|
* There are a multitude of scenarios where we want to ignore or insert functionality to calls
|
|
@@ -72,15 +23,14 @@ import '../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/Passkey
|
|
|
72
23
|
*/
|
|
73
24
|
const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMultiWalletEnabled, walletConnectorOptions, }) => {
|
|
74
25
|
const [showAuthFlow, _setShowAuthFlow] = useState(false);
|
|
75
|
-
const prevShowAuthFlow = usePrevious(showAuthFlow);
|
|
76
26
|
const { setError } = useErrorContext();
|
|
77
27
|
const setShowAuthFlow = useCallback((value, options = {}) => {
|
|
78
28
|
var _a;
|
|
79
29
|
const { emitCancelAuth, ignoreIfIsEmbeddedWidget, initializeWalletConnect, performMultiWalletChecks, clearErrors, } = Object.assign({ clearErrors: true, emitCancelAuth: false, ignoreIfIsEmbeddedWidget: true, initializeWalletConnect: true, performMultiWalletChecks: false }, options);
|
|
80
|
-
if (!
|
|
30
|
+
if (!showAuthFlow && value) {
|
|
81
31
|
dynamicEvents.emit('authFlowOpen');
|
|
82
32
|
}
|
|
83
|
-
else if (
|
|
33
|
+
else if (showAuthFlow && !value) {
|
|
84
34
|
dynamicEvents.emit('authFlowClose');
|
|
85
35
|
}
|
|
86
36
|
if (value) {
|
|
@@ -110,7 +60,6 @@ const useShowAuthFlow = ({ isAuthenticated, isRenderingEmbeddedAuthFlow, isMulti
|
|
|
110
60
|
setError,
|
|
111
61
|
showAuthFlow,
|
|
112
62
|
walletConnectorOptions,
|
|
113
|
-
prevShowAuthFlow,
|
|
114
63
|
]);
|
|
115
64
|
return [showAuthFlow, setShowAuthFlow];
|
|
116
65
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var useResponseHandlers = require('./useResponseHandlers.cjs');
|
|
9
|
+
|
|
10
|
+
const PhantomRedirectContext = React.createContext(undefined);
|
|
11
|
+
const PhantomRedirectContextProvider = ({ children, }) => {
|
|
12
|
+
const { phantomRedirectConnector, handleConnectResponse, handleUserResponse, } = useResponseHandlers.useResponseHandlers();
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (!phantomRedirectConnector || !utils.isMobile()) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const params = new URLSearchParams(window.location.search);
|
|
18
|
+
if (params.has('error')) {
|
|
19
|
+
// implement error handling
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// handle response of connect method
|
|
23
|
+
if (params.has('phantom_encryption_public_key')) {
|
|
24
|
+
handleConnectResponse();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// handle response of the following methods:
|
|
28
|
+
// signMessage, signTransaction, signAndSendTransaction or signAllTransactions
|
|
29
|
+
if (params.has('data')) {
|
|
30
|
+
handleUserResponse();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}, [handleConnectResponse, handleUserResponse, phantomRedirectConnector]);
|
|
34
|
+
return (jsxRuntime.jsx(PhantomRedirectContext.Provider, { value: {
|
|
35
|
+
phantomRedirectConnector,
|
|
36
|
+
}, children: children }));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.PhantomRedirectContext = PhantomRedirectContext;
|
|
40
|
+
exports.PhantomRedirectContextProvider = PhantomRedirectContextProvider;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { WalletConnector } from '../../..';
|
|
3
|
+
export type PhantomContextReturnType = {
|
|
4
|
+
phantomRedirectConnector: WalletConnector | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const PhantomRedirectContext: import("react").Context<PhantomContextReturnType | undefined>;
|
|
7
|
+
export declare const PhantomRedirectContextProvider: ({ children, }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
export declare const usePhantomRedirectContext: () => PhantomContextReturnType;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useEffect } from 'react';
|
|
3
|
+
import { isMobile } from '@dynamic-labs/utils';
|
|
4
|
+
import { useResponseHandlers } from './useResponseHandlers.js';
|
|
5
|
+
|
|
6
|
+
const PhantomRedirectContext = createContext(undefined);
|
|
7
|
+
const PhantomRedirectContextProvider = ({ children, }) => {
|
|
8
|
+
const { phantomRedirectConnector, handleConnectResponse, handleUserResponse, } = useResponseHandlers();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!phantomRedirectConnector || !isMobile()) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const params = new URLSearchParams(window.location.search);
|
|
14
|
+
if (params.has('error')) {
|
|
15
|
+
// implement error handling
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// handle response of connect method
|
|
19
|
+
if (params.has('phantom_encryption_public_key')) {
|
|
20
|
+
handleConnectResponse();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// handle response of the following methods:
|
|
24
|
+
// signMessage, signTransaction, signAndSendTransaction or signAllTransactions
|
|
25
|
+
if (params.has('data')) {
|
|
26
|
+
handleUserResponse();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}, [handleConnectResponse, handleUserResponse, phantomRedirectConnector]);
|
|
30
|
+
return (jsx(PhantomRedirectContext.Provider, { value: {
|
|
31
|
+
phantomRedirectConnector,
|
|
32
|
+
}, children: children }));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { PhantomRedirectContext, PhantomRedirectContextProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PhantomRedirectContext';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
require('../../events/dynamicEvents.cjs');
|
|
9
|
+
require('@dynamic-labs/utils');
|
|
10
|
+
require('../DynamicContext/DynamicContext.cjs');
|
|
11
|
+
require('@dynamic-labs/sdk-api');
|
|
12
|
+
require('../../shared/logger.cjs');
|
|
13
|
+
require('@dynamic-labs/iconic');
|
|
14
|
+
require('react/jsx-runtime');
|
|
15
|
+
var ViewContext = require('../ViewContext/ViewContext.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('../../utils/constants/colors.cjs');
|
|
18
|
+
require('../../utils/constants/values.cjs');
|
|
19
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
|
+
require('viem');
|
|
21
|
+
require('../../shared/consts/index.cjs');
|
|
22
|
+
var useInternalDynamicContext = require('../DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
23
|
+
var CaptchaContext = require('../CaptchaContext/CaptchaContext.cjs');
|
|
24
|
+
require('../ErrorContext/ErrorContext.cjs');
|
|
25
|
+
require('@dynamic-labs/multi-wallet');
|
|
26
|
+
require('viem/chains');
|
|
27
|
+
var useVerifyWallet = require('../../utils/hooks/useVerifyWallet/useVerifyWallet.cjs');
|
|
28
|
+
require('../../config/ApiEndpoint.cjs');
|
|
29
|
+
require('../EmailVerificationContext/EmailVerificationContext.cjs');
|
|
30
|
+
require('react-dom');
|
|
31
|
+
require('../ThemeContext/ThemeContext.cjs');
|
|
32
|
+
require('@dynamic-labs/types');
|
|
33
|
+
require('../AccountExistsContext/AccountExistsContext.cjs');
|
|
34
|
+
require('yup');
|
|
35
|
+
require('react-i18next');
|
|
36
|
+
require('../MockContext/MockContext.cjs');
|
|
37
|
+
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
38
|
+
require('../UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
39
|
+
require('@dynamic-labs/rpc-providers');
|
|
40
|
+
require('../UserWalletsContext/UserWalletsContext.cjs');
|
|
41
|
+
require('../../components/Alert/Alert.cjs');
|
|
42
|
+
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
43
|
+
require('../../components/IconButton/IconButton.cjs');
|
|
44
|
+
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
45
|
+
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
46
|
+
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
47
|
+
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
48
|
+
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
49
|
+
require('../../components/Popper/Popper/Popper.cjs');
|
|
50
|
+
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
51
|
+
require('react-focus-lock');
|
|
52
|
+
require('formik');
|
|
53
|
+
require('i18next');
|
|
54
|
+
require('../../components/OverlayCard/OverlayCard.context.cjs');
|
|
55
|
+
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
56
|
+
require('../../views/WalletList/WalletList.cjs');
|
|
57
|
+
require('../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
58
|
+
require('qrcode');
|
|
59
|
+
require('@hcaptcha/react-hcaptcha');
|
|
60
|
+
require('../LoadingContext/LoadingContext.cjs');
|
|
61
|
+
require('../SocialRedirectContext/SocialRedirectContext.cjs');
|
|
62
|
+
require('../WalletGroupContext/WalletGroupContext.cjs');
|
|
63
|
+
require('../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
64
|
+
require('../FooterAnimationContext/index.cjs');
|
|
65
|
+
require('../PasskeyContext/PasskeyContext.cjs');
|
|
66
|
+
require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
67
|
+
require('../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
68
|
+
require('../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
69
|
+
require('@dynamic-labs/viem-utils');
|
|
70
|
+
require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
71
|
+
|
|
72
|
+
const useResponseHandlers = () => {
|
|
73
|
+
const { walletConnectorOptions, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, connectWallet, setShowAuthFlow, setSelectedWalletConnectorKey, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
74
|
+
const { setView } = ViewContext.useViewContext();
|
|
75
|
+
const { getCaptchaToken } = CaptchaContext.useCaptchaContext();
|
|
76
|
+
const verifyWallet = useVerifyWallet.useVerifyWallet({
|
|
77
|
+
consumeNonce,
|
|
78
|
+
displaySiweStatement,
|
|
79
|
+
environmentId,
|
|
80
|
+
projectSettings,
|
|
81
|
+
setIsSingleWalletAccount,
|
|
82
|
+
});
|
|
83
|
+
const phantomRedirectConnector = walletConnectorOptions
|
|
84
|
+
.map(({ walletConnector }) => walletConnector)
|
|
85
|
+
.find(walletConnectorCore.isPhantomRedirectConnector);
|
|
86
|
+
const handleConnectResponse = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
87
|
+
if (!phantomRedirectConnector) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// this completes the connection step
|
|
91
|
+
yield phantomRedirectConnector.getSession();
|
|
92
|
+
yield connectWallet(phantomRedirectConnector);
|
|
93
|
+
setShowAuthFlow(true, { ignoreIfIsEmbeddedWidget: true });
|
|
94
|
+
setView('pending-signature');
|
|
95
|
+
setSelectedWalletConnectorKey('phantom');
|
|
96
|
+
}), [
|
|
97
|
+
connectWallet,
|
|
98
|
+
phantomRedirectConnector,
|
|
99
|
+
setSelectedWalletConnectorKey,
|
|
100
|
+
setShowAuthFlow,
|
|
101
|
+
setView,
|
|
102
|
+
]);
|
|
103
|
+
const handleUserResponse = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
if (!phantomRedirectConnector) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const { signature, message } = phantomRedirectConnector.extractSignature();
|
|
108
|
+
const [address] = yield phantomRedirectConnector.getConnectedAccounts();
|
|
109
|
+
yield verifyWallet({
|
|
110
|
+
captchaToken: getCaptchaToken(),
|
|
111
|
+
messageToSignOverride: message,
|
|
112
|
+
publicWalletAddress: address,
|
|
113
|
+
signedMessageOverride: signature,
|
|
114
|
+
walletConnector: phantomRedirectConnector,
|
|
115
|
+
});
|
|
116
|
+
}), [getCaptchaToken, phantomRedirectConnector, verifyWallet]);
|
|
117
|
+
return {
|
|
118
|
+
handleConnectResponse,
|
|
119
|
+
handleUserResponse,
|
|
120
|
+
phantomRedirectConnector,
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
exports.useResponseHandlers = useResponseHandlers;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { isPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import '../../events/dynamicEvents.js';
|
|
5
|
+
import '@dynamic-labs/utils';
|
|
6
|
+
import '../DynamicContext/DynamicContext.js';
|
|
7
|
+
import '@dynamic-labs/sdk-api';
|
|
8
|
+
import '../../shared/logger.js';
|
|
9
|
+
import '@dynamic-labs/iconic';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
import { useViewContext } from '../ViewContext/ViewContext.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '../../utils/constants/colors.js';
|
|
14
|
+
import '../../utils/constants/values.js';
|
|
15
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import 'viem';
|
|
17
|
+
import '../../shared/consts/index.js';
|
|
18
|
+
import { useInternalDynamicContext } from '../DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
19
|
+
import { useCaptchaContext } from '../CaptchaContext/CaptchaContext.js';
|
|
20
|
+
import '../ErrorContext/ErrorContext.js';
|
|
21
|
+
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import 'viem/chains';
|
|
23
|
+
import { useVerifyWallet } from '../../utils/hooks/useVerifyWallet/useVerifyWallet.js';
|
|
24
|
+
import '../../config/ApiEndpoint.js';
|
|
25
|
+
import '../EmailVerificationContext/EmailVerificationContext.js';
|
|
26
|
+
import 'react-dom';
|
|
27
|
+
import '../ThemeContext/ThemeContext.js';
|
|
28
|
+
import '@dynamic-labs/types';
|
|
29
|
+
import '../AccountExistsContext/AccountExistsContext.js';
|
|
30
|
+
import 'yup';
|
|
31
|
+
import 'react-i18next';
|
|
32
|
+
import '../MockContext/MockContext.js';
|
|
33
|
+
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
34
|
+
import '../UserFieldEditorContext/UserFieldEditorContext.js';
|
|
35
|
+
import '@dynamic-labs/rpc-providers';
|
|
36
|
+
import '../UserWalletsContext/UserWalletsContext.js';
|
|
37
|
+
import '../../components/Alert/Alert.js';
|
|
38
|
+
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
39
|
+
import '../../components/IconButton/IconButton.js';
|
|
40
|
+
import '../../components/InlineWidget/InlineWidget.js';
|
|
41
|
+
import '../../components/MenuList/Dropdown/Dropdown.js';
|
|
42
|
+
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
43
|
+
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
44
|
+
import '../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
45
|
+
import '../../components/Popper/Popper/Popper.js';
|
|
46
|
+
import '../../components/Popper/PopperContext/PopperContext.js';
|
|
47
|
+
import 'react-focus-lock';
|
|
48
|
+
import 'formik';
|
|
49
|
+
import 'i18next';
|
|
50
|
+
import '../../components/OverlayCard/OverlayCard.context.js';
|
|
51
|
+
import '../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
52
|
+
import '../../views/WalletList/WalletList.js';
|
|
53
|
+
import '../AccessDeniedContext/AccessDeniedContext.js';
|
|
54
|
+
import 'qrcode';
|
|
55
|
+
import '@hcaptcha/react-hcaptcha';
|
|
56
|
+
import '../LoadingContext/LoadingContext.js';
|
|
57
|
+
import '../SocialRedirectContext/SocialRedirectContext.js';
|
|
58
|
+
import '../WalletGroupContext/WalletGroupContext.js';
|
|
59
|
+
import '../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
60
|
+
import '../FooterAnimationContext/index.js';
|
|
61
|
+
import '../PasskeyContext/PasskeyContext.js';
|
|
62
|
+
import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
63
|
+
import '../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
64
|
+
import '../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
65
|
+
import '@dynamic-labs/viem-utils';
|
|
66
|
+
import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
67
|
+
|
|
68
|
+
const useResponseHandlers = () => {
|
|
69
|
+
const { walletConnectorOptions, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, connectWallet, setShowAuthFlow, setSelectedWalletConnectorKey, } = useInternalDynamicContext();
|
|
70
|
+
const { setView } = useViewContext();
|
|
71
|
+
const { getCaptchaToken } = useCaptchaContext();
|
|
72
|
+
const verifyWallet = useVerifyWallet({
|
|
73
|
+
consumeNonce,
|
|
74
|
+
displaySiweStatement,
|
|
75
|
+
environmentId,
|
|
76
|
+
projectSettings,
|
|
77
|
+
setIsSingleWalletAccount,
|
|
78
|
+
});
|
|
79
|
+
const phantomRedirectConnector = walletConnectorOptions
|
|
80
|
+
.map(({ walletConnector }) => walletConnector)
|
|
81
|
+
.find(isPhantomRedirectConnector);
|
|
82
|
+
const handleConnectResponse = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
if (!phantomRedirectConnector) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// this completes the connection step
|
|
87
|
+
yield phantomRedirectConnector.getSession();
|
|
88
|
+
yield connectWallet(phantomRedirectConnector);
|
|
89
|
+
setShowAuthFlow(true, { ignoreIfIsEmbeddedWidget: true });
|
|
90
|
+
setView('pending-signature');
|
|
91
|
+
setSelectedWalletConnectorKey('phantom');
|
|
92
|
+
}), [
|
|
93
|
+
connectWallet,
|
|
94
|
+
phantomRedirectConnector,
|
|
95
|
+
setSelectedWalletConnectorKey,
|
|
96
|
+
setShowAuthFlow,
|
|
97
|
+
setView,
|
|
98
|
+
]);
|
|
99
|
+
const handleUserResponse = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
if (!phantomRedirectConnector) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { signature, message } = phantomRedirectConnector.extractSignature();
|
|
104
|
+
const [address] = yield phantomRedirectConnector.getConnectedAccounts();
|
|
105
|
+
yield verifyWallet({
|
|
106
|
+
captchaToken: getCaptchaToken(),
|
|
107
|
+
messageToSignOverride: message,
|
|
108
|
+
publicWalletAddress: address,
|
|
109
|
+
signedMessageOverride: signature,
|
|
110
|
+
walletConnector: phantomRedirectConnector,
|
|
111
|
+
});
|
|
112
|
+
}), [getCaptchaToken, phantomRedirectConnector, verifyWallet]);
|
|
113
|
+
return {
|
|
114
|
+
handleConnectResponse,
|
|
115
|
+
handleUserResponse,
|
|
116
|
+
phantomRedirectConnector,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export { useResponseHandlers };
|
|
@@ -90,6 +90,8 @@ export interface VerifyCallbackArgs {
|
|
|
90
90
|
oauth?: OauthProviderRequest;
|
|
91
91
|
publicWalletAddress: string;
|
|
92
92
|
walletConnector: WalletConnector;
|
|
93
|
+
signedMessageOverride?: string;
|
|
94
|
+
messageToSignOverride?: string;
|
|
93
95
|
}
|
|
94
96
|
export interface VerifyWalletProps {
|
|
95
97
|
verifyWallet: ({ walletConnector, fetchPublicAddressOpts, }: VerifyCallbackArgs) => Promise<void>;
|
|
@@ -6,7 +6,7 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
|
6
6
|
var index = require('../generateMessages/index.cjs');
|
|
7
7
|
|
|
8
8
|
// TODO - This function is doing too much we should split it up.
|
|
9
|
-
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, signedMessageOverride, messageToSignOverride, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
10
|
// WARNING - PLEASE READ!
|
|
11
11
|
// DO NOT ADD ANY NEW ASYNC WORK WITH AWAIT!
|
|
12
12
|
// Deep linking could break with too many blocking awaits
|
|
@@ -14,6 +14,23 @@ const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId,
|
|
|
14
14
|
// This could manifest in users being directed to the app store
|
|
15
15
|
// instead of the actual wallet app.
|
|
16
16
|
const chain = walletConnector.connectedChain;
|
|
17
|
+
if (signedMessageOverride && messageToSignOverride) {
|
|
18
|
+
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
19
|
+
walletConnector.getNetwork(),
|
|
20
|
+
walletConnector.getAdditionalAddresses(publicWalletAddress),
|
|
21
|
+
]);
|
|
22
|
+
return {
|
|
23
|
+
additionalWalletAddresses,
|
|
24
|
+
chain,
|
|
25
|
+
messageToSign: messageToSignOverride,
|
|
26
|
+
network: String(network),
|
|
27
|
+
publicWalletAddress,
|
|
28
|
+
signedMessage: signedMessageOverride,
|
|
29
|
+
skipEmptyAccountCheck,
|
|
30
|
+
walletName: walletConnector.key,
|
|
31
|
+
walletProvider,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
17
34
|
// generate message to sign and then initiate signing step to prove ownership
|
|
18
35
|
const { messageToSign, signedMessage } = yield index.generateMessages(publicWalletAddress, walletConnector, nonce, environmentId, displaySiweStatement, siweStatement);
|
|
19
36
|
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FetchPublicAddressOpts } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { WalletAdditionalAddress } from '@dynamic-labs/sdk-api';
|
|
2
3
|
import { WalletConnector } from '../../../..';
|
|
3
4
|
import { WalletProvider } from '../../../shared';
|
|
4
5
|
type Props = {
|
|
@@ -11,16 +12,19 @@ type Props = {
|
|
|
11
12
|
skipEmptyAccountCheck?: boolean;
|
|
12
13
|
walletConnector: WalletConnector;
|
|
13
14
|
walletProvider: WalletProvider;
|
|
15
|
+
signedMessageOverride?: string;
|
|
16
|
+
messageToSignOverride?: string;
|
|
14
17
|
};
|
|
15
|
-
|
|
16
|
-
additionalWalletAddresses:
|
|
17
|
-
chain:
|
|
18
|
+
type VerifyArgs = {
|
|
19
|
+
additionalWalletAddresses: WalletAdditionalAddress[] | undefined;
|
|
20
|
+
chain: string;
|
|
18
21
|
messageToSign: string;
|
|
19
22
|
network: string;
|
|
20
23
|
publicWalletAddress: string;
|
|
21
24
|
signedMessage: string;
|
|
22
|
-
skipEmptyAccountCheck
|
|
25
|
+
skipEmptyAccountCheck?: boolean;
|
|
23
26
|
walletName: string;
|
|
24
|
-
walletProvider:
|
|
25
|
-
}
|
|
27
|
+
walletProvider: WalletProvider;
|
|
28
|
+
};
|
|
29
|
+
export declare const getVerifyArgs: ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, signedMessageOverride, messageToSignOverride, }: Props) => Promise<VerifyArgs>;
|
|
26
30
|
export {};
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
|
2
2
|
import { generateMessages } from '../generateMessages/index.js';
|
|
3
3
|
|
|
4
4
|
// TODO - This function is doing too much we should split it up.
|
|
5
|
-
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId, displaySiweStatement, skipEmptyAccountCheck, siweStatement, publicWalletAddress, signedMessageOverride, messageToSignOverride, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6
6
|
// WARNING - PLEASE READ!
|
|
7
7
|
// DO NOT ADD ANY NEW ASYNC WORK WITH AWAIT!
|
|
8
8
|
// Deep linking could break with too many blocking awaits
|
|
@@ -10,6 +10,23 @@ const getVerifyArgs = ({ walletConnector, nonce, walletProvider, environmentId,
|
|
|
10
10
|
// This could manifest in users being directed to the app store
|
|
11
11
|
// instead of the actual wallet app.
|
|
12
12
|
const chain = walletConnector.connectedChain;
|
|
13
|
+
if (signedMessageOverride && messageToSignOverride) {
|
|
14
|
+
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
15
|
+
walletConnector.getNetwork(),
|
|
16
|
+
walletConnector.getAdditionalAddresses(publicWalletAddress),
|
|
17
|
+
]);
|
|
18
|
+
return {
|
|
19
|
+
additionalWalletAddresses,
|
|
20
|
+
chain,
|
|
21
|
+
messageToSign: messageToSignOverride,
|
|
22
|
+
network: String(network),
|
|
23
|
+
publicWalletAddress,
|
|
24
|
+
signedMessage: signedMessageOverride,
|
|
25
|
+
skipEmptyAccountCheck,
|
|
26
|
+
walletName: walletConnector.key,
|
|
27
|
+
walletProvider,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
13
30
|
// generate message to sign and then initiate signing step to prove ownership
|
|
14
31
|
const { messageToSign, signedMessage } = yield generateMessages(publicWalletAddress, walletConnector, nonce, environmentId, displaySiweStatement, siweStatement);
|
|
15
32
|
const [network, additionalWalletAddresses] = yield Promise.all([
|
|
@@ -89,7 +89,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
89
89
|
// and need to distinguish between logic for verify or linking.
|
|
90
90
|
const verifyOnly = !authToken;
|
|
91
91
|
const shouldFallbackToConnectOnly = enableConnectOnlyFallback && (verifyOnly || !multiWalletEnabled);
|
|
92
|
-
const generateJWT = (walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
const generateJWT = (walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
93
93
|
let Jwt;
|
|
94
94
|
const nonce = consumeNonce();
|
|
95
95
|
if (nonce === undefined)
|
|
@@ -98,8 +98,10 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
98
98
|
displaySiweStatement,
|
|
99
99
|
environmentId,
|
|
100
100
|
fetchPublicAddressOpts,
|
|
101
|
+
messageToSignOverride,
|
|
101
102
|
nonce,
|
|
102
103
|
publicWalletAddress,
|
|
104
|
+
signedMessageOverride,
|
|
103
105
|
siweStatement: getSiweStatement.getSiweStatement({ appName, siweStatement }),
|
|
104
106
|
walletConnector,
|
|
105
107
|
walletProvider,
|
|
@@ -159,6 +161,10 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
159
161
|
};
|
|
160
162
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
161
163
|
var _a;
|
|
164
|
+
// see: PhantomRedirect#signMessage
|
|
165
|
+
if (e.message === 'ignore') {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
162
168
|
if (e instanceof utils.WalletUsedError) {
|
|
163
169
|
handleDisconnectWallet({ endSession: false, walletConnector });
|
|
164
170
|
return handleWalletUsedError(e);
|
|
@@ -215,12 +221,12 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
215
221
|
setErrorMessage(e.code);
|
|
216
222
|
}
|
|
217
223
|
};
|
|
218
|
-
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
224
|
+
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
219
225
|
var _a;
|
|
220
226
|
const walletProvider = getWalletProvider.getWalletProvider(walletConnector);
|
|
221
227
|
try {
|
|
222
228
|
setIsVerificationInProgress(true);
|
|
223
|
-
const { Jwt, verifyArgs } = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
229
|
+
const { Jwt, verifyArgs } = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride);
|
|
224
230
|
const decodedJwt = decodeJwt.decodeJwt(Jwt);
|
|
225
231
|
if (decodedJwt === undefined)
|
|
226
232
|
throw new utils.DynamicError('Invalid token!');
|
|
@@ -5,5 +5,5 @@ type UseVerifyWalletArgs = VerifyProps & ProjectSettingsProps & {
|
|
|
5
5
|
displaySiweStatement: boolean;
|
|
6
6
|
setIsSingleWalletAccount: Dispatch<SetStateAction<boolean>>;
|
|
7
7
|
};
|
|
8
|
-
export declare const useVerifyWallet: ({ consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }: VerifyCallbackArgs) => Promise<void>;
|
|
8
|
+
export declare const useVerifyWallet: ({ consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, }: UseVerifyWalletArgs) => ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }: VerifyCallbackArgs) => Promise<void>;
|
|
9
9
|
export {};
|
|
@@ -85,7 +85,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
85
85
|
// and need to distinguish between logic for verify or linking.
|
|
86
86
|
const verifyOnly = !authToken;
|
|
87
87
|
const shouldFallbackToConnectOnly = enableConnectOnlyFallback && (verifyOnly || !multiWalletEnabled);
|
|
88
|
-
const generateJWT = (walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const generateJWT = (walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
89
|
let Jwt;
|
|
90
90
|
const nonce = consumeNonce();
|
|
91
91
|
if (nonce === undefined)
|
|
@@ -94,8 +94,10 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
94
94
|
displaySiweStatement,
|
|
95
95
|
environmentId,
|
|
96
96
|
fetchPublicAddressOpts,
|
|
97
|
+
messageToSignOverride,
|
|
97
98
|
nonce,
|
|
98
99
|
publicWalletAddress,
|
|
100
|
+
signedMessageOverride,
|
|
99
101
|
siweStatement: getSiweStatement({ appName, siweStatement }),
|
|
100
102
|
walletConnector,
|
|
101
103
|
walletProvider,
|
|
@@ -155,6 +157,10 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
155
157
|
};
|
|
156
158
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
157
159
|
var _a;
|
|
160
|
+
// see: PhantomRedirect#signMessage
|
|
161
|
+
if (e.message === 'ignore') {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
158
164
|
if (e instanceof WalletUsedError) {
|
|
159
165
|
handleDisconnectWallet({ endSession: false, walletConnector });
|
|
160
166
|
return handleWalletUsedError(e);
|
|
@@ -211,12 +217,12 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
211
217
|
setErrorMessage(e.code);
|
|
212
218
|
}
|
|
213
219
|
};
|
|
214
|
-
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
220
|
+
return ({ walletConnector, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
221
|
var _a;
|
|
216
222
|
const walletProvider = getWalletProvider(walletConnector);
|
|
217
223
|
try {
|
|
218
224
|
setIsVerificationInProgress(true);
|
|
219
|
-
const { Jwt, verifyArgs } = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth);
|
|
225
|
+
const { Jwt, verifyArgs } = yield generateJWT(walletConnector, walletProvider, fetchPublicAddressOpts, publicWalletAddress, captchaToken, oauth, signedMessageOverride, messageToSignOverride);
|
|
220
226
|
const decodedJwt = decodeJwt(Jwt);
|
|
221
227
|
if (decodedJwt === undefined)
|
|
222
228
|
throw new DynamicError('Invalid token!');
|
|
@@ -6,7 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var data = require('../../../views/WalletList/data.cjs');
|
|
7
7
|
var verifyRequiredConnectorsAreSetup = require('./utils/verifyRequiredConnectorsAreSetup/verifyRequiredConnectorsAreSetup.cjs');
|
|
8
8
|
|
|
9
|
-
const useWalletConnectorOptions = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, walletConnectPreferredChains, walletConnectorExtensions, }) => {
|
|
9
|
+
const useWalletConnectorOptions = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, mobileExperience, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, walletConnectPreferredChains, walletConnectorExtensions, }) => {
|
|
10
10
|
const walletConnectorOptions = React.useMemo(() => {
|
|
11
11
|
if (!projectSettings ||
|
|
12
12
|
!Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length ||
|
|
@@ -18,6 +18,7 @@ const useWalletConnectorOptions = ({ projectSettings, appLogoUrl, appName, deepL
|
|
|
18
18
|
appName,
|
|
19
19
|
deepLinkPreference,
|
|
20
20
|
flowNetwork,
|
|
21
|
+
mobileExperience,
|
|
21
22
|
networkConfigurations,
|
|
22
23
|
settings: projectSettings,
|
|
23
24
|
skipMemo: true,
|
|
@@ -7,6 +7,7 @@ type Props = {
|
|
|
7
7
|
appName?: string;
|
|
8
8
|
deepLinkPreference?: DeepLinkVariant;
|
|
9
9
|
flowNetwork?: 'mainnet' | 'testnet';
|
|
10
|
+
mobileExperience?: 'in-app-browser' | 'redirect';
|
|
10
11
|
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
11
12
|
projectSettings: ProjectSettings | undefined;
|
|
12
13
|
walletBook: WalletBookSchema;
|
|
@@ -16,7 +17,7 @@ type Props = {
|
|
|
16
17
|
walletUiUtils: WalletUiUtils<WalletConnector>;
|
|
17
18
|
walletConnectorExtensions?: WalletConnectorExtension[];
|
|
18
19
|
};
|
|
19
|
-
export declare const useWalletConnectorOptions: ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, walletConnectPreferredChains, walletConnectorExtensions, }: Props) => {
|
|
20
|
+
export declare const useWalletConnectorOptions: ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, mobileExperience, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, walletConnectPreferredChains, walletConnectorExtensions, }: Props) => {
|
|
20
21
|
walletConnectorOptions: import("../../../shared").WalletOption[];
|
|
21
22
|
};
|
|
22
23
|
export {};
|
|
@@ -2,7 +2,7 @@ import { useMemo, useEffect } from 'react';
|
|
|
2
2
|
import { getWallets } from '../../../views/WalletList/data.js';
|
|
3
3
|
import { verifyRequiredConnectorsAreSetup } from './utils/verifyRequiredConnectorsAreSetup/verifyRequiredConnectorsAreSetup.js';
|
|
4
4
|
|
|
5
|
-
const useWalletConnectorOptions = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, walletConnectPreferredChains, walletConnectorExtensions, }) => {
|
|
5
|
+
const useWalletConnectorOptions = ({ projectSettings, appLogoUrl, appName, deepLinkPreference, flowNetwork, mobileExperience, networkConfigurations, walletBook, walletConnectV1Bridge, walletUiUtils, walletConnectorsProp, walletConnectPreferredChains, walletConnectorExtensions, }) => {
|
|
6
6
|
const walletConnectorOptions = useMemo(() => {
|
|
7
7
|
if (!projectSettings ||
|
|
8
8
|
!Object.keys(walletBook !== null && walletBook !== void 0 ? walletBook : {}).length ||
|
|
@@ -14,6 +14,7 @@ const useWalletConnectorOptions = ({ projectSettings, appLogoUrl, appName, deepL
|
|
|
14
14
|
appName,
|
|
15
15
|
deepLinkPreference,
|
|
16
16
|
flowNetwork,
|
|
17
|
+
mobileExperience,
|
|
17
18
|
networkConfigurations,
|
|
18
19
|
settings: projectSettings,
|
|
19
20
|
skipMemo: true,
|
|
@@ -28,7 +28,6 @@ require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
28
28
|
require('@dynamic-labs/multi-wallet');
|
|
29
29
|
var getAuthToken = require('../../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
30
30
|
require('@dynamic-labs/sdk-api');
|
|
31
|
-
var isPasskeyEnabled = require('../../../utils/functions/isPasskeyEnabled/isPasskeyEnabled.cjs');
|
|
32
31
|
require('viem/chains');
|
|
33
32
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
33
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
@@ -37,7 +36,6 @@ require('../../../context/EmailVerificationContext/EmailVerificationContext.cjs'
|
|
|
37
36
|
require('react-dom');
|
|
38
37
|
var useCreateDynamicEmbeddedWalletMutation = require('../../../utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs');
|
|
39
38
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
40
|
-
var usePromise = require('../../../utils/hooks/usePromise/usePromise.cjs');
|
|
41
39
|
require('@dynamic-labs/types');
|
|
42
40
|
require('yup');
|
|
43
41
|
require('../../../context/MockContext/MockContext.cjs');
|
|
@@ -88,7 +86,9 @@ const PasskeyIntroView = () => {
|
|
|
88
86
|
const { walletConnectorOptions, environmentId, handleLogOut, onboardingOnlyJwt, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
89
87
|
const { setIsFooterExpanded } = index.useFooterAnimationContext();
|
|
90
88
|
const { t } = reactI18next.useTranslation();
|
|
91
|
-
|
|
89
|
+
// TODO(GVTY-1137): send a metric when we detect passkeys are not enabled by the browser/device
|
|
90
|
+
// we removed enforcing this check since we were getting false negatives
|
|
91
|
+
// const { data: passkeyEnabled } = usePromise(isPasskeyEnabled);
|
|
92
92
|
// if passkey is not yet setup, but user logged in with email in a passkey env
|
|
93
93
|
// it should be null to force user to setup passkey even after the a refresh
|
|
94
94
|
React.useEffect(() => localStorage.LocalStorage.removeFromLS(localStorage$1.LAST_USED_WALLET), []);
|
|
@@ -118,7 +118,7 @@ const PasskeyIntroView = () => {
|
|
|
118
118
|
return getProperErrorMessage.getProperErrorMessage(error);
|
|
119
119
|
}, [error]);
|
|
120
120
|
const infoIconButton = (jsxRuntime.jsx(Tooltip.Tooltip, { content: t('dyn_passkey_intro.helper.tooltip'), className: 'header__tooltip', copykey: 'dyn_passkey_intro.helper.tooltip', children: jsxRuntime.jsx(IconButton.IconButton, { type: 'button', "data-testid": 'info-button', onClick: () => setIsFooterExpanded((prev) => !prev), className: 'header__icon', children: jsxRuntime.jsx(questionMark.ReactComponent, {}) }) }, 'info-button'));
|
|
121
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: infoIconButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_passkey_intro.title', children: t('dyn_passkey_intro.title') }) }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view', children: [jsxRuntime.jsx("div", { className: 'passkey-intro-view__header', children: jsxRuntime.jsx(passkeyIntroIcon.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', copykey: 'dyn_passkey_intro.subtitle', children: t('dyn_passkey_intro.subtitle') }),
|
|
121
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: infoIconButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_passkey_intro.title', children: t('dyn_passkey_intro.title') }) }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view', children: [jsxRuntime.jsx("div", { className: 'passkey-intro-view__header', children: jsxRuntime.jsx(passkeyIntroIcon.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', copykey: 'dyn_passkey_intro.subtitle', children: t('dyn_passkey_intro.subtitle') }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view__actions', children: [jsxRuntime.jsx(Button.Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick: handleCreateEmbeddedWallet, dataTestId: 'setup-passkey-button', loading: isLoading, disabled: isLoading, typographyProps: {
|
|
122
122
|
color: 'inherit',
|
|
123
123
|
}, children: jsxRuntime.jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, {}), jsxRuntime.jsx(Typography.Typography, { copykey: 'dyn_passkey_intro.button', children: t('dyn_passkey_intro.button') })] }) }), jsxRuntime.jsx(TextButton.TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, copykey: 'dyn_passkey_intro.button_logout', children: t('dyn_passkey_intro.button_logout') })] })] })] }));
|
|
124
124
|
};
|
|
@@ -24,7 +24,6 @@ import '../../../context/ErrorContext/ErrorContext.js';
|
|
|
24
24
|
import '@dynamic-labs/multi-wallet';
|
|
25
25
|
import { getAuthToken } from '../../../utils/functions/getAuthToken/getAuthToken.js';
|
|
26
26
|
import '@dynamic-labs/sdk-api';
|
|
27
|
-
import { isPasskeyEnabled } from '../../../utils/functions/isPasskeyEnabled/isPasskeyEnabled.js';
|
|
28
27
|
import 'viem/chains';
|
|
29
28
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
29
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
@@ -33,7 +32,6 @@ import '../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
|
33
32
|
import 'react-dom';
|
|
34
33
|
import { useCreateDynamicEmbeddedWalletMutation } from '../../../utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js';
|
|
35
34
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
36
|
-
import { usePromise } from '../../../utils/hooks/usePromise/usePromise.js';
|
|
37
35
|
import '@dynamic-labs/types';
|
|
38
36
|
import 'yup';
|
|
39
37
|
import '../../../context/MockContext/MockContext.js';
|
|
@@ -84,7 +82,9 @@ const PasskeyIntroView = () => {
|
|
|
84
82
|
const { walletConnectorOptions, environmentId, handleLogOut, onboardingOnlyJwt, } = useInternalDynamicContext();
|
|
85
83
|
const { setIsFooterExpanded } = useFooterAnimationContext();
|
|
86
84
|
const { t } = useTranslation();
|
|
87
|
-
|
|
85
|
+
// TODO(GVTY-1137): send a metric when we detect passkeys are not enabled by the browser/device
|
|
86
|
+
// we removed enforcing this check since we were getting false negatives
|
|
87
|
+
// const { data: passkeyEnabled } = usePromise(isPasskeyEnabled);
|
|
88
88
|
// if passkey is not yet setup, but user logged in with email in a passkey env
|
|
89
89
|
// it should be null to force user to setup passkey even after the a refresh
|
|
90
90
|
useEffect(() => LocalStorage.removeFromLS(LAST_USED_WALLET), []);
|
|
@@ -114,7 +114,7 @@ const PasskeyIntroView = () => {
|
|
|
114
114
|
return getProperErrorMessage(error);
|
|
115
115
|
}, [error]);
|
|
116
116
|
const infoIconButton = (jsx(Tooltip, { content: t('dyn_passkey_intro.helper.tooltip'), className: 'header__tooltip', copykey: 'dyn_passkey_intro.helper.tooltip', children: jsx(IconButton, { type: 'button', "data-testid": 'info-button', onClick: () => setIsFooterExpanded((prev) => !prev), className: 'header__icon', children: jsx(SvgQuestionMark, {}) }) }, 'info-button'));
|
|
117
|
-
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: infoIconButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_passkey_intro.title', children: t('dyn_passkey_intro.title') }) }), jsxs("div", { className: 'passkey-intro-view', children: [jsx("div", { className: 'passkey-intro-view__header', children: jsx(SvgPasskeyIntroIcon, {}) }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', copykey: 'dyn_passkey_intro.subtitle', children: t('dyn_passkey_intro.subtitle') }),
|
|
117
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: infoIconButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', copykey: 'dyn_passkey_intro.title', children: t('dyn_passkey_intro.title') }) }), jsxs("div", { className: 'passkey-intro-view', children: [jsx("div", { className: 'passkey-intro-view__header', children: jsx(SvgPasskeyIntroIcon, {}) }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', copykey: 'dyn_passkey_intro.subtitle', children: t('dyn_passkey_intro.subtitle') }), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'passkey-intro-view__actions', children: [jsx(Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick: handleCreateEmbeddedWallet, dataTestId: 'setup-passkey-button', loading: isLoading, disabled: isLoading, typographyProps: {
|
|
118
118
|
color: 'inherit',
|
|
119
119
|
}, children: jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsx(PasskeyDeviceIcon, {}), jsx(Typography, { copykey: 'dyn_passkey_intro.button', children: t('dyn_passkey_intro.button') })] }) }), jsx(TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, copykey: 'dyn_passkey_intro.button_logout', children: t('dyn_passkey_intro.button_logout') })] })] })] }));
|
|
120
120
|
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
-
var utils = require('@dynamic-labs/utils');
|
|
7
|
-
|
|
8
|
-
const isUserVerifyingPlatformAuthenticatorAvailable = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
return (typeof ((_a = window === null || window === void 0 ? void 0 : window.PublicKeyCredential) === null || _a === void 0 ? void 0 : _a.isUserVerifyingPlatformAuthenticatorAvailable) === 'function' &&
|
|
11
|
-
(yield ((_b = window === null || window === void 0 ? void 0 : window.PublicKeyCredential) === null || _b === void 0 ? void 0 : _b.isUserVerifyingPlatformAuthenticatorAvailable()))) ||
|
|
12
|
-
false;
|
|
13
|
-
});
|
|
14
|
-
// we couldn't find a reliable if passkey is enabled on Windows, so we're just going to assume it is
|
|
15
|
-
// isUserVerifyingPlatformAuthenticatorAvailable returns false, even when passkey works
|
|
16
|
-
const isPasskeyEnabled = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
return (yield isUserVerifyingPlatformAuthenticatorAvailable()) ||
|
|
18
|
-
utils.isWindows() ||
|
|
19
|
-
false;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
exports.isPasskeyEnabled = isPasskeyEnabled;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { isWindows } from '@dynamic-labs/utils';
|
|
3
|
-
|
|
4
|
-
const isUserVerifyingPlatformAuthenticatorAvailable = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
-
var _a, _b;
|
|
6
|
-
return (typeof ((_a = window === null || window === void 0 ? void 0 : window.PublicKeyCredential) === null || _a === void 0 ? void 0 : _a.isUserVerifyingPlatformAuthenticatorAvailable) === 'function' &&
|
|
7
|
-
(yield ((_b = window === null || window === void 0 ? void 0 : window.PublicKeyCredential) === null || _b === void 0 ? void 0 : _b.isUserVerifyingPlatformAuthenticatorAvailable()))) ||
|
|
8
|
-
false;
|
|
9
|
-
});
|
|
10
|
-
// we couldn't find a reliable if passkey is enabled on Windows, so we're just going to assume it is
|
|
11
|
-
// isUserVerifyingPlatformAuthenticatorAvailable returns false, even when passkey works
|
|
12
|
-
const isPasskeyEnabled = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
return (yield isUserVerifyingPlatformAuthenticatorAvailable()) ||
|
|
14
|
-
isWindows() ||
|
|
15
|
-
false;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export { isPasskeyEnabled };
|