This commit is contained in:
2026-10-29 17:39:02 -03:00
parent bf00317e95
commit 3a0414a057
19 changed files with 214 additions and 56 deletions
+24 -15
View File
@@ -1,5 +1,8 @@
import { useSignal } from "@preact/signals";
import Button, { button_class } from "@/components/Button.tsx";
import InputField from "@/components/InputField.tsx";
import TextAreaField from "@/components/TextAreaField.tsx";
import { save_master_key } from "@/src/key_store.ts";
import { type GetKeyResponse, import_key_text, unwrap_with_passphrase, verify_key_check } from "@/src/keys.ts";
@@ -66,42 +69,48 @@ export default function KeysUnlock(props: KeysUnlockProps) {
}
return (
<div>
<p>This account already has an encryption key. Unlock it on this device with one of your backups.</p>
<div class="mx-auto max-w-md py-8">
<p class="leading-normal text-gray-800 dark:text-gray-400">
This account already has an encryption key. Unlock it on this device with one of your backups.
</p>
<fieldset disabled={working.value}>
<fieldset class="flex flex-col gap-4" disabled={working.value}>
{props.account.passphrase_backup && (
<form onSubmit={unlock_with_passphrase}>
<h2>Passphrase</h2>
<input
<form class="flex flex-col gap-4" onSubmit={unlock_with_passphrase}>
<h2 class="mt-6 text-lg font-bold">Passphrase</h2>
<InputField
type="password"
autoComplete="current-password"
placeholder="Passphrase"
value={passphrase.value}
onInput={(event) => passphrase.value = event.currentTarget.value}
/>
<button type="submit">Unlock</button>
<Button type="submit" variant="primary">Unlock</Button>
</form>
)}
<h2>Key file</h2>
<input type="file" accept=".txt,text/plain" onChange={unlock_with_key_file} />
<h2 class="mt-6 text-lg font-bold">Key file</h2>
<label class={button_class("link", "self-start")}>
<input type="file" accept=".txt,text/plain" class="sr-only" onChange={unlock_with_key_file} />
Choose key file
</label>
<form onSubmit={unlock_with_key_text}>
<p>Or paste the key:</p>
<textarea
<form class="flex flex-col gap-4" onSubmit={unlock_with_key_text}>
<p class="text-sm text-gray-700 dark:text-gray-400">Or paste the key:</p>
<TextAreaField
class="h-24 font-mono text-sm break-all"
autoComplete="off"
spellcheck={false}
placeholder="vces-key-v1:..."
value={key_text.value}
onInput={(event) => key_text.value = event.currentTarget.value}
/>
<button type="submit">Unlock</button>
<Button type="submit" variant="primary">Unlock</Button>
</form>
</fieldset>
{working.value && <p>Unlocking...</p>}
{error.value && <p role="alert">{error.value}</p>}
{working.value && <p class="mt-4 text-gray-800 dark:text-gray-400">Unlocking...</p>}
{error.value && <p role="alert" class="mt-4 text-error-600 dark:text-error-400">{error.value}</p>}
</div>
);
}