@dynamic-labs/sdk-react-core 0.19.0-alpha.0 → 0.19.0-alpha.1

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.
Files changed (131) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.cjs +3 -3
  3. package/package.js +3 -3
  4. package/package.json +11 -10
  5. package/src/index.cjs +2 -0
  6. package/src/index.js +1 -0
  7. package/src/lib/Main.cjs +5 -0
  8. package/src/lib/Main.js +5 -0
  9. package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +9 -6
  10. package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +9 -6
  11. package/src/lib/components/Button/Button.cjs +10 -7
  12. package/src/lib/components/Button/Button.d.ts +3 -3
  13. package/src/lib/components/Button/Button.js +10 -7
  14. package/src/lib/components/DynamicConnectButton/components/ConnectButton.cjs +1 -1
  15. package/src/lib/components/DynamicConnectButton/components/ConnectButton.js +1 -1
  16. package/src/lib/components/Icon/Icon.cjs +1 -0
  17. package/src/lib/components/Icon/Icon.js +1 -0
  18. package/src/lib/components/Icon/Icon.types.d.ts +1 -1
  19. package/src/lib/components/IconWithSpinner/IconWithSpinner.d.ts +1 -1
  20. package/src/lib/components/ListTile/ListTile.cjs +1 -1
  21. package/src/lib/components/ListTile/ListTile.js +1 -1
  22. package/src/lib/components/ListTile/ListTile.types.d.ts +1 -0
  23. package/src/lib/components/ModalHeader/ModalHeader.cjs +2 -2
  24. package/src/lib/components/ModalHeader/ModalHeader.js +2 -2
  25. package/src/lib/components/ModalHeader/ModalHeader.types.d.ts +2 -1
  26. package/src/lib/components/NetworkPicker/NetworkPicker.cjs +1 -1
  27. package/src/lib/components/NetworkPicker/NetworkPicker.js +1 -1
  28. package/src/lib/components/OTPVerificationView/OTPVerificationView.cjs +5 -3
  29. package/src/lib/components/OTPVerificationView/OTPVerificationView.d.ts +1 -0
  30. package/src/lib/components/OTPVerificationView/OTPVerificationView.js +5 -3
  31. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.cjs +6 -2
  32. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.d.ts +1 -0
  33. package/src/lib/components/PoweredByDynamic/PoweredByDynamic.js +6 -2
  34. package/src/lib/components/UserProfileForm/UserProfileForm.cjs +26 -14
  35. package/src/lib/components/UserProfileForm/UserProfileForm.d.ts +14 -3
  36. package/src/lib/components/UserProfileForm/UserProfileForm.js +27 -15
  37. package/src/lib/components/UserProfileForm/index.d.ts +1 -0
  38. package/src/lib/context/DynamicContext/DynamicContext.cjs +9 -3
  39. package/src/lib/context/DynamicContext/DynamicContext.js +10 -4
  40. package/src/lib/context/ViewContext/ViewContext.d.ts +1 -1
  41. package/src/lib/data/api.cjs +16 -0
  42. package/src/lib/data/api.d.ts +1 -0
  43. package/src/lib/data/api.js +18 -3
  44. package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +10 -2
  45. package/src/lib/layout/DynamicAuthLayout/Header/header.js +10 -2
  46. package/src/lib/shared/assets/double-arrow-right.cjs +53 -0
  47. package/src/lib/shared/assets/double-arrow-right.js +29 -0
  48. package/src/lib/shared/assets/index.d.ts +1 -0
  49. package/src/lib/styles/index.shadow.cjs +1 -1
  50. package/src/lib/styles/index.shadow.js +1 -1
  51. package/src/lib/utils/constants/index.d.ts +1 -1
  52. package/src/lib/utils/constants/localStorage.cjs +3 -1
  53. package/src/lib/utils/constants/localStorage.d.ts +1 -0
  54. package/src/lib/utils/constants/localStorage.js +3 -2
  55. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.cjs +14 -2
  56. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.d.ts +3 -2
  57. package/src/lib/utils/functions/getUserProfileFields/getUserProfileFields.js +14 -2
  58. package/src/lib/utils/functions/getUserProfileFields/index.d.ts +1 -0
  59. package/src/lib/utils/functions/index.d.ts +2 -0
  60. package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
  61. package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
  62. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +6 -4
  63. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.d.ts +3 -1
  64. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +6 -4
  65. package/src/lib/utils/hooks/index.d.ts +4 -1
  66. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.cjs +19 -3
  67. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.d.ts +1 -2
  68. package/src/lib/utils/hooks/multiWallet/useMultiWallet/useMultiWallet.js +20 -4
  69. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +2 -1
  70. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +2 -1
  71. package/src/lib/utils/hooks/useFindSocialIcon/index.d.ts +1 -0
  72. package/src/lib/utils/hooks/{useGetSocialIcon/useGetSocialIcon.cjs → useFindSocialIcon/useFindSocialIcon.cjs} +3 -3
  73. package/src/lib/utils/hooks/useFindSocialIcon/useFindSocialIcon.d.ts +3 -0
  74. package/src/lib/utils/hooks/useFindSocialIcon/useFindSocialIcon.js +10 -0
  75. package/src/lib/utils/hooks/useTransactionEstimatedGas/index.d.ts +1 -0
  76. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.cjs +61 -0
  77. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.d.ts +20 -0
  78. package/src/lib/utils/hooks/useTransactionEstimatedGas/useTransactionEstimatedGas.js +57 -0
  79. package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
  80. package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
  81. package/src/lib/utils/hooks/useWalletConnectorEvent/index.d.ts +1 -0
  82. package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.cjs +42 -0
  83. package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.d.ts +12 -0
  84. package/src/lib/utils/hooks/useWalletConnectorEvent/useWalletConnectorEvent.js +38 -0
  85. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +12 -0
  86. package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +12 -0
  87. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.cjs +91 -136
  88. package/src/lib/utils/hooks/useWalletEventListeners/useWalletEventListeners.js +92 -137
  89. package/src/lib/views/AccountExistsView/AccountExistsView.cjs +3 -3
  90. package/src/lib/views/AccountExistsView/AccountExistsView.js +3 -3
  91. package/src/lib/views/CollectUserDataView/UserDataFields/index.cjs +4 -0
  92. package/src/lib/views/CollectUserDataView/UserDataFields/index.js +4 -0
  93. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +8 -2
  94. package/src/lib/views/EmailUpdate/EmailUpdate.js +8 -2
  95. package/src/lib/views/EmailVerification/EmailVerification.cjs +13 -4
  96. package/src/lib/views/EmailVerification/EmailVerification.js +15 -6
  97. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +3 -2
  98. package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +3 -2
  99. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +5 -3
  100. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +6 -4
  101. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.cjs +3 -3
  102. package/src/lib/views/LoginWithEmailView/components/SocialSignIn/SocialSignIn.js +3 -3
  103. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.cjs +107 -0
  104. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.d.ts +2 -0
  105. package/src/lib/views/MergeUserAccountsView/MergeUserAccountsView.js +103 -0
  106. package/src/lib/views/MergeUserAccountsView/index.d.ts +1 -0
  107. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.cjs +13 -3
  108. package/src/lib/views/NetworkNotSupported/NetworkNotSupported.js +13 -3
  109. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.cjs +14 -4
  110. package/src/lib/views/NetworkNotSupportedSwitchManual/NetworkNotSupportedSwitchManual.js +14 -4
  111. package/src/lib/views/SocialRedirectView/SocialRedirectView.cjs +3 -3
  112. package/src/lib/views/SocialRedirectView/SocialRedirectView.js +3 -3
  113. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.cjs +3 -3
  114. package/src/lib/views/SocialWrongAccountView/SocialWrongAccountView.js +3 -3
  115. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +2 -8
  116. package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +3 -9
  117. package/src/lib/views/viewToComponentMap.cjs +2 -0
  118. package/src/lib/views/viewToComponentMap.js +2 -0
  119. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.cjs +1 -1
  120. package/src/lib/widgets/DynamicBridgeWidget/views/WalletsView/WalletsView.js +1 -1
  121. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.cjs +2 -1
  122. package/src/lib/widgets/DynamicWidget/components/DynamicNav/DynamicNav.js +2 -1
  123. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.cjs +1 -1
  124. package/src/lib/widgets/DynamicWidget/components/DynamicWidgetFooter/DynamicWidgetFooter.js +1 -1
  125. package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.cjs +1 -1
  126. package/src/lib/widgets/DynamicWidget/views/ProfileView/ProfileView.js +1 -1
  127. package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.cjs +1 -1
  128. package/src/lib/widgets/DynamicWidget/views/WalletsView/WalletsView.js +1 -1
  129. package/src/lib/utils/hooks/useGetSocialIcon/index.d.ts +0 -1
  130. package/src/lib/utils/hooks/useGetSocialIcon/useGetSocialIcon.d.ts +0 -2
  131. package/src/lib/utils/hooks/useGetSocialIcon/useGetSocialIcon.js +0 -10
@@ -6,6 +6,7 @@ var _tslib = require('../../../../_virtual/_tslib.cjs');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
8
  var iconic = require('@dynamic-labs/iconic');
9
+ var utils = require('@dynamic-labs/utils');
9
10
  var Typography = require('../../components/Typography/Typography.cjs');
10
11
  require('@dynamic-labs/sdk-api');
11
12
  var logger = require('../../shared/logger.cjs');
@@ -13,7 +14,6 @@ require('@dynamic-labs/wallet-connector-core');
13
14
  var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
14
15
  var chevronLeft = require('../../shared/assets/chevron-left.cjs');
15
16
  require('@dynamic-labs/wallet-book');
16
- require('@dynamic-labs/utils');
17
17
  require('../../utils/constants/colors.cjs');
18
18
  require('../../shared/utils/classes/storage/localStorage.cjs');
19
19
  require('ethers');
@@ -56,6 +56,7 @@ const EmailUpdate = () => {
56
56
  const { setView, goToInitialView } = ViewContext.useViewContext();
57
57
  const { email, setEmail, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
58
58
  const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
59
+ const [emailError, setEmailError] = React.useState(undefined);
59
60
  const handleBackClick = () => {
60
61
  setView('verify-email');
61
62
  setError(undefined);
@@ -65,6 +66,7 @@ const EmailUpdate = () => {
65
66
  if (!updatedEmail) {
66
67
  return;
67
68
  }
69
+ setEmailError(undefined);
68
70
  setLoading(true);
69
71
  const { emailVerification } = yield api.updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
70
72
  if (!emailVerification) {
@@ -79,6 +81,10 @@ const EmailUpdate = () => {
79
81
  }
80
82
  catch (error) {
81
83
  logger.logger.debug(error);
84
+ if (error instanceof utils.EmailAlreadyExistsError) {
85
+ setEmailError('Email already exists');
86
+ return;
87
+ }
82
88
  setErrorMessage(error.code);
83
89
  }
84
90
  finally {
@@ -90,7 +96,7 @@ const EmailUpdate = () => {
90
96
  width: '3.125rem',
91
97
  }, className: 'email-update__icon' }), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-update__title' }, { children: "Update Email" })), jsxRuntime.jsxs("div", Object.assign({ className: 'email-update__copy-text-container' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your current email address is" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: email }))] })), jsxRuntime.jsx(Input.Input, { id: 'email_field', onChange: (e) => {
92
98
  setUpdatedEmail(e.target.value);
93
- }, type: 'email', label: 'Email address', className: 'email-update__input' }), jsxRuntime.jsx(Button.Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
99
+ }, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsxRuntime.jsx(Button.Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
94
100
  };
95
101
 
96
102
  exports.EmailUpdate = EmailUpdate;
@@ -2,6 +2,7 @@ import { __awaiter } from '../../../../_virtual/_tslib.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState } from 'react';
4
4
  import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
5
+ import { EmailAlreadyExistsError } from '@dynamic-labs/utils';
5
6
  import { Typography } from '../../components/Typography/Typography.js';
6
7
  import '@dynamic-labs/sdk-api';
7
8
  import { logger } from '../../shared/logger.js';
@@ -9,7 +10,6 @@ import '@dynamic-labs/wallet-connector-core';
9
10
  import { useViewContext } from '../../context/ViewContext/ViewContext.js';
10
11
  import { ReactComponent as SvgChevronLeft } from '../../shared/assets/chevron-left.js';
11
12
  import '@dynamic-labs/wallet-book';
12
- import '@dynamic-labs/utils';
13
13
  import '../../utils/constants/colors.js';
14
14
  import '../../shared/utils/classes/storage/localStorage.js';
15
15
  import 'ethers';
@@ -52,6 +52,7 @@ const EmailUpdate = () => {
52
52
  const { setView, goToInitialView } = useViewContext();
53
53
  const { email, setEmail, setVerificationUUID } = useEmailVerificationContext();
54
54
  const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext();
55
+ const [emailError, setEmailError] = useState(undefined);
55
56
  const handleBackClick = () => {
56
57
  setView('verify-email');
57
58
  setError(undefined);
@@ -61,6 +62,7 @@ const EmailUpdate = () => {
61
62
  if (!updatedEmail) {
62
63
  return;
63
64
  }
65
+ setEmailError(undefined);
64
66
  setLoading(true);
65
67
  const { emailVerification } = yield updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
66
68
  if (!emailVerification) {
@@ -75,6 +77,10 @@ const EmailUpdate = () => {
75
77
  }
76
78
  catch (error) {
77
79
  logger.debug(error);
80
+ if (error instanceof EmailAlreadyExistsError) {
81
+ setEmailError('Email already exists');
82
+ return;
83
+ }
78
84
  setErrorMessage(error.code);
79
85
  }
80
86
  finally {
@@ -86,7 +92,7 @@ const EmailUpdate = () => {
86
92
  width: '3.125rem',
87
93
  }, className: 'email-update__icon' }), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-update__title' }, { children: "Update Email" })), jsxs("div", Object.assign({ className: 'email-update__copy-text-container' }, { children: [jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "Your current email address is" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: email }))] })), jsx(Input, { id: 'email_field', onChange: (e) => {
88
94
  setUpdatedEmail(e.target.value);
89
- }, type: 'email', label: 'Email address', className: 'email-update__input' }), jsx(Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
95
+ }, type: 'email', label: 'Email address', className: 'email-update__input', error: Boolean(emailError), message: emailError }), jsx(Button, Object.assign({ buttonVariant: 'primary', buttonPadding: 'medium', buttonClassName: 'email-update__button', onClick: () => handleEmailUpdate(), loading: loading }, { children: "Send Verification Code" }))] })));
90
96
  };
91
97
 
92
98
  export { EmailUpdate };
@@ -11,6 +11,7 @@ var Typography = require('../../components/Typography/Typography.cjs');
11
11
  var decodeJwt = require('../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
12
12
  require('@dynamic-labs/wallet-connector-core');
13
13
  var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
14
+ var close = require('../../shared/assets/close.cjs');
14
15
  var check = require('../../shared/assets/check.cjs');
15
16
  var checkCircle = require('../../shared/assets/check-circle.cjs');
16
17
  var logger = require('../../shared/logger.cjs');
@@ -36,7 +37,8 @@ require('../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetu
36
37
  var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
37
38
  require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
38
39
  var AccountExistsContext = require('../../context/AccountExistsContext/AccountExistsContext.cjs');
39
- require('../../components/IconButton/IconButton.cjs');
40
+ var ModalHeader = require('../../components/ModalHeader/ModalHeader.cjs');
41
+ var IconButton = require('../../components/IconButton/IconButton.cjs');
40
42
  var IconWithStatus = require('../../components/IconWithStatus/IconWithStatus.cjs');
41
43
  var PoweredByDynamic = require('../../components/PoweredByDynamic/PoweredByDynamic.cjs');
42
44
  var IconWithSpinner = require('../../components/IconWithSpinner/IconWithSpinner.cjs');
@@ -101,6 +103,11 @@ const EmailVerification = () => {
101
103
  }
102
104
  catch (error) {
103
105
  logger.logger.debug(error);
106
+ // Handle the case where the user has already an account with the email
107
+ if (error instanceof utils.UserHasAccountWithEmailError) {
108
+ setView('merge-user-accounts');
109
+ return; // Early return to not show the error message
110
+ }
104
111
  setErrorMessage(error.code);
105
112
  }
106
113
  finally {
@@ -119,6 +126,7 @@ const EmailVerification = () => {
119
126
  setOnboardingOnlyJwt,
120
127
  setCallback,
121
128
  setErrorMessage,
129
+ setView,
122
130
  ]);
123
131
  const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
124
132
  setError(undefined);
@@ -214,9 +222,10 @@ const EmailVerification = () => {
214
222
  setLoading(false);
215
223
  }
216
224
  });
217
- return (jsxRuntime.jsxs("div", Object.assign({ className: 'email-verification__container' }, { children: [error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, Object.assign({ withIcon: false, className: 'email-verification__error-message' }, { children: error }))), showTransferMessage && (jsxRuntime.jsx("div", Object.assign({ className: 'email-verification__transfer-message' }, { children: "Verification complete, the email is now verified to this account." }))), isValidated ? (jsxRuntime.jsx("div", Object.assign({ className: 'email-verification__icon-container' }, { children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: iconic.SignInWithEmailIcon, iconSize: 50, InnerIcon: check.ReactComponent }) }))) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { className: classNames.classNames({
218
- 'email-verification__icon-with-spinner': Boolean(!error),
219
- }), Icon: iconic.SignInWithEmailIcon, iconSize: 80, isSpinning: true })), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-verification__title', color: 'primary' }, { children: "Confirm verification code" })), jsxRuntime.jsxs("div", Object.assign({ className: 'email-verification__copy-text-container' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "We\u2019ve sent a verification code to" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: shortenEmail.shortenEmail(email) }))] })), !isLoginView && (jsxRuntime.jsx(TextButton.TextButton, Object.assign({ onClick: () => setView('update-email'), className: 'email-verification__text-button', disabled: loading }, { children: "Edit email" }))), 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) }), retried ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: ["Re-send code in ", remainingSeconds] })), jsxRuntime.jsxs("span", Object.assign({ className: 'email-verification__retry-container' }, { children: [jsxRuntime.jsx(checkCircle.ReactComponent, {}), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'primary', className: 'email-verification__retry-container-text' }, { children: "Code sent" }))] }))] })) : (!hideRetryButton && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'secondary' }, { children: "Did not receive your code yet?" })), jsxRuntime.jsx(TextButton.TextButton, Object.assign({ className: 'email-verification__text-button', disabled: loading || isValidated, onClick: () => handleRetry() }, { children: "Re-send code" }))] }))), !isLoginView && (jsxRuntime.jsx(TextButton.TextButton, Object.assign({ className: 'email-verification__log-out', onClick: handleLogOut }, { children: "Log out" }))), jsxRuntime.jsx(PoweredByDynamic.PoweredByDynamic, {})] })));
225
+ const closeButton = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ onClick: () => setShowAuthFlow(false), type: 'button' }, { children: jsxRuntime.jsx(close.ReactComponent, {}) })));
226
+ return (jsxRuntime.jsxs("div", Object.assign({ className: 'email-verification__container' }, { children: [error && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, Object.assign({ withIcon: false, className: 'email-verification__error-message' }, { children: error }))), showTransferMessage && (jsxRuntime.jsx("div", Object.assign({ className: 'email-verification__transfer-message' }, { children: "Verification complete, the email is now verified to this account." }))), jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ style: { paddingBlock: 0 }, trailing: !isLoginView && closeButton }, { children: isValidated ? (jsxRuntime.jsx("div", Object.assign({ className: 'email-verification__icon-container' }, { children: jsxRuntime.jsx(IconWithStatus.IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: iconic.SignInWithEmailIcon, iconSize: 50, InnerIcon: check.ReactComponent }) }))) : (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { className: classNames.classNames({
227
+ 'email-verification__icon-with-spinner': Boolean(!error),
228
+ }), Icon: iconic.SignInWithEmailIcon, iconSize: 80, isSpinning: true })) })), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-verification__title', color: 'primary' }, { children: "Confirm verification code" })), jsxRuntime.jsxs("div", Object.assign({ className: 'email-verification__copy-text-container' }, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "We\u2019ve sent a verification code to" })), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: shortenEmail.shortenEmail(email) }))] })), !isLoginView && (jsxRuntime.jsx(TextButton.TextButton, Object.assign({ onClick: () => setView('update-email'), className: 'email-verification__text-button', disabled: loading }, { children: "Edit email" }))), 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) }), retried ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: ["Re-send code in ", remainingSeconds] })), jsxRuntime.jsxs("span", Object.assign({ className: 'email-verification__retry-container' }, { children: [jsxRuntime.jsx(checkCircle.ReactComponent, {}), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'primary', className: 'email-verification__retry-container-text' }, { children: "Code sent" }))] }))] })) : (!hideRetryButton && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'secondary' }, { children: "Did not receive your code yet?" })), jsxRuntime.jsx(TextButton.TextButton, Object.assign({ className: 'email-verification__text-button', disabled: loading || isValidated, onClick: () => handleRetry() }, { children: "Re-send code" }))] }))), !isLoginView && (jsxRuntime.jsx(TextButton.TextButton, Object.assign({ className: 'email-verification__log-out', onClick: handleLogOut }, { children: "Log out" }))), jsxRuntime.jsx(PoweredByDynamic.PoweredByDynamic, {})] })));
220
229
  };
221
230
 
222
231
  exports.EmailVerification = EmailVerification;
@@ -1,12 +1,13 @@
1
1
  import { __awaiter } from '../../../../_virtual/_tslib.js';
2
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { useState, useCallback } from 'react';
4
4
  import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
5
- import { NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
5
+ import { UserHasAccountWithEmailError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
6
6
  import { Typography } from '../../components/Typography/Typography.js';
7
7
  import { decodeJwt } from '../../shared/utils/functions/decodeJwt/decodeJwt.js';
8
8
  import '@dynamic-labs/wallet-connector-core';
9
9
  import { useViewContext } from '../../context/ViewContext/ViewContext.js';
10
+ import { ReactComponent as SvgClose } from '../../shared/assets/close.js';
10
11
  import { ReactComponent as SvgCheck } from '../../shared/assets/check.js';
11
12
  import { ReactComponent as SvgCheckCircle } from '../../shared/assets/check-circle.js';
12
13
  import { logger } from '../../shared/logger.js';
@@ -32,7 +33,8 @@ import '../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup
32
33
  import { useErrorContext } from '../../context/ErrorContext/ErrorContext.js';
33
34
  import '../../context/AccessDeniedContext/AccessDeniedContext.js';
34
35
  import { useAccountExistsContext } from '../../context/AccountExistsContext/AccountExistsContext.js';
35
- import '../../components/IconButton/IconButton.js';
36
+ import { ModalHeader } from '../../components/ModalHeader/ModalHeader.js';
37
+ import { IconButton } from '../../components/IconButton/IconButton.js';
36
38
  import { IconWithStatus } from '../../components/IconWithStatus/IconWithStatus.js';
37
39
  import { PoweredByDynamic } from '../../components/PoweredByDynamic/PoweredByDynamic.js';
38
40
  import { IconWithSpinner } from '../../components/IconWithSpinner/IconWithSpinner.js';
@@ -97,6 +99,11 @@ const EmailVerification = () => {
97
99
  }
98
100
  catch (error) {
99
101
  logger.debug(error);
102
+ // Handle the case where the user has already an account with the email
103
+ if (error instanceof UserHasAccountWithEmailError) {
104
+ setView('merge-user-accounts');
105
+ return; // Early return to not show the error message
106
+ }
100
107
  setErrorMessage(error.code);
101
108
  }
102
109
  finally {
@@ -115,6 +122,7 @@ const EmailVerification = () => {
115
122
  setOnboardingOnlyJwt,
116
123
  setCallback,
117
124
  setErrorMessage,
125
+ setView,
118
126
  ]);
119
127
  const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
120
128
  setError(undefined);
@@ -210,9 +218,10 @@ const EmailVerification = () => {
210
218
  setLoading(false);
211
219
  }
212
220
  });
213
- return (jsxs("div", Object.assign({ className: 'email-verification__container' }, { children: [error && (jsx(ErrorContainer, Object.assign({ withIcon: false, className: 'email-verification__error-message' }, { children: error }))), showTransferMessage && (jsx("div", Object.assign({ className: 'email-verification__transfer-message' }, { children: "Verification complete, the email is now verified to this account." }))), isValidated ? (jsx("div", Object.assign({ className: 'email-verification__icon-container' }, { children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: SignInWithEmailIcon, iconSize: 50, InnerIcon: SvgCheck }) }))) : (jsx(IconWithSpinner, { className: classNames({
214
- 'email-verification__icon-with-spinner': Boolean(!error),
215
- }), Icon: SignInWithEmailIcon, iconSize: 80, isSpinning: true })), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-verification__title', color: 'primary' }, { children: "Confirm verification code" })), jsxs("div", Object.assign({ className: 'email-verification__copy-text-container' }, { children: [jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "We\u2019ve sent a verification code to" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: shortenEmail(email) }))] })), !isLoginView && (jsx(TextButton, Object.assign({ onClick: () => setView('update-email'), className: 'email-verification__text-button', disabled: loading }, { children: "Edit 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) }), retried ? (jsxs(Fragment, { children: [jsxs(Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: ["Re-send code in ", remainingSeconds] })), jsxs("span", Object.assign({ className: 'email-verification__retry-container' }, { children: [jsx(SvgCheckCircle, {}), jsx(Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'primary', className: 'email-verification__retry-container-text' }, { children: "Code sent" }))] }))] })) : (!hideRetryButton && (jsxs(Fragment, { children: [jsx(Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'secondary' }, { children: "Did not receive your code yet?" })), jsx(TextButton, Object.assign({ className: 'email-verification__text-button', disabled: loading || isValidated, onClick: () => handleRetry() }, { children: "Re-send code" }))] }))), !isLoginView && (jsx(TextButton, Object.assign({ className: 'email-verification__log-out', onClick: handleLogOut }, { children: "Log out" }))), jsx(PoweredByDynamic, {})] })));
221
+ const closeButton = (jsx(IconButton, Object.assign({ onClick: () => setShowAuthFlow(false), type: 'button' }, { children: jsx(SvgClose, {}) })));
222
+ return (jsxs("div", Object.assign({ className: 'email-verification__container' }, { children: [error && (jsx(ErrorContainer, Object.assign({ withIcon: false, className: 'email-verification__error-message' }, { children: error }))), showTransferMessage && (jsx("div", Object.assign({ className: 'email-verification__transfer-message' }, { children: "Verification complete, the email is now verified to this account." }))), jsx(ModalHeader, Object.assign({ style: { paddingBlock: 0 }, trailing: !isLoginView && closeButton }, { children: isValidated ? (jsx("div", Object.assign({ className: 'email-verification__icon-container' }, { children: jsx(IconWithStatus, { containerClassName: 'email-verification__icon--verified', Icon: SignInWithEmailIcon, iconSize: 50, InnerIcon: SvgCheck }) }))) : (jsx(IconWithSpinner, { className: classNames({
223
+ 'email-verification__icon-with-spinner': Boolean(!error),
224
+ }), Icon: SignInWithEmailIcon, iconSize: 80, isSpinning: true })) })), jsx(Typography, Object.assign({ weight: 'medium', variant: 'title', className: 'email-verification__title', color: 'primary' }, { children: "Confirm verification code" })), jsxs("div", Object.assign({ className: 'email-verification__copy-text-container' }, { children: [jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'regular', color: 'secondary' }, { children: "We\u2019ve sent a verification code to" })), jsx(Typography, Object.assign({ variant: 'body_normal', weight: 'bold', color: 'secondary' }, { children: shortenEmail(email) }))] })), !isLoginView && (jsx(TextButton, Object.assign({ onClick: () => setView('update-email'), className: 'email-verification__text-button', disabled: loading }, { children: "Edit 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) }), retried ? (jsxs(Fragment, { children: [jsxs(Typography, Object.assign({ variant: 'body_small', color: 'secondary' }, { children: ["Re-send code in ", remainingSeconds] })), jsxs("span", Object.assign({ className: 'email-verification__retry-container' }, { children: [jsx(SvgCheckCircle, {}), jsx(Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'primary', className: 'email-verification__retry-container-text' }, { children: "Code sent" }))] }))] })) : (!hideRetryButton && (jsxs(Fragment, { children: [jsx(Typography, Object.assign({ variant: 'body_small', weight: 'medium', color: 'secondary' }, { children: "Did not receive your code yet?" })), jsx(TextButton, Object.assign({ className: 'email-verification__text-button', disabled: loading || isValidated, onClick: () => handleRetry() }, { children: "Re-send code" }))] }))), !isLoginView && (jsx(TextButton, Object.assign({ className: 'email-verification__log-out', onClick: handleLogOut }, { children: "Log out" }))), jsx(PoweredByDynamic, {})] })));
216
225
  };
217
226
 
218
227
  export { EmailVerification };
@@ -47,7 +47,7 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
47
47
  const EmailWalletOTPVerificationView = () => {
48
48
  const { setView } = ViewContext.useViewContext();
49
49
  const [error, setError] = React.useState();
50
- const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext.useInternalDynamicContext();
50
+ const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
51
51
  if (!emailWalletConnector ||
52
52
  !walletConnectorCore.isEmailOTPWalletConnector(emailWalletConnector)) {
53
53
  throw new Error('Current wallet is not EmailWalletConnector');
@@ -61,10 +61,11 @@ const EmailWalletOTPVerificationView = () => {
61
61
  clearStatesOnBackClick();
62
62
  setView('login-with-email-or-wallet');
63
63
  };
64
+ const handleOnClickClose = () => setShowAuthFlow(false);
64
65
  const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
65
66
  onFailure: (error) => setError(error),
66
67
  });
67
- return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
68
+ return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
68
69
  };
69
70
 
70
71
  exports.EmailWalletOTPVerificationView = EmailWalletOTPVerificationView;
@@ -43,7 +43,7 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
43
43
  const EmailWalletOTPVerificationView = () => {
44
44
  const { setView } = useViewContext();
45
45
  const [error, setError] = useState();
46
- const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext();
46
+ const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, setShowAuthFlow, } = useInternalDynamicContext();
47
47
  if (!emailWalletConnector ||
48
48
  !isEmailOTPWalletConnector(emailWalletConnector)) {
49
49
  throw new Error('Current wallet is not EmailWalletConnector');
@@ -57,10 +57,11 @@ const EmailWalletOTPVerificationView = () => {
57
57
  clearStatesOnBackClick();
58
58
  setView('login-with-email-or-wallet');
59
59
  };
60
+ const handleOnClickClose = () => setShowAuthFlow(false);
60
61
  const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
61
62
  onFailure: (error) => setError(error),
62
63
  });
63
- return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
64
+ return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickClose: handleOnClickClose, onClickEditEmail: handleBackClick, displayPoweredByDynamic: true }));
64
65
  };
65
66
 
66
67
  export { EmailWalletOTPVerificationView };
@@ -10,6 +10,7 @@ var sdkApi = require('@dynamic-labs/sdk-api');
10
10
  var logger = require('../../../../shared/logger.cjs');
11
11
  require('@dynamic-labs/iconic');
12
12
  require('../../../../context/ViewContext/ViewContext.cjs');
13
+ var arrowRight = require('../../../../shared/assets/arrow-right.cjs');
13
14
  require('@dynamic-labs/wallet-book');
14
15
  require('@dynamic-labs/utils');
15
16
  require('../../../../utils/constants/colors.cjs');
@@ -32,8 +33,7 @@ require('../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagic
32
33
  var ErrorContext = require('../../../../context/ErrorContext/ErrorContext.cjs');
33
34
  require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
34
35
  require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
35
- require('../../../../components/IconButton/IconButton.cjs');
36
- var Button = require('../../../../components/Button/Button.cjs');
36
+ var IconButton = require('../../../../components/IconButton/IconButton.cjs');
37
37
  require('../../../../components/Alert/Alert.cjs');
38
38
  require('../../../../context/MockContext/MockContext.cjs');
39
39
  require('../../../../context/CaptchaContext/CaptchaContext.cjs');
@@ -49,6 +49,7 @@ var useEmailProvider = require('../../../../utils/hooks/useEmailProvider/useEmai
49
49
 
50
50
  const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
51
51
  const LoginWithEmailForm = () => {
52
+ var _a;
52
53
  const { environmentId, wallets, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
53
54
  const { loading, setLoading } = LoadingContext.useLoadingContext();
54
55
  const { setErrorMessage } = ErrorContext.useErrorContext();
@@ -67,6 +68,7 @@ const LoginWithEmailForm = () => {
67
68
  };
68
69
  const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
69
70
  const onChangeHandler = handleEmailOnChangeEvent;
71
+ const emailInputSuffixIcon = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ "data-testid": 'email_submit_button', type: 'submit', className: `icon-button${((_a = emailInput === null || emailInput === void 0 ? void 0 : emailInput.trim()) === null || _a === void 0 ? void 0 : _a.length) ? '--visible' : ''}`, disabled: isLoading }, { children: jsxRuntime.jsx(arrowRight.ReactComponent, {}) })));
70
72
  const handleSubmit = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
71
73
  e.preventDefault();
72
74
  if (!EMAIL_REGEX.test(emailInput)) {
@@ -99,7 +101,7 @@ const LoginWithEmailForm = () => {
99
101
  }
100
102
  });
101
103
  // social sign in currently coupled to email... might be better to decouple
102
- return (jsxRuntime.jsxs("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: [jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address' }), jsxRuntime.jsx(Button.Button, Object.assign({ buttonClassName: 'login-with-email-form__button', type: 'submit', loading: isLoading, disabled: isLoading, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'medium', expanded: true }, { children: "Continue" }))] })));
104
+ return (jsxRuntime.jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsxRuntime.jsx(Input.Input, { id: 'email_field', value: emailInput, onChange: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address', suffix: emailInputSuffixIcon }) })));
103
105
  };
104
106
 
105
107
  exports.EMAIL_REGEX = EMAIL_REGEX;
@@ -1,11 +1,12 @@
1
1
  import { __awaiter } from '../../../../../../_virtual/_tslib.js';
2
- import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { jsx } from 'react/jsx-runtime';
3
3
  import { useState, useMemo } from 'react';
4
4
  import { isEmailWalletConnector } from '@dynamic-labs/wallet-connector-core';
5
5
  import { ProviderEnum } from '@dynamic-labs/sdk-api';
6
6
  import { logger } from '../../../../shared/logger.js';
7
7
  import '@dynamic-labs/iconic';
8
8
  import '../../../../context/ViewContext/ViewContext.js';
9
+ import { ReactComponent as SvgArrowRight } from '../../../../shared/assets/arrow-right.js';
9
10
  import '@dynamic-labs/wallet-book';
10
11
  import '@dynamic-labs/utils';
11
12
  import '../../../../utils/constants/colors.js';
@@ -28,8 +29,7 @@ import '../../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicI
28
29
  import { useErrorContext } from '../../../../context/ErrorContext/ErrorContext.js';
29
30
  import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
30
31
  import '../../../../context/AccountExistsContext/AccountExistsContext.js';
31
- import '../../../../components/IconButton/IconButton.js';
32
- import { Button } from '../../../../components/Button/Button.js';
32
+ import { IconButton } from '../../../../components/IconButton/IconButton.js';
33
33
  import '../../../../components/Alert/Alert.js';
34
34
  import '../../../../context/MockContext/MockContext.js';
35
35
  import '../../../../context/CaptchaContext/CaptchaContext.js';
@@ -45,6 +45,7 @@ import { useEmailProvider } from '../../../../utils/hooks/useEmailProvider/useEm
45
45
 
46
46
  const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
47
47
  const LoginWithEmailForm = () => {
48
+ var _a;
48
49
  const { environmentId, wallets, projectSettings } = useInternalDynamicContext();
49
50
  const { loading, setLoading } = useLoadingContext();
50
51
  const { setErrorMessage } = useErrorContext();
@@ -63,6 +64,7 @@ const LoginWithEmailForm = () => {
63
64
  };
64
65
  const isInjectedWalletProviderEnabled = emailWalletConnector !== undefined;
65
66
  const onChangeHandler = handleEmailOnChangeEvent;
67
+ const emailInputSuffixIcon = (jsx(IconButton, Object.assign({ "data-testid": 'email_submit_button', type: 'submit', className: `icon-button${((_a = emailInput === null || emailInput === void 0 ? void 0 : emailInput.trim()) === null || _a === void 0 ? void 0 : _a.length) ? '--visible' : ''}`, disabled: isLoading }, { children: jsx(SvgArrowRight, {}) })));
66
68
  const handleSubmit = (e) => __awaiter(void 0, void 0, void 0, function* () {
67
69
  e.preventDefault();
68
70
  if (!EMAIL_REGEX.test(emailInput)) {
@@ -95,7 +97,7 @@ const LoginWithEmailForm = () => {
95
97
  }
96
98
  });
97
99
  // social sign in currently coupled to email... might be better to decouple
98
- return (jsxs("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: [jsx(Input, { id: 'email_field', value: emailInput, onChange: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address' }), jsx(Button, Object.assign({ buttonClassName: 'login-with-email-form__button', type: 'submit', loading: isLoading, disabled: isLoading, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'medium', expanded: true }, { children: "Continue" }))] })));
100
+ return (jsx("form", Object.assign({ className: 'login-with-email-form', onSubmit: (e) => handleSubmit(e) }, { children: jsx(Input, { id: 'email_field', value: emailInput, onChange: onChangeHandler, label: 'Enter your email', error: emailError, message: emailError && 'Please enter a valid email address', suffix: emailInputSuffixIcon }) })));
99
101
  };
100
102
 
101
103
  export { EMAIL_REGEX, LoginWithEmailForm };
@@ -43,7 +43,7 @@ require('../../../../context/MockContext/MockContext.cjs');
43
43
  require('../../../../context/CaptchaContext/CaptchaContext.cjs');
44
44
  var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
45
45
  require('../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
46
- var useGetSocialIcon = require('../../../../utils/hooks/useGetSocialIcon/useGetSocialIcon.cjs');
46
+ var useFindSocialIcon = require('../../../../utils/hooks/useFindSocialIcon/useFindSocialIcon.cjs');
47
47
  var IconListTile = require('../../../../components/IconListTile/IconListTile.cjs');
48
48
  require('../../../../components/Popper/Popper/Popper.cjs');
49
49
  require('../../../../components/Popper/PopperContext/PopperContext.cjs');
@@ -59,7 +59,7 @@ var capitalize = require('../../../../shared/utils/functions/capitalize/capitali
59
59
  const SocialSignIn = () => {
60
60
  const { socialProvidersFilter = (providers) => providers } = useInternalDynamicContext.useInternalDynamicContext();
61
61
  const { socialProvider, setSocialProvider, socialWalletConnector, enabledSocialProviders, } = SocialRedirectContext.useSocialRedirectContext();
62
- const getSocialIcon = useGetSocialIcon.useGetSocialIcon();
62
+ const findSocialIcon = useFindSocialIcon.useFindSocialIcon();
63
63
  const [showCard, setShowCard] = React.useState(false);
64
64
  const closeCard = () => !isLoading && setShowCard(false);
65
65
  const socialProviders = socialProvidersFilter(enabledSocialProviders);
@@ -78,7 +78,7 @@ const SocialSignIn = () => {
78
78
  const closeButton = (jsxRuntime.jsx(IconButton.IconButton, Object.assign({ onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button' }, { children: jsxRuntime.jsx(close.ReactComponent, {}) })));
79
79
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in', style: {
80
80
  '--number-of-social-grid-items': numberOfSocialGridItems,
81
- } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize.capitalize(provider)] })))] }), provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary' }, { children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) })) }), 'show-more-options'))] })), jsxRuntime.jsx(OverlayCard.OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsxRuntime.jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
81
+ } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxRuntime.jsxs(IconListTile.IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile' }, { children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxRuntime.jsxs(Typography.Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize.capitalize(provider)] })))] }), provider))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-primary' }, { children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) })) }), 'show-more-options'))] })), jsxRuntime.jsx(OverlayCard.OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxRuntime.jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, Object.assign({ trailing: closeButton }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsxRuntime.jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsxRuntime.jsx(IconListTile.IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile' }, { children: jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: findSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
82
82
  };
83
83
 
84
84
  exports.SocialSignIn = SocialSignIn;
@@ -39,7 +39,7 @@ import '../../../../context/MockContext/MockContext.js';
39
39
  import '../../../../context/CaptchaContext/CaptchaContext.js';
40
40
  import { useMutation } from '../../../../utils/hooks/useMutation/useMutation.js';
41
41
  import '../../../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
42
- import { useGetSocialIcon } from '../../../../utils/hooks/useGetSocialIcon/useGetSocialIcon.js';
42
+ import { useFindSocialIcon } from '../../../../utils/hooks/useFindSocialIcon/useFindSocialIcon.js';
43
43
  import { IconListTile } from '../../../../components/IconListTile/IconListTile.js';
44
44
  import '../../../../components/Popper/Popper/Popper.js';
45
45
  import '../../../../components/Popper/PopperContext/PopperContext.js';
@@ -55,7 +55,7 @@ import { capitalize } from '../../../../shared/utils/functions/capitalize/capita
55
55
  const SocialSignIn = () => {
56
56
  const { socialProvidersFilter = (providers) => providers } = useInternalDynamicContext();
57
57
  const { socialProvider, setSocialProvider, socialWalletConnector, enabledSocialProviders, } = useSocialRedirectContext();
58
- const getSocialIcon = useGetSocialIcon();
58
+ const findSocialIcon = useFindSocialIcon();
59
59
  const [showCard, setShowCard] = useState(false);
60
60
  const closeCard = () => !isLoading && setShowCard(false);
61
61
  const socialProviders = socialProvidersFilter(enabledSocialProviders);
@@ -74,7 +74,7 @@ const SocialSignIn = () => {
74
74
  const closeButton = (jsx(IconButton, Object.assign({ onClick: closeCard, type: 'button', id: 'close-button', disabled: isLoading, "data-testid": 'close-button' }, { children: jsx(SvgClose, {}) })));
75
75
  return (jsxs(Fragment, { children: [jsxs("div", Object.assign({ className: 'social-sign-in', style: {
76
76
  '--number-of-social-grid-items': numberOfSocialGridItems,
77
- } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize(provider)] })))] }), provider))), showCardButton && (jsx(IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsx(Icon, Object.assign({ color: 'text-primary' }, { children: jsx(SvgDotsHorizontal, {}) })) }), 'show-more-options'))] })), jsx(OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsx(IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), className: 'social-sign-in--card--tile' }, { children: jsx(IconWithSpinner, { Icon: getSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
77
+ } }, { children: [socialProvidersToDisplayInline.map((provider) => (jsxs(IconListTile, Object.assign({ dataTestId: `inline-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--tile' }, { children: [jsx(IconWithSpinner, { Icon: findSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }), showConnectText && (jsxs(Typography, Object.assign({ variant: 'button_primary' }, { children: ["Connect with ", capitalize(provider)] })))] }), provider))), showCardButton && (jsx(IconListTile, Object.assign({ dataTestId: 'show-more-options', onClick: () => setShowCard(true) }, { children: jsx(Icon, Object.assign({ color: 'text-primary' }, { children: jsx(SvgDotsHorizontal, {}) })) }), 'show-more-options'))] })), jsx(OverlayCard, Object.assign({ isOpen: showCard, onClickOverlay: closeCard }, { children: jsxs("div", Object.assign({ className: 'social-sign-in--card' }, { children: [jsx(ModalHeader, Object.assign({ trailing: closeButton }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span' }, { children: "Choose a social account" })) })), jsx("div", Object.assign({ className: 'social-sign-in--card--body' }, { children: socialProviders.map((provider) => (jsx(IconListTile, Object.assign({ dataTestId: `card-${provider}`, onClick: () => onClickProvider(provider), disabled: Boolean(socialProvider), className: 'social-sign-in--card--tile' }, { children: jsx(IconWithSpinner, { Icon: findSocialIcon(provider), isSpinning: socialProvider === provider, iconSize: 32 }) }), provider))) }))] })) }))] }));
78
78
  };
79
79
 
80
80
  export { SocialSignIn };
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var utils = require('@dynamic-labs/utils');
8
+ var walletBook = require('@dynamic-labs/wallet-book');
9
+ var iconic = require('@dynamic-labs/iconic');
10
+ require('react');
11
+ var Typography = require('../../components/Typography/Typography.cjs');
12
+ var decodeJwt = require('../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
13
+ require('@dynamic-labs/wallet-connector-core');
14
+ var ViewContext = require('../../context/ViewContext/ViewContext.cjs');
15
+ var doubleArrowRight = require('../../shared/assets/double-arrow-right.cjs');
16
+ require('../../shared/logger.cjs');
17
+ var shortenWalletAddress = require('../../shared/utils/functions/shortenWalletAddress/shortenWalletAddress.cjs');
18
+ require('../../utils/constants/colors.cjs');
19
+ require('../../shared/utils/classes/storage/localStorage.cjs');
20
+ require('ethers');
21
+ require('../../shared/consts/index.cjs');
22
+ var useInternalDynamicContext = require('../../context/DynamicContext/useInternalDynamicContext.cjs');
23
+ var index = require('../../utils/functions/storeAuthToken/index.cjs');
24
+ require('@dynamic-labs/multi-wallet');
25
+ var createUserProfile = require('../../utils/functions/createUserProfile/createUserProfile.cjs');
26
+ require('@dynamic-labs/sdk-api');
27
+ require('../../components/ShadowDOM/ShadowDOM.cjs');
28
+ require('../../context/ThemeContext/ThemeContext.cjs');
29
+ var Icon = require('../../components/Icon/Icon.cjs');
30
+ require('react-dom');
31
+ require('react-focus-lock');
32
+ require('../../components/Transition/ZoomTransition/ZoomTransition.cjs');
33
+ require('../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
34
+ require('../../components/Transition/OpacityTransition/OpacityTransition.cjs');
35
+ var api = require('../../data/api.cjs');
36
+ require('@dynamic-labs/rpc-providers');
37
+ require('../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
38
+ var ErrorContext = require('../../context/ErrorContext/ErrorContext.cjs');
39
+ require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
40
+ require('../../context/AccountExistsContext/AccountExistsContext.cjs');
41
+ require('../../components/IconButton/IconButton.cjs');
42
+ var Button = require('../../components/Button/Button.cjs');
43
+ require('../../components/Alert/Alert.cjs');
44
+ require('../../context/MockContext/MockContext.cjs');
45
+ require('../../context/CaptchaContext/CaptchaContext.cjs');
46
+ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
47
+ var shortenEmail = require('../../shared/utils/functions/shortenEmail/shortenEmail.cjs');
48
+ require('../../components/Popper/Popper/Popper.cjs');
49
+ require('../../components/Popper/PopperContext/PopperContext.cjs');
50
+ require('formik');
51
+ require('yup');
52
+ require('../../components/InlineWidget/InlineWidget.cjs');
53
+ require('../../components/MenuList/Dropdown/Dropdown.cjs');
54
+ var EmailVerificationContext = require('../../context/EmailVerificationContext/EmailVerificationContext.cjs');
55
+
56
+ const MergeUserAccountsView = () => {
57
+ const { environmentId, setUser, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, primaryWallet, user, authToken, onboardingOnlyJwt, } = useInternalDynamicContext.useInternalDynamicContext();
58
+ const { setError } = ErrorContext.useErrorContext();
59
+ const { setView, goToInitialView } = ViewContext.useViewContext();
60
+ const { email } = EmailVerificationContext.useEmailVerificationContext();
61
+ // If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
62
+ // If user tries to merge during KYC step, authToken is undefined and onboardingOnlyJwt is defined
63
+ const jwtToken = authToken || onboardingOnlyJwt;
64
+ const handleMergeUserAccounts = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
65
+ if (!jwtToken) {
66
+ return;
67
+ }
68
+ try {
69
+ const newJwt = yield api.mergeUserAccounts(jwtToken, environmentId);
70
+ if (newJwt) {
71
+ index.storeAuthToken(newJwt);
72
+ const decodedJwt = decodeJwt.decodeJwt(newJwt);
73
+ if (decodedJwt === undefined) {
74
+ throw new utils.DynamicError('Invalid token!');
75
+ }
76
+ const newUser = createUserProfile.createUserProfile(decodedJwt);
77
+ setOnboardingOnlyJwt(undefined);
78
+ setUser(newUser);
79
+ setShowAuthFlow(false);
80
+ setCallback('authSuccess');
81
+ return;
82
+ }
83
+ throw new utils.DynamicError('Something went wrong, please try again.');
84
+ }
85
+ catch (e) {
86
+ setError('Something went wrong, please try again.');
87
+ goToInitialView();
88
+ }
89
+ });
90
+ const handleUseDifferentEmail = () => {
91
+ setError(undefined);
92
+ if (user) {
93
+ setShowAuthFlow(false);
94
+ return;
95
+ }
96
+ setView('collect-user-data');
97
+ };
98
+ return (jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__container' }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts' }, { children: [jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsxRuntime.jsx(walletBook.WalletIcon, { walletName: primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.name, className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenWalletAddress.shortenWalletAddress(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address, 3, 3) }))] })), jsxRuntime.jsx("div", Object.assign({ className: 'merge-user-accounts__accounts__divider' }, { children: jsxRuntime.jsx(Icon.Icon, Object.assign({ color: 'text-secondary', size: 'small' }, { children: jsxRuntime.jsx(doubleArrowRight.ReactComponent, {}) })) })), jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__accounts__item' }, { children: [jsxRuntime.jsx(iconic.UserProfileIcon, { className: 'merge-user-accounts__accounts__item__icon' }), jsxRuntime.jsx(Typography.Typography, Object.assign({ variant: 'body_normal', weight: 'medium', color: 'secondary', className: 'merge-user-accounts__accounts__item__text' }, { children: shortenEmail.shortenEmail(email, {
99
+ breakpoint: 4,
100
+ cutEnd: 1,
101
+ cutStart: 2,
102
+ }) }))] }))] })), jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'regular', variant: 'title', className: 'merge-user-accounts__text merge-user-accounts__text__header' }, { children: "Would you like to link this wallet to this existing account?" })), jsxRuntime.jsxs(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', className: 'merge-user-accounts__text merge-user-accounts__text__body' }, { children: ["An account already exists that uses", ' ', jsxRuntime.jsx("span", Object.assign({ className: 'merge-user-accounts__text--bold' }, { children: shortenEmail.shortenEmail(email, {
103
+ breakpoint: 14,
104
+ }) })), ' ', "email."] })), jsxRuntime.jsxs("div", Object.assign({ className: 'merge-user-accounts__buttons' }, { children: [jsxRuntime.jsx(Button.Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleMergeUserAccounts, buttonVariant: 'primary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "Yes, link to existing account" })), jsxRuntime.jsx(Button.Button, Object.assign({ className: 'merge-user-accounts__buttons__button', onClick: handleUseDifferentEmail, buttonVariant: 'secondary', buttonPadding: 'large', buttonRounded: 'default' }, { children: "No, I'll use a different email" }))] }))] })));
105
+ };
106
+
107
+ exports.MergeUserAccountsView = MergeUserAccountsView;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const MergeUserAccountsView: () => JSX.Element;