From 27cb1a7b5b599563a33d8a8cc5e5e2818121fd0a Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Tue, 6 Jan 2026 01:14:49 +0100 Subject: [PATCH] fix key import --- components/KeyIndicator.tsx | 22 ++++++++++++++++++---- locales/en.txt | 3 +++ locales/fr.txt | 3 +++ public/locales/en.txt | 3 +++ public/locales/fr.txt | 3 +++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/components/KeyIndicator.tsx b/components/KeyIndicator.tsx index 7789698..e34c58c 100644 --- a/components/KeyIndicator.tsx +++ b/components/KeyIndicator.tsx @@ -1,13 +1,27 @@ import Link from 'next/link' import { useNostrAuth } from '@/hooks/useNostrAuth' +import { t } from '@/lib/i18n' export function KeyIndicator() { const { pubkey, isUnlocked } = useNostrAuth() - // Red if private key is accessible (unlocked) - // Green if only public key is accessible (connected but not unlocked) - const color = isUnlocked ? 'text-red-500' : 'text-green-500' - const title = isUnlocked ? 'Private key accessible (Settings)' : pubkey ? 'Public key accessible (Settings)' : 'Settings' + // Determine color and title based on key status + let color: string + let title: string + + if (!pubkey) { + // Gray if no key is available - allows importing a key + color = 'text-gray-500' + title = t('settings.keyManagement.import.title') + } else if (isUnlocked) { + // Red if private key is accessible (unlocked) + color = 'text-red-500' + title = t('settings.keyManagement.status.privateKey') + } else { + // Green if only public key is accessible (connected but not unlocked) + color = 'text-green-500' + title = t('settings.keyManagement.status.publicKey') + } return ( 4 recovery words (BIP39 dictionary) to secure your account. These words encrypt a Key Encryption Key (KEK) stored in the browser's Credentials API, which then encrypts your private key stored in IndexedDB (two-level encryption system). settings.keyManagement.import.warning.replace=Warning: Importing a new key will replace your existing account. Make sure you have your recovery phrase saved before proceeding. diff --git a/locales/fr.txt b/locales/fr.txt index cca3f1f..094b8cf 100644 --- a/locales/fr.txt +++ b/locales/fr.txt @@ -138,8 +138,11 @@ settings.keyManagement.copy=Copier settings.keyManagement.copied=✓ Copié settings.keyManagement.noAccount.title=Aucun compte trouvé settings.keyManagement.noAccount.description=Créez un nouveau compte en important une clé privée. La clé sera chiffrée à l'aide d'un système de chiffrement à deux niveaux. +settings.keyManagement.import.title=Importer une clé (Paramètres) settings.keyManagement.import.button.new=Importer une clé privée settings.keyManagement.import.button.replace=Remplacer le compte (Importer une nouvelle clé) +settings.keyManagement.status.privateKey=Clé privée accessible (Paramètres) +settings.keyManagement.status.publicKey=Clé publique accessible (Paramètres) settings.keyManagement.import.warning.title=⚠️ Important settings.keyManagement.import.warning.description=Après l'import, vous recevrez 4 mots de récupération (dictionnaire BIP39) pour sécuriser votre compte. Ces mots chiffrent une clé de chiffrement (KEK) stockée dans l'API Credentials du navigateur, qui chiffre ensuite votre clé privée stockée dans IndexedDB (système de chiffrement à deux niveaux). settings.keyManagement.import.warning.replace=Avertissement : L'importation d'une nouvelle clé remplacera votre compte existant. Assurez-vous d'avoir sauvegardé votre phrase de récupération avant de continuer. diff --git a/public/locales/en.txt b/public/locales/en.txt index a1e7149..1414931 100644 --- a/public/locales/en.txt +++ b/public/locales/en.txt @@ -139,8 +139,11 @@ settings.keyManagement.copy=Copy settings.keyManagement.copied=✓ Copied settings.keyManagement.noAccount.title=No account found settings.keyManagement.noAccount.description=Create a new account by importing a private key. The key will be encrypted using a two-level encryption system. +settings.keyManagement.import.title=Import key (Settings) settings.keyManagement.import.button.new=Import Private Key settings.keyManagement.import.button.replace=Replace Account (Import New Key) +settings.keyManagement.status.privateKey=Private key accessible (Settings) +settings.keyManagement.status.publicKey=Public key accessible (Settings) settings.keyManagement.import.warning.title=⚠️ Important settings.keyManagement.import.warning.description=After importing, you will receive 4 recovery words (BIP39 dictionary) to secure your account. These words encrypt a Key Encryption Key (KEK) stored in the browser's Credentials API, which then encrypts your private key stored in IndexedDB (two-level encryption system). settings.keyManagement.import.warning.replace=Warning: Importing a new key will replace your existing account. Make sure you have your recovery phrase saved before proceeding. diff --git a/public/locales/fr.txt b/public/locales/fr.txt index f517e8f..3d75f26 100644 --- a/public/locales/fr.txt +++ b/public/locales/fr.txt @@ -139,8 +139,11 @@ settings.keyManagement.copy=Copier settings.keyManagement.copied=✓ Copié settings.keyManagement.noAccount.title=Aucun compte trouvé settings.keyManagement.noAccount.description=Créez un nouveau compte en important une clé privée. La clé sera chiffrée à l'aide d'un système de chiffrement à deux niveaux. +settings.keyManagement.import.title=Importer une clé (Paramètres) settings.keyManagement.import.button.new=Importer une clé privée settings.keyManagement.import.button.replace=Remplacer le compte (Importer une nouvelle clé) +settings.keyManagement.status.privateKey=Clé privée accessible (Paramètres) +settings.keyManagement.status.publicKey=Clé publique accessible (Paramètres) settings.keyManagement.import.warning.title=⚠️ Important settings.keyManagement.import.warning.description=Après l'import, vous recevrez 4 mots de récupération (dictionnaire BIP39) pour sécuriser votre compte. Ces mots chiffrent une clé de chiffrement (KEK) stockée dans l'API Credentials du navigateur, qui chiffre ensuite votre clé privée stockée dans IndexedDB (système de chiffrement à deux niveaux). settings.keyManagement.import.warning.replace=Avertissement : L'importation d'une nouvelle clé remplacera votre compte existant. Assurez-vous d'avoir sauvegardé votre phrase de récupération avant de continuer.