@dynamic-labs/sdk-react-core 2.1.0-alpha.22 → 2.1.0-alpha.23
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 +1 -1
- package/package.js +1 -1
- package/package.json +13 -13
- package/src/index.d.ts +5 -1
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.cjs +2 -6
- package/src/lib/components/AuthProviderIcon/AuthProviderIcon.js +2 -6
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.cjs +11 -5
- package/src/lib/components/SyncEmbeddedWalletAuthFlow/SyncEmbeddedWalletAuthFlow.js +11 -5
- package/src/lib/context/DynamicContext/DynamicContext.cjs +8 -17
- package/src/lib/context/DynamicContext/DynamicContext.js +8 -17
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/types.d.ts +0 -1
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.cjs +0 -2
- package/src/lib/context/DynamicContext/hooks/useHandleLogout/useHandleLogout.js +1 -3
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.cjs +37 -0
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useIsAuthenticated/useIsAuthenticated.js +33 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +9 -1
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +9 -1
- package/src/lib/context/DynamicContext/types/index.d.ts +1 -4
- package/src/lib/context/LoadingContext/LoadingContext.cjs +1 -1
- package/src/lib/context/LoadingContext/LoadingContext.js +1 -1
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.cjs +1 -1
- package/src/lib/context/PhantomRedirectContext/useResponseHandlers.js +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +1 -1
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +1 -1
- package/src/lib/data/api/api.cjs +1 -3
- package/src/lib/data/api/api.js +1 -3
- package/src/lib/data/api/user/user.cjs +9 -6
- package/src/lib/data/api/user/user.d.ts +5 -5
- package/src/lib/data/api/user/user.js +9 -6
- package/src/lib/data/api/wallets/wallets.cjs +6 -3
- package/src/lib/data/api/wallets/wallets.d.ts +3 -2
- package/src/lib/data/api/wallets/wallets.js +7 -4
- package/src/lib/events/auth.d.ts +38 -0
- package/src/lib/events/dynamicEvents.d.ts +8 -32
- package/src/lib/events/embeddedWallet.d.ts +14 -0
- package/src/lib/events/otp.d.ts +5 -0
- package/src/lib/events/passkey.d.ts +5 -0
- package/src/lib/events/social.d.ts +3 -0
- package/src/lib/events/ui.d.ts +10 -0
- package/src/lib/events/wallets.d.ts +7 -0
- package/src/lib/layout/DynamicAuthLayout/Header/header.cjs +6 -1
- package/src/lib/layout/DynamicAuthLayout/Header/header.js +6 -1
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +11 -0
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs +1 -2
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.d.ts +6 -2
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js +1 -2
- package/src/lib/utils/constants/index.d.ts +1 -1
- package/src/lib/utils/constants/localStorage.cjs +0 -2
- package/src/lib/utils/constants/localStorage.d.ts +0 -1
- package/src/lib/utils/constants/localStorage.js +1 -2
- package/src/lib/utils/functions/index.d.ts +0 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSignSplitSteps/useConnectAndSignSplitSteps.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.cjs +12 -7
- package/src/lib/utils/hooks/authenticationHooks/useOtpVerificationRequest/useOtpVerificationRequest.js +13 -8
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.cjs +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useSignConnectOnlyUser/useSignConnectOnlyUser.js +1 -1
- package/src/lib/utils/hooks/events/useDynamicEvents/useDynamicEvents.d.ts +2 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.d.ts +1 -2
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +1 -2
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.cjs +29 -14
- package/src/lib/utils/hooks/useEmailProvider/useEmailProvider.js +29 -14
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +4 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +4 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.cjs +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useMPCEmbeddedWallet/useMPCEmbeddedWallet.js +2 -2
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +4 -5
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +5 -6
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.cjs +0 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useTurnkey/useTurnkey.js +0 -1
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.cjs +2 -2
- package/src/lib/utils/hooks/useEmbeddedWalletPassword/useEmbeddedWalletPassword.js +2 -2
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.cjs +8 -6
- package/src/lib/utils/hooks/useHandleUnlinkWallet/useHandleUnlinkWallet.js +8 -6
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.cjs +4 -4
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.d.ts +4 -3
- package/src/lib/utils/hooks/useHandleVerificationRequired/useHandleVerificationRequired.js +4 -4
- package/src/lib/utils/hooks/useHandleVerifiedUser/useHandleVerifiedUser.cjs +1 -16
- package/src/lib/utils/hooks/useHandleVerifiedUser/useHandleVerifiedUser.d.ts +1 -4
- package/src/lib/utils/hooks/useHandleVerifiedUser/useHandleVerifiedUser.js +1 -16
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.cjs +1 -1
- package/src/lib/utils/hooks/useMergeUserAccounts/useMergeUserAccounts.js +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +37 -20
- package/src/lib/utils/hooks/useMfa/useMfa.js +37 -20
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.cjs +1 -1
- package/src/lib/utils/hooks/useNetworkNotSupported/useNetworkNotSupported.js +1 -1
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.cjs +13 -12
- package/src/lib/utils/hooks/usePasskeyRecovery/usePasskeyRecovery.js +13 -12
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.cjs +6 -11
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.d.ts +3 -2
- package/src/lib/utils/hooks/usePrimaryWalletId/usePrimaryWalletId.js +6 -11
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.cjs +3 -22
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.d.ts +2 -1
- package/src/lib/utils/hooks/useSetWalletConnectorVerifiedCredentials/useSetWalletConnectorVerifiedCredentials.js +3 -22
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +8 -8
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +8 -8
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +39 -27
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +5 -3
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +39 -27
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +39 -33
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.d.ts +2 -2
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +39 -33
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.types.d.ts +7 -24
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.cjs +1 -1
- package/src/lib/utils/hooks/useUserDataForm/useUserDataForm.js +1 -1
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs +9 -16
- package/src/lib/utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js +10 -17
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +1 -1
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +1 -1
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +21 -3
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +21 -3
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.cjs +10 -26
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.d.ts +1 -2
- package/src/lib/utils/hooks/useWalletConnectors/useWalletConnectors.js +10 -26
- package/src/lib/views/CollectUserDataView/CollectUserDataView.cjs +4 -6
- package/src/lib/views/CollectUserDataView/CollectUserDataView.js +4 -6
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +3 -5
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +3 -5
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.cjs +3 -5
- package/src/lib/views/CollectUserDataViewNoWallet/CollectUserDataViewNoWallet.js +3 -5
- package/src/lib/views/EmailVerification/EmailVerification.cjs +8 -5
- package/src/lib/views/EmailVerification/EmailVerification.js +8 -5
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +5 -0
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +5 -0
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.cjs +3 -6
- package/src/lib/views/EmbeddedReveal/EmbeddedRevealView/EmbeddedRevealView.js +3 -6
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.cjs +7 -13
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.d.ts +3 -3
- package/src/lib/views/EmbeddedReveal/utils/turnkeyExport/turnkeyExport.js +8 -14
- package/src/lib/views/LoginView/LoginView.cjs +3 -21
- package/src/lib/views/LoginView/LoginView.js +4 -22
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.cjs +11 -1
- package/src/lib/views/LoginView/sections/PhoneNumberSignInSection/useSubmitPhoneNumber/useSubmitPhoneNumber.js +11 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +3 -3
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +3 -3
- package/src/lib/views/NoAccess/NoAccess.cjs +2 -2
- package/src/lib/views/NoAccess/NoAccess.js +2 -2
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +2 -8
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +2 -8
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +3 -3
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +3 -3
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +1 -2
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.cjs +1 -4
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.d.ts +1 -2
- package/src/lib/views/Passkey/utils/createEmbeddedWalletRequest/createEmbeddedWalletRequest.js +1 -4
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.cjs +15 -20
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.d.ts +8 -13
- package/src/lib/views/Passkey/utils/passkeyRecovery/passkeyRecovery.js +15 -20
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.cjs +11 -8
- package/src/lib/views/SmsVerification/useSmsVerification/useSmsVerification.js +11 -8
- package/src/lib/views/viewToComponentMap.cjs +1 -1
- package/src/lib/views/viewToComponentMap.d.ts +1 -1
- package/src/lib/views/viewToComponentMap.js +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.js +1 -1
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.cjs +0 -31
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.d.ts +0 -1
- package/src/lib/utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.js +0 -27
- package/src/lib/utils/functions/getOnboardingAuthToken/index.d.ts +0 -1
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.cjs +0 -49
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.d.ts +0 -13
- package/src/lib/utils/functions/handleUnlinkHelper/handleUnlinkHelper.js +0 -45
- package/src/lib/utils/functions/handleUnlinkHelper/index.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsAuthenticated: () => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { decodeJwt } from '../../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
3
|
+
import '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import '../../../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../../../ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../../../utils/constants/colors.js';
|
|
12
|
+
import '../../../../utils/constants/values.js';
|
|
13
|
+
import '../../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '@dynamic-labs/utils';
|
|
15
|
+
import '../../../../shared/consts/index.js';
|
|
16
|
+
import '../../../../../../_virtual/_tslib.js';
|
|
17
|
+
import '@dynamic-labs/multi-wallet';
|
|
18
|
+
import { getAuthToken } from '../../../../utils/functions/getAuthToken/getAuthToken.js';
|
|
19
|
+
import 'react-international-phone';
|
|
20
|
+
import 'viem';
|
|
21
|
+
import 'viem/chains';
|
|
22
|
+
import '../../../../config/ApiEndpoint.js';
|
|
23
|
+
import '../../../../locale/locale.js';
|
|
24
|
+
import '@dynamic-labs/store';
|
|
25
|
+
|
|
26
|
+
const useIsAuthenticated = () => {
|
|
27
|
+
var _a;
|
|
28
|
+
const token = getAuthToken();
|
|
29
|
+
const decoded = decodeJwt(token);
|
|
30
|
+
return Boolean(token) && !((_a = decoded === null || decoded === void 0 ? void 0 : decoded.scope) === null || _a === void 0 ? void 0 : _a.includes('requiresAdditionalAuth'));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { useIsAuthenticated };
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs
CHANGED
|
@@ -31,9 +31,9 @@ require('@dynamic-labs/store');
|
|
|
31
31
|
require('../../../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
32
|
require('../../../AccountExistsContext/AccountExistsContext.cjs');
|
|
33
33
|
require('../../../UserWalletsContext/UserWalletsContext.cjs');
|
|
34
|
+
require('../../../../events/dynamicEvents.cjs');
|
|
34
35
|
require('../../../VerificationContext/VerificationContext.cjs');
|
|
35
36
|
require('react-dom');
|
|
36
|
-
require('../../../../events/dynamicEvents.cjs');
|
|
37
37
|
require('../../../WalletContext/WalletContext.cjs');
|
|
38
38
|
require('../../../ThemeContext/ThemeContext.cjs');
|
|
39
39
|
require('@dynamic-labs/types');
|
|
@@ -119,6 +119,14 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, setHasLoggedOut, }) =>
|
|
|
119
119
|
var _a;
|
|
120
120
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onLogout) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, user);
|
|
121
121
|
});
|
|
122
|
+
useDynamicEvents.useInternalDynamicEvents('authFailure', (data, reason) => {
|
|
123
|
+
var _a;
|
|
124
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFailure) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, data, reason);
|
|
125
|
+
});
|
|
126
|
+
useDynamicEvents.useInternalDynamicEvents('authInit', (data) => {
|
|
127
|
+
var _a;
|
|
128
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthInit) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, data);
|
|
129
|
+
});
|
|
122
130
|
};
|
|
123
131
|
|
|
124
132
|
exports.useTieCallbacksToEvents = useTieCallbacksToEvents;
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js
CHANGED
|
@@ -27,9 +27,9 @@ import '@dynamic-labs/store';
|
|
|
27
27
|
import '../../../AccessDeniedContext/AccessDeniedContext.js';
|
|
28
28
|
import '../../../AccountExistsContext/AccountExistsContext.js';
|
|
29
29
|
import '../../../UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import '../../../../events/dynamicEvents.js';
|
|
30
31
|
import '../../../VerificationContext/VerificationContext.js';
|
|
31
32
|
import 'react-dom';
|
|
32
|
-
import '../../../../events/dynamicEvents.js';
|
|
33
33
|
import '../../../WalletContext/WalletContext.js';
|
|
34
34
|
import '../../../ThemeContext/ThemeContext.js';
|
|
35
35
|
import '@dynamic-labs/types';
|
|
@@ -115,6 +115,14 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, setHasLoggedOut, }) =>
|
|
|
115
115
|
var _a;
|
|
116
116
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onLogout) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, user);
|
|
117
117
|
});
|
|
118
|
+
useInternalDynamicEvents('authFailure', (data, reason) => {
|
|
119
|
+
var _a;
|
|
120
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthFailure) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, data, reason);
|
|
121
|
+
});
|
|
122
|
+
useInternalDynamicEvents('authInit', (data) => {
|
|
123
|
+
var _a;
|
|
124
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onAuthInit) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, data);
|
|
125
|
+
});
|
|
118
126
|
};
|
|
119
127
|
|
|
120
128
|
export { useTieCallbacksToEvents };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch, MutableRefObject, ReactElement, ReactNode, SetStateAction } from 'react';
|
|
2
2
|
import { changeLanguage } from 'i18next';
|
|
3
|
-
import {
|
|
3
|
+
import { NameServiceData, ProjectSettings, SdkView } from '@dynamic-labs/sdk-api-core';
|
|
4
4
|
import { GenericNetwork, NetworkConfigurationMap, SocialProviderFilter, UserProfile, WalletUiUtils } from '@dynamic-labs/types';
|
|
5
5
|
import { Chain, GetAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
6
|
import { PasskeySuccessEnum } from '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner';
|
|
@@ -79,7 +79,6 @@ export interface IDynamicContext {
|
|
|
79
79
|
customPrivacyPolicy?: ReactNode;
|
|
80
80
|
customTermsOfServices?: ReactNode;
|
|
81
81
|
debugError: boolean;
|
|
82
|
-
decodedOnboardingOnlyToken: Omit<DynamicJwt, 'jwt'> | undefined;
|
|
83
82
|
defaultNumberOfWalletsToShow: number;
|
|
84
83
|
desktopUri: string;
|
|
85
84
|
disconnectWallet: (walletId: string) => void;
|
|
@@ -120,7 +119,6 @@ export interface IDynamicContext {
|
|
|
120
119
|
newToWeb3WalletChainMap: ChainToWalletMap;
|
|
121
120
|
notInTheListImageUrl?: string;
|
|
122
121
|
onboardingImageUrl?: string;
|
|
123
|
-
onboardingOnlyJwt: string | undefined;
|
|
124
122
|
overrides?: SettingsOverrides;
|
|
125
123
|
passkeySuccessPopup: PasskeySuccessEnum | undefined;
|
|
126
124
|
policiesConsentInnerComponent?: ReactNode | ReactNode[];
|
|
@@ -152,7 +150,6 @@ export interface IDynamicContext {
|
|
|
152
150
|
setLegacyIsVerifying: Dispatch<SetStateAction<boolean>>;
|
|
153
151
|
setLogInWithEmail: Dispatch<SetStateAction<boolean>>;
|
|
154
152
|
setMultiWalletWidgetState: MultiWalletWidgetStateSetter;
|
|
155
|
-
setOnboardingOnlyJwt: Dispatch<SetStateAction<string | undefined>>;
|
|
156
153
|
setPasskeySuccessPopup: (key: PasskeySuccessEnum) => void;
|
|
157
154
|
setPrimaryWallet: (walletId: string) => Promise<void>;
|
|
158
155
|
setPrimaryWalletId: (walletId: string) => void;
|
|
@@ -31,9 +31,9 @@ require('@dynamic-labs/store');
|
|
|
31
31
|
require('../AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
32
|
require('../AccountExistsContext/AccountExistsContext.cjs');
|
|
33
33
|
require('../UserWalletsContext/UserWalletsContext.cjs');
|
|
34
|
+
require('../../events/dynamicEvents.cjs');
|
|
34
35
|
require('../VerificationContext/VerificationContext.cjs');
|
|
35
36
|
require('react-dom');
|
|
36
|
-
require('../../events/dynamicEvents.cjs');
|
|
37
37
|
require('../WalletContext/WalletContext.cjs');
|
|
38
38
|
require('../ThemeContext/ThemeContext.cjs');
|
|
39
39
|
require('@dynamic-labs/types');
|
|
@@ -27,9 +27,9 @@ import '@dynamic-labs/store';
|
|
|
27
27
|
import '../AccessDeniedContext/AccessDeniedContext.js';
|
|
28
28
|
import '../AccountExistsContext/AccountExistsContext.js';
|
|
29
29
|
import '../UserWalletsContext/UserWalletsContext.js';
|
|
30
|
+
import '../../events/dynamicEvents.js';
|
|
30
31
|
import '../VerificationContext/VerificationContext.js';
|
|
31
32
|
import 'react-dom';
|
|
32
|
-
import '../../events/dynamicEvents.js';
|
|
33
33
|
import '../WalletContext/WalletContext.js';
|
|
34
34
|
import '../ThemeContext/ThemeContext.js';
|
|
35
35
|
import '@dynamic-labs/types';
|
|
@@ -37,8 +37,8 @@ require('react-dom');
|
|
|
37
37
|
require('../WalletContext/WalletContext.cjs');
|
|
38
38
|
require('../ThemeContext/ThemeContext.cjs');
|
|
39
39
|
require('@dynamic-labs/types');
|
|
40
|
-
require('../LoadingContext/LoadingContext.cjs');
|
|
41
40
|
require('../AccountExistsContext/AccountExistsContext.cjs');
|
|
41
|
+
require('../LoadingContext/LoadingContext.cjs');
|
|
42
42
|
require('yup');
|
|
43
43
|
require('../MockContext/MockContext.cjs');
|
|
44
44
|
require('../../views/CollectUserDataView/useFields.cjs');
|
|
@@ -33,8 +33,8 @@ import 'react-dom';
|
|
|
33
33
|
import '../WalletContext/WalletContext.js';
|
|
34
34
|
import '../ThemeContext/ThemeContext.js';
|
|
35
35
|
import '@dynamic-labs/types';
|
|
36
|
-
import '../LoadingContext/LoadingContext.js';
|
|
37
36
|
import '../AccountExistsContext/AccountExistsContext.js';
|
|
37
|
+
import '../LoadingContext/LoadingContext.js';
|
|
38
38
|
import 'yup';
|
|
39
39
|
import '../MockContext/MockContext.js';
|
|
40
40
|
import '../../views/CollectUserDataView/useFields.js';
|
|
@@ -37,8 +37,8 @@ require('../../events/dynamicEvents.cjs');
|
|
|
37
37
|
require('../WalletContext/WalletContext.cjs');
|
|
38
38
|
require('../ThemeContext/ThemeContext.cjs');
|
|
39
39
|
require('@dynamic-labs/types');
|
|
40
|
-
require('../LoadingContext/LoadingContext.cjs');
|
|
41
40
|
require('../AccountExistsContext/AccountExistsContext.cjs');
|
|
41
|
+
require('../LoadingContext/LoadingContext.cjs');
|
|
42
42
|
require('yup');
|
|
43
43
|
require('../MockContext/MockContext.cjs');
|
|
44
44
|
require('../../views/CollectUserDataView/useFields.cjs');
|
|
@@ -33,8 +33,8 @@ import '../../events/dynamicEvents.js';
|
|
|
33
33
|
import '../WalletContext/WalletContext.js';
|
|
34
34
|
import '../ThemeContext/ThemeContext.js';
|
|
35
35
|
import '@dynamic-labs/types';
|
|
36
|
-
import '../LoadingContext/LoadingContext.js';
|
|
37
36
|
import '../AccountExistsContext/AccountExistsContext.js';
|
|
37
|
+
import '../LoadingContext/LoadingContext.js';
|
|
38
38
|
import 'yup';
|
|
39
39
|
import '../MockContext/MockContext.js';
|
|
40
40
|
import '../../views/CollectUserDataView/useFields.js';
|
package/src/lib/data/api/api.cjs
CHANGED
|
@@ -21,7 +21,6 @@ require('../../utils/constants/colors.cjs');
|
|
|
21
21
|
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
22
22
|
require('../../shared/consts/index.cjs');
|
|
23
23
|
var getMinAuthToken = require('../../utils/functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
24
|
-
var getOnboardingAuthToken = require('../../utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.cjs');
|
|
25
24
|
require('react-international-phone');
|
|
26
25
|
require('viem');
|
|
27
26
|
require('viem/chains');
|
|
@@ -30,14 +29,13 @@ require('@dynamic-labs/store');
|
|
|
30
29
|
var isCookieEnabled = require('../../utils/functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
31
30
|
|
|
32
31
|
const sdkApi = () => {
|
|
33
|
-
var _a;
|
|
34
32
|
const settings = {
|
|
35
33
|
basePath: ApiEndpoint.getBaseUrl(),
|
|
36
34
|
headers: {
|
|
37
35
|
'Content-Type': 'application/json',
|
|
38
36
|
},
|
|
39
37
|
};
|
|
40
|
-
const minJwt =
|
|
38
|
+
const minJwt = getMinAuthToken.getMinAuthToken();
|
|
41
39
|
if (minJwt) {
|
|
42
40
|
settings.headers.Authorization = `Bearer ${minJwt}`;
|
|
43
41
|
}
|
package/src/lib/data/api/api.js
CHANGED
|
@@ -17,7 +17,6 @@ import '../../utils/constants/colors.js';
|
|
|
17
17
|
import '../../shared/utils/classes/storage/localStorage.js';
|
|
18
18
|
import '../../shared/consts/index.js';
|
|
19
19
|
import { getMinAuthToken } from '../../utils/functions/getMinAuthToken/getMinAuthToken.js';
|
|
20
|
-
import { getOnboardingAuthToken } from '../../utils/functions/getOnboardingAuthToken/getOnboardingAuthToken.js';
|
|
21
20
|
import 'react-international-phone';
|
|
22
21
|
import 'viem';
|
|
23
22
|
import 'viem/chains';
|
|
@@ -26,14 +25,13 @@ import '@dynamic-labs/store';
|
|
|
26
25
|
import { isCookieEnabled } from '../../utils/functions/isCookieEnabled/isCookieEnabled.js';
|
|
27
26
|
|
|
28
27
|
const sdkApi = () => {
|
|
29
|
-
var _a;
|
|
30
28
|
const settings = {
|
|
31
29
|
basePath: ApiEndpoint.getBaseUrl(),
|
|
32
30
|
headers: {
|
|
33
31
|
'Content-Type': 'application/json',
|
|
34
32
|
},
|
|
35
33
|
};
|
|
36
|
-
const minJwt =
|
|
34
|
+
const minJwt = getMinAuthToken();
|
|
37
35
|
if (minJwt) {
|
|
38
36
|
settings.headers.Authorization = `Bearer ${minJwt}`;
|
|
39
37
|
}
|
|
@@ -22,11 +22,12 @@ var storeAuthTokenAndUser = require('../../../store/utils/storeAuthTokenAndUser/
|
|
|
22
22
|
|
|
23
23
|
const updateUserProfileFields = (environmentId, fields) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
|
-
const
|
|
25
|
+
const response = yield api.sdkApi().updateSelf({
|
|
26
26
|
environmentId,
|
|
27
27
|
userFields: fields,
|
|
28
28
|
});
|
|
29
|
-
|
|
29
|
+
const userProfile = yield storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
30
|
+
return Object.assign(Object.assign({}, response), { userProfile });
|
|
30
31
|
}
|
|
31
32
|
catch (e) {
|
|
32
33
|
logger.logger.error(e);
|
|
@@ -44,8 +45,9 @@ const updateUserProfileFields = (environmentId, fields) => _tslib.__awaiter(void
|
|
|
44
45
|
else if (error.code === 'too_many_verification_attempts') {
|
|
45
46
|
throw new utils.TooManyEmailVerificationsError();
|
|
46
47
|
}
|
|
47
|
-
else if (error.code === 'invalid_phone'
|
|
48
|
-
|
|
48
|
+
else if (error.code === 'invalid_phone' ||
|
|
49
|
+
error.code === 'invalid_sms_verification') {
|
|
50
|
+
throw new utils.InvalidPhoneNumberError(error.error);
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
throw e;
|
|
@@ -82,10 +84,11 @@ const verifyMergeUsers = (environmentId, mergeConflictResolutions) => _tslib.__a
|
|
|
82
84
|
});
|
|
83
85
|
const refreshUserJwt = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
|
|
84
86
|
try {
|
|
85
|
-
const
|
|
87
|
+
const response = yield api.sdkApi().refreshAuth({
|
|
86
88
|
environmentId,
|
|
87
89
|
});
|
|
88
|
-
|
|
90
|
+
const user = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
91
|
+
return user;
|
|
89
92
|
}
|
|
90
93
|
catch (e) {
|
|
91
94
|
return undefined;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { UserFields, UpdateSelfResponse, MergeUserConflictResolution, SdkUser } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { UserProfile } from '../../../..';
|
|
3
|
-
export
|
|
3
|
+
export type UpdateUserResponse = UpdateSelfResponse & {
|
|
4
|
+
userProfile: UserProfile;
|
|
5
|
+
};
|
|
6
|
+
export declare const updateUserProfileFields: (environmentId: string, fields: UserFields) => Promise<UpdateUserResponse>;
|
|
4
7
|
export declare const mergeUserAccounts: (environmentId: string) => Promise<UserProfile>;
|
|
5
8
|
export declare const verifyMergeUsers: (environmentId: string, mergeConflictResolutions: MergeUserConflictResolution[]) => Promise<UserProfile>;
|
|
6
9
|
export declare const refreshUserJwt: ({ environmentId, }: {
|
|
7
10
|
environmentId: string;
|
|
8
|
-
}) => Promise<
|
|
9
|
-
jwt: string;
|
|
10
|
-
minifiedJwt: string;
|
|
11
|
-
} | undefined>;
|
|
11
|
+
}) => Promise<UserProfile | undefined>;
|
|
12
12
|
export declare const getAuthenticatedUser: ({ environmentId, }: {
|
|
13
13
|
environmentId: string;
|
|
14
14
|
}) => Promise<SdkUser | undefined>;
|
|
@@ -18,11 +18,12 @@ import { storeAuthTokenAndUser } from '../../../store/utils/storeAuthTokenAndUse
|
|
|
18
18
|
|
|
19
19
|
const updateUserProfileFields = (environmentId, fields) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
try {
|
|
21
|
-
const
|
|
21
|
+
const response = yield sdkApi().updateSelf({
|
|
22
22
|
environmentId,
|
|
23
23
|
userFields: fields,
|
|
24
24
|
});
|
|
25
|
-
|
|
25
|
+
const userProfile = yield storeAuthTokenAndUser(response);
|
|
26
|
+
return Object.assign(Object.assign({}, response), { userProfile });
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
29
|
logger.error(e);
|
|
@@ -40,8 +41,9 @@ const updateUserProfileFields = (environmentId, fields) => __awaiter(void 0, voi
|
|
|
40
41
|
else if (error.code === 'too_many_verification_attempts') {
|
|
41
42
|
throw new TooManyEmailVerificationsError();
|
|
42
43
|
}
|
|
43
|
-
else if (error.code === 'invalid_phone'
|
|
44
|
-
|
|
44
|
+
else if (error.code === 'invalid_phone' ||
|
|
45
|
+
error.code === 'invalid_sms_verification') {
|
|
46
|
+
throw new InvalidPhoneNumberError(error.error);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
throw e;
|
|
@@ -78,10 +80,11 @@ const verifyMergeUsers = (environmentId, mergeConflictResolutions) => __awaiter(
|
|
|
78
80
|
});
|
|
79
81
|
const refreshUserJwt = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, }) {
|
|
80
82
|
try {
|
|
81
|
-
const
|
|
83
|
+
const response = yield sdkApi().refreshAuth({
|
|
82
84
|
environmentId,
|
|
83
85
|
});
|
|
84
|
-
|
|
86
|
+
const user = storeAuthTokenAndUser(response);
|
|
87
|
+
return user;
|
|
85
88
|
}
|
|
86
89
|
catch (e) {
|
|
87
90
|
return undefined;
|
|
@@ -18,6 +18,7 @@ require('../../../utils/constants/values.cjs');
|
|
|
18
18
|
require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
var api = require('../api.cjs');
|
|
21
|
+
var storeAuthTokenAndUser = require('../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs');
|
|
21
22
|
|
|
22
23
|
const storeSelectedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ environmentId, walletId, }) {
|
|
23
24
|
try {
|
|
@@ -27,7 +28,8 @@ const storeSelectedWallet = (_a) => _tslib.__awaiter(void 0, [_a], void 0, funct
|
|
|
27
28
|
walletId,
|
|
28
29
|
},
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
+
const user = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
32
|
+
return user;
|
|
31
33
|
}
|
|
32
34
|
catch (e) {
|
|
33
35
|
logger.logger.error('error storing selected wallet', e);
|
|
@@ -69,7 +71,7 @@ const linkWallet = (environmentId_1, _b) => _tslib.__awaiter(void 0, [environmen
|
|
|
69
71
|
walletAddress: publicWalletAddress,
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
|
-
|
|
74
|
+
throw new utils.DynamicError(data.error);
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
77
|
const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
@@ -81,7 +83,8 @@ const unlinkWallet = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({
|
|
|
81
83
|
walletId,
|
|
82
84
|
},
|
|
83
85
|
});
|
|
84
|
-
|
|
86
|
+
const user = storeAuthTokenAndUser.storeAuthTokenAndUser(response);
|
|
87
|
+
return user;
|
|
85
88
|
}
|
|
86
89
|
catch (e) {
|
|
87
90
|
return undefined;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { VerifyResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { VerifyWallet } from '../../../shared/types';
|
|
3
|
+
import { UserProfile } from '../../../..';
|
|
3
4
|
export declare const storeSelectedWallet: ({ environmentId, walletId, }: {
|
|
4
5
|
environmentId: string;
|
|
5
6
|
walletId: string;
|
|
6
|
-
}) => Promise<
|
|
7
|
+
}) => Promise<UserProfile | undefined>;
|
|
7
8
|
export declare const linkWallet: (environmentId: string, { messageToSign, network, signedMessage, publicWalletAddress, chain, walletName, walletProvider, additionalWalletAddresses, backup, password, passwordSource, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
8
9
|
export declare const unlinkWallet: ({ environmentId, primaryWalletId, walletId, }: {
|
|
9
10
|
environmentId: string;
|
|
10
11
|
primaryWalletId: string | undefined;
|
|
11
12
|
walletId: string;
|
|
12
|
-
}) => Promise<
|
|
13
|
+
}) => Promise<UserProfile | undefined>;
|
|
13
14
|
export declare const transferWallet: (environmentId: string, { network, messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, skipEmptyAccountCheck, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
14
15
|
export declare const verifyWallet: (environmentId: string, { messageToSign, signedMessage, publicWalletAddress, chain, walletName, walletProvider, captchaToken, network, oauth, additionalWalletAddresses, }: VerifyWallet) => Promise<VerifyResponse | undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { VerifyRequestFromJSON } from '@dynamic-labs/sdk-api-core';
|
|
4
|
-
import { WalletUsedError, MergeAccountsConfirmationError, WalletNotDeployedError, ChainalysisError, GateBlockedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
4
|
+
import { WalletUsedError, MergeAccountsConfirmationError, DynamicError, WalletNotDeployedError, ChainalysisError, GateBlockedError, NoAccessError, AccountExistsError } from '@dynamic-labs/utils';
|
|
5
5
|
import { logger } from '../../../shared/logger.js';
|
|
6
6
|
import '@dynamic-labs/iconic';
|
|
7
7
|
import '@dynamic-labs/wallet-connector-core';
|
|
@@ -14,6 +14,7 @@ import '../../../utils/constants/values.js';
|
|
|
14
14
|
import '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import { sdkApi } from '../api.js';
|
|
17
|
+
import { storeAuthTokenAndUser } from '../../../store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js';
|
|
17
18
|
|
|
18
19
|
const storeSelectedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({ environmentId, walletId, }) {
|
|
19
20
|
try {
|
|
@@ -23,7 +24,8 @@ const storeSelectedWallet = (_a) => __awaiter(void 0, [_a], void 0, function* ({
|
|
|
23
24
|
walletId,
|
|
24
25
|
},
|
|
25
26
|
});
|
|
26
|
-
|
|
27
|
+
const user = storeAuthTokenAndUser(response);
|
|
28
|
+
return user;
|
|
27
29
|
}
|
|
28
30
|
catch (e) {
|
|
29
31
|
logger.error('error storing selected wallet', e);
|
|
@@ -65,7 +67,7 @@ const linkWallet = (environmentId_1, _b) => __awaiter(void 0, [environmentId_1,
|
|
|
65
67
|
walletAddress: publicWalletAddress,
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
|
-
|
|
70
|
+
throw new DynamicError(data.error);
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
73
|
const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ environmentId, primaryWalletId, walletId, }) {
|
|
@@ -77,7 +79,8 @@ const unlinkWallet = (_c) => __awaiter(void 0, [_c], void 0, function* ({ enviro
|
|
|
77
79
|
walletId,
|
|
78
80
|
},
|
|
79
81
|
});
|
|
80
|
-
|
|
82
|
+
const user = storeAuthTokenAndUser(response);
|
|
83
|
+
return user;
|
|
81
84
|
}
|
|
82
85
|
catch (e) {
|
|
83
86
|
return undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AuthMethod, AuthOptions } from '@dynamic-labs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Maps auth methods to what property will be displayed under the "option" property of the event.
|
|
4
|
+
*
|
|
5
|
+
* Users will be able to access this data through the AuthOptions[K] type injection as well,
|
|
6
|
+
* but with the "option" property they will also have a standard way to access the auth method target.
|
|
7
|
+
*/
|
|
8
|
+
type AuthEventPayloadOptionMap = {
|
|
9
|
+
wallet: AuthOptions['wallet']['connectorName'];
|
|
10
|
+
sms: AuthOptions['sms']['phone'];
|
|
11
|
+
email: AuthOptions['email']['email'];
|
|
12
|
+
social: AuthOptions['social']['provider'];
|
|
13
|
+
};
|
|
14
|
+
/** Payload of auth events that provide insight into which auth method was selected */
|
|
15
|
+
export type AuthEventPayload = {
|
|
16
|
+
[K in AuthMethod]: {
|
|
17
|
+
type: K;
|
|
18
|
+
option: AuthEventPayloadOptionMap[K];
|
|
19
|
+
} & AuthOptions[K];
|
|
20
|
+
}[AuthMethod];
|
|
21
|
+
export type AuthEvents = {
|
|
22
|
+
/**
|
|
23
|
+
* Informs an auth attempt failed.
|
|
24
|
+
* In general triggered when an error occurs or when user cancels out.
|
|
25
|
+
* For email/sms, specifically happens when users cancels the OTP verification.
|
|
26
|
+
*/
|
|
27
|
+
authFailure: (method: AuthEventPayload,
|
|
28
|
+
/** Will be 'user-cancelled' when cancelled, or the error when there is an error */
|
|
29
|
+
reason: 'user-cancelled' | {
|
|
30
|
+
error: unknown;
|
|
31
|
+
}) => void;
|
|
32
|
+
/** Informs an auth attempt initialized, and provides insight into which auth option it is */
|
|
33
|
+
authInit: (method: AuthEventPayload) => void;
|
|
34
|
+
logout: () => void;
|
|
35
|
+
/** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */
|
|
36
|
+
triggerLogout: () => void;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { AuthEvents } from './auth';
|
|
3
|
+
import { EmbeddedWalletEvents } from './embeddedWallet';
|
|
4
|
+
import { OTPEvents } from './otp';
|
|
5
|
+
import { PasskeyEvents } from './passkey';
|
|
6
|
+
import { SocialEvents } from './social';
|
|
7
|
+
import { UIEvents } from './ui';
|
|
8
|
+
import { WalletEvents } from './wallets';
|
|
5
9
|
/** Maps internal event names to their listeners */
|
|
6
|
-
export type DynamicEvents =
|
|
7
|
-
authFlowOpen: () => void;
|
|
8
|
-
/** Triggered when auth is closed before reaching success (due to user cancel or fail) */
|
|
9
|
-
authFlowClose: () => void;
|
|
10
|
-
/** Triggered when auth is attempted but fails, like when user rejects connection or the network call fails */
|
|
11
|
-
authFlowCancelled: () => void;
|
|
12
|
-
emailVerificationResult: (param: boolean, email: string) => void;
|
|
13
|
-
smsVerificationResult: (param: boolean, phone: PhoneData) => void;
|
|
14
|
-
embeddedWalletCreated: (wallet: Wallet, verifiedCredential: JwtVerifiedCredential | undefined, authToken: string | undefined) => void;
|
|
15
|
-
embeddedWalletFailed: (error: unknown) => void;
|
|
16
|
-
passkeyRecoveryCompleted: (wallet: Wallet) => void;
|
|
17
|
-
passkeyRecoveryFailed: (error: unknown) => void;
|
|
18
|
-
embeddedWalletRevealCompleted: (wallet: Wallet) => void;
|
|
19
|
-
embeddedWalletRevealFailed: (error: unknown) => void;
|
|
20
|
-
embeddedWalletCreatePasswordCompleted: (password: string) => void;
|
|
21
|
-
embeddedWalletCreatePasswordFailed: (error: unknown) => void;
|
|
22
|
-
embeddedWalletRecoveryEmailCompleted: (email: string) => void;
|
|
23
|
-
embeddedWalletRecoveryEmailFailed: (error: unknown) => void;
|
|
24
|
-
embeddedWalletUpdatePasswordCompleted: (password: string) => void;
|
|
25
|
-
embeddedWalletUpdatePasswordFailed: (error: unknown) => void;
|
|
26
|
-
logout: () => void;
|
|
27
|
-
/** Triggered when a new wallet is added to user wallets list */
|
|
28
|
-
walletAdded: (wallet: Wallet, userWallets: Wallet[]) => void;
|
|
29
|
-
/** Triggered when a wallet is removed from user wallets list */
|
|
30
|
-
walletRemoved: (wallet: Wallet, userWallets: Wallet[]) => void;
|
|
31
|
-
/** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */
|
|
32
|
-
triggerLogout: () => void;
|
|
33
|
-
farcasterConnectCancelled: () => void;
|
|
34
|
-
};
|
|
10
|
+
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents;
|
|
35
11
|
export declare const dynamicEvents: EventEmitter<DynamicEvents, any>;
|
|
36
12
|
export type DynamicEventEmitter = typeof dynamicEvents;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { Wallet } from '../shared/types/wallets';
|
|
3
|
+
export type EmbeddedWalletEvents = {
|
|
4
|
+
embeddedWalletCreated: (wallet: Wallet, verifiedCredential: JwtVerifiedCredential | undefined, authToken: string | undefined) => void;
|
|
5
|
+
embeddedWalletFailed: (error: unknown) => void;
|
|
6
|
+
embeddedWalletRevealCompleted: (wallet: Wallet) => void;
|
|
7
|
+
embeddedWalletRevealFailed: (error: unknown) => void;
|
|
8
|
+
embeddedWalletCreatePasswordCompleted: (password: string) => void;
|
|
9
|
+
embeddedWalletCreatePasswordFailed: (error: unknown) => void;
|
|
10
|
+
embeddedWalletRecoveryEmailCompleted: (email: string) => void;
|
|
11
|
+
embeddedWalletRecoveryEmailFailed: (error: unknown) => void;
|
|
12
|
+
embeddedWalletUpdatePasswordCompleted: (password: string) => void;
|
|
13
|
+
embeddedWalletUpdatePasswordFailed: (error: unknown) => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type UIEvents = {
|
|
2
|
+
authFlowOpen: () => void;
|
|
3
|
+
/** Triggered when auth is closed before reaching success (due to user cancel or fail) */
|
|
4
|
+
authFlowClose: () => void;
|
|
5
|
+
/**
|
|
6
|
+
* Triggered alongside authFlowClose when auth is attempted but fails
|
|
7
|
+
* like when user rejects connection or the network call fails
|
|
8
|
+
*/
|
|
9
|
+
authFlowCancelled: () => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Wallet } from '../shared/types/wallets';
|
|
2
|
+
export type WalletEvents = {
|
|
3
|
+
/** Triggered when a new wallet is added to user wallets list */
|
|
4
|
+
walletAdded: (wallet: Wallet, userWallets: Wallet[]) => void;
|
|
5
|
+
/** Triggered when a wallet is removed from user wallets list */
|
|
6
|
+
walletRemoved: (wallet: Wallet, userWallets: Wallet[]) => void;
|
|
7
|
+
};
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
8
9
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
9
10
|
require('../../../../../_virtual/_tslib.cjs');
|
|
10
11
|
require('@dynamic-labs/utils');
|
|
11
12
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
12
|
-
require('@dynamic-labs/sdk-api-core');
|
|
13
13
|
require('../../../shared/logger.cjs');
|
|
14
14
|
require('@dynamic-labs/iconic');
|
|
15
15
|
require('@dynamic-labs/wallet-connector-core');
|
|
@@ -103,6 +103,11 @@ const Header = ({ onClose: handleClose, heading, projectSettings, copykey, }) =>
|
|
|
103
103
|
if (view.type === 'farcaster-connect-view') {
|
|
104
104
|
setSocialProvider(undefined);
|
|
105
105
|
dynamicEvents.dynamicEvents.emit('farcasterConnectCancelled');
|
|
106
|
+
dynamicEvents.dynamicEvents.emit('authFailure', {
|
|
107
|
+
option: sdkApiCore.ProviderEnum.Farcaster,
|
|
108
|
+
provider: sdkApiCore.ProviderEnum.Farcaster,
|
|
109
|
+
type: 'social',
|
|
110
|
+
}, 'user-cancelled');
|
|
106
111
|
}
|
|
107
112
|
setExistentAccountData(undefined);
|
|
108
113
|
setError(undefined);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
|
+
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
5
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
5
6
|
import '../../../../../_virtual/_tslib.js';
|
|
6
7
|
import '@dynamic-labs/utils';
|
|
7
8
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
8
|
-
import '@dynamic-labs/sdk-api-core';
|
|
9
9
|
import '../../../shared/logger.js';
|
|
10
10
|
import '@dynamic-labs/iconic';
|
|
11
11
|
import '@dynamic-labs/wallet-connector-core';
|
|
@@ -99,6 +99,11 @@ const Header = ({ onClose: handleClose, heading, projectSettings, copykey, }) =>
|
|
|
99
99
|
if (view.type === 'farcaster-connect-view') {
|
|
100
100
|
setSocialProvider(undefined);
|
|
101
101
|
dynamicEvents.emit('farcasterConnectCancelled');
|
|
102
|
+
dynamicEvents.emit('authFailure', {
|
|
103
|
+
option: ProviderEnum.Farcaster,
|
|
104
|
+
provider: ProviderEnum.Farcaster,
|
|
105
|
+
type: 'social',
|
|
106
|
+
}, 'user-cancelled');
|
|
102
107
|
}
|
|
103
108
|
setExistentAccountData(undefined);
|
|
104
109
|
setError(undefined);
|