Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Refactor (#1338)

Leendert de Borstc63b7ceac42a
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
index befebf9a2..08f844de0 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
@@ -21,10 +21,8 @@ import { VAULT_LOCKED_DISMISS_UNTIL_KEY } from '@/utils/Constants';
import type { VaultResponse } from '@/utils/dist/shared/models/webapi';
import EncryptionUtility from '@/utils/EncryptionUtility';
import {
- getFailedAttempts,
getPinLength,
isPinEnabled,
- isPinLocked,
PinLockedError,
IncorrectPinError,
InvalidPinFormatError,
@@ -66,8 +64,6 @@ const Unlock: React.FC = () => {
// PIN unlock state
const [pin, setPin] = useState('');
const [pinLength, setPinLength] = useState<number>(6);
- const [failedAttempts, setFailedAttempts] = useState<number>(0);
- const [isLocked, setIsLocked] = useState<boolean>(false);
const inputRef = useRef<HTMLInputElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
@@ -106,20 +102,16 @@ const Unlock: React.FC = () => {
*/
const initialize = async (): Promise<void> => {
// First check PIN availability and set initial mode
- const [enabled, length, attempts, locked] = await Promise.all([
+ const [pinEnabled, pinLength] = await Promise.all([
isPinEnabled(),
getPinLength(),
- getFailedAttempts(),
- isPinLocked()
]);
- setPinAvailable(enabled && !locked);
- setPinLength(length || 6);
- setFailedAttempts(attempts);
- setIsLocked(locked);
+ setPinAvailable(pinEnabled);
+ setPinLength(pinLength || 6);
// Default to PIN mode if available, otherwise password
- if (enabled && !locked) {
+ if (pinEnabled) {
setUnlockMode('pin');
} else {
setUnlockMode('password');
@@ -331,7 +323,6 @@ const Unlock: React.FC = () => {
hideLoading();
} catch (err: unknown) {
if (err instanceof PinLockedError) {
- setIsLocked(true);
setPinAvailable(false);
setUnlockMode('password');
setError(t('settings.unlockMethod.pinLocked'));
@@ -344,10 +335,6 @@ const Unlock: React.FC = () => {
setError(t('settings.unlockMethod.incorrectPin', { attemptsRemaining }));
}
setPin('');
-
- /* Update failed attempts counter */
- const newAttempts = await getFailedAttempts();
- setFailedAttempts(newAttempts);
} else if (err instanceof InvalidPinFormatError) {
setError(t('settings.unlockMethod.invalidPinFormat'));
setPin('');
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx
index d9a7cf3cc..0abe64afa 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx
@@ -33,10 +33,10 @@ const Settings: React.FC = () => {
* Open the client tab.
*/
const openClientTab = async () : Promise<void> => {
- const settingClientUrl = await browser.storage.local.get('clientUrl');
+ const settingClientUrl = await storage.getItem('local:clientUrl') as string | undefined;
let clientUrl = AppInfo.DEFAULT_CLIENT_URL;
- if (settingClientUrl?.clientUrl && settingClientUrl.clientUrl.length > 0) {
- clientUrl = settingClientUrl.clientUrl;
+ if (settingClientUrl && settingClientUrl.length > 0) {
+ clientUrl = settingClientUrl;
}
window.open(clientUrl, '_blank');
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx
index da579f4f7..56faf2e7e 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx
@@ -47,7 +47,7 @@ const VaultUnlockSettings: React.FC = () => {
setPinEnabled(enabled);
setIsLocked(locked);
setIsInitialLoading(false);
- } catch (err: any) {
+ } catch (err: unknown) {
console.error('Failed to load PIN settings:', err);
setError(t('common.errors.unknownErrorTryAgain'));
setIsInitialLoading(false);
@@ -157,7 +157,7 @@ const VaultUnlockSettings: React.FC = () => {
setPinEnabled(false);
setIsLocked(false);
hideLoading();
- } catch (err: any) {
+ } catch (err: unknown) {
console.error('Failed to disable PIN:', err);
setError(t('common.errors.unknownErrorTryAgain'));
hideLoading();