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
+8 -4
View File
@@ -1,5 +1,7 @@
import { Signal, useSignal, useSignalEffect } from "@preact/signals";
import Button from "@/components/Button.tsx";
import InputField from "@/components/InputField.tsx";
import Form from "@/islands/Form.tsx";
import { post_json } from "@/src/client.ts";
@@ -37,13 +39,15 @@ export default function AskCode({ page }: AskCodeProps) {
});
if (checking.value) {
return <p>Verifying code...</p>;
return <p class="text-center text-gray-800 dark:text-gray-400">Verifying code...</p>;
}
return (
<Form action="/api/verify_code" on_success={on_success}>
<input type="text" name="code" />
<button type="submit">Enter</button>
<Form class="mx-auto w-full max-w-md py-8" action="/api/verify_code" on_success={on_success}>
<div class="flex flex-col gap-4">
<InputField type="text" name="code" placeholder="Code" />
<Button type="submit" variant="primary">Enter</Button>
</div>
</Form>
);
}
+1 -1
View File
@@ -39,7 +39,7 @@ export default function Form<T = unknown>(props: FormProps<T>) {
return (
<form class={props.class} onSubmit={submit}>
<fieldset disabled={submitting.value}>{props.children}</fieldset>
{error.value && <p role="alert">{error.value}</p>}
{error.value && <p role="alert" class="mt-4 text-error-600 dark:text-error-400">{error.value}</p>}
</form>
);
}
+28 -18
View File
@@ -1,5 +1,8 @@
import { useComputed, useSignal } from "@preact/signals";
import Button from "@/components/Button.tsx";
import InputField from "@/components/InputField.tsx";
import TextAreaField from "@/components/TextAreaField.tsx";
import { post_json } from "@/src/client.ts";
import { save_master_key } from "@/src/key_store.ts";
import {
@@ -102,56 +105,63 @@ export default function KeysCreate(props: KeysCreateProps) {
if (step.value === "create") {
return (
<div>
<p>Your files are encrypted in this browser with a key the server never sees.</p>
<button type="button" onClick={create}>Create encryption key</button>
<div class="mx-auto flex max-w-md flex-col items-center py-8">
<p class="mb-6 text-center leading-normal text-gray-800 dark:text-gray-400">
Your files are encrypted in this browser with a key the server never sees.
</p>
<Button variant="primary" onClick={create}>Create encryption key</Button>
</div>
);
}
return (
<form onSubmit={finish}>
<fieldset disabled={step.value === "saving"}>
<p>Back up your key. If you lose it, your files can't be recovered, not even by the server.</p>
<form class="mx-auto max-w-md py-8" onSubmit={finish}>
<fieldset class="flex flex-col gap-4" disabled={step.value === "saving"}>
<p class="leading-normal text-gray-800 dark:text-gray-400">
Back up your key. If you lose it, your files can't be recovered, not even by the server.
</p>
<h2>Key file</h2>
<textarea readOnly value={key_text.value} />
<button type="button" onClick={download_key_file}>Download key file</button>
<label>
<h2 class="mt-4 text-lg font-bold">Key file</h2>
<TextAreaField class="h-24 font-mono text-sm break-all" readOnly value={key_text.value} />
<Button variant="link" class="self-start" onClick={download_key_file}>Download key file</Button>
<label class="flex cursor-pointer items-center gap-2 leading-normal">
<input
type="checkbox"
class="size-5 accent-primary-500"
checked={saved_file.value}
onChange={(event) => saved_file.value = event.currentTarget.checked}
/>
I saved my key file somewhere safe
</label>
<h2>Passphrase (optional)</h2>
<p>
<h2 class="mt-4 text-lg font-bold">Passphrase (optional)</h2>
<p class="text-sm leading-normal text-gray-700 dark:text-gray-400">
Stores a copy of your key on the server, locked with this passphrase, so you can unlock other
devices with it. The key file is the stronger backup.
</p>
<input
<InputField
type="password"
autoComplete="new-password"
placeholder="Passphrase"
value={passphrase.value}
onInput={(event) => passphrase.value = event.currentTarget.value}
/>
<input
<InputField
type="password"
autoComplete="new-password"
placeholder="Confirm passphrase"
value={passphrase_confirm.value}
onInput={(event) => passphrase_confirm.value = event.currentTarget.value}
/>
{passphrase_error.value && <p role="alert">{passphrase_error.value}</p>}
{passphrase_error.value && (
<p role="alert" class="text-error-600 dark:text-error-400">{passphrase_error.value}</p>
)}
<button type="submit" disabled={!can_continue.value}>
<Button type="submit" variant="primary" class="mt-4" disabled={!can_continue.value}>
{step.value === "saving" ? "Saving..." : "Continue"}
</button>
</Button>
</fieldset>
{error.value && <p role="alert">{error.value}</p>}
{error.value && <p role="alert" class="mt-4 text-error-600 dark:text-error-400">{error.value}</p>}
</form>
);
}
+3 -1
View File
@@ -54,7 +54,9 @@ export default function KeysNew(props: KeysNewProps) {
}
if (step.value === "loading" || !account.value) {
return load_error.value ? <p role="alert">{load_error.value}</p> : <p>Loading...</p>;
return load_error.value
? <p role="alert" class="text-center text-error-600 dark:text-error-400">{load_error.value}</p>
: <p class="text-center text-gray-800 dark:text-gray-400">Loading...</p>;
}
if (step.value === "create") {
+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>
);
}