@dynamic-labs/sdk-react-core 2.1.0-alpha.14 → 2.1.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.cjs +1 -1
- package/src/index.js +1 -1
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createEmailHandler.js +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/createSmsHandler.js +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.cjs +4 -0
- package/src/lib/context/ConnectWithOtpContext/utils/findEmailProvider.js +4 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +8 -4
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +9 -5
- package/src/lib/context/FundingContext/FundingContext.cjs +6 -6
- package/src/lib/context/FundingContext/FundingContext.js +6 -6
- package/src/lib/context/PasskeyContext/PasskeyContext.cjs +0 -1
- package/src/lib/context/PasskeyContext/PasskeyContext.js +0 -1
- package/src/lib/data/api/api.cjs +25 -3
- package/src/lib/data/api/api.d.ts +1 -1
- package/src/lib/data/api/api.js +25 -3
- package/src/lib/data/api/chains/balances.cjs +2 -2
- package/src/lib/data/api/chains/balances.d.ts +1 -2
- package/src/lib/data/api/chains/balances.js +2 -2
- package/src/lib/data/api/email/email.cjs +2 -2
- package/src/lib/data/api/email/email.d.ts +1 -1
- package/src/lib/data/api/email/email.js +2 -2
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +23 -23
- package/src/lib/data/api/embeddedWallets/embeddedWallets.d.ts +11 -12
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +23 -23
- package/src/lib/data/api/embeddedWallets/types.d.ts +0 -6
- package/src/lib/data/api/mfa/mfa.cjs +18 -18
- package/src/lib/data/api/mfa/mfa.d.ts +9 -18
- package/src/lib/data/api/mfa/mfa.js +18 -18
- package/src/lib/data/api/oauth/oauth.cjs +4 -4
- package/src/lib/data/api/oauth/oauth.d.ts +3 -3
- package/src/lib/data/api/oauth/oauth.js +4 -4
- package/src/lib/data/api/session/session.cjs +2 -2
- package/src/lib/data/api/session/session.d.ts +1 -1
- package/src/lib/data/api/session/session.js +2 -2
- package/src/lib/data/api/sms/sms.cjs +2 -2
- package/src/lib/data/api/sms/sms.d.ts +1 -1
- package/src/lib/data/api/sms/sms.js +2 -2
- package/src/lib/data/api/user/user.cjs +8 -10
- package/src/lib/data/api/user/user.d.ts +4 -4
- package/src/lib/data/api/user/user.js +9 -11
- package/src/lib/data/api/wallets/wallets.cjs +8 -8
- package/src/lib/data/api/wallets/wallets.d.ts +4 -4
- package/src/lib/data/api/wallets/wallets.js +8 -8
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.cjs +8 -4
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.d.ts +1 -2
- package/src/lib/utils/functions/getCoinbaseMPCConnectorFetchers/getCoinbaseMPCConnectorFetchers.js +8 -4
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.cjs +31 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.d.ts +1 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.js +27 -0
- package/src/lib/utils/functions/getOnboardingAuthToken/index.d.ts +1 -0
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +7 -3
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +7 -3
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +1 -1
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.cjs +2 -2
- package/src/lib/utils/hooks/multiWallet/useVerifyOnAwaitingSignature/useVerifyOnAwaitingSignature.js +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +2 -2
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +1 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +3 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +3 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +2 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +2 -0
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +4 -4
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +4 -4
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.cjs +4 -0
- package/src/lib/utils/hooks/useFetchNonce/useFetchNonce.js +4 -0
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +4 -4
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +4 -4
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +1 -3
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +1 -3
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -8
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -8
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +1 -1
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +1 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +1 -1
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +1 -1
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +2 -2
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +2 -2
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +1 -1
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +1 -1
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -7
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +4 -7
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +11 -14
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +11 -14
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.cjs +0 -1
- package/src/lib/utils/hooks/useTokenBalances/useTokenBalances.js +0 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.cjs +1 -1
- package/src/lib/utils/hooks/useTransferWallet/useTransferWallet.js +1 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +6 -1
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +6 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +3 -3
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +3 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +1 -1
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.cjs +4 -4
- package/src/lib/utils/hooks/useWalletItemActions/useWalletItemActions.js +4 -4
- package/src/lib/views/EmailUpdate/EmailUpdate.cjs +2 -5
- package/src/lib/views/EmailUpdate/EmailUpdate.js +2 -5
- package/src/lib/views/EmailVerification/EmailVerification.cjs +3 -1
- package/src/lib/views/EmailVerification/EmailVerification.js +3 -1
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +5 -2
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +5 -2
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +4 -2
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +4 -2
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.cjs +0 -2
- package/src/lib/views/Passkey/RenamePasskeyView/RenamePasskeyView.js +0 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +3 -3
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +3 -3
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +4 -9
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +4 -9
|
@@ -34,7 +34,7 @@ const usePrimaryWalletId = ({ minAuthToken, environmentId, setUser, }) => {
|
|
|
34
34
|
const setPrimaryWalletId = React.useCallback((walletId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
setPrimaryWalletIdState(walletId);
|
|
36
36
|
if (minAuthToken) {
|
|
37
|
-
const response = yield wallets.storeSelectedWallet({ environmentId, walletId }
|
|
37
|
+
const response = yield wallets.storeSelectedWallet({ environmentId, walletId });
|
|
38
38
|
// only update userProfile, authToken, and minAuthToken when response is valid from storeSelectedWallet
|
|
39
39
|
if (response) {
|
|
40
40
|
setUser(updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(response.jwt, response.minifiedJwt));
|
|
@@ -30,7 +30,7 @@ const usePrimaryWalletId = ({ minAuthToken, environmentId, setUser, }) => {
|
|
|
30
30
|
const setPrimaryWalletId = useCallback((walletId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
setPrimaryWalletIdState(walletId);
|
|
32
32
|
if (minAuthToken) {
|
|
33
|
-
const response = yield storeSelectedWallet({ environmentId, walletId }
|
|
33
|
+
const response = yield storeSelectedWallet({ environmentId, walletId });
|
|
34
34
|
// only update userProfile, authToken, and minAuthToken when response is valid from storeSelectedWallet
|
|
35
35
|
if (response) {
|
|
36
36
|
setUser(updateJWTAndCreateUserProfile(response.jwt, response.minifiedJwt));
|
|
@@ -19,13 +19,13 @@ require('@dynamic-labs/utils');
|
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
require('../../../../../_virtual/_tslib.cjs');
|
|
21
21
|
require('../../../config/ApiEndpoint.cjs');
|
|
22
|
-
var settings = require('../../../data/api/settings/settings.cjs');
|
|
23
|
-
require('../../../locale/locale.cjs');
|
|
24
22
|
require('@dynamic-labs/multi-wallet');
|
|
25
23
|
require('react-international-phone');
|
|
26
24
|
require('viem');
|
|
27
25
|
require('viem/chains');
|
|
28
26
|
var serializeWalletConnectors = require('../../functions/serializeWalletConnectors/serializeWalletConnectors.cjs');
|
|
27
|
+
var settings = require('../../../data/api/settings/settings.cjs');
|
|
28
|
+
require('../../../locale/locale.cjs');
|
|
29
29
|
|
|
30
30
|
const useSendDynamicProps = ({ settings: settings$1, environmentId, }) => {
|
|
31
31
|
useEffectOnce.useEffectOnce(() => {
|
|
@@ -15,13 +15,13 @@ import '@dynamic-labs/utils';
|
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import '../../../../../_virtual/_tslib.js';
|
|
17
17
|
import '../../../config/ApiEndpoint.js';
|
|
18
|
-
import { sendDynamicProps } from '../../../data/api/settings/settings.js';
|
|
19
|
-
import '../../../locale/locale.js';
|
|
20
18
|
import '@dynamic-labs/multi-wallet';
|
|
21
19
|
import 'react-international-phone';
|
|
22
20
|
import 'viem';
|
|
23
21
|
import 'viem/chains';
|
|
24
22
|
import { serializeWalletConnectors } from '../../functions/serializeWalletConnectors/serializeWalletConnectors.js';
|
|
23
|
+
import { sendDynamicProps } from '../../../data/api/settings/settings.js';
|
|
24
|
+
import '../../../locale/locale.js';
|
|
25
25
|
|
|
26
26
|
const useSendDynamicProps = ({ settings, environmentId, }) => {
|
|
27
27
|
useEffectOnce(() => {
|
|
@@ -26,7 +26,7 @@ var getCoinbaseMPCConnectorFetchers = require('../../functions/getCoinbaseMPCCon
|
|
|
26
26
|
const useSetWalletConnectorFetchers = (authToken, walletOptions, environmentId) => {
|
|
27
27
|
if (!authToken || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
28
28
|
return;
|
|
29
|
-
const { fetchAuthToken, fetchBackupCode, fetchPasscode } = getCoinbaseMPCConnectorFetchers.getCoinbaseMPCConnectorFetchers({
|
|
29
|
+
const { fetchAuthToken, fetchBackupCode, fetchPasscode } = getCoinbaseMPCConnectorFetchers.getCoinbaseMPCConnectorFetchers({ environmentId });
|
|
30
30
|
walletOptions.forEach((walletOption) => {
|
|
31
31
|
if (walletConnectorCore.isCoinbaseMpcWalletConnector(walletOption.walletConnector)) {
|
|
32
32
|
walletOption.walletConnector.setAuthTokenFetcher(fetchAuthToken);
|
|
@@ -22,7 +22,7 @@ import { getCoinbaseMPCConnectorFetchers } from '../../functions/getCoinbaseMPCC
|
|
|
22
22
|
const useSetWalletConnectorFetchers = (authToken, walletOptions, environmentId) => {
|
|
23
23
|
if (!authToken || !(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
24
24
|
return;
|
|
25
|
-
const { fetchAuthToken, fetchBackupCode, fetchPasscode } = getCoinbaseMPCConnectorFetchers({
|
|
25
|
+
const { fetchAuthToken, fetchBackupCode, fetchPasscode } = getCoinbaseMPCConnectorFetchers({ environmentId });
|
|
26
26
|
walletOptions.forEach((walletOption) => {
|
|
27
27
|
if (isCoinbaseMpcWalletConnector(walletOption.walletConnector)) {
|
|
28
28
|
walletOption.walletConnector.setAuthTokenFetcher(fetchAuthToken);
|
|
@@ -24,7 +24,6 @@ require('../../../events/dynamicEvents.cjs');
|
|
|
24
24
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
25
25
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
26
26
|
require('@dynamic-labs/multi-wallet');
|
|
27
|
-
var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
28
27
|
require('react-international-phone');
|
|
29
28
|
var index = require('../../functions/getEnabledOAuthProviders/index.cjs');
|
|
30
29
|
var isSocialKycEnabled = require('../../functions/isSocialKycEnabled/isSocialKycEnabled.cjs');
|
|
@@ -85,8 +84,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
85
84
|
const useSocialAccounts = ({ sessionTimeout } = {
|
|
86
85
|
sessionTimeout: 10000,
|
|
87
86
|
}) => {
|
|
88
|
-
|
|
89
|
-
const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
|
|
87
|
+
const { environmentId, user, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
90
88
|
const { setView } = ViewContext.useViewContext();
|
|
91
89
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
92
90
|
const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth.useSocialAuth({
|
|
@@ -94,7 +92,6 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
94
92
|
onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
|
|
95
93
|
sessionTimeout,
|
|
96
94
|
});
|
|
97
|
-
const userJwt = (_a = getMinAuthToken.getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
98
95
|
const oauthProviders = index.getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
99
96
|
const verifiedOAuthCredentialsMap = React.useMemo(() => {
|
|
100
97
|
var _a, _b;
|
|
@@ -128,7 +125,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
128
125
|
connectSocialAccount({ provider, validator: checkValidOAuthLinking });
|
|
129
126
|
});
|
|
130
127
|
const unlinkSocialAccount = (provider) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
131
|
-
var
|
|
128
|
+
var _a;
|
|
132
129
|
setError(undefined);
|
|
133
130
|
setIsProcessing(true);
|
|
134
131
|
if (!checkValidProvider(provider)) {
|
|
@@ -144,8 +141,8 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
144
141
|
const response = yield oauth.unlinkOAuth({
|
|
145
142
|
environmentId,
|
|
146
143
|
primaryWalletId,
|
|
147
|
-
verifiedCrentialId: (
|
|
148
|
-
}
|
|
144
|
+
verifiedCrentialId: (_a = verifiedCredential.id) !== null && _a !== void 0 ? _a : '',
|
|
145
|
+
});
|
|
149
146
|
if (!response) {
|
|
150
147
|
handleError(types.SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
151
148
|
return;
|
|
@@ -20,7 +20,6 @@ import '../../../events/dynamicEvents.js';
|
|
|
20
20
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
21
21
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
22
22
|
import '@dynamic-labs/multi-wallet';
|
|
23
|
-
import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
|
|
24
23
|
import 'react-international-phone';
|
|
25
24
|
import { getEnabledOAuthProviders } from '../../functions/getEnabledOAuthProviders/index.js';
|
|
26
25
|
import { isSocialKycEnabled } from '../../functions/isSocialKycEnabled/isSocialKycEnabled.js';
|
|
@@ -81,8 +80,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
81
80
|
const useSocialAccounts = ({ sessionTimeout } = {
|
|
82
81
|
sessionTimeout: 10000,
|
|
83
82
|
}) => {
|
|
84
|
-
|
|
85
|
-
const { environmentId, user, projectSettings, onboardingOnlyJwt } = useInternalDynamicContext();
|
|
83
|
+
const { environmentId, user, projectSettings } = useInternalDynamicContext();
|
|
86
84
|
const { setView } = useViewContext();
|
|
87
85
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
88
86
|
const { handleError, setError, setIsProcessing, checkValidProvider, error, isProcessing, connectSocialAccount, } = useSocialAuth({
|
|
@@ -90,7 +88,6 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
90
88
|
onFarcasterUrl: (url) => setView('farcaster-connect-view', { url }),
|
|
91
89
|
sessionTimeout,
|
|
92
90
|
});
|
|
93
|
-
const userJwt = (_a = getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
94
91
|
const oauthProviders = getEnabledOAuthProviders(projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers);
|
|
95
92
|
const verifiedOAuthCredentialsMap = useMemo(() => {
|
|
96
93
|
var _a, _b;
|
|
@@ -124,7 +121,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
124
121
|
connectSocialAccount({ provider, validator: checkValidOAuthLinking });
|
|
125
122
|
});
|
|
126
123
|
const unlinkSocialAccount = (provider) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
-
var
|
|
124
|
+
var _a;
|
|
128
125
|
setError(undefined);
|
|
129
126
|
setIsProcessing(true);
|
|
130
127
|
if (!checkValidProvider(provider)) {
|
|
@@ -140,8 +137,8 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
140
137
|
const response = yield unlinkOAuth({
|
|
141
138
|
environmentId,
|
|
142
139
|
primaryWalletId,
|
|
143
|
-
verifiedCrentialId: (
|
|
144
|
-
}
|
|
140
|
+
verifiedCrentialId: (_a = verifiedCredential.id) !== null && _a !== void 0 ? _a : '',
|
|
141
|
+
});
|
|
145
142
|
if (!response) {
|
|
146
143
|
handleError(SocialOAuthErrorCode.UNLINK_ERROR, `Failed to unlink social account: ${provider} | ${verifiedCredential.id}`);
|
|
147
144
|
return;
|
|
@@ -25,7 +25,6 @@ var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
|
25
25
|
var digestSHA256 = require('../../functions/digestSHA256/digestSHA256.cjs');
|
|
26
26
|
var encodeBase64URL = require('../../functions/encodeBase64URL/encodeBase64URL.cjs');
|
|
27
27
|
require('@dynamic-labs/multi-wallet');
|
|
28
|
-
var getMinAuthToken = require('../../functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
29
28
|
require('react-international-phone');
|
|
30
29
|
var getOauthLoginUrl = require('../../functions/getOauthLoginUrl/getOauthLoginUrl.cjs');
|
|
31
30
|
var getProviderByType = require('../../functions/getProviderByType/getProviderByType.cjs');
|
|
@@ -103,8 +102,7 @@ const providersRequiringPkce = ['twitter', 'github'];
|
|
|
103
102
|
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
104
103
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
105
104
|
const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }) => {
|
|
106
|
-
|
|
107
|
-
const { environmentId, onboardingOnlyJwt, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
105
|
+
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
108
106
|
const { setErrorMessage, setError: setContextError } = ErrorContext.useErrorContext();
|
|
109
107
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
|
|
110
108
|
const { initAuth } = useUserAuth.useUserAuth({
|
|
@@ -115,7 +113,6 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
115
113
|
const providersWaitingOauthMessage = React.useRef({});
|
|
116
114
|
const authWindowInterval = React.useRef();
|
|
117
115
|
const shouldPool = React.useRef(false);
|
|
118
|
-
const userJwt = (_a = getMinAuthToken.getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
119
116
|
const clearError = () => {
|
|
120
117
|
setError(undefined);
|
|
121
118
|
setContextError(undefined);
|
|
@@ -183,8 +180,8 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
183
180
|
verifyFunction: () => apiCall(),
|
|
184
181
|
});
|
|
185
182
|
});
|
|
186
|
-
const connectSocialAccount = (
|
|
187
|
-
var
|
|
183
|
+
const connectSocialAccount = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
184
|
+
var _b, _c;
|
|
188
185
|
clearInterval(authWindowInterval.current);
|
|
189
186
|
clearError();
|
|
190
187
|
setIsProcessing(true);
|
|
@@ -207,9 +204,9 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
207
204
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: false });
|
|
208
205
|
};
|
|
209
206
|
const handleAuthWindowMessage = (event) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
210
|
-
var
|
|
207
|
+
var _d, _e;
|
|
211
208
|
const message = event.data;
|
|
212
|
-
const apiProvider = getProviderByType.getProviderByType((
|
|
209
|
+
const apiProvider = getProviderByType.getProviderByType((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
|
|
213
210
|
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
214
211
|
return;
|
|
215
212
|
}
|
|
@@ -247,7 +244,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
247
244
|
return;
|
|
248
245
|
}
|
|
249
246
|
setIsProcessing(true);
|
|
250
|
-
if (!((
|
|
247
|
+
if (!((_e = providersWaitingOauthMessage.current) === null || _e === void 0 ? void 0 : _e[provider])) {
|
|
251
248
|
handleError(types.SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
252
249
|
return;
|
|
253
250
|
}
|
|
@@ -283,17 +280,17 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
283
280
|
code,
|
|
284
281
|
codeVerifier: verifier,
|
|
285
282
|
state,
|
|
286
|
-
}
|
|
283
|
+
});
|
|
287
284
|
yield linkAccount(provider, apiCall);
|
|
288
285
|
}
|
|
289
286
|
setIsProcessing(false);
|
|
290
287
|
});
|
|
291
|
-
const loginUrl = getOauthLoginUrl.getOauthLoginUrl((
|
|
288
|
+
const loginUrl = getOauthLoginUrl.getOauthLoginUrl((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _b !== void 0 ? _b : [], provider);
|
|
292
289
|
if (!loginUrl) {
|
|
293
290
|
handleError(types.SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
294
291
|
return;
|
|
295
292
|
}
|
|
296
|
-
if (!((
|
|
293
|
+
if (!((_c = providersWaitingOauthMessage.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
297
294
|
window.addEventListener('message', handleAuthWindowMessage);
|
|
298
295
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: true });
|
|
299
296
|
}
|
|
@@ -341,10 +338,10 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
341
338
|
authWindowTimeout = authWindowTimeout * 3;
|
|
342
339
|
}
|
|
343
340
|
authWindowInterval.current = setInterval(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
344
|
-
var
|
|
341
|
+
var _f;
|
|
345
342
|
shouldPool.current = false;
|
|
346
343
|
// clear all states/listeners, assuming user closed the window before completing oauth
|
|
347
|
-
if ((
|
|
344
|
+
if ((_f = providersWaitingOauthMessage.current) === null || _f === void 0 ? void 0 : _f[provider]) {
|
|
348
345
|
clearListeners();
|
|
349
346
|
handleError(types.SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
350
347
|
}
|
|
@@ -21,7 +21,6 @@ import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
|
21
21
|
import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
|
|
22
22
|
import { encodeBase64URL } from '../../functions/encodeBase64URL/encodeBase64URL.js';
|
|
23
23
|
import '@dynamic-labs/multi-wallet';
|
|
24
|
-
import { getMinAuthToken } from '../../functions/getMinAuthToken/getMinAuthToken.js';
|
|
25
24
|
import 'react-international-phone';
|
|
26
25
|
import { getOauthLoginUrl } from '../../functions/getOauthLoginUrl/getOauthLoginUrl.js';
|
|
27
26
|
import { getProviderByType } from '../../functions/getProviderByType/getProviderByType.js';
|
|
@@ -99,8 +98,7 @@ const providersRequiringPkce = ['twitter', 'github'];
|
|
|
99
98
|
const providersWithoutWindowOpenerRefence = ['twitter'];
|
|
100
99
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
101
100
|
const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcasterUrl, }) => {
|
|
102
|
-
|
|
103
|
-
const { environmentId, onboardingOnlyJwt, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
|
|
101
|
+
const { environmentId, setShowAuthFlow, projectSettings, consumeNonce, redirectUrl, } = useInternalDynamicContext();
|
|
104
102
|
const { setErrorMessage, setError: setContextError } = useErrorContext();
|
|
105
103
|
const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
|
|
106
104
|
const { initAuth } = useUserAuth({
|
|
@@ -111,7 +109,6 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
111
109
|
const providersWaitingOauthMessage = useRef({});
|
|
112
110
|
const authWindowInterval = useRef();
|
|
113
111
|
const shouldPool = useRef(false);
|
|
114
|
-
const userJwt = (_a = getMinAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
115
112
|
const clearError = () => {
|
|
116
113
|
setError(undefined);
|
|
117
114
|
setContextError(undefined);
|
|
@@ -179,8 +176,8 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
179
176
|
verifyFunction: () => apiCall(),
|
|
180
177
|
});
|
|
181
178
|
});
|
|
182
|
-
const connectSocialAccount = (
|
|
183
|
-
var
|
|
179
|
+
const connectSocialAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ provider, validator, captchaToken, }) {
|
|
180
|
+
var _b, _c;
|
|
184
181
|
clearInterval(authWindowInterval.current);
|
|
185
182
|
clearError();
|
|
186
183
|
setIsProcessing(true);
|
|
@@ -203,9 +200,9 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
203
200
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: false });
|
|
204
201
|
};
|
|
205
202
|
const handleAuthWindowMessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
206
|
-
var
|
|
203
|
+
var _d, _e;
|
|
207
204
|
const message = event.data;
|
|
208
|
-
const apiProvider = getProviderByType((
|
|
205
|
+
const apiProvider = getProviderByType((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _d !== void 0 ? _d : [], provider);
|
|
209
206
|
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
210
207
|
return;
|
|
211
208
|
}
|
|
@@ -243,7 +240,7 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
243
240
|
return;
|
|
244
241
|
}
|
|
245
242
|
setIsProcessing(true);
|
|
246
|
-
if (!((
|
|
243
|
+
if (!((_e = providersWaitingOauthMessage.current) === null || _e === void 0 ? void 0 : _e[provider])) {
|
|
247
244
|
handleError(SocialOAuthErrorCode.SESSION_TIMEOUT, `Connecting ${provider} account session timeout.`);
|
|
248
245
|
return;
|
|
249
246
|
}
|
|
@@ -279,17 +276,17 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
279
276
|
code,
|
|
280
277
|
codeVerifier: verifier,
|
|
281
278
|
state,
|
|
282
|
-
}
|
|
279
|
+
});
|
|
283
280
|
yield linkAccount(provider, apiCall);
|
|
284
281
|
}
|
|
285
282
|
setIsProcessing(false);
|
|
286
283
|
});
|
|
287
|
-
const loginUrl = getOauthLoginUrl((
|
|
284
|
+
const loginUrl = getOauthLoginUrl((_b = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _b !== void 0 ? _b : [], provider);
|
|
288
285
|
if (!loginUrl) {
|
|
289
286
|
handleError(SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`);
|
|
290
287
|
return;
|
|
291
288
|
}
|
|
292
|
-
if (!((
|
|
289
|
+
if (!((_c = providersWaitingOauthMessage.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
293
290
|
window.addEventListener('message', handleAuthWindowMessage);
|
|
294
291
|
providersWaitingOauthMessage.current = Object.assign(Object.assign({}, providersWaitingOauthMessage.current), { [provider]: true });
|
|
295
292
|
}
|
|
@@ -337,10 +334,10 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, onFarcast
|
|
|
337
334
|
authWindowTimeout = authWindowTimeout * 3;
|
|
338
335
|
}
|
|
339
336
|
authWindowInterval.current = setInterval(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
340
|
-
var
|
|
337
|
+
var _f;
|
|
341
338
|
shouldPool.current = false;
|
|
342
339
|
// clear all states/listeners, assuming user closed the window before completing oauth
|
|
343
|
-
if ((
|
|
340
|
+
if ((_f = providersWaitingOauthMessage.current) === null || _f === void 0 ? void 0 : _f[provider]) {
|
|
344
341
|
clearListeners();
|
|
345
342
|
handleError(SocialOAuthErrorCode.OAUTH_WINDOW_TIMEOUT, `Connecting ${provider} account window timeout.`);
|
|
346
343
|
}
|
|
@@ -112,7 +112,7 @@ const useTransferWallet = () => {
|
|
|
112
112
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
113
113
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider.getWalletProvider(walletConnector) });
|
|
114
114
|
const verifyArgs = yield getVerifyArgs.getVerifyArgs(args);
|
|
115
|
-
const response = yield wallets.transferWallet(environmentId, verifyArgs
|
|
115
|
+
const response = yield wallets.transferWallet(environmentId, verifyArgs);
|
|
116
116
|
const userProfile = updateJWTAndCreateUserProfile.updateJWTAndCreateUserProfile(response === null || response === void 0 ? void 0 : response.jwt, response === null || response === void 0 ? void 0 : response.minifiedJwt);
|
|
117
117
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
118
118
|
setUser(userProfile);
|
|
@@ -108,7 +108,7 @@ const useTransferWallet = () => {
|
|
|
108
108
|
// and if props doesn't have nonce, that means it has messageToSignOverride and signedMessageOverride
|
|
109
109
|
nonce: '', siweStatement: props.overrideSiweStatement, walletProvider: getWalletProvider(walletConnector) });
|
|
110
110
|
const verifyArgs = yield getVerifyArgs(args);
|
|
111
|
-
const response = yield transferWallet(environmentId, verifyArgs
|
|
111
|
+
const response = yield transferWallet(environmentId, verifyArgs);
|
|
112
112
|
const userProfile = updateJWTAndCreateUserProfile(response === null || response === void 0 ? void 0 : response.jwt, response === null || response === void 0 ? void 0 : response.minifiedJwt);
|
|
113
113
|
updatePrimaryWalletId(walletConnector, userProfile);
|
|
114
114
|
setUser(userProfile);
|
|
@@ -15,9 +15,10 @@ require('@dynamic-labs/wallet-connector-core');
|
|
|
15
15
|
require('react/jsx-runtime');
|
|
16
16
|
var ViewContext = require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
17
|
require('@dynamic-labs/wallet-book');
|
|
18
|
+
var localStorage$1 = require('../../constants/localStorage.cjs');
|
|
18
19
|
require('../../constants/colors.cjs');
|
|
19
20
|
require('../../constants/values.cjs');
|
|
20
|
-
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
|
+
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
21
22
|
require('../../../shared/consts/index.cjs');
|
|
22
23
|
require('../../../events/dynamicEvents.cjs');
|
|
23
24
|
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
@@ -105,6 +106,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
105
106
|
}
|
|
106
107
|
setMultiWalletWidgetState('idle');
|
|
107
108
|
setOnboardingOnlyJwt(undefined);
|
|
109
|
+
localStorage.LocalStorage.removeFromLS(localStorage$1.AUTH_ONBOARDING_TOKEN);
|
|
108
110
|
yield handleVerifiedUserWithJWT(jwt);
|
|
109
111
|
if (showSuccessMessage) {
|
|
110
112
|
// this timeout is set to make sure that the user will see success message
|
|
@@ -133,6 +135,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
133
135
|
});
|
|
134
136
|
const handleOnboarding = (jwt, showSuccessMessage, onSettled) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
135
137
|
setOnboardingOnlyJwt(jwt);
|
|
138
|
+
localStorage.LocalStorage.setToLS(localStorage$1.AUTH_ONBOARDING_TOKEN, jwt, true);
|
|
136
139
|
if (showSuccessMessage) {
|
|
137
140
|
yield sleepToShowSuccessMessage();
|
|
138
141
|
}
|
|
@@ -204,6 +207,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
204
207
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
205
208
|
onValidUpdatedJwt === null || onValidUpdatedJwt === void 0 ? void 0 : onValidUpdatedJwt();
|
|
206
209
|
setOnboardingOnlyJwt(updateUserProfileResponse.jwt);
|
|
210
|
+
localStorage.LocalStorage.setToLS(localStorage$1.AUTH_ONBOARDING_TOKEN, updateUserProfileResponse.minifiedJwt, true);
|
|
207
211
|
if (isEmailVerificationRequired &&
|
|
208
212
|
missingFields.map((field) => field.name).toString() === 'email') {
|
|
209
213
|
setView('verify-email');
|
|
@@ -223,6 +227,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
223
227
|
if (onboardingOnlyJwt) {
|
|
224
228
|
yield handleVerifiedUserWithJWT(updateUserProfileResponse.jwt);
|
|
225
229
|
setOnboardingOnlyJwt(undefined);
|
|
230
|
+
localStorage.LocalStorage.removeFromLS(localStorage$1.AUTH_ONBOARDING_TOKEN);
|
|
226
231
|
setCallback('authSuccess');
|
|
227
232
|
}
|
|
228
233
|
if (completeSignInFlow) {
|
|
@@ -11,9 +11,10 @@ import '@dynamic-labs/wallet-connector-core';
|
|
|
11
11
|
import 'react/jsx-runtime';
|
|
12
12
|
import { useViewContext } from '../../../context/ViewContext/ViewContext.js';
|
|
13
13
|
import '@dynamic-labs/wallet-book';
|
|
14
|
+
import { AUTH_ONBOARDING_TOKEN } from '../../constants/localStorage.js';
|
|
14
15
|
import '../../constants/colors.js';
|
|
15
16
|
import '../../constants/values.js';
|
|
16
|
-
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
|
+
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
17
18
|
import '../../../shared/consts/index.js';
|
|
18
19
|
import '../../../events/dynamicEvents.js';
|
|
19
20
|
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
@@ -101,6 +102,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
101
102
|
}
|
|
102
103
|
setMultiWalletWidgetState('idle');
|
|
103
104
|
setOnboardingOnlyJwt(undefined);
|
|
105
|
+
LocalStorage.removeFromLS(AUTH_ONBOARDING_TOKEN);
|
|
104
106
|
yield handleVerifiedUserWithJWT(jwt);
|
|
105
107
|
if (showSuccessMessage) {
|
|
106
108
|
// this timeout is set to make sure that the user will see success message
|
|
@@ -129,6 +131,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
129
131
|
});
|
|
130
132
|
const handleOnboarding = (jwt, showSuccessMessage, onSettled) => __awaiter(void 0, void 0, void 0, function* () {
|
|
131
133
|
setOnboardingOnlyJwt(jwt);
|
|
134
|
+
LocalStorage.setToLS(AUTH_ONBOARDING_TOKEN, jwt, true);
|
|
132
135
|
if (showSuccessMessage) {
|
|
133
136
|
yield sleepToShowSuccessMessage();
|
|
134
137
|
}
|
|
@@ -200,6 +203,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
200
203
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
201
204
|
onValidUpdatedJwt === null || onValidUpdatedJwt === void 0 ? void 0 : onValidUpdatedJwt();
|
|
202
205
|
setOnboardingOnlyJwt(updateUserProfileResponse.jwt);
|
|
206
|
+
LocalStorage.setToLS(AUTH_ONBOARDING_TOKEN, updateUserProfileResponse.minifiedJwt, true);
|
|
203
207
|
if (isEmailVerificationRequired &&
|
|
204
208
|
missingFields.map((field) => field.name).toString() === 'email') {
|
|
205
209
|
setView('verify-email');
|
|
@@ -219,6 +223,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
219
223
|
if (onboardingOnlyJwt) {
|
|
220
224
|
yield handleVerifiedUserWithJWT(updateUserProfileResponse.jwt);
|
|
221
225
|
setOnboardingOnlyJwt(undefined);
|
|
226
|
+
LocalStorage.removeFromLS(AUTH_ONBOARDING_TOKEN);
|
|
222
227
|
setCallback('authSuccess');
|
|
223
228
|
}
|
|
224
229
|
if (completeSignInFlow) {
|
|
@@ -107,7 +107,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
107
107
|
const { setRetryData } = VerificationContext.useVerification();
|
|
108
108
|
const { selectedPhoneCountry } = FieldsStateContext.useFieldsState();
|
|
109
109
|
const updateUser = React.useCallback((userFields, options) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
-
var _a, _b
|
|
110
|
+
var _a, _b;
|
|
111
111
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
112
112
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
113
113
|
const { metadata } = userFields;
|
|
@@ -124,10 +124,10 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
124
124
|
iso2: selectedPhoneCountry.current.iso2,
|
|
125
125
|
phone: validatedUserFields.phoneNumber,
|
|
126
126
|
});
|
|
127
|
-
const updateUserProfileResponse = yield user.updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.
|
|
127
|
+
const updateUserProfileResponse = yield user.updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.userEnvironmentId) !== null && _a !== void 0 ? _a : environmentId, Object.assign(Object.assign({}, validatedUserFields), { metadata }));
|
|
128
128
|
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
129
129
|
const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
|
|
130
|
-
const missingFields = (
|
|
130
|
+
const missingFields = (_b = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _b !== void 0 ? _b : [];
|
|
131
131
|
const requiredVerificationDestination = useHandleVerificationRequired.isVerificationRequired(updateUserProfileResponse);
|
|
132
132
|
if (requiredVerificationDestination && handleVerificationRequired.current)
|
|
133
133
|
return handleVerificationRequired.current({
|
|
@@ -103,7 +103,7 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
103
103
|
const { setRetryData } = useVerification();
|
|
104
104
|
const { selectedPhoneCountry } = useFieldsState();
|
|
105
105
|
const updateUser = useCallback((userFields, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
var _a, _b
|
|
106
|
+
var _a, _b;
|
|
107
107
|
// `stripUnknown: true` will automatically strip out any values in the metadata object
|
|
108
108
|
// so we need to pull out the metadata object here and then re-add it after stripping unknown fields
|
|
109
109
|
const { metadata } = userFields;
|
|
@@ -120,10 +120,10 @@ const useUpdateUser = (validationSchemaStripUnknown) => {
|
|
|
120
120
|
iso2: selectedPhoneCountry.current.iso2,
|
|
121
121
|
phone: validatedUserFields.phoneNumber,
|
|
122
122
|
});
|
|
123
|
-
const updateUserProfileResponse = yield updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.
|
|
123
|
+
const updateUserProfileResponse = yield updateUserProfileFields((_a = options === null || options === void 0 ? void 0 : options.userEnvironmentId) !== null && _a !== void 0 ? _a : environmentId, Object.assign(Object.assign({}, validatedUserFields), { metadata }));
|
|
124
124
|
// check if decoded JWT still somehow has missing fields, we can't proceed if it does
|
|
125
125
|
const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
|
|
126
|
-
const missingFields = (
|
|
126
|
+
const missingFields = (_b = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _b !== void 0 ? _b : [];
|
|
127
127
|
const requiredVerificationDestination = isVerificationRequired(updateUserProfileResponse);
|
|
128
128
|
if (requiredVerificationDestination && handleVerificationRequired.current)
|
|
129
129
|
return handleVerificationRequired.current({
|
|
@@ -118,7 +118,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
118
118
|
oauth }));
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
|
-
verifyResponse = wallets.linkWallet(environmentId, verifyArgs
|
|
121
|
+
verifyResponse = wallets.linkWallet(environmentId, verifyArgs);
|
|
122
122
|
}
|
|
123
123
|
return { verifyArgs, verifyFunction: () => verifyResponse };
|
|
124
124
|
});
|
|
@@ -114,7 +114,7 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
114
114
|
oauth }));
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
verifyResponse = linkWallet(environmentId, verifyArgs
|
|
117
|
+
verifyResponse = linkWallet(environmentId, verifyArgs);
|
|
118
118
|
}
|
|
119
119
|
return { verifyArgs, verifyFunction: () => verifyResponse };
|
|
120
120
|
});
|
|
@@ -26,15 +26,15 @@ require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
|
26
26
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
27
27
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
28
28
|
require('../../../config/ApiEndpoint.cjs');
|
|
29
|
-
require('../../../locale/locale.cjs');
|
|
30
29
|
require('@dynamic-labs/multi-wallet');
|
|
31
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
32
|
-
var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs');
|
|
33
|
-
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
34
30
|
require('react-international-phone');
|
|
35
31
|
var requiresTwoStepAuthentication = require('../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.cjs');
|
|
36
32
|
require('viem');
|
|
37
33
|
require('viem/chains');
|
|
34
|
+
require('../../../locale/locale.cjs');
|
|
35
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
36
|
+
var useConnectAndSignSplitSteps = require('../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs');
|
|
37
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
38
38
|
require('react-dom');
|
|
39
39
|
require('../../../context/WalletContext/WalletContext.cjs');
|
|
40
40
|
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
@@ -22,15 +22,15 @@ import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
|
22
22
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
23
23
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
24
24
|
import '../../../config/ApiEndpoint.js';
|
|
25
|
-
import '../../../locale/locale.js';
|
|
26
25
|
import '@dynamic-labs/multi-wallet';
|
|
27
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
28
|
-
import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js';
|
|
29
|
-
import '../../../context/VerificationContext/VerificationContext.js';
|
|
30
26
|
import 'react-international-phone';
|
|
31
27
|
import { requiresTwoStepAuthentication } from '../../functions/requiresTwoStepAuthentication/requiresTwoStepAuthentication.js';
|
|
32
28
|
import 'viem';
|
|
33
29
|
import 'viem/chains';
|
|
30
|
+
import '../../../locale/locale.js';
|
|
31
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
32
|
+
import { useConnectAndSignSplitSteps } from '../authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js';
|
|
33
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
34
34
|
import 'react-dom';
|
|
35
35
|
import '../../../context/WalletContext/WalletContext.js';
|
|
36
36
|
import '../../../context/ThemeContext/ThemeContext.js';
|
|
@@ -85,7 +85,7 @@ const EmailUpdate = () => {
|
|
|
85
85
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
86
86
|
const { setView, goToInitialView } = ViewContext.useViewContext();
|
|
87
87
|
const { displayedDestination: email, setDisplayedDestination: setEmail, setVerificationUUID, } = VerificationContext.useVerification();
|
|
88
|
-
const { environmentId, handleLogOut
|
|
88
|
+
const { environmentId, handleLogOut } = useInternalDynamicContext.useInternalDynamicContext();
|
|
89
89
|
const { t } = reactI18next.useTranslation();
|
|
90
90
|
const [emailError, setEmailError] = React.useState(undefined);
|
|
91
91
|
const handleBackClick = () => {
|
|
@@ -93,9 +93,6 @@ const EmailUpdate = () => {
|
|
|
93
93
|
setError(undefined);
|
|
94
94
|
};
|
|
95
95
|
const backButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: handleBackClick, "data-testid": 'back-button', children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
|
|
96
|
-
// If user tries to update an email for logged user there is already an authToken and onboardingOnlyJwt is undefined
|
|
97
|
-
// If user tries to update the email in the authFlow, authToken is undefined and onboardingOnlyJwt is defined
|
|
98
|
-
const jwtToken = minAuthToken || onboardingOnlyJwt;
|
|
99
96
|
const handleEmailUpdate = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
100
97
|
try {
|
|
101
98
|
if (!updatedEmail) {
|
|
@@ -103,7 +100,7 @@ const EmailUpdate = () => {
|
|
|
103
100
|
}
|
|
104
101
|
setEmailError(undefined);
|
|
105
102
|
setLoading(true);
|
|
106
|
-
const { emailVerification } = yield user.updateUserProfileFields(
|
|
103
|
+
const { emailVerification } = yield user.updateUserProfileFields(environmentId, { email: updatedEmail });
|
|
107
104
|
if (!emailVerification) {
|
|
108
105
|
yield handleLogOut();
|
|
109
106
|
goToInitialView();
|