@dynamic-labs/sdk-react-core 2.1.0-alpha.18 → 2.1.0-alpha.19
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 +16 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/lib/components/MfaRecoveryIcon/MfaRecoveryIcon.cjs +15 -0
- package/src/lib/components/MfaRecoveryIcon/MfaRecoveryIcon.d.ts +2 -0
- package/src/lib/components/MfaRecoveryIcon/MfaRecoveryIcon.js +11 -0
- package/src/lib/components/MfaRecoveryIcon/index.d.ts +1 -0
- package/src/lib/components/Portal/Portal.cjs +0 -1
- package/src/lib/components/Portal/Portal.js +0 -1
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +5 -2
- package/src/lib/components/SocialSignIn/SocialSignIn.js +5 -2
- package/src/lib/components/UserProfile/parts/UserProfileField/UserProfileField.d.ts +1 -1
- package/src/lib/components/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.cjs +4 -5
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.d.ts +3 -2
- package/src/lib/context/DynamicContext/hooks/useNameService/useNameService.js +4 -5
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +1 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.js +2 -2
- package/src/lib/context/ViewContext/types/index.d.ts +1 -1
- package/src/lib/data/api/api.cjs +2 -2
- package/src/lib/data/api/api.js +2 -2
- package/src/lib/data/api/user/user.cjs +3 -0
- package/src/lib/data/api/user/user.js +4 -1
- package/src/lib/locale/en/translation.cjs +38 -21
- package/src/lib/locale/en/translation.d.ts +38 -21
- package/src/lib/locale/en/translation.js +38 -21
- package/src/lib/modals/SignMessageConfirmationModal/getProperErrorMessage.cjs +19 -2
- package/src/lib/modals/SignMessageConfirmationModal/getProperErrorMessage.js +19 -2
- package/src/lib/shared/assets/index.d.ts +1 -0
- package/src/lib/shared/assets/mfa-recovery-icon.cjs +54 -0
- package/src/lib/shared/assets/mfa-recovery-icon.js +30 -0
- package/src/lib/shared/utils/functions/lastAuthenticatedAccount/index.d.ts +2 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.d.ts +2 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
- package/src/lib/utils/functions/getEnabledSocialSignInProvidersAsProviderEnum/getEnabledSocialSignInProvidersAsProviderEnum.cjs +21 -0
- package/src/lib/utils/functions/getEnabledSocialSignInProvidersAsProviderEnum/getEnabledSocialSignInProvidersAsProviderEnum.js +17 -0
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +6 -3
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +2 -1
- package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +7 -4
- package/src/lib/utils/functions/validateMfaRecoveryCode/index.d.ts +1 -0
- package/src/lib/utils/functions/validateMfaRecoveryCode/validateMfaRecoveryCode.cjs +11 -0
- package/src/lib/utils/functions/validateMfaRecoveryCode/validateMfaRecoveryCode.d.ts +1 -0
- package/src/lib/utils/functions/validateMfaRecoveryCode/validateMfaRecoveryCode.js +7 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +5 -3
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +5 -3
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +8 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +8 -0
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.cjs +10 -1
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.d.ts +5 -0
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.js +10 -1
- package/src/lib/utils/hooks/useKYCFlag/useKYCFlag.cjs +1 -0
- package/src/lib/utils/hooks/useKYCFlag/useKYCFlag.js +1 -0
- package/src/lib/utils/hooks/useMfaModals/index.d.ts +1 -0
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +131 -0
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.d.ts +8 -0
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +127 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +24 -3
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +1 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +24 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +8 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +3 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +8 -4
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +9 -2
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +10 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +7 -2
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +7 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +1 -10
- package/src/lib/views/EmailVerification/EmailVerification.js +1 -10
- package/src/lib/views/FarcasterQrCodeView/FarcasterQrCodeView.cjs +1 -1
- package/src/lib/views/FarcasterQrCodeView/FarcasterQrCodeView.js +1 -1
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +5 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +5 -2
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.cjs +116 -0
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.d.ts +2 -0
- package/src/lib/views/MfaRecoveryView/MfaRecoveryView.js +112 -0
- package/src/lib/views/MfaRecoveryView/index.d.ts +1 -0
- package/src/lib/views/viewToComponentMap.cjs +2 -2
- package/src/lib/views/viewToComponentMap.d.ts +2 -2
- package/src/lib/views/viewToComponentMap.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/ProfileView/ProfileView.cjs +5 -1
- package/src/lib/widgets/DynamicBridgeWidget/views/ProfileView/ProfileView.js +5 -1
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/prompts/PendingConnectionModal/PendingConnectionModal.js +3 -3
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +0 -131
- package/src/lib/views/EmailUpdate/EmailUpdate.d.ts +0 -2
- package/src/lib/views/EmailUpdate/EmailUpdate.js +0 -127
- package/src/lib/views/EmailUpdate/index.d.ts +0 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
4
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
5
|
+
import '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import '../../../shared/logger.js';
|
|
7
|
+
import '@dynamic-labs/iconic';
|
|
8
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
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 '@dynamic-labs/utils';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
import '../../../events/dynamicEvents.js';
|
|
17
|
+
import '../../../../../_virtual/_tslib.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 '../../../locale/locale.js';
|
|
26
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
27
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
28
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
29
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
30
|
+
import 'react-dom';
|
|
31
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
32
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
33
|
+
import '@dynamic-labs/types';
|
|
34
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
35
|
+
import 'yup';
|
|
36
|
+
import '../../../context/MockContext/MockContext.js';
|
|
37
|
+
import 'react-i18next';
|
|
38
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
39
|
+
import '../useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
40
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
41
|
+
import '@dynamic-labs/rpc-providers';
|
|
42
|
+
import '../../../components/Alert/Alert.js';
|
|
43
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
44
|
+
import '../../../components/IconButton/IconButton.js';
|
|
45
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
46
|
+
import '../../../components/Input/Input.js';
|
|
47
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
48
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
49
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
50
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
51
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
52
|
+
import '../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.js';
|
|
53
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
54
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
55
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
56
|
+
import 'react-focus-lock';
|
|
57
|
+
import 'qrcode';
|
|
58
|
+
import 'formik';
|
|
59
|
+
import '../../../views/WalletList/WalletList.js';
|
|
60
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
61
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
62
|
+
import '@hcaptcha/react-hcaptcha';
|
|
63
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
64
|
+
import '../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
65
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
66
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
67
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
68
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
69
|
+
import '../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
|
|
70
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
71
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
72
|
+
|
|
73
|
+
const useMfaModals = () => {
|
|
74
|
+
var _a;
|
|
75
|
+
const { setShowAuthFlow, projectSettings } = useInternalDynamicContext();
|
|
76
|
+
const { setView } = useViewContext();
|
|
77
|
+
const isMfaEnabled = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.mfa) === null || _a === void 0 ? void 0 : _a.enabled;
|
|
78
|
+
const setShowMfaChooseType = useCallback((value) => {
|
|
79
|
+
if (value) {
|
|
80
|
+
if (!isMfaEnabled)
|
|
81
|
+
return;
|
|
82
|
+
setView('mfa-choose-device');
|
|
83
|
+
}
|
|
84
|
+
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
85
|
+
}, [isMfaEnabled, setShowAuthFlow, setView]);
|
|
86
|
+
const setShowMfaQRCode = useCallback((value) => {
|
|
87
|
+
if (value) {
|
|
88
|
+
if (!isMfaEnabled)
|
|
89
|
+
return;
|
|
90
|
+
setView('mfa-secure-device');
|
|
91
|
+
}
|
|
92
|
+
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
93
|
+
}, [isMfaEnabled, setShowAuthFlow, setView]);
|
|
94
|
+
const setShowOTPVerification = useCallback((value) => {
|
|
95
|
+
if (value) {
|
|
96
|
+
if (!isMfaEnabled)
|
|
97
|
+
return;
|
|
98
|
+
setView('mfa-verification');
|
|
99
|
+
}
|
|
100
|
+
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
101
|
+
}, [isMfaEnabled, setShowAuthFlow, setView]);
|
|
102
|
+
const setShowMfaViewBackupCodes = useCallback((value) => {
|
|
103
|
+
if (value) {
|
|
104
|
+
if (!isMfaEnabled)
|
|
105
|
+
return;
|
|
106
|
+
setView('mfa-display-backup-codes');
|
|
107
|
+
}
|
|
108
|
+
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
109
|
+
}, [isMfaEnabled, setShowAuthFlow, setView]);
|
|
110
|
+
const setShowMfaEnterBackupCodes = useCallback((value) => {
|
|
111
|
+
if (value) {
|
|
112
|
+
if (!isMfaEnabled)
|
|
113
|
+
return;
|
|
114
|
+
setView('mfa-recovery');
|
|
115
|
+
}
|
|
116
|
+
setShowAuthFlow(value, { emitCancelAuth: true });
|
|
117
|
+
}, [isMfaEnabled, setShowAuthFlow, setView]);
|
|
118
|
+
return {
|
|
119
|
+
setShowMfaChooseType,
|
|
120
|
+
setShowMfaEnterBackupCodes,
|
|
121
|
+
setShowMfaQRCode,
|
|
122
|
+
setShowMfaViewBackupCodes,
|
|
123
|
+
setShowOTPVerification,
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export { useMfaModals };
|
|
@@ -26,6 +26,7 @@ require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
26
26
|
require('@dynamic-labs/multi-wallet');
|
|
27
27
|
require('react-international-phone');
|
|
28
28
|
var index = require('../../functions/getEnabledOAuthProviders/index.cjs');
|
|
29
|
+
var getEnabledSocialSignInProvidersAsProviderEnum = require('../../functions/getEnabledSocialSignInProvidersAsProviderEnum/getEnabledSocialSignInProvidersAsProviderEnum.cjs');
|
|
29
30
|
var isSocialKycEnabled = require('../../functions/isSocialKycEnabled/isSocialKycEnabled.cjs');
|
|
30
31
|
require('viem');
|
|
31
32
|
require('viem/chains');
|
|
@@ -88,11 +89,9 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
88
89
|
const { setView } = ViewContext.useViewContext();
|
|
89
90
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
90
91
|
const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth.useSocialAuth({
|
|
91
|
-
authMode: 'link',
|
|
92
92
|
onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
|
|
93
93
|
sessionTimeout,
|
|
94
94
|
});
|
|
95
|
-
const oauthProviders = index.getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
96
95
|
const verifiedOAuthCredentialsMap = React.useMemo(() => {
|
|
97
96
|
var _a, _b;
|
|
98
97
|
const verifiedOAuthCredential = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.filter((credential) => credential.format === 'oauth')) !== null && _b !== void 0 ? _b : [];
|
|
@@ -114,6 +113,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
114
113
|
handleError(types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`);
|
|
115
114
|
return false;
|
|
116
115
|
}
|
|
116
|
+
const oauthProviders = index.getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
117
117
|
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
118
118
|
if (!oauthProvider) {
|
|
119
119
|
handleError(types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`);
|
|
@@ -122,7 +122,11 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
122
122
|
return true;
|
|
123
123
|
};
|
|
124
124
|
const linkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
-
connectSocialAccount({
|
|
125
|
+
connectSocialAccount({
|
|
126
|
+
authMode: 'link',
|
|
127
|
+
provider,
|
|
128
|
+
validator: checkValidOAuthLinking,
|
|
129
|
+
});
|
|
126
130
|
});
|
|
127
131
|
const unlinkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
128
132
|
var _a;
|
|
@@ -172,12 +176,29 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
172
176
|
username: oauthUsername,
|
|
173
177
|
};
|
|
174
178
|
};
|
|
179
|
+
const checkValidOAuthSignIn = (provider) => {
|
|
180
|
+
var _a;
|
|
181
|
+
const oauthProvider = getEnabledSocialSignInProvidersAsProviderEnum.getEnabledSocialSignInProvidersAsProviderEnum((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.providers).find((socialProvider) => socialProvider === provider);
|
|
182
|
+
if (!oauthProvider) {
|
|
183
|
+
handleError(types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled for sign-in on the dashboard: ${provider}`);
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
};
|
|
188
|
+
const signInWithSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
189
|
+
connectSocialAccount({
|
|
190
|
+
authMode: 'signin',
|
|
191
|
+
provider,
|
|
192
|
+
validator: checkValidOAuthSignIn,
|
|
193
|
+
});
|
|
194
|
+
});
|
|
175
195
|
return {
|
|
176
196
|
error,
|
|
177
197
|
getLinkedAccountInformation,
|
|
178
198
|
isLinked,
|
|
179
199
|
isProcessing,
|
|
180
200
|
linkSocialAccount,
|
|
201
|
+
signInWithSocialAccount,
|
|
181
202
|
unlinkSocialAccount,
|
|
182
203
|
};
|
|
183
204
|
};
|
|
@@ -9,6 +9,7 @@ export declare const useSocialAccounts: ({ sessionTimeout }?: UseSocialAccountsP
|
|
|
9
9
|
readonly isLinked: (provider: ProviderEnum) => boolean;
|
|
10
10
|
readonly isProcessing: boolean;
|
|
11
11
|
readonly linkSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
12
|
+
readonly signInWithSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
12
13
|
readonly unlinkSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
13
14
|
};
|
|
14
15
|
export {};
|
|
@@ -22,6 +22,7 @@ import '../../../context/ErrorContext/ErrorContext.js';
|
|
|
22
22
|
import '@dynamic-labs/multi-wallet';
|
|
23
23
|
import 'react-international-phone';
|
|
24
24
|
import { getEnabledOAuthProviders } from '../../functions/getEnabledOAuthProviders/index.js';
|
|
25
|
+
import { getEnabledSocialSignInProvidersAsProviderEnum } from '../../functions/getEnabledSocialSignInProvidersAsProviderEnum/getEnabledSocialSignInProvidersAsProviderEnum.js';
|
|
25
26
|
import { isSocialKycEnabled } from '../../functions/isSocialKycEnabled/isSocialKycEnabled.js';
|
|
26
27
|
import 'viem';
|
|
27
28
|
import 'viem/chains';
|
|
@@ -84,11 +85,9 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
84
85
|
const { setView } = useViewContext();
|
|
85
86
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
86
87
|
const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth({
|
|
87
|
-
authMode: 'link',
|
|
88
88
|
onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
|
|
89
89
|
sessionTimeout,
|
|
90
90
|
});
|
|
91
|
-
const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
92
91
|
const verifiedOAuthCredentialsMap = useMemo(() => {
|
|
93
92
|
var _a, _b;
|
|
94
93
|
const verifiedOAuthCredential = (_b = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.filter((credential) => credential.format === 'oauth')) !== null && _b !== void 0 ? _b : [];
|
|
@@ -110,6 +109,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
110
109
|
handleError(SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`);
|
|
111
110
|
return false;
|
|
112
111
|
}
|
|
112
|
+
const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
113
113
|
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
114
114
|
if (!oauthProvider) {
|
|
115
115
|
handleError(SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`);
|
|
@@ -118,7 +118,11 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
118
118
|
return true;
|
|
119
119
|
};
|
|
120
120
|
const linkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
|
-
connectSocialAccount({
|
|
121
|
+
connectSocialAccount({
|
|
122
|
+
authMode: 'link',
|
|
123
|
+
provider,
|
|
124
|
+
validator: checkValidOAuthLinking,
|
|
125
|
+
});
|
|
122
126
|
});
|
|
123
127
|
const unlinkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
128
|
var _a;
|
|
@@ -168,12 +172,29 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
168
172
|
username: oauthUsername,
|
|
169
173
|
};
|
|
170
174
|
};
|
|
175
|
+
const checkValidOAuthSignIn = (provider) => {
|
|
176
|
+
var _a;
|
|
177
|
+
const oauthProvider = getEnabledSocialSignInProvidersAsProviderEnum((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.providers).find((socialProvider) => socialProvider === provider);
|
|
178
|
+
if (!oauthProvider) {
|
|
179
|
+
handleError(SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled for sign-in on the dashboard: ${provider}`);
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return true;
|
|
183
|
+
};
|
|
184
|
+
const signInWithSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
+
connectSocialAccount({
|
|
186
|
+
authMode: 'signin',
|
|
187
|
+
provider,
|
|
188
|
+
validator: checkValidOAuthSignIn,
|
|
189
|
+
});
|
|
190
|
+
});
|
|
171
191
|
return {
|
|
172
192
|
error,
|
|
173
193
|
getLinkedAccountInformation,
|
|
174
194
|
isLinked,
|
|
175
195
|
isProcessing,
|
|
176
196
|
linkSocialAccount,
|
|
197
|
+
signInWithSocialAccount,
|
|
177
198
|
unlinkSocialAccount,
|
|
178
199
|
};
|
|
179
200
|
};
|
|
@@ -101,7 +101,7 @@ const socialProviders = [
|
|
|
101
101
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
102
102
|
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
103
103
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
104
|
-
const useSocialAuth = ({ sessionTimeout,
|
|
104
|
+
const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }) => {
|
|
105
105
|
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
106
106
|
const { setErrorMessage, setError: setContextError } = ErrorContext.useErrorContext();
|
|
107
107
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
@@ -180,11 +180,15 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
180
180
|
verifyFunction: () => apiCall(),
|
|
181
181
|
});
|
|
182
182
|
});
|
|
183
|
-
const connectSocialAccount = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
183
|
+
const connectSocialAccount = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ authMode, provider, validator, captchaToken, }) {
|
|
184
184
|
var _b, _c;
|
|
185
185
|
clearInterval(authWindowInterval.current);
|
|
186
186
|
clearError();
|
|
187
187
|
setIsProcessing(true);
|
|
188
|
+
if (!authMode) {
|
|
189
|
+
logger.logger.error('Auth mode is required. Please use either "link" or "signin"');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
188
192
|
if (!checkValidProvider(provider)) {
|
|
189
193
|
return;
|
|
190
194
|
}
|
|
@@ -193,7 +197,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
193
197
|
return;
|
|
194
198
|
}
|
|
195
199
|
if (provider === sdkApiCore.ProviderEnum.Farcaster) {
|
|
196
|
-
connectWithFarcaster();
|
|
200
|
+
connectWithFarcaster(authMode);
|
|
197
201
|
return;
|
|
198
202
|
}
|
|
199
203
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
@@ -351,7 +355,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
351
355
|
}), authWindowTimeout);
|
|
352
356
|
}
|
|
353
357
|
});
|
|
354
|
-
const connectWithFarcaster = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
358
|
+
const connectWithFarcaster = (authMode) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
355
359
|
const dynamicNonce = consumeNonce();
|
|
356
360
|
const domain = window.location.host;
|
|
357
361
|
const data = yield farcaster.connect({
|
|
@@ -4,14 +4,14 @@ import { SocialOAuthError, SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
|
4
4
|
type SocialAuthMode = 'link' | 'signin';
|
|
5
5
|
type UseSocialAuthProps = {
|
|
6
6
|
sessionTimeout: number;
|
|
7
|
-
authMode: SocialAuthMode;
|
|
8
7
|
onSettled?: () => void;
|
|
9
8
|
onError?: () => void;
|
|
10
9
|
onFarcasterUrl?: (url: string) => void;
|
|
11
10
|
};
|
|
12
|
-
export declare const useSocialAuth: ({ sessionTimeout,
|
|
11
|
+
export declare const useSocialAuth: ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }: UseSocialAuthProps) => {
|
|
13
12
|
readonly checkValidProvider: (provider: ProviderEnum) => boolean;
|
|
14
|
-
readonly connectSocialAccount: ({ provider, validator, captchaToken, }: {
|
|
13
|
+
readonly connectSocialAccount: ({ authMode, provider, validator, captchaToken, }: {
|
|
14
|
+
authMode: SocialAuthMode;
|
|
15
15
|
provider: ProviderEnum;
|
|
16
16
|
validator?: (provider: ProviderEnum) => boolean;
|
|
17
17
|
captchaToken?: string;
|
|
@@ -97,7 +97,7 @@ const socialProviders = [
|
|
|
97
97
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
98
98
|
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
99
99
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
100
|
-
const useSocialAuth = ({ sessionTimeout,
|
|
100
|
+
const useSocialAuth = ({ sessionTimeout, onSettled, onError, onFarcasterUrl, }) => {
|
|
101
101
|
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
|
|
102
102
|
const { setErrorMessage, setError: setContextError } = useErrorContext();
|
|
103
103
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
@@ -176,11 +176,15 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
176
176
|
verifyFunction: () => apiCall(),
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
|
-
const connectSocialAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
179
|
+
const connectSocialAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authMode, provider, validator, captchaToken, }) {
|
|
180
180
|
var _b, _c;
|
|
181
181
|
clearInterval(authWindowInterval.current);
|
|
182
182
|
clearError();
|
|
183
183
|
setIsProcessing(true);
|
|
184
|
+
if (!authMode) {
|
|
185
|
+
logger.error('Auth mode is required. Please use either "link" or "signin"');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
184
188
|
if (!checkValidProvider(provider)) {
|
|
185
189
|
return;
|
|
186
190
|
}
|
|
@@ -189,7 +193,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
189
193
|
return;
|
|
190
194
|
}
|
|
191
195
|
if (provider === ProviderEnum.Farcaster) {
|
|
192
|
-
connectWithFarcaster();
|
|
196
|
+
connectWithFarcaster(authMode);
|
|
193
197
|
return;
|
|
194
198
|
}
|
|
195
199
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
@@ -347,7 +351,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
347
351
|
}), authWindowTimeout);
|
|
348
352
|
}
|
|
349
353
|
});
|
|
350
|
-
const connectWithFarcaster = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
354
|
+
const connectWithFarcaster = (authMode) => __awaiter(void 0, void 0, void 0, function* () {
|
|
351
355
|
const dynamicNonce = consumeNonce();
|
|
352
356
|
const domain = window.location.host;
|
|
353
357
|
const data = yield connect({
|
|
@@ -161,6 +161,13 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
161
161
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
162
162
|
});
|
|
163
163
|
const handleError = (error, { options = {}, onError, }) => {
|
|
164
|
+
// these get caught in onboarding form and handled there
|
|
165
|
+
if (error instanceof utils.EmailAlreadyExistsError ||
|
|
166
|
+
error instanceof utils.CustomFieldNotUniqueError ||
|
|
167
|
+
error instanceof utils.UsernameAlreadyExistsError ||
|
|
168
|
+
error instanceof utils.TooManyEmailVerificationsError ||
|
|
169
|
+
error instanceof utils.InvalidPhoneNumberError)
|
|
170
|
+
throw error;
|
|
164
171
|
if (error instanceof utils.NoAccessError) {
|
|
165
172
|
setView('no-access');
|
|
166
173
|
return;
|
|
@@ -192,12 +199,12 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
192
199
|
};
|
|
193
200
|
const handleVerifyMissingFields = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
194
201
|
if (isEmailVerificationRequired &&
|
|
195
|
-
missingFields.
|
|
202
|
+
missingFields.find((field) => field.name === 'email')) {
|
|
196
203
|
setView('verify-email');
|
|
197
204
|
return;
|
|
198
205
|
}
|
|
199
206
|
if (isSmsVerificationRequired &&
|
|
200
|
-
missingFields.
|
|
207
|
+
missingFields.find((field) => field.name === 'phoneNumber')) {
|
|
201
208
|
setView('verify-sms');
|
|
202
209
|
return;
|
|
203
210
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { DynamicError, NoAccessError, AccountExistsError, UserHasAccountWithEmailError, sleep } from '@dynamic-labs/utils';
|
|
3
|
+
import { DynamicError, EmailAlreadyExistsError, CustomFieldNotUniqueError, UsernameAlreadyExistsError, TooManyEmailVerificationsError, InvalidPhoneNumberError, NoAccessError, AccountExistsError, UserHasAccountWithEmailError, sleep } from '@dynamic-labs/utils';
|
|
4
4
|
import 'react';
|
|
5
5
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
6
6
|
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
@@ -157,6 +157,13 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
157
157
|
onSettled === null || onSettled === void 0 ? void 0 : onSettled();
|
|
158
158
|
});
|
|
159
159
|
const handleError = (error, { options = {}, onError, }) => {
|
|
160
|
+
// these get caught in onboarding form and handled there
|
|
161
|
+
if (error instanceof EmailAlreadyExistsError ||
|
|
162
|
+
error instanceof CustomFieldNotUniqueError ||
|
|
163
|
+
error instanceof UsernameAlreadyExistsError ||
|
|
164
|
+
error instanceof TooManyEmailVerificationsError ||
|
|
165
|
+
error instanceof InvalidPhoneNumberError)
|
|
166
|
+
throw error;
|
|
160
167
|
if (error instanceof NoAccessError) {
|
|
161
168
|
setView('no-access');
|
|
162
169
|
return;
|
|
@@ -188,12 +195,12 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
188
195
|
};
|
|
189
196
|
const handleVerifyMissingFields = (_b) => __awaiter(void 0, [_b], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
190
197
|
if (isEmailVerificationRequired &&
|
|
191
|
-
missingFields.
|
|
198
|
+
missingFields.find((field) => field.name === 'email')) {
|
|
192
199
|
setView('verify-email');
|
|
193
200
|
return;
|
|
194
201
|
}
|
|
195
202
|
if (isSmsVerificationRequired &&
|
|
196
|
-
missingFields.
|
|
203
|
+
missingFields.find((field) => field.name === 'phoneNumber')) {
|
|
197
204
|
setView('verify-sms');
|
|
198
205
|
return;
|
|
199
206
|
}
|
|
@@ -101,7 +101,7 @@ const userFieldsSchema = yup.object().shape({
|
|
|
101
101
|
username: yup.string(),
|
|
102
102
|
});
|
|
103
103
|
const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
104
|
-
const { minAuthToken, onboardingOnlyJwt, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
104
|
+
const { minAuthToken, onboardingOnlyJwt, environmentId, decodedOnboardingOnlyToken, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
105
105
|
const jwtToken = onboardingOnlyJwt || minAuthToken;
|
|
106
106
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
107
107
|
const { setRetryData } = VerificationContext.useVerification();
|
|
@@ -110,7 +110,11 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
110
110
|
var _a, _b;
|
|
111
111
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
112
112
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
113
|
-
|
|
113
|
+
let { metadata } = userFields;
|
|
114
|
+
// when a user has already logged in but a custom field was added to env, in order to not clear the old fields
|
|
115
|
+
metadata = metadata
|
|
116
|
+
? Object.assign(Object.assign({}, decodedOnboardingOnlyToken === null || decodedOnboardingOnlyToken === void 0 ? void 0 : decodedOnboardingOnlyToken.metadata), metadata) : decodedOnboardingOnlyToken === null || decodedOnboardingOnlyToken === void 0 ? void 0 : decodedOnboardingOnlyToken.metadata;
|
|
117
|
+
// we dont add user.metadata from edit profile because it is already in the metadata request for updateUser
|
|
114
118
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
115
119
|
stripUnknown: validationSchemaStripUnknown,
|
|
116
120
|
});
|
|
@@ -150,6 +154,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
150
154
|
environmentId,
|
|
151
155
|
updateUserProfileByJWT,
|
|
152
156
|
setRetryData,
|
|
157
|
+
decodedOnboardingOnlyToken,
|
|
153
158
|
]);
|
|
154
159
|
// This is necessary to avoid a circular declaration issue
|
|
155
160
|
const handleVerificationRequired = React.useRef(undefined);
|
|
@@ -97,7 +97,7 @@ const userFieldsSchema = object().shape({
|
|
|
97
97
|
username: string(),
|
|
98
98
|
});
|
|
99
99
|
const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
100
|
-
const { minAuthToken, onboardingOnlyJwt, environmentId } = useInternalDynamicContext();
|
|
100
|
+
const { minAuthToken, onboardingOnlyJwt, environmentId, decodedOnboardingOnlyToken, } = useInternalDynamicContext();
|
|
101
101
|
const jwtToken = onboardingOnlyJwt || minAuthToken;
|
|
102
102
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
103
103
|
const { setRetryData } = useVerification();
|
|
@@ -106,7 +106,11 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
106
106
|
var _a, _b;
|
|
107
107
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
108
108
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
109
|
-
|
|
109
|
+
let { metadata } = userFields;
|
|
110
|
+
// when a user has already logged in but a custom field was added to env, in order to not clear the old fields
|
|
111
|
+
metadata = metadata
|
|
112
|
+
? Object.assign(Object.assign({}, decodedOnboardingOnlyToken === null || decodedOnboardingOnlyToken === void 0 ? void 0 : decodedOnboardingOnlyToken.metadata), metadata) : decodedOnboardingOnlyToken === null || decodedOnboardingOnlyToken === void 0 ? void 0 : decodedOnboardingOnlyToken.metadata;
|
|
113
|
+
// we dont add user.metadata from edit profile because it is already in the metadata request for updateUser
|
|
110
114
|
const validatedUserFields = yield userFieldsSchema.validate(userFields, {
|
|
111
115
|
stripUnknown: validationSchemaStripUnknown,
|
|
112
116
|
});
|
|
@@ -146,6 +150,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
146
150
|
environmentId,
|
|
147
151
|
updateUserProfileByJWT,
|
|
148
152
|
setRetryData,
|
|
153
|
+
decodedOnboardingOnlyToken,
|
|
149
154
|
]);
|
|
150
155
|
// This is necessary to avoid a circular declaration issue
|
|
151
156
|
const handleVerificationRequired = useRef(undefined);
|
|
@@ -282,22 +282,13 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
282
282
|
setLoading(false);
|
|
283
283
|
}
|
|
284
284
|
});
|
|
285
|
-
// Go to update email screen, but prevent onEmailVerificationX callback from being called
|
|
286
|
-
const updateEmail = () => {
|
|
287
|
-
callCallbackOnUnmount.current = false;
|
|
288
|
-
if (isEmailRecoveryFlow) {
|
|
289
|
-
setView('passkey-recovery-add-email');
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
setView('update-email');
|
|
293
|
-
};
|
|
294
285
|
const EmailIcon = React.useMemo(() => {
|
|
295
286
|
const EmailIcon = (props) => (jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(signInWithEmail.ReactComponent, Object.assign({}, props)) }));
|
|
296
287
|
return EmailIcon;
|
|
297
288
|
}, []);
|
|
298
289
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { withIcon: false, className: 'email-verification__error-message', children: error })), jsxRuntime.jsxs("div", { className: classNames.classNames('email-verification__container', {
|
|
299
290
|
'email-verification__container--error': Boolean(error),
|
|
300
|
-
}), children: [showTransferMessage && (jsxRuntime.jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsxRuntime.jsx("div", { className: 'email-verification__icon-container', children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: check.ReactComponent }) })) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxRuntime.jsxs("div", { className: 'email-verification__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail.shortenEmail(email$1) })] }),
|
|
291
|
+
}), children: [showTransferMessage && (jsxRuntime.jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsxRuntime.jsx("div", { className: 'email-verification__icon-container', children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: check.ReactComponent }) })) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxRuntime.jsxs("div", { className: 'email-verification__copy-text-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail.shortenEmail(email$1) })] }), jsxRuntime.jsx(PinField.PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: isLoginView ? handleEmailLogin : handleComplete, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }), showRetryButton && (jsxRuntime.jsx(RetrySendVerificationCodeSection.RetrySendVerificationCodeSection, { className: 'email-verification__retry-container', retryHandler: handleRetry, secondsToRetry: SECONDS_TO_RETRY })), !isLoginView && !isEmailRecoveryFlow && (jsxRuntime.jsx(TextButton.TextButton, { className: 'email-verification__log-out', onClick: handleLogOut, copykey: 'dyn_otp_verification.log_out_button', children: t('dyn_otp_verification.log_out_button') }))] })] }));
|
|
301
292
|
};
|
|
302
293
|
|
|
303
294
|
exports.EmailVerification = EmailVerification;
|
|
@@ -278,22 +278,13 @@ const EmailVerification = ({ isEmailRecoveryFlow = false, showRetryButton: _show
|
|
|
278
278
|
setLoading(false);
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
|
-
// Go to update email screen, but prevent onEmailVerificationX callback from being called
|
|
282
|
-
const updateEmail = () => {
|
|
283
|
-
callCallbackOnUnmount.current = false;
|
|
284
|
-
if (isEmailRecoveryFlow) {
|
|
285
|
-
setView('passkey-recovery-add-email');
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
setView('update-email');
|
|
289
|
-
};
|
|
290
281
|
const EmailIcon = useMemo(() => {
|
|
291
282
|
const EmailIcon = (props) => (jsx(Icon, { color: 'brand-primary', children: jsx(SvgSignInWithEmail, Object.assign({}, props)) }));
|
|
292
283
|
return EmailIcon;
|
|
293
284
|
}, []);
|
|
294
285
|
return (jsxs(Fragment, { children: [error && (jsx(ErrorContainer, { withIcon: false, className: 'email-verification__error-message', children: error })), jsxs("div", { className: classNames('email-verification__container', {
|
|
295
286
|
'email-verification__container--error': Boolean(error),
|
|
296
|
-
}), children: [showTransferMessage && (jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsx("div", { className: 'email-verification__icon-container', children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: SvgCheck }) })) : (jsx(IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxs("div", { className: 'email-verification__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail(email) })] }),
|
|
287
|
+
}), children: [showTransferMessage && (jsx("div", { className: 'email-verification__transfer-message', copykey: 'dyn_otp_verification.email.complete', children: t('dyn_otp_verification.email.complete') })), isValidated ? (jsx("div", { className: 'email-verification__icon-container', children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: EmailIcon, iconSize: 64, InnerIcon: SvgCheck }) })) : (jsx(IconWithSpinner, { Icon: EmailIcon, iconSize: 96, isSpinning: true, className: 'email-verification__icon-with-spinner' })), jsxs("div", { className: 'email-verification__copy-text-container', children: [jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', copykey: 'dyn_otp_verification.description', children: t('dyn_otp_verification.description') }), jsx(Typography, { variant: 'body_normal', weight: 'bold', color: 'secondary', children: shortenEmail(email) })] }), jsx(PinField, { initialValue: Array(6).join('.').split('.'), isLoading: loading, handleComplete: isLoginView ? handleEmailLogin : handleComplete, isValidated: isValidated, inputMode: 'numeric', pattern: '[0-9]*', hasError: Boolean(error), onChange: () => setError(undefined) }), showRetryButton && (jsx(RetrySendVerificationCodeSection, { className: 'email-verification__retry-container', retryHandler: handleRetry, secondsToRetry: SECONDS_TO_RETRY })), !isLoginView && !isEmailRecoveryFlow && (jsx(TextButton, { className: 'email-verification__log-out', onClick: handleLogOut, copykey: 'dyn_otp_verification.log_out_button', children: t('dyn_otp_verification.log_out_button') }))] })] }));
|
|
297
288
|
};
|
|
298
289
|
|
|
299
290
|
export { EmailVerification };
|
|
@@ -29,13 +29,13 @@ const FarcasterQrCodeView = () => {
|
|
|
29
29
|
const { setError } = ErrorContext.useErrorContext();
|
|
30
30
|
const [url, setUrl] = React.useState(undefined);
|
|
31
31
|
const { connectSocialAccount } = useSocialAuth.useSocialAuth({
|
|
32
|
-
authMode: 'signin',
|
|
33
32
|
onError: () => setError('Something went wrong'),
|
|
34
33
|
onFarcasterUrl: (url) => setUrl(url),
|
|
35
34
|
sessionTimeout: 10000,
|
|
36
35
|
});
|
|
37
36
|
useEffectOnce.useEffectOnce(() => {
|
|
38
37
|
connectSocialAccount({
|
|
38
|
+
authMode: 'signin',
|
|
39
39
|
provider: sdkApiCore.ProviderEnum.Farcaster,
|
|
40
40
|
});
|
|
41
41
|
});
|
|
@@ -25,13 +25,13 @@ const FarcasterQrCodeView = () => {
|
|
|
25
25
|
const { setError } = useErrorContext();
|
|
26
26
|
const [url, setUrl] = useState(undefined);
|
|
27
27
|
const { connectSocialAccount } = useSocialAuth({
|
|
28
|
-
authMode: 'signin',
|
|
29
28
|
onError: () => setError('Something went wrong'),
|
|
30
29
|
onFarcasterUrl: (url) => setUrl(url),
|
|
31
30
|
sessionTimeout: 10000,
|
|
32
31
|
});
|
|
33
32
|
useEffectOnce(() => {
|
|
34
33
|
connectSocialAccount({
|
|
34
|
+
authMode: 'signin',
|
|
35
35
|
provider: ProviderEnum.Farcaster,
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -83,7 +83,6 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
|
|
|
83
83
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
84
84
|
const { engageCaptcha } = CaptchaContext.useCaptchaContext();
|
|
85
85
|
const { isProcessing, connectSocialAccount } = useSocialAuth.useSocialAuth({
|
|
86
|
-
authMode: 'signin',
|
|
87
86
|
onError: () => {
|
|
88
87
|
goToInitialView();
|
|
89
88
|
},
|
|
@@ -104,6 +103,7 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
|
|
|
104
103
|
setView('social-redirect-view');
|
|
105
104
|
setShowAuthFlow(true);
|
|
106
105
|
connectSocialAccount({
|
|
106
|
+
authMode: 'signin',
|
|
107
107
|
captchaToken,
|
|
108
108
|
provider: providerEnum,
|
|
109
109
|
});
|
|
@@ -113,7 +113,10 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
|
|
|
113
113
|
}
|
|
114
114
|
setView('social-redirect-view');
|
|
115
115
|
setShowAuthFlow(true);
|
|
116
|
-
connectSocialAccount({
|
|
116
|
+
connectSocialAccount({
|
|
117
|
+
authMode: 'signin',
|
|
118
|
+
provider: providerEnum,
|
|
119
|
+
});
|
|
117
120
|
};
|
|
118
121
|
return (jsxRuntime.jsx(SocialSignIn.SocialSignIn, { onSelectProvider: onSelectProvider, providers: enabledSocialProviders, selectedProvider: socialProvider, isLoading: isProcessing, testId: 'dynamic-social-sign-in', defaultProvider: defaultProvider, numOfItemsToDisplay: numOfItemsToDisplay, collapsedLayout: collapsedLayout }));
|
|
119
122
|
};
|