@dynamic-labs/sdk-react-core 2.1.0-alpha.22 → 2.1.0-alpha.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/index.d.ts +5 -1
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +2 -6
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +2 -6
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.cjs +11 -5
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.js +11 -5
- package/src/lib/context/DynamicContext/DynamicContext.cjs +8 -17
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -17
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -2
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -3
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.cjs +37 -0
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.js +33 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +9 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +9 -1
- package/src/lib/context/DynamicContext/types/index.d.ts +1 -4
- package/src/lib/context/LoadingContext/LoadingContext.cjs +1 -1
- package/src/lib/context/LoadingContext/LoadingContext.js +1 -1
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +1 -1
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
- package/src/lib/data/api/api.cjs +1 -3
- package/src/lib/data/api/api.js +1 -3
- package/src/lib/data/api/user/user.cjs +9 -6
- package/src/lib/data/api/user/user.d.ts +5 -5
- package/src/lib/data/api/user/user.js +9 -6
- package/src/lib/data/api/wallets/wallets.cjs +6 -3
- package/src/lib/data/api/wallets/wallets.d.ts +3 -2
- package/src/lib/data/api/wallets/wallets.js +7 -4
- package/src/lib/events/auth.d.ts +38 -0
- package/src/lib/events/dynamicEvents.d.ts +8 -32
- package/src/lib/events/embeddedWallet.d.ts +14 -0
- package/src/lib/events/otp.d.ts +5 -0
- package/src/lib/events/passkey.d.ts +5 -0
- package/src/lib/events/social.d.ts +3 -0
- package/src/lib/events/ui.d.ts +10 -0
- package/src/lib/events/wallets.d.ts +7 -0
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +6 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +6 -1
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +11 -0
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs +1 -2
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.d.ts +6 -2
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js +1 -2
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +0 -2
- package/src/lib/utils/constants/localStorage.d.ts +0 -1
- package/src/lib/utils/constants/localStorage.js +1 -2
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +12 -7
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +13 -8
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.d.ts +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -2
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +29 -14
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +29 -14
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +4 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +4 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +4 -5
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +0 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +0 -1
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +2 -2
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +8 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +8 -6
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.cjs +4 -4
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.d.ts +4 -3
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.js +4 -4
- package/src/lib/utils/hooks/useHandleVerifiedUser/useHandleVerifiedUser.cjs +1 -16
- package/src/lib/utils/hooks/useHandleVerifiedUser/useHandleVerifiedUser.d.ts +1 -4
- package/src/lib/utils/hooks/useHandleVerifiedUser/useHandleVerifiedUser.js +1 -16
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +1 -1
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +37 -20
- package/src/lib/utils/hooks/useMfa/useMfa.js +37 -20
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.cjs +1 -1
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.js +1 -1
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +13 -12
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +13 -12
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -11
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +3 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -11
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.cjs +3 -22
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.d.ts +2 -1
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.js +3 -22
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +8 -8
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +8 -8
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +39 -27
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +5 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +39 -27
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +39 -33
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.d.ts +2 -2
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +39 -33
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.types.d.ts +7 -24
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.cjs +1 -1
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.js +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +9 -16
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +10 -17
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +21 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +21 -3
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +10 -26
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.d.ts +1 -2
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +10 -26
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +4 -6
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +4 -6
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -5
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -5
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +3 -5
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +3 -5
- package/src/lib/views/EmailVerification/EmailVerification.cjs +8 -5
- package/src/lib/views/EmailVerification/EmailVerification.js +8 -5
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +5 -0
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +5 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +3 -6
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +3 -6
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +7 -13
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +3 -3
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +8 -14
- package/src/lib/views/LoginView/LoginView.cjs +3 -21
- package/src/lib/views/LoginView/LoginView.js +4 -22
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +11 -1
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +11 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +3 -3
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +3 -3
- package/src/lib/views/NoAccess/NoAccess.cjs +2 -2
- package/src/lib/views/NoAccess/NoAccess.js +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -8
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -8
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +3 -3
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +3 -3
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +1 -2
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +1 -4
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +1 -4
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +15 -20
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.d.ts +8 -13
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +15 -20
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +11 -8
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +11 -8
- package/src/lib/views/viewToComponentMap.cjs +1 -1
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/views/viewToComponentMap.js +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -1
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.cjs +0 -31
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.d.ts +0 -1
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.js +0 -27
- package/src/lib/utils/functions/getOnboardingAuthToken/index.d.ts +0 -1
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +0 -49
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.d.ts +0 -13
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +0 -45
- package/src/lib/utils/functions/handleUnlinkHelper/index.d.ts +0 -1
|
@@ -34,7 +34,7 @@ import 'react-dom';
|
|
|
34
34
|
import '../../../context/WalletContext/WalletContext.js';
|
|
35
35
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
36
36
|
import '@dynamic-labs/types';
|
|
37
|
-
import '
|
|
37
|
+
import { useUserAuth } from '../useUserAuth/useUserAuth.js';
|
|
38
38
|
import 'yup';
|
|
39
39
|
import '../../../context/MockContext/MockContext.js';
|
|
40
40
|
import '../../../views/CollectUserDataView/useFields.js';
|
|
@@ -64,6 +64,7 @@ import '../../../views/WalletList/WalletList.js';
|
|
|
64
64
|
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
65
65
|
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
66
66
|
import '@hcaptcha/react-hcaptcha';
|
|
67
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
67
68
|
import '../../../context/FooterAnimationContext/index.js';
|
|
68
69
|
import '../../../views/LoginView/sections/PhoneNumberSignInSection/PhoneNumberSignInSection.js';
|
|
69
70
|
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
@@ -76,18 +77,19 @@ import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCar
|
|
|
76
77
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
77
78
|
|
|
78
79
|
const useMfa = () => {
|
|
79
|
-
const {
|
|
80
|
+
const { completeAuth } = useUserAuth({});
|
|
81
|
+
const { user, userWithMissingFields, environmentId } = useInternalDynamicContext();
|
|
80
82
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
81
|
-
const
|
|
83
|
+
const verifiedUser = user || userWithMissingFields;
|
|
82
84
|
const getUserDevices = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
-
if (!
|
|
85
|
+
if (!verifiedUser) {
|
|
84
86
|
throw new Error('User is not logged in');
|
|
85
87
|
}
|
|
86
88
|
const devices = yield getUserMfaDevices({ environmentId });
|
|
87
89
|
return devices;
|
|
88
90
|
});
|
|
89
91
|
const updateUserDevice = (deviceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
if (!
|
|
92
|
+
if (!verifiedUser) {
|
|
91
93
|
throw new Error('User is not logged in');
|
|
92
94
|
}
|
|
93
95
|
yield updateUserMfaDevice({
|
|
@@ -96,7 +98,7 @@ const useMfa = () => {
|
|
|
96
98
|
});
|
|
97
99
|
});
|
|
98
100
|
const deleteUserDevice = (deviceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
if (!
|
|
101
|
+
if (!verifiedUser) {
|
|
100
102
|
throw new Error('User is not logged in');
|
|
101
103
|
}
|
|
102
104
|
yield deleteMfaDevice({
|
|
@@ -105,7 +107,7 @@ const useMfa = () => {
|
|
|
105
107
|
});
|
|
106
108
|
});
|
|
107
109
|
const addDevice = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (type = MFADeviceType.Totp) {
|
|
108
|
-
if (!
|
|
110
|
+
if (!verifiedUser) {
|
|
109
111
|
throw new Error('User is not logged in');
|
|
110
112
|
}
|
|
111
113
|
const { id, secret, uri } = yield addMfaDevice({
|
|
@@ -115,22 +117,37 @@ const useMfa = () => {
|
|
|
115
117
|
return { id, secret, uri };
|
|
116
118
|
});
|
|
117
119
|
const authDevice = (code_1, ...args_2) => __awaiter(void 0, [code_1, ...args_2], void 0, function* (code, type = MFADeviceType.Totp) {
|
|
118
|
-
if (!
|
|
120
|
+
if (!verifiedUser) {
|
|
119
121
|
throw new Error('User is not logged in');
|
|
120
122
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
let isValid = false;
|
|
124
|
+
yield completeAuth({
|
|
125
|
+
onValidUpdatedJwt: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
isValid = true;
|
|
127
|
+
}),
|
|
128
|
+
updateJwtFunction: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
const response = yield authMfaDevice({
|
|
130
|
+
code,
|
|
131
|
+
environmentId,
|
|
132
|
+
type,
|
|
133
|
+
});
|
|
134
|
+
if (!response) {
|
|
135
|
+
throw new Error('Failed to authenticate device');
|
|
136
|
+
}
|
|
137
|
+
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
138
|
+
return {
|
|
139
|
+
isEmailVerificationRequired: false,
|
|
140
|
+
isSmsVerificationRequired: false,
|
|
141
|
+
missingFields: [],
|
|
142
|
+
// in the mfa flow, we only care about the tokens in the response
|
|
143
|
+
updateUserProfileResponse: response,
|
|
144
|
+
};
|
|
145
|
+
}),
|
|
125
146
|
});
|
|
126
|
-
|
|
127
|
-
throw new Error('Failed to authenticate device');
|
|
128
|
-
}
|
|
129
|
-
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
130
|
-
return true;
|
|
147
|
+
return isValid;
|
|
131
148
|
});
|
|
132
149
|
const authRecoveryCode = (code) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
-
if (!
|
|
150
|
+
if (!verifiedUser) {
|
|
134
151
|
throw new Error('User is not logged in');
|
|
135
152
|
}
|
|
136
153
|
const response = yield authMfaRecovery({
|
|
@@ -143,7 +160,7 @@ const useMfa = () => {
|
|
|
143
160
|
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
144
161
|
});
|
|
145
162
|
const verifyDevice = (code_2, ...args_3) => __awaiter(void 0, [code_2, ...args_3], void 0, function* (code, type = MFADeviceType.Totp) {
|
|
146
|
-
if (!
|
|
163
|
+
if (!verifiedUser) {
|
|
147
164
|
throw new Error('User is not logged in');
|
|
148
165
|
}
|
|
149
166
|
const device = yield verifyMfaDevice({
|
|
@@ -157,7 +174,7 @@ const useMfa = () => {
|
|
|
157
174
|
return device;
|
|
158
175
|
});
|
|
159
176
|
const getRecoveryCodes$1 = (...args_4) => __awaiter(void 0, [...args_4], void 0, function* (generateNewCodes = false) {
|
|
160
|
-
if (!
|
|
177
|
+
if (!verifiedUser) {
|
|
161
178
|
throw new Error('User is not logged in');
|
|
162
179
|
}
|
|
163
180
|
const getRecoveryCodesFunc = generateNewCodes
|
|
@@ -35,8 +35,8 @@ require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
35
35
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
36
36
|
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
37
37
|
require('@dynamic-labs/types');
|
|
38
|
-
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
39
38
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
39
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
40
40
|
require('yup');
|
|
41
41
|
require('../../../context/MockContext/MockContext.cjs');
|
|
42
42
|
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
@@ -31,8 +31,8 @@ import '../../../context/ErrorContext/ErrorContext.js';
|
|
|
31
31
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
32
32
|
import '../../../context/VerificationContext/VerificationContext.js';
|
|
33
33
|
import '@dynamic-labs/types';
|
|
34
|
-
import '../../../context/LoadingContext/LoadingContext.js';
|
|
35
34
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
35
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
36
36
|
import 'yup';
|
|
37
37
|
import '../../../context/MockContext/MockContext.js';
|
|
38
38
|
import '../../../views/CollectUserDataView/useFields.js';
|
|
@@ -32,6 +32,7 @@ var getEOAWallet = require('../../functions/getEOAWallet/getEOAWallet.cjs');
|
|
|
32
32
|
require('../../../config/ApiEndpoint.cjs');
|
|
33
33
|
require('../../../locale/locale.cjs');
|
|
34
34
|
var user = require('../../../data/api/user/user.cjs');
|
|
35
|
+
require('@dynamic-labs/store');
|
|
35
36
|
var updateJWTAndCreateUserProfile = require('../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.cjs');
|
|
36
37
|
var getEmbeddedWalletSessionExpiration = require('../../functions/getEmbeddedWalletSessionExpiration/getEmbeddedWalletSessionExpiration.cjs');
|
|
37
38
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
@@ -54,7 +55,6 @@ require('../../../context/MockContext/MockContext.cjs');
|
|
|
54
55
|
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
55
56
|
require('../useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
56
57
|
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
57
|
-
require('@dynamic-labs/store');
|
|
58
58
|
require('@dynamic-labs/rpc-providers');
|
|
59
59
|
require('react-i18next');
|
|
60
60
|
require('../../../components/Alert/Alert.cjs');
|
|
@@ -93,7 +93,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
93
93
|
// Hook exposed to customers and used internally to trigger passkey recovery
|
|
94
94
|
const usePasskeyRecovery = () => {
|
|
95
95
|
var _a, _b;
|
|
96
|
-
const {
|
|
96
|
+
const { environmentId, primaryWallet, projectSettings, setShowAuthFlow, user: user$1, setUser, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
97
97
|
const { createRootElement } = useElementById.useElementById();
|
|
98
98
|
const iframeContainerRef = createRootElement(constants.iframeContainerId);
|
|
99
99
|
const { userHasEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
|
|
@@ -215,17 +215,17 @@ const usePasskeyRecovery = () => {
|
|
|
215
215
|
};
|
|
216
216
|
const addRecoveryEmail = (emailInput) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
217
217
|
try {
|
|
218
|
-
let
|
|
218
|
+
let updatedUser = user$1;
|
|
219
|
+
// TODO - This seems wrong what if the user has a different email.
|
|
220
|
+
// As well it does not verify the the email is verified
|
|
219
221
|
if (!(user$1 === null || user$1 === void 0 ? void 0 : user$1.email)) {
|
|
220
|
-
|
|
222
|
+
updatedUser = yield updateUserProfile(emailInput);
|
|
221
223
|
}
|
|
222
|
-
|
|
223
|
-
authToken: jwt,
|
|
224
|
+
yield passkeyRecovery.addEmailRecovery({
|
|
224
225
|
environmentId,
|
|
225
|
-
|
|
226
|
+
user: updatedUser,
|
|
226
227
|
wallet: primaryWallet,
|
|
227
|
-
})
|
|
228
|
-
setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(newerJwt, minifiedJwt));
|
|
228
|
+
});
|
|
229
229
|
dynamicEvents.dynamicEvents.emit('embeddedWalletRecoveryEmailCompleted', '');
|
|
230
230
|
}
|
|
231
231
|
catch (err) {
|
|
@@ -235,19 +235,20 @@ const usePasskeyRecovery = () => {
|
|
|
235
235
|
});
|
|
236
236
|
const updateUserProfile = (emailInput) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
237
237
|
try {
|
|
238
|
-
const { nextView, emailVerification,
|
|
238
|
+
const { nextView, emailVerification, userProfile } = yield user.updateUserProfileFields(environmentId, {
|
|
239
239
|
email: emailInput,
|
|
240
240
|
});
|
|
241
241
|
if (nextView === sdkApiCore.NextViewEnum.Done) {
|
|
242
|
-
return
|
|
242
|
+
return userProfile;
|
|
243
243
|
}
|
|
244
244
|
setView('verify-email', { isEmailRecoveryFlow: true });
|
|
245
245
|
setEmailForVerification(emailInput);
|
|
246
246
|
setVerificationUUID(emailVerification === null || emailVerification === void 0 ? void 0 : emailVerification.verificationUUID);
|
|
247
247
|
return new Promise((resolve, reject) => {
|
|
248
|
+
// TODO - This is not the latest user, it is the not verified user
|
|
248
249
|
dynamicEvents.dynamicEvents.once('emailVerificationResult', (wasSuccessful) => {
|
|
249
250
|
if (wasSuccessful) {
|
|
250
|
-
resolve(
|
|
251
|
+
resolve(userProfile);
|
|
251
252
|
}
|
|
252
253
|
reject('Failed to verify email');
|
|
253
254
|
});
|
|
@@ -28,6 +28,7 @@ import { getEOAWallet } from '../../functions/getEOAWallet/getEOAWallet.js';
|
|
|
28
28
|
import '../../../config/ApiEndpoint.js';
|
|
29
29
|
import '../../../locale/locale.js';
|
|
30
30
|
import { updateUserProfileFields } from '../../../data/api/user/user.js';
|
|
31
|
+
import '@dynamic-labs/store';
|
|
31
32
|
import { updateJWTAndCreateUserProfile } from '../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.js';
|
|
32
33
|
import { getEmbeddedWalletSessionExpiration } from '../../functions/getEmbeddedWalletSessionExpiration/getEmbeddedWalletSessionExpiration.js';
|
|
33
34
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
@@ -50,7 +51,6 @@ import '../../../context/MockContext/MockContext.js';
|
|
|
50
51
|
import '../../../views/CollectUserDataView/useFields.js';
|
|
51
52
|
import '../useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
52
53
|
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
53
|
-
import '@dynamic-labs/store';
|
|
54
54
|
import '@dynamic-labs/rpc-providers';
|
|
55
55
|
import 'react-i18next';
|
|
56
56
|
import '../../../components/Alert/Alert.js';
|
|
@@ -89,7 +89,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
89
89
|
// Hook exposed to customers and used internally to trigger passkey recovery
|
|
90
90
|
const usePasskeyRecovery = () => {
|
|
91
91
|
var _a, _b;
|
|
92
|
-
const {
|
|
92
|
+
const { environmentId, primaryWallet, projectSettings, setShowAuthFlow, user, setUser, } = useInternalDynamicContext();
|
|
93
93
|
const { createRootElement } = useElementById();
|
|
94
94
|
const iframeContainerRef = createRootElement(iframeContainerId);
|
|
95
95
|
const { userHasEmbeddedWallet } = useEmbeddedWallet();
|
|
@@ -211,17 +211,17 @@ const usePasskeyRecovery = () => {
|
|
|
211
211
|
};
|
|
212
212
|
const addRecoveryEmail = (emailInput) => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
213
|
try {
|
|
214
|
-
let
|
|
214
|
+
let updatedUser = user;
|
|
215
|
+
// TODO - This seems wrong what if the user has a different email.
|
|
216
|
+
// As well it does not verify the the email is verified
|
|
215
217
|
if (!(user === null || user === void 0 ? void 0 : user.email)) {
|
|
216
|
-
|
|
218
|
+
updatedUser = yield updateUserProfile(emailInput);
|
|
217
219
|
}
|
|
218
|
-
|
|
219
|
-
authToken: jwt,
|
|
220
|
+
yield addEmailRecovery({
|
|
220
221
|
environmentId,
|
|
221
|
-
|
|
222
|
+
user: updatedUser,
|
|
222
223
|
wallet: primaryWallet,
|
|
223
|
-
})
|
|
224
|
-
setUser(updateJWTAndCreateUserProfile(newerJwt, minifiedJwt));
|
|
224
|
+
});
|
|
225
225
|
dynamicEvents.emit('embeddedWalletRecoveryEmailCompleted', '');
|
|
226
226
|
}
|
|
227
227
|
catch (err) {
|
|
@@ -231,19 +231,20 @@ const usePasskeyRecovery = () => {
|
|
|
231
231
|
});
|
|
232
232
|
const updateUserProfile = (emailInput) => __awaiter(void 0, void 0, void 0, function* () {
|
|
233
233
|
try {
|
|
234
|
-
const { nextView, emailVerification,
|
|
234
|
+
const { nextView, emailVerification, userProfile } = yield updateUserProfileFields(environmentId, {
|
|
235
235
|
email: emailInput,
|
|
236
236
|
});
|
|
237
237
|
if (nextView === NextViewEnum.Done) {
|
|
238
|
-
return
|
|
238
|
+
return userProfile;
|
|
239
239
|
}
|
|
240
240
|
setView('verify-email', { isEmailRecoveryFlow: true });
|
|
241
241
|
setEmailForVerification(emailInput);
|
|
242
242
|
setVerificationUUID(emailVerification === null || emailVerification === void 0 ? void 0 : emailVerification.verificationUUID);
|
|
243
243
|
return new Promise((resolve, reject) => {
|
|
244
|
+
// TODO - This is not the latest user, it is the not verified user
|
|
244
245
|
dynamicEvents.once('emailVerificationResult', (wasSuccessful) => {
|
|
245
246
|
if (wasSuccessful) {
|
|
246
|
-
resolve(
|
|
247
|
+
resolve(userProfile);
|
|
247
248
|
}
|
|
248
249
|
reject('Failed to verify email');
|
|
249
250
|
});
|
|
@@ -26,23 +26,18 @@ require('viem');
|
|
|
26
26
|
require('viem/chains');
|
|
27
27
|
require('../../../config/ApiEndpoint.cjs');
|
|
28
28
|
require('../../../locale/locale.cjs');
|
|
29
|
-
var userActions = require('../../../store/actions/userActions/userActions.cjs');
|
|
30
|
-
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
31
|
-
var updateJWTAndCreateUserProfile = require('../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.cjs');
|
|
32
29
|
require('@dynamic-labs/store');
|
|
30
|
+
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
33
31
|
|
|
34
|
-
const usePrimaryWalletId = ({
|
|
32
|
+
const usePrimaryWalletId = ({ environmentId, user }) => {
|
|
35
33
|
const [primaryWalletId, setPrimaryWalletIdState, clearPrimaryWalletId] = useLocalStorage.useLocalStorage(localStorage.PRIMARY_WALLET_ID, undefined, primaryWalletIdValidator.primaryWalletIdValidator);
|
|
36
34
|
const setPrimaryWalletId = React.useCallback((walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
37
35
|
setPrimaryWalletIdState(walletId);
|
|
38
|
-
if
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (response) {
|
|
42
|
-
userActions.setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(response.jwt, response.minifiedJwt));
|
|
43
|
-
}
|
|
36
|
+
// should only store the selected wallet if the user is authenticated
|
|
37
|
+
if (user) {
|
|
38
|
+
yield wallets.storeSelectedWallet({ environmentId, walletId });
|
|
44
39
|
}
|
|
45
|
-
}), [setPrimaryWalletIdState]);
|
|
40
|
+
}), [environmentId, setPrimaryWalletIdState, user]);
|
|
46
41
|
return {
|
|
47
42
|
clearPrimaryWalletId,
|
|
48
43
|
primaryWalletId,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { UserProfile } from '../../../..';
|
|
1
2
|
type Props = {
|
|
2
3
|
environmentId: string;
|
|
3
|
-
|
|
4
|
+
user: UserProfile | undefined;
|
|
4
5
|
};
|
|
5
|
-
export declare const usePrimaryWalletId: ({
|
|
6
|
+
export declare const usePrimaryWalletId: ({ environmentId, user }: Props) => {
|
|
6
7
|
clearPrimaryWalletId: () => void;
|
|
7
8
|
primaryWalletId: string | undefined;
|
|
8
9
|
setPrimaryWalletId: (walletId: string) => Promise<void>;
|
|
@@ -22,23 +22,18 @@ import 'viem';
|
|
|
22
22
|
import 'viem/chains';
|
|
23
23
|
import '../../../config/ApiEndpoint.js';
|
|
24
24
|
import '../../../locale/locale.js';
|
|
25
|
-
import { setUser } from '../../../store/actions/userActions/userActions.js';
|
|
26
|
-
import { storeSelectedWallet } from '../../../data/api/wallets/wallets.js';
|
|
27
|
-
import { updateJWTAndCreateUserProfile } from '../../functions/updateJWTAndCreateUserProfile/updateJWTAndCreateUserProfile.js';
|
|
28
25
|
import '@dynamic-labs/store';
|
|
26
|
+
import { storeSelectedWallet } from '../../../data/api/wallets/wallets.js';
|
|
29
27
|
|
|
30
|
-
const usePrimaryWalletId = ({
|
|
28
|
+
const usePrimaryWalletId = ({ environmentId, user }) => {
|
|
31
29
|
const [primaryWalletId, setPrimaryWalletIdState, clearPrimaryWalletId] = useLocalStorage(PRIMARY_WALLET_ID, undefined, primaryWalletIdValidator);
|
|
32
30
|
const setPrimaryWalletId = useCallback((walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
31
|
setPrimaryWalletIdState(walletId);
|
|
34
|
-
if
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (response) {
|
|
38
|
-
setUser(updateJWTAndCreateUserProfile(response.jwt, response.minifiedJwt));
|
|
39
|
-
}
|
|
32
|
+
// should only store the selected wallet if the user is authenticated
|
|
33
|
+
if (user) {
|
|
34
|
+
yield storeSelectedWallet({ environmentId, walletId });
|
|
40
35
|
}
|
|
41
|
-
}), [setPrimaryWalletIdState]);
|
|
36
|
+
}), [environmentId, setPrimaryWalletIdState, user]);
|
|
42
37
|
return {
|
|
43
38
|
clearPrimaryWalletId,
|
|
44
39
|
primaryWalletId,
|
|
@@ -3,30 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require('../../../shared/logger.cjs');
|
|
9
|
-
require('@dynamic-labs/iconic');
|
|
10
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
11
|
-
require('react/jsx-runtime');
|
|
12
|
-
require('../../../context/ViewContext/ViewContext.cjs');
|
|
13
|
-
require('react');
|
|
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('@dynamic-labs/utils');
|
|
19
|
-
require('../../../shared/consts/index.cjs');
|
|
20
|
-
|
|
21
|
-
const useSetWalletConnectorVerifiedCredentials = (authToken, walletOptions) => {
|
|
22
|
-
if (!authToken || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
23
|
-
return;
|
|
24
|
-
const decodedJwt = decodeJwt.decodeJwt(authToken);
|
|
25
|
-
if (!decodedJwt) {
|
|
6
|
+
const useSetWalletConnectorVerifiedCredentials = (user, walletOptions) => {
|
|
7
|
+
if (!user || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
26
8
|
return;
|
|
27
|
-
}
|
|
28
9
|
walletOptions.forEach((walletOption) => {
|
|
29
|
-
walletOption.walletConnector.setVerifiedCredentials(
|
|
10
|
+
walletOption.walletConnector.setVerifiedCredentials(user.verifiedCredentials);
|
|
30
11
|
});
|
|
31
12
|
};
|
|
32
13
|
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { UserProfile } from '../../../..';
|
|
1
2
|
import { WalletOption } from '../../../shared';
|
|
2
|
-
export declare const useSetWalletConnectorVerifiedCredentials: (
|
|
3
|
+
export declare const useSetWalletConnectorVerifiedCredentials: (user: UserProfile | undefined, walletOptions: WalletOption[] | undefined) => void;
|
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '../../../shared/logger.js';
|
|
5
|
-
import '@dynamic-labs/iconic';
|
|
6
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
-
import 'react/jsx-runtime';
|
|
8
|
-
import '../../../context/ViewContext/ViewContext.js';
|
|
9
|
-
import 'react';
|
|
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
|
-
|
|
17
|
-
const useSetWalletConnectorVerifiedCredentials = (authToken, walletOptions) => {
|
|
18
|
-
if (!authToken || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
19
|
-
return;
|
|
20
|
-
const decodedJwt = decodeJwt(authToken);
|
|
21
|
-
if (!decodedJwt) {
|
|
2
|
+
const useSetWalletConnectorVerifiedCredentials = (user, walletOptions) => {
|
|
3
|
+
if (!user || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
22
4
|
return;
|
|
23
|
-
}
|
|
24
5
|
walletOptions.forEach((walletOption) => {
|
|
25
|
-
walletOption.walletConnector.setVerifiedCredentials(
|
|
6
|
+
walletOption.walletConnector.setVerifiedCredentials(user.verifiedCredentials);
|
|
26
7
|
});
|
|
27
8
|
};
|
|
28
9
|
|
|
@@ -108,18 +108,18 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
108
108
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
109
109
|
const checkValidOAuthLinking = (provider) => {
|
|
110
110
|
if (!isSocialKycEnabled.isSocialKycEnabled(projectSettings)) {
|
|
111
|
-
handleError(types.SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard');
|
|
111
|
+
handleError(provider, types.SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard', { raiseAuthFailure: false });
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
114
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
115
115
|
if (verifiedCredential) {
|
|
116
|
-
handleError(types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}
|
|
116
|
+
handleError(provider, types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
const oauthProviders = index.getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
120
120
|
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
121
121
|
if (!oauthProvider) {
|
|
122
|
-
handleError(types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}
|
|
122
|
+
handleError(provider, types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`, { raiseAuthFailure: false });
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
125
125
|
return true;
|
|
@@ -135,12 +135,12 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
135
135
|
var _a;
|
|
136
136
|
setError(undefined);
|
|
137
137
|
setIsProcessing(true);
|
|
138
|
-
if (!checkValidProvider(provider)) {
|
|
138
|
+
if (!checkValidProvider(provider, 'unlink')) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
142
142
|
if (!verifiedCredential) {
|
|
143
|
-
handleError(types.SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}
|
|
143
|
+
handleError(provider, types.SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
try {
|
|
@@ -151,14 +151,14 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
151
151
|
verifiedCrentialId: (_a = verifiedCredential.id) !== null && _a !== void 0 ? _a : '',
|
|
152
152
|
});
|
|
153
153
|
if (!response) {
|
|
154
|
-
handleError(types.SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}
|
|
154
|
+
handleError(provider, types.SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`, { raiseAuthFailure: false });
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
158
158
|
setIsProcessing(false);
|
|
159
159
|
}
|
|
160
160
|
catch (err) {
|
|
161
|
-
handleError(types.SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}
|
|
161
|
+
handleError(provider, types.SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`, { raiseAuthFailure: false });
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
const isLinked = (provider) => Boolean(verifiedOAuthCredentialsMap[provider]);
|
|
@@ -183,7 +183,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
183
183
|
var _a;
|
|
184
184
|
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);
|
|
185
185
|
if (!oauthProvider) {
|
|
186
|
-
handleError(types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled for sign-in on the dashboard: ${provider}
|
|
186
|
+
handleError(provider, types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled for sign-in on the dashboard: ${provider}`, { raiseAuthFailure: true });
|
|
187
187
|
return false;
|
|
188
188
|
}
|
|
189
189
|
return true;
|
|
@@ -104,18 +104,18 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
104
104
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
105
105
|
const checkValidOAuthLinking = (provider) => {
|
|
106
106
|
if (!isSocialKycEnabled(projectSettings)) {
|
|
107
|
-
handleError(SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard');
|
|
107
|
+
handleError(provider, SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled on the dashboard', { raiseAuthFailure: false });
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
111
111
|
if (verifiedCredential) {
|
|
112
|
-
handleError(SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}
|
|
112
|
+
handleError(provider, SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
115
115
|
const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
116
116
|
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
117
117
|
if (!oauthProvider) {
|
|
118
|
-
handleError(SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}
|
|
118
|
+
handleError(provider, SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled on the dashboard: ${provider}`, { raiseAuthFailure: false });
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
121
|
return true;
|
|
@@ -131,12 +131,12 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
131
131
|
var _a;
|
|
132
132
|
setError(undefined);
|
|
133
133
|
setIsProcessing(true);
|
|
134
|
-
if (!checkValidProvider(provider)) {
|
|
134
|
+
if (!checkValidProvider(provider, 'unlink')) {
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
138
138
|
if (!verifiedCredential) {
|
|
139
|
-
handleError(SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}
|
|
139
|
+
handleError(provider, SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
try {
|
|
@@ -147,14 +147,14 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
147
147
|
verifiedCrentialId: (_a = verifiedCredential.id) !== null && _a !== void 0 ? _a : '',
|
|
148
148
|
});
|
|
149
149
|
if (!response) {
|
|
150
|
-
handleError(SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}
|
|
150
|
+
handleError(provider, SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`, { raiseAuthFailure: false });
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
153
153
|
yield updateUserProfileByJWT(response.jwt, response.minifiedJwt);
|
|
154
154
|
setIsProcessing(false);
|
|
155
155
|
}
|
|
156
156
|
catch (err) {
|
|
157
|
-
handleError(SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}
|
|
157
|
+
handleError(provider, SocialOAuthErrorCode.GENERAL_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`, { raiseAuthFailure: false });
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
const isLinked = (provider) => Boolean(verifiedOAuthCredentialsMap[provider]);
|
|
@@ -179,7 +179,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
179
179
|
var _a;
|
|
180
180
|
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);
|
|
181
181
|
if (!oauthProvider) {
|
|
182
|
-
handleError(SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled for sign-in on the dashboard: ${provider}
|
|
182
|
+
handleError(provider, SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Provider is not enabled for sign-in on the dashboard: ${provider}`, { raiseAuthFailure: true });
|
|
183
183
|
return false;
|
|
184
184
|
}
|
|
185
185
|
return true;
|