@dynamic-labs/sdk-react-core 1.0.4 → 1.0.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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +10 -10
  5. package/src/lib/layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.cjs +12 -0
  6. package/src/lib/layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.d.ts +6 -0
  7. package/src/lib/layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.js +8 -0
  8. package/src/lib/layout/DynamicAuthLayout/DefaultFooter/index.d.ts +1 -0
  9. package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +1 -3
  10. package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +1 -3
  11. package/src/lib/shared/utils/functions/isUserLinkingWallet/isUserLinkingWallet.cjs +1 -2
  12. package/src/lib/shared/utils/functions/isUserLinkingWallet/isUserLinkingWallet.js +1 -2
  13. package/src/lib/styles/index.shadow.cjs +1 -1
  14. package/src/lib/styles/index.shadow.js +1 -1
  15. package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs +1 -28
  16. package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js +1 -28
  17. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +3 -2
  18. package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +3 -2
  19. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -1
  20. package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -1
  21. package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +5 -4
  22. package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.d.ts +2 -0
  23. package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +5 -5
  24. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +0 -3
  25. package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +0 -3
  26. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +14 -20
  27. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +14 -20
  28. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +4 -26
  29. package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +4 -26
  30. package/src/lib/views/EmailVerification/EmailVerification.cjs +23 -34
  31. package/src/lib/views/EmailVerification/EmailVerification.js +23 -34
  32. package/src/lib/views/LoginView/LoginView.cjs +6 -1
  33. package/src/lib/views/LoginView/LoginView.js +6 -1
  34. package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.cjs +3 -4
  35. package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.js +3 -4
  36. package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/findEmailOtpWalletConnector.cjs +17 -0
  37. package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/findEmailOtpWalletConnector.d.ts +3 -0
  38. package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/findEmailOtpWalletConnector.js +13 -0
  39. package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/index.d.ts +1 -0
  40. package/src/lib/views/Passkey/utils/index.d.ts +1 -0
  41. package/src/lib/views/WalletList/WalletList.cjs +6 -7
  42. package/src/lib/views/WalletList/WalletList.js +6 -7
@@ -60,7 +60,8 @@ const useAuthLayoutChecks = (walletConnector) => {
60
60
  // Don't show empty footer during the login
61
61
  ((view === 'login-with-email-or-wallet' ||
62
62
  view === 'login-with-email-or-wallet-full-wallet-list' ||
63
- view === 'login-with-wallet-only') &&
63
+ view === 'login-with-wallet-only' ||
64
+ view === 'multi-wallet-wallet-list') &&
64
65
  (termsOfServiceUrl ||
65
66
  privacyPolicyUrl ||
66
67
  customPrivacyPolicy ||
@@ -90,7 +91,7 @@ const useAuthLayoutChecks = (walletConnector) => {
90
91
  view === 'passkey-intro' ||
91
92
  (view === 'merge-user-accounts' && !user);
92
93
  const showQrCodePreHeader = view === 'qr-code' && showQrCodeMessage && !showQrCodeImage;
93
- const showDefaultFooter = !showDynamicFooter && !showToSFooter;
94
+ const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
94
95
  return {
95
96
  displayBorderBelowHeader,
96
97
  isWalletListTypeView,
@@ -6,11 +6,11 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
6
6
  var createEmbeddedWalletWithPasskey = require('../../../views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs');
7
7
  var findPasskeyEmailWalletConnector = require('../../../views/Passkey/utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.cjs');
8
8
  var createPregeneratedWallet = require('../../../views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs');
9
+ require('@dynamic-labs/wallet-connector-core');
9
10
  var createUserProfile = require('../../functions/createUserProfile/createUserProfile.cjs');
10
11
  require('@dynamic-labs/sdk-api');
11
12
  var logger = require('../../../shared/logger.cjs');
12
13
  require('@dynamic-labs/iconic');
13
- require('@dynamic-labs/wallet-connector-core');
14
14
  require('react/jsx-runtime');
15
15
  require('../../../context/ViewContext/ViewContext.cjs');
16
16
  require('react');
@@ -2,11 +2,11 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
2
2
  import { createEmbeddedWalletWithPasskey } from '../../../views/Passkey/utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js';
3
3
  import { findPasskeyEmailWalletConnector } from '../../../views/Passkey/utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.js';
4
4
  import { createPregeneratedWallet } from '../../../views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js';
5
+ import '@dynamic-labs/wallet-connector-core';
5
6
  import { createUserProfile } from '../../functions/createUserProfile/createUserProfile.js';
6
7
  import '@dynamic-labs/sdk-api';
7
8
  import { logger } from '../../../shared/logger.js';
8
9
  import '@dynamic-labs/iconic';
9
- import '@dynamic-labs/wallet-connector-core';
10
10
  import 'react/jsx-runtime';
11
11
  import '../../../context/ViewContext/ViewContext.js';
12
12
  import 'react';
@@ -22,8 +22,11 @@ require('viem');
22
22
  require('@dynamic-labs/utils');
23
23
  require('../../../shared/consts/index.cjs');
24
24
  require('@dynamic-labs/multi-wallet');
25
+ var isProviderEnabled = require('../../functions/isProviderEnabled/isProviderEnabled.cjs');
25
26
  var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
26
27
 
28
+ const checkMagicOrBloctoEnabled = (providers) => isProviderEnabled.isProviderEnabled(providers || [], sdkApi.ProviderEnum.MagicLink) ||
29
+ isProviderEnabled.isProviderEnabled(providers || [], sdkApi.ProviderEnum.Blocto);
27
30
  const useEmailProvider = ({ emailWalletConnector }) => {
28
31
  const { projectSettings, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
29
32
  const { setEmail: setEmailForVerification, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
@@ -38,10 +41,7 @@ const useEmailProvider = ({ emailWalletConnector }) => {
38
41
  // this is enabled in the sense that we could use the given provider in the email form
39
42
  // for magic, as long as there are magic credentials available, then could have an email
40
43
  // address that is a magic address, even if magic was previously turned off in dashboard
41
- const isMagicOrBloctoEnabled = isInjectedWalletProviderEnabled &&
42
- Boolean(providers === null || providers === void 0 ? void 0 : providers.filter((provider) => (provider.provider === sdkApi.ProviderEnum.MagicLink &&
43
- Boolean(provider.providerProjectId)) ||
44
- (provider.enabledAt && provider.provider === sdkApi.ProviderEnum.Blocto)).length);
44
+ const isMagicOrBloctoEnabled = isInjectedWalletProviderEnabled && checkMagicOrBloctoEnabled(providers);
45
45
  const handleEmailOnlyLoginSubmit = (emailInput, captchaToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
46
46
  const { email, verificationUUID } = yield api.createEmailVerification({
47
47
  captchaToken,
@@ -89,4 +89,5 @@ const useEmailProvider = ({ emailWalletConnector }) => {
89
89
  };
90
90
  };
91
91
 
92
+ exports.checkMagicOrBloctoEnabled = checkMagicOrBloctoEnabled;
92
93
  exports.useEmailProvider = useEmailProvider;
@@ -1,7 +1,9 @@
1
1
  import { IEmailWalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ import { Provider } from '@dynamic-labs/sdk-api';
2
3
  type Props = {
3
4
  emailWalletConnector: IEmailWalletConnector | undefined;
4
5
  };
6
+ export declare const checkMagicOrBloctoEnabled: (providers: Provider[] | undefined) => boolean;
5
7
  export declare const useEmailProvider: ({ emailWalletConnector }: Props) => {
6
8
  handleEmailSubmitWithOptionalCaptcha: (emailInput: string, captchaToken?: string) => Promise<void>;
7
9
  isEmailProviderLoading: boolean;
@@ -18,8 +18,11 @@ import 'viem';
18
18
  import '@dynamic-labs/utils';
19
19
  import '../../../shared/consts/index.js';
20
20
  import '@dynamic-labs/multi-wallet';
21
+ import { isProviderEnabled } from '../../functions/isProviderEnabled/isProviderEnabled.js';
21
22
  import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
22
23
 
24
+ const checkMagicOrBloctoEnabled = (providers) => isProviderEnabled(providers || [], ProviderEnum.MagicLink) ||
25
+ isProviderEnabled(providers || [], ProviderEnum.Blocto);
23
26
  const useEmailProvider = ({ emailWalletConnector }) => {
24
27
  const { projectSettings, environmentId } = useInternalDynamicContext();
25
28
  const { setEmail: setEmailForVerification, setVerificationUUID } = useEmailVerificationContext();
@@ -34,10 +37,7 @@ const useEmailProvider = ({ emailWalletConnector }) => {
34
37
  // this is enabled in the sense that we could use the given provider in the email form
35
38
  // for magic, as long as there are magic credentials available, then could have an email
36
39
  // address that is a magic address, even if magic was previously turned off in dashboard
37
- const isMagicOrBloctoEnabled = isInjectedWalletProviderEnabled &&
38
- Boolean(providers === null || providers === void 0 ? void 0 : providers.filter((provider) => (provider.provider === ProviderEnum.MagicLink &&
39
- Boolean(provider.providerProjectId)) ||
40
- (provider.enabledAt && provider.provider === ProviderEnum.Blocto)).length);
40
+ const isMagicOrBloctoEnabled = isInjectedWalletProviderEnabled && checkMagicOrBloctoEnabled(providers);
41
41
  const handleEmailOnlyLoginSubmit = (emailInput, captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
42
42
  const { email, verificationUUID } = yield createEmailVerification({
43
43
  captchaToken,
@@ -85,4 +85,4 @@ const useEmailProvider = ({ emailWalletConnector }) => {
85
85
  };
86
86
  };
87
87
 
88
- export { useEmailProvider };
88
+ export { checkMagicOrBloctoEnabled, useEmailProvider };
@@ -27,14 +27,12 @@ var isEmbeddedWalletPresent = require('../../functions/isEmbeddedWalletPresent/i
27
27
  var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
28
28
  var smartWallet = require('../useWalletConnectors/utils/smartWallet/smartWallet.cjs');
29
29
  var useCreateDynamicEmbeddedWalletMutation = require('../useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs');
30
- var useCreateUserProfileByJWTCallback = require('../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs');
31
30
 
32
31
  // Hook exposed to customers and used internally to trigger embedded wallet creation
33
32
  const useEmbeddedWallet = () => {
34
33
  const { projectSettings, onboardingOnlyJwt, setPrimaryWalletId, walletConnectorOptions, internalSetShowAuthFlow, internalEvents, primaryWallet, environmentId, } = useInternalDynamicContext.useInternalDynamicContext();
35
34
  const { setView } = ViewContext.useViewContext();
36
35
  const { createDynamicEmbeddedWalletMutation } = useCreateDynamicEmbeddedWalletMutation.useCreateDynamicEmbeddedWalletMutation();
37
- const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback.useCreateUserProfileByJWTCallback();
38
36
  const userHasEmbeddedWallet = () => {
39
37
  var _a;
40
38
  const jwt = (_a = getAuthToken.getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
@@ -87,7 +85,6 @@ const useEmbeddedWallet = () => {
87
85
  // if user already has embedded wallet, set it as primary wallet
88
86
  if (decodedJwt) {
89
87
  (_a = turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) === null || _a === void 0 ? void 0 : _a.setVerifiedCredentials(decodedJwt.verifiedCredentials);
90
- yield createUserProfileByJWT(jwt);
91
88
  const smartWallet$1 = smartWallet.findSmartWallet(embeddedWalletVerifiedCredential, decodedJwt.verifiedCredentials);
92
89
  if (smartWallet$1) {
93
90
  yield smartWallet.initializeSmartWallet({
@@ -23,14 +23,12 @@ import { isEmbeddedWalletPresent } from '../../functions/isEmbeddedWalletPresent
23
23
  import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
24
24
  import { findSmartWallet, initializeSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
25
25
  import { useCreateDynamicEmbeddedWalletMutation } from '../useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js';
26
- import { useCreateUserProfileByJWTCallback } from '../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js';
27
26
 
28
27
  // Hook exposed to customers and used internally to trigger embedded wallet creation
29
28
  const useEmbeddedWallet = () => {
30
29
  const { projectSettings, onboardingOnlyJwt, setPrimaryWalletId, walletConnectorOptions, internalSetShowAuthFlow, internalEvents, primaryWallet, environmentId, } = useInternalDynamicContext();
31
30
  const { setView } = useViewContext();
32
31
  const { createDynamicEmbeddedWalletMutation } = useCreateDynamicEmbeddedWalletMutation();
33
- const { createUserProfileByJWT } = useCreateUserProfileByJWTCallback();
34
32
  const userHasEmbeddedWallet = () => {
35
33
  var _a;
36
34
  const jwt = (_a = getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
@@ -83,7 +81,6 @@ const useEmbeddedWallet = () => {
83
81
  // if user already has embedded wallet, set it as primary wallet
84
82
  if (decodedJwt) {
85
83
  (_a = turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector) === null || _a === void 0 ? void 0 : _a.setVerifiedCredentials(decodedJwt.verifiedCredentials);
86
- yield createUserProfileByJWT(jwt);
87
84
  const smartWallet = findSmartWallet(embeddedWalletVerifiedCredential, decodedJwt.verifiedCredentials);
88
85
  if (smartWallet) {
89
86
  yield initializeSmartWallet({
@@ -27,9 +27,7 @@ require('@dynamic-labs/multi-wallet');
27
27
  var getAuthToken = require('../../functions/getAuthToken/getAuthToken.cjs');
28
28
  var getOauthLoginUrl = require('../../functions/getOauthLoginUrl/getOauthLoginUrl.cjs');
29
29
  var getProviderByType = require('../../functions/getProviderByType/getProviderByType.cjs');
30
- var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
31
30
  var randomString = require('../../functions/randomString/randomString.cjs');
32
- var index = require('../../functions/storeAuthToken/index.cjs');
33
31
  var stringifyURIQuery = require('../../functions/stringifyURIQuery/stringifyURIQuery.cjs');
34
32
  var useCreateUserProfileByJWTCallback = require('../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.cjs');
35
33
  var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
@@ -60,7 +58,6 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
60
58
  const { createEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
61
59
  const [isProcessing, setIsProcessing] = React.useState(false);
62
60
  const [error, setError] = React.useState();
63
- const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
64
61
  const providersWaitingOauthMessage = React.useRef({});
65
62
  const authWindowInterval = React.useRef();
66
63
  const shouldPool = React.useRef(false);
@@ -150,25 +147,22 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
150
147
  return;
151
148
  }
152
149
  setCallback('authSuccess');
153
- if (isTurnkeyProviderEnabled &&
154
- ((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation)) {
155
- try {
156
- index.storeAuthToken(jwt);
157
- // this function will check turnkey wallet enabled and create wallet if needed
158
- // if not enabled, it will throw an error.
159
- yield createEmbeddedWallet();
160
- onSettled === null || onSettled === void 0 ? void 0 : onSettled();
161
- }
162
- catch (e) {
163
- yield createUserProfileByJWT(jwt);
164
- setShowAuthFlow(false);
165
- onSettled === null || onSettled === void 0 ? void 0 : onSettled();
166
- }
150
+ yield createUserProfileByJWT(jwt);
151
+ if (!((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation)) {
152
+ setShowAuthFlow(false);
153
+ onSettled === null || onSettled === void 0 ? void 0 : onSettled();
167
154
  return;
168
155
  }
169
- yield createUserProfileByJWT(jwt);
170
- setShowAuthFlow(false);
171
- onSettled === null || onSettled === void 0 ? void 0 : onSettled();
156
+ try {
157
+ // this function will check turnkey wallet enabled and create wallet if needed
158
+ // if not enabled, it will throw an error.
159
+ yield createEmbeddedWallet();
160
+ onSettled === null || onSettled === void 0 ? void 0 : onSettled();
161
+ }
162
+ catch (e) {
163
+ setShowAuthFlow(false);
164
+ onSettled === null || onSettled === void 0 ? void 0 : onSettled();
165
+ }
172
166
  }
173
167
  catch (error) {
174
168
  if (error instanceof utils.NoAccessError) {
@@ -23,9 +23,7 @@ import '@dynamic-labs/multi-wallet';
23
23
  import { getAuthToken } from '../../functions/getAuthToken/getAuthToken.js';
24
24
  import { getOauthLoginUrl } from '../../functions/getOauthLoginUrl/getOauthLoginUrl.js';
25
25
  import { getProviderByType } from '../../functions/getProviderByType/getProviderByType.js';
26
- import { isTurnkeyEnabled } from '../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
27
26
  import { randomString } from '../../functions/randomString/randomString.js';
28
- import { storeAuthToken } from '../../functions/storeAuthToken/index.js';
29
27
  import { stringifyURIQuery } from '../../functions/stringifyURIQuery/stringifyURIQuery.js';
30
28
  import { useCreateUserProfileByJWTCallback } from '../useCreateUserProfileByJWTCallback/useCreateUserProfileByJWTCallback.js';
31
29
  import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
@@ -56,7 +54,6 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
56
54
  const { createEmbeddedWallet } = useEmbeddedWallet();
57
55
  const [isProcessing, setIsProcessing] = useState(false);
58
56
  const [error, setError] = useState();
59
- const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
60
57
  const providersWaitingOauthMessage = useRef({});
61
58
  const authWindowInterval = useRef();
62
59
  const shouldPool = useRef(false);
@@ -146,25 +143,22 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
146
143
  return;
147
144
  }
148
145
  setCallback('authSuccess');
149
- if (isTurnkeyProviderEnabled &&
150
- ((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation)) {
151
- try {
152
- storeAuthToken(jwt);
153
- // this function will check turnkey wallet enabled and create wallet if needed
154
- // if not enabled, it will throw an error.
155
- yield createEmbeddedWallet();
156
- onSettled === null || onSettled === void 0 ? void 0 : onSettled();
157
- }
158
- catch (e) {
159
- yield createUserProfileByJWT(jwt);
160
- setShowAuthFlow(false);
161
- onSettled === null || onSettled === void 0 ? void 0 : onSettled();
162
- }
146
+ yield createUserProfileByJWT(jwt);
147
+ if (!((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation)) {
148
+ setShowAuthFlow(false);
149
+ onSettled === null || onSettled === void 0 ? void 0 : onSettled();
163
150
  return;
164
151
  }
165
- yield createUserProfileByJWT(jwt);
166
- setShowAuthFlow(false);
167
- onSettled === null || onSettled === void 0 ? void 0 : onSettled();
152
+ try {
153
+ // this function will check turnkey wallet enabled and create wallet if needed
154
+ // if not enabled, it will throw an error.
155
+ yield createEmbeddedWallet();
156
+ onSettled === null || onSettled === void 0 ? void 0 : onSettled();
157
+ }
158
+ catch (e) {
159
+ setShowAuthFlow(false);
160
+ onSettled === null || onSettled === void 0 ? void 0 : onSettled();
161
+ }
168
162
  }
169
163
  catch (error) {
170
164
  if (error instanceof NoAccessError) {
@@ -25,8 +25,6 @@ require('../../../../context/CaptchaContext/CaptchaContext.cjs');
25
25
  require('../../../../context/ErrorContext/ErrorContext.cjs');
26
26
  require('@dynamic-labs/multi-wallet');
27
27
  require('@dynamic-labs/sdk-api');
28
- var isTurnkeyEnabled = require('../../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
29
- var index = require('../../../functions/storeAuthToken/index.cjs');
30
28
  require('../../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
31
29
  require('../../../../context/AccountExistsContext/AccountExistsContext.cjs');
32
30
  var useEmailVerificationRequest = require('../../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
@@ -56,14 +54,13 @@ const userFieldsSchema = yup.object().shape({
56
54
  username: yup.string(),
57
55
  });
58
56
  const useUpdateUser = (validationSchemaStripUnknown) => {
59
- const { authToken, onboardingOnlyJwt, environmentId, projectSettings, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
60
- const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
57
+ const { authToken, onboardingOnlyJwt, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
61
58
  const jwtToken = onboardingOnlyJwt || authToken;
62
59
  const { setVerificationUUID, setEmail } = EmailVerificationContext.useEmailVerificationContext();
63
60
  const { verifyEmail } = useEmailVerificationRequest.useEmailVerificationRequest();
64
61
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
65
62
  return React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
66
- var _a, _b, _c, _d;
63
+ var _a, _b, _c;
67
64
  // `stripUnknown: true` will automatically strip out any values in the metadata object
68
65
  // so we need to pull out the metadata object here and then re-add it after stripping unknown fields
69
66
  const { metadata } = userFields;
@@ -75,25 +72,6 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
75
72
  const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
76
73
  const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
77
74
  const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
78
- // This is to handle properly the embedded wallet creation.
79
- // In that case we shouldn't create a user. Only store the JWT in the localstorage
80
- // The user will be created after generating the wallet.
81
- // This should be called only when:
82
- // Turnkey is enabled
83
- // automaticEmbeddedWalletCreation is set to true
84
- // there is no emailVerificationRequired -> it's already verified
85
- // there is no primaryWallet -> it means that the user is already logged in
86
- if (isTurnkeyProviderEnabled &&
87
- ((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
88
- !_isEmailVerificationRequired &&
89
- !primaryWallet) {
90
- index.storeAuthToken(updateUserProfileResponse.jwt);
91
- return {
92
- isEmailVerificationRequired: false,
93
- missingFields,
94
- updateUserProfileResponse,
95
- };
96
- }
97
75
  if (!_isEmailVerificationRequired) {
98
76
  // If email verification is not needed then we can update the user profile immediately.
99
77
  yield updateUserProfileByJWT(updateUserProfileResponse.jwt);
@@ -104,8 +82,8 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
104
82
  };
105
83
  }
106
84
  // We update EmailContext to use this information in the Email Verification view
107
- setEmail((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.email);
108
- setVerificationUUID((_d = updateUserProfileResponse.emailVerification) === null || _d === void 0 ? void 0 : _d.verificationUUID);
85
+ setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
86
+ setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
109
87
  // DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
110
88
  // VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
111
89
  // setEmail and setVerificationUUID in the above lines will are not visible in this promise.
@@ -21,8 +21,6 @@ import '../../../../context/CaptchaContext/CaptchaContext.js';
21
21
  import '../../../../context/ErrorContext/ErrorContext.js';
22
22
  import '@dynamic-labs/multi-wallet';
23
23
  import '@dynamic-labs/sdk-api';
24
- import { isTurnkeyEnabled } from '../../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
25
- import { storeAuthToken } from '../../../functions/storeAuthToken/index.js';
26
24
  import '../../../../context/AccessDeniedContext/AccessDeniedContext.js';
27
25
  import '../../../../context/AccountExistsContext/AccountExistsContext.js';
28
26
  import { useEmailVerificationRequest } from '../../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js';
@@ -52,14 +50,13 @@ const userFieldsSchema = object().shape({
52
50
  username: string(),
53
51
  });
54
52
  const useUpdateUser = (validationSchemaStripUnknown) => {
55
- const { authToken, onboardingOnlyJwt, environmentId, projectSettings, primaryWallet, } = useInternalDynamicContext();
56
- const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
53
+ const { authToken, onboardingOnlyJwt, environmentId } = useInternalDynamicContext();
57
54
  const jwtToken = onboardingOnlyJwt || authToken;
58
55
  const { setVerificationUUID, setEmail } = useEmailVerificationContext();
59
56
  const { verifyEmail } = useEmailVerificationRequest();
60
57
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
61
58
  return useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
62
- var _a, _b, _c, _d;
59
+ var _a, _b, _c;
63
60
  // `stripUnknown: true` will automatically strip out any values in the metadata object
64
61
  // so we need to pull out the metadata object here and then re-add it after stripping unknown fields
65
62
  const { metadata } = userFields;
@@ -71,25 +68,6 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
71
68
  const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
72
69
  const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
73
70
  const _isEmailVerificationRequired = isEmailVerificationRequired(updateUserProfileResponse);
74
- // This is to handle properly the embedded wallet creation.
75
- // In that case we shouldn't create a user. Only store the JWT in the localstorage
76
- // The user will be created after generating the wallet.
77
- // This should be called only when:
78
- // Turnkey is enabled
79
- // automaticEmbeddedWalletCreation is set to true
80
- // there is no emailVerificationRequired -> it's already verified
81
- // there is no primaryWallet -> it means that the user is already logged in
82
- if (isTurnkeyProviderEnabled &&
83
- ((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
84
- !_isEmailVerificationRequired &&
85
- !primaryWallet) {
86
- storeAuthToken(updateUserProfileResponse.jwt);
87
- return {
88
- isEmailVerificationRequired: false,
89
- missingFields,
90
- updateUserProfileResponse,
91
- };
92
- }
93
71
  if (!_isEmailVerificationRequired) {
94
72
  // If email verification is not needed then we can update the user profile immediately.
95
73
  yield updateUserProfileByJWT(updateUserProfileResponse.jwt);
@@ -100,8 +78,8 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
100
78
  };
101
79
  }
102
80
  // We update EmailContext to use this information in the Email Verification view
103
- setEmail((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.email);
104
- setVerificationUUID((_d = updateUserProfileResponse.emailVerification) === null || _d === void 0 ? void 0 : _d.verificationUUID);
81
+ setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
82
+ setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
105
83
  // DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
106
84
  // VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
107
85
  // setEmail and setVerificationUUID in the above lines will are not visible in this promise.
@@ -27,8 +27,6 @@ var useEffectOnce = require('../../shared/utils/hooks/useEffectOnce/useEffectOnc
27
27
  require('../../shared/consts/index.cjs');
28
28
  require('@dynamic-labs/multi-wallet');
29
29
  require('@dynamic-labs/sdk-api');
30
- var isTurnkeyEnabled = require('../../utils/functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
31
- var index = require('../../utils/functions/storeAuthToken/index.cjs');
32
30
  require('../../context/AccessDeniedContext/AccessDeniedContext.cjs');
33
31
  var AccountExistsContext = require('../../context/AccountExistsContext/AccountExistsContext.cjs');
34
32
  var api = require('../../data/api.cjs');
@@ -102,7 +100,6 @@ const EmailVerification = () => {
102
100
  const { loading, setLoading } = LoadingContext.useLoadingContext();
103
101
  const { t } = reactI18next.useTranslation();
104
102
  const { createEmbeddedWallet } = useEmbeddedWallet.useEmbeddedWallet();
105
- const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
106
103
  const { remainingSeconds, startCountdown } = useCountdown.useCountdown({
107
104
  callback: () => setRetried(false),
108
105
  seconds: SECONDS_TO_RETRY,
@@ -135,7 +132,7 @@ const EmailVerification = () => {
135
132
  return;
136
133
  }
137
134
  try {
138
- const { nextView, jwt } = yield verifyEmail(verificationToken, verificationUUID);
135
+ const { nextView } = yield verifyEmail(verificationToken, verificationUUID);
139
136
  if (onboardingOnlyJwt) {
140
137
  setOnboardingOnlyJwt(undefined);
141
138
  setCallback('authSuccess');
@@ -144,20 +141,18 @@ const EmailVerification = () => {
144
141
  if (nextView === 'verified-and-transferred') {
145
142
  setShowTransferMessage(true);
146
143
  }
147
- if (isTurnkeyProviderEnabled &&
148
- ((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation)) {
149
- try {
150
- index.storeAuthToken(jwt);
151
- // this function will check turnkey wallet enabled and create wallet if needed
152
- // if not enabled, it will throw an error.
153
- yield createEmbeddedWallet();
154
- }
155
- catch (e) {
156
- setShowAuthFlow(false);
157
- }
144
+ if (!((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation)) {
145
+ setShowAuthFlow(false);
158
146
  return;
159
147
  }
160
- setShowAuthFlow(false);
148
+ try {
149
+ // this function will check turnkey wallet enabled and create wallet if needed
150
+ // if not enabled, it will throw an error.
151
+ yield createEmbeddedWallet();
152
+ }
153
+ catch (e) {
154
+ setShowAuthFlow(false);
155
+ }
161
156
  }
162
157
  catch (error) {
163
158
  logger.logger.debug(error);
@@ -185,8 +180,8 @@ const EmailVerification = () => {
185
180
  (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.automaticEmbeddedWalletCreation,
186
181
  createEmbeddedWallet,
187
182
  setShowAuthFlow,
183
+ setErrorMessage,
188
184
  setView,
189
- isTurnkeyProviderEnabled,
190
185
  ]);
191
186
  const handleEmailLogin = React.useCallback((verificationToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
192
187
  var _d;
@@ -219,24 +214,19 @@ const EmailVerification = () => {
219
214
  setCallback('authSuccess');
220
215
  // this timeout is set to make sure that the user will see success message
221
216
  yield sleepToShowSuccessMessage();
222
- if (isTurnkeyProviderEnabled &&
223
- ((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.automaticEmbeddedWalletCreation)) {
224
- try {
225
- // Store the auth token in local storage so it can be used during embedded wallet creation
226
- index.storeAuthToken(jwt);
227
- // this function will check turnkey wallet enabled and create wallet if needed
228
- // if not enabled, it will throw an error.
229
- yield createEmbeddedWallet();
230
- }
231
- catch (e) {
232
- yield createUserProfileByJWT(jwt);
233
- setShowAuthFlow(false);
234
- }
217
+ yield createUserProfileByJWT(jwt);
218
+ if (!((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.automaticEmbeddedWalletCreation)) {
219
+ setShowAuthFlow(false);
235
220
  return;
236
221
  }
237
- // If not creating embedded wallet automatically, create user profile
238
- yield createUserProfileByJWT(jwt);
239
- setShowAuthFlow(false);
222
+ try {
223
+ // this function will check turnkey wallet enabled and create wallet if needed
224
+ // if not enabled, it will throw an error.
225
+ yield createEmbeddedWallet();
226
+ }
227
+ catch (e) {
228
+ setShowAuthFlow(false);
229
+ }
240
230
  }
241
231
  catch (error) {
242
232
  if (error instanceof utils.NoAccessError) {
@@ -268,7 +258,6 @@ const EmailVerification = () => {
268
258
  setShowAuthFlow,
269
259
  setErrorMessage,
270
260
  setExistentAccountData,
271
- isTurnkeyProviderEnabled,
272
261
  ]);
273
262
  const handleRetry = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
274
263
  try {
@@ -23,8 +23,6 @@ import { useEffectOnce } from '../../shared/utils/hooks/useEffectOnce/useEffectO
23
23
  import '../../shared/consts/index.js';
24
24
  import '@dynamic-labs/multi-wallet';
25
25
  import '@dynamic-labs/sdk-api';
26
- import { isTurnkeyEnabled } from '../../utils/functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
27
- import { storeAuthToken } from '../../utils/functions/storeAuthToken/index.js';
28
26
  import '../../context/AccessDeniedContext/AccessDeniedContext.js';
29
27
  import { useAccountExistsContext } from '../../context/AccountExistsContext/AccountExistsContext.js';
30
28
  import { signInWithEmailVerification, retryEmailVerification } from '../../data/api.js';
@@ -98,7 +96,6 @@ const EmailVerification = () => {
98
96
  const { loading, setLoading } = useLoadingContext();
99
97
  const { t } = useTranslation();
100
98
  const { createEmbeddedWallet } = useEmbeddedWallet();
101
- const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
102
99
  const { remainingSeconds, startCountdown } = useCountdown({
103
100
  callback: () => setRetried(false),
104
101
  seconds: SECONDS_TO_RETRY,
@@ -131,7 +128,7 @@ const EmailVerification = () => {
131
128
  return;
132
129
  }
133
130
  try {
134
- const { nextView, jwt } = yield verifyEmail(verificationToken, verificationUUID);
131
+ const { nextView } = yield verifyEmail(verificationToken, verificationUUID);
135
132
  if (onboardingOnlyJwt) {
136
133
  setOnboardingOnlyJwt(undefined);
137
134
  setCallback('authSuccess');
@@ -140,20 +137,18 @@ const EmailVerification = () => {
140
137
  if (nextView === 'verified-and-transferred') {
141
138
  setShowTransferMessage(true);
142
139
  }
143
- if (isTurnkeyProviderEnabled &&
144
- ((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation)) {
145
- try {
146
- storeAuthToken(jwt);
147
- // this function will check turnkey wallet enabled and create wallet if needed
148
- // if not enabled, it will throw an error.
149
- yield createEmbeddedWallet();
150
- }
151
- catch (e) {
152
- setShowAuthFlow(false);
153
- }
140
+ if (!((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _c === void 0 ? void 0 : _c.automaticEmbeddedWalletCreation)) {
141
+ setShowAuthFlow(false);
154
142
  return;
155
143
  }
156
- setShowAuthFlow(false);
144
+ try {
145
+ // this function will check turnkey wallet enabled and create wallet if needed
146
+ // if not enabled, it will throw an error.
147
+ yield createEmbeddedWallet();
148
+ }
149
+ catch (e) {
150
+ setShowAuthFlow(false);
151
+ }
157
152
  }
158
153
  catch (error) {
159
154
  logger.debug(error);
@@ -181,8 +176,8 @@ const EmailVerification = () => {
181
176
  (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.automaticEmbeddedWalletCreation,
182
177
  createEmbeddedWallet,
183
178
  setShowAuthFlow,
179
+ setErrorMessage,
184
180
  setView,
185
- isTurnkeyProviderEnabled,
186
181
  ]);
187
182
  const handleEmailLogin = useCallback((verificationToken) => __awaiter(void 0, void 0, void 0, function* () {
188
183
  var _d;
@@ -215,24 +210,19 @@ const EmailVerification = () => {
215
210
  setCallback('authSuccess');
216
211
  // this timeout is set to make sure that the user will see success message
217
212
  yield sleepToShowSuccessMessage();
218
- if (isTurnkeyProviderEnabled &&
219
- ((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.automaticEmbeddedWalletCreation)) {
220
- try {
221
- // Store the auth token in local storage so it can be used during embedded wallet creation
222
- storeAuthToken(jwt);
223
- // this function will check turnkey wallet enabled and create wallet if needed
224
- // if not enabled, it will throw an error.
225
- yield createEmbeddedWallet();
226
- }
227
- catch (e) {
228
- yield createUserProfileByJWT(jwt);
229
- setShowAuthFlow(false);
230
- }
213
+ yield createUserProfileByJWT(jwt);
214
+ if (!((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _d === void 0 ? void 0 : _d.automaticEmbeddedWalletCreation)) {
215
+ setShowAuthFlow(false);
231
216
  return;
232
217
  }
233
- // If not creating embedded wallet automatically, create user profile
234
- yield createUserProfileByJWT(jwt);
235
- setShowAuthFlow(false);
218
+ try {
219
+ // this function will check turnkey wallet enabled and create wallet if needed
220
+ // if not enabled, it will throw an error.
221
+ yield createEmbeddedWallet();
222
+ }
223
+ catch (e) {
224
+ setShowAuthFlow(false);
225
+ }
236
226
  }
237
227
  catch (error) {
238
228
  if (error instanceof NoAccessError) {
@@ -264,7 +254,6 @@ const EmailVerification = () => {
264
254
  setShowAuthFlow,
265
255
  setErrorMessage,
266
256
  setExistentAccountData,
267
- isTurnkeyProviderEnabled,
268
257
  ]);
269
258
  const handleRetry = () => __awaiter(void 0, void 0, void 0, function* () {
270
259
  try {