@dynamic-labs/sdk-react-core 3.0.0-alpha.31 → 3.0.0-alpha.33
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 +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +2 -2
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +2 -2
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.cjs +2 -0
- package/src/lib/components/SyncAuthFlow/SyncAuthFlow.js +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -11
- package/src/lib/context/DynamicContext/DynamicContext.js +17 -11
- package/src/lib/context/DynamicContext/types/IDynamicContext.d.ts +1 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +2 -2
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.d.ts +1 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +2 -2
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +3 -3
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +3 -3
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +5 -6
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +5 -6
- package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +1 -1
- package/src/lib/data/api/embeddedWallets/embeddedWallets.js +2 -2
- package/src/lib/data/api/embeddedWallets/types.d.ts +2 -2
- package/src/lib/data/api/externalAuth/externalAuth.cjs +20 -0
- package/src/lib/data/api/externalAuth/externalAuth.d.ts +4 -0
- package/src/lib/data/api/externalAuth/externalAuth.js +20 -1
- package/src/lib/events/auth.d.ts +12 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs +14 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.d.ts +2 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js +10 -0
- package/src/lib/shared/utils/functions/hasPendingMfaAction/index.d.ts +1 -0
- package/src/lib/shared/utils/functions/index.d.ts +1 -0
- package/src/lib/store/hooks/useUser/useUser.cjs +24 -6
- package/src/lib/store/hooks/useUser/useUser.d.ts +6 -3
- package/src/lib/store/hooks/useUser/useUser.js +24 -6
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.cjs +1 -1
- package/src/lib/utils/functions/walletListBuilder/walletListBuilder.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +3 -3
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +3 -3
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.cjs +2 -0
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.js +2 -0
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +2 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +2 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +3 -1
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.d.ts +2 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +4 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.d.ts +3 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.d.ts +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.d.ts +2 -2
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.cjs +30 -1
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.d.ts +1 -0
- package/src/lib/utils/hooks/useExternalAuth/useExternalAuth.js +31 -2
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +8 -28
- package/src/lib/utils/hooks/useMfa/useMfa.d.ts +1 -7
- package/src/lib/utils/hooks/useMfa/useMfa.js +8 -28
- package/src/lib/utils/hooks/useResetCookieLocalStorage/index.d.ts +1 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.cjs +143 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.d.ts +8 -0
- package/src/lib/utils/hooks/useResetCookieLocalStorage/useResetCookieLocalStorage.js +139 -0
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +4 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.d.ts +8 -2
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +4 -2
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +6 -5
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +2 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +6 -5
- package/src/lib/utils/hooks/useSyncMfaFlow/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.cjs +152 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.d.ts +4 -0
- package/src/lib/utils/hooks/useSyncMfaFlow/useSyncMfaFlow.js +148 -0
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.cjs +9 -7
- package/src/lib/utils/hooks/useSyncOnboardingFlow/useSyncOnboardingFlow.js +9 -7
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +8 -14
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +8 -14
- 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/views/CollectUserDataView/CollectUserDataView.cjs +4 -4
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +4 -4
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -3
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +3 -3
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +3 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +4 -4
- package/src/lib/views/EmailVerification/EmailVerification.js +4 -4
- package/src/lib/views/MfaVerificationView/MfaVerificationView.cjs +2 -2
- package/src/lib/views/MfaVerificationView/MfaVerificationView.js +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.d.ts +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +2 -2
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +3 -3
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +3 -3
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/index.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.cjs +0 -8
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.d.ts +0 -2
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.js +0 -4
|
@@ -90,7 +90,7 @@ import '../ReinitializeContext/ReinitializeContextProvider.js';
|
|
|
90
90
|
const SocialRedirectContext = createContext(undefined);
|
|
91
91
|
const SocialRedirectContextProvider = ({ children, }) => {
|
|
92
92
|
var _a, _b, _c, _d;
|
|
93
|
-
const { setShowAuthFlow, walletConnectorOptions, setSelectedWalletConnectorKey, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile,
|
|
93
|
+
const { setShowAuthFlow, walletConnectorOptions, setSelectedWalletConnectorKey, walletUiUtils, consumeNonce, displaySiweStatement, environmentId, projectSettings, setIsSingleWalletAccount, setShowDynamicUserProfile, setPrimaryWalletId, secondaryWallets, sdkHasLoaded, user, connectWallet, primaryWallet, socialProvidersFilter = (providers) => providers, } = useInternalDynamicContext();
|
|
94
94
|
const { setErrorMessage } = useErrorContext();
|
|
95
95
|
const { setView } = useViewContext();
|
|
96
96
|
const { getCaptchaToken } = useCaptchaContext();
|
|
@@ -120,7 +120,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
120
120
|
useInternalDynamicEvents('logout', () => setSocialProvider(undefined));
|
|
121
121
|
const handleError = useCallback((message) => {
|
|
122
122
|
logger.error(message);
|
|
123
|
-
if (
|
|
123
|
+
if (user) {
|
|
124
124
|
setShowAuthFlow(false, { emitCancelAuth: true });
|
|
125
125
|
setShowDynamicUserProfile(true);
|
|
126
126
|
}
|
|
@@ -130,7 +130,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
130
130
|
setErrorMessage('-1');
|
|
131
131
|
}
|
|
132
132
|
}, [
|
|
133
|
-
|
|
133
|
+
user,
|
|
134
134
|
setErrorMessage,
|
|
135
135
|
setShowAuthFlow,
|
|
136
136
|
setShowDynamicUserProfile,
|
|
@@ -162,7 +162,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
162
162
|
setRedirectStatus('loading');
|
|
163
163
|
setView('social-redirect-view');
|
|
164
164
|
setShowAuthFlow(true);
|
|
165
|
-
if (!
|
|
165
|
+
if (!user) {
|
|
166
166
|
setSelectedWalletConnectorKey(socialWalletConnector.key);
|
|
167
167
|
}
|
|
168
168
|
(_b = socialWalletConnector
|
|
@@ -173,7 +173,7 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
173
173
|
* have successfully re-authenticated with the social provider. We can now finish
|
|
174
174
|
* the setPrimaryWallet flow
|
|
175
175
|
*/
|
|
176
|
-
if (
|
|
176
|
+
if (user) {
|
|
177
177
|
if (!socialAccount) {
|
|
178
178
|
throw new Error('Social account not found');
|
|
179
179
|
}
|
|
@@ -240,7 +240,6 @@ const SocialRedirectContextProvider = ({ children, }) => {
|
|
|
240
240
|
}, [
|
|
241
241
|
socialAccount,
|
|
242
242
|
user,
|
|
243
|
-
isAuthenticated,
|
|
244
243
|
projectSettings,
|
|
245
244
|
sdkHasLoaded,
|
|
246
245
|
secondaryWallets,
|
|
@@ -21,7 +21,7 @@ require('../../../shared/consts/index.cjs');
|
|
|
21
21
|
var api = require('../api.cjs');
|
|
22
22
|
var storeAuthTokenAndUser = require('../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
|
|
23
23
|
|
|
24
|
-
const createTurnkeyEmbeddedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [sdkApiCore.
|
|
24
|
+
const createTurnkeyEmbeddedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [sdkApiCore.EmbeddedWalletChainEnum.Evm], passkeyAlias, }) {
|
|
25
25
|
const embeddedWallets = [
|
|
26
26
|
{
|
|
27
27
|
chains,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
4
|
-
import { EmbeddedWalletProviderEnum,
|
|
4
|
+
import { EmbeddedWalletProviderEnum, EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
7
7
|
import '@dynamic-labs/wallet-connector-core';
|
|
@@ -17,7 +17,7 @@ import '../../../shared/consts/index.js';
|
|
|
17
17
|
import { sdkApi } from '../api.js';
|
|
18
18
|
import { storeAuthTokenAndUser } from '../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
19
19
|
|
|
20
|
-
const createTurnkeyEmbeddedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [
|
|
20
|
+
const createTurnkeyEmbeddedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ attestation, challenge, environmentId, chains = [EmbeddedWalletChainEnum.Evm], passkeyAlias, }) {
|
|
21
21
|
const embeddedWallets = [
|
|
22
22
|
{
|
|
23
23
|
chains,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmbeddedWalletChainEnum, PasskeyRegistrationCredential, UpdateRecoveryEmailRequest } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { AuthenticatorType } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
export type CreateTurnkeyEmbeddedWalletProps = {
|
|
4
4
|
environmentId: string;
|
|
5
5
|
attestation?: PasskeyRegistrationCredential;
|
|
6
6
|
challenge?: string;
|
|
7
|
-
chains?:
|
|
7
|
+
chains?: EmbeddedWalletChainEnum[];
|
|
8
8
|
passkeyAlias?: string;
|
|
9
9
|
};
|
|
10
10
|
export type InitPasskeyRecoveryProps = {
|
|
@@ -40,5 +40,25 @@ const externalAuthSignin = (_a) => _tslib.__awaiter(void 0, [_a], void 0, functi
|
|
|
40
40
|
throw new utils.DynamicError(data.error);
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
const externalAuthVerify = (_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ environmentId, externalJwt, }) {
|
|
44
|
+
try {
|
|
45
|
+
const response = yield api.sdkApi().externalAuthVerify({
|
|
46
|
+
environmentId,
|
|
47
|
+
externalAuthSigninRequest: {
|
|
48
|
+
jwt: externalJwt,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
return storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
const data = yield e.json();
|
|
55
|
+
logger.logger.error('Error verifying external JWT', data);
|
|
56
|
+
if (data.code === 'invalid_external_auth') {
|
|
57
|
+
throw new utils.ExternalAuthError(data.code);
|
|
58
|
+
}
|
|
59
|
+
throw new utils.DynamicError(data.error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
43
62
|
|
|
44
63
|
exports.externalAuthSignin = externalAuthSignin;
|
|
64
|
+
exports.externalAuthVerify = externalAuthVerify;
|
|
@@ -3,3 +3,7 @@ export declare const externalAuthSignin: ({ environmentId, externalJwt, }: {
|
|
|
3
3
|
environmentId: string;
|
|
4
4
|
externalJwt?: string;
|
|
5
5
|
}) => Promise<UserProfile | undefined>;
|
|
6
|
+
export declare const externalAuthVerify: ({ environmentId, externalJwt, }: {
|
|
7
|
+
environmentId: string;
|
|
8
|
+
externalJwt?: string;
|
|
9
|
+
}) => Promise<UserProfile | undefined>;
|
|
@@ -36,5 +36,24 @@ const externalAuthSignin = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
36
36
|
throw new DynamicError(data.error);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
|
+
const externalAuthVerify = (_b) => __awaiter(void 0, [_b], void 0, function* ({ environmentId, externalJwt, }) {
|
|
40
|
+
try {
|
|
41
|
+
const response = yield sdkApi().externalAuthVerify({
|
|
42
|
+
environmentId,
|
|
43
|
+
externalAuthSigninRequest: {
|
|
44
|
+
jwt: externalJwt,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return storeAuthTokenAndUser(response);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
const data = yield e.json();
|
|
51
|
+
logger.error('Error verifying external JWT', data);
|
|
52
|
+
if (data.code === 'invalid_external_auth') {
|
|
53
|
+
throw new ExternalAuthError(data.code);
|
|
54
|
+
}
|
|
55
|
+
throw new DynamicError(data.error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
39
58
|
|
|
40
|
-
export { externalAuthSignin };
|
|
59
|
+
export { externalAuthSignin, externalAuthVerify };
|
package/src/lib/events/auth.d.ts
CHANGED
|
@@ -35,5 +35,17 @@ export type AuthEvents = {
|
|
|
35
35
|
logout: () => void;
|
|
36
36
|
/** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */
|
|
37
37
|
triggerLogout: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Emitted when the user succesfully completes an MFA challenge
|
|
40
|
+
*/
|
|
41
|
+
mfaCompletionSuccess: (args: {
|
|
42
|
+
mfaToken?: string;
|
|
43
|
+
}) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Emitted when there is an error verifiyng the MFA challenge
|
|
46
|
+
*/
|
|
47
|
+
mfaCompletionFailure: (args: {
|
|
48
|
+
error: unknown;
|
|
49
|
+
}) => void;
|
|
38
50
|
};
|
|
39
51
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
|
|
8
|
+
const hasPendingMfaAction = (user) => {
|
|
9
|
+
var _a;
|
|
10
|
+
return ((_a = user.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) ||
|
|
11
|
+
user.mfaBackupCodeAcknowledgement === sdkApiCore.MfaBackupCodeAcknowledgement.Pending;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.hasPendingMfaAction = hasPendingMfaAction;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
|
|
4
|
+
const hasPendingMfaAction = (user) => {
|
|
5
|
+
var _a;
|
|
6
|
+
return ((_a = user.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth')) ||
|
|
7
|
+
user.mfaBackupCodeAcknowledgement === MfaBackupCodeAcknowledgement.Pending;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { hasPendingMfaAction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hasPendingMfaAction';
|
|
@@ -3,20 +3,38 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
require('../../../shared/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/iconic');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('react/jsx-runtime');
|
|
11
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
+
require('react');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('../../../utils/constants/colors.cjs');
|
|
15
|
+
require('../../../utils/constants/values.cjs');
|
|
16
|
+
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
|
+
require('../../../shared/utils/classes/storage/sessionStorage.cjs');
|
|
18
|
+
var hasPendingMfaAction = require('../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.cjs');
|
|
19
|
+
require('@dynamic-labs/utils');
|
|
20
|
+
require('../../../shared/consts/index.cjs');
|
|
6
21
|
var store = require('../../store.cjs');
|
|
7
22
|
var useStoreWithSelector = require('../useStoreWithSelector/useStoreWithSelector.cjs');
|
|
8
23
|
|
|
9
24
|
const useUser = () => {
|
|
10
|
-
var _a
|
|
25
|
+
var _a;
|
|
11
26
|
const userFromStore = useStoreWithSelector.useStoreWithSelector(store.getStore(), ({ user }) => user);
|
|
12
|
-
|
|
27
|
+
if (!userFromStore) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
// adding userWithMissingInfo to avoid breaking changes for customer who consider that when we have a user,
|
|
13
31
|
// it means that they are already fully authenticated.
|
|
14
32
|
// since we won't have onboarding jwt anymore, the idea is to just store the user in LS and either use the user state
|
|
15
|
-
// or
|
|
33
|
+
// or userWithMissingInfo, depending on the value of missing fields or mfa required.
|
|
16
34
|
// this is just following our existing logic of how we handle authToken vs onboardingOnlyToken.
|
|
17
|
-
if (((_a = userFromStore
|
|
18
|
-
(
|
|
19
|
-
return {
|
|
35
|
+
if (((_a = userFromStore.missingFields) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
36
|
+
hasPendingMfaAction.hasPendingMfaAction(userFromStore)) {
|
|
37
|
+
return { userWithMissingInfo: userFromStore };
|
|
20
38
|
}
|
|
21
39
|
return { user: userFromStore };
|
|
22
40
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare const useUser: () => {
|
|
2
|
-
|
|
2
|
+
userWithMissingInfo?: undefined;
|
|
3
3
|
user?: undefined;
|
|
4
4
|
} | {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
userWithMissingInfo: import("dist/packages/types/src").UserProfile;
|
|
6
|
+
user?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
user: import("dist/packages/types/src").UserProfile;
|
|
9
|
+
userWithMissingInfo?: undefined;
|
|
7
10
|
};
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import '../../../shared/logger.js';
|
|
4
|
+
import '@dynamic-labs/iconic';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '../../../utils/constants/colors.js';
|
|
11
|
+
import '../../../utils/constants/values.js';
|
|
12
|
+
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
13
|
+
import '../../../shared/utils/classes/storage/sessionStorage.js';
|
|
14
|
+
import { hasPendingMfaAction } from '../../../shared/utils/functions/hasPendingMfaAction/hasPendingMfaAction.js';
|
|
15
|
+
import '@dynamic-labs/utils';
|
|
16
|
+
import '../../../shared/consts/index.js';
|
|
2
17
|
import { getStore } from '../../store.js';
|
|
3
18
|
import { useStoreWithSelector } from '../useStoreWithSelector/useStoreWithSelector.js';
|
|
4
19
|
|
|
5
20
|
const useUser = () => {
|
|
6
|
-
var _a
|
|
21
|
+
var _a;
|
|
7
22
|
const userFromStore = useStoreWithSelector(getStore(), ({ user }) => user);
|
|
8
|
-
|
|
23
|
+
if (!userFromStore) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
// adding userWithMissingInfo to avoid breaking changes for customer who consider that when we have a user,
|
|
9
27
|
// it means that they are already fully authenticated.
|
|
10
28
|
// since we won't have onboarding jwt anymore, the idea is to just store the user in LS and either use the user state
|
|
11
|
-
// or
|
|
29
|
+
// or userWithMissingInfo, depending on the value of missing fields or mfa required.
|
|
12
30
|
// this is just following our existing logic of how we handle authToken vs onboardingOnlyToken.
|
|
13
|
-
if (((_a = userFromStore
|
|
14
|
-
(
|
|
15
|
-
return {
|
|
31
|
+
if (((_a = userFromStore.missingFields) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
32
|
+
hasPendingMfaAction(userFromStore)) {
|
|
33
|
+
return { userWithMissingInfo: userFromStore };
|
|
16
34
|
}
|
|
17
35
|
return { user: userFromStore };
|
|
18
36
|
};
|
|
@@ -134,7 +134,7 @@ const orderAndFilterList = (walletList, walletsFilter, isWalletConnectList, reco
|
|
|
134
134
|
return sortedWalletList;
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
-
const KEEP_WALLETS_NAME_LIST = ['
|
|
137
|
+
const KEEP_WALLETS_NAME_LIST = ['walletconnect', 'bitcoin.com wallet'];
|
|
138
138
|
const applySearchFilterToWalletOptionList = (rawSearchFilter, walletOptionList) => {
|
|
139
139
|
const searchFilter = rawSearchFilter.trim().toLowerCase();
|
|
140
140
|
const cleanName = (name) => {
|
|
@@ -130,7 +130,7 @@ const orderAndFilterList = (walletList, walletsFilter, isWalletConnectList, reco
|
|
|
130
130
|
return sortedWalletList;
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
|
-
const KEEP_WALLETS_NAME_LIST = ['
|
|
133
|
+
const KEEP_WALLETS_NAME_LIST = ['walletconnect', 'bitcoin.com wallet'];
|
|
134
134
|
const applySearchFilterToWalletOptionList = (rawSearchFilter, walletOptionList) => {
|
|
135
135
|
const searchFilter = rawSearchFilter.trim().toLowerCase();
|
|
136
136
|
const cleanName = (name) => {
|
|
@@ -99,11 +99,11 @@ require('../../../../context/ReinitializeContext/ReinitializeContextProvider.cjs
|
|
|
99
99
|
* This is to avoid a circular logic issue, as handleVerificationRequired needs to use the logic in this file as well.
|
|
100
100
|
*/
|
|
101
101
|
const useOtpVerificationRequestRaw = () => {
|
|
102
|
-
const { environmentId, user,
|
|
102
|
+
const { environmentId, user, userWithMissingInfo } = useInternalDynamicContext.useInternalDynamicContext();
|
|
103
103
|
const { verificationUUID: contextVerificationUUID } = VerificationContext.useVerification();
|
|
104
104
|
const verifyOtp = React.useCallback((handleVerificationRequired, verificationToken, destination, localVerificationUUID) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
105
105
|
var _a;
|
|
106
|
-
if (!user && !
|
|
106
|
+
if (!user && !userWithMissingInfo)
|
|
107
107
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
108
108
|
// VerificationUUID is saved in the context in case the view changes
|
|
109
109
|
// after a profile update (changing the view from edit profile to verify email)
|
|
@@ -133,7 +133,7 @@ const useOtpVerificationRequestRaw = () => {
|
|
|
133
133
|
missingFields,
|
|
134
134
|
updateUserProfileResponse: updateSelfResponse,
|
|
135
135
|
};
|
|
136
|
-
}), [contextVerificationUUID, environmentId, user,
|
|
136
|
+
}), [contextVerificationUUID, environmentId, user, userWithMissingInfo]);
|
|
137
137
|
return { verifyOtp };
|
|
138
138
|
};
|
|
139
139
|
/**
|
|
@@ -95,11 +95,11 @@ import '../../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
|
95
95
|
* This is to avoid a circular logic issue, as handleVerificationRequired needs to use the logic in this file as well.
|
|
96
96
|
*/
|
|
97
97
|
const useOtpVerificationRequestRaw = () => {
|
|
98
|
-
const { environmentId, user,
|
|
98
|
+
const { environmentId, user, userWithMissingInfo } = useInternalDynamicContext();
|
|
99
99
|
const { verificationUUID: contextVerificationUUID } = useVerification();
|
|
100
100
|
const verifyOtp = useCallback((handleVerificationRequired, verificationToken, destination, localVerificationUUID) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
101
|
var _a;
|
|
102
|
-
if (!user && !
|
|
102
|
+
if (!user && !userWithMissingInfo)
|
|
103
103
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
|
104
104
|
// VerificationUUID is saved in the context in case the view changes
|
|
105
105
|
// after a profile update (changing the view from edit profile to verify email)
|
|
@@ -129,7 +129,7 @@ const useOtpVerificationRequestRaw = () => {
|
|
|
129
129
|
missingFields,
|
|
130
130
|
updateUserProfileResponse: updateSelfResponse,
|
|
131
131
|
};
|
|
132
|
-
}), [contextVerificationUUID, environmentId, user,
|
|
132
|
+
}), [contextVerificationUUID, environmentId, user, userWithMissingInfo]);
|
|
133
133
|
return { verifyOtp };
|
|
134
134
|
};
|
|
135
135
|
/**
|
|
@@ -30,6 +30,8 @@ const externalEvents = [
|
|
|
30
30
|
'embeddedWalletCreated',
|
|
31
31
|
'logout',
|
|
32
32
|
'walletAdded',
|
|
33
|
+
'mfaCompletionSuccess',
|
|
34
|
+
'mfaCompletionFailure',
|
|
33
35
|
];
|
|
34
36
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
35
37
|
const useDynamicEvents = (event, listener) => {
|
|
@@ -4,5 +4,5 @@ type DynamicEventListener<E extends keyof DynamicEvents> = (...args: EventArgs<D
|
|
|
4
4
|
/** Allows us to subscribe to all dynamicEvents with a hook, even the internal ones */
|
|
5
5
|
export declare const useInternalDynamicEvents: <E extends keyof import("../../../../events/auth").AuthEvents | keyof import("../../../../events/ui").UIEvents | keyof import("../../../../events/otp").OTPEvents | keyof import("../../../../events/wallets").WalletEvents | keyof import("../../../../events/passkey").PasskeyEvents | "farcasterConnectCancelled" | keyof import("../../../../events/embeddedWallet").EmbeddedWalletEvents | keyof import("../../../../events/multiWallet").MultiWalletInternalEvents>(event: E, listener: DynamicEventListener<E>) => void;
|
|
6
6
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
7
|
-
export declare const useDynamicEvents: <E extends "logout" | "emailVerificationResult" | "walletAdded" | "embeddedWalletCreated">(event: E, listener: DynamicEventListener<E>) => void;
|
|
7
|
+
export declare const useDynamicEvents: <E extends "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "emailVerificationResult" | "walletAdded" | "embeddedWalletCreated">(event: E, listener: DynamicEventListener<E>) => void;
|
|
8
8
|
export {};
|
|
@@ -26,6 +26,8 @@ const externalEvents = [
|
|
|
26
26
|
'embeddedWalletCreated',
|
|
27
27
|
'logout',
|
|
28
28
|
'walletAdded',
|
|
29
|
+
'mfaCompletionSuccess',
|
|
30
|
+
'mfaCompletionFailure',
|
|
29
31
|
];
|
|
30
32
|
/** Allows subscribing to dynamic events directly inside components with a hook */
|
|
31
33
|
const useDynamicEvents = (event, listener) => {
|
|
@@ -61,3 +61,5 @@ export { useSyncOnboardingFlow } from './useSyncOnboardingFlow';
|
|
|
61
61
|
export { useExternalAuth } from './useExternalAuth';
|
|
62
62
|
export { useRefreshUser } from './useRefreshUser';
|
|
63
63
|
export { useSelectWalletOption } from './useSelectWalletOption';
|
|
64
|
+
export { useResetCookieLocalStorage } from './useResetCookieLocalStorage';
|
|
65
|
+
export { useSyncMfaFlow } from './useSyncMfaFlow';
|
|
@@ -92,8 +92,9 @@ require('../../../../context/ReinitializeContext/ReinitializeContextProvider.cjs
|
|
|
92
92
|
var useInternalDynamicContext = require('../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
|
|
93
93
|
|
|
94
94
|
const useSyncPrimaryWallet = (canSync = true) => {
|
|
95
|
-
const { setShowAuthFlow,
|
|
95
|
+
const { setShowAuthFlow, authMode, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, setMultiWalletWidgetState, showLockedWalletView, secondaryWallets, setPrimaryWallet, setSelectedWalletWithAction, multiWallet, selectedWalletWithAction, user, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
96
96
|
const { setView } = ViewContext.useViewContext();
|
|
97
|
+
const isAuthenticated = Boolean(user);
|
|
97
98
|
const handlePrimaryWalletNotActive = React.useCallback((connectedAddress) => {
|
|
98
99
|
logVerboseTroubleshootingMessage.logVerboseTroubleshootingMessage('[useSyncPrimaryWallet] handlePrimaryWalletNotActive', {
|
|
99
100
|
authMode,
|
|
@@ -88,8 +88,9 @@ import '../../../../context/ReinitializeContext/ReinitializeContextProvider.js';
|
|
|
88
88
|
import { useInternalDynamicContext } from '../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext.js';
|
|
89
89
|
|
|
90
90
|
const useSyncPrimaryWallet = (canSync = true) => {
|
|
91
|
-
const { setShowAuthFlow,
|
|
91
|
+
const { setShowAuthFlow, authMode, connectWallet, handleLogOut, multiWalletWidgetState, primaryWallet, setMultiWalletWidgetState, showLockedWalletView, secondaryWallets, setPrimaryWallet, setSelectedWalletWithAction, multiWallet, selectedWalletWithAction, user, } = useInternalDynamicContext();
|
|
92
92
|
const { setView } = useViewContext();
|
|
93
|
+
const isAuthenticated = Boolean(user);
|
|
93
94
|
const handlePrimaryWalletNotActive = useCallback((connectedAddress) => {
|
|
94
95
|
logVerboseTroubleshootingMessage('[useSyncPrimaryWallet] handlePrimaryWalletNotActive', {
|
|
95
96
|
authMode,
|
|
@@ -104,7 +104,9 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
104
104
|
const primaryEmbeddedChain = findPrimaryEmbeddedChain.findPrimaryEmbeddedChain(projectSettings);
|
|
105
105
|
const embeddedChains = embeddedChainConfig
|
|
106
106
|
.filter((chain) => chain.enabled)
|
|
107
|
-
.map((c) =>
|
|
107
|
+
.map((c) => c.name === 'SOL'
|
|
108
|
+
? sdkApiCore.EmbeddedWalletChainEnum.Sol
|
|
109
|
+
: sdkApiCore.EmbeddedWalletChainEnum.Evm);
|
|
108
110
|
const createDynamicEmbeddedWalletMutation = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, walletConnectorOptions, withAuthenticator, options, chains, }) {
|
|
109
111
|
var _d, _e;
|
|
110
112
|
setIsLoading(true);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { WebAuthnAttestation } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { WalletOption } from '../../../shared';
|
|
4
4
|
type MutationProps = {
|
|
@@ -8,7 +8,7 @@ type MutationProps = {
|
|
|
8
8
|
options?: {
|
|
9
9
|
webAuthnAttestation: WebAuthnAttestation;
|
|
10
10
|
};
|
|
11
|
-
chains?:
|
|
11
|
+
chains?: EmbeddedWalletChainEnum[];
|
|
12
12
|
};
|
|
13
13
|
export declare const useCreateDynamicEmbeddedWalletMutation: () => {
|
|
14
14
|
createDynamicEmbeddedWalletMutation: ({ environmentId, walletConnectorOptions, withAuthenticator, options, chains, }: MutationProps) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useState, useCallback } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
7
7
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -100,7 +100,9 @@ const useCreateDynamicEmbeddedWalletMutation = () => {
|
|
|
100
100
|
const primaryEmbeddedChain = findPrimaryEmbeddedChain(projectSettings);
|
|
101
101
|
const embeddedChains = embeddedChainConfig
|
|
102
102
|
.filter((chain) => chain.enabled)
|
|
103
|
-
.map((c) =>
|
|
103
|
+
.map((c) => c.name === 'SOL'
|
|
104
|
+
? EmbeddedWalletChainEnum.Sol
|
|
105
|
+
: EmbeddedWalletChainEnum.Evm);
|
|
104
106
|
const createDynamicEmbeddedWalletMutation = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, walletConnectorOptions, withAuthenticator, options, chains, }) {
|
|
105
107
|
var _d, _e;
|
|
106
108
|
setIsLoading(true);
|
|
@@ -116,7 +116,7 @@ var useInternalDynamicContext = require('../../../context/DynamicContext/useDyna
|
|
|
116
116
|
const useEmbeddedWallet = () => {
|
|
117
117
|
const { user, projectSettings, setPrimaryWalletId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
118
118
|
const { isTurnkeyWallet } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
119
|
-
const { createEmbeddedWallet: createMPCWallet, canCreateMPCWallet, createPassword, revealEmbeddedWalletKey:
|
|
119
|
+
const { createEmbeddedWallet: createMPCWallet, canCreateMPCWallet, createPassword, revealEmbeddedWalletKey: revealCoinbaseMPCEmbeddedWalletKey, } = useMPCEmbeddedWallet.useMPCEmbeddedWallet();
|
|
120
120
|
const { createEmbeddedWallet: createTurnkeyEmbeddedWallet, createOrRestoreSession, createPasskey, revealEmbeddedWalletKey: revealTurnkeyEmbeddedWalletKey, getPasskeys, isSessionActive, sendOneTimeCode, getWalletVersion: getTurnkeyWalletVersion, } = useSecureEnclaveEmbeddedWallet.useSecureEnclaveEmbeddedWallet();
|
|
121
121
|
const { isLoadingEmbeddedWallet } = WalletContext.useWalletContext();
|
|
122
122
|
const userHasEmbeddedWallet = () => hasEmbeddedWallet.hasEmbeddedWallet(user);
|
|
@@ -161,7 +161,7 @@ const useEmbeddedWallet = () => {
|
|
|
161
161
|
if (isTurnkeyWallet) {
|
|
162
162
|
return revealTurnkeyEmbeddedWalletKey(options);
|
|
163
163
|
}
|
|
164
|
-
return
|
|
164
|
+
return revealCoinbaseMPCEmbeddedWalletKey();
|
|
165
165
|
});
|
|
166
166
|
const shouldAutoCreateEmbeddedWallet = React.useCallback((verifiedUser) => {
|
|
167
167
|
var _a, _b, _c, _d, _e;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { Wallet } from '../../../shared';
|
|
3
3
|
import { UserProfile } from '../../../..';
|
|
4
4
|
/**
|
|
@@ -16,7 +16,7 @@ import { UserProfile } from '../../../..';
|
|
|
16
16
|
* }
|
|
17
17
|
*/
|
|
18
18
|
export declare const useEmbeddedWallet: () => {
|
|
19
|
-
readonly createEmbeddedWallet: (chains?:
|
|
19
|
+
readonly createEmbeddedWallet: (chains?: EmbeddedWalletChainEnum[], options?: {
|
|
20
20
|
webAuthnAttestation: import("dist/packages/wallet-connector-core/src").WebAuthnAttestation;
|
|
21
21
|
} | undefined) => Promise<Wallet | undefined>;
|
|
22
22
|
readonly createOrRestoreSession: (options?: {
|
|
@@ -112,7 +112,7 @@ import { useInternalDynamicContext } from '../../../context/DynamicContext/useDy
|
|
|
112
112
|
const useEmbeddedWallet = () => {
|
|
113
113
|
const { user, projectSettings, setPrimaryWalletId } = useInternalDynamicContext();
|
|
114
114
|
const { isTurnkeyWallet } = useIsTurnkeyWallet();
|
|
115
|
-
const { createEmbeddedWallet: createMPCWallet, canCreateMPCWallet, createPassword, revealEmbeddedWalletKey:
|
|
115
|
+
const { createEmbeddedWallet: createMPCWallet, canCreateMPCWallet, createPassword, revealEmbeddedWalletKey: revealCoinbaseMPCEmbeddedWalletKey, } = useMPCEmbeddedWallet();
|
|
116
116
|
const { createEmbeddedWallet: createTurnkeyEmbeddedWallet, createOrRestoreSession, createPasskey, revealEmbeddedWalletKey: revealTurnkeyEmbeddedWalletKey, getPasskeys, isSessionActive, sendOneTimeCode, getWalletVersion: getTurnkeyWalletVersion, } = useSecureEnclaveEmbeddedWallet();
|
|
117
117
|
const { isLoadingEmbeddedWallet } = useWalletContext();
|
|
118
118
|
const userHasEmbeddedWallet = () => hasEmbeddedWallet(user);
|
|
@@ -157,7 +157,7 @@ const useEmbeddedWallet = () => {
|
|
|
157
157
|
if (isTurnkeyWallet) {
|
|
158
158
|
return revealTurnkeyEmbeddedWalletKey(options);
|
|
159
159
|
}
|
|
160
|
-
return
|
|
160
|
+
return revealCoinbaseMPCEmbeddedWalletKey();
|
|
161
161
|
});
|
|
162
162
|
const shouldAutoCreateEmbeddedWallet = useCallback((verifiedUser) => {
|
|
163
163
|
var _a, _b, _c, _d, _e;
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.cjs
CHANGED
|
@@ -193,7 +193,7 @@ const useCoinbaseMPC = () => {
|
|
|
193
193
|
}
|
|
194
194
|
return undefined;
|
|
195
195
|
}), [linkCoinbaseMPCWallet, handleLogOut, setError]);
|
|
196
|
-
const createCoinbaseMPCWallet = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (chains = [sdkApiCore.
|
|
196
|
+
const createCoinbaseMPCWallet = React.useCallback((...args_1) => _tslib.__awaiter(void 0, [...args_1], void 0, function* (chains = [sdkApiCore.EmbeddedWalletChainEnum.Evm], password) {
|
|
197
197
|
var _d;
|
|
198
198
|
if (!user) {
|
|
199
199
|
throw new utils.DynamicError(errors.USER_NOT_LOGGED_IN);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { Wallet } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
export declare const useCoinbaseMPC: () => {
|
|
4
|
-
createCoinbaseMPCWallet: (chains?:
|
|
4
|
+
createCoinbaseMPCWallet: (chains?: EmbeddedWalletChainEnum[], password?: string) => Promise<Wallet | undefined>;
|
|
5
5
|
};
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useCoinbaseMPC/useCoinbaseMPC.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
-
import { PasswordSourceTypeEnum,
|
|
4
|
+
import { PasswordSourceTypeEnum, EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { Wallet, isCoinbaseMpcWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
7
7
|
import { createUserProfileFromSdkUser } from '../../../../functions/createUserProfile/createUserProfile.js';
|
|
@@ -189,7 +189,7 @@ const useCoinbaseMPC = () => {
|
|
|
189
189
|
}
|
|
190
190
|
return undefined;
|
|
191
191
|
}), [linkCoinbaseMPCWallet, handleLogOut, setError]);
|
|
192
|
-
const createCoinbaseMPCWallet = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (chains = [
|
|
192
|
+
const createCoinbaseMPCWallet = useCallback((...args_1) => __awaiter(void 0, [...args_1], void 0, function* (chains = [EmbeddedWalletChainEnum.Evm], password) {
|
|
193
193
|
var _d;
|
|
194
194
|
if (!user) {
|
|
195
195
|
throw new DynamicError(USER_NOT_LOGGED_IN);
|
package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmbeddedWalletChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { Wallet } from '../../../../shared';
|
|
3
3
|
/**
|
|
4
4
|
* @returns {
|
|
@@ -9,8 +9,8 @@ import { Wallet } from '../../../../shared';
|
|
|
9
9
|
* }
|
|
10
10
|
*/
|
|
11
11
|
export declare const useMPCEmbeddedWallet: () => {
|
|
12
|
-
readonly canCreateMPCWallet: (chains?:
|
|
13
|
-
readonly createEmbeddedWallet: (chains?:
|
|
12
|
+
readonly canCreateMPCWallet: (chains?: EmbeddedWalletChainEnum[]) => Promise<boolean>;
|
|
13
|
+
readonly createEmbeddedWallet: (chains?: EmbeddedWalletChainEnum[]) => Promise<Wallet | undefined>;
|
|
14
14
|
readonly createPassword: (showIntro?: boolean) => Promise<string>;
|
|
15
15
|
readonly isLoadingEmbeddedWallet: boolean;
|
|
16
16
|
readonly revealEmbeddedWalletKey: () => Promise<never>;
|