mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-02 17:32:50 +08:00
Options -> Sicherheit: real master password
Identities, favorites (with their passwords), saved channel passwords and the store admin token are kept AES-GCM encrypted (PBKDF2, 310k rounds) in one localStorage entry and only decrypted in memory. The app asks for the password on load before App is imported; "forgot password" wipes the encrypted data. Enable, change and disable (the latter two re-ask the current password). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
1 parent
14aa44c1c9
commit
440e7b7ae8
9 files changed
+377
-19
No files matched your search
+78
-7
@@ -141,6 +141,7 @@ import {
|
||||
type SoundEventId,
|
||||
} from "./sounds";
|
||||
import { parseSoundpack } from "./soundpack";
|
||||
import { checkMasterPassword, isVaultUnlocked, removeMasterPassword, setMasterPassword } from "./vault";
|
||||
import {
|
||||
BUILTIN_PACK,
|
||||
NO_SOUNDS_PACK,
|
||||
@@ -6623,6 +6624,82 @@ function ChatPanel() {
|
||||
);
|
||||
}
|
||||
|
||||
/** Options -> Sicherheit -> "Master Passwort benutzen" / "ändern" (vault.ts). */
|
||||
function MasterPasswordRow() {
|
||||
const t = useT();
|
||||
const [on, setOn] = useState(isVaultUnlocked);
|
||||
// What the inline form is doing: turning it on, changing it, or turning it off.
|
||||
const [mode, setMode] = useState<"enable" | "change" | "disable" | null>(null);
|
||||
const [current, setCurrent] = useState("");
|
||||
const [next, setNext] = useState("");
|
||||
const [repeat, setRepeat] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const open = (m: typeof mode) => {
|
||||
setMode(m);
|
||||
setCurrent("");
|
||||
setNext("");
|
||||
setRepeat("");
|
||||
setError("");
|
||||
};
|
||||
const submit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (mode !== "enable" && !(await checkMasterPassword(current))) return setError(t("vault.wrong"));
|
||||
if (mode !== "disable" && next !== repeat) return setError(t("securitySettings.masterMismatch"));
|
||||
setBusy(true);
|
||||
if (mode === "disable") await removeMasterPassword();
|
||||
else await setMasterPassword(next);
|
||||
setBusy(false);
|
||||
setOn(isVaultUnlocked());
|
||||
setMode(null);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="ts-security-row">
|
||||
<label className="ts-options-checkbox" title={t("securitySettings.masterHint")}>
|
||||
<input type="checkbox" checked={on || mode === "enable"} onChange={(e) => open(e.target.checked ? "enable" : "disable")} />
|
||||
{t("securitySettings.masterPassword")}
|
||||
</label>
|
||||
<button disabled={!on} onClick={() => open("change")}>
|
||||
{t("securitySettings.changeMasterPassword")}
|
||||
</button>
|
||||
</div>
|
||||
{mode && (
|
||||
<form className="ts-master-form" onSubmit={submit}>
|
||||
{mode !== "enable" && (
|
||||
<label className="ts-dialog-field">
|
||||
{t("securitySettings.masterCurrent")}
|
||||
<input type="password" autoFocus value={current} onChange={(e) => setCurrent(e.target.value)} />
|
||||
</label>
|
||||
)}
|
||||
{mode !== "disable" && (
|
||||
<>
|
||||
<label className="ts-dialog-field">
|
||||
{t("securitySettings.masterNew")}
|
||||
<input type="password" autoFocus={mode === "enable"} value={next} onChange={(e) => setNext(e.target.value)} />
|
||||
</label>
|
||||
<label className="ts-dialog-field">
|
||||
{t("securitySettings.masterRepeat")}
|
||||
<input type="password" value={repeat} onChange={(e) => setRepeat(e.target.value)} />
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
{mode === "enable" && <p className="ts-master-note">{t("securitySettings.masterNote")}</p>}
|
||||
{error && <p className="ts-vault-wrong">{error}</p>}
|
||||
<div className="ts-security-row">
|
||||
<button type="submit" disabled={busy || (mode === "disable" ? !current : !next)}>
|
||||
{t("options.ok")}
|
||||
</button>
|
||||
<button type="button" onClick={() => setMode(null)}>
|
||||
{t("options.cancel")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function SecurityPanel({ onOpenIdentities, onClearCache }: { onOpenIdentities: () => void; onClearCache: () => void }) {
|
||||
const t = useT();
|
||||
const { security, setSecurity } = useContext(DisplayPrefsContext);
|
||||
@@ -6652,13 +6729,7 @@ function SecurityPanel({ onOpenIdentities, onClearCache }: { onOpenIdentities: (
|
||||
{t("securitySettings.clearChannelPasswords")}
|
||||
</button>
|
||||
</div>
|
||||
<div className="ts-security-row">
|
||||
<label className="ts-options-checkbox ts-options-disabled" title={t("design.notAvailable")}>
|
||||
<input type="checkbox" disabled />
|
||||
{t("securitySettings.masterPassword")}
|
||||
</label>
|
||||
<button disabled>{t("securitySettings.changeMasterPassword")}</button>
|
||||
</div>
|
||||
<MasterPasswordRow />
|
||||
</fieldset>
|
||||
<fieldset className="ts-options-fieldset">
|
||||
<legend>{t("securitySettings.cleanup")}</legend>
|
||||
|
||||
Reference in new issue
Block a user