@dynamic-labs/sdk-react-core 1.0.3 → 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.
- package/CHANGELOG.md +18 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/lib/layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.cjs +12 -0
- package/src/lib/layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.d.ts +6 -0
- package/src/lib/layout/DynamicAuthLayout/DefaultFooter/DefaultFooter.js +8 -0
- package/src/lib/layout/DynamicAuthLayout/DefaultFooter/index.d.ts +1 -0
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.cjs +1 -3
- package/src/lib/layout/DynamicAuthLayout/DynamicAuthLayout.js +1 -3
- package/src/lib/shared/utils/functions/isUserLinkingWallet/isUserLinkingWallet.cjs +1 -2
- package/src/lib/shared/utils/functions/isUserLinkingWallet/isUserLinkingWallet.js +1 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +16 -9
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +16 -9
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs +1 -28
- package/src/lib/utils/hooks/authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js +1 -28
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.cjs +3 -2
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAuthLayoutChecks.js +3 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -4
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -1
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +5 -4
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.d.ts +2 -0
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +5 -5
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +0 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +0 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +14 -20
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +14 -20
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +4 -26
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +4 -26
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +2 -2
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +2 -2
- package/src/lib/views/EmailVerification/EmailVerification.cjs +23 -34
- package/src/lib/views/EmailVerification/EmailVerification.js +23 -34
- package/src/lib/views/LoginView/LoginView.cjs +6 -1
- package/src/lib/views/LoginView/LoginView.js +6 -1
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.cjs +3 -4
- package/src/lib/views/LoginView/sections/EmailSignInSection/LoginEmailForm.js +3 -4
- package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/findEmailOtpWalletConnector.cjs +17 -0
- package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/findEmailOtpWalletConnector.d.ts +3 -0
- package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/findEmailOtpWalletConnector.js +13 -0
- package/src/lib/views/Passkey/utils/findEmailOtpWalletConnector/index.d.ts +1 -0
- package/src/lib/views/Passkey/utils/index.d.ts +1 -0
- package/src/lib/views/WalletList/WalletList.cjs +6 -7
- package/src/lib/views/WalletList/WalletList.js +6 -7
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.cjs +65 -21
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/hooks/useFetchBalance/useFetchBalance.js +66 -22
|
@@ -8,31 +8,14 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useI
|
|
|
8
8
|
var api = require('../../../../data/api.cjs');
|
|
9
9
|
var useUpdateUserProfileByJWTCallback = require('../../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
|
|
10
10
|
var EmailVerificationContext = require('../../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
|
|
11
|
-
require('@dynamic-labs/sdk-api');
|
|
12
|
-
require('../../../../shared/logger.cjs');
|
|
13
|
-
require('@dynamic-labs/iconic');
|
|
14
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
15
|
-
require('react/jsx-runtime');
|
|
16
|
-
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
17
|
-
require('@dynamic-labs/wallet-book');
|
|
18
|
-
require('../../../constants/colors.cjs');
|
|
19
|
-
require('../../../../shared/utils/classes/storage/localStorage.cjs');
|
|
20
|
-
require('viem');
|
|
21
|
-
require('@dynamic-labs/utils');
|
|
22
|
-
require('../../../../shared/consts/index.cjs');
|
|
23
|
-
require('@dynamic-labs/multi-wallet');
|
|
24
|
-
var isTurnkeyEnabled = require('../../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
|
|
25
11
|
|
|
26
12
|
// Hook exposed to the public as a scoped function in useUserUpdateRequest result
|
|
27
13
|
const useEmailVerificationRequest = () => {
|
|
28
|
-
|
|
29
|
-
const { onboardingOnlyJwt, authToken, environmentId, projectSettings, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
14
|
+
const { onboardingOnlyJwt, authToken, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
30
15
|
const jwtToken = onboardingOnlyJwt || authToken;
|
|
31
|
-
const isTurnkeyProviderEnabled = isTurnkeyEnabled.isTurnkeyEnabled(projectSettings);
|
|
32
16
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
33
17
|
const { verificationUUID: emailVerificationContextVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
34
18
|
const verifyEmail = React.useCallback((verificationToken, verificationUUID) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
-
var _b;
|
|
36
19
|
if (!jwtToken)
|
|
37
20
|
throw new Error('No JWT token provided');
|
|
38
21
|
// VerificationUUID is saved in the context in case the view changes
|
|
@@ -44,22 +27,12 @@ const useEmailVerificationRequest = () => {
|
|
|
44
27
|
verificationToken,
|
|
45
28
|
verificationUUID: String(verificationUUID || emailVerificationContextVerificationUUID),
|
|
46
29
|
}, jwtToken);
|
|
47
|
-
if (isTurnkeyProviderEnabled &&
|
|
48
|
-
((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
49
|
-
!primaryWallet) {
|
|
50
|
-
// Don't create the user right now
|
|
51
|
-
// It will be done after the wallet creation
|
|
52
|
-
return verifyEmailResponse;
|
|
53
|
-
}
|
|
54
30
|
yield updateUserProfileByJWT(verifyEmailResponse.jwt);
|
|
55
31
|
return verifyEmailResponse;
|
|
56
32
|
}), [
|
|
57
33
|
emailVerificationContextVerificationUUID,
|
|
58
34
|
environmentId,
|
|
59
|
-
isTurnkeyProviderEnabled,
|
|
60
35
|
jwtToken,
|
|
61
|
-
primaryWallet,
|
|
62
|
-
(_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.automaticEmbeddedWalletCreation,
|
|
63
36
|
updateUserProfileByJWT,
|
|
64
37
|
]);
|
|
65
38
|
return { verifyEmail };
|
|
@@ -4,31 +4,14 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
4
4
|
import { verifyEmail } from '../../../../data/api.js';
|
|
5
5
|
import { useUpdateUserProfileByJWTCallback } from '../../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
|
|
6
6
|
import { useEmailVerificationContext } from '../../../../context/EmailVerificationContext/EmailVerificationContext.js';
|
|
7
|
-
import '@dynamic-labs/sdk-api';
|
|
8
|
-
import '../../../../shared/logger.js';
|
|
9
|
-
import '@dynamic-labs/iconic';
|
|
10
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
11
|
-
import 'react/jsx-runtime';
|
|
12
|
-
import '../../../../context/ViewContext/ViewContext.js';
|
|
13
|
-
import '@dynamic-labs/wallet-book';
|
|
14
|
-
import '../../../constants/colors.js';
|
|
15
|
-
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
16
|
-
import 'viem';
|
|
17
|
-
import '@dynamic-labs/utils';
|
|
18
|
-
import '../../../../shared/consts/index.js';
|
|
19
|
-
import '@dynamic-labs/multi-wallet';
|
|
20
|
-
import { isTurnkeyEnabled } from '../../../functions/isTurnkeyEnabled/isTurnkeyEnabled.js';
|
|
21
7
|
|
|
22
8
|
// Hook exposed to the public as a scoped function in useUserUpdateRequest result
|
|
23
9
|
const useEmailVerificationRequest = () => {
|
|
24
|
-
|
|
25
|
-
const { onboardingOnlyJwt, authToken, environmentId, projectSettings, primaryWallet, } = useInternalDynamicContext();
|
|
10
|
+
const { onboardingOnlyJwt, authToken, environmentId } = useInternalDynamicContext();
|
|
26
11
|
const jwtToken = onboardingOnlyJwt || authToken;
|
|
27
|
-
const isTurnkeyProviderEnabled = isTurnkeyEnabled(projectSettings);
|
|
28
12
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
29
13
|
const { verificationUUID: emailVerificationContextVerificationUUID } = useEmailVerificationContext();
|
|
30
14
|
const verifyEmail$1 = useCallback((verificationToken, verificationUUID) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
var _b;
|
|
32
15
|
if (!jwtToken)
|
|
33
16
|
throw new Error('No JWT token provided');
|
|
34
17
|
// VerificationUUID is saved in the context in case the view changes
|
|
@@ -40,22 +23,12 @@ const useEmailVerificationRequest = () => {
|
|
|
40
23
|
verificationToken,
|
|
41
24
|
verificationUUID: String(verificationUUID || emailVerificationContextVerificationUUID),
|
|
42
25
|
}, jwtToken);
|
|
43
|
-
if (isTurnkeyProviderEnabled &&
|
|
44
|
-
((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _b === void 0 ? void 0 : _b.automaticEmbeddedWalletCreation) &&
|
|
45
|
-
!primaryWallet) {
|
|
46
|
-
// Don't create the user right now
|
|
47
|
-
// It will be done after the wallet creation
|
|
48
|
-
return verifyEmailResponse;
|
|
49
|
-
}
|
|
50
26
|
yield updateUserProfileByJWT(verifyEmailResponse.jwt);
|
|
51
27
|
return verifyEmailResponse;
|
|
52
28
|
}), [
|
|
53
29
|
emailVerificationContextVerificationUUID,
|
|
54
30
|
environmentId,
|
|
55
|
-
isTurnkeyProviderEnabled,
|
|
56
31
|
jwtToken,
|
|
57
|
-
primaryWallet,
|
|
58
|
-
(_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.automaticEmbeddedWalletCreation,
|
|
59
32
|
updateUserProfileByJWT,
|
|
60
33
|
]);
|
|
61
34
|
return { verifyEmail: verifyEmail$1 };
|
|
@@ -64,7 +64,8 @@ const useAuthLayoutChecks = (walletConnector) => {
|
|
|
64
64
|
// Don't show empty footer during the login
|
|
65
65
|
((view === 'login-with-email-or-wallet' ||
|
|
66
66
|
view === 'login-with-email-or-wallet-full-wallet-list' ||
|
|
67
|
-
view === 'login-with-wallet-only'
|
|
67
|
+
view === 'login-with-wallet-only' ||
|
|
68
|
+
view === 'multi-wallet-wallet-list') &&
|
|
68
69
|
(termsOfServiceUrl ||
|
|
69
70
|
privacyPolicyUrl ||
|
|
70
71
|
customPrivacyPolicy ||
|
|
@@ -94,7 +95,7 @@ const useAuthLayoutChecks = (walletConnector) => {
|
|
|
94
95
|
view === 'passkey-intro' ||
|
|
95
96
|
(view === 'merge-user-accounts' && !user);
|
|
96
97
|
const showQrCodePreHeader = view === 'qr-code' && showQrCodeMessage && !showQrCodeImage;
|
|
97
|
-
const showDefaultFooter = !showDynamicFooter && !showToSFooter;
|
|
98
|
+
const showDefaultFooter = !showConnectedWalletProgress && !showDynamicFooter && !showToSFooter;
|
|
98
99
|
return {
|
|
99
100
|
displayBorderBelowHeader,
|
|
100
101
|
isWalletListTypeView,
|
|
@@ -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,
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
9
|
var UserWalletsContext = require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
9
10
|
var api = require('../../../data/api.cjs');
|
|
10
11
|
require('@dynamic-labs/sdk-api');
|
|
@@ -18,7 +19,6 @@ require('../../constants/colors.cjs');
|
|
|
18
19
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
20
|
require('viem');
|
|
20
21
|
var useLocalStorage = require('../../../shared/utils/hooks/useLocalStorage/useLocalStorage.cjs');
|
|
21
|
-
require('@dynamic-labs/utils');
|
|
22
22
|
require('../../../shared/consts/index.cjs');
|
|
23
23
|
require('@dynamic-labs/multi-wallet');
|
|
24
24
|
var shouldManuallyReconnectOnRefresh = require('../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.cjs');
|
|
@@ -166,9 +166,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
166
166
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
167
167
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
168
168
|
if (!walletAddress) {
|
|
169
|
-
|
|
170
|
-
error.code = 'missing-public-address';
|
|
171
|
-
throw error;
|
|
169
|
+
throw new utils.MissingPublicAddressError();
|
|
172
170
|
}
|
|
173
171
|
if (onBeforeConnectSuccessConfirmation && shouldCallCallback) {
|
|
174
172
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
2
|
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { getWalletConnectorByKey, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { MissingPublicAddressError } from '@dynamic-labs/utils';
|
|
4
5
|
import { useInternalUserWallets } from '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
5
6
|
import { createVisit } from '../../../data/api.js';
|
|
6
7
|
import '@dynamic-labs/sdk-api';
|
|
@@ -14,7 +15,6 @@ import '../../constants/colors.js';
|
|
|
14
15
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
16
|
import 'viem';
|
|
16
17
|
import { useLocalStorage } from '../../../shared/utils/hooks/useLocalStorage/useLocalStorage.js';
|
|
17
|
-
import '@dynamic-labs/utils';
|
|
18
18
|
import '../../../shared/consts/index.js';
|
|
19
19
|
import '@dynamic-labs/multi-wallet';
|
|
20
20
|
import { shouldManuallyReconnectOnRefresh } from '../../functions/shouldManuallyReconnectOnRefresh/shouldManuallyReconnectOnRefresh.js';
|
|
@@ -162,9 +162,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
162
162
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
163
163
|
const walletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
164
164
|
if (!walletAddress) {
|
|
165
|
-
|
|
166
|
-
error.code = 'missing-public-address';
|
|
167
|
-
throw error;
|
|
165
|
+
throw new MissingPublicAddressError();
|
|
168
166
|
}
|
|
169
167
|
if (onBeforeConnectSuccessConfirmation && shouldCallCallback) {
|
|
170
168
|
const shouldProceedWithConnection = yield onBeforeConnectSuccessConfirmation({
|
|
@@ -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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
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
|
|
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((
|
|
108
|
-
setVerificationUUID((
|
|
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
|
|
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
|
|
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((
|
|
104
|
-
setVerificationUUID((
|
|
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.
|
|
@@ -38,7 +38,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
38
38
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
39
39
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
40
40
|
const { setErrorMessage, setError } = ErrorContext.useErrorContext();
|
|
41
|
-
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
41
|
+
const { setUser, multiWalletWidgetState, debugError, multiWallet: multiWalletEnabled, appName, primaryWalletId, setCallback, setShowAuthFlow, setPrimaryWalletId, siweStatement, connectedWallets, authMode, setOnboardingOnlyJwt, authToken, setAuthMode, removeConnectedWalletsInfo, setIsVerificationInProgress, eventsCallbacks, primaryWallet, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
42
42
|
// If the user is not already logged it means that we only need to verify
|
|
43
43
|
// We need this boolean for the part of the logic where we already persisted a new authToken,
|
|
44
44
|
// and need to distinguish between logic for verify or linking.
|
|
@@ -80,7 +80,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
80
80
|
if (newSelectedCredentialWallet) {
|
|
81
81
|
const currentPrimaryWallet = user.verifiedCredentials.find((a) => a.id === primaryWalletId);
|
|
82
82
|
if (verifyOnly ||
|
|
83
|
-
|
|
83
|
+
!primaryWallet ||
|
|
84
84
|
(multiWalletWidgetState === 'awaiting_signature' &&
|
|
85
85
|
newSelectedCredentialWallet.walletName ===
|
|
86
86
|
(currentPrimaryWallet === null || currentPrimaryWallet === void 0 ? void 0 : currentPrimaryWallet.walletName)) ||
|