@dynamic-labs/sdk-react-core 1.0.0-alpha.7 → 1.0.0-alpha.8
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 +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/lib/components/NeedHelpSection/NeedHelpSection.cjs +1 -1
- package/src/lib/components/NeedHelpSection/NeedHelpSection.js +1 -1
- package/src/lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs +68 -0
- package/src/lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.d.ts +6 -0
- package/src/lib/components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js +64 -0
- package/src/lib/components/PasskeyCreatedSuccessBanner/index.d.ts +1 -0
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.cjs +24 -0
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.d.ts +6 -0
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.js +20 -0
- package/src/lib/components/SecureTurnkeyWalletCard/index.d.ts +1 -0
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +4 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +4 -1
- package/src/lib/components/SyncPasskeyFlow/SyncPasskeyFlow.cjs +5 -2
- package/src/lib/components/SyncPasskeyFlow/SyncPasskeyFlow.js +5 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +6 -2
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +6 -2
- package/src/lib/components/index.d.ts +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +7 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +7 -1
- package/src/lib/context/DynamicContext/hooks/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useShowPasskeyCreateSuccess/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/hooks/useShowPasskeyCreateSuccess/useShowPasskeyCreateSuccess.cjs +23 -0
- package/src/lib/context/DynamicContext/hooks/useShowPasskeyCreateSuccess/useShowPasskeyCreateSuccess.d.ts +4 -0
- package/src/lib/context/DynamicContext/hooks/useShowPasskeyCreateSuccess/useShowPasskeyCreateSuccess.js +19 -0
- package/src/lib/context/DynamicContext/types/index.d.ts +2 -0
- package/src/lib/data/api.cjs +14 -11
- package/src/lib/data/api.d.ts +2 -2
- package/src/lib/data/api.js +14 -11
- package/src/lib/locale/en/translation.cjs +70 -0
- package/src/lib/locale/en/translation.d.ts +70 -0
- package/src/lib/locale/en/translation.js +70 -0
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.cjs +6 -2
- package/src/lib/modals/SignMessageConfirmationModal/SignMessageConfirmationModal.js +6 -2
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/index.d.ts +1 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs +83 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.d.ts +15 -0
- package/src/lib/utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js +79 -0
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.cjs +11 -3
- package/src/lib/utils/hooks/useDynamicLayoutData/useDynamicLayoutData.js +11 -3
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +57 -33
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +1 -1
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +57 -33
- package/src/lib/utils/hooks/useIsTurnkeyWallet/index.d.ts +1 -0
- package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs +37 -0
- package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.d.ts +6 -0
- package/src/lib/utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js +33 -0
- package/src/lib/views/AccountExistsView/AccountExistsView.cjs +1 -1
- package/src/lib/views/AccountExistsView/AccountExistsView.js +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +1 -1
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +1 -1
- package/src/lib/views/LoginView/sections/SocialSignInSection/MagicSocialSignIn/MagicSocialSignIn.cjs +1 -1
- package/src/lib/views/LoginView/sections/SocialSignInSection/MagicSocialSignIn/MagicSocialSignIn.js +1 -1
- package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.cjs +2 -5
- package/src/lib/views/LoginView/sections/SocialSignInSection/SocialSignInSection.js +2 -5
- package/src/lib/views/LoginView/useLoginView.cjs +101 -84
- package/src/lib/views/LoginView/useLoginView.js +102 -85
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.cjs +20 -50
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.d.ts +1 -6
- package/src/lib/views/Passkey/PasskeyIntroView/PasskeyIntroView.js +20 -50
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.cjs +7 -2
- package/src/lib/views/Passkey/PasskeyRecovery/BundleValidation/PasskeyBundleRecovery.js +7 -2
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.cjs +11 -7
- package/src/lib/views/Passkey/PasskeyRecovery/CompleteRecovery/PasskeyCompleteRecovery.js +11 -7
- package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.cjs +8 -10
- package/src/lib/views/Passkey/PasskeyRecovery/InitRecovery/PasskeyInitRecovery.js +8 -10
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.cjs +56 -0
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.d.ts +13 -0
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/createPregeneratedWallet.js +52 -0
- package/src/lib/views/Passkey/utils/createPregeneratedWallet/index.d.ts +1 -0
- package/src/lib/views/Passkey/utils/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +1 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +4 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +4 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js +2 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.cjs +8 -5
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetWalletHeader/DynamicWidgetWalletHeader.js +8 -5
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +1 -1
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.cjs +11 -2
- package/src/lib/widgets/DynamicWidget/components/EmptyWallets/EmptyWallets.js +11 -2
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/ManagePasskeysWidgetView.cjs +2 -1
- package/src/lib/widgets/DynamicWidget/views/ManagePasskeysWidgetView/ManagePasskeysWidgetView.js +2 -1
- package/src/lib/utils/functions/getEnabledProviders/index.cjs +0 -7
- package/src/lib/utils/functions/getEnabledProviders/index.js +0 -3
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
var React = require('react');
|
|
8
7
|
var reactI18next = require('react-i18next');
|
|
@@ -10,24 +9,23 @@ var utils = require('@dynamic-labs/utils');
|
|
|
10
9
|
var useInternalDynamicContext = require('../../../context/DynamicContext/useInternalDynamicContext.cjs');
|
|
11
10
|
require('@dynamic-labs/sdk-api');
|
|
12
11
|
require('../../../config/ApiEndpoint.cjs');
|
|
13
|
-
var
|
|
12
|
+
var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
14
13
|
require('@dynamic-labs/iconic');
|
|
15
14
|
require('@dynamic-labs/wallet-connector-core');
|
|
16
15
|
require('../../../context/ViewContext/ViewContext.cjs');
|
|
17
16
|
var passkeyIntroIcon = require('../../../shared/assets/passkey-intro-icon.cjs');
|
|
18
17
|
var questionMark = require('../../../shared/assets/question-mark.cjs');
|
|
18
|
+
require('../../../shared/logger.cjs');
|
|
19
19
|
require('@dynamic-labs/wallet-book');
|
|
20
20
|
var localStorage$1 = require('../../../utils/constants/localStorage.cjs');
|
|
21
21
|
require('../../../utils/constants/colors.cjs');
|
|
22
22
|
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
23
23
|
require('viem');
|
|
24
24
|
require('../../../shared/consts/index.cjs');
|
|
25
|
+
var getAuthToken = require('../../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
25
26
|
require('@dynamic-labs/multi-wallet');
|
|
26
27
|
require('@dynamic-labs/rpc-providers');
|
|
27
28
|
require('../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
28
|
-
var createUserProfile = require('../../../utils/functions/createUserProfile/createUserProfile.cjs');
|
|
29
|
-
var index$1 = require('../../../utils/functions/storeAuthToken/index.cjs');
|
|
30
|
-
var smartWallet = require('../../../utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.cjs');
|
|
31
29
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
32
30
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
33
31
|
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
@@ -56,6 +54,7 @@ require('yup');
|
|
|
56
54
|
var ErrorContainer = require('../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
57
55
|
require('../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
58
56
|
require('@dynamic-labs/types');
|
|
57
|
+
var useCreateDynamicEmbeddedWalletMutation = require('../../../utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.cjs');
|
|
59
58
|
require('../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
60
59
|
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
61
60
|
require('formik');
|
|
@@ -65,7 +64,6 @@ var IconButton = require('../../../components/IconButton/IconButton.cjs');
|
|
|
65
64
|
require('../../../components/Alert/Alert.cjs');
|
|
66
65
|
require('../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
67
66
|
var getProperErrorMessage = require('../../../modals/SignMessageConfirmationModal/getProperErrorMessage.cjs');
|
|
68
|
-
var useMutation = require('../../../utils/hooks/useMutation/useMutation.cjs');
|
|
69
67
|
var TextButton = require('../../../components/TextButton/TextButton.cjs');
|
|
70
68
|
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
71
69
|
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
@@ -73,60 +71,32 @@ require('../../../components/Popper/Popper/Popper.cjs');
|
|
|
73
71
|
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
74
72
|
require('react-focus-lock');
|
|
75
73
|
var isPasskeyEnabled = require('../../../utils/functions/isPasskeyEnabled/isPasskeyEnabled.cjs');
|
|
76
|
-
var createEmbeddedWalletWithPasskey = require('../utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.cjs');
|
|
77
|
-
var findPasskeyEmailWalletConnector = require('../utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.cjs');
|
|
78
74
|
var PasskeyDeviceIcon = require('../PasskeyDeviceIcon/PasskeyDeviceIcon.cjs');
|
|
79
75
|
|
|
80
|
-
const PasskeyIntroView = (
|
|
81
|
-
const {
|
|
76
|
+
const PasskeyIntroView = () => {
|
|
77
|
+
const { wallets, environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext.useInternalDynamicContext();
|
|
82
78
|
const { setIsFooterExpanded } = index.useFooterAnimationContext();
|
|
83
79
|
const { t } = reactI18next.useTranslation();
|
|
84
80
|
const { data: passkeyEnabled } = usePromise.usePromise(isPasskeyEnabled.isPasskeyEnabled);
|
|
85
81
|
// if passkey is not yet setup, but user logged in with email in a passkey env
|
|
86
82
|
// it should be null to force user to setup passkey even after the a refresh
|
|
87
83
|
React.useEffect(() => localStorage.LocalStorage.removeFromLS(localStorage$1.LAST_USED_WALLET), []);
|
|
88
|
-
const {
|
|
84
|
+
const { createDynamicEmbeddedWalletMutation, isLoading, error } = useCreateDynamicEmbeddedWalletMutation.useCreateDynamicEmbeddedWalletMutation();
|
|
85
|
+
const handleCreateEmbeddedWallet = () => {
|
|
89
86
|
var _a;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
walletConnector: findPasskeyEmailWalletConnector.findPasskeyEmailWalletConnector(wallets),
|
|
95
|
-
});
|
|
96
|
-
const passkeyWallet = {
|
|
97
|
-
address: (yield walletConnector.fetchPublicAddress()) || '',
|
|
98
|
-
chain: walletConnector.connectedChain || '',
|
|
99
|
-
connected: true,
|
|
100
|
-
connector: walletConnector,
|
|
101
|
-
id: embeddedWalletVerifiedCredential.id,
|
|
102
|
-
};
|
|
103
|
-
internalEvents.current.emit('embeddedWalletCreated', passkeyWallet);
|
|
104
|
-
const smartWallet$1 = smartWallet.findSmartWallet(embeddedWalletVerifiedCredential, decodedJwt.verifiedCredentials);
|
|
105
|
-
if (smartWallet$1) {
|
|
106
|
-
yield smartWallet.initializeSmartWallet({
|
|
107
|
-
account: smartWallet$1,
|
|
108
|
-
verifiedCredentials: decodedJwt.verifiedCredentials,
|
|
109
|
-
walletOptions: wallets,
|
|
110
|
-
});
|
|
111
|
-
setPrimaryWalletId(smartWallet$1.id);
|
|
87
|
+
const jwt = (_a = getAuthToken.getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
88
|
+
const decodedJwt = decodeJwt.decodeJwt(jwt);
|
|
89
|
+
if (!jwt || !decodedJwt) {
|
|
90
|
+
throw new Error('User is not logged in');
|
|
112
91
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const turnkeyVerifiedCredentials = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
|
|
120
|
-
setCallback('embeddedWalletCreated', {
|
|
121
|
-
email: (turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.email) || '',
|
|
122
|
-
verifiedCredential: turnkeyVerifiedCredentials,
|
|
92
|
+
createDynamicEmbeddedWalletMutation({
|
|
93
|
+
authToken: jwt,
|
|
94
|
+
decodedJwt,
|
|
95
|
+
environmentId,
|
|
96
|
+
wallets,
|
|
97
|
+
withAuthenticator: true,
|
|
123
98
|
});
|
|
124
|
-
}
|
|
125
|
-
onFailure: (err) => {
|
|
126
|
-
logger.logger.error('Failed to create embedded wallet', err);
|
|
127
|
-
internalEvents.current.emit('embeddedWalletFailed', err);
|
|
128
|
-
},
|
|
129
|
-
});
|
|
99
|
+
};
|
|
130
100
|
const errorText = React.useMemo(() => {
|
|
131
101
|
if (!error) {
|
|
132
102
|
return undefined;
|
|
@@ -137,7 +107,7 @@ const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletW
|
|
|
137
107
|
return getProperErrorMessage.getProperErrorMessage(error);
|
|
138
108
|
}, [error]);
|
|
139
109
|
const infoIconButton = (jsxRuntime.jsx(Tooltip.Tooltip, { content: t('dyn_passkey_intro.helper.tooltip'), className: 'header__tooltip', children: jsxRuntime.jsx(IconButton.IconButton, { type: 'button', "data-testid": 'info-button', onClick: () => setIsFooterExpanded((prev) => !prev), className: 'header__icon', children: jsxRuntime.jsx(questionMark.ReactComponent, {}) }) }, 'info-button'));
|
|
140
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: infoIconButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: t('dyn_passkey_intro.title') }) }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view', children: [jsxRuntime.jsx("div", { className: 'passkey-intro-view__header', children: jsxRuntime.jsx(passkeyIntroIcon.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', children: t('dyn_passkey_intro.subtitle') }), passkeyEnabled === false && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: t('dyn_passkey_intro.disabled') })), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view__actions', children: [jsxRuntime.jsx(Button.Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick:
|
|
110
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: infoIconButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: t('dyn_passkey_intro.title') }) }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view', children: [jsxRuntime.jsx("div", { className: 'passkey-intro-view__header', children: jsxRuntime.jsx(passkeyIntroIcon.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', children: t('dyn_passkey_intro.subtitle') }), passkeyEnabled === false && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: t('dyn_passkey_intro.disabled') })), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsxs("div", { className: 'passkey-intro-view__actions', children: [jsxRuntime.jsx(Button.Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick: handleCreateEmbeddedWallet, dataTestId: 'setup-passkey-button', loading: isLoading, disabled: isLoading || !passkeyEnabled, typographyProps: {
|
|
141
111
|
color: 'inherit',
|
|
142
112
|
}, children: jsxRuntime.jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, {}), jsxRuntime.jsx(Typography.Typography, { children: t('dyn_passkey_intro.button') })] }) }), jsxRuntime.jsx(TextButton.TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, children: t('dyn_passkey_intro.button_logout') })] })] })] }));
|
|
143
113
|
};
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
type PasskeyIntroViewProps = {
|
|
4
|
-
createEmbeddedWalletMutation?: typeof createEmbeddedWalletWithPasskey;
|
|
5
|
-
};
|
|
6
|
-
export declare const PasskeyIntroView: FC<PasskeyIntroViewProps>;
|
|
7
|
-
export {};
|
|
2
|
+
export declare const PasskeyIntroView: FC;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
2
|
import { useEffect, useMemo } from 'react';
|
|
4
3
|
import { useTranslation } from 'react-i18next';
|
|
@@ -6,24 +5,23 @@ import { DynamicError } from '@dynamic-labs/utils';
|
|
|
6
5
|
import { useInternalDynamicContext } from '../../../context/DynamicContext/useInternalDynamicContext.js';
|
|
7
6
|
import '@dynamic-labs/sdk-api';
|
|
8
7
|
import '../../../config/ApiEndpoint.js';
|
|
9
|
-
import {
|
|
8
|
+
import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
|
|
10
9
|
import '@dynamic-labs/iconic';
|
|
11
10
|
import '@dynamic-labs/wallet-connector-core';
|
|
12
11
|
import '../../../context/ViewContext/ViewContext.js';
|
|
13
12
|
import { ReactComponent as SvgPasskeyIntroIcon } from '../../../shared/assets/passkey-intro-icon.js';
|
|
14
13
|
import { ReactComponent as SvgQuestionMark } from '../../../shared/assets/question-mark.js';
|
|
14
|
+
import '../../../shared/logger.js';
|
|
15
15
|
import '@dynamic-labs/wallet-book';
|
|
16
16
|
import { LAST_USED_WALLET } from '../../../utils/constants/localStorage.js';
|
|
17
17
|
import '../../../utils/constants/colors.js';
|
|
18
18
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
19
19
|
import 'viem';
|
|
20
20
|
import '../../../shared/consts/index.js';
|
|
21
|
+
import { getAuthToken } from '../../../utils/functions/getAuthToken/getAuthToken.js';
|
|
21
22
|
import '@dynamic-labs/multi-wallet';
|
|
22
23
|
import '@dynamic-labs/rpc-providers';
|
|
23
24
|
import '../../../utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
24
|
-
import { createUserProfile } from '../../../utils/functions/createUserProfile/createUserProfile.js';
|
|
25
|
-
import { storeAuthToken } from '../../../utils/functions/storeAuthToken/index.js';
|
|
26
|
-
import { findSmartWallet, initializeSmartWallet } from '../../../utils/hooks/useWalletConnectors/utils/smartWallet/smartWallet.js';
|
|
27
25
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
28
26
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
29
27
|
import '../../../context/ErrorContext/ErrorContext.js';
|
|
@@ -52,6 +50,7 @@ import 'yup';
|
|
|
52
50
|
import { ErrorContainer } from '../../../components/ErrorContainer/ErrorContainer.js';
|
|
53
51
|
import '../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
54
52
|
import '@dynamic-labs/types';
|
|
53
|
+
import { useCreateDynamicEmbeddedWalletMutation } from '../../../utils/hooks/useCreateDynamicEmbeddedWalletMutation/useCreateDynamicEmbeddedWalletMutation.js';
|
|
55
54
|
import '../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
56
55
|
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
57
56
|
import 'formik';
|
|
@@ -61,7 +60,6 @@ import { IconButton } from '../../../components/IconButton/IconButton.js';
|
|
|
61
60
|
import '../../../components/Alert/Alert.js';
|
|
62
61
|
import '../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
63
62
|
import { getProperErrorMessage } from '../../../modals/SignMessageConfirmationModal/getProperErrorMessage.js';
|
|
64
|
-
import { useMutation } from '../../../utils/hooks/useMutation/useMutation.js';
|
|
65
63
|
import { TextButton } from '../../../components/TextButton/TextButton.js';
|
|
66
64
|
import '../../../components/InlineWidget/InlineWidget.js';
|
|
67
65
|
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
@@ -69,60 +67,32 @@ import '../../../components/Popper/Popper/Popper.js';
|
|
|
69
67
|
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
70
68
|
import 'react-focus-lock';
|
|
71
69
|
import { isPasskeyEnabled } from '../../../utils/functions/isPasskeyEnabled/isPasskeyEnabled.js';
|
|
72
|
-
import { createEmbeddedWalletWithPasskey } from '../utils/createEmbeddedWalletWithPasskey/createEmbeddedWalletWithPasskey.js';
|
|
73
|
-
import { findPasskeyEmailWalletConnector } from '../utils/findPasskeyEmailWalletConnector/findPasskeyEmailWalletConnector.js';
|
|
74
70
|
import { PasskeyDeviceIcon } from '../PasskeyDeviceIcon/PasskeyDeviceIcon.js';
|
|
75
71
|
|
|
76
|
-
const PasskeyIntroView = (
|
|
77
|
-
const {
|
|
72
|
+
const PasskeyIntroView = () => {
|
|
73
|
+
const { wallets, environmentId, handleLogOut, onboardingOnlyJwt } = useInternalDynamicContext();
|
|
78
74
|
const { setIsFooterExpanded } = useFooterAnimationContext();
|
|
79
75
|
const { t } = useTranslation();
|
|
80
76
|
const { data: passkeyEnabled } = usePromise(isPasskeyEnabled);
|
|
81
77
|
// if passkey is not yet setup, but user logged in with email in a passkey env
|
|
82
78
|
// it should be null to force user to setup passkey even after the a refresh
|
|
83
79
|
useEffect(() => LocalStorage.removeFromLS(LAST_USED_WALLET), []);
|
|
84
|
-
const {
|
|
80
|
+
const { createDynamicEmbeddedWalletMutation, isLoading, error } = useCreateDynamicEmbeddedWalletMutation();
|
|
81
|
+
const handleCreateEmbeddedWallet = () => {
|
|
85
82
|
var _a;
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
walletConnector: findPasskeyEmailWalletConnector(wallets),
|
|
91
|
-
});
|
|
92
|
-
const passkeyWallet = {
|
|
93
|
-
address: (yield walletConnector.fetchPublicAddress()) || '',
|
|
94
|
-
chain: walletConnector.connectedChain || '',
|
|
95
|
-
connected: true,
|
|
96
|
-
connector: walletConnector,
|
|
97
|
-
id: embeddedWalletVerifiedCredential.id,
|
|
98
|
-
};
|
|
99
|
-
internalEvents.current.emit('embeddedWalletCreated', passkeyWallet);
|
|
100
|
-
const smartWallet = findSmartWallet(embeddedWalletVerifiedCredential, decodedJwt.verifiedCredentials);
|
|
101
|
-
if (smartWallet) {
|
|
102
|
-
yield initializeSmartWallet({
|
|
103
|
-
account: smartWallet,
|
|
104
|
-
verifiedCredentials: decodedJwt.verifiedCredentials,
|
|
105
|
-
walletOptions: wallets,
|
|
106
|
-
});
|
|
107
|
-
setPrimaryWalletId(smartWallet.id);
|
|
83
|
+
const jwt = (_a = getAuthToken()) !== null && _a !== void 0 ? _a : onboardingOnlyJwt;
|
|
84
|
+
const decodedJwt = decodeJwt(jwt);
|
|
85
|
+
if (!jwt || !decodedJwt) {
|
|
86
|
+
throw new Error('User is not logged in');
|
|
108
87
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const turnkeyVerifiedCredentials = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'));
|
|
116
|
-
setCallback('embeddedWalletCreated', {
|
|
117
|
-
email: (turnkeyVerifiedCredentials === null || turnkeyVerifiedCredentials === void 0 ? void 0 : turnkeyVerifiedCredentials.email) || '',
|
|
118
|
-
verifiedCredential: turnkeyVerifiedCredentials,
|
|
88
|
+
createDynamicEmbeddedWalletMutation({
|
|
89
|
+
authToken: jwt,
|
|
90
|
+
decodedJwt,
|
|
91
|
+
environmentId,
|
|
92
|
+
wallets,
|
|
93
|
+
withAuthenticator: true,
|
|
119
94
|
});
|
|
120
|
-
}
|
|
121
|
-
onFailure: (err) => {
|
|
122
|
-
logger.error('Failed to create embedded wallet', err);
|
|
123
|
-
internalEvents.current.emit('embeddedWalletFailed', err);
|
|
124
|
-
},
|
|
125
|
-
});
|
|
95
|
+
};
|
|
126
96
|
const errorText = useMemo(() => {
|
|
127
97
|
if (!error) {
|
|
128
98
|
return undefined;
|
|
@@ -133,7 +103,7 @@ const PasskeyIntroView = ({ createEmbeddedWalletMutation = createEmbeddedWalletW
|
|
|
133
103
|
return getProperErrorMessage(error);
|
|
134
104
|
}, [error]);
|
|
135
105
|
const infoIconButton = (jsx(Tooltip, { content: t('dyn_passkey_intro.helper.tooltip'), className: 'header__tooltip', children: jsx(IconButton, { type: 'button', "data-testid": 'info-button', onClick: () => setIsFooterExpanded((prev) => !prev), className: 'header__icon', children: jsx(SvgQuestionMark, {}) }) }, 'info-button'));
|
|
136
|
-
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: infoIconButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: t('dyn_passkey_intro.title') }) }), jsxs("div", { className: 'passkey-intro-view', children: [jsx("div", { className: 'passkey-intro-view__header', children: jsx(SvgPasskeyIntroIcon, {}) }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', children: t('dyn_passkey_intro.subtitle') }), passkeyEnabled === false && (jsx(ErrorContainer, { children: t('dyn_passkey_intro.disabled') })), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'passkey-intro-view__actions', children: [jsx(Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick:
|
|
106
|
+
return (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: infoIconButton, children: jsx(Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: t('dyn_passkey_intro.title') }) }), jsxs("div", { className: 'passkey-intro-view', children: [jsx("div", { className: 'passkey-intro-view__header', children: jsx(SvgPasskeyIntroIcon, {}) }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-intro-view__subtitle', children: t('dyn_passkey_intro.subtitle') }), passkeyEnabled === false && (jsx(ErrorContainer, { children: t('dyn_passkey_intro.disabled') })), errorText && jsx(ErrorContainer, { children: errorText }), jsxs("div", { className: 'passkey-intro-view__actions', children: [jsx(Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', onClick: handleCreateEmbeddedWallet, dataTestId: 'setup-passkey-button', loading: isLoading, disabled: isLoading || !passkeyEnabled, typographyProps: {
|
|
137
107
|
color: 'inherit',
|
|
138
108
|
}, children: jsxs("div", { className: 'passkey-intro-view__inline-button', children: [jsx(PasskeyDeviceIcon, {}), jsx(Typography, { children: t('dyn_passkey_intro.button') })] }) }), jsx(TextButton, { "data-testid": 'setup-passkey-logout-button', className: 'passkey-intro-view__log-out', onClick: handleLogOut, children: t('dyn_passkey_intro.button_logout') })] })] })] }));
|
|
139
109
|
};
|
|
@@ -36,6 +36,7 @@ require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
|
36
36
|
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
37
37
|
require('../../../../context/MockContext/MockContext.cjs');
|
|
38
38
|
require('../../../../context/QrCodeContext/QrCodeContext.cjs');
|
|
39
|
+
var useIsTurnkeyWallet = require('../../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
39
40
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
40
41
|
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
41
42
|
require('../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
@@ -51,6 +52,7 @@ require('../../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
|
51
52
|
require('yup');
|
|
52
53
|
require('../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
53
54
|
require('@dynamic-labs/types');
|
|
55
|
+
var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
|
|
54
56
|
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
55
57
|
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
56
58
|
require('formik');
|
|
@@ -58,7 +60,6 @@ require('../../../../components/IconButton/IconButton.cjs');
|
|
|
58
60
|
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
59
61
|
require('../../../../components/Alert/Alert.cjs');
|
|
60
62
|
require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
61
|
-
var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
|
|
62
63
|
var TextButton = require('../../../../components/TextButton/TextButton.cjs');
|
|
63
64
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
64
65
|
var Input = require('../../../../components/Input/Input.cjs');
|
|
@@ -72,6 +73,7 @@ var passkeyRecovery = require('../../utils/passkeyRecovery/passkeyRecovery.cjs')
|
|
|
72
73
|
const bundleRegex = new RegExp(/^([A-Za-z0-9\s_+@\.-]+)$/);
|
|
73
74
|
const PasskeyBundleRecovery = () => {
|
|
74
75
|
const { authToken, primaryWallet, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
76
|
+
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
75
77
|
const [bundleInput, setBundleInput] = React.useState('');
|
|
76
78
|
const [resendingCode, setResendingCode] = React.useState(false);
|
|
77
79
|
const [isValid, setIsValid] = React.useState(false);
|
|
@@ -130,7 +132,10 @@ const PasskeyBundleRecovery = () => {
|
|
|
130
132
|
}
|
|
131
133
|
});
|
|
132
134
|
const emailIcon = (jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(iconic.SignInWithEmailIcon, {}) }));
|
|
133
|
-
|
|
135
|
+
const translationKey = isTurnkeyWalletWithoutAuthenticator
|
|
136
|
+
? 'dyn_passkey_secure_modal'
|
|
137
|
+
: 'dyn_passkey_recovery';
|
|
138
|
+
return (jsxRuntime.jsxs("div", { className: 'passkey-recovery-view', children: [!error$1 && !isValid ? (jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: emailIcon, isSpinning: !error$1 && !isValid, iconSize: 96 })) : (jsxRuntime.jsx(IconWithStatus.IconWithStatus, { Icon: iconic.SignInWithEmailIcon, iconSize: 64, variant: error$1 ? 'red' : 'green', InnerIcon: error$1 ? error.ReactComponent : check.ReactComponent })), jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-recovery-view__subtitle', children: [t(`${translationKey}.code.description`), " ", jsxRuntime.jsx("strong", { children: "turnkey.com" })] }), jsxRuntime.jsx("div", { className: 'passkey-recovery-view__actions', children: jsxRuntime.jsx(Input.Input, { id: 'passkey-recovery-bundle', "data-testid": 'passkey-recovery-bundle-input', value: bundleInput, onChange: handleBundleChanged, label: t(`${translationKey}.code.input_label`), disabled: isLoading || resendingCode, error: Boolean(error$1), className: isValid ? 'passkey-recovery-view__input-valid' : '', autoFocus: true }) }), jsxRuntime.jsxs("div", { className: 'passkey-recovery-view__resend-code', children: [jsxRuntime.jsx(Typography.Typography, { color: 'secondary', variant: 'body_small', children: t(`${translationKey}.code.resend.text`) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'link', children: jsxRuntime.jsx(TextButton.TextButton, { "data-testid": 'resend-email-button', onClick: handleResentEmail, disabled: resendingCode || isLoading || bundleInput.length > 0, children: t(`${translationKey}.code.resend.button`) }) })] })] }));
|
|
134
139
|
};
|
|
135
140
|
|
|
136
141
|
exports.PasskeyBundleRecovery = PasskeyBundleRecovery;
|
|
@@ -32,6 +32,7 @@ import '../../../../components/OverlayCard/OverlayCard.context.js';
|
|
|
32
32
|
import '../../../../context/FooterAnimationContext/index.js';
|
|
33
33
|
import '../../../../context/MockContext/MockContext.js';
|
|
34
34
|
import '../../../../context/QrCodeContext/QrCodeContext.js';
|
|
35
|
+
import { useIsTurnkeyWallet } from '../../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
35
36
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
36
37
|
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
37
38
|
import '../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
@@ -47,6 +48,7 @@ import '../../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
|
47
48
|
import 'yup';
|
|
48
49
|
import '../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
49
50
|
import '@dynamic-labs/types';
|
|
51
|
+
import { useMutation } from '../../../../utils/hooks/useMutation/useMutation.js';
|
|
50
52
|
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
51
53
|
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
52
54
|
import 'formik';
|
|
@@ -54,7 +56,6 @@ import '../../../../components/IconButton/IconButton.js';
|
|
|
54
56
|
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
55
57
|
import '../../../../components/Alert/Alert.js';
|
|
56
58
|
import '../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
57
|
-
import { useMutation } from '../../../../utils/hooks/useMutation/useMutation.js';
|
|
58
59
|
import { TextButton } from '../../../../components/TextButton/TextButton.js';
|
|
59
60
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
60
61
|
import { Input } from '../../../../components/Input/Input.js';
|
|
@@ -68,6 +69,7 @@ import { passkeyRecoveryBundleValidation, resentRecoveryEmail } from '../../util
|
|
|
68
69
|
const bundleRegex = new RegExp(/^([A-Za-z0-9\s_+@\.-]+)$/);
|
|
69
70
|
const PasskeyBundleRecovery = () => {
|
|
70
71
|
const { authToken, primaryWallet, environmentId } = useInternalDynamicContext();
|
|
72
|
+
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet();
|
|
71
73
|
const [bundleInput, setBundleInput] = useState('');
|
|
72
74
|
const [resendingCode, setResendingCode] = useState(false);
|
|
73
75
|
const [isValid, setIsValid] = useState(false);
|
|
@@ -126,7 +128,10 @@ const PasskeyBundleRecovery = () => {
|
|
|
126
128
|
}
|
|
127
129
|
});
|
|
128
130
|
const emailIcon = (jsx(Icon, { color: 'brand-primary', children: jsx(SignInWithEmailIcon, {}) }));
|
|
129
|
-
|
|
131
|
+
const translationKey = isTurnkeyWalletWithoutAuthenticator
|
|
132
|
+
? 'dyn_passkey_secure_modal'
|
|
133
|
+
: 'dyn_passkey_recovery';
|
|
134
|
+
return (jsxs("div", { className: 'passkey-recovery-view', children: [!error && !isValid ? (jsx(IconWithSpinner, { Icon: emailIcon, isSpinning: !error && !isValid, iconSize: 96 })) : (jsx(IconWithStatus, { Icon: SignInWithEmailIcon, iconSize: 64, variant: error ? 'red' : 'green', InnerIcon: error ? SvgError : SvgCheck })), jsxs(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-recovery-view__subtitle', children: [t(`${translationKey}.code.description`), " ", jsx("strong", { children: "turnkey.com" })] }), jsx("div", { className: 'passkey-recovery-view__actions', children: jsx(Input, { id: 'passkey-recovery-bundle', "data-testid": 'passkey-recovery-bundle-input', value: bundleInput, onChange: handleBundleChanged, label: t(`${translationKey}.code.input_label`), disabled: isLoading || resendingCode, error: Boolean(error), className: isValid ? 'passkey-recovery-view__input-valid' : '', autoFocus: true }) }), jsxs("div", { className: 'passkey-recovery-view__resend-code', children: [jsx(Typography, { color: 'secondary', variant: 'body_small', children: t(`${translationKey}.code.resend.text`) }), jsx(Typography, { variant: 'body_small', color: 'link', children: jsx(TextButton, { "data-testid": 'resend-email-button', onClick: handleResentEmail, disabled: resendingCode || isLoading || bundleInput.length > 0, children: t(`${translationKey}.code.resend.button`) }) })] })] }));
|
|
130
135
|
};
|
|
131
136
|
|
|
132
137
|
export { PasskeyBundleRecovery };
|
|
@@ -37,6 +37,7 @@ require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
|
37
37
|
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
38
38
|
require('../../../../context/MockContext/MockContext.cjs');
|
|
39
39
|
require('../../../../context/QrCodeContext/QrCodeContext.cjs');
|
|
40
|
+
var useIsTurnkeyWallet = require('../../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
40
41
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
41
42
|
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
42
43
|
require('../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
@@ -46,11 +47,12 @@ require('../../../../context/EmailVerificationContext/EmailVerificationContext.c
|
|
|
46
47
|
require('qrcode');
|
|
47
48
|
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
48
49
|
require('i18next');
|
|
49
|
-
|
|
50
|
+
require('../../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
50
51
|
require('yup');
|
|
51
52
|
var ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
52
53
|
require('../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
53
54
|
require('@dynamic-labs/types');
|
|
55
|
+
var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
|
|
54
56
|
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
55
57
|
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
56
58
|
require('formik');
|
|
@@ -59,7 +61,6 @@ require('../../../../components/IconButton/IconButton.cjs');
|
|
|
59
61
|
require('../../../../components/Alert/Alert.cjs');
|
|
60
62
|
require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
61
63
|
var getProperErrorMessage = require('../../../../modals/SignMessageConfirmationModal/getProperErrorMessage.cjs');
|
|
62
|
-
var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
|
|
63
64
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
64
65
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
65
66
|
var NeedHelpSection = require('../../../../components/NeedHelpSection/NeedHelpSection.cjs');
|
|
@@ -70,8 +71,8 @@ var passkeyRecovery = require('../../utils/passkeyRecovery/passkeyRecovery.cjs')
|
|
|
70
71
|
var PasskeyDeviceIcon = require('../../PasskeyDeviceIcon/PasskeyDeviceIcon.cjs');
|
|
71
72
|
|
|
72
73
|
const PasskeyCompleteRecovery = () => {
|
|
73
|
-
const { authToken, primaryWallet, environmentId, internalEvents, user, setShowAuthFlow, setUser, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
74
|
-
const {
|
|
74
|
+
const { authToken, primaryWallet, environmentId, internalEvents, user, setShowAuthFlow, setUser, setShowPasskeyCreatedSuccess, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
75
|
+
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
75
76
|
const { t } = reactI18next.useTranslation();
|
|
76
77
|
const { mutate: completeRecovery, isLoading, error, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
78
|
const { jwt, decodedJwt } = yield passkeyRecovery.completePasskeyRecovery({
|
|
@@ -83,8 +84,8 @@ const PasskeyCompleteRecovery = () => {
|
|
|
83
84
|
internalEvents.current.emit('passkeyRecoveryCompleted', primaryWallet);
|
|
84
85
|
index.storeAuthToken(jwt);
|
|
85
86
|
setUser(createUserProfile.createUserProfile(decodedJwt));
|
|
86
|
-
setDynamicWidgetView('manage-passkeys');
|
|
87
87
|
setShowAuthFlow(false);
|
|
88
|
+
setShowPasskeyCreatedSuccess();
|
|
88
89
|
}), {
|
|
89
90
|
onFailure: (err) => {
|
|
90
91
|
logger.logger.error('Failed to init passkey recovery', err);
|
|
@@ -100,9 +101,12 @@ const PasskeyCompleteRecovery = () => {
|
|
|
100
101
|
}
|
|
101
102
|
return getProperErrorMessage.getProperErrorMessage(error);
|
|
102
103
|
}, [error]);
|
|
103
|
-
|
|
104
|
+
const translationKey = isTurnkeyWalletWithoutAuthenticator
|
|
105
|
+
? 'dyn_passkey_secure_modal'
|
|
106
|
+
: 'dyn_passkey_recovery';
|
|
107
|
+
return (jsxRuntime.jsxs("div", { className: 'passkey-recovery-view', children: [jsxRuntime.jsx("div", { className: 'passkey-recovery-view__header', children: jsxRuntime.jsx(passkeyIntroIcon.ReactComponent, {}) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-recovery-view__subtitle', children: t(`${translationKey}.complete.description`) }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsx("div", { className: 'passkey-recovery-view__actions', children: jsxRuntime.jsx(Button.Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', dataTestId: 'passkey-recovery-complete-button', onClick: () => completeRecovery(), disabled: isLoading, showInternalLoading: false, typographyProps: {
|
|
104
108
|
color: 'inherit',
|
|
105
|
-
}, children: jsxRuntime.jsxs("div", { className: 'passkey-recovery-view__inline-button', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, {}), jsxRuntime.jsx(Typography.Typography, { children: t(
|
|
109
|
+
}, children: jsxRuntime.jsxs("div", { className: 'passkey-recovery-view__inline-button', children: [jsxRuntime.jsx(PasskeyDeviceIcon.PasskeyDeviceIcon, {}), jsxRuntime.jsx(Typography.Typography, { children: t(`${translationKey}.complete.complete_button`) })] }) }) }), jsxRuntime.jsx(NeedHelpSection.NeedHelpSection, {})] }));
|
|
106
110
|
};
|
|
107
111
|
|
|
108
112
|
exports.PasskeyCompleteRecovery = PasskeyCompleteRecovery;
|
|
@@ -33,6 +33,7 @@ import '../../../../components/OverlayCard/OverlayCard.context.js';
|
|
|
33
33
|
import '../../../../context/FooterAnimationContext/index.js';
|
|
34
34
|
import '../../../../context/MockContext/MockContext.js';
|
|
35
35
|
import '../../../../context/QrCodeContext/QrCodeContext.js';
|
|
36
|
+
import { useIsTurnkeyWallet } from '../../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.js';
|
|
36
37
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
37
38
|
import '../../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
38
39
|
import '../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
@@ -42,11 +43,12 @@ import '../../../../context/EmailVerificationContext/EmailVerificationContext.js
|
|
|
42
43
|
import 'qrcode';
|
|
43
44
|
import '../../../../context/LoadingContext/LoadingContext.js';
|
|
44
45
|
import 'i18next';
|
|
45
|
-
import
|
|
46
|
+
import '../../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
46
47
|
import 'yup';
|
|
47
48
|
import { ErrorContainer } from '../../../../components/ErrorContainer/ErrorContainer.js';
|
|
48
49
|
import '../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.js';
|
|
49
50
|
import '@dynamic-labs/types';
|
|
51
|
+
import { useMutation } from '../../../../utils/hooks/useMutation/useMutation.js';
|
|
50
52
|
import '../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.js';
|
|
51
53
|
import '../../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
52
54
|
import 'formik';
|
|
@@ -55,7 +57,6 @@ import '../../../../components/IconButton/IconButton.js';
|
|
|
55
57
|
import '../../../../components/Alert/Alert.js';
|
|
56
58
|
import '../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
|
|
57
59
|
import { getProperErrorMessage } from '../../../../modals/SignMessageConfirmationModal/getProperErrorMessage.js';
|
|
58
|
-
import { useMutation } from '../../../../utils/hooks/useMutation/useMutation.js';
|
|
59
60
|
import '../../../../components/InlineWidget/InlineWidget.js';
|
|
60
61
|
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
61
62
|
import { NeedHelpSection } from '../../../../components/NeedHelpSection/NeedHelpSection.js';
|
|
@@ -66,8 +67,8 @@ import { completePasskeyRecovery } from '../../utils/passkeyRecovery/passkeyReco
|
|
|
66
67
|
import { PasskeyDeviceIcon } from '../../PasskeyDeviceIcon/PasskeyDeviceIcon.js';
|
|
67
68
|
|
|
68
69
|
const PasskeyCompleteRecovery = () => {
|
|
69
|
-
const { authToken, primaryWallet, environmentId, internalEvents, user, setShowAuthFlow, setUser, } = useInternalDynamicContext();
|
|
70
|
-
const {
|
|
70
|
+
const { authToken, primaryWallet, environmentId, internalEvents, user, setShowAuthFlow, setUser, setShowPasskeyCreatedSuccess, } = useInternalDynamicContext();
|
|
71
|
+
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet();
|
|
71
72
|
const { t } = useTranslation();
|
|
72
73
|
const { mutate: completeRecovery, isLoading, error, } = useMutation(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
74
|
const { jwt, decodedJwt } = yield completePasskeyRecovery({
|
|
@@ -79,8 +80,8 @@ const PasskeyCompleteRecovery = () => {
|
|
|
79
80
|
internalEvents.current.emit('passkeyRecoveryCompleted', primaryWallet);
|
|
80
81
|
storeAuthToken(jwt);
|
|
81
82
|
setUser(createUserProfile(decodedJwt));
|
|
82
|
-
setDynamicWidgetView('manage-passkeys');
|
|
83
83
|
setShowAuthFlow(false);
|
|
84
|
+
setShowPasskeyCreatedSuccess();
|
|
84
85
|
}), {
|
|
85
86
|
onFailure: (err) => {
|
|
86
87
|
logger.error('Failed to init passkey recovery', err);
|
|
@@ -96,9 +97,12 @@ const PasskeyCompleteRecovery = () => {
|
|
|
96
97
|
}
|
|
97
98
|
return getProperErrorMessage(error);
|
|
98
99
|
}, [error]);
|
|
99
|
-
|
|
100
|
+
const translationKey = isTurnkeyWalletWithoutAuthenticator
|
|
101
|
+
? 'dyn_passkey_secure_modal'
|
|
102
|
+
: 'dyn_passkey_recovery';
|
|
103
|
+
return (jsxs("div", { className: 'passkey-recovery-view', children: [jsx("div", { className: 'passkey-recovery-view__header', children: jsx(SvgPasskeyIntroIcon, {}) }), jsx(Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-recovery-view__subtitle', children: t(`${translationKey}.complete.description`) }), errorText && jsx(ErrorContainer, { children: errorText }), jsx("div", { className: 'passkey-recovery-view__actions', children: jsx(Button, { buttonVariant: 'brand-primary', buttonPadding: 'large', dataTestId: 'passkey-recovery-complete-button', onClick: () => completeRecovery(), disabled: isLoading, showInternalLoading: false, typographyProps: {
|
|
100
104
|
color: 'inherit',
|
|
101
|
-
}, children: jsxs("div", { className: 'passkey-recovery-view__inline-button', children: [jsx(PasskeyDeviceIcon, {}), jsx(Typography, { children: t(
|
|
105
|
+
}, children: jsxs("div", { className: 'passkey-recovery-view__inline-button', children: [jsx(PasskeyDeviceIcon, {}), jsx(Typography, { children: t(`${translationKey}.complete.complete_button`) })] }) }) }), jsx(NeedHelpSection, {})] }));
|
|
102
106
|
};
|
|
103
107
|
|
|
104
108
|
export { PasskeyCompleteRecovery };
|
|
@@ -13,7 +13,6 @@ var logger = require('../../../../shared/logger.cjs');
|
|
|
13
13
|
require('@dynamic-labs/iconic');
|
|
14
14
|
require('@dynamic-labs/wallet-connector-core');
|
|
15
15
|
var ViewContext = require('../../../../context/ViewContext/ViewContext.cjs');
|
|
16
|
-
var chevronLeft = require('../../../../shared/assets/chevron-left.cjs');
|
|
17
16
|
var close = require('../../../../shared/assets/close.cjs');
|
|
18
17
|
var signInWithEmail = require('../../../../shared/assets/sign-in-with-email.cjs');
|
|
19
18
|
require('@dynamic-labs/wallet-book');
|
|
@@ -38,6 +37,7 @@ require('../../../../components/OverlayCard/OverlayCard.context.cjs');
|
|
|
38
37
|
require('../../../../context/FooterAnimationContext/index.cjs');
|
|
39
38
|
require('../../../../context/MockContext/MockContext.cjs');
|
|
40
39
|
require('../../../../context/QrCodeContext/QrCodeContext.cjs');
|
|
40
|
+
var useIsTurnkeyWallet = require('../../../../utils/hooks/useIsTurnkeyWallet/useIsTurnkeyWallet.cjs');
|
|
41
41
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
42
42
|
require('../../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
43
43
|
require('../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
@@ -49,11 +49,12 @@ require('../../../../context/ThemeContext/ThemeContext.cjs');
|
|
|
49
49
|
require('../../../../context/LoadingContext/LoadingContext.cjs');
|
|
50
50
|
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
51
51
|
require('i18next');
|
|
52
|
-
|
|
52
|
+
require('../../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
53
53
|
require('yup');
|
|
54
54
|
var ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
55
55
|
require('../../../../components/UserProfile/parts/UserProfileField/components/VerifiedEmailIcon/VerifiedEmailIcon.cjs');
|
|
56
56
|
require('@dynamic-labs/types');
|
|
57
|
+
var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
|
|
57
58
|
require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/useUpdateUser.cjs');
|
|
58
59
|
require('../../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
59
60
|
require('formik');
|
|
@@ -63,7 +64,6 @@ var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
|
63
64
|
require('../../../../components/Alert/Alert.cjs');
|
|
64
65
|
var constants = require('../constants.cjs');
|
|
65
66
|
require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
|
|
66
|
-
var useMutation = require('../../../../utils/hooks/useMutation/useMutation.cjs');
|
|
67
67
|
require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
68
68
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
69
69
|
var NeedHelpSection = require('../../../../components/NeedHelpSection/NeedHelpSection.cjs');
|
|
@@ -74,8 +74,8 @@ var passkeyRecovery = require('../../utils/passkeyRecovery/passkeyRecovery.cjs')
|
|
|
74
74
|
|
|
75
75
|
const PasskeyInitRecovery = () => {
|
|
76
76
|
const { authToken, primaryWallet, environmentId, internalEvents, setShowAuthFlow, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
77
|
+
const { isTurnkeyWalletWithoutAuthenticator } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
77
78
|
const { setView } = ViewContext.useViewContext();
|
|
78
|
-
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
79
79
|
useElementById.useElementById(constants.iframeContainerId);
|
|
80
80
|
const { t } = reactI18next.useTranslation();
|
|
81
81
|
const { mutate: initRecovery, isLoading, error, } = useMutation.useMutation(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -103,13 +103,11 @@ const PasskeyInitRecovery = () => {
|
|
|
103
103
|
return 'Something went wrong.';
|
|
104
104
|
}, [error]);
|
|
105
105
|
const EmailIcon = (jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(signInWithEmail.ReactComponent, {}) }));
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
106
|
+
const translationKey = isTurnkeyWalletWithoutAuthenticator
|
|
107
|
+
? 'dyn_passkey_secure_modal'
|
|
108
|
+
: 'dyn_passkey_recovery';
|
|
110
109
|
const closeButton = (jsxRuntime.jsx(IconButton.IconButton, { type: 'button', onClick: () => setShowAuthFlow(false), "data-testid": 'close-button', children: jsxRuntime.jsx(close.ReactComponent, {}) }));
|
|
111
|
-
|
|
112
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: t('dyn_passkey_recovery.start.title') }) }), jsxRuntime.jsxs("div", { className: 'passkey-recovery-view', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, isSpinning: isLoading, iconSize: 96 }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-recovery-view__subtitle', children: t('dyn_passkey_recovery.start.description') }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsx("div", { className: 'passkey-recovery-view__actions', children: jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', dataTestId: 'passkey-recovery-button', onClick: () => initRecovery(), disabled: isLoading, showInternalLoading: false, children: jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Typography.Typography, { children: t('dyn_passkey_recovery.start.start_button') }) }) }) }), jsxRuntime.jsx(NeedHelpSection.NeedHelpSection, {})] })] }));
|
|
110
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { as: 'h1', variant: 'title', color: 'primary', "data-testid": 'dynamic-auth-modal-heading', className: 'header__typography', children: t(`${translationKey}.start.title`) }) }), jsxRuntime.jsxs("div", { className: 'passkey-recovery-view', children: [jsxRuntime.jsx(IconWithSpinner.IconWithSpinner, { Icon: EmailIcon, isSpinning: isLoading, iconSize: 96 }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', weight: 'regular', color: 'secondary', className: 'passkey-recovery-view__subtitle', children: t(`${translationKey}.start.description`) }), errorText && jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: errorText }), jsxRuntime.jsx("div", { className: 'passkey-recovery-view__actions', children: jsxRuntime.jsx(Button.Button, { buttonPadding: 'large', dataTestId: 'passkey-recovery-button', onClick: () => initRecovery(), disabled: isLoading, showInternalLoading: false, children: jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Typography.Typography, { children: t(`${translationKey}.start.start_button`) }) }) }) }), jsxRuntime.jsx(NeedHelpSection.NeedHelpSection, {})] })] }));
|
|
113
111
|
};
|
|
114
112
|
|
|
115
113
|
exports.PasskeyInitRecovery = PasskeyInitRecovery;
|