@dynamic-labs/sdk-react-core 4.4.2 → 4.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/Main.cjs +3 -3
- package/src/lib/Main.js +3 -3
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.cjs +2 -3
- package/src/lib/components/DynamicConnectButton/DynamicConnectButton.js +2 -3
- package/src/lib/components/NeedHelpSection/NeedHelpSection.cjs +2 -2
- package/src/lib/components/NeedHelpSection/NeedHelpSection.js +2 -2
- package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.cjs +2 -2
- package/src/lib/components/QrCodeWrapper/QrCodeContainer/QrCodeContainer.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/utils.cjs +2 -2
- package/src/lib/components/TransactionConfirmationPageLayout/utils.d.ts +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/utils.js +2 -2
- package/src/lib/context/CaptchaContext/CaptchaContext.cjs +3 -3
- package/src/lib/context/CaptchaContext/CaptchaContext.js +3 -3
- package/src/lib/context/MockContext/MockContext.cjs +0 -2
- package/src/lib/context/MockContext/MockContext.js +0 -2
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +5 -5
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +5 -5
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +8 -9
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +8 -9
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +8 -3
- package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +8 -3
- package/src/lib/context/ViewContext/ViewContext.cjs +0 -2
- package/src/lib/context/ViewContext/ViewContext.d.ts +0 -10
- package/src/lib/context/ViewContext/ViewContext.js +0 -2
- package/src/lib/context/WalletGroupContext/WalletGroupContext.cjs +3 -3
- package/src/lib/context/WalletGroupContext/WalletGroupContext.js +3 -3
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +4 -4
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +4 -4
- package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.cjs +4 -0
- package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.js +4 -0
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.cjs +3 -3
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.d.ts +1 -1
- package/src/lib/utils/hooks/authenticationHooks/helpers/showPendingConnectView.js +3 -3
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +8 -8
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +8 -8
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +7 -7
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +7 -7
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +2 -2
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.cjs +3 -3
- package/src/lib/utils/hooks/useConnectedWalletsNetworkValidation/useConnectedWalletsNetworkValidation.js +3 -3
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.cjs +3 -3
- package/src/lib/utils/hooks/useDynamicModals/useDynamicModals.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedReveal/useEmbeddedReveal.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +3 -3
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWalletAuthenticator/useEmbeddedWalletAuthenticator.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +4 -4
- package/src/lib/utils/hooks/useFunding/useConnectWalletForFunding/useConnectWalletForFunding.cjs +3 -3
- package/src/lib/utils/hooks/useFunding/useConnectWalletForFunding/useConnectWalletForFunding.js +3 -3
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.cjs +6 -6
- package/src/lib/utils/hooks/useHandleWalletsToConnect/useHandleWalletsToConnect.js +6 -6
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.cjs +2 -2
- package/src/lib/utils/hooks/useInitEmbeddedWalletAuthMethod/useInitEmbeddedWalletAuthMethod.js +2 -2
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.cjs +11 -11
- package/src/lib/utils/hooks/useMfaModals/useMfaModals.js +11 -11
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +5 -7
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +5 -7
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +38 -24
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +3 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +38 -24
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.cjs +3 -3
- package/src/lib/utils/hooks/useSwitchNetwork/useSwitchNetwork.js +3 -3
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +5 -5
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +5 -5
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +5 -5
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +5 -5
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +9 -9
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +9 -9
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.cjs +6 -6
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUserWithModal/useUpdateUserWithModal.js +6 -6
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +12 -12
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +12 -12
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.cjs +7 -7
- package/src/lib/utils/hooks/useWalletItemActions/useHandleWalletItem/useHandleWalletItem.js +7 -7
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +4 -4
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +4 -4
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.cjs +3 -3
- package/src/lib/utils/hooks/useWalletOptions/useWalletOptions.js +3 -3
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.cjs +2 -2
- package/src/lib/views/BridgeNextWalletConnectionView/BridgeNextWalletConnectionView.js +2 -2
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.cjs +2 -2
- package/src/lib/views/BridgeWelcomeView/BridgeWelcomeView.js +2 -2
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.cjs +2 -2
- package/src/lib/views/CoinbaseMPCClaimIntro/CoinbaseMPCClaimIntro.js +2 -2
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.cjs +3 -3
- package/src/lib/views/EmailConfirmationWaitingView/EmailConfirmationWaitingView.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +2 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +2 -2
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +4 -4
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +4 -4
- package/src/lib/views/LoginView/LoginView.cjs +2 -2
- package/src/lib/views/LoginView/LoginView.js +2 -2
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.cjs +4 -4
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.js +4 -4
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +3 -3
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +3 -3
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +5 -5
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +5 -5
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +3 -3
- package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +3 -3
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +4 -4
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +4 -4
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.cjs +5 -5
- package/src/lib/views/MfaChooseDeviceView/MfaChooseDeviceView.js +5 -5
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.cjs +5 -5
- package/src/lib/views/MfaSecureDeviceView/MfaSecureDeviceView.js +5 -5
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +5 -5
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +5 -5
- package/src/lib/views/NoAccess/NoAccess.cjs +2 -2
- package/src/lib/views/NoAccess/NoAccess.js +2 -2
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +2 -4
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +2 -4
- package/src/lib/views/SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.cjs +2 -2
- package/src/lib/views/SandboxMaximumThresholdReached/SandboxMaximumThresholdReached.js +2 -2
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.cjs +2 -2
- package/src/lib/views/WalletCannotBeTransferredView/WalletCannotBeTransferredView.js +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.cjs +2 -2
- package/src/lib/views/WalletList/WalletListItem/WalletListItem.js +2 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +2 -2
- package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.cjs +2 -2
- package/src/lib/views/WalletUsedView/WalletUsedView.js +2 -2
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicBridgeWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.cjs +1 -4
- package/src/lib/widgets/DynamicWidget/components/DotsMenu/DotsMenu.js +1 -4
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.cjs +3 -3
- package/src/lib/widgets/DynamicWidget/views/EditProfileView/EditProfileView.js +3 -3
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.cjs +4 -4
- package/src/lib/widgets/DynamicWidget/views/GlobalWalletView/GlobalWalletView.js +4 -4
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManageMfaWidgetView/ManageMfaWidgetView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js +2 -2
|
@@ -109,7 +109,7 @@ const usePasskeyRecovery = () => {
|
|
|
109
109
|
const { initAuthMethod } = useInitEmbeddedWalletAuthMethod();
|
|
110
110
|
const { setDisplayedDestination: setEmailForVerification, setVerificationUUID, } = useVerification();
|
|
111
111
|
const { getEOAWallet } = useSmartWallets();
|
|
112
|
-
const {
|
|
112
|
+
const { pushView } = useViewContext();
|
|
113
113
|
const wallet = (_a = (primaryWallet && getEOAWallet(primaryWallet))) !== null && _a !== void 0 ? _a : primaryWallet;
|
|
114
114
|
const isSessionRestored = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
115
|
var _d, _e;
|
|
@@ -186,7 +186,7 @@ const usePasskeyRecovery = () => {
|
|
|
186
186
|
? Object.keys(supportedAuthenticators)
|
|
187
187
|
: [];
|
|
188
188
|
if (!hasRecoveryEmail) {
|
|
189
|
-
|
|
189
|
+
pushView('passkey-recovery-add-email', { shouldInitRecovery: true });
|
|
190
190
|
setShowAuthFlow(true, {
|
|
191
191
|
ignoreIfIsEmbeddedWidget: false,
|
|
192
192
|
performMultiWalletChecks: false,
|
|
@@ -194,9 +194,7 @@ const usePasskeyRecovery = () => {
|
|
|
194
194
|
}
|
|
195
195
|
else if (!authenticatorType &&
|
|
196
196
|
supportedAuthenticatorMethods.length > 1) {
|
|
197
|
-
|
|
198
|
-
currentAction,
|
|
199
|
-
});
|
|
197
|
+
pushView('embedded-wallet-auth-choice', { currentAction });
|
|
200
198
|
setShowAuthFlow(true, {
|
|
201
199
|
ignoreIfIsEmbeddedWidget: false,
|
|
202
200
|
performMultiWalletChecks: false,
|
|
@@ -228,7 +226,7 @@ const usePasskeyRecovery = () => {
|
|
|
228
226
|
environmentId,
|
|
229
227
|
user,
|
|
230
228
|
setShowAuthFlow,
|
|
231
|
-
|
|
229
|
+
pushView,
|
|
232
230
|
initAuthMethod,
|
|
233
231
|
iframeContainerRef,
|
|
234
232
|
]);
|
|
@@ -260,7 +258,7 @@ const usePasskeyRecovery = () => {
|
|
|
260
258
|
if (nextView === NextViewEnum.Done) {
|
|
261
259
|
return userProfile;
|
|
262
260
|
}
|
|
263
|
-
|
|
261
|
+
pushView('verify-email', { isEmailRecoveryFlow: true });
|
|
264
262
|
setEmailForVerification(emailInput);
|
|
265
263
|
setVerificationUUID(emailVerification === null || emailVerification === void 0 ? void 0 : emailVerification.verificationUUID);
|
|
266
264
|
return new Promise((resolve, reject) => {
|
|
@@ -100,10 +100,10 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
100
100
|
const useSocialAccounts = () => {
|
|
101
101
|
var _a;
|
|
102
102
|
const { environmentId, user, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
103
|
-
const {
|
|
103
|
+
const { pushView } = ViewContext.useViewContext();
|
|
104
104
|
const { setSocialProvider } = SocialRedirectContext.useSocialRedirectContext();
|
|
105
105
|
const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth.useSocialAuth({
|
|
106
|
-
onFarcasterUrl: (url) =>
|
|
106
|
+
onFarcasterUrl: (url) => pushView('farcaster-connect-view', { url }, {
|
|
107
107
|
onBackClick: () => {
|
|
108
108
|
setSocialProvider(undefined);
|
|
109
109
|
dynamicEvents.dynamicEvents.emit('farcasterConnectCancelled');
|
|
@@ -118,32 +118,28 @@ const useSocialAccounts = () => {
|
|
|
118
118
|
const verifiedOAuthCredentialsMap = React.useMemo(() => {
|
|
119
119
|
var _a, _b;
|
|
120
120
|
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 : [];
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
];
|
|
127
|
-
})
|
|
121
|
+
const credentialMap = new Map();
|
|
122
|
+
verifiedOAuthCredential.forEach((credential) => {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const key = (_a = credential.oauthProvider) !== null && _a !== void 0 ? _a : credential.id;
|
|
125
|
+
const existing = (_b = credentialMap.get(key)) !== null && _b !== void 0 ? _b : [];
|
|
126
|
+
credentialMap.set(key, [...existing, credential]);
|
|
127
|
+
});
|
|
128
|
+
return Object.fromEntries(credentialMap);
|
|
128
129
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
129
130
|
const checkValidOAuthLinking = React.useCallback((provider) => {
|
|
130
131
|
if (!isSocialKycEnabled.isSocialKycEnabled(projectSettings)) {
|
|
131
132
|
handleError(provider, types.SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled in Information Capture on the dashboard', { raiseAuthFailure: false });
|
|
132
133
|
return false;
|
|
133
134
|
}
|
|
134
|
-
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
135
|
-
if (verifiedCredential) {
|
|
136
|
-
handleError(provider, types.SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
135
|
const oauthProviders = index.getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
140
|
-
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
136
|
+
const oauthProvider = oauthProviders === null || oauthProviders === void 0 ? void 0 : oauthProviders.find((p) => p.provider === provider);
|
|
141
137
|
if (!oauthProvider) {
|
|
142
138
|
handleError(provider, types.SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Social linking provider is not enabled in Information Capture on the dashboard: ${provider}`, { raiseAuthFailure: false });
|
|
143
139
|
return false;
|
|
144
140
|
}
|
|
145
141
|
return true;
|
|
146
|
-
}, [handleError, projectSettings
|
|
142
|
+
}, [handleError, projectSettings]);
|
|
147
143
|
const linkSocialAccount = React.useCallback((provider_1, ...args_1) => _tslib.__awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl } = { redirectUrl: undefined }) {
|
|
148
144
|
connectSocialAccount({
|
|
149
145
|
authMode: 'link',
|
|
@@ -152,14 +148,22 @@ const useSocialAccounts = () => {
|
|
|
152
148
|
validator: checkValidOAuthLinking,
|
|
153
149
|
});
|
|
154
150
|
}), [checkValidOAuthLinking, connectSocialAccount]);
|
|
155
|
-
const
|
|
151
|
+
const findVerifiedCredentialById = (provider, verifiedCredentialId) => {
|
|
152
|
+
var _a;
|
|
153
|
+
const verifiedCredentials = (_a = verifiedOAuthCredentialsMap[provider]) !== null && _a !== void 0 ? _a : [];
|
|
154
|
+
const verifiedCredential = verifiedCredentialId
|
|
155
|
+
? verifiedCredentials.find((cred) => cred.id === verifiedCredentialId)
|
|
156
|
+
: verifiedCredentials[0];
|
|
157
|
+
return verifiedCredential;
|
|
158
|
+
};
|
|
159
|
+
const unlinkSocialAccount = React.useCallback((provider, verifiedCredentialId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
156
160
|
var _b;
|
|
157
161
|
setError(undefined);
|
|
158
162
|
setIsProcessing(true);
|
|
159
163
|
if (!checkValidProvider(provider, 'unlink')) {
|
|
160
164
|
return;
|
|
161
165
|
}
|
|
162
|
-
const verifiedCredential =
|
|
166
|
+
const verifiedCredential = findVerifiedCredentialById(provider, verifiedCredentialId);
|
|
163
167
|
if (!verifiedCredential) {
|
|
164
168
|
handleError(provider, types.SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
165
169
|
return;
|
|
@@ -188,12 +192,8 @@ const useSocialAccounts = () => {
|
|
|
188
192
|
setIsProcessing,
|
|
189
193
|
verifiedOAuthCredentialsMap,
|
|
190
194
|
]);
|
|
191
|
-
const isLinked = React.useCallback((provider) => Boolean(verifiedOAuthCredentialsMap[provider]), [verifiedOAuthCredentialsMap]);
|
|
192
|
-
const
|
|
193
|
-
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
194
|
-
if (!verifiedCredential) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
195
|
+
const isLinked = React.useCallback((provider) => { var _a; return Boolean((_a = verifiedOAuthCredentialsMap[provider]) === null || _a === void 0 ? void 0 : _a.length); }, [verifiedOAuthCredentialsMap]);
|
|
196
|
+
const getAccountInformation = (verifiedCredential) => {
|
|
197
197
|
const { id, oauthAccountId, oauthAccountPhotos, oauthDisplayName, oauthEmails, oauthProvider, oauthUsername, publicIdentifier, } = verifiedCredential;
|
|
198
198
|
return {
|
|
199
199
|
accountId: oauthAccountId !== null && oauthAccountId !== void 0 ? oauthAccountId : undefined,
|
|
@@ -205,6 +205,18 @@ const useSocialAccounts = () => {
|
|
|
205
205
|
publicIdentifier,
|
|
206
206
|
username: oauthUsername,
|
|
207
207
|
};
|
|
208
|
+
};
|
|
209
|
+
const getLinkedAccountInformation = React.useCallback((provider, verifiedCredentialId) => {
|
|
210
|
+
const verifiedCredential = findVerifiedCredentialById(provider, verifiedCredentialId);
|
|
211
|
+
if (!verifiedCredential) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
return getAccountInformation(verifiedCredential);
|
|
215
|
+
}, [verifiedOAuthCredentialsMap]);
|
|
216
|
+
const getLinkedAccounts = React.useCallback((provider) => {
|
|
217
|
+
var _a;
|
|
218
|
+
const verifiedCredentials = (_a = verifiedOAuthCredentialsMap[provider]) !== null && _a !== void 0 ? _a : [];
|
|
219
|
+
return verifiedCredentials.map((credential) => getAccountInformation(credential));
|
|
208
220
|
}, [verifiedOAuthCredentialsMap]);
|
|
209
221
|
const checkValidOAuthSignIn = React.useCallback((provider) => {
|
|
210
222
|
var _a;
|
|
@@ -226,6 +238,7 @@ const useSocialAccounts = () => {
|
|
|
226
238
|
return React.useMemo(() => ({
|
|
227
239
|
error,
|
|
228
240
|
getLinkedAccountInformation,
|
|
241
|
+
getLinkedAccounts,
|
|
229
242
|
isLinked,
|
|
230
243
|
isProcessing,
|
|
231
244
|
linkSocialAccount,
|
|
@@ -234,6 +247,7 @@ const useSocialAccounts = () => {
|
|
|
234
247
|
}), [
|
|
235
248
|
error,
|
|
236
249
|
getLinkedAccountInformation,
|
|
250
|
+
getLinkedAccounts,
|
|
237
251
|
isLinked,
|
|
238
252
|
isProcessing,
|
|
239
253
|
linkSocialAccount,
|
|
@@ -8,11 +8,12 @@ type ConnectSocialProps = {
|
|
|
8
8
|
};
|
|
9
9
|
export declare const useSocialAccounts: () => {
|
|
10
10
|
readonly error: import("@dynamic-labs/types").SocialOAuthError | undefined;
|
|
11
|
-
readonly getLinkedAccountInformation: (provider: ProviderEnum) => SocialAccountInformation | undefined;
|
|
11
|
+
readonly getLinkedAccountInformation: (provider: ProviderEnum, verifiedCredentialId?: string) => SocialAccountInformation | undefined;
|
|
12
|
+
readonly getLinkedAccounts: (provider: ProviderEnum) => SocialAccountInformation[];
|
|
12
13
|
readonly isLinked: (provider: ProviderEnum) => boolean;
|
|
13
14
|
readonly isProcessing: boolean;
|
|
14
15
|
readonly linkSocialAccount: (provider: ProviderEnum, { redirectUrl }?: ConnectSocialProps) => Promise<void>;
|
|
15
16
|
readonly signInWithSocialAccount: (provider: ProviderEnum, { redirectUrl }?: ConnectSocialProps) => Promise<void>;
|
|
16
|
-
readonly unlinkSocialAccount: (provider: ProviderEnum) => Promise<void>;
|
|
17
|
+
readonly unlinkSocialAccount: (provider: ProviderEnum, verifiedCredentialId?: string) => Promise<void>;
|
|
17
18
|
};
|
|
18
19
|
export {};
|
|
@@ -96,10 +96,10 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
96
96
|
const useSocialAccounts = () => {
|
|
97
97
|
var _a;
|
|
98
98
|
const { environmentId, user, projectSettings } = useInternalDynamicContext();
|
|
99
|
-
const {
|
|
99
|
+
const { pushView } = useViewContext();
|
|
100
100
|
const { setSocialProvider } = useSocialRedirectContext();
|
|
101
101
|
const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth({
|
|
102
|
-
onFarcasterUrl: (url) =>
|
|
102
|
+
onFarcasterUrl: (url) => pushView('farcaster-connect-view', { url }, {
|
|
103
103
|
onBackClick: () => {
|
|
104
104
|
setSocialProvider(undefined);
|
|
105
105
|
dynamicEvents.emit('farcasterConnectCancelled');
|
|
@@ -114,32 +114,28 @@ const useSocialAccounts = () => {
|
|
|
114
114
|
const verifiedOAuthCredentialsMap = useMemo(() => {
|
|
115
115
|
var _a, _b;
|
|
116
116
|
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 : [];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
];
|
|
123
|
-
})
|
|
117
|
+
const credentialMap = new Map();
|
|
118
|
+
verifiedOAuthCredential.forEach((credential) => {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
const key = (_a = credential.oauthProvider) !== null && _a !== void 0 ? _a : credential.id;
|
|
121
|
+
const existing = (_b = credentialMap.get(key)) !== null && _b !== void 0 ? _b : [];
|
|
122
|
+
credentialMap.set(key, [...existing, credential]);
|
|
123
|
+
});
|
|
124
|
+
return Object.fromEntries(credentialMap);
|
|
124
125
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials]);
|
|
125
126
|
const checkValidOAuthLinking = useCallback((provider) => {
|
|
126
127
|
if (!isSocialKycEnabled(projectSettings)) {
|
|
127
128
|
handleError(provider, SocialOAuthErrorCode.SOCIAL_LINKING_NOT_ENABLED, 'Social linking is not enabled in Information Capture on the dashboard', { raiseAuthFailure: false });
|
|
128
129
|
return false;
|
|
129
130
|
}
|
|
130
|
-
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
131
|
-
if (verifiedCredential) {
|
|
132
|
-
handleError(provider, SocialOAuthErrorCode.ACCOUNT_ALREADY_LINKED, `Account already linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
131
|
const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
136
|
-
const oauthProvider = oauthProviders.find((p) => p.provider === provider);
|
|
132
|
+
const oauthProvider = oauthProviders === null || oauthProviders === void 0 ? void 0 : oauthProviders.find((p) => p.provider === provider);
|
|
137
133
|
if (!oauthProvider) {
|
|
138
134
|
handleError(provider, SocialOAuthErrorCode.PROVIDER_NOT_ENABLED, `Social linking provider is not enabled in Information Capture on the dashboard: ${provider}`, { raiseAuthFailure: false });
|
|
139
135
|
return false;
|
|
140
136
|
}
|
|
141
137
|
return true;
|
|
142
|
-
}, [handleError, projectSettings
|
|
138
|
+
}, [handleError, projectSettings]);
|
|
143
139
|
const linkSocialAccount = useCallback((provider_1, ...args_1) => __awaiter(void 0, [provider_1, ...args_1], void 0, function* (provider, { redirectUrl } = { redirectUrl: undefined }) {
|
|
144
140
|
connectSocialAccount({
|
|
145
141
|
authMode: 'link',
|
|
@@ -148,14 +144,22 @@ const useSocialAccounts = () => {
|
|
|
148
144
|
validator: checkValidOAuthLinking,
|
|
149
145
|
});
|
|
150
146
|
}), [checkValidOAuthLinking, connectSocialAccount]);
|
|
151
|
-
const
|
|
147
|
+
const findVerifiedCredentialById = (provider, verifiedCredentialId) => {
|
|
148
|
+
var _a;
|
|
149
|
+
const verifiedCredentials = (_a = verifiedOAuthCredentialsMap[provider]) !== null && _a !== void 0 ? _a : [];
|
|
150
|
+
const verifiedCredential = verifiedCredentialId
|
|
151
|
+
? verifiedCredentials.find((cred) => cred.id === verifiedCredentialId)
|
|
152
|
+
: verifiedCredentials[0];
|
|
153
|
+
return verifiedCredential;
|
|
154
|
+
};
|
|
155
|
+
const unlinkSocialAccount = useCallback((provider, verifiedCredentialId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
156
|
var _b;
|
|
153
157
|
setError(undefined);
|
|
154
158
|
setIsProcessing(true);
|
|
155
159
|
if (!checkValidProvider(provider, 'unlink')) {
|
|
156
160
|
return;
|
|
157
161
|
}
|
|
158
|
-
const verifiedCredential =
|
|
162
|
+
const verifiedCredential = findVerifiedCredentialById(provider, verifiedCredentialId);
|
|
159
163
|
if (!verifiedCredential) {
|
|
160
164
|
handleError(provider, SocialOAuthErrorCode.NO_ACCOUNT_LINKED, `No account linked for provider: ${provider}`, { raiseAuthFailure: false });
|
|
161
165
|
return;
|
|
@@ -184,12 +188,8 @@ const useSocialAccounts = () => {
|
|
|
184
188
|
setIsProcessing,
|
|
185
189
|
verifiedOAuthCredentialsMap,
|
|
186
190
|
]);
|
|
187
|
-
const isLinked = useCallback((provider) => Boolean(verifiedOAuthCredentialsMap[provider]), [verifiedOAuthCredentialsMap]);
|
|
188
|
-
const
|
|
189
|
-
const verifiedCredential = verifiedOAuthCredentialsMap[provider];
|
|
190
|
-
if (!verifiedCredential) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
191
|
+
const isLinked = useCallback((provider) => { var _a; return Boolean((_a = verifiedOAuthCredentialsMap[provider]) === null || _a === void 0 ? void 0 : _a.length); }, [verifiedOAuthCredentialsMap]);
|
|
192
|
+
const getAccountInformation = (verifiedCredential) => {
|
|
193
193
|
const { id, oauthAccountId, oauthAccountPhotos, oauthDisplayName, oauthEmails, oauthProvider, oauthUsername, publicIdentifier, } = verifiedCredential;
|
|
194
194
|
return {
|
|
195
195
|
accountId: oauthAccountId !== null && oauthAccountId !== void 0 ? oauthAccountId : undefined,
|
|
@@ -201,6 +201,18 @@ const useSocialAccounts = () => {
|
|
|
201
201
|
publicIdentifier,
|
|
202
202
|
username: oauthUsername,
|
|
203
203
|
};
|
|
204
|
+
};
|
|
205
|
+
const getLinkedAccountInformation = useCallback((provider, verifiedCredentialId) => {
|
|
206
|
+
const verifiedCredential = findVerifiedCredentialById(provider, verifiedCredentialId);
|
|
207
|
+
if (!verifiedCredential) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
return getAccountInformation(verifiedCredential);
|
|
211
|
+
}, [verifiedOAuthCredentialsMap]);
|
|
212
|
+
const getLinkedAccounts = useCallback((provider) => {
|
|
213
|
+
var _a;
|
|
214
|
+
const verifiedCredentials = (_a = verifiedOAuthCredentialsMap[provider]) !== null && _a !== void 0 ? _a : [];
|
|
215
|
+
return verifiedCredentials.map((credential) => getAccountInformation(credential));
|
|
204
216
|
}, [verifiedOAuthCredentialsMap]);
|
|
205
217
|
const checkValidOAuthSignIn = useCallback((provider) => {
|
|
206
218
|
var _a;
|
|
@@ -222,6 +234,7 @@ const useSocialAccounts = () => {
|
|
|
222
234
|
return useMemo(() => ({
|
|
223
235
|
error,
|
|
224
236
|
getLinkedAccountInformation,
|
|
237
|
+
getLinkedAccounts,
|
|
225
238
|
isLinked,
|
|
226
239
|
isProcessing,
|
|
227
240
|
linkSocialAccount,
|
|
@@ -230,6 +243,7 @@ const useSocialAccounts = () => {
|
|
|
230
243
|
}), [
|
|
231
244
|
error,
|
|
232
245
|
getLinkedAccountInformation,
|
|
246
|
+
getLinkedAccounts,
|
|
233
247
|
isLinked,
|
|
234
248
|
isProcessing,
|
|
235
249
|
linkSocialAccount,
|
|
@@ -11,15 +11,15 @@ var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
|
11
11
|
|
|
12
12
|
const useSwitchNetwork = () => {
|
|
13
13
|
const { setShowAuthFlow } = useDynamicContext.useDynamicContext();
|
|
14
|
-
const {
|
|
14
|
+
const { pushView } = ViewContext.useViewContext();
|
|
15
15
|
const switchNetwork = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ wallet, network, }) {
|
|
16
16
|
if (wallet.connector.switchNetworkOnlyFromWallet) {
|
|
17
17
|
setShowAuthFlow(true);
|
|
18
|
-
|
|
18
|
+
pushView('network-not-supported-manual');
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
yield wallet.connector.switchNetwork({ networkChainId: network });
|
|
22
|
-
}), [setShowAuthFlow,
|
|
22
|
+
}), [setShowAuthFlow, pushView]);
|
|
23
23
|
return switchNetwork;
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -7,15 +7,15 @@ import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
|
7
7
|
|
|
8
8
|
const useSwitchNetwork = () => {
|
|
9
9
|
const { setShowAuthFlow } = useDynamicContext();
|
|
10
|
-
const {
|
|
10
|
+
const { pushView } = useViewContext();
|
|
11
11
|
const switchNetwork = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ wallet, network, }) {
|
|
12
12
|
if (wallet.connector.switchNetworkOnlyFromWallet) {
|
|
13
13
|
setShowAuthFlow(true);
|
|
14
|
-
|
|
14
|
+
pushView('network-not-supported-manual');
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
yield wallet.connector.switchNetwork({ networkChainId: network });
|
|
18
|
-
}), [setShowAuthFlow,
|
|
18
|
+
}), [setShowAuthFlow, pushView]);
|
|
19
19
|
return switchNetwork;
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -99,7 +99,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
99
99
|
*/
|
|
100
100
|
const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
101
101
|
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext.useInternalDynamicContext();
|
|
102
|
-
const {
|
|
102
|
+
const { pushView } = ViewContext.useViewContext();
|
|
103
103
|
const { getUserDevices } = useMfa.useMfa();
|
|
104
104
|
// this is used to make sure we only trigger the effect once
|
|
105
105
|
const triggered = React.useRef(false);
|
|
@@ -141,21 +141,21 @@ const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
141
141
|
if ((_a = userWithMissingInfo.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) {
|
|
142
142
|
getUserDevices().then((devices) => {
|
|
143
143
|
if (devices.length === 0) {
|
|
144
|
-
|
|
144
|
+
pushView('mfa-choose-device');
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
|
-
|
|
147
|
+
pushView('mfa-verification');
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
else {
|
|
152
|
-
|
|
152
|
+
pushView('mfa-display-backup-codes');
|
|
153
153
|
}
|
|
154
154
|
}, [
|
|
155
155
|
getUserDevices,
|
|
156
156
|
sdkHasLoaded,
|
|
157
157
|
setShowAuthFlow,
|
|
158
|
-
|
|
158
|
+
pushView,
|
|
159
159
|
userWithMissingInfo,
|
|
160
160
|
headlessHandler,
|
|
161
161
|
]);
|
|
@@ -95,7 +95,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
95
95
|
*/
|
|
96
96
|
const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
97
97
|
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded } = useInternalDynamicContext();
|
|
98
|
-
const {
|
|
98
|
+
const { pushView } = useViewContext();
|
|
99
99
|
const { getUserDevices } = useMfa();
|
|
100
100
|
// this is used to make sure we only trigger the effect once
|
|
101
101
|
const triggered = useRef(false);
|
|
@@ -137,21 +137,21 @@ const useSyncMfaFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
137
137
|
if ((_a = userWithMissingInfo.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) {
|
|
138
138
|
getUserDevices().then((devices) => {
|
|
139
139
|
if (devices.length === 0) {
|
|
140
|
-
|
|
140
|
+
pushView('mfa-choose-device');
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
143
|
-
|
|
143
|
+
pushView('mfa-verification');
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
|
-
|
|
148
|
+
pushView('mfa-display-backup-codes');
|
|
149
149
|
}
|
|
150
150
|
}, [
|
|
151
151
|
getUserDevices,
|
|
152
152
|
sdkHasLoaded,
|
|
153
153
|
setShowAuthFlow,
|
|
154
|
-
|
|
154
|
+
pushView,
|
|
155
155
|
userWithMissingInfo,
|
|
156
156
|
headlessHandler,
|
|
157
157
|
]);
|
|
@@ -97,7 +97,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
97
97
|
|
|
98
98
|
const useSyncOnboardingFlow = ({ handler: headlessHandler, } = {}) => {
|
|
99
99
|
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
100
|
-
const {
|
|
100
|
+
const { pushView } = ViewContext.useViewContext();
|
|
101
101
|
const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
|
|
102
102
|
validationSchemaStripUnknown: false,
|
|
103
103
|
});
|
|
@@ -156,18 +156,18 @@ const useSyncOnboardingFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
156
156
|
switch (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.format) {
|
|
157
157
|
case sdkApiCore.JwtVerifiedCredentialFormatEnum.Email:
|
|
158
158
|
case sdkApiCore.JwtVerifiedCredentialFormatEnum.Oauth:
|
|
159
|
-
|
|
159
|
+
pushView('collect-user-data-login-no-wallet', {
|
|
160
160
|
userIdentification: 'email',
|
|
161
161
|
});
|
|
162
162
|
break;
|
|
163
163
|
case sdkApiCore.JwtVerifiedCredentialFormatEnum.PhoneNumber:
|
|
164
|
-
|
|
164
|
+
pushView('collect-user-data-login-no-wallet', {
|
|
165
165
|
userIdentification: 'phoneNumber',
|
|
166
166
|
userIdentificationOverride: formattedPhone,
|
|
167
167
|
});
|
|
168
168
|
break;
|
|
169
169
|
default:
|
|
170
|
-
|
|
170
|
+
pushView('collect-user-data');
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
if (!sdkHasLoaded ||
|
|
@@ -189,7 +189,7 @@ const useSyncOnboardingFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
189
189
|
completeAuth,
|
|
190
190
|
updateUser,
|
|
191
191
|
setShowAuthFlow,
|
|
192
|
-
|
|
192
|
+
pushView,
|
|
193
193
|
formattedPhone,
|
|
194
194
|
handleAuthError,
|
|
195
195
|
setSelectedWalletConnectorKey,
|
|
@@ -93,7 +93,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
93
93
|
|
|
94
94
|
const useSyncOnboardingFlow = ({ handler: headlessHandler, } = {}) => {
|
|
95
95
|
const { setShowAuthFlow, userWithMissingInfo, sdkHasLoaded, setSelectedWalletConnectorKey, } = useInternalDynamicContext();
|
|
96
|
-
const {
|
|
96
|
+
const { pushView } = useViewContext();
|
|
97
97
|
const { updateUser } = useUserUpdateRequestInternal({
|
|
98
98
|
validationSchemaStripUnknown: false,
|
|
99
99
|
});
|
|
@@ -152,18 +152,18 @@ const useSyncOnboardingFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
152
152
|
switch (lastVerifiedCredential === null || lastVerifiedCredential === void 0 ? void 0 : lastVerifiedCredential.format) {
|
|
153
153
|
case JwtVerifiedCredentialFormatEnum.Email:
|
|
154
154
|
case JwtVerifiedCredentialFormatEnum.Oauth:
|
|
155
|
-
|
|
155
|
+
pushView('collect-user-data-login-no-wallet', {
|
|
156
156
|
userIdentification: 'email',
|
|
157
157
|
});
|
|
158
158
|
break;
|
|
159
159
|
case JwtVerifiedCredentialFormatEnum.PhoneNumber:
|
|
160
|
-
|
|
160
|
+
pushView('collect-user-data-login-no-wallet', {
|
|
161
161
|
userIdentification: 'phoneNumber',
|
|
162
162
|
userIdentificationOverride: formattedPhone,
|
|
163
163
|
});
|
|
164
164
|
break;
|
|
165
165
|
default:
|
|
166
|
-
|
|
166
|
+
pushView('collect-user-data');
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
if (!sdkHasLoaded ||
|
|
@@ -185,7 +185,7 @@ const useSyncOnboardingFlow = ({ handler: headlessHandler, } = {}) => {
|
|
|
185
185
|
completeAuth,
|
|
186
186
|
updateUser,
|
|
187
187
|
setShowAuthFlow,
|
|
188
|
-
|
|
188
|
+
pushView,
|
|
189
189
|
formattedPhone,
|
|
190
190
|
handleAuthError,
|
|
191
191
|
setSelectedWalletConnectorKey,
|
|
@@ -99,7 +99,7 @@ const sleepToShowSuccessMessage = () => utils.sleep(1500);
|
|
|
99
99
|
const useUserAuth = ({ authMethod, }) => {
|
|
100
100
|
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, walletConnectorOptions, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
101
101
|
const { setDeniedOauthUsername, setDeniedOauthProvider } = AccessDeniedContext.useAccessDeniedContext();
|
|
102
|
-
const { view,
|
|
102
|
+
const { view, pushView, clearStackAndPushInitialView } = ViewContext.useViewContext();
|
|
103
103
|
const { setLoading } = LoadingContext.useLoadingContext();
|
|
104
104
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
105
105
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
@@ -183,21 +183,21 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
183
183
|
if (error instanceof utils.NoAccessError) {
|
|
184
184
|
setDeniedOauthProvider(error === null || error === void 0 ? void 0 : error.socialProvider);
|
|
185
185
|
setDeniedOauthUsername((_a = error === null || error === void 0 ? void 0 : error.socialUsername) !== null && _a !== void 0 ? _a : '');
|
|
186
|
-
|
|
186
|
+
pushView('no-access');
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
if (error instanceof utils.AccountExistsError) {
|
|
190
190
|
setExistentAccountData(error.errorPayload);
|
|
191
|
-
|
|
191
|
+
pushView('account-exists');
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
if (error instanceof utils.SandboxMaximumThresholdReachedError) {
|
|
195
|
-
|
|
195
|
+
pushView('sandbox-maximum-threshold-reached');
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
// Handle the case where the user has already an account with the email
|
|
199
199
|
if (error instanceof utils.UserHasAccountWithEmailError) {
|
|
200
|
-
|
|
200
|
+
pushView('merge-user-accounts-with-same-email', {
|
|
201
201
|
returnToView: 'isEmailRecoveryFlow' in options && options.isEmailRecoveryFlow
|
|
202
202
|
? 'passkey-recovery-add-email'
|
|
203
203
|
: undefined,
|
|
@@ -218,15 +218,15 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
218
218
|
const handleVerifyMissingFields = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
219
219
|
if (isEmailVerificationRequired &&
|
|
220
220
|
missingFields.find((field) => field.name === 'email')) {
|
|
221
|
-
|
|
221
|
+
pushView('verify-email');
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
if (isSmsVerificationRequired &&
|
|
225
225
|
missingFields.find((field) => field.name === 'phoneNumber')) {
|
|
226
|
-
|
|
226
|
+
pushView('verify-sms');
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
|
|
229
|
+
pushView(view.type);
|
|
230
230
|
});
|
|
231
231
|
const completeAuth = (_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options = {}, }) {
|
|
232
232
|
logger.logger.debug('completeAuth', { authMethod });
|
|
@@ -275,7 +275,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
275
275
|
const cancelAuth = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
276
276
|
logger.logger.debug('cancelAuth', { authMethod });
|
|
277
277
|
yield handleLogOut();
|
|
278
|
-
|
|
278
|
+
clearStackAndPushInitialView();
|
|
279
279
|
});
|
|
280
280
|
return {
|
|
281
281
|
cancelAuth,
|
|
@@ -95,7 +95,7 @@ const sleepToShowSuccessMessage = () => sleep(1500);
|
|
|
95
95
|
const useUserAuth = ({ authMethod, }) => {
|
|
96
96
|
const { handleLogOut, setShowAuthFlow, setCallback, setMultiWalletWidgetState, walletConnectorOptions, } = useInternalDynamicContext();
|
|
97
97
|
const { setDeniedOauthUsername, setDeniedOauthProvider } = useAccessDeniedContext();
|
|
98
|
-
const { view,
|
|
98
|
+
const { view, pushView, clearStackAndPushInitialView } = useViewContext();
|
|
99
99
|
const { setLoading } = useLoadingContext();
|
|
100
100
|
const { setErrorMessage, setError } = useErrorContext();
|
|
101
101
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
@@ -179,21 +179,21 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
179
179
|
if (error instanceof NoAccessError) {
|
|
180
180
|
setDeniedOauthProvider(error === null || error === void 0 ? void 0 : error.socialProvider);
|
|
181
181
|
setDeniedOauthUsername((_a = error === null || error === void 0 ? void 0 : error.socialUsername) !== null && _a !== void 0 ? _a : '');
|
|
182
|
-
|
|
182
|
+
pushView('no-access');
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
if (error instanceof AccountExistsError) {
|
|
186
186
|
setExistentAccountData(error.errorPayload);
|
|
187
|
-
|
|
187
|
+
pushView('account-exists');
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
if (error instanceof SandboxMaximumThresholdReachedError) {
|
|
191
|
-
|
|
191
|
+
pushView('sandbox-maximum-threshold-reached');
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
// Handle the case where the user has already an account with the email
|
|
195
195
|
if (error instanceof UserHasAccountWithEmailError) {
|
|
196
|
-
|
|
196
|
+
pushView('merge-user-accounts-with-same-email', {
|
|
197
197
|
returnToView: 'isEmailRecoveryFlow' in options && options.isEmailRecoveryFlow
|
|
198
198
|
? 'passkey-recovery-add-email'
|
|
199
199
|
: undefined,
|
|
@@ -214,15 +214,15 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
214
214
|
const handleVerifyMissingFields = (_c) => __awaiter(void 0, [_c], void 0, function* ({ missingFields, isEmailVerificationRequired, isSmsVerificationRequired, }) {
|
|
215
215
|
if (isEmailVerificationRequired &&
|
|
216
216
|
missingFields.find((field) => field.name === 'email')) {
|
|
217
|
-
|
|
217
|
+
pushView('verify-email');
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
220
|
if (isSmsVerificationRequired &&
|
|
221
221
|
missingFields.find((field) => field.name === 'phoneNumber')) {
|
|
222
|
-
|
|
222
|
+
pushView('verify-sms');
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
-
|
|
225
|
+
pushView(view.type);
|
|
226
226
|
});
|
|
227
227
|
const completeAuth = (_d) => __awaiter(void 0, [_d], void 0, function* ({ completeSignInFlow, updateJwtFunction, onValidUpdatedJwt, options = {}, }) {
|
|
228
228
|
logger.debug('completeAuth', { authMethod });
|
|
@@ -271,7 +271,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
271
271
|
const cancelAuth = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
272
272
|
logger.debug('cancelAuth', { authMethod });
|
|
273
273
|
yield handleLogOut();
|
|
274
|
-
|
|
274
|
+
clearStackAndPushInitialView();
|
|
275
275
|
});
|
|
276
276
|
return {
|
|
277
277
|
cancelAuth,
|