@dynamic-labs/sdk-react-core 3.0.0-alpha.32 → 3.0.0-alpha.34
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 +9 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +2 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +2 -2
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.cjs +2 -0
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.js +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -11
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -11
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -2
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +3 -3
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +3 -3
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +5 -6
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +5 -6
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +1 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +2 -2
- package/src/lib/data/api/embeddedWallets/types.d.ts +2 -2
- package/src/lib/data/api/externalAuth/externalAuth.cjs +20 -0
- package/src/lib/data/api/externalAuth/externalAuth.d.ts +4 -0
- package/src/lib/data/api/externalAuth/externalAuth.js +20 -1
- package/src/lib/events/auth.d.ts +12 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs +14 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.d.ts +2 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js +10 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/index.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.cjs +24 -6
- package/src/lib/store/hooks/useUser/useUser.d.ts +6 -3
- package/src/lib/store/hooks/useUser/useUser.js +24 -6
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +1 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +3 -3
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +3 -3
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs +2 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.js +2 -0
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +2 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +2 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +3 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.d.ts +2 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +4 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.d.ts +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.d.ts +2 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +30 -1
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.d.ts +1 -0
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +31 -2
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +8 -28
- package/src/lib/utils/hooks/useMfa/useMfa.d.ts +1 -7
- package/src/lib/utils/hooks/useMfa/useMfa.js +8 -28
- package/src/lib/utils/hooks/useResetCookieLocalStorage/index.d.ts +1 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +143 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.d.ts +8 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +139 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +152 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.d.ts +4 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +148 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +9 -7
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +9 -7
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +8 -14
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +8 -14
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +3 -3
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +4 -4
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +4 -4
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -3
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +3 -3
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +2 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.d.ts +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +3 -3
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +3 -3
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/index.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.cjs +0 -8
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.d.ts +0 -2
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.js +0 -4
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
8
|
+
require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
require('../../../shared/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../constants/values.cjs');
|
|
17
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
19
|
+
var hasPendingMfaAction = require('../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
|
|
20
|
+
require('@dynamic-labs/utils');
|
|
21
|
+
require('../../../shared/consts/index.cjs');
|
|
22
|
+
require('../../../events/dynamicEvents.cjs');
|
|
23
|
+
require('../../../../../_virtual/_tslib.cjs');
|
|
24
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
25
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
26
|
+
require('@dynamic-labs/multi-wallet');
|
|
27
|
+
require('react-international-phone');
|
|
28
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
29
|
+
require('@dynamic-labs/store');
|
|
30
|
+
require('../../../locale/locale.cjs');
|
|
31
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
33
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
34
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
35
|
+
require('react-dom');
|
|
36
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
37
|
+
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
38
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
39
|
+
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
40
|
+
require('@dynamic-labs/types');
|
|
41
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
42
|
+
require('yup');
|
|
43
|
+
require('../../../context/MockContext/MockContext.cjs');
|
|
44
|
+
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
45
|
+
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
46
|
+
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
47
|
+
require('@dynamic-labs/rpc-providers');
|
|
48
|
+
require('react-i18next');
|
|
49
|
+
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
50
|
+
require('../../../components/Alert/Alert.cjs');
|
|
51
|
+
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
52
|
+
require('../../../components/IconButton/IconButton.cjs');
|
|
53
|
+
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
54
|
+
require('../../../components/Input/Input.cjs');
|
|
55
|
+
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
56
|
+
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
57
|
+
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
58
|
+
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
59
|
+
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
60
|
+
require('../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
61
|
+
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
62
|
+
require('../../../components/Popper/Popper/Popper.cjs');
|
|
63
|
+
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
64
|
+
require('react-focus-lock');
|
|
65
|
+
require('qrcode');
|
|
66
|
+
require('formik');
|
|
67
|
+
require('../../../views/WalletList/WalletList.cjs');
|
|
68
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
69
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
70
|
+
require('@hcaptcha/react-hcaptcha');
|
|
71
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
72
|
+
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
73
|
+
var useMfa = require('../useMfa/useMfa.cjs');
|
|
74
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
75
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
76
|
+
require('../../../context/MfaSettingsContext/MfaSettingsContext.cjs');
|
|
77
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
78
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
79
|
+
require('../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
80
|
+
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
81
|
+
require('../../../../polyfills.cjs');
|
|
82
|
+
require('../../../context/ErrorBoundary/ErrorBoundaryBase.cjs');
|
|
83
|
+
require('../../../context/ErrorBoundary/ErrorBoundaryContext.cjs');
|
|
84
|
+
require('../../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.cjs');
|
|
85
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCard.cjs');
|
|
86
|
+
require('../../../context/WidgetRegistry/WidgetRegistryContextProvider.cjs');
|
|
87
|
+
require('../../../context/FundingContext/FundingContext.cjs');
|
|
88
|
+
require('../../../context/SendBalanceContext/SendBalanceContext.cjs');
|
|
89
|
+
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
90
|
+
require('../../../context/ConnectWithOtpContext/constants.cjs');
|
|
91
|
+
require('../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
92
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* This hook is used to ensure we show the correct MFA view on page refresh
|
|
96
|
+
*/
|
|
97
|
+
const useSyncMfaFlow = () => {
|
|
98
|
+
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext.useInternalDynamicContext();
|
|
99
|
+
const { setView } = ViewContext.useViewContext();
|
|
100
|
+
const { getUserDevices } = useMfa.useMfa();
|
|
101
|
+
// this is used to make sure we only trigger the effect once
|
|
102
|
+
const triggered = React.useRef(false);
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
var _a;
|
|
105
|
+
// boilterplate: we don't want to run the sync logic if the sdk hasn't finished loading,
|
|
106
|
+
// or if the effect has already been triggered
|
|
107
|
+
if (!sdkHasLoaded || triggered.current) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// this is the case when the user has fully logged in and completed all mfa steps if needed,
|
|
111
|
+
// like accepting their backup codes after enrolling
|
|
112
|
+
if (!userWithMissingInfo || !hasPendingMfaAction.hasPendingMfaAction(userWithMissingInfo)) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
triggered.current = true;
|
|
116
|
+
/**
|
|
117
|
+
* There are two scenarios:
|
|
118
|
+
* 1. The user has not yet completed mfa
|
|
119
|
+
* 2. The user has completed mfa, but has not yet acknowledged their backup codes
|
|
120
|
+
*
|
|
121
|
+
* In scenario 1, the user scope will contain 'requiresAdditionalAuth'. In this case, we need
|
|
122
|
+
* to show the enrollment view or verification view, depending on whether the user has devices
|
|
123
|
+
*
|
|
124
|
+
* In scenario 2, the user scope will not contain 'requiresAdditionalAuth', and the user
|
|
125
|
+
* mfaBackupCodeAcknowledgement field will be 'pending'. In this case, we need to show the
|
|
126
|
+
* backup codes view
|
|
127
|
+
*/
|
|
128
|
+
setShowAuthFlow(true);
|
|
129
|
+
if ((_a = userWithMissingInfo.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) {
|
|
130
|
+
getUserDevices().then((devices) => {
|
|
131
|
+
if (devices.length === 0) {
|
|
132
|
+
setView('mfa-choose-device');
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
setView('mfa-verification');
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
setView('mfa-display-backup-codes');
|
|
141
|
+
}
|
|
142
|
+
// TODO: Add / call handler for customers using headless
|
|
143
|
+
}, [
|
|
144
|
+
getUserDevices,
|
|
145
|
+
sdkHasLoaded,
|
|
146
|
+
setShowAuthFlow,
|
|
147
|
+
setView,
|
|
148
|
+
userWithMissingInfo,
|
|
149
|
+
]);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
exports.useSyncMfaFlow = useSyncMfaFlow;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import '../../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
15
|
+
import { hasPendingMfaAction } from '../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
|
|
16
|
+
import '@dynamic-labs/utils';
|
|
17
|
+
import '../../../shared/consts/index.js';
|
|
18
|
+
import '../../../events/dynamicEvents.js';
|
|
19
|
+
import '../../../../../_virtual/_tslib.js';
|
|
20
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
21
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
22
|
+
import '@dynamic-labs/multi-wallet';
|
|
23
|
+
import 'react-international-phone';
|
|
24
|
+
import '../../../config/ApiEndpoint.js';
|
|
25
|
+
import '@dynamic-labs/store';
|
|
26
|
+
import '../../../locale/locale.js';
|
|
27
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
28
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
29
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
31
|
+
import 'react-dom';
|
|
32
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
33
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
34
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
35
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
36
|
+
import '@dynamic-labs/types';
|
|
37
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
38
|
+
import 'yup';
|
|
39
|
+
import '../../../context/MockContext/MockContext.js';
|
|
40
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
41
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
42
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
43
|
+
import '@dynamic-labs/rpc-providers';
|
|
44
|
+
import 'react-i18next';
|
|
45
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
46
|
+
import '../../../components/Alert/Alert.js';
|
|
47
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
48
|
+
import '../../../components/IconButton/IconButton.js';
|
|
49
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
50
|
+
import '../../../components/Input/Input.js';
|
|
51
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
52
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
53
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
54
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
55
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
56
|
+
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
57
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
58
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
59
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
60
|
+
import 'react-focus-lock';
|
|
61
|
+
import 'qrcode';
|
|
62
|
+
import 'formik';
|
|
63
|
+
import '../../../views/WalletList/WalletList.js';
|
|
64
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
65
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
66
|
+
import '@hcaptcha/react-hcaptcha';
|
|
67
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
68
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
69
|
+
import { useMfa } from '../useMfa/useMfa.js';
|
|
70
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
71
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
72
|
+
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
73
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
74
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
75
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
76
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
77
|
+
import '../../../../polyfills.js';
|
|
78
|
+
import '../../../context/ErrorBoundary/ErrorBoundaryBase.js';
|
|
79
|
+
import '../../../context/ErrorBoundary/ErrorBoundaryContext.js';
|
|
80
|
+
import '../../../widgets/DynamicBridgeWidget/context/DynamicBridgeWidgetContext/DynamicBridgeWidgetContext.js';
|
|
81
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetCard/DynamicWidgetCard.js';
|
|
82
|
+
import '../../../context/WidgetRegistry/WidgetRegistryContextProvider.js';
|
|
83
|
+
import '../../../context/FundingContext/FundingContext.js';
|
|
84
|
+
import '../../../context/SendBalanceContext/SendBalanceContext.js';
|
|
85
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
86
|
+
import '../../../context/ConnectWithOtpContext/constants.js';
|
|
87
|
+
import '../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
88
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* This hook is used to ensure we show the correct MFA view on page refresh
|
|
92
|
+
*/
|
|
93
|
+
const useSyncMfaFlow = () => {
|
|
94
|
+
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext();
|
|
95
|
+
const { setView } = useViewContext();
|
|
96
|
+
const { getUserDevices } = useMfa();
|
|
97
|
+
// this is used to make sure we only trigger the effect once
|
|
98
|
+
const triggered = useRef(false);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
var _a;
|
|
101
|
+
// boilterplate: we don't want to run the sync logic if the sdk hasn't finished loading,
|
|
102
|
+
// or if the effect has already been triggered
|
|
103
|
+
if (!sdkHasLoaded || triggered.current) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// this is the case when the user has fully logged in and completed all mfa steps if needed,
|
|
107
|
+
// like accepting their backup codes after enrolling
|
|
108
|
+
if (!userWithMissingInfo || !hasPendingMfaAction(userWithMissingInfo)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
triggered.current = true;
|
|
112
|
+
/**
|
|
113
|
+
* There are two scenarios:
|
|
114
|
+
* 1. The user has not yet completed mfa
|
|
115
|
+
* 2. The user has completed mfa, but has not yet acknowledged their backup codes
|
|
116
|
+
*
|
|
117
|
+
* In scenario 1, the user scope will contain 'requiresAdditionalAuth'. In this case, we need
|
|
118
|
+
* to show the enrollment view or verification view, depending on whether the user has devices
|
|
119
|
+
*
|
|
120
|
+
* In scenario 2, the user scope will not contain 'requiresAdditionalAuth', and the user
|
|
121
|
+
* mfaBackupCodeAcknowledgement field will be 'pending'. In this case, we need to show the
|
|
122
|
+
* backup codes view
|
|
123
|
+
*/
|
|
124
|
+
setShowAuthFlow(true);
|
|
125
|
+
if ((_a = userWithMissingInfo.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) {
|
|
126
|
+
getUserDevices().then((devices) => {
|
|
127
|
+
if (devices.length === 0) {
|
|
128
|
+
setView('mfa-choose-device');
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
setView('mfa-verification');
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
setView('mfa-display-backup-codes');
|
|
137
|
+
}
|
|
138
|
+
// TODO: Add / call handler for customers using headless
|
|
139
|
+
}, [
|
|
140
|
+
getUserDevices,
|
|
141
|
+
sdkHasLoaded,
|
|
142
|
+
setShowAuthFlow,
|
|
143
|
+
setView,
|
|
144
|
+
userWithMissingInfo,
|
|
145
|
+
]);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export { useSyncMfaFlow };
|
|
@@ -18,6 +18,7 @@ require('../../constants/colors.cjs');
|
|
|
18
18
|
require('../../constants/values.cjs');
|
|
19
19
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
20
|
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
21
|
+
var hasPendingMfaAction = require('../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
|
|
21
22
|
require('@dynamic-labs/utils');
|
|
22
23
|
require('../../../shared/consts/index.cjs');
|
|
23
24
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -93,7 +94,7 @@ require('../../../context/ReinitializeContext/ReinitializeContextProvider.cjs');
|
|
|
93
94
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
94
95
|
|
|
95
96
|
const useSyncOnboardingFlow = () => {
|
|
96
|
-
const { setShowAuthFlow,
|
|
97
|
+
const { setShowAuthFlow, userWithMissingInfo, handlers, headless, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
97
98
|
const { setView } = ViewContext.useViewContext();
|
|
98
99
|
const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
|
|
99
100
|
validationSchemaStripUnknown: false,
|
|
@@ -113,12 +114,12 @@ const useSyncOnboardingFlow = () => {
|
|
|
113
114
|
const handleHeadlessOnboarding = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
114
115
|
var _b;
|
|
115
116
|
if (!(handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) ||
|
|
116
|
-
!((_b =
|
|
117
|
+
!((_b = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
triggeredOnboarding.current = true;
|
|
120
121
|
try {
|
|
121
|
-
const missingFieldsRequestInput =
|
|
122
|
+
const missingFieldsRequestInput = userWithMissingInfo.missingFields.map((field) => ({
|
|
122
123
|
isCustom: field.type === 'custom',
|
|
123
124
|
key: field.name,
|
|
124
125
|
label: field.label,
|
|
@@ -126,7 +127,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
126
127
|
}));
|
|
127
128
|
const onboardingResponse = yield handlers.handleUserOnboarding(missingFieldsRequestInput);
|
|
128
129
|
const userFields = {};
|
|
129
|
-
const customFields = Object.assign({},
|
|
130
|
+
const customFields = Object.assign({}, userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata);
|
|
130
131
|
onboardingResponse.forEach((field) => {
|
|
131
132
|
if (field.isCustom) {
|
|
132
133
|
customFields[field.key] = field.value;
|
|
@@ -147,7 +148,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
147
148
|
const handleOnboarding = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
149
|
triggeredOnboarding.current = true;
|
|
149
150
|
setShowAuthFlow(true);
|
|
150
|
-
const lastVerifiedCredential =
|
|
151
|
+
const lastVerifiedCredential = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.verifiedCredentials.find((vc) => vc.id === (userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.lastVerifiedCredentialId));
|
|
151
152
|
if (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName) {
|
|
152
153
|
setSelectedWalletConnectorKey(lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName);
|
|
153
154
|
}
|
|
@@ -170,7 +171,8 @@ const useSyncOnboardingFlow = () => {
|
|
|
170
171
|
});
|
|
171
172
|
if (!sdkHasLoaded ||
|
|
172
173
|
triggeredOnboarding.current ||
|
|
173
|
-
!((_a =
|
|
174
|
+
!((_a = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
175
|
+
hasPendingMfaAction.hasPendingMfaAction(userWithMissingInfo)) {
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
176
178
|
if (handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) {
|
|
@@ -185,7 +187,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
185
187
|
return;
|
|
186
188
|
}, [
|
|
187
189
|
sdkHasLoaded,
|
|
188
|
-
|
|
190
|
+
userWithMissingInfo,
|
|
189
191
|
handlers,
|
|
190
192
|
completeAuth,
|
|
191
193
|
updateUser,
|
|
@@ -14,6 +14,7 @@ import '../../constants/colors.js';
|
|
|
14
14
|
import '../../constants/values.js';
|
|
15
15
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
16
16
|
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
17
|
+
import { hasPendingMfaAction } from '../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
|
|
17
18
|
import '@dynamic-labs/utils';
|
|
18
19
|
import '../../../shared/consts/index.js';
|
|
19
20
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -89,7 +90,7 @@ import '../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
|
89
90
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
90
91
|
|
|
91
92
|
const useSyncOnboardingFlow = () => {
|
|
92
|
-
const { setShowAuthFlow,
|
|
93
|
+
const { setShowAuthFlow, userWithMissingInfo, handlers, headless, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext();
|
|
93
94
|
const { setView } = useViewContext();
|
|
94
95
|
const { updateUser } = useUserUpdateRequestInternal({
|
|
95
96
|
validationSchemaStripUnknown: false,
|
|
@@ -109,12 +110,12 @@ const useSyncOnboardingFlow = () => {
|
|
|
109
110
|
const handleHeadlessOnboarding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
111
|
var _b;
|
|
111
112
|
if (!(handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) ||
|
|
112
|
-
!((_b =
|
|
113
|
+
!((_b = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
116
|
triggeredOnboarding.current = true;
|
|
116
117
|
try {
|
|
117
|
-
const missingFieldsRequestInput =
|
|
118
|
+
const missingFieldsRequestInput = userWithMissingInfo.missingFields.map((field) => ({
|
|
118
119
|
isCustom: field.type === 'custom',
|
|
119
120
|
key: field.name,
|
|
120
121
|
label: field.label,
|
|
@@ -122,7 +123,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
122
123
|
}));
|
|
123
124
|
const onboardingResponse = yield handlers.handleUserOnboarding(missingFieldsRequestInput);
|
|
124
125
|
const userFields = {};
|
|
125
|
-
const customFields = Object.assign({},
|
|
126
|
+
const customFields = Object.assign({}, userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata);
|
|
126
127
|
onboardingResponse.forEach((field) => {
|
|
127
128
|
if (field.isCustom) {
|
|
128
129
|
customFields[field.key] = field.value;
|
|
@@ -143,7 +144,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
143
144
|
const handleOnboarding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
145
|
triggeredOnboarding.current = true;
|
|
145
146
|
setShowAuthFlow(true);
|
|
146
|
-
const lastVerifiedCredential =
|
|
147
|
+
const lastVerifiedCredential = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.verifiedCredentials.find((vc) => vc.id === (userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.lastVerifiedCredentialId));
|
|
147
148
|
if (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName) {
|
|
148
149
|
setSelectedWalletConnectorKey(lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName);
|
|
149
150
|
}
|
|
@@ -166,7 +167,8 @@ const useSyncOnboardingFlow = () => {
|
|
|
166
167
|
});
|
|
167
168
|
if (!sdkHasLoaded ||
|
|
168
169
|
triggeredOnboarding.current ||
|
|
169
|
-
!((_a =
|
|
170
|
+
!((_a = userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.missingFields) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
171
|
+
hasPendingMfaAction(userWithMissingInfo)) {
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
174
|
if (handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) {
|
|
@@ -181,7 +183,7 @@ const useSyncOnboardingFlow = () => {
|
|
|
181
183
|
return;
|
|
182
184
|
}, [
|
|
183
185
|
sdkHasLoaded,
|
|
184
|
-
|
|
186
|
+
userWithMissingInfo,
|
|
185
187
|
handlers,
|
|
186
188
|
completeAuth,
|
|
187
189
|
updateUser,
|
|
@@ -19,6 +19,7 @@ require('../../constants/colors.cjs');
|
|
|
19
19
|
require('../../constants/values.cjs');
|
|
20
20
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
21
|
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
22
|
+
var hasPendingMfaAction = require('../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
|
|
22
23
|
require('../../../shared/consts/index.cjs');
|
|
23
24
|
require('../../../events/dynamicEvents.cjs');
|
|
24
25
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -27,7 +28,6 @@ require('@dynamic-labs/multi-wallet');
|
|
|
27
28
|
require('react-international-phone');
|
|
28
29
|
require('../../../config/ApiEndpoint.cjs');
|
|
29
30
|
var storeAuthTokenAndUser = require('../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
|
|
30
|
-
var mfa = require('../../../data/api/mfa/mfa.cjs');
|
|
31
31
|
require('../../../locale/locale.cjs');
|
|
32
32
|
require('@dynamic-labs/store');
|
|
33
33
|
var AccessDeniedContext = require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -95,7 +95,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
95
95
|
|
|
96
96
|
const sleepToShowSuccessMessage = () => utils.sleep(1500);
|
|
97
97
|
const useUserAuth = ({ authMethod, }) => {
|
|
98
|
-
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState,
|
|
98
|
+
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
99
99
|
const { setDeniedOauthUsername, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
100
100
|
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
101
101
|
const { setLoading } = LoadingContext.useLoadingContext();
|
|
@@ -105,7 +105,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
105
105
|
const { shouldAutoCreateEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
106
106
|
const isVerifyResponse = (response) => response.user;
|
|
107
107
|
const initAuth = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ isSignIn = true, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage = false, skipDefaultErrorHandling = false, }) {
|
|
108
|
-
var _b
|
|
108
|
+
var _b;
|
|
109
109
|
logger.logger.debug('initAuth', { authMethod, isSignIn });
|
|
110
110
|
try {
|
|
111
111
|
// TODO: change this logic to const verifiedUser = await verifyFunction();
|
|
@@ -126,17 +126,11 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
126
126
|
walletConnectorOptions.forEach((walletOption) => {
|
|
127
127
|
walletOption.walletConnector.setVerifiedCredentials(verifiedUser.verifiedCredentials);
|
|
128
128
|
});
|
|
129
|
-
if ((
|
|
130
|
-
|
|
131
|
-
if (devices.length === 0) {
|
|
132
|
-
setView('mfa-choose-device');
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
setView('mfa-verification');
|
|
136
|
-
}
|
|
129
|
+
if (hasPendingMfaAction.hasPendingMfaAction(verifiedUser)) {
|
|
130
|
+
// handled in SyncAuthFlow
|
|
137
131
|
return;
|
|
138
132
|
}
|
|
139
|
-
if (isSignIn && ((
|
|
133
|
+
if (isSignIn && ((_b = verifiedUser.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
140
134
|
//onboarding will be handled in the onboarding flow
|
|
141
135
|
return;
|
|
142
136
|
}
|
|
@@ -213,7 +207,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
213
207
|
setError(error.message);
|
|
214
208
|
}
|
|
215
209
|
};
|
|
216
|
-
const handleVerifyMissingFields = (
|
|
210
|
+
const handleVerifyMissingFields = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
217
211
|
if (isEmailVerificationRequired &&
|
|
218
212
|
missingFields.find((field) => field.name === 'email')) {
|
|
219
213
|
setView('verify-email');
|
|
@@ -226,7 +220,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
226
220
|
}
|
|
227
221
|
setView(view.type);
|
|
228
222
|
});
|
|
229
|
-
const completeAuth = (
|
|
223
|
+
const completeAuth = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options = {}, }) {
|
|
230
224
|
logger.logger.debug('completeAuth', { authMethod });
|
|
231
225
|
try {
|
|
232
226
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
@@ -15,6 +15,7 @@ import '../../constants/colors.js';
|
|
|
15
15
|
import '../../constants/values.js';
|
|
16
16
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
17
|
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
18
|
+
import { hasPendingMfaAction } from '../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
|
|
18
19
|
import '../../../shared/consts/index.js';
|
|
19
20
|
import '../../../events/dynamicEvents.js';
|
|
20
21
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -23,7 +24,6 @@ import '@dynamic-labs/multi-wallet';
|
|
|
23
24
|
import 'react-international-phone';
|
|
24
25
|
import '../../../config/ApiEndpoint.js';
|
|
25
26
|
import { storeAuthTokenAndUser } from '../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
26
|
-
import { getUserMfaDevices } from '../../../data/api/mfa/mfa.js';
|
|
27
27
|
import '../../../locale/locale.js';
|
|
28
28
|
import '@dynamic-labs/store';
|
|
29
29
|
import { useAccessDeniedContext } from '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -91,7 +91,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
91
91
|
|
|
92
92
|
const sleepToShowSuccessMessage = () => sleep(1500);
|
|
93
93
|
const useUserAuth = ({ authMethod, }) => {
|
|
94
|
-
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState,
|
|
94
|
+
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, walletConnectorOptions, } = useInternalDynamicContext();
|
|
95
95
|
const { setDeniedOauthUsername, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
96
96
|
const { view, setView, goToInitialView } = useViewContext();
|
|
97
97
|
const { setLoading } = useLoadingContext();
|
|
@@ -101,7 +101,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
101
101
|
const { shouldAutoCreateEmbeddedWallet } = useEmbeddedWallet();
|
|
102
102
|
const isVerifyResponse = (response) => response.user;
|
|
103
103
|
const initAuth = (_a) => __awaiter(void 0, [_a], void 0, function* ({ isSignIn = true, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage = false, skipDefaultErrorHandling = false, }) {
|
|
104
|
-
var _b
|
|
104
|
+
var _b;
|
|
105
105
|
logger.debug('initAuth', { authMethod, isSignIn });
|
|
106
106
|
try {
|
|
107
107
|
// TODO: change this logic to const verifiedUser = await verifyFunction();
|
|
@@ -122,17 +122,11 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
122
122
|
walletConnectorOptions.forEach((walletOption) => {
|
|
123
123
|
walletOption.walletConnector.setVerifiedCredentials(verifiedUser.verifiedCredentials);
|
|
124
124
|
});
|
|
125
|
-
if ((
|
|
126
|
-
|
|
127
|
-
if (devices.length === 0) {
|
|
128
|
-
setView('mfa-choose-device');
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
setView('mfa-verification');
|
|
132
|
-
}
|
|
125
|
+
if (hasPendingMfaAction(verifiedUser)) {
|
|
126
|
+
// handled in SyncAuthFlow
|
|
133
127
|
return;
|
|
134
128
|
}
|
|
135
|
-
if (isSignIn && ((
|
|
129
|
+
if (isSignIn && ((_b = verifiedUser.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
136
130
|
//onboarding will be handled in the onboarding flow
|
|
137
131
|
return;
|
|
138
132
|
}
|
|
@@ -209,7 +203,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
209
203
|
setError(error.message);
|
|
210
204
|
}
|
|
211
205
|
};
|
|
212
|
-
const handleVerifyMissingFields = (
|
|
206
|
+
const handleVerifyMissingFields = (_c) => __awaiter(void 0, [_c], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
213
207
|
if (isEmailVerificationRequired &&
|
|
214
208
|
missingFields.find((field) => field.name === 'email')) {
|
|
215
209
|
setView('verify-email');
|
|
@@ -222,7 +216,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
222
216
|
}
|
|
223
217
|
setView(view.type);
|
|
224
218
|
});
|
|
225
|
-
const completeAuth = (
|
|
219
|
+
const completeAuth = (_d) => __awaiter(void 0, [_d], void 0, function* ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options = {}, }) {
|
|
226
220
|
logger.debug('completeAuth', { authMethod });
|
|
227
221
|
try {
|
|
228
222
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
@@ -92,7 +92,7 @@ require('../../../../context/ReinitializeContext/ReinitializeContextProvider.cjs
|
|
|
92
92
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
93
93
|
|
|
94
94
|
const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
95
|
-
const { environmentId,
|
|
95
|
+
const { environmentId, userWithMissingInfo, setCallback } = useInternalDynamicContext.useInternalDynamicContext();
|
|
96
96
|
const { setRetryData } = VerificationContext.useVerification();
|
|
97
97
|
const { selectedPhoneCountry } = FieldsStateContext.useFieldsState();
|
|
98
98
|
const handleVerificationRequired = useHandleVerificationRequired.useHandleVerificationRequired();
|
|
@@ -103,7 +103,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
103
103
|
let { metadata } = userFields;
|
|
104
104
|
// when a user has already logged in but a custom field was added to env, in order to not clear the old fields
|
|
105
105
|
metadata = metadata
|
|
106
|
-
? Object.assign(Object.assign({},
|
|
106
|
+
? Object.assign(Object.assign({}, userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata), metadata) : userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata;
|
|
107
107
|
// we dont add user.metadata from edit profile because it is already in the metadata request for updateUser
|
|
108
108
|
const validatedUserFields = yield userFieldsSchema.userFieldsSchema.validate(userFields, {
|
|
109
109
|
stripUnknown: validationSchemaStripUnknown,
|
|
@@ -136,7 +136,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
136
136
|
updateUserProfileResponse,
|
|
137
137
|
};
|
|
138
138
|
}), [
|
|
139
|
-
|
|
139
|
+
userWithMissingInfo === null || userWithMissingInfo === void 0 ? void 0 : userWithMissingInfo.metadata,
|
|
140
140
|
validationSchemaStripUnknown,
|
|
141
141
|
selectedPhoneCountry,
|
|
142
142
|
setRetryData,
|