@dynamic-labs/sdk-react-core 0.17.3 → 0.17.5

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 (27) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +9 -9
  5. package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +15 -6
  6. package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +15 -6
  7. package/src/lib/data/api.cjs +0 -15
  8. package/src/lib/data/api.d.ts +1 -5
  9. package/src/lib/data/api.js +2 -16
  10. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
  11. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
  12. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +3 -3
  13. package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +3 -3
  14. package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs +2 -2
  15. package/src/lib/utils/hooks/useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js +2 -2
  16. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +4 -2
  17. package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +5 -3
  18. package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -2
  19. package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -2
  20. package/src/lib/views/EmailVerification/EmailVerification.cjs +6 -5
  21. package/src/lib/views/EmailVerification/EmailVerification.js +6 -5
  22. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.cjs +4 -18
  23. package/src/lib/views/LoginWithEmailView/components/LoginWithEmailForm/LoginWithEmailForm.js +5 -19
  24. package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.cjs +2 -2
  25. package/src/lib/views/WalletSignSpinnerView/WalletSignSpinnerView.js +2 -2
  26. package/src/lib/views/WalletUsedView/WalletUsedView.cjs +2 -2
  27. package/src/lib/views/WalletUsedView/WalletUsedView.js +2 -2
package/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
1
 
2
+ ### [0.17.5](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.4...v0.17.5) (2023-06-15)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * don't remove project settings from ls if there's a connected wallet ([#2335](https://github.com/dynamic-labs/DynamicAuth/issues/2335)) ([a4d3f0e](https://github.com/dynamic-labs/DynamicAuth/commit/a4d3f0ef8667d0a67d489b05a7a46e5b401ed1a6))
8
+ * setting initial view when error in auth flow ([#2346](https://github.com/dynamic-labs/DynamicAuth/issues/2346)) ([35e0e47](https://github.com/dynamic-labs/DynamicAuth/commit/35e0e47a649f3a88f12126f539ec12167ce27486))
9
+ * **widget:** add fallback icon when oauth provider does not exist ([#2351](https://github.com/dynamic-labs/DynamicAuth/issues/2351)) ([af9f64f](https://github.com/dynamic-labs/DynamicAuth/commit/af9f64f4f4a287fff666109e19d969b351016b62)), closes [#2349](https://github.com/dynamic-labs/DynamicAuth/issues/2349)
10
+
11
+ ### [0.17.4](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.3...v0.17.4) (2023-06-14)
12
+
2
13
  ### [0.17.3](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.2...v0.17.3) (2023-06-14)
3
14
 
4
15
 
package/package.cjs CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "0.17.3";
5
+ var version = "0.17.5";
6
6
  var dependencies = {
7
7
  "react-focus-lock": "2.9.2",
8
8
  "@dynamic-labs/iconic": "0.1.23",
9
- "@dynamic-labs/sdk-api": "0.0.218",
9
+ "@dynamic-labs/sdk-api": "0.0.198",
10
10
  "@hcaptcha/react-hcaptcha": "1.4.4",
11
11
  "country-list": "2.3.0",
12
12
  yup: "0.32.11",
package/package.js CHANGED
@@ -1,8 +1,8 @@
1
- var version = "0.17.3";
1
+ var version = "0.17.5";
2
2
  var dependencies = {
3
3
  "react-focus-lock": "2.9.2",
4
4
  "@dynamic-labs/iconic": "0.1.23",
5
- "@dynamic-labs/sdk-api": "0.0.218",
5
+ "@dynamic-labs/sdk-api": "0.0.198",
6
6
  "@hcaptcha/react-hcaptcha": "1.4.4",
7
7
  "country-list": "2.3.0",
8
8
  yup: "0.32.11",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "0.17.3",
3
+ "version": "0.17.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -9,20 +9,20 @@
9
9
  "dependencies": {
10
10
  "react-focus-lock": "2.9.2",
11
11
  "@dynamic-labs/iconic": "0.1.23",
12
- "@dynamic-labs/sdk-api": "0.0.218",
12
+ "@dynamic-labs/sdk-api": "0.0.198",
13
13
  "@hcaptcha/react-hcaptcha": "1.4.4",
14
14
  "country-list": "2.3.0",
15
15
  "yup": "0.32.11",
16
16
  "formik": "2.2.9",
17
17
  "qrcode": "1.5.1",
18
18
  "ethers": "5.7.2",
19
- "@dynamic-labs/logger": "0.17.3",
20
- "@dynamic-labs/multi-wallet": "0.17.3",
21
- "@dynamic-labs/rpc-providers": "0.17.3",
22
- "@dynamic-labs/types": "0.17.3",
23
- "@dynamic-labs/utils": "0.17.3",
24
- "@dynamic-labs/wallet-book": "0.17.3",
25
- "@dynamic-labs/wallet-connector-core": "0.17.3"
19
+ "@dynamic-labs/logger": "0.17.5",
20
+ "@dynamic-labs/multi-wallet": "0.17.5",
21
+ "@dynamic-labs/rpc-providers": "0.17.5",
22
+ "@dynamic-labs/types": "0.17.5",
23
+ "@dynamic-labs/utils": "0.17.5",
24
+ "@dynamic-labs/wallet-book": "0.17.5",
25
+ "@dynamic-labs/wallet-connector-core": "0.17.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "semver": "7.3.8"
@@ -7,7 +7,7 @@ var walletBook = require('@dynamic-labs/wallet-book');
7
7
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
8
  var iconic = require('@dynamic-labs/iconic');
9
9
  require('@dynamic-labs/sdk-api');
10
- require('../../shared/logger.cjs');
10
+ var logger = require('../../shared/logger.cjs');
11
11
  require('../../config/LSSuffix.cjs');
12
12
  require('../../context/ViewContext/ViewContext.cjs');
13
13
  require('react');
@@ -44,16 +44,25 @@ require('../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs');
44
44
  var useGetSocialIcon = require('../../utils/hooks/useGetSocialIcon/useGetSocialIcon.cjs');
45
45
 
46
46
  const getMagicEmailOrSocialIcon = ({ getSocialIcon, wallet, jwt, }) => {
47
- let Icon = null;
48
47
  if (walletConnectorCore.isEmailOTPWalletConnector(wallet.connector)) {
49
- Icon = iconic.SignInWithEmailIcon;
48
+ return iconic.SignInWithEmailIcon;
50
49
  }
51
50
  if (walletConnectorCore.isSocialWalletConnector(wallet.connector)) {
52
51
  const socialAccountDataForWallet = getReferencedAccount.getReferencedAccount(jwt, wallet.id);
53
- const MagicSocialWalletIcon = getSocialIcon(socialAccountDataForWallet === null || socialAccountDataForWallet === void 0 ? void 0 : socialAccountDataForWallet.oauthProvider);
54
- Icon = MagicSocialWalletIcon;
52
+ if (!socialAccountDataForWallet ||
53
+ !socialAccountDataForWallet.oauthProvider) {
54
+ return iconic.SignInWithEmailIcon;
55
+ }
56
+ const { oauthProvider } = socialAccountDataForWallet;
57
+ try {
58
+ const MagicSocialWalletIcon = getSocialIcon(oauthProvider);
59
+ return MagicSocialWalletIcon;
60
+ }
61
+ catch (err) {
62
+ logger.logger.error(err);
63
+ }
55
64
  }
56
- return Icon;
65
+ return null;
57
66
  };
58
67
  const AuthProviderIcon = ({ jwt, iconSize = 64, showStatus, wallet, }) => {
59
68
  const { primaryWallet, selectedWalletConnector } = useInternalDynamicContext.useInternalDynamicContext();
@@ -3,7 +3,7 @@ import { WalletIcon } from '@dynamic-labs/wallet-book';
3
3
  import { isEmailOTPWalletConnector, isSocialWalletConnector } from '@dynamic-labs/wallet-connector-core';
4
4
  import { SignInWithEmailIcon } from '@dynamic-labs/iconic';
5
5
  import '@dynamic-labs/sdk-api';
6
- import '../../shared/logger.js';
6
+ import { logger } from '../../shared/logger.js';
7
7
  import '../../config/LSSuffix.js';
8
8
  import '../../context/ViewContext/ViewContext.js';
9
9
  import 'react';
@@ -40,16 +40,25 @@ import '../../utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js';
40
40
  import { useGetSocialIcon } from '../../utils/hooks/useGetSocialIcon/useGetSocialIcon.js';
41
41
 
42
42
  const getMagicEmailOrSocialIcon = ({ getSocialIcon, wallet, jwt, }) => {
43
- let Icon = null;
44
43
  if (isEmailOTPWalletConnector(wallet.connector)) {
45
- Icon = SignInWithEmailIcon;
44
+ return SignInWithEmailIcon;
46
45
  }
47
46
  if (isSocialWalletConnector(wallet.connector)) {
48
47
  const socialAccountDataForWallet = getReferencedAccount(jwt, wallet.id);
49
- const MagicSocialWalletIcon = getSocialIcon(socialAccountDataForWallet === null || socialAccountDataForWallet === void 0 ? void 0 : socialAccountDataForWallet.oauthProvider);
50
- Icon = MagicSocialWalletIcon;
48
+ if (!socialAccountDataForWallet ||
49
+ !socialAccountDataForWallet.oauthProvider) {
50
+ return SignInWithEmailIcon;
51
+ }
52
+ const { oauthProvider } = socialAccountDataForWallet;
53
+ try {
54
+ const MagicSocialWalletIcon = getSocialIcon(oauthProvider);
55
+ return MagicSocialWalletIcon;
56
+ }
57
+ catch (err) {
58
+ logger.error(err);
59
+ }
51
60
  }
52
- return Icon;
61
+ return null;
53
62
  };
54
63
  const AuthProviderIcon = ({ jwt, iconSize = 64, showStatus, wallet, }) => {
55
64
  const { primaryWallet, selectedWalletConnector } = useInternalDynamicContext();
@@ -43,20 +43,6 @@ const fetchNonce = (environmentId) => _tslib.__awaiter(void 0, void 0, void 0, f
43
43
  return undefined;
44
44
  }
45
45
  });
46
- const getEmailProvider = ({ email, environmentId, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
47
- try {
48
- const res = yield sdkApi().getEmailProvider({
49
- email,
50
- environmentId,
51
- });
52
- return res;
53
- }
54
- catch (e) {
55
- const data = yield e.json();
56
- logger.logger.error(data.error);
57
- throw new utils.EmailProviderError(data.code);
58
- }
59
- });
60
46
  const createEmailVerification = ({ email, environmentId, }) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
61
47
  try {
62
48
  const res = yield sdkApi().createEmailVerification({
@@ -376,7 +362,6 @@ exports.createVisit = createVisit;
376
362
  exports.fetchNetworkSettings = fetchNetworkSettings;
377
363
  exports.fetchNonce = fetchNonce;
378
364
  exports.fetchProjectSettings = fetchProjectSettings;
379
- exports.getEmailProvider = getEmailProvider;
380
365
  exports.getOnrampProviders = getOnrampProviders;
381
366
  exports.linkWallet = linkWallet;
382
367
  exports.mapAuthModeTypeToEnum = mapAuthModeTypeToEnum;
@@ -1,10 +1,6 @@
1
- import { ProjectSettings, UserFields, NetworkConfigurationResponse, ChainEnum, UpdateSelfResponse, WalletProviderEnum, AuthModeEnum, EmailVerificationCreateResponse, VerifyResponse, OauthRequest, ProviderEnum, OnrampConfiguration, EmailProviderResponse } from '@dynamic-labs/sdk-api';
1
+ import { ProjectSettings, UserFields, NetworkConfigurationResponse, ChainEnum, UpdateSelfResponse, WalletProviderEnum, AuthModeEnum, EmailVerificationCreateResponse, VerifyResponse, OauthRequest, ProviderEnum, OnrampConfiguration } from '@dynamic-labs/sdk-api';
2
2
  import { AuthModeType, VerifyWallet } from '../shared/types';
3
3
  export declare const fetchNonce: (environmentId: string) => Promise<string | undefined>;
4
- export declare const getEmailProvider: ({ email, environmentId, }: {
5
- email: string;
6
- environmentId: string;
7
- }) => Promise<EmailProviderResponse>;
8
4
  export declare const createEmailVerification: ({ email, environmentId, }: {
9
5
  email: string;
10
6
  environmentId: string;
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from '../../../_virtual/_tslib.js';
2
- import { NoAccessError, EmailVerificationError, DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError, EmailProviderError, WalletUsedError, WalletNotDeployedError, ChainalysisError } from '@dynamic-labs/utils';
2
+ import { NoAccessError, EmailVerificationError, DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError, WalletUsedError, WalletNotDeployedError, ChainalysisError } from '@dynamic-labs/utils';
3
3
  import { SDKApi, Configuration, VerifyRequestFromJSON, ChainEnum, WalletProviderEnum, AuthModeEnum } from '@dynamic-labs/sdk-api';
4
4
  import { VERSION, API_VERSION } from '../../version.js';
5
5
  import ApiEndpoint from '../config/ApiEndpoint.js';
@@ -39,20 +39,6 @@ const fetchNonce = (environmentId) => __awaiter(void 0, void 0, void 0, function
39
39
  return undefined;
40
40
  }
41
41
  });
42
- const getEmailProvider = ({ email, environmentId, }) => __awaiter(void 0, void 0, void 0, function* () {
43
- try {
44
- const res = yield sdkApi().getEmailProvider({
45
- email,
46
- environmentId,
47
- });
48
- return res;
49
- }
50
- catch (e) {
51
- const data = yield e.json();
52
- logger.error(data.error);
53
- throw new EmailProviderError(data.code);
54
- }
55
- });
56
42
  const createEmailVerification = ({ email, environmentId, }) => __awaiter(void 0, void 0, void 0, function* () {
57
43
  try {
58
44
  const res = yield sdkApi().createEmailVerification({
@@ -367,4 +353,4 @@ const getOnrampProviders = ({ chain, environmentId, networkId, token, walletAddr
367
353
  return onramps;
368
354
  });
369
355
 
370
- export { createEmailVerification, createVisit, fetchNetworkSettings, fetchNonce, fetchProjectSettings, getEmailProvider, getOnrampProviders, linkWallet, mapAuthModeTypeToEnum, mapChainToChainEnum, mapProviderToProviderEnum, retryEmailVerification, revokeSession, signInWithEmailVerification, transferWallet, unlinkOAuth, unlinkWallet, updateUserProfileFields, verifyEmail, verifyOAuth, verifyWallet };
356
+ export { createEmailVerification, createVisit, fetchNetworkSettings, fetchNonce, fetchProjectSettings, getOnrampProviders, linkWallet, mapAuthModeTypeToEnum, mapChainToChainEnum, mapProviderToProviderEnum, retryEmailVerification, revokeSession, signInWithEmailVerification, transferWallet, unlinkOAuth, unlinkWallet, updateUserProfileFields, verifyEmail, verifyOAuth, verifyWallet };
@@ -25,7 +25,7 @@ var useVerifyWallet = require('../../useVerifyWallet/useVerifyWallet.cjs');
25
25
  var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
26
26
 
27
27
  const useConnectAndSign = () => {
28
- const { setView } = ViewContext.useViewContext();
28
+ const { setView, goToInitialView } = ViewContext.useViewContext();
29
29
  const { setErrorMessage } = ErrorContext.useErrorContext();
30
30
  const { captchaToken } = CaptchaContext.useCaptchaContext();
31
31
  const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowAuthFlow, user, walletUiUtils, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
@@ -73,7 +73,7 @@ const useConnectAndSign = () => {
73
73
  }
74
74
  catch (err) {
75
75
  setErrorMessage((_b = err === null || err === void 0 ? void 0 : err.code) === null || _b === void 0 ? void 0 : _b.toString());
76
- setView('wallet-list');
76
+ goToInitialView();
77
77
  return;
78
78
  }
79
79
  });
@@ -21,7 +21,7 @@ import { useVerifyWallet } from '../../useVerifyWallet/useVerifyWallet.js';
21
21
  import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
22
22
 
23
23
  const useConnectAndSign = () => {
24
- const { setView } = useViewContext();
24
+ const { setView, goToInitialView } = useViewContext();
25
25
  const { setErrorMessage } = useErrorContext();
26
26
  const { captchaToken } = useCaptchaContext();
27
27
  const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, setShowAuthFlow, user, walletUiUtils, setCallback, } = useInternalDynamicContext();
@@ -69,7 +69,7 @@ const useConnectAndSign = () => {
69
69
  }
70
70
  catch (err) {
71
71
  setErrorMessage((_b = err === null || err === void 0 ? void 0 : err.code) === null || _b === void 0 ? void 0 : _b.toString());
72
- setView('wallet-list');
72
+ goToInitialView();
73
73
  return;
74
74
  }
75
75
  });
@@ -25,7 +25,7 @@ require('../../../../shared/consts/index.cjs');
25
25
  var CaptchaContext = require('../../../../context/CaptchaContext/CaptchaContext.cjs');
26
26
 
27
27
  const useConnectAndSignSplitSteps = () => {
28
- const { setView } = ViewContext.useViewContext();
28
+ const { setView, goToInitialView } = ViewContext.useViewContext();
29
29
  const { setErrorMessage } = ErrorContext.useErrorContext();
30
30
  const { captchaToken } = CaptchaContext.useCaptchaContext();
31
31
  const { connectWallet, consumeNonce, displayTermsOfService, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
@@ -60,7 +60,7 @@ const useConnectAndSignSplitSteps = () => {
60
60
  }
61
61
  catch (err) {
62
62
  setErrorMessage(err.toString());
63
- setView('wallet-list');
63
+ goToInitialView();
64
64
  return;
65
65
  }
66
66
  });
@@ -77,7 +77,7 @@ const useConnectAndSignSplitSteps = () => {
77
77
  }
78
78
  catch (err) {
79
79
  setErrorMessage(err.toString());
80
- setView('wallet-list');
80
+ goToInitialView();
81
81
  return;
82
82
  }
83
83
  });
@@ -21,7 +21,7 @@ import '../../../../shared/consts/index.js';
21
21
  import { useCaptchaContext } from '../../../../context/CaptchaContext/CaptchaContext.js';
22
22
 
23
23
  const useConnectAndSignSplitSteps = () => {
24
- const { setView } = useViewContext();
24
+ const { setView, goToInitialView } = useViewContext();
25
25
  const { setErrorMessage } = useErrorContext();
26
26
  const { captchaToken } = useCaptchaContext();
27
27
  const { connectWallet, consumeNonce, displayTermsOfService, projectSettings, environmentId, setIsSingleWalletAccount, setShowAuthFlow, user, authMode, setCallback, } = useInternalDynamicContext();
@@ -56,7 +56,7 @@ const useConnectAndSignSplitSteps = () => {
56
56
  }
57
57
  catch (err) {
58
58
  setErrorMessage(err.toString());
59
- setView('wallet-list');
59
+ goToInitialView();
60
60
  return;
61
61
  }
62
62
  });
@@ -73,7 +73,7 @@ const useConnectAndSignSplitSteps = () => {
73
73
  }
74
74
  catch (err) {
75
75
  setErrorMessage(err.toString());
76
- setView('wallet-list');
76
+ goToInitialView();
77
77
  return;
78
78
  }
79
79
  });
@@ -22,12 +22,12 @@ require('@dynamic-labs/sdk-api');
22
22
 
23
23
  const useCreateUserProfileByJWTCallback = () => {
24
24
  const { setUser, handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
25
- const { setView } = ViewContext.useViewContext();
25
+ const { goToInitialView } = ViewContext.useViewContext();
26
26
  const createUserProfileByJWT = React.useCallback((jwt) => {
27
27
  const decodedJWT = decodeJwt.decodeJwt(jwt);
28
28
  if (!decodedJWT) {
29
29
  handleLogOut();
30
- setView('wallet-list');
30
+ goToInitialView();
31
31
  return;
32
32
  }
33
33
  const userProfile = createUserProfile.createUserProfile(decodedJWT);
@@ -18,12 +18,12 @@ import '@dynamic-labs/sdk-api';
18
18
 
19
19
  const useCreateUserProfileByJWTCallback = () => {
20
20
  const { setUser, handleLogOut } = useInternalDynamicContext();
21
- const { setView } = useViewContext();
21
+ const { goToInitialView } = useViewContext();
22
22
  const createUserProfileByJWT = useCallback((jwt) => {
23
23
  const decodedJWT = decodeJwt(jwt);
24
24
  if (!decodedJWT) {
25
25
  handleLogOut();
26
- setView('wallet-list');
26
+ goToInitialView();
27
27
  return;
28
28
  }
29
29
  const userProfile = createUserProfile(decodedJWT);
@@ -7,6 +7,7 @@ var utils = require('@dynamic-labs/utils');
7
7
  var api = require('../../../data/api.cjs');
8
8
  require('@dynamic-labs/sdk-api');
9
9
  require('../../../shared/logger.cjs');
10
+ var getFromLS = require('../../../shared/utils/functions/storage/getFromLS.cjs');
10
11
  require('../../../config/LSSuffix.cjs');
11
12
  require('@dynamic-labs/iconic');
12
13
  require('@dynamic-labs/wallet-connector-core');
@@ -32,10 +33,11 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, })
32
33
  removeLsSettings();
33
34
  }
34
35
  React.useEffect(() => {
35
- if (!authToken) {
36
+ const connectedWalletData = getFromLS.getFromLS(localStorage.CONNECTED_WALLET_CONNECTOR_DATA);
37
+ if (!authToken && !connectedWalletData) {
36
38
  removeLsSettings();
37
39
  }
38
- }, [authToken]);
40
+ }, [authToken, removeLsSettings]);
39
41
  React.useEffect(() => {
40
42
  if (!lsSettingsExists &&
41
43
  !isLoading &&
@@ -3,12 +3,13 @@ import { DynamicError } from '@dynamic-labs/utils';
3
3
  import { fetchProjectSettings } from '../../../data/api.js';
4
4
  import '@dynamic-labs/sdk-api';
5
5
  import '../../../shared/logger.js';
6
+ import { getFromLS } from '../../../shared/utils/functions/storage/getFromLS.js';
6
7
  import '../../../config/LSSuffix.js';
7
8
  import '@dynamic-labs/iconic';
8
9
  import '@dynamic-labs/wallet-connector-core';
9
10
  import 'react/jsx-runtime';
10
11
  import '../../../context/ViewContext/ViewContext.js';
11
- import { PROJECT_SETTINGS_STORAGE_KEY } from '../../constants/localStorage.js';
12
+ import { PROJECT_SETTINGS_STORAGE_KEY, CONNECTED_WALLET_CONNECTOR_DATA } from '../../constants/localStorage.js';
12
13
  import '../../constants/colors.js';
13
14
  import 'ethers';
14
15
  import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
@@ -28,10 +29,11 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, })
28
29
  removeLsSettings();
29
30
  }
30
31
  useEffect(() => {
31
- if (!authToken) {
32
+ const connectedWalletData = getFromLS(CONNECTED_WALLET_CONNECTOR_DATA);
33
+ if (!authToken && !connectedWalletData) {
32
34
  removeLsSettings();
33
35
  }
34
- }, [authToken]);
36
+ }, [authToken, removeLsSettings]);
35
37
  useEffect(() => {
36
38
  if (!lsSettingsExists &&
37
39
  !isLoading &&
@@ -49,7 +49,7 @@ const EmailUpdate = () => {
49
49
  const [updatedEmail, setUpdatedEmail] = React.useState('');
50
50
  const { setError, setErrorMessage } = ErrorContext.useErrorContext();
51
51
  const { loading, setLoading } = LoadingContext.useLoadingContext();
52
- const { setView } = ViewContext.useViewContext();
52
+ const { setView, goToInitialView } = ViewContext.useViewContext();
53
53
  const { email, setEmail, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
54
54
  const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
55
55
  const handleBackClick = () => {
@@ -65,7 +65,7 @@ const EmailUpdate = () => {
65
65
  const { emailVerification } = yield api.updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
66
66
  if (!emailVerification) {
67
67
  yield handleLogOut();
68
- setView('wallet-list');
68
+ goToInitialView();
69
69
  return;
70
70
  }
71
71
  setError(undefined);
@@ -45,7 +45,7 @@ const EmailUpdate = () => {
45
45
  const [updatedEmail, setUpdatedEmail] = useState('');
46
46
  const { setError, setErrorMessage } = useErrorContext();
47
47
  const { loading, setLoading } = useLoadingContext();
48
- const { setView } = useViewContext();
48
+ const { setView, goToInitialView } = useViewContext();
49
49
  const { email, setEmail, setVerificationUUID } = useEmailVerificationContext();
50
50
  const { environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext();
51
51
  const handleBackClick = () => {
@@ -61,7 +61,7 @@ const EmailUpdate = () => {
61
61
  const { emailVerification } = yield updateUserProfileFields(onboardingOnlyJwt, environmentId, { email: updatedEmail });
62
62
  if (!emailVerification) {
63
63
  yield handleLogOut();
64
- setView('wallet-list');
64
+ goToInitialView();
65
65
  return;
66
66
  }
67
67
  setError(undefined);
@@ -76,7 +76,7 @@ const EmailVerification = () => {
76
76
  setLoading(true);
77
77
  if (!verificationUUID || (!authToken && !onboardingOnlyJwt)) {
78
78
  yield handleLogOut();
79
- setView('wallet-list');
79
+ goToInitialView();
80
80
  return;
81
81
  }
82
82
  try {
@@ -104,7 +104,7 @@ const EmailVerification = () => {
104
104
  authToken,
105
105
  onboardingOnlyJwt,
106
106
  handleLogOut,
107
- setView,
107
+ goToInitialView,
108
108
  verifyEmail,
109
109
  setShowAuthFlow,
110
110
  setOnboardingOnlyJwt,
@@ -116,7 +116,7 @@ const EmailVerification = () => {
116
116
  setLoading(true);
117
117
  if (!verificationUUID) {
118
118
  yield handleLogOut();
119
- setView('wallet-list');
119
+ goToInitialView();
120
120
  return;
121
121
  }
122
122
  try {
@@ -127,7 +127,7 @@ const EmailVerification = () => {
127
127
  });
128
128
  if (!jwt) {
129
129
  yield handleLogOut();
130
- setView('wallet-list');
130
+ goToInitialView();
131
131
  return;
132
132
  }
133
133
  const decodedJwt = decodeJwt.decodeJwt(jwt);
@@ -160,10 +160,11 @@ const EmailVerification = () => {
160
160
  setLoading,
161
161
  verificationUUID,
162
162
  handleLogOut,
163
- setView,
163
+ goToInitialView,
164
164
  environmentId,
165
165
  setCallback,
166
166
  setOnboardingOnlyJwt,
167
+ setView,
167
168
  createUserProfileByJWT,
168
169
  setShowAuthFlow,
169
170
  setErrorMessage,
@@ -72,7 +72,7 @@ const EmailVerification = () => {
72
72
  setLoading(true);
73
73
  if (!verificationUUID || (!authToken && !onboardingOnlyJwt)) {
74
74
  yield handleLogOut();
75
- setView('wallet-list');
75
+ goToInitialView();
76
76
  return;
77
77
  }
78
78
  try {
@@ -100,7 +100,7 @@ const EmailVerification = () => {
100
100
  authToken,
101
101
  onboardingOnlyJwt,
102
102
  handleLogOut,
103
- setView,
103
+ goToInitialView,
104
104
  verifyEmail,
105
105
  setShowAuthFlow,
106
106
  setOnboardingOnlyJwt,
@@ -112,7 +112,7 @@ const EmailVerification = () => {
112
112
  setLoading(true);
113
113
  if (!verificationUUID) {
114
114
  yield handleLogOut();
115
- setView('wallet-list');
115
+ goToInitialView();
116
116
  return;
117
117
  }
118
118
  try {
@@ -123,7 +123,7 @@ const EmailVerification = () => {
123
123
  });
124
124
  if (!jwt) {
125
125
  yield handleLogOut();
126
- setView('wallet-list');
126
+ goToInitialView();
127
127
  return;
128
128
  }
129
129
  const decodedJwt = decodeJwt(jwt);
@@ -156,10 +156,11 @@ const EmailVerification = () => {
156
156
  setLoading,
157
157
  verificationUUID,
158
158
  handleLogOut,
159
- setView,
159
+ goToInitialView,
160
160
  environmentId,
161
161
  setCallback,
162
162
  setOnboardingOnlyJwt,
163
+ setView,
163
164
  createUserProfileByJWT,
164
165
  setShowAuthFlow,
165
166
  setErrorMessage,
@@ -6,9 +6,9 @@ var _tslib = require('../../../../../../_virtual/_tslib.cjs');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
8
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
9
- var sdkApi = require('@dynamic-labs/sdk-api');
10
9
  require('@dynamic-labs/utils');
11
10
  var api = require('../../../../data/api.cjs');
11
+ require('@dynamic-labs/sdk-api');
12
12
  require('../../../../shared/logger.cjs');
13
13
  require('../../../../config/LSSuffix.cjs');
14
14
  require('@dynamic-labs/iconic');
@@ -45,7 +45,7 @@ var LoadingContext = require('../../../../context/LoadingContext/LoadingContext.
45
45
 
46
46
  const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
47
47
  const LoginWithEmailForm = () => {
48
- const { environmentId, wallets, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
48
+ const { environmentId, wallets } = useInternalDynamicContext.useInternalDynamicContext();
49
49
  const { setView } = ViewContext.useViewContext();
50
50
  const { loading, setLoading } = LoadingContext.useLoadingContext();
51
51
  const { setErrorMessage } = ErrorContext.useErrorContext();
@@ -72,10 +72,9 @@ const LoginWithEmailForm = () => {
72
72
  const handleMagicLinkSubmit = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
73
73
  yield connectWithEmail();
74
74
  });
75
- const handleEmailLoginSubmit = (emailInputOverride) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
76
- const emailToVerify = emailInputOverride !== null && emailInputOverride !== void 0 ? emailInputOverride : emailInput;
75
+ const handleEmailLoginSubmit = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
77
76
  const { email, verificationUUID } = yield api.createEmailVerification({
78
- email: emailToVerify,
77
+ email: emailInput,
79
78
  environmentId,
80
79
  });
81
80
  setView('login-with-email-verification');
@@ -98,19 +97,6 @@ const LoginWithEmailForm = () => {
98
97
  }
99
98
  try {
100
99
  setLoading(true);
101
- if (magicLinkEnabled &&
102
- (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
103
- // see: https://linear.app/dynamic-labs/issue/DYN-2517
104
- // if confirmWalletTransfers setting is true, check api first to confirm emailProvider
105
- const { emailProvider } = yield api.getEmailProvider({
106
- email: emailValue,
107
- environmentId,
108
- });
109
- if (emailProvider === sdkApi.ProviderEnum.EmailOnly) {
110
- yield handleEmailLoginSubmit(emailValue);
111
- return;
112
- }
113
- }
114
100
  yield submitHandler();
115
101
  }
116
102
  catch (error) {
@@ -2,9 +2,9 @@ import { __awaiter } from '../../../../../../_virtual/_tslib.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
3
  import { useState, useMemo } from 'react';
4
4
  import { isEmailWalletConnector } from '@dynamic-labs/wallet-connector-core';
5
- import { ProviderEnum } from '@dynamic-labs/sdk-api';
6
5
  import '@dynamic-labs/utils';
7
- import { getEmailProvider, createEmailVerification } from '../../../../data/api.js';
6
+ import { createEmailVerification } from '../../../../data/api.js';
7
+ import '@dynamic-labs/sdk-api';
8
8
  import '../../../../shared/logger.js';
9
9
  import '../../../../config/LSSuffix.js';
10
10
  import '@dynamic-labs/iconic';
@@ -41,7 +41,7 @@ import { useLoadingContext } from '../../../../context/LoadingContext/LoadingCon
41
41
 
42
42
  const EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
43
43
  const LoginWithEmailForm = () => {
44
- const { environmentId, wallets, projectSettings } = useInternalDynamicContext();
44
+ const { environmentId, wallets } = useInternalDynamicContext();
45
45
  const { setView } = useViewContext();
46
46
  const { loading, setLoading } = useLoadingContext();
47
47
  const { setErrorMessage } = useErrorContext();
@@ -68,10 +68,9 @@ const LoginWithEmailForm = () => {
68
68
  const handleMagicLinkSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
69
69
  yield connectWithEmail();
70
70
  });
71
- const handleEmailLoginSubmit = (emailInputOverride) => __awaiter(void 0, void 0, void 0, function* () {
72
- const emailToVerify = emailInputOverride !== null && emailInputOverride !== void 0 ? emailInputOverride : emailInput;
71
+ const handleEmailLoginSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
73
72
  const { email, verificationUUID } = yield createEmailVerification({
74
- email: emailToVerify,
73
+ email: emailInput,
75
74
  environmentId,
76
75
  });
77
76
  setView('login-with-email-verification');
@@ -94,19 +93,6 @@ const LoginWithEmailForm = () => {
94
93
  }
95
94
  try {
96
95
  setLoading(true);
97
- if (magicLinkEnabled &&
98
- (projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.confirmEmailProviderForVerify)) {
99
- // see: https://linear.app/dynamic-labs/issue/DYN-2517
100
- // if confirmWalletTransfers setting is true, check api first to confirm emailProvider
101
- const { emailProvider } = yield getEmailProvider({
102
- email: emailValue,
103
- environmentId,
104
- });
105
- if (emailProvider === ProviderEnum.EmailOnly) {
106
- yield handleEmailLoginSubmit(emailValue);
107
- return;
108
- }
109
- }
110
96
  yield submitHandler();
111
97
  }
112
98
  catch (error) {
@@ -45,7 +45,7 @@ require('formik');
45
45
  require('yup');
46
46
 
47
47
  const WalletSignSpinnerView = () => {
48
- const { setView } = ViewContext.useViewContext();
48
+ const { goToInitialView } = ViewContext.useViewContext();
49
49
  const { setMultiWalletWidgetState, setSelectedWalletConnector, selectedWalletConnector: walletConnector, } = useInternalDynamicContext.useInternalDynamicContext();
50
50
  if (!walletConnector) {
51
51
  return null;
@@ -53,7 +53,7 @@ const WalletSignSpinnerView = () => {
53
53
  const { name } = walletConnector;
54
54
  const iconSize = 80;
55
55
  const handleClose = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
56
- setView('wallet-list');
56
+ goToInitialView();
57
57
  setMultiWalletWidgetState('idle');
58
58
  setSelectedWalletConnector(null);
59
59
  yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.endSession());
@@ -41,7 +41,7 @@ import 'formik';
41
41
  import 'yup';
42
42
 
43
43
  const WalletSignSpinnerView = () => {
44
- const { setView } = useViewContext();
44
+ const { goToInitialView } = useViewContext();
45
45
  const { setMultiWalletWidgetState, setSelectedWalletConnector, selectedWalletConnector: walletConnector, } = useInternalDynamicContext();
46
46
  if (!walletConnector) {
47
47
  return null;
@@ -49,7 +49,7 @@ const WalletSignSpinnerView = () => {
49
49
  const { name } = walletConnector;
50
50
  const iconSize = 80;
51
51
  const handleClose = () => __awaiter(void 0, void 0, void 0, function* () {
52
- setView('wallet-list');
52
+ goToInitialView();
53
53
  setMultiWalletWidgetState('idle');
54
54
  setSelectedWalletConnector(null);
55
55
  yield (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.endSession());
@@ -56,7 +56,7 @@ const WalletUsedView = () => {
56
56
  const [walletAddress, setWalletAddress] = React.useState(undefined);
57
57
  const { setErrorMessage } = ErrorContext.useErrorContext();
58
58
  const { loading, setLoading } = LoadingContext.useLoadingContext();
59
- const { setView } = ViewContext.useViewContext();
59
+ const { setView, goToInitialView } = ViewContext.useViewContext();
60
60
  const { environmentId, displayTermsOfService, authToken, setCallback, setShowAuthFlow, setUser, appName, siweStatement, setPrimaryWalletId, primaryWallet, setMultiWalletWidgetState, connectWallet, selectedWalletConnector: walletConnector, isSingleWalletAccount, consumeNonce, handleLogOut, } = useInternalDynamicContext.useInternalDynamicContext();
61
61
  React.useEffect(() => {
62
62
  const _fetchPublicAddress = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
@@ -90,7 +90,7 @@ const WalletUsedView = () => {
90
90
  return;
91
91
  const nonce = consumeNonce();
92
92
  if (!nonce) {
93
- setView('wallet-list');
93
+ goToInitialView();
94
94
  setErrorMessage('missing-nonce');
95
95
  return;
96
96
  }
@@ -52,7 +52,7 @@ const WalletUsedView = () => {
52
52
  const [walletAddress, setWalletAddress] = useState(undefined);
53
53
  const { setErrorMessage } = useErrorContext();
54
54
  const { loading, setLoading } = useLoadingContext();
55
- const { setView } = useViewContext();
55
+ const { setView, goToInitialView } = useViewContext();
56
56
  const { environmentId, displayTermsOfService, authToken, setCallback, setShowAuthFlow, setUser, appName, siweStatement, setPrimaryWalletId, primaryWallet, setMultiWalletWidgetState, connectWallet, selectedWalletConnector: walletConnector, isSingleWalletAccount, consumeNonce, handleLogOut, } = useInternalDynamicContext();
57
57
  useEffect(() => {
58
58
  const _fetchPublicAddress = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -86,7 +86,7 @@ const WalletUsedView = () => {
86
86
  return;
87
87
  const nonce = consumeNonce();
88
88
  if (!nonce) {
89
- setView('wallet-list');
89
+ goToInitialView();
90
90
  setErrorMessage('missing-nonce');
91
91
  return;
92
92
  }