@dynamic-labs/sdk-react-core 4.9.2-preview.0 → 4.9.3
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 +28 -1
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -2
- package/src/index.js +2 -2
- 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/TosAndPp/TosAndPp.cjs +3 -1
- package/src/lib/components/TosAndPp/TosAndPp.js +3 -1
- 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/ErrorContext/hooks/useErrorText/useErrorText.cjs +1 -0
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.js +1 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +1 -0
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -0
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -0
- 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 +3 -2
- package/src/lib/locale/en/translation.d.ts +2 -1
- package/src/lib/locale/en/translation.js +3 -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/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +1 -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/useEmbeddedWallet/useEmbeddedWallet.cjs +8 -8
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +8 -8
- 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/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.cjs +1 -3
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.d.ts +1 -2
- package/src/lib/utils/hooks/useValidateSession/handleStoreAndEnvironmentMismatch/handleStoreAndEnvironmentMismatch.js +1 -3
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.cjs +3 -5
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.d.ts +1 -2
- package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.js +3 -5
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.cjs +37 -0
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.d.ts +9 -0
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/handleWalletInfoOutOfSync.js +33 -0
- package/src/lib/utils/hooks/useValidateSession/handleWalletInfoOutOfSync/index.d.ts +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +2 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +2 -0
- 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;
|
|
@@ -162,23 +162,23 @@ const useEmbeddedWallet = () => {
|
|
|
162
162
|
const shouldPromptForKeyExport = React.useCallback(() => { var _a; return Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.promptForKeyExport); }, [projectSettings]);
|
|
163
163
|
const embeddedWalletSettingVersion = React.useCallback(() => { var _a; return (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion; }, [projectSettings]);
|
|
164
164
|
const shouldAutoCreateEmbeddedWallet = React.useCallback((verifiedUser) => {
|
|
165
|
-
var _a, _b, _c, _d, _e
|
|
165
|
+
var _a, _b, _c, _d, _e;
|
|
166
166
|
const hasEmbeddedWalletProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
167
|
-
const defaultWalletVersion = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion;
|
|
168
167
|
const hasPrimaryWallet = primaryWalletId.getPrimaryWalletId();
|
|
169
|
-
if (
|
|
168
|
+
if (embeddedWalletSettingVersion() === sdkApiCore.EmbeddedWalletVersionEnum.V3 &&
|
|
169
|
+
!verifiedUser) {
|
|
170
170
|
return false;
|
|
171
171
|
}
|
|
172
172
|
if (!hasEmbeddedWalletProviderEnabled || hasPrimaryWallet) {
|
|
173
173
|
return false;
|
|
174
174
|
}
|
|
175
|
-
// Turnkey specific rules
|
|
175
|
+
// Turnkey and WAAS specific rules
|
|
176
176
|
if (verifiedUser) {
|
|
177
177
|
const primaryEmbeddedChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
178
|
-
const embeddedWalletVerifiedCredentialId = (
|
|
178
|
+
const embeddedWalletVerifiedCredentialId = (_a = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(verifiedUser, [
|
|
179
179
|
primaryEmbeddedChain,
|
|
180
|
-
])) === null ||
|
|
181
|
-
const AAWalletCredentialId = (
|
|
180
|
+
])) === null || _a === void 0 ? void 0 : _a.id;
|
|
181
|
+
const AAWalletCredentialId = (_c = (_b = verifiedUser.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((vc) => vc.walletProvider === sdkApiCore.WalletProviderEnum.SmartContractWallet)) === null || _c === void 0 ? void 0 : _c.id;
|
|
182
182
|
const targetPrimaryWalletId = AAWalletCredentialId
|
|
183
183
|
? AAWalletCredentialId
|
|
184
184
|
: embeddedWalletVerifiedCredentialId;
|
|
@@ -188,7 +188,7 @@ const useEmbeddedWallet = () => {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
if (isTurnkeyEnabled.isTurnkeyEnabled(projectSettings) &&
|
|
191
|
-
!((
|
|
191
|
+
!((_e = (_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.embeddedWallets) === null || _e === void 0 ? void 0 : _e.automaticEmbeddedWalletCreation)) {
|
|
192
192
|
return false;
|
|
193
193
|
}
|
|
194
194
|
return true;
|
|
@@ -158,23 +158,23 @@ const useEmbeddedWallet = () => {
|
|
|
158
158
|
const shouldPromptForKeyExport = useCallback(() => { var _a; return Boolean((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.promptForKeyExport); }, [projectSettings]);
|
|
159
159
|
const embeddedWalletSettingVersion = useCallback(() => { var _a; return (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion; }, [projectSettings]);
|
|
160
160
|
const shouldAutoCreateEmbeddedWallet = useCallback((verifiedUser) => {
|
|
161
|
-
var _a, _b, _c, _d, _e
|
|
161
|
+
var _a, _b, _c, _d, _e;
|
|
162
162
|
const hasEmbeddedWalletProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
163
|
-
const defaultWalletVersion = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _a === void 0 ? void 0 : _a.defaultWalletVersion;
|
|
164
163
|
const hasPrimaryWallet = getPrimaryWalletId();
|
|
165
|
-
if (
|
|
164
|
+
if (embeddedWalletSettingVersion() === EmbeddedWalletVersionEnum.V3 &&
|
|
165
|
+
!verifiedUser) {
|
|
166
166
|
return false;
|
|
167
167
|
}
|
|
168
168
|
if (!hasEmbeddedWalletProviderEnabled || hasPrimaryWallet) {
|
|
169
169
|
return false;
|
|
170
170
|
}
|
|
171
|
-
// Turnkey specific rules
|
|
171
|
+
// Turnkey and WAAS specific rules
|
|
172
172
|
if (verifiedUser) {
|
|
173
173
|
const primaryEmbeddedChain = findPrimaryEmbeddedChain(projectSettings);
|
|
174
|
-
const embeddedWalletVerifiedCredentialId = (
|
|
174
|
+
const embeddedWalletVerifiedCredentialId = (_a = findEmbeddedWalletFromVerifiedCredentials(verifiedUser, [
|
|
175
175
|
primaryEmbeddedChain,
|
|
176
|
-
])) === null ||
|
|
177
|
-
const AAWalletCredentialId = (
|
|
176
|
+
])) === null || _a === void 0 ? void 0 : _a.id;
|
|
177
|
+
const AAWalletCredentialId = (_c = (_b = verifiedUser.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find((vc) => vc.walletProvider === WalletProviderEnum.SmartContractWallet)) === null || _c === void 0 ? void 0 : _c.id;
|
|
178
178
|
const targetPrimaryWalletId = AAWalletCredentialId
|
|
179
179
|
? AAWalletCredentialId
|
|
180
180
|
: embeddedWalletVerifiedCredentialId;
|
|
@@ -184,7 +184,7 @@ const useEmbeddedWallet = () => {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
if (isTurnkeyEnabled(projectSettings) &&
|
|
187
|
-
!((
|
|
187
|
+
!((_e = (_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.embeddedWallets) === null || _e === void 0 ? void 0 : _e.automaticEmbeddedWalletCreation)) {
|
|
188
188
|
return false;
|
|
189
189
|
}
|
|
190
190
|
return true;
|
|
@@ -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
|
|
|
@@ -8,19 +8,17 @@ var dynamicContextProps = require('../../../../store/state/dynamicContextProps/d
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Detects envId mismtach with store.
|
|
11
|
-
* @returns true if there is no mismatch.
|
|
12
11
|
*/
|
|
13
12
|
const handleStoreAndEnvironmentMismatch = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, logout, }) {
|
|
14
13
|
const storeEnvId = dynamicContextProps.getEnvironmentId();
|
|
15
14
|
if (!storeEnvId || environmentId === storeEnvId) {
|
|
16
|
-
return
|
|
15
|
+
return;
|
|
17
16
|
}
|
|
18
17
|
yield logout('store and environment are out of sync', {
|
|
19
18
|
currentEnvId: environmentId,
|
|
20
19
|
storedEnvId: storeEnvId,
|
|
21
20
|
});
|
|
22
21
|
dynamicContextProps.setEnvironmentId(environmentId);
|
|
23
|
-
return false;
|
|
24
22
|
});
|
|
25
23
|
|
|
26
24
|
exports.handleStoreAndEnvironmentMismatch = handleStoreAndEnvironmentMismatch;
|
|
@@ -4,6 +4,5 @@ export type HandleStoreAndEnvironmentMismatchParams = {
|
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
6
|
* Detects envId mismtach with store.
|
|
7
|
-
* @returns true if there is no mismatch.
|
|
8
7
|
*/
|
|
9
|
-
export declare const handleStoreAndEnvironmentMismatch: ({ environmentId, logout, }: HandleStoreAndEnvironmentMismatchParams) => Promise<
|
|
8
|
+
export declare const handleStoreAndEnvironmentMismatch: ({ environmentId, logout, }: HandleStoreAndEnvironmentMismatchParams) => Promise<void>;
|
|
@@ -4,19 +4,17 @@ import { getEnvironmentId, setEnvironmentId } from '../../../../store/state/dyna
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Detects envId mismtach with store.
|
|
7
|
-
* @returns true if there is no mismatch.
|
|
8
7
|
*/
|
|
9
8
|
const handleStoreAndEnvironmentMismatch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, logout, }) {
|
|
10
9
|
const storeEnvId = getEnvironmentId();
|
|
11
10
|
if (!storeEnvId || environmentId === storeEnvId) {
|
|
12
|
-
return
|
|
11
|
+
return;
|
|
13
12
|
}
|
|
14
13
|
yield logout('store and environment are out of sync', {
|
|
15
14
|
currentEnvId: environmentId,
|
|
16
15
|
storedEnvId: storeEnvId,
|
|
17
16
|
});
|
|
18
17
|
setEnvironmentId(environmentId);
|
|
19
|
-
return false;
|
|
20
18
|
});
|
|
21
19
|
|
|
22
20
|
export { handleStoreAndEnvironmentMismatch };
|
package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.cjs
CHANGED
|
@@ -14,14 +14,13 @@ var getAuthToken = require('../../../functions/getAuthToken/getAuthToken.cjs');
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Detects mismatch between user and auth token.
|
|
17
|
-
* @returns true if there is no mismatch.
|
|
18
17
|
*/
|
|
19
18
|
const handleUserDataOutOfSync = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, logout, projectSettings, }) {
|
|
20
19
|
const cookieEnabled = isCookieEnabled.isCookieEnabled(projectSettings);
|
|
21
20
|
const authToken = getAuthToken.getAuthToken();
|
|
22
21
|
const user$2 = user.getUser();
|
|
23
22
|
if (authToken || !user$2) {
|
|
24
|
-
return
|
|
23
|
+
return;
|
|
25
24
|
}
|
|
26
25
|
if (user$2 && !authToken && cookieEnabled) {
|
|
27
26
|
try {
|
|
@@ -33,16 +32,15 @@ const handleUserDataOutOfSync = (_a) => _tslib.__awaiter(void 0, [_a], void 0, f
|
|
|
33
32
|
authToken,
|
|
34
33
|
user: user$2,
|
|
35
34
|
});
|
|
36
|
-
return
|
|
35
|
+
return;
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
return
|
|
38
|
+
return;
|
|
40
39
|
}
|
|
41
40
|
yield logout('user data out of sync', {
|
|
42
41
|
authToken,
|
|
43
42
|
user: user$2,
|
|
44
43
|
});
|
|
45
|
-
return false;
|
|
46
44
|
});
|
|
47
45
|
|
|
48
46
|
exports.handleUserDataOutOfSync = handleUserDataOutOfSync;
|
package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ export type HandleUserDataOutOfSyncParams = {
|
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Detects mismatch between user and auth token.
|
|
9
|
-
* @returns true if there is no mismatch.
|
|
10
9
|
*/
|
|
11
|
-
export declare const handleUserDataOutOfSync: ({ environmentId, logout, projectSettings, }: HandleUserDataOutOfSyncParams) => Promise<
|
|
10
|
+
export declare const handleUserDataOutOfSync: ({ environmentId, logout, projectSettings, }: HandleUserDataOutOfSyncParams) => Promise<void>;
|
package/src/lib/utils/hooks/useValidateSession/handleUserDataOutOfSync/handleUserDataOutOfSync.js
CHANGED
|
@@ -10,14 +10,13 @@ import { getAuthToken } from '../../../functions/getAuthToken/getAuthToken.js';
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Detects mismatch between user and auth token.
|
|
13
|
-
* @returns true if there is no mismatch.
|
|
14
13
|
*/
|
|
15
14
|
const handleUserDataOutOfSync = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, logout, projectSettings, }) {
|
|
16
15
|
const cookieEnabled = isCookieEnabled(projectSettings);
|
|
17
16
|
const authToken = getAuthToken();
|
|
18
17
|
const user = getUser();
|
|
19
18
|
if (authToken || !user) {
|
|
20
|
-
return
|
|
19
|
+
return;
|
|
21
20
|
}
|
|
22
21
|
if (user && !authToken && cookieEnabled) {
|
|
23
22
|
try {
|
|
@@ -29,16 +28,15 @@ const handleUserDataOutOfSync = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
29
28
|
authToken,
|
|
30
29
|
user,
|
|
31
30
|
});
|
|
32
|
-
return
|
|
31
|
+
return;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
return
|
|
34
|
+
return;
|
|
36
35
|
}
|
|
37
36
|
yield logout('user data out of sync', {
|
|
38
37
|
authToken,
|
|
39
38
|
user,
|
|
40
39
|
});
|
|
41
|
-
return false;
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
export { handleUserDataOutOfSync };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var user = require('../../../../store/state/user/user.cjs');
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
9
|
+
require('../../../constants/values.cjs');
|
|
10
|
+
require('@dynamic-labs/sdk-api-core');
|
|
11
|
+
require('../../../../store/state/projectSettings/projectSettings.cjs');
|
|
12
|
+
var primaryWalletId = require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
13
|
+
var connectedWalletsInfo = require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Detects mismatch between wallet info.
|
|
17
|
+
* If there is primary wallet id, but no user or connected wallets info,
|
|
18
|
+
* it means it's in a bad state and we should log out.
|
|
19
|
+
*/
|
|
20
|
+
const handleWalletInfoOutOfSync = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ logout, }) {
|
|
21
|
+
const primaryWalletId$1 = primaryWalletId.getPrimaryWalletId();
|
|
22
|
+
if (!primaryWalletId$1) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const user$1 = user.getUser();
|
|
26
|
+
const connectedWallets = connectedWalletsInfo.getConnectedWalletsInfo();
|
|
27
|
+
if (user$1 || connectedWallets.length > 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
yield logout('wallet info is out of sync', {
|
|
31
|
+
connectedWallets,
|
|
32
|
+
primaryWalletId: primaryWalletId$1,
|
|
33
|
+
user: user$1,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.handleWalletInfoOutOfSync = handleWalletInfoOutOfSync;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type HandleWalletInfoOutOfSyncParams = {
|
|
2
|
+
logout: (reason: string, params: any) => Promise<void>;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Detects mismatch between wallet info.
|
|
6
|
+
* If there is primary wallet id, but no user or connected wallets info,
|
|
7
|
+
* it means it's in a bad state and we should log out.
|
|
8
|
+
*/
|
|
9
|
+
export declare const handleWalletInfoOutOfSync: ({ logout, }: HandleWalletInfoOutOfSyncParams) => Promise<void>;
|