From e1fde63c028fc7c3e36d854ccd834f824d30c7be Mon Sep 17 00:00:00 2001 From: Bartosz Date: Wed, 23 Oct 2024 10:02:05 +0200 Subject: [PATCH 01/18] feat: use usd currency name instead of dollar sign --- src/composables/currencies.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/composables/currencies.ts b/src/composables/currencies.ts index da146ccd2..cb9260114 100644 --- a/src/composables/currencies.ts +++ b/src/composables/currencies.ts @@ -116,7 +116,7 @@ export function useCurrencies({ function formatCurrency(value: number): string { return new Intl.NumberFormat( DEFAULT_LOCALE, - { style: 'currency', currencyDisplay: 'narrowSymbol', currency: currentCurrencyCode.value }, + { style: 'currency', currencyDisplay: 'code', currency: currentCurrencyCode.value }, ).format(value); } From 435d3d0967b33516856969610e55edd6715d5ba8 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Fri, 25 Oct 2024 09:23:03 +0200 Subject: [PATCH 02/18] feat: skip password protection for web --- src/composables/auth.ts | 33 ++++--- src/popup/components/Modals/SetPassword.vue | 79 +++++++--------- src/popup/components/SwitchButton.vue | 75 ++++++++------- src/popup/locales/en.json | 60 ++++++------ src/popup/pages/More.vue | 63 +++++++----- src/popup/pages/SecureLoginSettings.vue | 100 ++++++++++++++------ src/popup/router/routeNames.ts | 3 + src/popup/router/routes.ts | 9 +- 8 files changed, 239 insertions(+), 183 deletions(-) diff --git a/src/composables/auth.ts b/src/composables/auth.ts index 10faabaa7..979558c9c 100644 --- a/src/composables/auth.ts +++ b/src/composables/auth.ts @@ -15,8 +15,8 @@ import { IS_IOS, IS_MOBILE_APP, IS_OFFSCREEN_TAB, + RUNNING_IN_TESTS, STORAGE_KEYS, - UNFINISHED_FEATURES, } from '@/constants'; import { STUB_ACCOUNT } from '@/constants/stubs'; import { @@ -292,8 +292,22 @@ export const useAuth = createCustomScopedComposable(() => { isAuthenticated.value = true; } } else if (isMnemonicEncrypted.value) { - // Check if extension can be restored without requiring password - if (!encryptionKey.value && IS_EXTENSION && !IS_OFFSCREEN_TAB) { + // Environments that will always ask user about password + const autoLoginDisabledEnv = IS_OFFSCREEN_TAB || RUNNING_IN_TESTS; + + // Attempt to log in with the default password that is set when a user skips + // password protection. This check needs to go first as we need to know + // if default password was used. + if (!encryptionKey.value && !autoLoginDisabledEnv) { + try { + await authenticateWithPassword(STUB_ACCOUNT.password); + isUsingDefaultPassword.value = true; + } catch (error) { /* NOOP */ } + } + + // If default password auth failed, check if extension can be restored + // by using data stored in the background process. + if (!encryptionKey.value && !autoLoginDisabledEnv && IS_EXTENSION) { setLoaderVisible(true); const sessionEncryptionKey = await getSessionEncryptionKey(); if (sessionEncryptionKey) { @@ -304,17 +318,7 @@ export const useAuth = createCustomScopedComposable(() => { setLoaderVisible(false); } - // If restoring from background failed try to use the dev mode password set - // when using "Skip" when setting password. - if (!encryptionKey.value && UNFINISHED_FEATURES && !IS_OFFSCREEN_TAB) { - await authenticateWithPassword(STUB_ACCOUNT.password) - .then(() => { - isUsingDefaultPassword.value = true; - }) - .catch(() => openPasswordLoginModal()); - } - - // Finally if other attempts failed ask user for the password + // Finally if other attempts failed, ask user for the password. if (!encryptionKey.value) { await openPasswordLoginModal(); } @@ -434,6 +438,7 @@ export const useAuth = createCustomScopedComposable(() => { lockWallet, logout, setMnemonicAndInitializeAuthentication, + setPassword, updatePassword, }; }); diff --git a/src/popup/components/Modals/SetPassword.vue b/src/popup/components/Modals/SetPassword.vue index b6b6ed094..18cd966c2 100644 --- a/src/popup/components/Modals/SetPassword.vue +++ b/src/popup/components/Modals/SetPassword.vue @@ -2,7 +2,6 @@ @@ -19,20 +18,18 @@

+

+

-

-

-

-

-

@@ -52,12 +49,12 @@ v-model="password" data-cy="password" class="password-input" - :placeholder="$t('pages.secureLogin.setPassword.passwordPlaceholder')" - :label="$t('pages.secureLogin.setPassword.passwordLabel')" + :placeholder="$t('pages.setPassword.passwordPlaceholder')" + :label="$t('pages.setPassword.passwordLabel')" :message="errorMessage ?? errors.confirmPassword" :help="{ - title: $t('pages.secureLogin.setPassword.help.title'), - msg: $t('pages.secureLogin.setPassword.help.text'), + title: $t('pages.setPassword.help.title'), + msg: $t('pages.setPassword.help.text'), fullscreen: true, }" show-password-strength @@ -76,8 +73,8 @@ v-model="confirmPassword" data-cy="confirm-password" class="password-input" - :placeholder="$t('pages.secureLogin.setPassword.confirmPlaceholder')" - :label="$t('pages.secureLogin.setPassword.confirmLabel')" + :placeholder="$t('pages.setPassword.confirmPlaceholder')" + :label="$t('pages.setPassword.confirmLabel')" :message="errorMessage" hide-eye-icon @keydown.enter="handleSubmit($event, onSubmit)" @@ -86,7 +83,6 @@
@@ -119,8 +113,8 @@ import { defineComponent, PropType, ref } from 'vue'; import { Form, Field } from 'vee-validate'; import type { RejectCallback, ResolveCallback } from '@/types'; -import { UNFINISHED_FEATURES } from '@/constants'; import { STUB_ACCOUNT } from '@/constants/stubs'; +import { useAuth } from '@/composables'; import Modal from '@/popup/components/Modal.vue'; import IconBoxed from '@/popup/components/IconBoxed.vue'; @@ -128,7 +122,6 @@ import InputPassword from '@/popup/components/InputPassword.vue'; import BtnMain from '@/popup/components/buttons/BtnMain.vue'; import LockIcon from '@/icons/secure-lock-outline.svg?vue-component'; -import { useAuth } from '@/composables'; export default defineComponent({ components: { @@ -160,11 +153,13 @@ export default defineComponent({ } } + /** + * Bypassing password protection means we will still encrypt some important data, + * but the stub password will be used for the encryption. + */ function useDefaultPassword() { - if (UNFINISHED_FEATURES) { - props.resolve(STUB_ACCOUNT.password); - isUsingDefaultPassword.value = true; - } + props.resolve(STUB_ACCOUNT.password); + isUsingDefaultPassword.value = true; } return { @@ -175,7 +170,6 @@ export default defineComponent({ handleClose, useDefaultPassword, LockIcon, - UNFINISHED_FEATURES, }; }, }); @@ -199,20 +193,13 @@ export default defineComponent({ flex-direction: column; gap: 8px; } + } - .buttons { - display: flex; - margin-top: 40px; - gap: 8px; - - .btn-main { - width: 100%; - } - - .default-password { - width: 20%; - } - } + .buttons { + display: flex; + flex-direction: column; + gap: 12px; + margin-top: 24px; } } diff --git a/src/popup/components/SwitchButton.vue b/src/popup/components/SwitchButton.vue index 3f67fc411..39e30c4e7 100644 --- a/src/popup/components/SwitchButton.vue +++ b/src/popup/components/SwitchButton.vue @@ -1,38 +1,41 @@ - diff --git a/src/popup/components/AddressBook/AddressBookList.vue b/src/popup/components/AddressBook/AddressBookList.vue index 921709f0e..1e092cf34 100644 --- a/src/popup/components/AddressBook/AddressBookList.vue +++ b/src/popup/components/AddressBook/AddressBookList.vue @@ -15,6 +15,7 @@ :is-selector="isSelector" /> + - + + +

addressBookFilteredByProtocol.value.some((entry) => entry.isBookmarked), ); - function handleAddressBookItemClick(entry: IAddressBookEntry) { - if (entry) { - emit('select-address', entry.address); - } - } - const handleScroll = throttle(() => { if (!scrollWrapper.value) return; isScrolled.value = scrollWrapper.value?.scrollTop > 0; @@ -138,6 +146,7 @@ export default defineComponent({ }, { deep: true }); return { + ROUTE_ADDRESS_BOOK_EDIT, scrollWrapperEl, isSearchVisible, hasBookmarkedEntries, @@ -145,7 +154,6 @@ export default defineComponent({ addressBookFiltered, noRecordsMessage, protocolName, - handleAddressBookItemClick, }; }, }); @@ -171,12 +179,6 @@ export default defineComponent({ margin-bottom: 16px; } - .list { - display: flex; - flex-direction: column; - gap: 8px; - } - .message { @extend %face-sans-15-medium; diff --git a/src/popup/components/PanelItem.vue b/src/popup/components/PanelItem.vue index caebda5e7..f0630c26b 100644 --- a/src/popup/components/PanelItem.vue +++ b/src/popup/components/PanelItem.vue @@ -9,7 +9,7 @@

- {{ title }} + {{ title }}
@@ -54,7 +54,7 @@ export default defineComponent({ BtnBase, }, props: { - title: { type: String, required: true }, + title: { type: String, default: '' }, info: { type: String, default: '' }, to: { type: Object as PropType, default: null }, href: { type: String, default: null }, diff --git a/src/popup/pages/AddressBook.vue b/src/popup/pages/AddressBook.vue index a76a06d17..bbfbde185 100644 --- a/src/popup/pages/AddressBook.vue +++ b/src/popup/pages/AddressBook.vue @@ -26,19 +26,17 @@ />
- + +
+ + diff --git a/src/popup/components/form/FormTextarea.vue b/src/popup/components/form/FormTextarea.vue index d230eb9c3..8ac449455 100644 --- a/src/popup/components/form/FormTextarea.vue +++ b/src/popup/components/form/FormTextarea.vue @@ -83,12 +83,14 @@ export default defineComponent({ onMounted(() => { watch(() => props.modelValue, () => { - if (props.autoHeight && textarea.value) { + if (props.autoHeight && textarea?.value) { height.value = 'auto'; nextTick(() => { - const { scrollHeight, clientHeight } = textarea.value!; - const newHeight = clientHeight > scrollHeight ? clientHeight : scrollHeight; - height.value = `${newHeight}px`; + if (textarea?.value) { + const { scrollHeight, clientHeight } = textarea.value!; + const newHeight = clientHeight > scrollHeight ? clientHeight : scrollHeight; + height.value = `${newHeight}px`; + } }); } }, { immediate: true }); diff --git a/src/protocols/aeternity/components/TransferSendForm.vue b/src/protocols/aeternity/components/TransferSendForm.vue index 8105a7480..f434e1bf4 100644 --- a/src/protocols/aeternity/components/TransferSendForm.vue +++ b/src/protocols/aeternity/components/TransferSendForm.vue @@ -60,7 +60,7 @@