1import { createEffect, createMemo, createSignal, For, Match, onCleanup, onMount, Show, Switch } from "solid-js";2import { sendMessage } from "../App";3import { createBreachScan } from "./breach-scan";4import { PeachMark } from "../components/PeachMark";5import { SyncModeSelector } from "../components/SyncModeSelector";6import { StackDeck } from "../components/settings/StackDeck";7import type { CardId, StackBodies, StackCardSpec } from "../components/settings/types";8import { RecoveryWordDisplayView } from "./RecoveryWordDisplay";9import { WhatsNewView } from "./WhatsNew";10import type { Canary } from "../../shared/types";11import { ACCENT_COLORS } from "../../shared/types";12import { PEACH_VERSION, hasReleaseNotes } from "../../shared/release-notes";13import type {14 AccentColorName,15 PasskeyProviderState,16 ProFeature,17 VaultSnapshot,18} from "../../shared/types";19import type { PairedDevice } from "../../shared/sync-types";20import {21 describeSyncOutcome,22 syncIndicator,23 syncIndicatorLabel,24 type SyncOutcomeSummary,25} from "../../shared/sync-outcome";26import type { SyncGeneration } from "../../background/sync-generation";27import {28 DEFAULT_BINDINGS,29 findConflict,30 formatKeybinding,31 keybindingFromEvent,32 SHORTCUT_DESCRIPTORS,33 type Keybinding,34 type ShortcutAction,35} from "../../shared/shortcuts";36import { WEB3FORMS_KEY } from "../../shared/config";37import { PRO_FEATURES, PRO_SECURITY_FEATURES } from "../pro-features";3839interface LicenseInfo {40 valid: boolean;41 plan: "free" | "pro";42 issued?: string;43}4445interface SettingsProps {46 entriesCount: number;47 breachMonitoring: boolean;48 lockOnClose: boolean;49 autoLockMinutes: number;50 lockedSyncRequiresUnlock: boolean;51 trashRetentionDays: number;52 theme: "dark" | "light";53 accentColor: AccentColorName;54 textSize: "small" | "medium" | "large";55 reduceMotion: boolean;56 isPro?: boolean;57 initialSection?: string | null;58 upgradeHighlight?: ProFeature | null;59 onBreachMonitoringChange: (enabled: boolean) => void | Promise<void>;60 onLockOnCloseChange: (enabled: boolean) => void | Promise<void>;61 onAutoLockMinutesChange: (minutes: number) => void | Promise<void>;62 onLockedSyncRequiresUnlockChange: (enabled: boolean) => void | Promise<void>;63 onTrashRetentionChange: (days: number) => void | Promise<void>;64 onThemeChange: (theme: "dark" | "light") => void;65 onAccentChange: (name: AccentColorName) => void | Promise<void>;66 onTextSizeChange: (size: "small" | "medium" | "large") => void | Promise<void>;67 onReduceMotionChange: (enabled: boolean) => void | Promise<void>;68 shortcuts: Record<ShortcutAction, Keybinding>;69 onShortcutsChange: (active: Record<ShortcutAction, Keybinding>) => void | Promise<void>;70 onLicenseChange?: () => void | Promise<void>;71 isExiting?: boolean;72 onBack: () => void;73 onImport: () => void;74 onExport: () => void;75 onBreachCheckDone: () => void;76 onOpenHealth?: () => void;77 onOpenSyncPairing?: (method?: "code") => void;78 onOpenFileImport?: () => void;79 onOpenPanic?: () => void;80 onOpenCodexGenerate?: () => void;81 onOpenCodexRestore?: () => void;82 838485 onProGate?: (feature: ProFeature) => void;86 onCardChange?: (id: CardId) => void;87}8889const FEEDBACK_CATEGORIES = ["Bug report", "Feature request", "Question", "Other"];90const MAX_FEEDBACK_MESSAGE_LENGTH = 4000;91const PRO_CELEBRATION_CARD_STEP_MS = 150;92const PRO_CELEBRATION_THANK_YOU_MS = 3200;9394function sanitizeFeedbackMessage(value: string): string {95 return value96 .trim()97 .slice(0, MAX_FEEDBACK_MESSAGE_LENGTH)98 99 .replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, "")100 .replace(/&/g, "&")101 .replace(/</g, "<")102 .replace(/>/g, ">")103 .replace(/"/g, """)104 .replace(/'/g, "'");105}106107function formatActivatedSince(issued: string | undefined): string {108 if (!issued) return "Active";109 try {110 const d = new Date(issued);111 if (Number.isNaN(d.getTime())) return "Active";112 return `Active since ${d.toLocaleDateString(undefined, { month: "long", year: "numeric" })}`;113 } catch {114 return "Active";115 }116}117118function initialSectionToCard(value: string | null | undefined): CardId | null {119 if (!value) return null;120 if (value === "security") return "protection";121 if (value === "license") return "pro";122 if (123 value === "protection" ||124 value === "vault" ||125 value === "sync" ||126 value === "appearance" ||127 value === "shortcuts" ||128 value === "pro" ||129 value === "feedback"130 ) {131 return value;132 }133 return null;134}135136137138139140const SECURE_RESET_DISCLOSURE =141 "Peach will archive this device's old Sync trust and start the new Sync generation. " +142 "Every other device must be updated first, then re-paired with this one — they will " +143 "not continue on their own. Your vault and your recovery words are not changed.";144145function secureResetHeadline(state: string | undefined): string {146 switch (state) {147 case "LEGACY_ACTIVE":148 return "Legacy Sync generation";149 case "RESET_REQUIRED":150 return "Reset required";151 case "RESET_CONFIRMED":152 return "Reset not completed";153 case "V2_ANCHOR":154 case "REPAIRING":155 return "Not re-paired";156 case "V2_ACTIVE":157 return "New Sync generation";158 case "UNKNOWN":159 return "Sync generation unreadable";160 default:161 return "Sync generation";162 }163}164165function secureResetDetail(state: string | undefined): string {166 switch (state) {167 case "LEGACY_ACTIVE":168 return "This device still holds the old Sync trust. Resetting retires it for good: update Peach on every other device, then re-pair each one.";169 case "RESET_REQUIRED":170 return "Sync is stopped until the reset completes. Update Peach on every other device, then reset this one and re-pair each device.";171 case "RESET_CONFIRMED":172 return "The reset did not finish, so Sync is paused. If Peach reports an archive problem, contact Peach support before retrying.";173 case "V2_ANCHOR":174 case "REPAIRING":175 return "This device anchors the new Sync generation and is not re-paired yet. Pair each device again; until then it keeps its own vault and cannot sync.";176 case "V2_ACTIVE":177 return "This device is on the new Sync generation. Each device is re-paired individually.";178 case "UNKNOWN":179 return "This device's Sync generation can't be read, so sync is stopped. Reinstall or contact support.";180 default:181 return "Sync state is unavailable.";182 }183}184185export function SettingsView(props: SettingsProps) {186 const manifest = chrome.runtime.getManifest();187 const version = manifest.version;188 const initial = props.initialSection;189 const [activeCard, setActiveCard] = createSignal<CardId>(190 props.upgradeHighlight ? "pro" : initialSectionToCard(initial) ?? "pro"191 );192193 createEffect(() => { props.onCardChange?.(activeCard()); });194195 const [justActivated, setJustActivated] = createSignal(false);196 const [isFanning, setIsFanning] = createSignal(false);197198 function triggerCelebration() {199 if (isFanning()) return;200 setJustActivated(false);201 setIsFanning(true);202 setActiveCard("pro");203 const fanOrder: CardId[] = ["protection", "vault", "sync", "appearance", "shortcuts", "feedback"];204 fanOrder.forEach((id, i) => {205 window.setTimeout(() => setActiveCard(id), (i + 1) * PRO_CELEBRATION_CARD_STEP_MS);206 });207 window.setTimeout(() => {208 setActiveCard("pro");209 setIsFanning(false);210 setJustActivated(true);211 window.setTimeout(() => setJustActivated(false), PRO_CELEBRATION_THANK_YOU_MS);212 }, (fanOrder.length + 1) * PRO_CELEBRATION_CARD_STEP_MS);213 }214215 function handleProCelebrationClick(e: MouseEvent) {216 e.stopPropagation();217 triggerCelebration();218 }219220 const breachScan = createBreachScan(() => props.onBreachCheckDone());221 const [licenseInfo, setLicenseInfo] = createSignal<LicenseInfo | null>(null);222 const [licenseKeyInput, setLicenseKeyInput] = createSignal("");223 const [licenseError, setLicenseError] = createSignal<string | null>(null);224 const [, setLicenseSuccess] = createSignal<string | null>(null);225 const [activatingLicense, setActivatingLicense] = createSignal(false);226227 const isPro = () => props.isPro ?? false;228 const cards = createMemo<StackCardSpec[]>(() => [229 {230 id: "pro",231 num: "I · FOREVER",232 title: "Peach Pro",233 lede: isPro() ? "active · paid once, yours forever" : "$39 once · yours forever",234 bgVar: "--stack-pro-bg",235 fgVar: "--stack-pro-fg",236 icon: "spark",237 onIconClick: isPro() ? triggerCelebration : undefined,238 },239 {240 id: "protection",241 num: "II · PROTECT",242 title: "Protection",243 lede: `${props.breachMonitoring ? "breaches watched" : "breach watch off"} · ${props.lockOnClose ? "locks on close" : "manual lock"}`,244 bgVar: "--stack-protect-bg",245 fgVar: "--stack-protect-fg",246 icon: "shield",247 },248 {249 id: "vault",250 num: "III · KEEP",251 title: "Vault",252 lede: `${props.entriesCount} ${props.entriesCount === 1 ? "entry" : "entries"} · backups, history, cleanup`,253 bgVar: "--stack-vault-bg",254 fgVar: "--stack-vault-fg",255 icon: "lock",256 },257 {258 id: "sync",259 num: "IV · ECHO",260 title: "Sync",261 lede: isPro() ? "End to End Encryption" : "Pro · encrypted device sync",262 bgVar: "--stack-sync-bg",263 fgVar: "--stack-sync-fg",264 icon: "sync",265 },266 {267 id: "appearance",268 num: "V · DRESS",269 title: "Appearance",270 lede: `${props.theme} · ${props.accentColor} · ${props.textSize}`,271 bgVar: "--stack-appear-bg",272 fgVar: "--stack-appear-fg",273 icon: "sun",274 },275 {276 id: "shortcuts",277 num: "VI · KEYS",278 title: "Shortcuts",279 lede: `${SHORTCUT_DESCRIPTORS.length} bindings · what your fingers know`,280 bgVar: "--stack-shortcut-bg",281 fgVar: "--stack-shortcut-fg",282 icon: "keys",283 },284 {285 id: "feedback",286 num: "VII · ECHO",287 title: "Feedback",288 lede: `version ${version} · tell us what would make it better`,289 bgVar: "--stack-feedback-bg",290 fgVar: "--stack-feedback-fg",291 icon: "bubble",292 },293 ]);294 const [passkeyState, setPasskeyState] = createSignal<PasskeyProviderState | null>(null);295 const [passkeySaving, setPasskeySaving] = createSignal(false);296297 298 299 interface PendingVouched {300 deviceId: string;301 deviceName: string;302 longTermPublicKeyHex: string;303 receivedAt: number;304 vouchedByDeviceId: string;305 }306 const [pendingVouched, setPendingVouched] = createSignal<PendingVouched[]>([]);307 const [vouchedBusy, setVouchedBusy] = createSignal<string | null>(null);308 309 const [pairedDevices, setPairedDevices] = createSignal<PairedDevice[]>([]);310 const [trustDataCorrupted, setTrustDataCorrupted] = createSignal(false);311312 const [confirmUnpair, setConfirmUnpair] = createSignal<string | null>(null);313 const [unpairError, setUnpairError] = createSignal<string | null>(null);314 const [renameDeviceId, setRenameDeviceId] = createSignal<string | null>(null);315 const [renameDraft, setRenameDraft] = createSignal("");316 const [syncStatus, setSyncStatus] = createSignal<"idle" | "syncing" | "error">("idle");317 const [syncFlash, setSyncFlash] = createSignal<string | null>(null);318 319 320 const [syncSummary, setSyncSummary] = createSignal<SyncOutcomeSummary>({});321 322 323 const [generation, setGeneration] = createSignal<SyncGeneration | null>(null);324 const [resetOpen, setResetOpen] = createSignal(false);325 const [resetPassword, setResetPassword] = createSignal("");326 const [resetError, setResetError] = createSignal<string | null>(null);327 const [resetting, setResetting] = createSignal(false);328 const syncLight = () =>329 syncStatus() === "syncing"330 ? "busy"331 : syncIndicator(syncSummary(), pairedDevices().length);332 const syncLightLabel = () => syncIndicatorLabel(syncLight(), syncSummary());333 const lastSyncLine = () => {334 const s = syncSummary();335 if (!s.outcome) return "No sync attempted yet";336 return `${syncRelativeTime(s.finishedAt)} · ${describeSyncOutcome(s)}`;337 };338 async function loadSyncState() {339 const r = (await sendMessage({ type: "GET_SYNC_STATE" })) as {340 ok: boolean;341 data?: SyncOutcomeSummary;342 };343 if (r.ok && r.data) {344 setSyncSummary(r.data);345 setSyncStatus(r.data.status ?? "idle");346 }347 }348349 async function loadGeneration() {350 const r = (await sendMessage({ type: "GET_SYNC_GENERATION" })) as {351 ok: boolean;352 data?: SyncGeneration | null;353 };354 if (r.ok) setGeneration(r.data ?? null);355 }356357 async function runSecureReset() {358 setResetting(true);359 const r = (await sendMessage({360 type: "SECURE_RESET",361 payload: { password: resetPassword() },362 })) as { ok: boolean; data?: SyncGeneration | null; error?: string };363 setResetting(false);364 setResetPassword("");365 if (!r.ok) {366 setResetError(r.error ?? "The reset did not complete. Check the error before retrying.");367 await loadGeneration();368 return;369 }370 setResetError(null);371 setResetOpen(false);372 if (r.data) setGeneration(r.data);373 }374375 const STALE_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000;376 function syncRelativeTime(when: number | undefined): string {377 if (!when) return "Not synced yet";378 const elapsed = Date.now() - when;379 if (elapsed < 60_000) return "Just now";380 const minutes = Math.floor(elapsed / 60_000);381 if (minutes < 60) return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;382 const hours = Math.floor(minutes / 60);383 if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;384 const days = Math.floor(hours / 24);385 return days < 7 ? `${days} day${days === 1 ? "" : "s"} ago` : "Not seen recently";386 }387 function isSyncStale(d: PairedDevice): boolean {388 return d.lastSyncedAt !== undefined && Date.now() - d.lastSyncedAt > STALE_THRESHOLD_MS;389 }390 function deviceTypeLabel(t: PairedDevice["deviceType"]): string {391 switch (t) {392 case "android": return "Android";393 case "ios": return "iPhone";394 case "extension": return "Browser";395 default: return "Device";396 }397 }398399 async function loadPairedDevices() {400 if (!isPro()) return;401 const r = (await sendMessage({ type: "LIST_PAIRED_DEVICES" })) as {402 ok: boolean;403 error?: string;404 data?: { devices: PairedDevice[] };405 };406 if (r.ok) {407 setTrustDataCorrupted(false);408 setPairedDevices(r.data?.devices ?? []);409 } else if (r.error === "trust_data_corrupted") {410 setPairedDevices([]);411 setTrustDataCorrupted(true);412 }413 }414 async function unpairDevice(deviceId: string) {415 const result = (await sendMessage({ type: "UNPAIR_DEVICE", payload: { deviceId } })) as {416 ok: boolean;417 error?: string;418 };419 if (!result.ok) {420 setUnpairError(result.error ?? "Could not remove this device");421 return;422 }423 setUnpairError(null);424 setConfirmUnpair(null);425 await loadPairedDevices();426 }427 async function renameDevice(deviceId: string) {428 const name = renameDraft().trim();429 if (!name) return;430 const result = (await sendMessage({431 type: "RENAME_PAIRED_DEVICE",432 payload: { deviceId, name },433 })) as { ok: boolean };434 if (!result.ok) return;435 setRenameDeviceId(null);436 await loadPairedDevices();437 }438 async function syncNow() {439 setSyncStatus("syncing");440 setSyncFlash(null);441 const res = (await sendMessage({442 type: "TRIGGER_SYNC",443 payload: { reason: "manual", force: true },444 })) as { ok: boolean; error?: string };445 if (!res.ok) {446 setSyncStatus("error");447 setSyncSummary({ status: "error", outcome: "run_failed", detail: res.error });448 return;449 }450 451 452 453 let s: SyncOutcomeSummary = { status: "syncing" };454 for (let i = 0; i < 40 && s.status === "syncing"; i++) {455 await new Promise((r) => setTimeout(r, 250));456 const state = (await sendMessage({ type: "GET_SYNC_STATE" })) as {457 ok: boolean;458 data?: SyncOutcomeSummary;459 };460 s = state.ok ? state.data ?? { status: "idle" } : { status: "error", outcome: "run_failed" };461 }462 setSyncSummary(s);463 setSyncStatus(s.status ?? "idle");464 465 466 setSyncFlash(describeSyncOutcome(s));467 setTimeout(() => setSyncFlash(null), 4000);468 await loadPairedDevices();469 }470 471 const [rotateConfirmOpen, setRotateConfirmOpen] = createSignal(false);472 const [rotatePassword, setRotatePassword] = createSignal("");473 const [rotating, setRotating] = createSignal(false);474 const [rotateError, setRotateError] = createSignal<string | null>(null);475 const [showSyncConnection, setShowSyncConnection] = createSignal(false);476 const [showSyncRecovery, setShowSyncRecovery] = createSignal(false);477478 async function loadPendingVouched() {479 const r = (await sendMessage({ type: "GET_PENDING_VOUCHED_DEVICES" })) as {480 ok: boolean;481 data?: PendingVouched[];482 };483 if (r.ok) setPendingVouched(r.data ?? []);484 }485 async function confirmVouched(deviceId: string) {486 setVouchedBusy(deviceId);487 try {488 await sendMessage({ type: "CONFIRM_VOUCHED_DEVICE", payload: { deviceId } });489 await loadPendingVouched();490 } finally {491 setVouchedBusy(null);492 }493 }494 async function rejectVouched(deviceId: string) {495 setVouchedBusy(deviceId);496 try {497 await sendMessage({ type: "REJECT_VOUCHED_DEVICE", payload: { deviceId } });498 await loadPendingVouched();499 } finally {500 setVouchedBusy(null);501 }502 }503 async function doRotateSyncIdentity() {504 setRotateError(null);505 const password = rotatePassword();506 if (!password) { setRotateError("enter your master password"); return; }507 setRotatePassword("");508 setRotating(true);509 try {510 const r = (await sendMessage({ type: "ROTATE_SYNC_IDENTITY", payload: { password } })) as {511 ok: boolean;512 error?: string;513 };514 if (!r.ok) {515 setRotateError(r.error === "wrong_password" ? "incorrect password" : r.error ?? "Rotation failed.");516 return;517 }518 setRotateConfirmOpen(false);519 520 setShowNewRecoveryWords(true);521 } finally {522 setRotating(false);523 }524 }525526 const [dedupCount, setDedupCount] = createSignal<number | null>(null);527 const [dedupRunning, setDedupRunning] = createSignal(false);528 const [dedupDone, setDedupDone] = createSignal<number | null>(null);529530 const [declinedCardCount, setDeclinedCardCount] = createSignal(0);531532 533 534 535 const [historySnapshots, setHistorySnapshots] = createSignal<VaultSnapshot[]>([]);536 const [historyLoading, setHistoryLoading] = createSignal(false);537 const [historyRestoring, setHistoryRestoring] = createSignal<string | null>(null);538 const [historyShowAll, setHistoryShowAll] = createSignal(false);539540 async function loadVaultHistory() {541 setHistoryLoading(true);542 try {543 const res = await sendMessage({ type: "GET_VAULT_HISTORY" });544 const list = (res as { ok: boolean; data?: VaultSnapshot[] }).data ?? [];545 setHistorySnapshots(list);546 } finally {547 setHistoryLoading(false);548 }549 }550551 async function handleRestoreVaultSnapshot(id: string) {552 if (historyRestoring()) return;553 setHistoryRestoring(id);554 const res = await sendMessage({555 type: "RESTORE_VAULT_SNAPSHOT",556 payload: { snapshotId: id },557 });558 setHistoryRestoring(null);559 if ((res as { ok: boolean }).ok) {560 561 562 props.onBack();563 }564 }565566 function formatSnapshotTime(savedAt: number): string {567 const diff = Date.now() - savedAt;568 if (diff < 60_000) return "Just now";569 if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m ago`;570 const d = new Date(savedAt);571 const isToday = new Date().toDateString() === d.toDateString();572 const isYest =573 new Date(Date.now() - 86_400_000).toDateString() === d.toDateString();574 const t = d.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });575 if (isToday) return `Today ${t}`;576 if (isYest) return `Yesterday ${t}`;577 return `${d.toLocaleDateString([], { month: "short", day: "numeric" })} ${t}`;578 }579580 function reasonLabel(reason: VaultSnapshot["reason"]): string {581 return (582 {583 local_save: "saved",584 sync_received: "synced",585 import: "imported",586 restore: "restored",587 } as const588 )[reason] ?? reason;589 }590591 const [showVaultAdvanced, setShowVaultAdvanced] = createSignal(false);592 const [showWhatsNew, setShowWhatsNew] = createSignal(false);593594 const [showChangePw, setShowChangePw] = createSignal(false);595 const [changePwCurrent, setChangePwCurrent] = createSignal("");596 const [changePwNew, setChangePwNew] = createSignal("");597 const [changePwConfirm, setChangePwConfirm] = createSignal("");598 const [changePwSaving, setChangePwSaving] = createSignal(false);599 const [changePwError, setChangePwError] = createSignal<string | null>(null);600 const [changePwSuccess] = createSignal(false);601 const [showNewRecoveryWords, setShowNewRecoveryWords] = createSignal(false);602603 const [pinEnabled, setPinEnabled] = createSignal(false);604 const [pinFlow, setPinFlow] = createSignal<"setup" | "disable" | null>(null);605 const [pinCurrentPassword, setPinCurrentPassword] = createSignal("");606 const [pinValue, setPinValue] = createSignal("");607 const [pinConfirm, setPinConfirm] = createSignal("");608 const [pinSaving, setPinSaving] = createSignal(false);609 const [pinError, setPinError] = createSignal<string | null>(null);610611 612 const [showViewWords, setShowViewWords] = createSignal(false);613 const [viewWordsPassword, setViewWordsPassword] = createSignal("");614 const [viewWordsError, setViewWordsError] = createSignal<string | null>(null);615 const [viewedWords, setViewedWords] = createSignal<string[] | null>(null);616 const [viewWordsBusy, setViewWordsBusy] = createSignal(false);617618 async function handleViewRecoveryWords() {619 setViewWordsError(null);620 if (!viewWordsPassword()) {621 setViewWordsError("Enter your master password.");622 return;623 }624 setViewWordsBusy(true);625 try {626 const r = (await sendMessage({627 type: "GET_RECOVERY_WORDS",628 payload: { password: viewWordsPassword() },629 })) as { ok: boolean; data?: string[]; error?: string };630 if (r.ok) {631 setViewedWords(r.data ?? []);632 setViewWordsPassword("");633 return;634 }635 switch (r.error) {636 case "wrong_password":637 setViewWordsError("Incorrect password");638 break;639 case "password_required":640 setViewWordsError("Enter your master password.");641 break;642 case "recovery_not_setup":643 setViewWordsError("Recovery words aren't set up for this vault yet.");644 break;645 default:646 setViewWordsError("Couldn't retrieve recovery words.");647 }648 } finally {649 setViewWordsBusy(false);650 }651 }652 function closeViewWords() {653 setShowViewWords(false);654 setViewWordsPassword("");655 setViewWordsError(null);656 setViewedWords(null);657 }658659 const [duressEnabled, setDuressEnabled] = createSignal(false);660 const [showDuressSetup, setShowDuressSetup] = createSignal(false);661 const [duressPassword, setDuressPassword] = createSignal("");662 const [duressConfirm, setDuressConfirm] = createSignal("");663 const [duressMainPassword, setDuressMainPassword] = createSignal("");664 const [duressSaving, setDuressSaving] = createSignal(false);665 const [duressError, setDuressError] = createSignal<string | null>(null);666 const [duressSuccess, setDuressSuccess] = createSignal<string | null>(null);667668 const [canaryEntries, setCanaryEntries] = createSignal<Array<{id: string; title: string; canary: Canary}>>([]);669670 const [canaryTestingId, setCanaryTestingId] = createSignal<string | null>(null);671 const [canaryTestResult, setCanaryTestResult] = createSignal<{id: string; ok: boolean} | null>(null);672673 const [fbCategory, setFbCategory] = createSignal("Bug report");674 const [fbMessage, setFbMessage] = createSignal("");675 type FeedbackState = 'idle' | 'sending' | 'sent' | 'error';676 const [feedbackState, setFeedbackState] = createSignal<FeedbackState>('idle');677678 createEffect(() => {679 if (props.upgradeHighlight) {680 setActiveCard("pro");681 }682 });683684 onMount(async () => {685 const [licenseRes, passkeyRes, duressRes, settingsRes, keyRes] = await Promise.all([686 sendMessage({ type: "GET_LICENSE" }),687 sendMessage({ type: "GET_PASSKEY_PROVIDER_STATE" }),688 sendMessage({ type: "IS_DURESS_ENABLED" }),689 sendMessage({ type: "GET_SETTINGS" }),690 sendMessage({ type: "GET_LICENSE_KEY" }),691 ]);692693 694 695 void loadVaultHistory();696697 698 699 void loadPendingVouched();700 void loadPairedDevices();701 void loadSyncState();702 void loadGeneration();703 const onBroadcast = (msg: unknown) => {704 const m = msg as { type?: string; payload?: unknown } | null;705 if (m?.type === "VOUCHED_DEVICE_PENDING") {706 void loadPendingVouched();707 }708 if (m?.type === "SYNC_STATE_CHANGED") {709 const payload = (m.payload ?? {}) as SyncOutcomeSummary;710 setSyncSummary(payload);711 setSyncStatus(payload.status ?? "idle");712 }713 };714 chrome.runtime?.onMessage?.addListener(onBroadcast);715 onCleanup(() => {716 try { chrome.runtime?.onMessage?.removeListener(onBroadcast); } catch { }717 });718719 if ((licenseRes as { ok: boolean }).ok) {720 setLicenseInfo((licenseRes as { ok: boolean; data?: LicenseInfo }).data ?? null);721 }722723 if ((passkeyRes as { ok: boolean }).ok) {724 setPasskeyState(725 (passkeyRes as { ok: boolean; data?: PasskeyProviderState }).data ?? null726 );727 }728729 if ((duressRes as { ok: boolean }).ok) {730 setDuressEnabled((duressRes as { ok: boolean; data?: boolean }).data ?? false);731 }732733 if ((settingsRes as { ok: boolean }).ok) {734 const sData = (settingsRes as { ok: boolean; data?: { declinedCardFingerprints?: string[]; pinEnabled?: boolean } }).data;735 setDeclinedCardCount(sData?.declinedCardFingerprints?.length ?? 0);736 setPinEnabled(sData?.pinEnabled === true);737 }738739 if ((keyRes as { ok: boolean }).ok) {740 setLicenseKey((keyRes as { ok: boolean; data?: string }).data ?? null);741 }742743 const entriesRes = await sendMessage({ type: "GET_ENTRIES" });744 if ((entriesRes as { ok: boolean }).ok) {745 const entries = (entriesRes as { ok: boolean; data?: Array<{id: string; title: string; canary?: Canary}> }).data ?? [];746 setCanaryEntries(747 entries748 .filter((e) => e.canary?.webhookUrl)749 .map((e) => ({ id: e.id, title: e.title, canary: e.canary! }))750 );751 }752753 });754755 function resetPinFlow() {756 setPinFlow(null);757 setPinCurrentPassword("");758 setPinValue("");759 setPinConfirm("");760 setPinError(null);761 }762763 async function handleSetupPin() {764 setPinError(null);765 if (!pinCurrentPassword()) { setPinError("enter your current password"); return; }766 if (!/^\d{4,12}$/.test(pinValue())) { setPinError("PIN must be 4–12 digits"); return; }767 if (pinValue() !== pinConfirm()) { setPinError("PINs do not match"); return; }768 setPinSaving(true);769 const res = await sendMessage({770 type: "SETUP_PIN",771 payload: { currentPassword: pinCurrentPassword(), pin: pinValue() },772 }) as { ok: boolean; error?: string };773 if (res.ok) {774 setPinEnabled(true);775 resetPinFlow();776 } else {777 setPinError(res.error === "incorrect_current_password" ? "incorrect current password" : "couldn't set up PIN");778 }779 setPinSaving(false);780 }781782 async function handleDisablePin() {783 setPinError(null);784 if (!pinCurrentPassword()) { setPinError("enter your current password"); return; }785 setPinSaving(true);786 const res = await sendMessage({787 type: "DISABLE_PIN",788 payload: { currentPassword: pinCurrentPassword() },789 }) as { ok: boolean; error?: string };790 if (res.ok) {791 setPinEnabled(false);792 resetPinFlow();793 } else {794 setPinError(res.error === "incorrect_current_password" ? "incorrect current password" : "couldn't remove PIN");795 }796 setPinSaving(false);797 }798799 async function handleChangePassword() {800 setChangePwError(null);801 if (!changePwCurrent().trim()) { setChangePwError("enter your current password"); return; }802 if (changePwNew().length < 12) { setChangePwError("new password must be at least 12 characters"); return; }803 if (changePwNew() !== changePwConfirm()) { setChangePwError("new passwords do not match"); return; }804 if (changePwNew() === changePwCurrent()) { setChangePwError("new password must differ from current"); return; }805 setChangePwSaving(true);806 const res = await sendMessage({807 type: "CHANGE_PASSWORD",808 payload: { currentPassword: changePwCurrent(), newPassword: changePwNew() },809 }) as { ok: boolean; error?: string };810 if (res.ok) {811 setChangePwCurrent(""); setChangePwNew(""); setChangePwConfirm("");812 setShowChangePw(false);813 setShowNewRecoveryWords(true);814 } else {815 setChangePwError(res.error ?? "failed to change password");816 }817 setChangePwSaving(false);818 }819820 const [copied, setCopied] = createSignal(false);821822 async function copyLicenseKey(key: string) {823 await navigator.clipboard.writeText(key);824 setCopied(true);825 setTimeout(() => setCopied(false), 2000);826 }827828 async function handleActivateLicense() {829 const key = licenseKeyInput().trim();830 if (!key) return;831 setActivatingLicense(true);832 setLicenseError(null);833 setLicenseSuccess(null);834 const res = await sendMessage({ type: "ACTIVATE_LICENSE", payload: { key } });835 setActivatingLicense(false);836 if ((res as { ok: boolean }).ok) {837 const data = (res as { ok: boolean; data?: LicenseInfo }).data;838 if (data?.valid) {839 setLicenseInfo(data);840 setLicenseKey(key);841 setLicenseSuccess("License activated!");842 setLicenseKeyInput("");843 } else {844 setLicenseError("Invalid license key");845 }846 } else {847 setLicenseError("Activation failed");848 }849 }850851 async function handleTogglePasskeys() {852 const current = passkeyState();853 if (!current || !current.supported) return;854 setPasskeySaving(true);855 const res = await sendMessage({856 type: "SET_PASSKEY_PROVIDER_ENABLED",857 payload: { enabled: !current.enabled },858 });859 setPasskeySaving(false);860 if ((res as { ok: boolean }).ok) {861 setPasskeyState(862 (res as { ok: boolean; data?: PasskeyProviderState }).data ?? null863 );864 }865 }866867868869 async function handleSetupDuress() {870 const mainPw = duressMainPassword().trim();871 const duressPw = duressPassword().trim();872 const confirmPw = duressConfirm().trim();873874 if (!mainPw) { setDuressError("enter your main password to confirm"); return; }875 if (duressPw.length < 8) { setDuressError("duress password must be at least 8 characters"); return; }876 if (duressPw === mainPw) { setDuressError("duress password must differ from your main password"); return; }877 if (duressPw !== confirmPw) { setDuressError("passwords do not match"); return; }878879 setDuressSaving(true);880 setDuressError(null);881882 const verifyRes = await sendMessage({ type: "VERIFY_MAIN_PASSWORD", payload: { password: mainPw } }) as { ok: boolean; data?: boolean };883 if (!verifyRes.ok || !verifyRes.data) {884 setDuressError("incorrect main password");885 setDuressSaving(false);886 return;887 }888889 const res = await sendMessage({ type: "SETUP_DURESS", payload: { duressPassword: duressPw } }) as { ok: boolean; error?: string };890 setDuressSaving(false);891 if (res.ok) {892 setDuressEnabled(true);893 setShowDuressSetup(false);894 setDuressPassword("");895 setDuressConfirm("");896 setDuressMainPassword("");897 setDuressSuccess("Duress password set. If entered, a decoy vault will be shown.");898 setTimeout(() => setDuressSuccess(null), 5000);899 } else {900 setDuressError(901 res.error === "session_expired"902 ? "Vault session expired — lock and unlock Peach, then try again"903 : res.error ?? "failed to set duress password"904 );905 }906 }907908 async function handleClearDeclinedCards() {909 await sendMessage({ type: "UPDATE_SETTINGS", payload: { declinedCardFingerprints: [] } });910 setDeclinedCardCount(0);911 }912913 async function handleCountDuplicates() {914 setDedupRunning(true);915 setDedupDone(null);916 const res = await sendMessage({ type: "COUNT_DUPLICATES" }) as { ok: boolean; data?: number };917 setDedupRunning(false);918 if (res.ok) setDedupCount(res.data ?? 0);919 }920921 async function handleDeduplicate() {922 setDedupRunning(true);923 const res = await sendMessage({ type: "DEDUPLICATE_ENTRIES" }) as { ok: boolean; data?: number };924 setDedupRunning(false);925 if (res.ok) {926 setDedupDone(res.data ?? 0);927 setDedupCount(0);928 }929 }930931 async function handleDisableDuress() {932 const mainPw = duressMainPassword().trim();933 if (!mainPw) { setDuressError("enter your main password to confirm"); return; }934935 setDuressSaving(true);936 setDuressError(null);937938 const verifyRes = await sendMessage({ type: "VERIFY_MAIN_PASSWORD", payload: { password: mainPw } }) as { ok: boolean; data?: boolean };939 if (!verifyRes.ok || !verifyRes.data) {940 setDuressError("incorrect main password");941 setDuressSaving(false);942 return;943 }944945 const res = await sendMessage({ type: "DISABLE_DURESS" }) as { ok: boolean; error?: string };946 setDuressSaving(false);947 if (res.ok) {948 setDuressEnabled(false);949 setShowDuressSetup(false);950 setDuressMainPassword("");951 setDuressSuccess("Duress password disabled.");952 setTimeout(() => setDuressSuccess(null), 4000);953 } else {954 setDuressError(res.error ?? "failed to disable duress password");955 }956 }957958 async function handleSubmitFeedback() {959 const message = sanitizeFeedbackMessage(fbMessage());960 if (!message) return;961962 setFeedbackState('sending');963964 try {965 const category = FEEDBACK_CATEGORIES.includes(fbCategory())966 ? fbCategory()967 : FEEDBACK_CATEGORIES[0];968 const res = await fetch('https://api.web3forms.com/submit', {969 method: 'POST',970 headers: { 'Content-Type': 'application/json' },971 body: JSON.stringify({972 access_key: WEB3FORMS_KEY,973 subject: `Peach Feedback - ${category}`,974 message,975 from_name: 'Peach User',976 977 botcheck: '',978 }),979 });980981 if (!res.ok) throw new Error(`HTTP ${res.status}`);982 const data = await res.json() as { success: boolean; message?: string };983 if (!data.success) throw new Error(data.message ?? 'unknown error');984985 setFeedbackState('sent');986 setFbMessage('');987 setFbCategory(FEEDBACK_CATEGORIES[0]);988 } catch (err) {989 console.error('[feedback]', err);990 setFeedbackState('error');991 setTimeout(() => setFeedbackState('idle'), 4000);992 }993 }994995 function renderSecurity() {996 return (997 <div class="peach-settings-body">998 <div class="peach-settings-group">999 <p class="peach-settings-sub-label">LOCKING</p>1000 <div class="peach-settings-row">1001 <span>Lock on close</span>1002 <button1003 class={`peach-toggle ${props.lockOnClose ? "is-on" : ""}`}1004 onClick={() => void props.onLockOnCloseChange(!props.lockOnClose)}1005 aria-label="Toggle lock on close"1006 >1007 <span class="peach-toggle-knob"></span>1008 </button>1009 </div>1010 <div class="peach-settings-row">1011 <span>Auto-lock after</span>1012 <select1013 class="peach-settings-select"1014 value={String(props.autoLockMinutes)}1015 onChange={(e) => void props.onAutoLockMinutesChange(Number(e.currentTarget.value))}1016 >1017 <option value="1">1 minute</option>1018 <option value="5">5 minutes</option>1019 <option value="15">15 minutes</option>1020 <option value="30">30 minutes</option>1021 <option value="0">Never</option>1022 </select>1023 </div>1024 <p class="peach-settings-sub-label">SYNC WHILE LOCKED</p>1025 <div class="peach-settings-row">1026 <span>Require unlock after restart</span>1027 <button1028 class={`peach-toggle ${props.lockedSyncRequiresUnlock ? "is-on" : ""}`}1029 onClick={() => void props.onLockedSyncRequiresUnlockChange(!props.lockedSyncRequiresUnlock)}1030 aria-label="Toggle unlock requirement for locked Sync after restart"1031 aria-pressed={props.lockedSyncRequiresUnlock}1032 >1033 <span class="peach-toggle-knob"></span>1034 </button>1035 </div>1036 <p class="peach-settings-sub-label">QUICK UNLOCK</p>1037 <div class="peach-settings-row peach-settings-row--meta">1038 <span>PIN unlock</span>1039 <button1040 class="peach-btn peach-btn--subtle peach-btn--sm"1041 onClick={() => { setPinFlow(pinEnabled() ? "disable" : "setup"); setPinError(null); }}1042 >1043 {pinEnabled() ? "remove" : "set up"}1044 </button>1045 </div>1046 <Show when={pinFlow() === "setup"}>1047 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1048 <input1049 class="peach-settings-input"1050 type="password"1051 placeholder="current password"1052 value={pinCurrentPassword()}1053 onInput={(e) => setPinCurrentPassword((e.target as HTMLInputElement).value)}1054 autocomplete="current-password"1055 />1056 <input1057 class="peach-settings-input"1058 type="password"1059 inputmode="numeric"1060 maxlength="12"1061 placeholder="new 4–12 digit PIN"1062 value={pinValue()}1063 onInput={(e) => setPinValue((e.target as HTMLInputElement).value.replace(/\D/g, "").slice(0, 12))}1064 autocomplete="off"1065 />1066 <input1067 class="peach-settings-input"1068 type="password"1069 inputmode="numeric"1070 maxlength="12"1071 placeholder="confirm PIN"1072 value={pinConfirm()}1073 onInput={(e) => setPinConfirm((e.target as HTMLInputElement).value.replace(/\D/g, "").slice(0, 12))}1074 autocomplete="off"1075 onKeyDown={(e) => { if (e.key === "Enter") void handleSetupPin(); }}1076 />1077 <Show when={pinError()}>1078 <p class="peach-hint peach-hint-error" style="margin:0">{pinError()}</p>1079 </Show>1080 <button1081 class="peach-btn peach-btn--accent peach-btn--sm"1082 style="align-self:flex-start"1083 onClick={() => void handleSetupPin()}1084 disabled={pinSaving() || !pinCurrentPassword() || !/^\d{4,12}$/.test(pinValue()) || !/^\d{4,12}$/.test(pinConfirm())}1085 >1086 {pinSaving() ? "saving…" : "save PIN"}1087 </button>1088 </div>1089 </Show>1090 <Show when={pinFlow() === "disable"}>1091 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1092 <input1093 class="peach-settings-input"1094 type="password"1095 placeholder="current password"1096 value={pinCurrentPassword()}1097 onInput={(e) => setPinCurrentPassword((e.target as HTMLInputElement).value)}1098 autocomplete="current-password"1099 onKeyDown={(e) => { if (e.key === "Enter") void handleDisablePin(); }}1100 />1101 <Show when={pinError()}>1102 <p class="peach-hint peach-hint-error" style="margin:0">{pinError()}</p>1103 </Show>1104 <button1105 class="peach-btn peach-btn--subtle peach-btn--sm"1106 style="align-self:flex-start"1107 onClick={() => void handleDisablePin()}1108 disabled={pinSaving() || !pinCurrentPassword()}1109 >1110 {pinSaving() ? "removing…" : "remove PIN"}1111 </button>1112 </div>1113 </Show>11141115 <p class="peach-settings-sub-label">BREACH PROTECTION</p>1116 <div class="peach-settings-row">1117 <span>Breach monitoring</span>1118 <button1119 class={`peach-toggle ${props.breachMonitoring ? "is-on" : ""}`}1120 onClick={() => void props.onBreachMonitoringChange(!props.breachMonitoring)}1121 aria-label="Toggle breach monitoring"1122 >1123 <span class="peach-toggle-knob"></span>1124 </button>1125 </div>1126 <div class="peach-settings-row peach-settings-row--meta">1127 <span>Check all passwords</span>1128 <button1129 class="peach-btn peach-btn--subtle peach-btn--sm"1130 onClick={() => void breachScan.start()}1131 disabled={breachScan.checking()}1132 >1133 {breachScan.checking() ? "checking..." : "run"}1134 </button>1135 </div>1136 <Show when={breachScan.result()}>1137 <div class="peach-settings-row peach-settings-row--meta">1138 <span>Current check</span>1139 <span class="peach-settings-value" role="status">{breachScan.result()}</span>1140 </div>1141 </Show>11421143 <p class="peach-settings-sub-label">MASTER PASSWORD</p>1144 <div class="peach-settings-row peach-settings-row--meta">1145 <span>Master password</span>1146 <button1147 class="peach-btn peach-btn--subtle peach-btn--sm"1148 onClick={() => { setShowChangePw((v) => !v); setChangePwError(null); }}1149 >1150 {showChangePw() ? "cancel" : "change"}1151 </button>1152 </div>1153 <Show when={showChangePw()}>1154 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1155 <input1156 class="peach-settings-input"1157 type="password"1158 placeholder="current password"1159 value={changePwCurrent()}1160 onInput={(e) => setChangePwCurrent((e.target as HTMLInputElement).value)}1161 autocomplete="current-password"1162 />1163 <input1164 class="peach-settings-input"1165 type="password"1166 placeholder="new password (min 12 chars)"1167 value={changePwNew()}1168 onInput={(e) => setChangePwNew((e.target as HTMLInputElement).value)}1169 autocomplete="new-password"1170 />1171 <input1172 class="peach-settings-input"1173 type="password"1174 placeholder="confirm new password"1175 value={changePwConfirm()}1176 onInput={(e) => setChangePwConfirm((e.target as HTMLInputElement).value)}1177 autocomplete="new-password"1178 onKeyDown={(e) => { if (e.key === "Enter") void handleChangePassword(); }}1179 />1180 <Show when={changePwError()}>1181 <p class="peach-hint peach-hint-error" style="margin:0">{changePwError()}</p>1182 </Show>1183 <Show when={changePwSuccess()}>1184 <p class="peach-hint" style="margin:0;color:var(--peach-accent)">password changed ✓</p>1185 </Show>1186 <button1187 class="peach-btn peach-btn--accent peach-btn--sm"1188 style="align-self:flex-start"1189 onClick={() => void handleChangePassword()}1190 disabled={changePwSaving() || !changePwCurrent() || !changePwNew() || !changePwConfirm()}1191 >1192 {changePwSaving() ? "saving…" : "save new password"}1193 </button>1194 </div>1195 </Show>11961197 {}1198 <div class="peach-settings-row peach-settings-row--meta">1199 <span>Recovery words</span>1200 <button1201 class="peach-btn peach-btn--subtle peach-btn--sm"1202 onClick={() => {1203 if (showViewWords()) { closeViewWords(); } else { setShowViewWords(true); }1204 }}1205 >1206 {showViewWords() ? "cancel" : "view"}1207 </button>1208 </div>1209 <Show when={showViewWords()}>1210 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1211 <Show1212 when={viewedWords()}1213 fallback={1214 <>1215 <p class="peach-hint" style="margin:0;color:var(--peach-t2)">1216 Enter your master password to reveal your recovery words.1217 </p>1218 <input1219 class="peach-settings-input"1220 type="password"1221 placeholder="master password"1222 value={viewWordsPassword()}1223 onInput={(e) => setViewWordsPassword((e.target as HTMLInputElement).value)}1224 autocomplete="current-password"1225 onKeyDown={(e) => { if (e.key === "Enter") void handleViewRecoveryWords(); }}1226 />1227 <Show when={viewWordsError()}>1228 <p class="peach-hint peach-hint-error" style="margin:0">{viewWordsError()}</p>1229 </Show>1230 <button1231 class="peach-btn peach-btn--accent peach-btn--sm"1232 style="align-self:flex-start"1233 onClick={() => void handleViewRecoveryWords()}1234 disabled={viewWordsBusy() || !viewWordsPassword()}1235 >1236 {viewWordsBusy() ? "checking…" : "reveal recovery words"}1237 </button>1238 </>1239 }1240 >1241 <div class="peach-recovery-words-grid">1242 <For each={viewedWords()!}>1243 {(word, i) => (1244 <span class="peach-recovery-word"><b>{i() + 1}</b> {word}</span>1245 )}1246 </For>1247 </div>1248 <button1249 class="peach-btn peach-btn--subtle peach-btn--sm"1250 style="align-self:flex-start"1251 onClick={closeViewWords}1252 >done</button>1253 </Show>1254 </div>1255 </Show>12561257 <p class="peach-settings-sub-label">1258 DURESS PASSWORD1259 <Show when={!isPro()}>1260 <span class="peach-pro-mark" aria-label="Pro feature" style="margin-left:6px">✦</span>1261 </Show>1262 </p>1263 <div class="peach-settings-row peach-settings-row--top">1264 <div class="peach-settings-row-main">1265 <span>1266 Duress password1267 <Show when={!isPro()}>1268 <span class="peach-pro-badge">Pro</span>1269 </Show>1270 </span>1271 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--t2)">1272 If entered under coercion, shows a decoy empty vault instead of your real one.1273 </span>1274 </div>1275 <div class={`peach-duress-status-pill ${duressEnabled() ? "is-active" : ""}`}>1276 {duressEnabled() ? "on" : "off"}1277 </div>1278 </div>12791280 <Show when={duressEnabled() && !showDuressSetup()}>1281 <div class="peach-settings-row peach-settings-row--meta">1282 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1283 If someone forces you to unlock Peach, enter the duress password instead. A decoy empty vault opens; your real vault stays hidden. The encrypted storage is identical in size whether a hidden vault exists or not, so the hidden vault cannot be proven or disproven without both passwords. This protects against a coercer who demands your password — not against device malware or someone who already has your device unlocked.1284 </span>1285 </div>1286 </Show>12871288 <Show when={duressSuccess()}>1289 <div class="peach-settings-row peach-settings-row--meta">1290 <span class="peach-settings-value" style="color:var(--peach-sync-ok)">{duressSuccess()}</span>1291 </div>1292 </Show>12931294 <Show when={!showDuressSetup()}>1295 <div class="peach-settings-row peach-settings-row--meta">1296 <button1297 class="peach-btn peach-btn--subtle peach-btn--sm"1298 onClick={() => {1299 1300 1301 1302 1303 1304 if (!isPro() && !duressEnabled()) {1305 props.onProGate?.("duress_vault");1306 setActiveCard("pro");1307 return;1308 }1309 setShowDuressSetup(true);1310 setDuressError(null);1311 setDuressSuccess(null);1312 setDuressPassword("");1313 setDuressConfirm("");1314 setDuressMainPassword("");1315 }}1316 >1317 {duressEnabled() ? "Change / disable" : "Set up"}1318 </button>1319 </div>1320 </Show>13211322 <Show when={showDuressSetup()}>1323 <div class="peach-duress-form">1324 <label class="peach-label">main password (to confirm)</label>1325 <input1326 class="peach-settings-input"1327 type="password"1328 placeholder="your current master password"1329 autocomplete="current-password"1330 value={duressMainPassword()}1331 onInput={(e) => setDuressMainPassword(e.currentTarget.value)}1332 />1333 <Show when={!duressEnabled()}>1334 <label class="peach-label">new duress password</label>1335 <input1336 class="peach-settings-input"1337 type="password"1338 placeholder="duress password (min 8 chars)"1339 autocomplete="new-password"1340 value={duressPassword()}1341 onInput={(e) => setDuressPassword(e.currentTarget.value)}1342 />1343 <label class="peach-label">confirm duress password</label>1344 <input1345 class="peach-settings-input"1346 type="password"1347 placeholder="confirm duress password"1348 autocomplete="new-password"1349 value={duressConfirm()}1350 onInput={(e) => setDuressConfirm(e.currentTarget.value)}1351 />1352 </Show>13531354 <Show when={duressError()}>1355 <p class="peach-hint peach-hint-error">{duressError()}</p>1356 </Show>13571358 <div class="peach-duress-actions">1359 <button1360 class="peach-btn peach-btn--subtle peach-btn--sm"1361 onClick={() => { setShowDuressSetup(false); setDuressError(null); }}1362 >1363 cancel1364 </button>1365 <Show when={duressEnabled()}>1366 <button1367 class="peach-btn peach-btn--ghost peach-btn--sm"1368 style="color:var(--peach-breach)"1369 onClick={() => void handleDisableDuress()}1370 disabled={duressSaving()}1371 >1372 {duressSaving() ? "disabling..." : "disable duress"}1373 </button>1374 </Show>1375 <Show when={!duressEnabled()}>1376 <button1377 class="peach-btn peach-btn--accent peach-btn--sm"1378 onClick={() => void handleSetupDuress()}1379 disabled={duressSaving() || !duressMainPassword() || !duressPassword() || !duressConfirm()}1380 >1381 {duressSaving() ? "saving..." : "save"}1382 </button>1383 </Show>1384 </div>1385 </div>1386 </Show>13871388 <p class="peach-settings-sub-label">1389 CANARY ENTRIES1390 <Show when={!isPro()}>1391 <span class="peach-pro-mark" aria-label="Pro feature" style="margin-left:6px">✦</span>1392 </Show>1393 </p>1394 <div class="peach-settings-row peach-settings-row--top">1395 <div class="peach-settings-row-main">1396 <span>1397 Canary entries1398 <Show when={!isPro()}>1399 <span class="peach-pro-badge">Pro</span>1400 </Show>1401 </span>1402 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1403 Silently pings a webhook when an entry is accessed. Configure canary on any entry in your vault.1404 </span>1405 </div>1406 <span class="peach-settings-value" style="flex-shrink:0">1407 {canaryEntries().length > 0 ? `${canaryEntries().length} active` : "none"}1408 </span>1409 </div>1410 <Show when={canaryEntries().length > 0}>1411 <For each={canaryEntries()}>1412 {(entry) => (1413 <div class="peach-settings-row peach-settings-row--meta">1414 <span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0">{entry.title}</span>1415 <button1416 class="peach-btn peach-btn--subtle peach-btn--sm"1417 onClick={() => void handleTestCanary(entry)}1418 disabled={canaryTestingId() === entry.id}1419 style="flex-shrink:0"1420 >1421 {canaryTestingId() === entry.id1422 ? "sending…"1423 : canaryTestResult()?.id === entry.id1424 ? (canaryTestResult()!.ok ? "sent ✓" : "failed ✗")1425 : "test"}1426 </button>1427 </div>1428 )}1429 </For>1430 </Show>14311432 <p class="peach-settings-sub-label">PASSKEYS</p>1433 <div class="peach-settings-row peach-settings-row--top">1434 <div class="peach-settings-row-main">1435 <span>Intercept passkey requests</span>1436 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--t2)">1437 Use Peach for passkey sign-in and creation in Chrome and Firefox.1438 </span>1439 </div>1440 <button1441 class={`peach-toggle ${passkeyState()?.enabled ? "is-on" : ""}`}1442 onClick={() => void handleTogglePasskeys()}1443 aria-label="Toggle passkey interception"1444 disabled={!passkeyState()?.supported || passkeySaving()}1445 >1446 <span class="peach-toggle-knob"></span>1447 </button>1448 </div>1449 <div class="peach-settings-row peach-settings-row--meta">1450 <span>Status</span>1451 <span class="peach-settings-value">{passkeyState()?.statusLabel ?? "Unavailable"}</span>1452 </div>1453 <div class="peach-settings-row peach-settings-row--meta">1454 <span>Browser</span>1455 <span class="peach-settings-value">1456 {passkeyState()?.browserLabel ?? "Unknown"}1457 {passkeyState()?.supported ? " ✓" : " (interception unavailable)"}1458 </span>1459 </div>1460 <div class="peach-info-notice" style="margin-top:8px">1461 Only one passkey provider can be active at a time. Disable Bitwarden or 1Password passkey interception if Peach reports a conflict.1462 </div>1463 <Show when={passkeyState()?.conflict}>1464 <div class="peach-settings-row peach-settings-row--meta">1465 <span class="peach-settings-value" style="color:#e7b36b">{passkeyState()!.conflict}</span>1466 </div>1467 </Show>1468 </div>1469 </div>1470 );1471 }14721473 function renderVault() {1474 return (1475 <div class="peach-settings-body">1476 <div class="peach-settings-group">1477 <p class="peach-settings-sub-label">ENTRIES</p>1478 <div class="peach-settings-row peach-settings-row--meta">1479 <span>Entries</span>1480 <span class="peach-settings-value">{props.entriesCount}</span>1481 </div>1482 <div class="peach-settings-row peach-settings-row--meta">1483 <span>Duplicates</span>1484 <Show when={dedupDone() !== null} fallback={1485 <button1486 class="peach-btn peach-btn--subtle peach-btn--sm"1487 onClick={() => void handleCountDuplicates()}1488 disabled={dedupRunning()}1489 >1490 {dedupRunning() ? "scanning..." : dedupCount() === null ? "scan" : dedupCount() === 0 ? "none found" : `${dedupCount()} found — remove?`}1491 </button>1492 }>1493 <span class="peach-settings-value" style="color:var(--peach-sync-ok)">1494 {dedupDone() === 0 ? "already clean" : `removed ${dedupDone()}`}1495 </span>1496 </Show>1497 </div>1498 <Show when={dedupCount() !== null && dedupCount()! > 0 && dedupDone() === null}>1499 <div class="peach-settings-row peach-settings-row--meta" style="flex-direction:column;align-items:stretch;gap:6px">1500 <div class="peach-restore-warning">1501 {dedupCount()} duplicate {dedupCount() === 1 ? "entry" : "entries"} found. The newest copy of each will be kept; older duplicates will be moved to trash.1502 </div>1503 <div style="display:flex;gap:6px">1504 <button1505 class="peach-btn peach-btn--subtle peach-btn--sm"1506 onClick={() => setDedupCount(null)}1507 >1508 cancel1509 </button>1510 <button1511 class="peach-btn peach-btn--accent peach-btn--sm"1512 onClick={() => void handleDeduplicate()}1513 disabled={dedupRunning()}1514 >1515 {dedupRunning() ? "removing..." : "remove duplicates"}1516 </button>1517 </div>1518 </div>1519 </Show>15201521 <p class="peach-settings-sub-label">MAINTENANCE</p>1522 <div class="peach-settings-row peach-settings-row--meta">1523 <span>Trash auto-delete</span>1524 <select1525 class="peach-settings-select"1526 value={String(props.trashRetentionDays)}1527 onChange={(e) => void props.onTrashRetentionChange(Number(e.currentTarget.value))}1528 >1529 <option value="7">7 days</option>1530 <option value="30">30 days</option>1531 <option value="90">90 days</option>1532 <option value="0">Never</option>1533 </select>1534 </div>1535 <div class="peach-settings-row peach-settings-row--meta">1536 <span>Advanced Vault Health</span>1537 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={props.onOpenHealth}>1538 open1539 </button>1540 </div>1541 <Show when={declinedCardCount() > 0}>1542 <div class="peach-settings-row peach-settings-row--meta">1543 <span>{declinedCardCount()} card{declinedCardCount() === 1 ? '' : 's'} set to never save</span>1544 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => void handleClearDeclinedCards()}>1545 Clear1546 </button>1547 </div>1548 </Show>15491550 <p class="peach-settings-sub-label">DATA</p>1551 <div class="peach-settings-row peach-settings-row--meta">1552 <span>Import passwords</span>1553 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={props.onImport}>1554 open1555 </button>1556 </div>1557 <div class="peach-settings-row peach-settings-row--meta">1558 <span>Export backup</span>1559 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={props.onExport}>1560 open1561 </button>1562 </div>1563 <div class="peach-settings-row peach-settings-row--meta">1564 <span>1565 Peach Codex1566 <Show when={!isPro()}>1567 <span class="peach-pro-badge">Pro</span>1568 </Show>1569 </span>1570 <button1571 class="peach-btn peach-btn--subtle peach-btn--sm"1572 onClick={() => props.onOpenCodexGenerate?.()}1573 >1574 open1575 </button>1576 </div>1577 {1578}1579 <div class="peach-settings-row peach-settings-row--meta">1580 <span>Restore from Codex</span>1581 <button1582 class="peach-btn peach-btn--subtle peach-btn--sm"1583 onClick={() => props.onOpenCodexRestore?.()}1584 >1585 open1586 </button>1587 </div>15881589 <Show when={hasReleaseNotes()}>1590 <p class="peach-settings-sub-label">RELEASE NOTES</p>1591 <div class="peach-settings-row peach-settings-row--meta">1592 <span>v{PEACH_VERSION}</span>1593 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => setShowWhatsNew(true)}>1594 view1595 </button>1596 </div>1597 </Show>15981599 <span class="peach-settings-sub-label">VAULT HISTORY</span>1600 <Show when={historyLoading()}>1601 <p class="peach-settings-hint">Loading…</p>1602 </Show>1603 <Show when={!historyLoading() && historySnapshots().length === 0}>1604 <p class="peach-settings-hint">1605 No snapshots yet. Peach saves automatically before every change —1606 saves, syncs, and imports.1607 </p>1608 </Show>1609 <Show when={!historyLoading() && historySnapshots().length > 0}>1610 <p class="peach-settings-hint">1611 Restoring locks your vault. Unlock with the password that1612 encrypted that snapshot to confirm.1613 </p>1614 <div class="peach-history-list">1615 <For each={historySnapshots().slice(0, historyShowAll() ? undefined : 3)}>1616 {(snap) => (1617 <div class="peach-history-row">1618 <div class="peach-history-meta">1619 <span class="peach-history-time">1620 {formatSnapshotTime(snap.savedAt)}1621 </span>1622 <span class="peach-history-sub">1623 {[1624 snap.entryCount !== null1625 ? `up to ${snap.entryCount} ${snap.entryCount === 1 ? "entry" : "entries"}`1626 : null,1627 reasonLabel(snap.reason),1628 ]1629 .filter(Boolean)1630 .join(" · ")}1631 </span>1632 </div>1633 <button1634 class={`peach-btn peach-btn--subtle peach-btn--sm peach-history-btn${1635 historyRestoring() === snap.id ? " is-busy" : ""1636 }`}1637 onClick={() => void handleRestoreVaultSnapshot(snap.id)}1638 disabled={historyRestoring() !== null}1639 >1640 <Show when={historyRestoring() === snap.id} fallback="Restore">1641 …1642 </Show>1643 </button>1644 </div>1645 )}1646 </For>1647 </div>1648 <Show when={historySnapshots().length > 3}>1649 <button1650 class="peach-settings-advanced-toggle"1651 onClick={() => setHistoryShowAll((v) => !v)}1652 aria-expanded={historyShowAll()}1653 >1654 <span class="peach-settings-hint" style="margin:0">1655 {historyShowAll() ? "show less" : `${historySnapshots().length - 3} older`}1656 </span>1657 <span class="peach-settings-advanced-chevron">1658 {historyShowAll() ? "▲" : "▼"}1659 </span>1660 </button>1661 </Show>1662 <p class="peach-history-footer">1663 {historySnapshots().length} of 10 snapshots1664 </p>1665 </Show>16661667 <button1668 class="peach-settings-advanced-toggle"1669 onClick={() => setShowVaultAdvanced((v) => !v)}1670 aria-expanded={showVaultAdvanced()}1671 >1672 <span class="peach-settings-sub-label" style="margin:0">ADVANCED</span>1673 <span class="peach-settings-advanced-chevron">1674 {showVaultAdvanced() ? "▲" : "▼"}1675 </span>1676 </button>16771678 <Show when={showVaultAdvanced()}>1679 <div class="peach-danger-card">1680 <div class="peach-danger-card-head">1681 <span class="peach-danger-card-glyph" aria-hidden="true">⟳</span>1682 <h3 class="peach-danger-card-title">Replace vault from backup</h3>1683 </div>1684 <p class="peach-danger-card-copy">1685 Wipes the current vault and restores from a backup file.1686 Recoverable only if your backup is good.1687 </p>1688 <button1689 class="peach-danger-card-button"1690 onClick={() => props.onOpenFileImport?.()}1691 >1692 Choose backup file1693 </button>1694 </div>16951696 <Show when={props.onOpenPanic}>1697 <div class="peach-danger-card peach-danger-card--hazard">1698 <div class="peach-danger-card-head">1699 <span class="peach-danger-card-glyph" aria-hidden="true">⚠</span>1700 <h3 class="peach-danger-card-title">Destroy vault</h3>1701 </div>1702 <p class="peach-danger-card-copy">1703 Permanently wipes every entry, setting, and license on this1704 device. There is no recovery.1705 </p>1706 <button1707 class="peach-danger-card-button"1708 onClick={() => props.onOpenPanic?.()}1709 >1710 Begin destruction1711 </button>1712 </div>1713 </Show>1714 </Show>1715 </div>1716 </div>1717 );1718 }17191720 function renderSync() {1721 return (1722 <div class="peach-settings-body">1723 <div class="peach-settings-group">1724 <p class="peach-settings-sub-label" style="margin-top:0">SYNC STATUS</p>1725 <Show when={trustDataCorrupted()}>1726 <p class="peach-settings-value" role="alert" style="color:var(--peach-danger,#e5805c);line-height:1.5">1727 Device trust data is damaged — re-pair your devices after updating1728 </p>1729 </Show>1730 <div1731 class="peach-settings-row peach-settings-row--meta"1732 style="align-items:center;gap:8px"1733 aria-label={syncLightLabel()}1734 title={syncLightLabel()}1735 >1736 <span class={`stk-pip stk-pip--sync is-${syncLight()}`} aria-hidden="true" />1737 <span class="peach-settings-value" style="color:var(--peach-t2);line-height:1.5;flex:1;min-width:0;overflow-wrap:anywhere">1738 {syncFlash() ?? lastSyncLine()}1739 </span>1740 {17411742}1743 <Show when={pairedDevices().length > 0}>1744 <button1745 class="peach-btn peach-btn--subtle peach-btn--sm"1746 aria-label="Sync this vault now"1747 disabled={syncStatus() === "syncing"}1748 onClick={() => void syncNow()}1749 >{syncStatus() === "syncing" ? "syncing…" : "sync now"}</button>1750 </Show>1751 </div>17521753 {17541755}1756 <Show when={generation()?.state && generation()?.state !== "V2_ACTIVE"}>1757 <p class="peach-settings-sub-label">SECURE SYNC RESET</p>1758 <div class="peach-settings-row peach-settings-row--top">1759 <div class="peach-settings-row-main">1760 <span class="peach-settings-value" style="color:var(--peach-t1)">1761 {secureResetHeadline(generation()?.state)}1762 </span>1763 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1764 {secureResetDetail(generation()?.state)}1765 </span>1766 </div>1767 <Show1768 when={1769 generation()?.state === "LEGACY_ACTIVE" ||1770 generation()?.state === "RESET_REQUIRED" ||1771 generation()?.state === "RESET_CONFIRMED"1772 }1773 >1774 <button1775 class="peach-btn peach-btn--subtle peach-btn--sm"1776 onClick={() => {1777 setResetError(null);1778 setResetPassword("");1779 setResetOpen(true);1780 }}1781 >reset sync</button>1782 </Show>1783 </div>1784 <Show when={resetError()}>1785 <p1786 class="peach-settings-value"1787 role="alert"1788 style="color:var(--peach-danger,#e5805c);font-size:11px;line-height:1.5"1789 >{resetError()}</p>1790 </Show>1791 <Show when={resetOpen()}>1792 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1793 <p class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1794 {SECURE_RESET_DISCLOSURE}1795 </p>1796 <input1797 class="peach-settings-input"1798 type="password"1799 placeholder="master password"1800 value={resetPassword()}1801 onInput={(e) => setResetPassword((e.target as HTMLInputElement).value)}1802 autocomplete="current-password"1803 />1804 <div style="display:flex;gap:4px">1805 <button1806 class="peach-btn peach-btn--subtle peach-btn--sm"1807 disabled={resetting()}1808 onClick={() => void runSecureReset()}1809 >{resetting() ? "resetting…" : "reset"}</button>1810 <button1811 class="peach-btn peach-btn--subtle peach-btn--sm"1812 disabled={resetting()}1813 onClick={() => setResetOpen(false)}1814 >cancel</button>1815 </div>1816 </div>1817 </Show>1818 </Show>18191820 <Show when={pairedDevices().length > 0}>1821 <p class="peach-settings-sub-label">PAIRED DEVICES</p>1822 <For each={pairedDevices()}>1823 {(d) => (1824 <div class="peach-settings-row peach-settings-row--top">1825 <div class="peach-settings-row-main">1826 <Show1827 when={renameDeviceId() === d.deviceId}1828 fallback={<span>{d.localAlias ?? d.deviceName ?? "Unnamed device"}</span>}1829 >1830 <input1831 class="peach-settings-input"1832 aria-label={`Rename ${d.localAlias ?? d.deviceName ?? "device"}`}1833 maxlength={64}1834 value={renameDraft()}1835 onInput={(event) => setRenameDraft(event.currentTarget.value)}1836 onKeyDown={(event) => {1837 if (event.key === "Enter") void renameDevice(d.deviceId);1838 if (event.key === "Escape") setRenameDeviceId(null);1839 }}1840 />1841 </Show>1842 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1843 {deviceTypeLabel(d.deviceType)} · {syncRelativeTime(d.lastSyncedAt)}{isSyncStale(d) ? " · not seen recently" : ""}1844 </span>1845 </div>1846 <Show1847 when={confirmUnpair() === d.deviceId}1848 fallback={1849 <div style="display:flex;gap:4px;flex-shrink:0">1850 <Show1851 when={renameDeviceId() === d.deviceId}1852 fallback={1853 <button1854 class="peach-btn peach-btn--subtle peach-btn--sm"1855 onClick={() => {1856 setRenameDraft(d.localAlias ?? d.deviceName ?? "");1857 setRenameDeviceId(d.deviceId);1858 }}1859 >rename</button>1860 }1861 >1862 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => setRenameDeviceId(null)}>cancel</button>1863 <button class="peach-btn peach-btn--subtle peach-btn--sm" disabled={!renameDraft().trim()} onClick={() => void renameDevice(d.deviceId)}>save</button>1864 </Show>1865 <button1866 class="peach-btn peach-btn--subtle peach-btn--sm"1867 onClick={() => {1868 setUnpairError(null);1869 setConfirmUnpair(d.deviceId);1870 }}1871 >remove</button>1872 </div>1873 }1874 >1875 {18761877187818791880}1881 <div class="peach-unpair-confirm">1882 <p class="peach-unpair-confirm-note">1883 Stops this device receiving future changes. It doesn't1884 lock it out of what it already has — if it's lost or1885 stolen, also change your master password and generate1886 new recovery words.1887 </p>1888 <div style="display:flex;gap:6px;justify-content:flex-end">1889 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => setConfirmUnpair(null)}>cancel</button>1890 <button1891 class="peach-btn peach-btn--sm"1892 style="background:var(--peach-breach);border-color:var(--peach-breach)"1893 onClick={() => void unpairDevice(d.deviceId)}1894 >remove</button>1895 </div>1896 </div>1897 <Show when={unpairError()}>1898 <p class="peach-settings-value" role="alert" style="color:var(--peach-danger,#e5805c);font-size:11px;line-height:1.5">1899 {unpairError()}1900 </p>1901 </Show>1902 </Show>1903 </div>1904 )}1905 </For>1906 </Show>19071908 <Show when={pendingVouched().length > 0}>1909 <p class="peach-settings-sub-label">1910 PENDING DEVICES1911 <span class="peach-pro-badge" style="background:#C8A840;color:#1a1a1a">{pendingVouched().length}</span>1912 </p>1913 <For each={pendingVouched()}>1914 {(dev) => (1915 <div class="peach-settings-row peach-settings-row--top">1916 <div class="peach-settings-row-main">1917 <span>{dev.deviceName}</span>1918 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1919 Key {dev.longTermPublicKeyHex.slice(0, 12).match(/.{4}/g)?.join(" ")} ·1920 requested {new Date(dev.receivedAt).toISOString().slice(0, 16).replace("T", " ")} UTC ·1921 vouched by device {dev.vouchedByDeviceId}. Allowing it can read1922 existing vault contents and all future changes.1923 </span>1924 </div>1925 <div style="display:flex;gap:6px;flex-shrink:0">1926 <button1927 class="peach-btn peach-btn--sm"1928 disabled={vouchedBusy() === dev.deviceId}1929 onClick={() => void confirmVouched(dev.deviceId)}1930 >Allow</button>1931 <button1932 class="peach-btn peach-btn--subtle peach-btn--sm"1933 disabled={vouchedBusy() === dev.deviceId}1934 onClick={() => void rejectVouched(dev.deviceId)}1935 >Reject</button>1936 </div>1937 </div>1938 )}1939 </For>1940 </Show>19411942 <p class="peach-settings-sub-label">ADD A DEVICE</p>1943 <button1944 class="peach-sync-pair-option"1945 onClick={() => props.onOpenSyncPairing?.("code")}1946 >1947 <span class="peach-sync-pair-option-icon" aria-hidden="true">1948 <svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">1949 <rect x="6" y="2.5" width="8" height="15" rx="1.6" />1950 <path d="M9 15 L11 15" />1951 </svg>1952 </span>1953 <span class="peach-sync-pair-option-main">1954 <span class="peach-sync-pair-option-title">Show a code</span>1955 <span class="peach-sync-pair-option-sub">Scan it with Peach on your phone, then confirm one 8-digit code</span>1956 </span>1957 <span class="peach-sync-pair-option-chevron" aria-hidden="true">›</span>1958 </button>1959 <Show when={!isPro()}>1960 <p class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2);margin:8px 2px 0">1961 At least one device needs Peach Pro — pair with a Pro device and it carries over to here.1962 </p>1963 </Show>19641965 <button1966 class="peach-settings-advanced-toggle peach-sync-disclosure-toggle"1967 onClick={() => setShowSyncConnection((value) => !value)}1968 aria-expanded={showSyncConnection()}1969 aria-controls="peach-sync-connection"1970 >1971 <span>1972 <span class="peach-settings-sub-label" style="margin:0">CONNECTION</span>1973 <span class="peach-sync-disclosure-summary">Relay and privacy choices</span>1974 </span>1975 <span class="peach-settings-advanced-chevron">1976 {showSyncConnection() ? "▲" : "▼"}1977 </span>1978 </button>1979 <Show when={showSyncConnection()}>1980 <div id="peach-sync-connection" class="peach-sync-disclosure-content">1981 <SyncModeSelector />1982 </div>1983 </Show>19841985 <button1986 class="peach-settings-advanced-toggle peach-sync-disclosure-toggle"1987 onClick={() => setShowSyncRecovery((value) => !value)}1988 aria-expanded={showSyncRecovery()}1989 aria-controls="peach-sync-recovery"1990 >1991 <span>1992 <span class="peach-settings-sub-label" style="margin:0">RECOVERY & SECURITY</span>1993 <span class="peach-sync-disclosure-summary">For a lost or stolen device</span>1994 </span>1995 <span class="peach-settings-advanced-chevron">1996 {showSyncRecovery() ? "▲" : "▼"}1997 </span>1998 </button>1999 <Show when={showSyncRecovery()}>2000 <div id="peach-sync-recovery" class="peach-sync-disclosure-content">2001 <Show2002 when={rotateConfirmOpen()}2003 fallback={2004 <div class="peach-settings-row peach-settings-row--top">2005 <div class="peach-settings-row-main">2006 <span>Rotate sync identity</span>2007 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">2008 Disconnects every device and replaces the keys used for sync.2009 </span>2010 </div>2011 <button2012 class="peach-btn peach-btn--subtle peach-btn--sm"2013 style="color:var(--peach-breach);border-color:color-mix(in srgb,var(--peach-breach) 40%,transparent)"2014 onClick={() => { setRotateError(null); setRotatePassword(""); setRotateConfirmOpen(true); }}2015 >rotate</button>2016 </div>2017 }2018 >2019 <div class="peach-info-notice" style="margin-top:8px;border-color:color-mix(in srgb,var(--peach-breach) 40%,transparent)">2020 This disconnects every paired device and changes your 12 recovery words. You'll be shown the new words next.2021 <label class="peach-label" for="rotate-master-password">master password</label>2022 <input2023 id="rotate-master-password"2024 class="peach-input"2025 type="password"2026 autocomplete="current-password"2027 value={rotatePassword()}2028 onInput={(event) => setRotatePassword(event.currentTarget.value)}2029 disabled={rotating()}2030 />2031 <Show when={rotateError()}>2032 <div style="color:var(--peach-breach);margin-top:6px">{rotateError()}</div>2033 </Show>2034 <div style="display:flex;gap:6px;margin-top:10px">2035 <button2036 class="peach-btn peach-btn--subtle peach-btn--sm"2037 disabled={rotating()}2038 onClick={() => { setRotatePassword(""); setRotateConfirmOpen(false); }}2039 >Cancel</button>2040 <button2041 class="peach-btn peach-btn--sm"2042 style="background:var(--peach-breach);border-color:var(--peach-breach)"2043 disabled={rotating() || !rotatePassword()}2044 onClick={() => void doRotateSyncIdentity()}2045 >{rotating() ? "Rotating…" : "Rotate sync identity"}</button>2046 </div>2047 </div>2048 </Show>2049 </div>2050 </Show>2051 </div>2052 </div>2053 );2054 }20552056 function renderAppearance() {2057 const sizeOptions: Array<{ id: "medium" | "large"; label: string }> = [2058 { id: "medium", label: "Default" },2059 { id: "large", label: "Large" },2060 ];2061 return (2062 <div class="peach-settings-body">2063 <div class="peach-settings-group">2064 <p class="peach-settings-sub-label">THEME</p>2065 <div class="peach-settings-row peach-settings-row--meta">2066 <span>Theme</span>2067 <button2068 class="peach-btn peach-btn--subtle peach-btn--sm"2069 onClick={() =>2070 props.onThemeChange(props.theme === "dark" ? "light" : "dark")2071 }2072 >2073 {props.theme === "dark" ? "Switch to light" : "Switch to dark"}2074 </button>2075 </div>20762077 <p class="peach-settings-sub-label">ACCENT</p>2078 <div class="peach-settings-row peach-settings-row--meta peach-settings-row--accent">2079 <span>Accent</span>2080 <div class="peach-accent-picker">2081 <For each={ACCENT_COLORS}>2082 {(color) => (2083 <button2084 class="peach-accent-swatch peach-swatch"2085 classList={{ "is-active": props.accentColor === color.name }}2086 style={{ background: color.hex }}2087 onClick={() => void props.onAccentChange(color.name)}2088 aria-label={color.name}2089 title={color.name}2090 />2091 )}2092 </For>2093 </div>2094 </div>20952096 <p class="peach-settings-sub-label">TEXT SIZE</p>2097 <div class="peach-settings-row peach-settings-row--meta">2098 <span>Size</span>2099 <div class="peach-pill-group">2100 <For each={sizeOptions}>2101 {(opt) => (2102 <button2103 class="peach-btn peach-btn--ghost peach-btn--sm"2104 classList={{ "is-active": props.textSize === opt.id }}2105 onClick={() => void props.onTextSizeChange(opt.id)}2106 >2107 {opt.label}2108 </button>2109 )}2110 </For>2111 </div>2112 </div>21132114 <p class="peach-settings-sub-label">MOTION</p>2115 <div class="peach-settings-row peach-settings-row--meta">2116 <span>Reduce motion</span>2117 <button2118 class="peach-btn peach-btn--subtle peach-btn--sm"2119 onClick={() => void props.onReduceMotionChange(!props.reduceMotion)}2120 >2121 {props.reduceMotion ? "On" : "Off"}2122 </button>2123 </div>2124 </div>2125 </div>2126 );2127 }21282129 function renderShortcuts() {2130 const [capturingAction, setCapturingAction] = createSignal<ShortcutAction | null>(null);2131 const [conflictMsg, setConflictMsg] = createSignal<string | null>(null);21322133 function startCapture(action: ShortcutAction) {2134 setConflictMsg(null);2135 setCapturingAction(action);2136 }2137 function cancelCapture() {2138 setCapturingAction(null);2139 setConflictMsg(null);2140 }2141 function commitBinding(action: ShortcutAction, binding: Keybinding) {2142 const conflict = findConflict(props.shortcuts, binding, action);2143 if (conflict) {2144 const other = SHORTCUT_DESCRIPTORS.find((d) => d.action === conflict);2145 setConflictMsg(`Already bound to "${other?.label ?? conflict}"`);2146 return;2147 }2148 const next = { ...props.shortcuts, [action]: binding };2149 setCapturingAction(null);2150 setConflictMsg(null);2151 void props.onShortcutsChange(next);2152 }2153 function resetAction(action: ShortcutAction) {2154 const next = { ...props.shortcuts, [action]: DEFAULT_BINDINGS[action] };2155 void props.onShortcutsChange(next);2156 }2157 function resetAll() {2158 void props.onShortcutsChange({ ...DEFAULT_BINDINGS });2159 }21602161 2162 2163 function handleCaptureKey(e: KeyboardEvent) {2164 e.preventDefault();2165 e.stopPropagation();2166 if (e.key === "Escape") { cancelCapture(); return; }2167 const binding = keybindingFromEvent(e);2168 if (!binding) return; 2169 const action = capturingAction();2170 if (action) commitBinding(action, binding);2171 }21722173 return (2174 <div class="peach-settings-body">2175 <div class="peach-settings-group peach-shortcuts-group">2176 <p class="peach-settings-sub-label">ENTRY VIEW</p>2177 <For each={SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "entry")}>2178 {(desc) => renderRow(desc, capturingAction, startCapture, cancelCapture, resetAction, handleCaptureKey)}2179 </For>2180 </div>21812182 <div class="peach-settings-group peach-shortcuts-group">2183 <p class="peach-settings-sub-label">ANYWHERE IN POPUP</p>2184 <For each={SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "global")}>2185 {(desc) => renderRow(desc, capturingAction, startCapture, cancelCapture, resetAction, handleCaptureKey)}2186 </For>2187 </div>21882189 <Show when={conflictMsg()}>2190 <div class="peach-shortcuts-conflict">{conflictMsg()}</div>2191 </Show>21922193 <div class="peach-settings-group" style="display:flex;flex-direction:column;gap:8px">2194 <div class="peach-settings-row peach-settings-row--meta">2195 <span>Inline autofill on page</span>2196 <a2197 class="peach-settings-link"2198 href="chrome://extensions/shortcuts"2199 onClick={(e) => {2200 e.preventDefault();2201 chrome.tabs.create({ url: "chrome://extensions/shortcuts" });2202 }}2203 >2204 ⌘⇧P — customize ↗2205 </a>2206 </div>2207 <button2208 class="peach-btn peach-btn--subtle peach-btn--sm"2209 style="align-self:flex-start"2210 onClick={resetAll}2211 >2212 Reset all to defaults2213 </button>2214 </div>2215 </div>2216 );22172218 function renderRow(2219 desc: typeof SHORTCUT_DESCRIPTORS[number],2220 capturing: () => ShortcutAction | null,2221 onStart: (a: ShortcutAction) => void,2222 onCancel: () => void,2223 onReset: (a: ShortcutAction) => void,2224 onKey: (e: KeyboardEvent) => void,2225 ) {2226 const isActive = () => capturing() === desc.action;2227 const binding = () => props.shortcuts[desc.action];2228 const isCustom = () => {2229 const b = binding();2230 const d = DEFAULT_BINDINGS[desc.action];2231 return b.key !== d.key2232 || Boolean(b.ctrl) !== Boolean(d.ctrl)2233 || Boolean(b.meta) !== Boolean(d.meta)2234 || Boolean(b.shift) !== Boolean(d.shift)2235 || Boolean(b.alt) !== Boolean(d.alt);2236 };2237 return (2238 <div class="peach-shortcut-row">2239 <span class="peach-shortcut-row-label">{desc.label}</span>2240 <button2241 class="peach-shortcut-chip"2242 classList={{ "is-capturing": isActive(), "is-custom": isCustom() }}2243 onClick={() => isActive() ? onCancel() : onStart(desc.action)}2244 onKeyDown={(e) => { if (isActive()) onKey(e); }}2245 ref={(el) => {2246 2247 if (el) {2248 queueMicrotask(() => { if (isActive()) el.focus(); });2249 }2250 }}2251 >2252 {isActive() ? "Press a key…" : formatKeybinding(binding())}2253 </button>2254 <Show when={isCustom() && !isActive()}>2255 <button2256 class="peach-shortcut-reset"2257 title="Reset to default"2258 onClick={() => onReset(desc.action)}2259 >2260 ↺2261 </button>2262 </Show>2263 </div>2264 );2265 }2266 }22672268 const [licenseKey, setLicenseKey] = createSignal<string | null>(null);2269 const [showKey, setShowKey] = createSignal(false);22702271 const [deactivating, setDeactivating] = createSignal(false);22722273 async function handleDeactivateLicense() {2274 setDeactivating(true);2275 await sendMessage({ type: "DEACTIVATE_LICENSE" });2276 setLicenseInfo(null);2277 await props.onLicenseChange?.();2278 setDeactivating(false);2279 }22802281 async function handleTestCanary(entry: {id: string; title: string; canary: Canary}) {2282 setCanaryTestingId(entry.id);2283 setCanaryTestResult(null);2284 const res = await sendMessage({2285 type: "FIRE_CANARY_PING",2286 payload: { webhookUrl: entry.canary.webhookUrl, entryTitle: entry.title, trigger: "test" },2287 }) as { ok: boolean };2288 setCanaryTestResult({ id: entry.id, ok: res.ok });2289 setCanaryTestingId(null);2290 setTimeout(() => setCanaryTestResult((r) => r?.id === entry.id ? null : r), 3000);2291 }22922293 function renderLicense() {2294 async function onActivate() {2295 await handleActivateLicense();2296 if ((licenseInfo()?.valid ?? false) && licenseInfo()?.plan === "pro") {2297 await props.onLicenseChange?.();2298 }2299 }23002301 return (2302 <div class="peach-settings-body">2303 <Show2304 when={isPro()}2305 fallback={2306 <div class="peach-pro-upgrade">2307 <p class="peach-pro-eyebrow">PEACH PRO · ONE-TIME</p>23082309 <h2 class="peach-pro-headline">2310 Every<em>thing,</em><br />every<em>where.</em>2311 </h2>23122313 <p class="peach-pro-subtitle">2314 One key unlocks every Pro feature — for the lifetime of the app.2315 </p>23162317 <div class="peach-pro-grid">2318 <For each={PRO_FEATURES}>2319 {(item, i) => (2320 <div2321 class="peach-pro-grid-item"2322 classList={{ "is-highlighted": props.upgradeHighlight === item.feature }}2323 >2324 <span class="peach-pro-grid-num">{String(i() + 1).padStart(2, "0")}</span>2325 <span class="peach-pro-grid-name">{item.name}</span>2326 <span class="peach-pro-grid-desc">{item.desc}</span>2327 </div>2328 )}2329 </For>2330 </div>23312332 <p class="peach-pro-section-label">ADVANCED SECURITY</p>2333 <div class="peach-pro-grid">2334 <For each={PRO_SECURITY_FEATURES}>2335 {(item, i) => (2336 <div2337 class="peach-pro-grid-item"2338 classList={{ "is-highlighted": props.upgradeHighlight === item.feature }}2339 >2340 <span class="peach-pro-grid-num">{String(PRO_FEATURES.length + i() + 1).padStart(2, "0")}</span>2341 <span class="peach-pro-grid-name">{item.name}</span>2342 <span class="peach-pro-grid-desc">{item.desc}</span>2343 </div>2344 )}2345 </For>2346 </div>23472348 <div class="peach-pro-upgrade-actions">2349 <p class="peach-pro-pricing">2350 $39 <span class="peach-pro-pricing-sub">once · yours forever</span>2351 </p>2352 <a2353 href="https://buy.polar.sh/polar_cl_IXSFIPojx67rcOTksn8LkH5mnU3osPHtYqBIl1eyuIz"2354 target="_blank"2355 rel="noopener noreferrer"2356 class="peach-pro-upgrade-cta"2357 >2358 Get Peach Pro2359 </a>2360 <div class="peach-pro-key-divider"><span>ALREADY HAVE A KEY</span></div>2361 <div class="peach-pro-key-inline">2362 <input2363 class="peach-pro-key-inline-input"2364 type="text"2365 placeholder="PEACH-XXXX-XXXX-XXXX"2366 value={licenseKeyInput()}2367 onInput={(e) => setLicenseKeyInput(e.currentTarget.value)}2368 onKeyDown={(e) => { if (e.key === "Enter") void onActivate(); }}2369 autocomplete="off"2370 spellcheck={false}2371 />2372 <button2373 class="peach-pro-key-apply"2374 onClick={() => void onActivate()}2375 disabled={activatingLicense() || !licenseKeyInput().trim()}2376 >2377 {activatingLicense() ? "…" : "APPLY"}2378 </button>2379 </div>2380 <Show when={licenseError()}>2381 <p class="peach-pro-key-error">{licenseError()}</p>2382 </Show>2383 </div>2384 </div>2385 }2386 >2387 <div class="peach-pro-active">2388 <div class="peach-pro-active-hero">2389 <button2390 class="peach-pro-active-mark-wrap"2391 type="button"2392 aria-label="Celebrate"2393 onClick={handleProCelebrationClick}2394 >2395 <PeachMark class="peach-pro-active-mark" />2396 <Show when={justActivated()}>2397 <div class="peach-pro-sparks" aria-hidden="true">2398 <span class="peach-pro-spark" style="--spark-x:0px;--spark-y:-54px;--spark-delay:0ms">✦</span>2399 <span class="peach-pro-spark" style="--spark-x:38px;--spark-y:-38px;--spark-delay:50ms">✦</span>2400 <span class="peach-pro-spark" style="--spark-x:54px;--spark-y:0px;--spark-delay:110ms">·</span>2401 <span class="peach-pro-spark" style="--spark-x:38px;--spark-y:38px;--spark-delay:30ms">✦</span>2402 <span class="peach-pro-spark" style="--spark-x:0px;--spark-y:54px;--spark-delay:80ms">·</span>2403 <span class="peach-pro-spark" style="--spark-x:-38px;--spark-y:38px;--spark-delay:130ms">✦</span>2404 <span class="peach-pro-spark" style="--spark-x:-54px;--spark-y:0px;--spark-delay:55ms">·</span>2405 <span class="peach-pro-spark" style="--spark-x:-38px;--spark-y:-38px;--spark-delay:95ms">✦</span>2406 </div>2407 </Show>2408 </button>2409 <h2 class="peach-pro-active-title">Peach Pro</h2>2410 <p class="peach-pro-active-since">{formatActivatedSince(licenseInfo()?.issued)}</p>2411 <Show when={justActivated()}>2412 <p class="peach-pro-thankyou-text" aria-live="polite">thank you ✦</p>2413 </Show>2414 </div>24152416 <Show when={licenseKey()}>2417 <div class="peach-settings-license">2418 <span class="peach-settings-label">LICENSE KEY</span>2419 <div class="peach-settings-license-row">2420 <Show2421 when={showKey()}2422 fallback={2423 <span class="peach-settings-license-key peach-settings-license-key--masked" aria-label="License key hidden">2424 ••••••••••••••••••••••••••••2425 </span>2426 }2427 >2428 <span class="peach-settings-license-key">{licenseKey()!}</span>2429 </Show>2430 <div class="peach-settings-license-actions">2431 <button2432 class="peach-settings-license-copy"2433 title="Copy license key"2434 onClick={() => copyLicenseKey(licenseKey()!)}2435 >2436 {copied() ? "✓" : "copy"}2437 </button>2438 <button2439 class="peach-settings-license-toggle"2440 aria-label={showKey() ? "Hide license key" : "Reveal license key"}2441 title={showKey() ? "Hide" : "Reveal"}2442 onClick={() => setShowKey(v => !v)}2443 >2444 <Show2445 when={showKey()}2446 fallback={2447 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">2448 <ellipse cx="7" cy="7" rx="5.5" ry="3.5" />2449 <circle cx="7" cy="7" r="1.5" fill="currentColor" stroke="none" />2450 </svg>2451 }2452 >2453 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">2454 <ellipse cx="7" cy="7" rx="5.5" ry="3.5" />2455 <circle cx="7" cy="7" r="1.5" fill="currentColor" stroke="none" />2456 <line x1="2" y1="2" x2="12" y2="12" />2457 </svg>2458 </Show>2459 </button>2460 </div>2461 </div>2462 </div>2463 </Show>24642465 <div class="peach-pro-active-features">2466 <For each={[...PRO_FEATURES, ...PRO_SECURITY_FEATURES]}>2467 {(item) => (2468 <div class="peach-pro-active-feature">2469 <span class="peach-pro-active-feature-mark">✦</span>2470 <span class="peach-pro-active-feature-name">{item.name}</span>2471 </div>2472 )}2473 </For>2474 </div>24752476 <button2477 class="peach-pro-deactivate"2478 onClick={() => void handleDeactivateLicense()}2479 disabled={deactivating()}2480 >2481 {deactivating() ? "Deactivating…" : "Deactivate"}2482 </button>2483 </div>2484 </Show>2485 </div>2486 );2487 }24882489 function renderFeedback() {2490 return (2491 <div class="peach-settings-body">2492 <div class="peach-settings-group peach-feedback-group">2493 <Show2494 when={feedbackState() === 'sent'}2495 fallback={2496 <>2497 <p class="peach-feedback-intro">2498 Help us improve Peach. Every report goes directly to our inbox.2499 </p>25002501 <p class="peach-settings-sub-label">TYPE</p>2502 <div class="peach-feedback-chips">2503 <For each={FEEDBACK_CATEGORIES}>2504 {(cat) => {2505 const selected = () => fbCategory() === cat;2506 return (2507 <button2508 type="button"2509 class={`peach-feedback-chip ${selected() ? "is-active" : ""}`}2510 aria-pressed={selected()}2511 onClick={() => setFbCategory(cat)}2512 >2513 {cat}2514 </button>2515 );2516 }}2517 </For>2518 </div>25192520 <p class="peach-settings-sub-label">MESSAGE</p>2521 <textarea2522 class="peach-feedback-textarea"2523 placeholder="Describe the issue or idea..."2524 maxLength={MAX_FEEDBACK_MESSAGE_LENGTH}2525 value={fbMessage()}2526 onInput={(e) => setFbMessage(e.currentTarget.value)}2527 />25282529 <p class="peach-feedback-meta">2530 Version {version} · will be included automatically2531 </p>25322533 <button2534 type="button"2535 class="peach-btn peach-btn--accent peach-btn--sm peach-feedback-submit"2536 disabled={!fbMessage().trim() || feedbackState() === 'sending'}2537 onClick={() => void handleSubmitFeedback()}2538 >2539 <Switch>2540 <Match when={feedbackState() === 'idle'}>Send</Match>2541 <Match when={feedbackState() === 'sending'}>Sending...</Match>2542 <Match when={feedbackState() === 'error'}>Failed - try again</Match>2543 </Switch>2544 </button>25452546 <p class="peach-feedback-anon">2547 Sent anonymously · no account required2548 </p>2549 </>2550 }2551 >2552 <div class="peach-feedback-thanks" role="status" aria-live="polite">2553 <p class="peach-feedback-thanks-title">Thank you</p>2554 <p>2555 Your note is in the queue. Someone will process it soon.2556 </p>2557 </div>2558 </Show>2559 </div>2560 </div>2561 );2562 }25632564 const bodies: StackBodies = {2565 protection: renderSecurity(),2566 vault: renderVault(),2567 sync: renderSync(),2568 appearance: renderAppearance(),2569 shortcuts: renderShortcuts(),2570 pro: renderLicense(),2571 feedback: renderFeedback(),2572 };25732574 return (2575 <Show2576 when={showWhatsNew()}2577 fallback={2578 <Show2579 when={showNewRecoveryWords()}2580 fallback={2581 <div2582 class="peach-overlay-view peach-settings-overlay"2583 classList={{ "ov-enter-right": !props.isExiting, "ov-exit-right": !!props.isExiting }}2584 style="display:flex;flex-direction:column"2585 >2586 <StackDeck2587 active={activeCard()}2588 onActiveChange={setActiveCard}2589 onBack={props.onBack}2590 cards={cards()}2591 bodies={bodies}2592 version={version}2593 isFanning={isFanning()}2594 celebratingCardId={justActivated() ? "pro" : null}2595 isPro={isPro()}2596 />2597 </div>2598 }2599 >2600 <RecoveryWordDisplayView onDone={() => setShowNewRecoveryWords(false)} />2601 </Show>2602 }2603 >2604 <div class="peach-overlay-view peach-settings-overlay">2605 <WhatsNewView mode="history" onContinue={() => setShowWhatsNew(false)} />2606 </div>2607 </Show>2608 );2609}