@dynamic-labs/sdk-react-core 2.1.0-alpha.30 → 2.1.0-alpha.32
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 +26 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.cjs +2 -1
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.js +2 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +6 -9
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +6 -9
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -3
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +3 -5
- package/src/lib/context/PasskeyContext/PasskeyContext.js +3 -5
- package/src/lib/shared/types/dynamicHandlers.d.ts +13 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +190 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +186 -0
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +10 -31
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.d.ts +5 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +10 -31
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +9 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +9 -2
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +4 -6
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +4 -6
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedWidget.cjs +3 -85
- package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedWidget.js +3 -85
- package/src/lib/widgets/DynamicWidget/DynamicWidget.cjs +1 -7
- package/src/lib/widgets/DynamicWidget/DynamicWidget.js +2 -8
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
4
|
+
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import { useInternalDynamicEvents } from '../events/useDynamicEvents/useDynamicEvents.js';
|
|
6
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
7
|
+
import { logger } from '../../../shared/logger.js';
|
|
8
|
+
import '@dynamic-labs/iconic';
|
|
9
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '../../constants/colors.js';
|
|
14
|
+
import '../../constants/values.js';
|
|
15
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
+
import '@dynamic-labs/utils';
|
|
17
|
+
import '../../../shared/consts/index.js';
|
|
18
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import 'react-international-phone';
|
|
22
|
+
import 'viem';
|
|
23
|
+
import 'viem/chains';
|
|
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 '../../../events/dynamicEvents.js';
|
|
31
|
+
import { useVerification } from '../../../context/VerificationContext/VerificationContext.js';
|
|
32
|
+
import 'react-dom';
|
|
33
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
34
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
35
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
36
|
+
import '@dynamic-labs/types';
|
|
37
|
+
import { useUserAuth } from '../useUserAuth/useUserAuth.js';
|
|
38
|
+
import 'yup';
|
|
39
|
+
import '../../../context/MockContext/MockContext.js';
|
|
40
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
41
|
+
import { useUserUpdateRequestInternal } from '../useUserUpdateRequest/useUserUpdateRequest.js';
|
|
42
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
43
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
44
|
+
import '@dynamic-labs/rpc-providers';
|
|
45
|
+
import 'react-i18next';
|
|
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/LoadingContext/LoadingContext.js';
|
|
68
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
69
|
+
import '../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
70
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
71
|
+
import '../../../context/MfaSettingsContext/MfaSettingsContext.js';
|
|
72
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
73
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
74
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
75
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
76
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
77
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
78
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
79
|
+
|
|
80
|
+
const useSyncOnboardingFlow = () => {
|
|
81
|
+
const { setShowAuthFlow, unauthenticatedUser, handlers, headless, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext();
|
|
82
|
+
const { setView } = useViewContext();
|
|
83
|
+
const { updateUser } = useUserUpdateRequestInternal({
|
|
84
|
+
validationSchemaStripUnknown: false,
|
|
85
|
+
});
|
|
86
|
+
const { completeAuth, handleAuthError } = useUserAuth({});
|
|
87
|
+
const { displayedDestination: formattedPhone } = useVerification();
|
|
88
|
+
const triggeredOnboarding = useRef(false);
|
|
89
|
+
useInternalDynamicEvents('logout', () => {
|
|
90
|
+
triggeredOnboarding.current = false;
|
|
91
|
+
});
|
|
92
|
+
// this is used to trigger onboarding flow
|
|
93
|
+
// either by headless or dynamic widget
|
|
94
|
+
// it will be triggered when user has missing fields
|
|
95
|
+
// either on login or refreshing the page
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
var _a;
|
|
98
|
+
const handleHeadlessOnboarding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
+
var _b;
|
|
100
|
+
if (!(handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) ||
|
|
101
|
+
!((_b = unauthenticatedUser === null || unauthenticatedUser === void 0 ? void 0 : unauthenticatedUser.missingFields) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
triggeredOnboarding.current = true;
|
|
105
|
+
try {
|
|
106
|
+
const missingFieldsRequestInput = unauthenticatedUser.missingFields.map((field) => ({
|
|
107
|
+
isCustom: field.type === 'custom',
|
|
108
|
+
key: field.name,
|
|
109
|
+
label: field.label,
|
|
110
|
+
required: field.required,
|
|
111
|
+
}));
|
|
112
|
+
const onboardingResponse = yield handlers.handleUserOnboarding(missingFieldsRequestInput);
|
|
113
|
+
const userFields = {};
|
|
114
|
+
const customFields = Object.assign({}, unauthenticatedUser === null || unauthenticatedUser === void 0 ? void 0 : unauthenticatedUser.metadata);
|
|
115
|
+
onboardingResponse.forEach((field) => {
|
|
116
|
+
if (field.isCustom) {
|
|
117
|
+
customFields[field.key] = field.value;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
userFields[field.key] = field.value;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
yield completeAuth({
|
|
124
|
+
updateJwtFunction: () => __awaiter(void 0, void 0, void 0, function* () { return updateUser(Object.assign(Object.assign({}, userFields), { metadata: customFields })); }),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
logger.error('Error handling user onboarding', error);
|
|
129
|
+
handleAuthError(error, {});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
const handleOnboarding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
triggeredOnboarding.current = true;
|
|
134
|
+
setShowAuthFlow(true);
|
|
135
|
+
const lastVerifiedCredential = unauthenticatedUser === null || unauthenticatedUser === void 0 ? void 0 : unauthenticatedUser.verifiedCredentials.find((vc) => vc.id === (unauthenticatedUser === null || unauthenticatedUser === void 0 ? void 0 : unauthenticatedUser.lastVerifiedCredentialId));
|
|
136
|
+
if (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName) {
|
|
137
|
+
setSelectedWalletConnectorKey(lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.walletName);
|
|
138
|
+
}
|
|
139
|
+
switch (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.format) {
|
|
140
|
+
case JwtVerifiedCredentialFormatEnum.Email:
|
|
141
|
+
case JwtVerifiedCredentialFormatEnum.Oauth:
|
|
142
|
+
setView('collect-user-data-login-no-wallet', {
|
|
143
|
+
userIdentification: 'email',
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
case JwtVerifiedCredentialFormatEnum.PhoneNumber:
|
|
147
|
+
setView('collect-user-data-login-no-wallet', {
|
|
148
|
+
userIdentification: 'phoneNumber',
|
|
149
|
+
userIdentificationOverride: formattedPhone,
|
|
150
|
+
});
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
setView('collect-user-data');
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (!sdkHasLoaded ||
|
|
157
|
+
triggeredOnboarding.current ||
|
|
158
|
+
!((_a = unauthenticatedUser === null || unauthenticatedUser === void 0 ? void 0 : unauthenticatedUser.missingFields) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (handlers === null || handlers === void 0 ? void 0 : handlers.handleUserOnboarding) {
|
|
162
|
+
handleHeadlessOnboarding();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (headless) {
|
|
166
|
+
logger.error('No onboarding handler found. Please add a handleUserOnboarding handler to your dynamic provider settings.');
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
handleOnboarding();
|
|
170
|
+
return;
|
|
171
|
+
}, [
|
|
172
|
+
sdkHasLoaded,
|
|
173
|
+
unauthenticatedUser,
|
|
174
|
+
handlers,
|
|
175
|
+
completeAuth,
|
|
176
|
+
updateUser,
|
|
177
|
+
headless,
|
|
178
|
+
setShowAuthFlow,
|
|
179
|
+
setView,
|
|
180
|
+
formattedPhone,
|
|
181
|
+
handleAuthError,
|
|
182
|
+
setSelectedWalletConnectorKey,
|
|
183
|
+
]);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export { useSyncOnboardingFlow };
|
|
@@ -32,7 +32,7 @@ var mfa = require('../../../data/api/mfa/mfa.cjs');
|
|
|
32
32
|
require('../../../locale/locale.cjs');
|
|
33
33
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
34
34
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
35
|
-
|
|
35
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
36
36
|
require('react-dom');
|
|
37
37
|
var useEmbeddedWallet = require('../useEmbeddedWallet/useEmbeddedWallet.cjs');
|
|
38
38
|
require('../../../context/WalletContext/WalletContext.cjs');
|
|
@@ -90,7 +90,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
90
90
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
91
91
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
92
92
|
const handleVerifiedUser = useHandleVerifiedUser.useHandleVerifiedUser();
|
|
93
|
-
const { displayedDestination: formattedPhone } = VerificationContext.useVerification();
|
|
94
93
|
const { shouldAutoCreateEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
95
94
|
const isVerifyResponse = (response) => response.user;
|
|
96
95
|
const initAuth = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ isSignIn = true, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage = false, skipDefaultErrorHandling = false, }) {
|
|
@@ -112,11 +111,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
112
111
|
verifiedUser = verifyResponse;
|
|
113
112
|
}
|
|
114
113
|
onVerifySuccess === null || onVerifySuccess === void 0 ? void 0 : onVerifySuccess(verifiedUser);
|
|
115
|
-
if (
|
|
116
|
-
yield handleOnboarding(showSuccessMessage, onSettled);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if ((_c = verifiedUser.scope) === null || _c === void 0 ? void 0 : _c.includes('requiresAdditionalAuth')) {
|
|
114
|
+
if ((_b = verifiedUser.scope) === null || _b === void 0 ? void 0 : _b.includes('requiresAdditionalAuth')) {
|
|
120
115
|
const devices = yield mfa.getUserMfaDevices({ environmentId });
|
|
121
116
|
if (devices.length === 0) {
|
|
122
117
|
setView('mfa-choose-device');
|
|
@@ -126,6 +121,10 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
126
121
|
}
|
|
127
122
|
return;
|
|
128
123
|
}
|
|
124
|
+
if (isSignIn && ((_c = verifiedUser.missingFields) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
125
|
+
//onboarding will be handled in the onboarding flow
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
129
128
|
setMultiWalletWidgetState('idle');
|
|
130
129
|
yield handleVerifiedUser(verifiedUser);
|
|
131
130
|
if (showSuccessMessage) {
|
|
@@ -149,35 +148,14 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
149
148
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
150
149
|
return;
|
|
151
150
|
}
|
|
152
|
-
|
|
151
|
+
handleAuthError(error, { onError });
|
|
153
152
|
}
|
|
154
153
|
finally {
|
|
155
154
|
setLoading(false);
|
|
156
155
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
157
156
|
}
|
|
158
157
|
});
|
|
159
|
-
const
|
|
160
|
-
if (showSuccessMessage) {
|
|
161
|
-
yield sleepToShowSuccessMessage();
|
|
162
|
-
}
|
|
163
|
-
setShowAuthFlow(true);
|
|
164
|
-
if (authMethod === 'email' || authMethod === 'social') {
|
|
165
|
-
setView('collect-user-data-login-no-wallet', {
|
|
166
|
-
userIdentification: 'email',
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
else if (authMethod === 'sms') {
|
|
170
|
-
setView('collect-user-data-login-no-wallet', {
|
|
171
|
-
userIdentification: 'phoneNumber',
|
|
172
|
-
userIdentificationOverride: formattedPhone,
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
else if (authMethod === 'wallet') {
|
|
176
|
-
setView('collect-user-data');
|
|
177
|
-
}
|
|
178
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
179
|
-
});
|
|
180
|
-
const handleError = (error, { options = {}, onError, }) => {
|
|
158
|
+
const handleAuthError = (error, { options = {}, onError, }) => {
|
|
181
159
|
if (error instanceof utils.MfaInvalidOtpError) {
|
|
182
160
|
throw error;
|
|
183
161
|
}
|
|
@@ -266,7 +244,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
266
244
|
}
|
|
267
245
|
catch (error) {
|
|
268
246
|
logger.logger.debug(error);
|
|
269
|
-
|
|
247
|
+
handleAuthError(error, { options });
|
|
270
248
|
}
|
|
271
249
|
finally {
|
|
272
250
|
setLoading(false);
|
|
@@ -280,6 +258,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
280
258
|
return {
|
|
281
259
|
cancelAuth,
|
|
282
260
|
completeAuth,
|
|
261
|
+
handleAuthError,
|
|
283
262
|
initAuth,
|
|
284
263
|
};
|
|
285
264
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { CompleteUserAuthProps, InitUserAuthProps, UseUserAuthProps } from './useUserAuth.types';
|
|
1
|
+
import { CompleteUserAuthProps, InitUserAuthProps, OnErrorCallback, UseUserAuthOptions, UseUserAuthProps } from './useUserAuth.types';
|
|
2
2
|
export declare const useUserAuth: <T extends keyof import("@dynamic-labs/types").AuthOptions>({ authMethod, }: UseUserAuthProps<T>) => {
|
|
3
3
|
cancelAuth: () => Promise<void>;
|
|
4
4
|
completeAuth: ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options, }: CompleteUserAuthProps<T>) => Promise<void>;
|
|
5
|
+
handleAuthError: <T_1 extends keyof import("@dynamic-labs/types").AuthOptions>(error: any, { options, onError, }: {
|
|
6
|
+
options?: UseUserAuthOptions[T_1] | undefined;
|
|
7
|
+
onError?: OnErrorCallback | undefined;
|
|
8
|
+
}) => void;
|
|
5
9
|
initAuth: ({ isSignIn, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage, skipDefaultErrorHandling, }: InitUserAuthProps<T>) => Promise<void>;
|
|
6
10
|
};
|
|
@@ -28,7 +28,7 @@ import { getUserMfaDevices } from '../../../data/api/mfa/mfa.js';
|
|
|
28
28
|
import '../../../locale/locale.js';
|
|
29
29
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
30
30
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
31
|
-
import
|
|
31
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
32
32
|
import 'react-dom';
|
|
33
33
|
import { useEmbeddedWallet } from '../useEmbeddedWallet/useEmbeddedWallet.js';
|
|
34
34
|
import '../../../context/WalletContext/WalletContext.js';
|
|
@@ -86,7 +86,6 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
86
86
|
const { setErrorMessage, setError } = useErrorContext();
|
|
87
87
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
88
88
|
const handleVerifiedUser = useHandleVerifiedUser();
|
|
89
|
-
const { displayedDestination: formattedPhone } = useVerification();
|
|
90
89
|
const { shouldAutoCreateEmbeddedWallet } = useEmbeddedWallet();
|
|
91
90
|
const isVerifyResponse = (response) => response.user;
|
|
92
91
|
const initAuth = (_a) => __awaiter(void 0, [_a], void 0, function* ({ isSignIn = true, verifyFunction, onVerifySuccess, onSettled, onError, showSuccessMessage = false, skipDefaultErrorHandling = false, }) {
|
|
@@ -108,11 +107,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
108
107
|
verifiedUser = verifyResponse;
|
|
109
108
|
}
|
|
110
109
|
onVerifySuccess === null || onVerifySuccess === void 0 ? void 0 : onVerifySuccess(verifiedUser);
|
|
111
|
-
if (
|
|
112
|
-
yield handleOnboarding(showSuccessMessage, onSettled);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if ((_c = verifiedUser.scope) === null || _c === void 0 ? void 0 : _c.includes('requiresAdditionalAuth')) {
|
|
110
|
+
if ((_b = verifiedUser.scope) === null || _b === void 0 ? void 0 : _b.includes('requiresAdditionalAuth')) {
|
|
116
111
|
const devices = yield getUserMfaDevices({ environmentId });
|
|
117
112
|
if (devices.length === 0) {
|
|
118
113
|
setView('mfa-choose-device');
|
|
@@ -122,6 +117,10 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
122
117
|
}
|
|
123
118
|
return;
|
|
124
119
|
}
|
|
120
|
+
if (isSignIn && ((_c = verifiedUser.missingFields) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
121
|
+
//onboarding will be handled in the onboarding flow
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
125
124
|
setMultiWalletWidgetState('idle');
|
|
126
125
|
yield handleVerifiedUser(verifiedUser);
|
|
127
126
|
if (showSuccessMessage) {
|
|
@@ -145,35 +144,14 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
145
144
|
onError === null || onError === void 0 ? void 0 : onError(error);
|
|
146
145
|
return;
|
|
147
146
|
}
|
|
148
|
-
|
|
147
|
+
handleAuthError(error, { onError });
|
|
149
148
|
}
|
|
150
149
|
finally {
|
|
151
150
|
setLoading(false);
|
|
152
151
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
153
152
|
}
|
|
154
153
|
});
|
|
155
|
-
const
|
|
156
|
-
if (showSuccessMessage) {
|
|
157
|
-
yield sleepToShowSuccessMessage();
|
|
158
|
-
}
|
|
159
|
-
setShowAuthFlow(true);
|
|
160
|
-
if (authMethod === 'email' || authMethod === 'social') {
|
|
161
|
-
setView('collect-user-data-login-no-wallet', {
|
|
162
|
-
userIdentification: 'email',
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
else if (authMethod === 'sms') {
|
|
166
|
-
setView('collect-user-data-login-no-wallet', {
|
|
167
|
-
userIdentification: 'phoneNumber',
|
|
168
|
-
userIdentificationOverride: formattedPhone,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
else if (authMethod === 'wallet') {
|
|
172
|
-
setView('collect-user-data');
|
|
173
|
-
}
|
|
174
|
-
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
175
|
-
});
|
|
176
|
-
const handleError = (error, { options = {}, onError, }) => {
|
|
154
|
+
const handleAuthError = (error, { options = {}, onError, }) => {
|
|
177
155
|
if (error instanceof MfaInvalidOtpError) {
|
|
178
156
|
throw error;
|
|
179
157
|
}
|
|
@@ -262,7 +240,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
262
240
|
}
|
|
263
241
|
catch (error) {
|
|
264
242
|
logger.debug(error);
|
|
265
|
-
|
|
243
|
+
handleAuthError(error, { options });
|
|
266
244
|
}
|
|
267
245
|
finally {
|
|
268
246
|
setLoading(false);
|
|
@@ -276,6 +254,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
276
254
|
return {
|
|
277
255
|
cancelAuth,
|
|
278
256
|
completeAuth,
|
|
257
|
+
handleAuthError,
|
|
279
258
|
initAuth,
|
|
280
259
|
};
|
|
281
260
|
};
|
|
@@ -125,9 +125,16 @@ const exportCredential = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function
|
|
|
125
125
|
throw new utils.DynamicError('Invalid export response', errors.ERROR_PROCESSING_REVEAL_REQUEST);
|
|
126
126
|
}
|
|
127
127
|
if (address || privateKeyId) {
|
|
128
|
-
return turnkeyExportHandler.verifyExportPrivateKey(
|
|
128
|
+
return turnkeyExportHandler.verifyExportPrivateKey({
|
|
129
|
+
chain: wallet === null || wallet === void 0 ? void 0 : wallet.chain,
|
|
130
|
+
exportBundle,
|
|
131
|
+
organizationId,
|
|
132
|
+
});
|
|
129
133
|
}
|
|
130
|
-
return turnkeyExportHandler.verifyExportWallet(
|
|
134
|
+
return turnkeyExportHandler.verifyExportWallet({
|
|
135
|
+
exportBundle,
|
|
136
|
+
organizationId,
|
|
137
|
+
});
|
|
131
138
|
});
|
|
132
139
|
const cleanupExport = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ wallet }) {
|
|
133
140
|
var _e;
|
|
@@ -121,9 +121,16 @@ const exportCredential = (_c) => __awaiter(void 0, [_c], void 0, function* ({ us
|
|
|
121
121
|
throw new DynamicError('Invalid export response', ERROR_PROCESSING_REVEAL_REQUEST);
|
|
122
122
|
}
|
|
123
123
|
if (address || privateKeyId) {
|
|
124
|
-
return turnkeyExportHandler.verifyExportPrivateKey(
|
|
124
|
+
return turnkeyExportHandler.verifyExportPrivateKey({
|
|
125
|
+
chain: wallet === null || wallet === void 0 ? void 0 : wallet.chain,
|
|
126
|
+
exportBundle,
|
|
127
|
+
organizationId,
|
|
128
|
+
});
|
|
125
129
|
}
|
|
126
|
-
return turnkeyExportHandler.verifyExportWallet(
|
|
130
|
+
return turnkeyExportHandler.verifyExportWallet({
|
|
131
|
+
exportBundle,
|
|
132
|
+
organizationId,
|
|
133
|
+
});
|
|
127
134
|
});
|
|
128
135
|
const cleanupExport = (_d) => __awaiter(void 0, [_d], void 0, function* ({ wallet }) {
|
|
129
136
|
var _e;
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs
CHANGED
|
@@ -98,13 +98,11 @@ const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) =>
|
|
|
98
98
|
dynamicEvents.dynamicEvents.removeListener('logout', resetAuthView);
|
|
99
99
|
};
|
|
100
100
|
}, [resetAuthView]);
|
|
101
|
+
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
101
102
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
102
|
-
React.useEffect(() => {
|
|
103
|
-
isRenderingEmbeddedAuthFlow.current =
|
|
104
|
-
|
|
105
|
-
isRenderingEmbeddedAuthFlow.current = false;
|
|
106
|
-
};
|
|
107
|
-
}, [hide, isRenderingEmbeddedAuthFlow]);
|
|
103
|
+
React.useEffect(() => () => {
|
|
104
|
+
isRenderingEmbeddedAuthFlow.current = false;
|
|
105
|
+
}, [isRenderingEmbeddedAuthFlow]);
|
|
108
106
|
if (hide)
|
|
109
107
|
return null;
|
|
110
108
|
const content = (jsxRuntime.jsx(DynamicAuthLayout.DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsxRuntime.jsx(RenderView.RenderView, {}) }));
|
package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js
CHANGED
|
@@ -94,13 +94,11 @@ const DynamicEmbeddedAuthFlow = ({ background = 'none', className, style, }) =>
|
|
|
94
94
|
dynamicEvents.removeListener('logout', resetAuthView);
|
|
95
95
|
};
|
|
96
96
|
}, [resetAuthView]);
|
|
97
|
+
isRenderingEmbeddedAuthFlow.current = !hide;
|
|
97
98
|
// Keep isRenderingEmbeddedAuthFlow up to date
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
isRenderingEmbeddedAuthFlow.current =
|
|
100
|
-
|
|
101
|
-
isRenderingEmbeddedAuthFlow.current = false;
|
|
102
|
-
};
|
|
103
|
-
}, [hide, isRenderingEmbeddedAuthFlow]);
|
|
99
|
+
useEffect(() => () => {
|
|
100
|
+
isRenderingEmbeddedAuthFlow.current = false;
|
|
101
|
+
}, [isRenderingEmbeddedAuthFlow]);
|
|
104
102
|
if (hide)
|
|
105
103
|
return null;
|
|
106
104
|
const content = (jsx(DynamicAuthLayout, { className: className, style: style, projectSettings: projectSettings, children: jsx(RenderView, {}) }));
|
|
@@ -4,93 +4,11 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
9
|
-
require('@dynamic-labs/sdk-api-core');
|
|
10
|
-
require('../../shared/logger.cjs');
|
|
11
|
-
require('@dynamic-labs/iconic');
|
|
12
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
-
require('../../context/ViewContext/ViewContext.cjs');
|
|
14
|
-
require('@dynamic-labs/wallet-book');
|
|
15
|
-
require('../../utils/constants/colors.cjs');
|
|
16
|
-
require('../../utils/constants/values.cjs');
|
|
17
|
-
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
-
require('@dynamic-labs/utils');
|
|
19
|
-
require('../../shared/consts/index.cjs');
|
|
20
|
-
require('../../events/dynamicEvents.cjs');
|
|
21
|
-
require('../../../../_virtual/_tslib.cjs');
|
|
22
|
-
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
|
-
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
24
|
-
require('@dynamic-labs/multi-wallet');
|
|
25
|
-
require('react-international-phone');
|
|
26
|
-
require('viem');
|
|
27
|
-
require('viem/chains');
|
|
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('../../context/ThemeContext/ThemeContext.cjs');
|
|
38
|
-
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
39
|
-
require('@dynamic-labs/types');
|
|
40
|
-
require('../../context/LoadingContext/LoadingContext.cjs');
|
|
41
|
-
require('yup');
|
|
42
|
-
require('../../context/MockContext/MockContext.cjs');
|
|
43
|
-
require('../../views/CollectUserDataView/useFields.cjs');
|
|
44
|
-
require('../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
45
|
-
require('../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
46
|
-
require('@dynamic-labs/rpc-providers');
|
|
47
|
-
require('react-i18next');
|
|
48
|
-
require('../../components/Alert/Alert.cjs');
|
|
49
|
-
require('../../components/ShadowDOM/ShadowDOM.cjs');
|
|
50
|
-
require('../../components/IconButton/IconButton.cjs');
|
|
51
|
-
require('../../components/InlineWidget/InlineWidget.cjs');
|
|
52
|
-
require('../../components/Input/Input.cjs');
|
|
53
|
-
require('../../components/IsBrowser/IsBrowser.cjs');
|
|
54
|
-
require('../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
55
|
-
require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
56
|
-
require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
57
|
-
require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
58
|
-
require('../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
59
|
-
require('../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
60
|
-
require('../../components/Popper/Popper/Popper.cjs');
|
|
61
|
-
require('../../components/Popper/PopperContext/PopperContext.cjs');
|
|
62
|
-
require('react-focus-lock');
|
|
63
|
-
require('qrcode');
|
|
64
|
-
require('formik');
|
|
65
|
-
require('../../views/WalletList/WalletList.cjs');
|
|
66
|
-
require('../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
67
|
-
require('../DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
68
|
-
require('@hcaptcha/react-hcaptcha');
|
|
69
|
-
require('../../context/FooterAnimationContext/index.cjs');
|
|
70
|
-
require('../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.cjs');
|
|
71
|
-
require('../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
72
|
-
require('../../context/MfaSettingsContext/MfaSettingsContext.cjs');
|
|
73
|
-
require('../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
74
|
-
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
75
|
-
require('../DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
76
|
-
require('../DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
77
|
-
require('../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
|
|
78
|
-
require('../DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
79
|
-
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
80
7
|
var DynamicEmbeddedAuthFlow = require('./DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs');
|
|
81
8
|
var DynamicEmbeddedUserProfile = require('./DynamicEmbeddedUserProfile/DynamicEmbeddedUserProfile.cjs');
|
|
82
9
|
|
|
83
|
-
const DynamicEmbeddedWidget = ({ background = 'none', className, style, }) =>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setDynamicWidgetHasLoaded(true);
|
|
87
|
-
return () => {
|
|
88
|
-
setDynamicWidgetHasLoaded(false);
|
|
89
|
-
};
|
|
90
|
-
}, [setDynamicWidgetHasLoaded]);
|
|
91
|
-
return (
|
|
92
|
-
// Only one of these 2 show at any given time, due these components' own definitions
|
|
93
|
-
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DynamicEmbeddedAuthFlow.DynamicEmbeddedAuthFlow, { background: background, className: className, style: style }), jsxRuntime.jsx(DynamicEmbeddedUserProfile.DynamicEmbeddedUserProfile, { background: background, className: className, style: style })] }));
|
|
94
|
-
};
|
|
10
|
+
const DynamicEmbeddedWidget = ({ background = 'none', className, style, }) => (
|
|
11
|
+
// Only one of these 2 show at any given time, due these components' own definitions
|
|
12
|
+
jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DynamicEmbeddedAuthFlow.DynamicEmbeddedAuthFlow, { background: background, className: className, style: style }), jsxRuntime.jsx(DynamicEmbeddedUserProfile.DynamicEmbeddedUserProfile, { background: background, className: className, style: style })] }));
|
|
95
13
|
|
|
96
14
|
exports.DynamicEmbeddedWidget = DynamicEmbeddedWidget;
|