@dynamic-labs/sdk-react-core 4.9.1 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +3 -1
- package/src/index.d.ts +4 -3
- package/src/index.js +2 -1
- package/src/lib/components/Portal/ModalComponent/ModalComponent.cjs +32 -0
- package/src/lib/components/Portal/ModalComponent/ModalComponent.d.ts +9 -0
- package/src/lib/components/Portal/ModalComponent/ModalComponent.js +24 -0
- package/src/lib/components/Portal/ModalComponent/index.d.ts +1 -0
- package/src/lib/components/Portal/Portal.cjs +3 -119
- package/src/lib/components/Portal/Portal.d.ts +3 -8
- package/src/lib/components/Portal/Portal.js +3 -115
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.cjs +1 -1
- package/src/lib/components/TransactionCard/SendBalanceTransactionCard.js +1 -1
- package/src/lib/components/TransactionCard/TransactionCard.cjs +1 -1
- package/src/lib/components/TransactionCard/TransactionCard.js +1 -1
- package/src/lib/components/Typography/Typography.cjs +1 -0
- package/src/lib/components/Typography/Typography.js +1 -0
- package/src/lib/components/Typography/Typography.types.d.ts +1 -1
- package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.cjs +10 -2
- package/src/lib/components/WalletConnectorEvents/WalletConnectorEvents.js +10 -2
- package/src/lib/context/DynamicContext/DynamicContext.cjs +13 -9
- package/src/lib/context/DynamicContext/DynamicContext.js +15 -11
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +0 -12
- package/src/lib/context/DynamicContext/helpers/helpers.d.ts +1 -9
- package/src/lib/context/DynamicContext/helpers/helpers.js +1 -12
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.cjs +18 -0
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.d.ts +10 -0
- package/src/lib/context/DynamicContext/hooks/useInitialViewType/useInitialViewType.js +14 -0
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.cjs +1 -1
- package/src/lib/context/DynamicContext/hooks/useShowAuthFlow/useShowAuthFlow.js +1 -1
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +6 -2
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +1 -1
- package/src/lib/context/ViewContext/ViewContext.cjs +1 -1
- package/src/lib/context/ViewContext/ViewContext.js +1 -1
- package/src/lib/locale/en/translation.cjs +2 -2
- package/src/lib/locale/en/translation.d.ts +1 -1
- package/src/lib/locale/en/translation.js +2 -2
- package/src/lib/main.global.cjs +1 -1
- package/src/lib/main.global.js +1 -1
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/authViewLayoutChecks.cjs +135 -0
- package/src/lib/utils/constants/authViewLayoutChecks.d.ts +21 -0
- package/src/lib/utils/constants/authViewLayoutChecks.js +123 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +36 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.d.ts +11 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +32 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +20 -93
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.d.ts +1 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +19 -92
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +7 -4
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +5 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +7 -4
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +2 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +2 -1
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +3 -2
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +3 -2
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +8 -2
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +9 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +4 -1
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +4 -1
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +1 -4
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +1 -4
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +4 -10
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +4 -10
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +7 -5
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +7 -5
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +164 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.d.ts +3 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +160 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +11 -50
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +11 -50
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/components/Balance/Balance.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetWallets/DynamicWidgetWallets.js +4 -4
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/views/DepositView/DepositView.js +1 -1
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.cjs +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/TokenBalanceItem.js +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceItem/index.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.cjs +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.d.ts +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/TokenBalanceList.js +0 -0
- /package/src/lib/widgets/DynamicWidget/components/{ActiveWalletInformation → ActiveWalletBalance}/TokenBalanceList/index.d.ts +0 -0
|
@@ -19,9 +19,9 @@ import '../../../context/ErrorContext/ErrorContext.js';
|
|
|
19
19
|
import '@dynamic-labs/multi-wallet';
|
|
20
20
|
import 'react-international-phone';
|
|
21
21
|
import '../../../store/state/nonce/nonce.js';
|
|
22
|
-
import '../../../store/state/projectSettings/projectSettings.js';
|
|
22
|
+
import { useProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
|
|
23
23
|
import '../../../config/ApiEndpoint.js';
|
|
24
|
-
import '../../../store/state/user/user.js';
|
|
24
|
+
import { useUserCoalesced } from '../../../store/state/user/user.js';
|
|
25
25
|
import '../../../locale/locale.js';
|
|
26
26
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
27
27
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
@@ -65,6 +65,7 @@ import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBan
|
|
|
65
65
|
import '../../../components/Popper/Popper/Popper.js';
|
|
66
66
|
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
67
67
|
import 'react-focus-lock';
|
|
68
|
+
import { useAllowClose } from './useAllowClose/useAllowClose.js';
|
|
68
69
|
import 'qrcode';
|
|
69
70
|
import 'formik';
|
|
70
71
|
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
@@ -75,9 +76,10 @@ import '../../../context/ConnectWithOtpContext/constants.js';
|
|
|
75
76
|
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
76
77
|
import '@hcaptcha/react-hcaptcha';
|
|
77
78
|
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
79
|
+
import { useFooterAnimationContext } from '../../../context/FooterAnimationContext/index.js';
|
|
78
80
|
import { isUserLinkingWallet } from '../../../shared/utils/functions/isUserLinkingWallet/isUserLinkingWallet.js';
|
|
81
|
+
import { viewsThatPreventBorderBelowHeader, viewsWithWalletListType, viewsThatHideHelpContent, viewsThatHideHeader, viewsThatShowConnectedWalletProgress, viewsThatShowDynamicFooter } from '../../constants/authViewLayoutChecks.js';
|
|
79
82
|
import { useDynamicLayoutData } from '../useDynamicLayoutData/useDynamicLayoutData.js';
|
|
80
|
-
import { useFooterAnimationContext } from '../../../context/FooterAnimationContext/index.js';
|
|
81
83
|
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
82
84
|
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
83
85
|
import '../../../store/state/sendBalances.js';
|
|
@@ -96,67 +98,24 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
96
98
|
const useAuthLayoutChecks = () => {
|
|
97
99
|
var _a;
|
|
98
100
|
const { view } = useViewContext();
|
|
99
|
-
const {
|
|
101
|
+
const { customPrivacyPolicy, customTermsOfServices, privacyPolicyUrl, termsOfServiceUrl, isBridgeFlow, authMode, } = useInternalDynamicContext();
|
|
100
102
|
const { isFooterExpanded } = useFooterAnimationContext();
|
|
101
103
|
const { mockedSDK } = useMockContext();
|
|
102
104
|
const { helpHeaderData } = useDynamicLayoutData({
|
|
103
105
|
authMode,
|
|
104
106
|
view: view.type,
|
|
105
107
|
});
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const isWalletListTypeView = view.type === 'wallet-connect-mobile-wallets-list' ||
|
|
112
|
-
view.type === 'wallet-list' ||
|
|
113
|
-
view.type === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
114
|
-
view.type === 'login-with-wallet-only';
|
|
108
|
+
const user = useUserCoalesced();
|
|
109
|
+
const projectSettings = useProjectSettings();
|
|
110
|
+
const isLinkingWallet = isUserLinkingWallet(user, view.type, mockedSDK);
|
|
111
|
+
const displayBorderBelowHeader = !viewsThatPreventBorderBelowHeader.includes(view.type) || isFooterExpanded;
|
|
112
|
+
const isWalletListTypeView = viewsWithWalletListType.includes(view.type);
|
|
115
113
|
const showHelpContent = Boolean(helpHeaderData &&
|
|
116
|
-
|
|
117
|
-
!
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
view.type === 'wallet-sign' ||
|
|
122
|
-
view.type === 'collect-user-data' ||
|
|
123
|
-
view.type === 'passkey-new-domain-detected' ||
|
|
124
|
-
isUserLinkingWallet(user, view.type, mockedSDK)));
|
|
125
|
-
const showHeader = view.type !== 'collect-user-data' &&
|
|
126
|
-
view.type !== 'no-access' &&
|
|
127
|
-
view.type !== 'chainalysis-blocked-wallet' &&
|
|
128
|
-
view.type !== 'wallet-locked-view' &&
|
|
129
|
-
view.type !== 'gate-blocked-wallet' &&
|
|
130
|
-
view.type !== 'email-wallet-otp-verification-view' &&
|
|
131
|
-
view.type !== 'bridge-welcome' &&
|
|
132
|
-
view.type !== 'bridge-summary' &&
|
|
133
|
-
view.type !== 'bridge-next-wallet-connection' &&
|
|
134
|
-
view.type !== 'passkey-intro' &&
|
|
135
|
-
view.type !== 'passkey-new-domain-detected' &&
|
|
136
|
-
view.type !== 'social-redirect-view' &&
|
|
137
|
-
view.type !== 'collect-user-data-login-no-wallet' &&
|
|
138
|
-
view.type !== 'passkey-recovery-bundle' &&
|
|
139
|
-
view.type !== 'passkey-recovery-start' &&
|
|
140
|
-
view.type !== 'embedded-reveal-view' &&
|
|
141
|
-
view.type !== 'embedded-reveal-account-view' &&
|
|
142
|
-
view.type !== 'rename-passkey' &&
|
|
143
|
-
view.type !== 'embedded-wallet-auth-choice' &&
|
|
144
|
-
view.type !== 'passkey-recovery-add-email' &&
|
|
145
|
-
view.type !== 'global-wallet-confirm' &&
|
|
146
|
-
view.type !== 'global-wallet-malicious' &&
|
|
147
|
-
view.type !== 'global-wallet-info' &&
|
|
148
|
-
view.type !== 'mfa-choose-device' &&
|
|
149
|
-
view.type !== 'mfa-verification';
|
|
150
|
-
const showConnectedWalletProgress = isBridgeFlow &&
|
|
151
|
-
(view.type === 'wallet-list' ||
|
|
152
|
-
view.type === 'qr-code' ||
|
|
153
|
-
view.type === 'wallet-connect-mobile-wallets-list' ||
|
|
154
|
-
view.type === 'pending-connect' ||
|
|
155
|
-
view.type === 'pending-signature' ||
|
|
156
|
-
view.type === 'pending-signature-without-back-button' ||
|
|
157
|
-
view.type === 'bridge-next-wallet-connection' ||
|
|
158
|
-
view.type === 'bridge-summary');
|
|
159
|
-
const showToSFooter = Boolean(!isUserLinkingWallet(user, view.type, mockedSDK) &&
|
|
114
|
+
!viewsThatHideHelpContent.includes(view.type) &&
|
|
115
|
+
!isLinkingWallet);
|
|
116
|
+
const showHeader = !viewsThatHideHeader.includes(view.type);
|
|
117
|
+
const showConnectedWalletProgress = isBridgeFlow && viewsThatShowConnectedWalletProgress.includes(view.type);
|
|
118
|
+
const showToSFooter = Boolean(!isLinkingWallet &&
|
|
160
119
|
(view.type === 'wallet-list' ||
|
|
161
120
|
view.type === 'wallet-connect-mobile-wallets-list' ||
|
|
162
121
|
// Don't show empty footer during the login
|
|
@@ -169,44 +128,12 @@ const useAuthLayoutChecks = () => {
|
|
|
169
128
|
customPrivacyPolicy ||
|
|
170
129
|
customTermsOfServices))));
|
|
171
130
|
const showDynamicFooter = Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.displayDynamicMessaging) &&
|
|
172
|
-
(view.type
|
|
173
|
-
view.type === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
174
|
-
view.type === 'login-with-wallet-only' ||
|
|
175
|
-
view.type === 'login-with-email-verification' ||
|
|
176
|
-
view.type === 'login-with-sms-verification' ||
|
|
177
|
-
view.type === 'verify-email' ||
|
|
178
|
-
view.type === 'verify-sms' ||
|
|
179
|
-
view.type === 'pending-connect' ||
|
|
180
|
-
view.type === 'wallet-group' ||
|
|
181
|
-
view.type === 'select-wallet-in-wallet-group' ||
|
|
182
|
-
view.type === 'select-hardware-wallet' ||
|
|
183
|
-
view.type === 'pending-signature' ||
|
|
184
|
-
view.type === 'qr-code' ||
|
|
185
|
-
view.type === 'wallet-used' ||
|
|
186
|
-
view.type === 'email-wallet-otp-verification-view' ||
|
|
187
|
-
view.type === 'farcaster-connect-view' ||
|
|
188
|
-
view.type === 'merge-user-accounts' ||
|
|
189
|
-
view.type === 'merge-user-accounts-conflicts' ||
|
|
190
|
-
view.type === 'mfa-verification' ||
|
|
191
|
-
view.type === 'mfa-display-backup-codes' ||
|
|
192
|
-
view.type === 'mfa-recovery');
|
|
193
|
-
const showCloseButton = view.type !== 'login-with-email-or-wallet-full-wallet-list' &&
|
|
194
|
-
view.type !== 'login-with-email-verification' &&
|
|
195
|
-
view.type !== 'login-with-sms-verification' &&
|
|
196
|
-
view.type !== 'network-not-supported' &&
|
|
197
|
-
view.type !== 'passkey-recovery-complete' &&
|
|
198
|
-
view.type !== 'passkey-recovery-start' &&
|
|
199
|
-
view.type !== 'passkey-recovery-bundle' &&
|
|
200
|
-
view.type !== 'rename-passkey' &&
|
|
201
|
-
view.type !== 'mobile-wallet-redirect-view' &&
|
|
202
|
-
view.type !== 'qr-code' &&
|
|
203
|
-
view.type !== 'mfa-verification' &&
|
|
204
|
-
view.type !== 'mfa-display-backup-codes' &&
|
|
205
|
-
view.type !== 'mfa-recovery' &&
|
|
206
|
-
view.type !== 'user-delete-account';
|
|
131
|
+
viewsThatShowDynamicFooter.includes(view.type);
|
|
207
132
|
const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
|
|
208
133
|
const shouldHideDynamicFooterSeparator = showDynamicFooter && showToSFooter;
|
|
134
|
+
const { allowsClosing, showCloseButton } = useAllowClose();
|
|
209
135
|
return {
|
|
136
|
+
allowsClosing,
|
|
210
137
|
displayBorderBelowHeader,
|
|
211
138
|
isWalletListTypeView,
|
|
212
139
|
shouldHideDynamicFooterSeparator,
|
|
@@ -101,14 +101,15 @@ require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
101
101
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
102
102
|
|
|
103
103
|
const dynamicWaasKey = 'dynamicwaas';
|
|
104
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, }) => {
|
|
104
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, }) => {
|
|
105
105
|
walletConnector.setEnvironmentId(environmentId);
|
|
106
106
|
walletConnector.setBaseApiUrl(apiBaseUrl === null || apiBaseUrl === void 0 ? void 0 : apiBaseUrl.replace('/api/v0', ''));
|
|
107
107
|
walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
|
|
108
|
+
walletConnector.setRelayUrl(relayUrl);
|
|
108
109
|
return walletConnector;
|
|
109
110
|
};
|
|
110
111
|
const useDynamicWaas = () => {
|
|
111
|
-
var _a;
|
|
112
|
+
var _a, _b, _c;
|
|
112
113
|
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
113
114
|
const { user: user$1 } = user.useUser();
|
|
114
115
|
const apiBaseUrl = dynamicContextProps.useApiBaseUrl();
|
|
@@ -116,8 +117,9 @@ const useDynamicWaas = () => {
|
|
|
116
117
|
const environmentId = dynamicContextProps.useEnvironmentId();
|
|
117
118
|
const walletConnectorOptions = walletOptions.useWalletConnectorOptions();
|
|
118
119
|
const refresh = useRefreshUser.useRefreshUser();
|
|
120
|
+
const relayUrl = (_b = (_a = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
|
|
119
121
|
const embeddedWalletSettings = projectSettings$1 === null || projectSettings$1 === void 0 ? void 0 : projectSettings$1.sdk.embeddedWallets;
|
|
120
|
-
const enabledChains = (
|
|
122
|
+
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
121
123
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
122
124
|
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
123
125
|
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
@@ -142,6 +144,7 @@ const useDynamicWaas = () => {
|
|
|
142
144
|
apiBaseUrl,
|
|
143
145
|
authToken,
|
|
144
146
|
environmentId,
|
|
147
|
+
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
145
148
|
walletConnector,
|
|
146
149
|
});
|
|
147
150
|
return configuredWalletConnector;
|
|
@@ -198,7 +201,7 @@ const useDynamicWaas = () => {
|
|
|
198
201
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
199
202
|
walletConnectorOptions,
|
|
200
203
|
]);
|
|
201
|
-
const importPrivateKey = (
|
|
204
|
+
const importPrivateKey = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ chainName, privateKey, }) {
|
|
202
205
|
const walletConnector = getWalletConnector(chainName);
|
|
203
206
|
if (!walletConnector)
|
|
204
207
|
return;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
-
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, }: {
|
|
2
|
+
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, }: {
|
|
3
3
|
walletConnector: IDynamicWaasConnector;
|
|
4
4
|
environmentId: string;
|
|
5
5
|
apiBaseUrl: string;
|
|
6
6
|
authToken: string | undefined;
|
|
7
|
+
relayUrl: string;
|
|
7
8
|
}) => IDynamicWaasConnector;
|
|
8
9
|
export declare const useDynamicWaas: () => {
|
|
9
10
|
createWalletAccount: () => Promise<({
|
|
10
11
|
chainName: string;
|
|
11
12
|
accountAddress: string;
|
|
12
|
-
|
|
13
|
+
rawPublicKey: Uint8Array;
|
|
14
|
+
clientKeyShares: string[];
|
|
15
|
+
publicKeyHex?: string | undefined;
|
|
13
16
|
} | undefined)[]>;
|
|
14
17
|
dynamicWaasIsEnabled: boolean;
|
|
15
18
|
getWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
|
|
@@ -97,14 +97,15 @@ import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
97
97
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
98
98
|
|
|
99
99
|
const dynamicWaasKey = 'dynamicwaas';
|
|
100
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, }) => {
|
|
100
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, authToken, relayUrl, }) => {
|
|
101
101
|
walletConnector.setEnvironmentId(environmentId);
|
|
102
102
|
walletConnector.setBaseApiUrl(apiBaseUrl === null || apiBaseUrl === void 0 ? void 0 : apiBaseUrl.replace('/api/v0', ''));
|
|
103
103
|
walletConnector.setGetAuthTokenFunction(() => authToken !== null && authToken !== void 0 ? authToken : '');
|
|
104
|
+
walletConnector.setRelayUrl(relayUrl);
|
|
104
105
|
return walletConnector;
|
|
105
106
|
};
|
|
106
107
|
const useDynamicWaas = () => {
|
|
107
|
-
var _a;
|
|
108
|
+
var _a, _b, _c;
|
|
108
109
|
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
109
110
|
const { user } = useUser();
|
|
110
111
|
const apiBaseUrl = useApiBaseUrl();
|
|
@@ -112,8 +113,9 @@ const useDynamicWaas = () => {
|
|
|
112
113
|
const environmentId = useEnvironmentId();
|
|
113
114
|
const walletConnectorOptions = useWalletConnectorOptions();
|
|
114
115
|
const refresh = useRefreshUser();
|
|
116
|
+
const relayUrl = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.waas) === null || _b === void 0 ? void 0 : _b.relayUrl;
|
|
115
117
|
const embeddedWalletSettings = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets;
|
|
116
|
-
const enabledChains = (
|
|
118
|
+
const enabledChains = (_c = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.chainConfigurations) === null || _c === void 0 ? void 0 : _c.filter((c) => c.enabled);
|
|
117
119
|
const primaryChain = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.find((chain) => chain.primary);
|
|
118
120
|
const enabledChainNames = enabledChains === null || enabledChains === void 0 ? void 0 : enabledChains.map((chain) => chain.name);
|
|
119
121
|
const automaticEmbeddedWalletCreationEnabled = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.automaticEmbeddedWalletCreation;
|
|
@@ -138,6 +140,7 @@ const useDynamicWaas = () => {
|
|
|
138
140
|
apiBaseUrl,
|
|
139
141
|
authToken,
|
|
140
142
|
environmentId,
|
|
143
|
+
relayUrl: relayUrl !== null && relayUrl !== void 0 ? relayUrl : '',
|
|
141
144
|
walletConnector,
|
|
142
145
|
});
|
|
143
146
|
return configuredWalletConnector;
|
|
@@ -194,7 +197,7 @@ const useDynamicWaas = () => {
|
|
|
194
197
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
195
198
|
walletConnectorOptions,
|
|
196
199
|
]);
|
|
197
|
-
const importPrivateKey = (
|
|
200
|
+
const importPrivateKey = (_d) => __awaiter(void 0, [_d], void 0, function* ({ chainName, privateKey, }) {
|
|
198
201
|
const walletConnector = getWalletConnector(chainName);
|
|
199
202
|
if (!walletConnector)
|
|
200
203
|
return;
|
|
@@ -105,7 +105,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
105
105
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
106
106
|
return;
|
|
107
107
|
walletOptions.forEach((walletOption) => {
|
|
108
|
-
var _a, _b;
|
|
108
|
+
var _a, _b, _c, _d, _e;
|
|
109
109
|
if (walletConnectorCore.isSessionKeyCompatibleWalletConnector(walletOption.walletConnector)) {
|
|
110
110
|
(_a = walletOption.walletConnector) === null || _a === void 0 ? void 0 : _a.setSessionKeyFetcher(registerEmbeddedWalletSessionKey);
|
|
111
111
|
(_b = walletOption.walletConnector) === null || _b === void 0 ? void 0 : _b.setSessionKeyRemoveFunction(() => removeSessionKey());
|
|
@@ -115,6 +115,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
115
115
|
apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : DEFAULT_API_BASE_URL,
|
|
116
116
|
authToken,
|
|
117
117
|
environmentId,
|
|
118
|
+
relayUrl: (_e = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.waas) === null || _d === void 0 ? void 0 : _d.relayUrl) !== null && _e !== void 0 ? _e : '',
|
|
118
119
|
walletConnector: walletOption.walletConnector,
|
|
119
120
|
});
|
|
120
121
|
}
|
|
@@ -101,7 +101,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
101
101
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
102
102
|
return;
|
|
103
103
|
walletOptions.forEach((walletOption) => {
|
|
104
|
-
var _a, _b;
|
|
104
|
+
var _a, _b, _c, _d, _e;
|
|
105
105
|
if (isSessionKeyCompatibleWalletConnector(walletOption.walletConnector)) {
|
|
106
106
|
(_a = walletOption.walletConnector) === null || _a === void 0 ? void 0 : _a.setSessionKeyFetcher(registerEmbeddedWalletSessionKey);
|
|
107
107
|
(_b = walletOption.walletConnector) === null || _b === void 0 ? void 0 : _b.setSessionKeyRemoveFunction(() => removeSessionKey());
|
|
@@ -111,6 +111,7 @@ const useSetWalletConnectorFetchers = (walletOptions, environmentId, projectSett
|
|
|
111
111
|
apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : DEFAULT_API_BASE_URL,
|
|
112
112
|
authToken,
|
|
113
113
|
environmentId,
|
|
114
|
+
relayUrl: (_e = (_d = (_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.waas) === null || _d === void 0 ? void 0 : _d.relayUrl) !== null && _e !== void 0 ? _e : '',
|
|
114
115
|
walletConnector: walletOption.walletConnector,
|
|
115
116
|
});
|
|
116
117
|
}
|
|
@@ -103,7 +103,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
103
103
|
*/
|
|
104
104
|
const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
105
105
|
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
|
-
const { pushView } = ViewContext.useViewContext();
|
|
106
|
+
const { pushView, clearStackAndPush } = ViewContext.useViewContext();
|
|
107
107
|
const { getUserDevices } = useMfa.useMfa();
|
|
108
108
|
// this is used to make sure we only trigger the effect once
|
|
109
109
|
const triggered = React.useRef(false);
|
|
@@ -153,7 +153,7 @@ const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
|
-
|
|
156
|
+
clearStackAndPush('mfa-display-backup-codes');
|
|
157
157
|
}
|
|
158
158
|
}, [
|
|
159
159
|
getUserDevices,
|
|
@@ -162,6 +162,7 @@ const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
162
162
|
pushView,
|
|
163
163
|
userWithMissingInfo,
|
|
164
164
|
headlessHandler,
|
|
165
|
+
clearStackAndPush,
|
|
165
166
|
]);
|
|
166
167
|
};
|
|
167
168
|
|
|
@@ -99,7 +99,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
99
99
|
*/
|
|
100
100
|
const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
101
101
|
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext();
|
|
102
|
-
const { pushView } = useViewContext();
|
|
102
|
+
const { pushView, clearStackAndPush } = useViewContext();
|
|
103
103
|
const { getUserDevices } = useMfa();
|
|
104
104
|
// this is used to make sure we only trigger the effect once
|
|
105
105
|
const triggered = useRef(false);
|
|
@@ -149,7 +149,7 @@ const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
|
-
|
|
152
|
+
clearStackAndPush('mfa-display-backup-codes');
|
|
153
153
|
}
|
|
154
154
|
}, [
|
|
155
155
|
getUserDevices,
|
|
@@ -158,6 +158,7 @@ const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
158
158
|
pushView,
|
|
159
159
|
userWithMissingInfo,
|
|
160
160
|
headlessHandler,
|
|
161
|
+
clearStackAndPush,
|
|
161
162
|
]);
|
|
162
163
|
};
|
|
163
164
|
|
package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs
CHANGED
|
@@ -210,7 +210,12 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
210
210
|
const handleWalletItemClick = (wallet) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
211
211
|
const { walletConnector, isInstalledOnBrowser } = wallet;
|
|
212
212
|
const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
|
|
213
|
-
walletConnectorCore.isPhantomRedirectConnector(walletConnector)
|
|
213
|
+
walletConnectorCore.isPhantomRedirectConnector(walletConnector) ||
|
|
214
|
+
// because WC only supports one connection at a time,
|
|
215
|
+
// we need to end the session (disconnect) when the user selects
|
|
216
|
+
// a different wallet to connect with
|
|
217
|
+
// a new connection is established a few steps further down
|
|
218
|
+
walletConnectorCore.isWalletConnectConnector(walletConnector);
|
|
214
219
|
logger.logger.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
|
|
215
220
|
mockedSDK,
|
|
216
221
|
shouldEndWalletConnectorSession,
|
|
@@ -241,7 +246,8 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
241
246
|
}
|
|
242
247
|
if (!allowAlreadyConnectedWallet &&
|
|
243
248
|
isSelectedWalletAlreadyConnected.isSelectedWalletAlreadyConnected(linkedWallets, walletConnector, user) &&
|
|
244
|
-
walletConnector.connectedChain !== 'FLOW'
|
|
249
|
+
walletConnector.connectedChain !== 'FLOW' &&
|
|
250
|
+
!walletConnector.isWalletConnect) {
|
|
245
251
|
// wallet is already connected
|
|
246
252
|
handleAlreadyConnectedWallet(walletConnector);
|
|
247
253
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { StorageService, isMobile, UserRejectedRequestError } from '@dynamic-labs/utils';
|
|
4
|
-
import { isPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { isPhantomRedirectConnector, isWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import 'react';
|
|
6
6
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
7
7
|
import '@dynamic-labs/sdk-api-core';
|
|
@@ -206,7 +206,12 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
206
206
|
const handleWalletItemClick = (wallet) => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
207
|
const { walletConnector, isInstalledOnBrowser } = wallet;
|
|
208
208
|
const shouldEndWalletConnectorSession = walletConnector.connectedChain === 'FLOW' ||
|
|
209
|
-
isPhantomRedirectConnector(walletConnector)
|
|
209
|
+
isPhantomRedirectConnector(walletConnector) ||
|
|
210
|
+
// because WC only supports one connection at a time,
|
|
211
|
+
// we need to end the session (disconnect) when the user selects
|
|
212
|
+
// a different wallet to connect with
|
|
213
|
+
// a new connection is established a few steps further down
|
|
214
|
+
isWalletConnectConnector(walletConnector);
|
|
210
215
|
logger.logVerboseTroubleshootingMessage('[handleWalletItemClick]', {
|
|
211
216
|
mockedSDK,
|
|
212
217
|
shouldEndWalletConnectorSession,
|
|
@@ -237,7 +242,8 @@ const useHandleWalletItem = ({ allowAlreadyConnectedWallet, onQrCodeConnect, onC
|
|
|
237
242
|
}
|
|
238
243
|
if (!allowAlreadyConnectedWallet &&
|
|
239
244
|
isSelectedWalletAlreadyConnected(linkedWallets, walletConnector, user) &&
|
|
240
|
-
walletConnector.connectedChain !== 'FLOW'
|
|
245
|
+
walletConnector.connectedChain !== 'FLOW' &&
|
|
246
|
+
!walletConnector.isWalletConnect) {
|
|
241
247
|
// wallet is already connected
|
|
242
248
|
handleAlreadyConnectedWallet(walletConnector);
|
|
243
249
|
}
|
|
@@ -71,8 +71,8 @@ require('../../store/state/loadingAndLifecycle.cjs');
|
|
|
71
71
|
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
72
72
|
require('../../store/state/walletOptions/walletOptions.cjs');
|
|
73
73
|
var Typography = require('../../components/Typography/Typography.cjs');
|
|
74
|
-
var useIsTurnkeyWallet = require('../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
75
74
|
require('../../context/FooterAnimationContext/index.cjs');
|
|
75
|
+
var useIsTurnkeyWallet = require('../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
76
76
|
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
77
77
|
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
78
78
|
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
@@ -67,8 +67,8 @@ import '../../store/state/loadingAndLifecycle.js';
|
|
|
67
67
|
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
68
68
|
import '../../store/state/walletOptions/walletOptions.js';
|
|
69
69
|
import { Typography } from '../../components/Typography/Typography.js';
|
|
70
|
-
import { useIsTurnkeyWallet } from '../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
71
70
|
import '../../context/FooterAnimationContext/index.js';
|
|
71
|
+
import { useIsTurnkeyWallet } from '../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
72
72
|
import '../../components/ShadowDOM/ShadowDOM.js';
|
|
73
73
|
import '../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
74
74
|
import '../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
@@ -113,7 +113,10 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, }) => {
|
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
if (isInitialSetup) {
|
|
116
|
-
pushView('mfa-secure-device', {
|
|
116
|
+
pushView('mfa-secure-device', {
|
|
117
|
+
isInitialSetup: true,
|
|
118
|
+
type: option.type,
|
|
119
|
+
});
|
|
117
120
|
return;
|
|
118
121
|
}
|
|
119
122
|
pushView('mfa-verification', {
|
|
@@ -109,7 +109,10 @@ const MfaChooseDeviceView = ({ isInitialSetup = true, }) => {
|
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
if (isInitialSetup) {
|
|
112
|
-
pushView('mfa-secure-device', {
|
|
112
|
+
pushView('mfa-secure-device', {
|
|
113
|
+
isInitialSetup: true,
|
|
114
|
+
type: option.type,
|
|
115
|
+
});
|
|
113
116
|
return;
|
|
114
117
|
}
|
|
115
118
|
pushView('mfa-verification', {
|
|
@@ -117,13 +117,10 @@ const MfaSecureDeviceView = ({ type, isInitialSetup = false, }) => {
|
|
|
117
117
|
});
|
|
118
118
|
};
|
|
119
119
|
const onHelpClick = ({ secret, uri }) => {
|
|
120
|
-
const onMfaSecureDeviceHelpBackClick = () => {
|
|
121
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
122
|
-
};
|
|
123
120
|
pushView('mfa-secure-device-help', {
|
|
124
121
|
secret,
|
|
125
122
|
uri,
|
|
126
|
-
}
|
|
123
|
+
});
|
|
127
124
|
};
|
|
128
125
|
return (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsxRuntime.jsx(Typography.Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsxRuntime.jsx(spinner.Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxRuntime.jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsxRuntime.jsx(QRCode.QRCode, { Icon: jsxRuntime.jsx(passwordHero.ReactComponent, {}), value: data.uri, logoSize: 50 }), jsxRuntime.jsx("div", { className: 'button-container', children: jsxRuntime.jsx("button", { onClick: () => onHelpClick({ secret: data.secret, uri: data.uri }), children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', children: t('dyn_mfa.secure_device_view.helper.button') }) }) })] })), jsxRuntime.jsx(TypographyButton.TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') }), jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-secure-device-view__logout-button', onClick: handleLogOut, copykey: 'dyn_mfa.choose_device_view.logout', children: t('dyn_mfa.secure_device_view.logout') })] }));
|
|
129
126
|
};
|
|
@@ -113,13 +113,10 @@ const MfaSecureDeviceView = ({ type, isInitialSetup = false, }) => {
|
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
115
|
const onHelpClick = ({ secret, uri }) => {
|
|
116
|
-
const onMfaSecureDeviceHelpBackClick = () => {
|
|
117
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
118
|
-
};
|
|
119
116
|
pushView('mfa-secure-device-help', {
|
|
120
117
|
secret,
|
|
121
118
|
uri,
|
|
122
|
-
}
|
|
119
|
+
});
|
|
123
120
|
};
|
|
124
121
|
return (jsxs("div", { className: 'mfa-secure-device-view__body', "data-testid": 'mfa-secure-device-view', children: [jsx(Typography, { className: 'mfa-secure-device-view__copy', variant: 'body_normal', weight: 'regular', color: 'secondary', children: t('dyn_mfa.secure_device_view.body') }), isLoading && (jsx(Spinner, { className: 'mfa-secure-device-view__loading-spinner' })), data && (jsxs("div", { className: 'mfa-secure-device-view__qrcode', children: [jsx(QRCode, { Icon: jsx(SvgPasswordHero, {}), value: data.uri, logoSize: 50 }), jsx("div", { className: 'button-container', children: jsx("button", { onClick: () => onHelpClick({ secret: data.secret, uri: data.uri }), children: jsx(Typography, { variant: 'body_small', weight: 'medium', color: 'secondary', children: t('dyn_mfa.secure_device_view.helper.button') }) }) })] })), jsx(TypographyButton, { className: 'mfa-secure-device-view__button', expanded: true, onClick: onContinue, children: t('dyn_mfa.secure_device_view.continue') }), jsx(TextButton, { className: 'mfa-secure-device-view__logout-button', onClick: handleLogOut, copykey: 'dyn_mfa.choose_device_view.logout', children: t('dyn_mfa.secure_device_view.logout') })] }));
|
|
125
122
|
};
|
|
@@ -101,7 +101,7 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
101
101
|
|
|
102
102
|
const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = false, deviceId, }) => {
|
|
103
103
|
const { t } = reactI18next.useTranslation();
|
|
104
|
-
const { pushView } = ViewContext.useViewContext();
|
|
104
|
+
const { clearStackAndPush, pushView, goBack, canGoBack } = ViewContext.useViewContext();
|
|
105
105
|
const { authDevice } = useMfa.useMfa();
|
|
106
106
|
const [code, setCode] = React.useState('');
|
|
107
107
|
const [error, setError] = React.useState();
|
|
@@ -123,7 +123,7 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
123
123
|
const user$1 = user.getUser();
|
|
124
124
|
if ((user$1 === null || user$1 === void 0 ? void 0 : user$1.mfaBackupCodeAcknowledgement) !==
|
|
125
125
|
sdkApiCore.MfaBackupCodeAcknowledgement.Complete) {
|
|
126
|
-
|
|
126
|
+
clearStackAndPush('mfa-display-backup-codes');
|
|
127
127
|
}
|
|
128
128
|
}),
|
|
129
129
|
});
|
|
@@ -134,14 +134,8 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
134
134
|
const onSubmit = (code) => {
|
|
135
135
|
setCode(code);
|
|
136
136
|
};
|
|
137
|
-
const onClickBack =
|
|
138
|
-
|
|
139
|
-
pushView('mfa-choose-device', { isInitialSetup });
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
143
|
-
};
|
|
144
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { MainIcon: passwordHero.ReactComponent, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: showBackButton ? onClickBack : undefined, disabled: isRateLimited }), !isInitialSetup && (jsxRuntime.jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
137
|
+
const onClickBack = canGoBack && showBackButton ? goBack : undefined;
|
|
138
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { MainIcon: passwordHero.ReactComponent, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: onClickBack, disabled: isRateLimited }), !isInitialSetup && (jsxRuntime.jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsxRuntime.jsx(TextButton.TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
145
139
|
};
|
|
146
140
|
|
|
147
141
|
exports.MfaVerificationView = MfaVerificationView;
|
|
@@ -97,7 +97,7 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
97
97
|
|
|
98
98
|
const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = false, deviceId, }) => {
|
|
99
99
|
const { t } = useTranslation();
|
|
100
|
-
const { pushView } = useViewContext();
|
|
100
|
+
const { clearStackAndPush, pushView, goBack, canGoBack } = useViewContext();
|
|
101
101
|
const { authDevice } = useMfa();
|
|
102
102
|
const [code, setCode] = useState('');
|
|
103
103
|
const [error, setError] = useState();
|
|
@@ -119,7 +119,7 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
119
119
|
const user = getUser();
|
|
120
120
|
if ((user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) !==
|
|
121
121
|
MfaBackupCodeAcknowledgement.Complete) {
|
|
122
|
-
|
|
122
|
+
clearStackAndPush('mfa-display-backup-codes');
|
|
123
123
|
}
|
|
124
124
|
}),
|
|
125
125
|
});
|
|
@@ -130,14 +130,8 @@ const MfaVerificationView = ({ type, isInitialSetup = false, showBackButton = fa
|
|
|
130
130
|
const onSubmit = (code) => {
|
|
131
131
|
setCode(code);
|
|
132
132
|
};
|
|
133
|
-
const onClickBack =
|
|
134
|
-
|
|
135
|
-
pushView('mfa-choose-device', { isInitialSetup });
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
pushView('mfa-secure-device', { isInitialSetup, type });
|
|
139
|
-
};
|
|
140
|
-
return (jsxs(Fragment, { children: [jsx(OTPVerificationView, { MainIcon: SvgPasswordHero, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: showBackButton ? onClickBack : undefined, disabled: isRateLimited }), !isInitialSetup && (jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsx(TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
133
|
+
const onClickBack = canGoBack && showBackButton ? goBack : undefined;
|
|
134
|
+
return (jsxs(Fragment, { children: [jsx(OTPVerificationView, { MainIcon: SvgPasswordHero, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: Boolean(isValid), onPinChange: onCodeChange, description: t('dyn_mfa.otp_verification_view.body'), onClickBack: onClickBack, disabled: isRateLimited }), !isInitialSetup && (jsx("div", { className: 'mfa-verification-view__choose-another-method', children: jsx(TextButton, { className: 'mfa-verification-view__choose-another-method-button', onClick: () => pushView('mfa-choose-device', { isInitialSetup }), copykey: 'dyn_mfa.otp_verification_view.choose_another_method', children: t('dyn_mfa.otp_verification_view.choose_another_method') }) }))] }));
|
|
141
135
|
};
|
|
142
136
|
|
|
143
137
|
export { MfaVerificationView };
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs
CHANGED
|
@@ -102,12 +102,14 @@ var SandboxIndicatorWrapper = require('../../../components/SandboxIndicatorWrapp
|
|
|
102
102
|
|
|
103
103
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
104
104
|
const hide = useIsLoggedIn.useIsLoggedIn();
|
|
105
|
-
const { projectSettings,
|
|
106
|
-
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
105
|
+
const { projectSettings, setIsRenderingEmbeddedAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
107
106
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
108
|
-
React.useEffect(() =>
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
setIsRenderingEmbeddedAuthFlow(!hide);
|
|
109
|
+
return () => {
|
|
110
|
+
setIsRenderingEmbeddedAuthFlow(false);
|
|
111
|
+
};
|
|
112
|
+
}, [setIsRenderingEmbeddedAuthFlow, hide]);
|
|
111
113
|
if (hide)
|
|
112
114
|
return null;
|
|
113
115
|
const content = (jsxRuntime.jsx(DynamicAuthLayout.DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsxRuntime.jsx(RenderView.RenderView, {}) }));
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js
CHANGED
|
@@ -98,12 +98,14 @@ import { SandboxIndicatorWrapper } from '../../../components/SandboxIndicatorWra
|
|
|
98
98
|
|
|
99
99
|
const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) => {
|
|
100
100
|
const hide = useIsLoggedIn();
|
|
101
|
-
const { projectSettings,
|
|
102
|
-
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
101
|
+
const { projectSettings, setIsRenderingEmbeddedAuthFlow } = useInternalDynamicContext();
|
|
103
102
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
104
|
-
useEffect(() =>
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
setIsRenderingEmbeddedAuthFlow(!hide);
|
|
105
|
+
return () => {
|
|
106
|
+
setIsRenderingEmbeddedAuthFlow(false);
|
|
107
|
+
};
|
|
108
|
+
}, [setIsRenderingEmbeddedAuthFlow, hide]);
|
|
107
109
|
if (hide)
|
|
108
110
|
return null;
|
|
109
111
|
const content = (jsx(DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsx(RenderView, {}) }));
|