1import { createEffect, createMemo, createSignal, For, Match, onCleanup, onMount, Show, Switch } from "solid-js";2import { sendMessage } from "../App";3import { PeachMark } from "../components/PeachMark";4import { SyncModeSelector } from "../components/SyncModeSelector";5import { StackDeck } from "../components/settings/StackDeck";6import type { CardId, StackBodies, StackCardSpec } from "../components/settings/types";7import { RecoveryWordDisplayView } from "./RecoveryWordDisplay";8import { WhatsNewView } from "./WhatsNew";9import type { Canary } from "../../shared/types";10import { ACCENT_COLORS } from "../../shared/types";11import { PEACH_VERSION, hasReleaseNotes } from "../../shared/release-notes";12import type {13 AccentColorName,14 PasskeyProviderState,15 ProFeature,16 VaultSnapshot,17} from "../../shared/types";18import type { PairedDevice } from "../../shared/sync-types";19import {20 describeSyncOutcome,21 syncIndicator,22 syncIndicatorLabel,23 type SyncOutcomeSummary,24} from "../../shared/sync-outcome";25import type { SyncGeneration } from "../../background/sync-generation";26import {27 DEFAULT_BINDINGS,28 findConflict,29 formatKeybinding,30 keybindingFromEvent,31 SHORTCUT_DESCRIPTORS,32 type Keybinding,33 type ShortcutAction,34} from "../../shared/shortcuts";35import { WEB3FORMS_KEY } from "../../shared/config";36import { PRO_FEATURES, PRO_SECURITY_FEATURES } from "../pro-features";3738interface LicenseInfo {39 valid: boolean;40 plan: "free" | "pro";41 issued?: string;42}4344interface SettingsProps {45 entriesCount: number;46 breachMonitoring: boolean;47 lockOnClose: boolean;48 autoLockMinutes: number;49 lockedSyncRequiresUnlock: boolean;50 trashRetentionDays: number;51 theme: "dark" | "light";52 accentColor: AccentColorName;53 textSize: "small" | "medium" | "large";54 reduceMotion: boolean;55 isPro?: boolean;56 initialSection?: string | null;57 upgradeHighlight?: ProFeature | null;58 onBreachMonitoringChange: (enabled: boolean) => void | Promise<void>;59 onLockOnCloseChange: (enabled: boolean) => void | Promise<void>;60 onAutoLockMinutesChange: (minutes: number) => void | Promise<void>;61 onLockedSyncRequiresUnlockChange: (enabled: boolean) => void | Promise<void>;62 onTrashRetentionChange: (days: number) => void | Promise<void>;63 onThemeChange: (theme: "dark" | "light") => void;64 onAccentChange: (name: AccentColorName) => void | Promise<void>;65 onTextSizeChange: (size: "small" | "medium" | "large") => void | Promise<void>;66 onReduceMotionChange: (enabled: boolean) => void | Promise<void>;67 shortcuts: Record<ShortcutAction, Keybinding>;68 onShortcutsChange: (active: Record<ShortcutAction, Keybinding>) => void | Promise<void>;69 onLicenseChange?: () => void | Promise<void>;70 isExiting?: boolean;71 onBack: () => void;72 onImport: () => void;73 onExport: () => void;74 onBreachCheckDone: () => void;75 onOpenHealth?: () => void;76 onOpenSyncPairing?: (method?: "code") => void;77 onOpenFileImport?: () => void;78 onOpenPanic?: () => void;79 onOpenCodexGenerate?: () => void;80 onOpenCodexRestore?: () => void;81 828384 onProGate?: (feature: ProFeature) => void;85 onCardChange?: (id: CardId) => void;86}8788const FEEDBACK_CATEGORIES = ["Bug report", "Feature request", "Question", "Other"];89const MAX_FEEDBACK_MESSAGE_LENGTH = 4000;90const PRO_CELEBRATION_CARD_STEP_MS = 150;91const PRO_CELEBRATION_THANK_YOU_MS = 3200;9293function sanitizeFeedbackMessage(value: string): string {94 return value95 .trim()96 .slice(0, MAX_FEEDBACK_MESSAGE_LENGTH)97 98 .replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, "")99 .replace(/&/g, "&")100 .replace(/</g, "<")101 .replace(/>/g, ">")102 .replace(/"/g, """)103 .replace(/'/g, "'");104}105106function formatActivatedSince(issued: string | undefined): string {107 if (!issued) return "Active";108 try {109 const d = new Date(issued);110 if (Number.isNaN(d.getTime())) return "Active";111 return `Active since ${d.toLocaleDateString(undefined, { month: "long", year: "numeric" })}`;112 } catch {113 return "Active";114 }115}116117function initialSectionToCard(value: string | null | undefined): CardId | null {118 if (!value) return null;119 if (value === "security") return "protection";120 if (value === "license") return "pro";121 if (122 value === "protection" ||123 value === "vault" ||124 value === "sync" ||125 value === "appearance" ||126 value === "shortcuts" ||127 value === "pro" ||128 value === "feedback"129 ) {130 return value;131 }132 return null;133}134135136137138139const SECURE_RESET_DISCLOSURE =140 "Peach will archive this device's old Sync trust and start the new Sync generation. " +141 "Every other device must be updated first, then re-paired with this one — they will " +142 "not continue on their own. Your vault and your recovery words are not changed.";143144function secureResetHeadline(state: string | undefined): string {145 switch (state) {146 case "LEGACY_ACTIVE":147 return "Legacy Sync generation";148 case "RESET_REQUIRED":149 return "Reset required";150 case "RESET_CONFIRMED":151 return "Reset not completed";152 case "V2_ANCHOR":153 case "REPAIRING":154 return "Not re-paired";155 case "V2_ACTIVE":156 return "New Sync generation";157 case "UNKNOWN":158 return "Sync generation unreadable";159 default:160 return "Sync generation";161 }162}163164function secureResetDetail(state: string | undefined): string {165 switch (state) {166 case "LEGACY_ACTIVE":167 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.";168 case "RESET_REQUIRED":169 return "Sync is stopped until the reset completes. Update Peach on every other device, then reset this one and re-pair each device.";170 case "RESET_CONFIRMED":171 return "The reset did not finish, so Sync is paused. If Peach reports an archive problem, contact Peach support before retrying.";172 case "V2_ANCHOR":173 case "REPAIRING":174 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.";175 case "V2_ACTIVE":176 return "This device is on the new Sync generation. Each device is re-paired individually.";177 case "UNKNOWN":178 return "This device's Sync generation can't be read, so sync is stopped. Reinstall or contact support.";179 default:180 return "Sync state is unavailable.";181 }182}183184export function SettingsView(props: SettingsProps) {185 const manifest = chrome.runtime.getManifest();186 const version = manifest.version;187 const initial = props.initialSection;188 const [activeCard, setActiveCard] = createSignal<CardId>(189 props.upgradeHighlight ? "pro" : initialSectionToCard(initial) ?? "pro"190 );191192 createEffect(() => { props.onCardChange?.(activeCard()); });193194 const [justActivated, setJustActivated] = createSignal(false);195 const [isFanning, setIsFanning] = createSignal(false);196197 function triggerCelebration() {198 if (isFanning()) return;199 setJustActivated(false);200 setIsFanning(true);201 setActiveCard("pro");202 const fanOrder: CardId[] = ["protection", "vault", "sync", "appearance", "shortcuts", "feedback"];203 fanOrder.forEach((id, i) => {204 window.setTimeout(() => setActiveCard(id), (i + 1) * PRO_CELEBRATION_CARD_STEP_MS);205 });206 window.setTimeout(() => {207 setActiveCard("pro");208 setIsFanning(false);209 setJustActivated(true);210 window.setTimeout(() => setJustActivated(false), PRO_CELEBRATION_THANK_YOU_MS);211 }, (fanOrder.length + 1) * PRO_CELEBRATION_CARD_STEP_MS);212 }213214 function handleProCelebrationClick(e: MouseEvent) {215 e.stopPropagation();216 triggerCelebration();217 }218219 const [checkingBreaches, setCheckingBreaches] = createSignal(false);220 const [breachResult, setBreachResult] = createSignal<string | null>(null);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 }866867 async function handleCheckAllBreaches() {868 setCheckingBreaches(true);869 setBreachResult(null);870 const res = await sendMessage({ type: "CHECK_ALL_BREACHES" });871 setCheckingBreaches(false);872 if ((res as { ok: boolean }).ok) {873 const data = (res as { ok: boolean; data?: Record<string, number> }).data ?? {};874 const breached = Object.values(data).filter((count) => count > 0).length;875 setBreachResult(876 breached > 0 ? `${breached} password${breached > 1 ? "s" : ""} found in breaches` : "All passwords clean"877 );878 props.onBreachCheckDone();879 }880 }881882883 async function handleSetupDuress() {884 const mainPw = duressMainPassword().trim();885 const duressPw = duressPassword().trim();886 const confirmPw = duressConfirm().trim();887888 if (!mainPw) { setDuressError("enter your main password to confirm"); return; }889 if (duressPw.length < 8) { setDuressError("duress password must be at least 8 characters"); return; }890 if (duressPw === mainPw) { setDuressError("duress password must differ from your main password"); return; }891 if (duressPw !== confirmPw) { setDuressError("passwords do not match"); return; }892893 setDuressSaving(true);894 setDuressError(null);895896 const verifyRes = await sendMessage({ type: "VERIFY_MAIN_PASSWORD", payload: { password: mainPw } }) as { ok: boolean; data?: boolean };897 if (!verifyRes.ok || !verifyRes.data) {898 setDuressError("incorrect main password");899 setDuressSaving(false);900 return;901 }902903 const res = await sendMessage({ type: "SETUP_DURESS", payload: { duressPassword: duressPw } }) as { ok: boolean; error?: string };904 setDuressSaving(false);905 if (res.ok) {906 setDuressEnabled(true);907 setShowDuressSetup(false);908 setDuressPassword("");909 setDuressConfirm("");910 setDuressMainPassword("");911 setDuressSuccess("Duress password set. If entered, a decoy vault will be shown.");912 setTimeout(() => setDuressSuccess(null), 5000);913 } else {914 setDuressError(915 res.error === "session_expired"916 ? "Vault session expired — lock and unlock Peach, then try again"917 : res.error ?? "failed to set duress password"918 );919 }920 }921922 async function handleClearDeclinedCards() {923 await sendMessage({ type: "UPDATE_SETTINGS", payload: { declinedCardFingerprints: [] } });924 setDeclinedCardCount(0);925 }926927 async function handleCountDuplicates() {928 setDedupRunning(true);929 setDedupDone(null);930 const res = await sendMessage({ type: "COUNT_DUPLICATES" }) as { ok: boolean; data?: number };931 setDedupRunning(false);932 if (res.ok) setDedupCount(res.data ?? 0);933 }934935 async function handleDeduplicate() {936 setDedupRunning(true);937 const res = await sendMessage({ type: "DEDUPLICATE_ENTRIES" }) as { ok: boolean; data?: number };938 setDedupRunning(false);939 if (res.ok) {940 setDedupDone(res.data ?? 0);941 setDedupCount(0);942 }943 }944945 async function handleDisableDuress() {946 const mainPw = duressMainPassword().trim();947 if (!mainPw) { setDuressError("enter your main password to confirm"); return; }948949 setDuressSaving(true);950 setDuressError(null);951952 const verifyRes = await sendMessage({ type: "VERIFY_MAIN_PASSWORD", payload: { password: mainPw } }) as { ok: boolean; data?: boolean };953 if (!verifyRes.ok || !verifyRes.data) {954 setDuressError("incorrect main password");955 setDuressSaving(false);956 return;957 }958959 const res = await sendMessage({ type: "DISABLE_DURESS" }) as { ok: boolean; error?: string };960 setDuressSaving(false);961 if (res.ok) {962 setDuressEnabled(false);963 setShowDuressSetup(false);964 setDuressMainPassword("");965 setDuressSuccess("Duress password disabled.");966 setTimeout(() => setDuressSuccess(null), 4000);967 } else {968 setDuressError(res.error ?? "failed to disable duress password");969 }970 }971972 async function handleSubmitFeedback() {973 const message = sanitizeFeedbackMessage(fbMessage());974 if (!message) return;975976 setFeedbackState('sending');977978 try {979 const category = FEEDBACK_CATEGORIES.includes(fbCategory())980 ? fbCategory()981 : FEEDBACK_CATEGORIES[0];982 const res = await fetch('https://api.web3forms.com/submit', {983 method: 'POST',984 headers: { 'Content-Type': 'application/json' },985 body: JSON.stringify({986 access_key: WEB3FORMS_KEY,987 subject: `Peach Feedback - ${category}`,988 message,989 from_name: 'Peach User',990 991 botcheck: '',992 }),993 });994995 if (!res.ok) throw new Error(`HTTP ${res.status}`);996 const data = await res.json() as { success: boolean; message?: string };997 if (!data.success) throw new Error(data.message ?? 'unknown error');998999 setFeedbackState('sent');1000 setFbMessage('');1001 setFbCategory(FEEDBACK_CATEGORIES[0]);1002 } catch (err) {1003 console.error('[feedback]', err);1004 setFeedbackState('error');1005 setTimeout(() => setFeedbackState('idle'), 4000);1006 }1007 }10081009 function renderSecurity() {1010 return (1011 <div class="peach-settings-body">1012 <div class="peach-settings-group">1013 <p class="peach-settings-sub-label">LOCKING</p>1014 <div class="peach-settings-row">1015 <span>Lock on close</span>1016 <button1017 class={`peach-toggle ${props.lockOnClose ? "is-on" : ""}`}1018 onClick={() => void props.onLockOnCloseChange(!props.lockOnClose)}1019 aria-label="Toggle lock on close"1020 >1021 <span class="peach-toggle-knob"></span>1022 </button>1023 </div>1024 <div class="peach-settings-row">1025 <span>Auto-lock after</span>1026 <select1027 class="peach-settings-select"1028 value={String(props.autoLockMinutes)}1029 onChange={(e) => void props.onAutoLockMinutesChange(Number(e.currentTarget.value))}1030 >1031 <option value="1">1 minute</option>1032 <option value="5">5 minutes</option>1033 <option value="15">15 minutes</option>1034 <option value="30">30 minutes</option>1035 <option value="0">Never</option>1036 </select>1037 </div>1038 <p class="peach-settings-sub-label">SYNC WHILE LOCKED</p>1039 <div class="peach-settings-row">1040 <span>Require unlock after restart</span>1041 <button1042 class={`peach-toggle ${props.lockedSyncRequiresUnlock ? "is-on" : ""}`}1043 onClick={() => void props.onLockedSyncRequiresUnlockChange(!props.lockedSyncRequiresUnlock)}1044 aria-label="Toggle unlock requirement for locked Sync after restart"1045 aria-pressed={props.lockedSyncRequiresUnlock}1046 >1047 <span class="peach-toggle-knob"></span>1048 </button>1049 </div>1050 <p class="peach-settings-sub-label">QUICK UNLOCK</p>1051 <div class="peach-settings-row peach-settings-row--meta">1052 <span>PIN unlock</span>1053 <button1054 class="peach-btn peach-btn--subtle peach-btn--sm"1055 onClick={() => { setPinFlow(pinEnabled() ? "disable" : "setup"); setPinError(null); }}1056 >1057 {pinEnabled() ? "remove" : "set up"}1058 </button>1059 </div>1060 <Show when={pinFlow() === "setup"}>1061 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1062 <input1063 class="peach-settings-input"1064 type="password"1065 placeholder="current password"1066 value={pinCurrentPassword()}1067 onInput={(e) => setPinCurrentPassword((e.target as HTMLInputElement).value)}1068 autocomplete="current-password"1069 />1070 <input1071 class="peach-settings-input"1072 type="password"1073 inputmode="numeric"1074 maxlength="12"1075 placeholder="new 4–12 digit PIN"1076 value={pinValue()}1077 onInput={(e) => setPinValue((e.target as HTMLInputElement).value.replace(/\D/g, "").slice(0, 12))}1078 autocomplete="off"1079 />1080 <input1081 class="peach-settings-input"1082 type="password"1083 inputmode="numeric"1084 maxlength="12"1085 placeholder="confirm PIN"1086 value={pinConfirm()}1087 onInput={(e) => setPinConfirm((e.target as HTMLInputElement).value.replace(/\D/g, "").slice(0, 12))}1088 autocomplete="off"1089 onKeyDown={(e) => { if (e.key === "Enter") void handleSetupPin(); }}1090 />1091 <Show when={pinError()}>1092 <p class="peach-hint peach-hint-error" style="margin:0">{pinError()}</p>1093 </Show>1094 <button1095 class="peach-btn peach-btn--accent peach-btn--sm"1096 style="align-self:flex-start"1097 onClick={() => void handleSetupPin()}1098 disabled={pinSaving() || !pinCurrentPassword() || !/^\d{4,12}$/.test(pinValue()) || !/^\d{4,12}$/.test(pinConfirm())}1099 >1100 {pinSaving() ? "saving…" : "save PIN"}1101 </button>1102 </div>1103 </Show>1104 <Show when={pinFlow() === "disable"}>1105 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1106 <input1107 class="peach-settings-input"1108 type="password"1109 placeholder="current password"1110 value={pinCurrentPassword()}1111 onInput={(e) => setPinCurrentPassword((e.target as HTMLInputElement).value)}1112 autocomplete="current-password"1113 onKeyDown={(e) => { if (e.key === "Enter") void handleDisablePin(); }}1114 />1115 <Show when={pinError()}>1116 <p class="peach-hint peach-hint-error" style="margin:0">{pinError()}</p>1117 </Show>1118 <button1119 class="peach-btn peach-btn--subtle peach-btn--sm"1120 style="align-self:flex-start"1121 onClick={() => void handleDisablePin()}1122 disabled={pinSaving() || !pinCurrentPassword()}1123 >1124 {pinSaving() ? "removing…" : "remove PIN"}1125 </button>1126 </div>1127 </Show>11281129 <p class="peach-settings-sub-label">BREACH PROTECTION</p>1130 <div class="peach-settings-row">1131 <span>Breach monitoring</span>1132 <button1133 class={`peach-toggle ${props.breachMonitoring ? "is-on" : ""}`}1134 onClick={() => void props.onBreachMonitoringChange(!props.breachMonitoring)}1135 aria-label="Toggle breach monitoring"1136 >1137 <span class="peach-toggle-knob"></span>1138 </button>1139 </div>1140 <div class="peach-settings-row peach-settings-row--meta">1141 <span>Check all passwords</span>1142 <button1143 class="peach-btn peach-btn--subtle peach-btn--sm"1144 onClick={() => void handleCheckAllBreaches()}1145 disabled={checkingBreaches()}1146 >1147 {checkingBreaches() ? "checking..." : "run"}1148 </button>1149 </div>1150 <Show when={breachResult()}>1151 <div class="peach-settings-row peach-settings-row--meta">1152 <span>Last check</span>1153 <span class="peach-settings-value">{breachResult()}</span>1154 </div>1155 </Show>11561157 <p class="peach-settings-sub-label">MASTER PASSWORD</p>1158 <div class="peach-settings-row peach-settings-row--meta">1159 <span>Master password</span>1160 <button1161 class="peach-btn peach-btn--subtle peach-btn--sm"1162 onClick={() => { setShowChangePw((v) => !v); setChangePwError(null); }}1163 >1164 {showChangePw() ? "cancel" : "change"}1165 </button>1166 </div>1167 <Show when={showChangePw()}>1168 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1169 <input1170 class="peach-settings-input"1171 type="password"1172 placeholder="current password"1173 value={changePwCurrent()}1174 onInput={(e) => setChangePwCurrent((e.target as HTMLInputElement).value)}1175 autocomplete="current-password"1176 />1177 <input1178 class="peach-settings-input"1179 type="password"1180 placeholder="new password (min 12 chars)"1181 value={changePwNew()}1182 onInput={(e) => setChangePwNew((e.target as HTMLInputElement).value)}1183 autocomplete="new-password"1184 />1185 <input1186 class="peach-settings-input"1187 type="password"1188 placeholder="confirm new password"1189 value={changePwConfirm()}1190 onInput={(e) => setChangePwConfirm((e.target as HTMLInputElement).value)}1191 autocomplete="new-password"1192 onKeyDown={(e) => { if (e.key === "Enter") void handleChangePassword(); }}1193 />1194 <Show when={changePwError()}>1195 <p class="peach-hint peach-hint-error" style="margin:0">{changePwError()}</p>1196 </Show>1197 <Show when={changePwSuccess()}>1198 <p class="peach-hint" style="margin:0;color:var(--peach-accent)">password changed ✓</p>1199 </Show>1200 <button1201 class="peach-btn peach-btn--accent peach-btn--sm"1202 style="align-self:flex-start"1203 onClick={() => void handleChangePassword()}1204 disabled={changePwSaving() || !changePwCurrent() || !changePwNew() || !changePwConfirm()}1205 >1206 {changePwSaving() ? "saving…" : "save new password"}1207 </button>1208 </div>1209 </Show>12101211 {}1212 <div class="peach-settings-row peach-settings-row--meta">1213 <span>Recovery words</span>1214 <button1215 class="peach-btn peach-btn--subtle peach-btn--sm"1216 onClick={() => {1217 if (showViewWords()) { closeViewWords(); } else { setShowViewWords(true); }1218 }}1219 >1220 {showViewWords() ? "cancel" : "view"}1221 </button>1222 </div>1223 <Show when={showViewWords()}>1224 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1225 <Show1226 when={viewedWords()}1227 fallback={1228 <>1229 <p class="peach-hint" style="margin:0;color:var(--peach-t2)">1230 Enter your master password to reveal your recovery words.1231 </p>1232 <input1233 class="peach-settings-input"1234 type="password"1235 placeholder="master password"1236 value={viewWordsPassword()}1237 onInput={(e) => setViewWordsPassword((e.target as HTMLInputElement).value)}1238 autocomplete="current-password"1239 onKeyDown={(e) => { if (e.key === "Enter") void handleViewRecoveryWords(); }}1240 />1241 <Show when={viewWordsError()}>1242 <p class="peach-hint peach-hint-error" style="margin:0">{viewWordsError()}</p>1243 </Show>1244 <button1245 class="peach-btn peach-btn--accent peach-btn--sm"1246 style="align-self:flex-start"1247 onClick={() => void handleViewRecoveryWords()}1248 disabled={viewWordsBusy() || !viewWordsPassword()}1249 >1250 {viewWordsBusy() ? "checking…" : "reveal recovery words"}1251 </button>1252 </>1253 }1254 >1255 <div class="peach-recovery-words-grid">1256 <For each={viewedWords()!}>1257 {(word, i) => (1258 <span class="peach-recovery-word"><b>{i() + 1}</b> {word}</span>1259 )}1260 </For>1261 </div>1262 <button1263 class="peach-btn peach-btn--subtle peach-btn--sm"1264 style="align-self:flex-start"1265 onClick={closeViewWords}1266 >done</button>1267 </Show>1268 </div>1269 </Show>12701271 <p class="peach-settings-sub-label">1272 DURESS PASSWORD1273 <Show when={!isPro()}>1274 <span class="peach-pro-mark" aria-label="Pro feature" style="margin-left:6px">✦</span>1275 </Show>1276 </p>1277 <div class="peach-settings-row peach-settings-row--top">1278 <div class="peach-settings-row-main">1279 <span>1280 Duress password1281 <Show when={!isPro()}>1282 <span class="peach-pro-badge">Pro</span>1283 </Show>1284 </span>1285 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--t2)">1286 If entered under coercion, shows a decoy empty vault instead of your real one.1287 </span>1288 </div>1289 <div class={`peach-duress-status-pill ${duressEnabled() ? "is-active" : ""}`}>1290 {duressEnabled() ? "on" : "off"}1291 </div>1292 </div>12931294 <Show when={duressEnabled() && !showDuressSetup()}>1295 <div class="peach-settings-row peach-settings-row--meta">1296 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1297 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.1298 </span>1299 </div>1300 </Show>13011302 <Show when={duressSuccess()}>1303 <div class="peach-settings-row peach-settings-row--meta">1304 <span class="peach-settings-value" style="color:var(--peach-sync-ok)">{duressSuccess()}</span>1305 </div>1306 </Show>13071308 <Show when={!showDuressSetup()}>1309 <div class="peach-settings-row peach-settings-row--meta">1310 <button1311 class="peach-btn peach-btn--subtle peach-btn--sm"1312 onClick={() => {1313 1314 1315 1316 1317 1318 if (!isPro() && !duressEnabled()) {1319 props.onProGate?.("duress_vault");1320 setActiveCard("pro");1321 return;1322 }1323 setShowDuressSetup(true);1324 setDuressError(null);1325 setDuressSuccess(null);1326 setDuressPassword("");1327 setDuressConfirm("");1328 setDuressMainPassword("");1329 }}1330 >1331 {duressEnabled() ? "Change / disable" : "Set up"}1332 </button>1333 </div>1334 </Show>13351336 <Show when={showDuressSetup()}>1337 <div class="peach-duress-form">1338 <label class="peach-label">main password (to confirm)</label>1339 <input1340 class="peach-settings-input"1341 type="password"1342 placeholder="your current master password"1343 autocomplete="current-password"1344 value={duressMainPassword()}1345 onInput={(e) => setDuressMainPassword(e.currentTarget.value)}1346 />1347 <Show when={!duressEnabled()}>1348 <label class="peach-label">new duress password</label>1349 <input1350 class="peach-settings-input"1351 type="password"1352 placeholder="duress password (min 8 chars)"1353 autocomplete="new-password"1354 value={duressPassword()}1355 onInput={(e) => setDuressPassword(e.currentTarget.value)}1356 />1357 <label class="peach-label">confirm duress password</label>1358 <input1359 class="peach-settings-input"1360 type="password"1361 placeholder="confirm duress password"1362 autocomplete="new-password"1363 value={duressConfirm()}1364 onInput={(e) => setDuressConfirm(e.currentTarget.value)}1365 />1366 </Show>13671368 <Show when={duressError()}>1369 <p class="peach-hint peach-hint-error">{duressError()}</p>1370 </Show>13711372 <div class="peach-duress-actions">1373 <button1374 class="peach-btn peach-btn--subtle peach-btn--sm"1375 onClick={() => { setShowDuressSetup(false); setDuressError(null); }}1376 >1377 cancel1378 </button>1379 <Show when={duressEnabled()}>1380 <button1381 class="peach-btn peach-btn--ghost peach-btn--sm"1382 style="color:var(--peach-breach)"1383 onClick={() => void handleDisableDuress()}1384 disabled={duressSaving()}1385 >1386 {duressSaving() ? "disabling..." : "disable duress"}1387 </button>1388 </Show>1389 <Show when={!duressEnabled()}>1390 <button1391 class="peach-btn peach-btn--accent peach-btn--sm"1392 onClick={() => void handleSetupDuress()}1393 disabled={duressSaving() || !duressMainPassword() || !duressPassword() || !duressConfirm()}1394 >1395 {duressSaving() ? "saving..." : "save"}1396 </button>1397 </Show>1398 </div>1399 </div>1400 </Show>14011402 <p class="peach-settings-sub-label">1403 CANARY ENTRIES1404 <Show when={!isPro()}>1405 <span class="peach-pro-mark" aria-label="Pro feature" style="margin-left:6px">✦</span>1406 </Show>1407 </p>1408 <div class="peach-settings-row peach-settings-row--top">1409 <div class="peach-settings-row-main">1410 <span>1411 Canary entries1412 <Show when={!isPro()}>1413 <span class="peach-pro-badge">Pro</span>1414 </Show>1415 </span>1416 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1417 Silently pings a webhook when an entry is accessed. Configure canary on any entry in your vault.1418 </span>1419 </div>1420 <span class="peach-settings-value" style="flex-shrink:0">1421 {canaryEntries().length > 0 ? `${canaryEntries().length} active` : "none"}1422 </span>1423 </div>1424 <Show when={canaryEntries().length > 0}>1425 <For each={canaryEntries()}>1426 {(entry) => (1427 <div class="peach-settings-row peach-settings-row--meta">1428 <span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0">{entry.title}</span>1429 <button1430 class="peach-btn peach-btn--subtle peach-btn--sm"1431 onClick={() => void handleTestCanary(entry)}1432 disabled={canaryTestingId() === entry.id}1433 style="flex-shrink:0"1434 >1435 {canaryTestingId() === entry.id1436 ? "sending…"1437 : canaryTestResult()?.id === entry.id1438 ? (canaryTestResult()!.ok ? "sent ✓" : "failed ✗")1439 : "test"}1440 </button>1441 </div>1442 )}1443 </For>1444 </Show>14451446 <p class="peach-settings-sub-label">PASSKEYS</p>1447 <div class="peach-settings-row peach-settings-row--top">1448 <div class="peach-settings-row-main">1449 <span>Intercept passkey requests</span>1450 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--t2)">1451 Use Peach for passkey sign-in and creation in Chrome and Firefox.1452 </span>1453 </div>1454 <button1455 class={`peach-toggle ${passkeyState()?.enabled ? "is-on" : ""}`}1456 onClick={() => void handleTogglePasskeys()}1457 aria-label="Toggle passkey interception"1458 disabled={!passkeyState()?.supported || passkeySaving()}1459 >1460 <span class="peach-toggle-knob"></span>1461 </button>1462 </div>1463 <div class="peach-settings-row peach-settings-row--meta">1464 <span>Status</span>1465 <span class="peach-settings-value">{passkeyState()?.statusLabel ?? "Unavailable"}</span>1466 </div>1467 <div class="peach-settings-row peach-settings-row--meta">1468 <span>Browser</span>1469 <span class="peach-settings-value">1470 {passkeyState()?.browserLabel ?? "Unknown"}1471 {passkeyState()?.supported ? " ✓" : " (interception unavailable)"}1472 </span>1473 </div>1474 <div class="peach-info-notice" style="margin-top:8px">1475 Only one passkey provider can be active at a time. Disable Bitwarden or 1Password passkey interception if Peach reports a conflict.1476 </div>1477 <Show when={passkeyState()?.conflict}>1478 <div class="peach-settings-row peach-settings-row--meta">1479 <span class="peach-settings-value" style="color:#e7b36b">{passkeyState()!.conflict}</span>1480 </div>1481 </Show>1482 </div>1483 </div>1484 );1485 }14861487 function renderVault() {1488 return (1489 <div class="peach-settings-body">1490 <div class="peach-settings-group">1491 <p class="peach-settings-sub-label">ENTRIES</p>1492 <div class="peach-settings-row peach-settings-row--meta">1493 <span>Entries</span>1494 <span class="peach-settings-value">{props.entriesCount}</span>1495 </div>1496 <div class="peach-settings-row peach-settings-row--meta">1497 <span>Duplicates</span>1498 <Show when={dedupDone() !== null} fallback={1499 <button1500 class="peach-btn peach-btn--subtle peach-btn--sm"1501 onClick={() => void handleCountDuplicates()}1502 disabled={dedupRunning()}1503 >1504 {dedupRunning() ? "scanning..." : dedupCount() === null ? "scan" : dedupCount() === 0 ? "none found" : `${dedupCount()} found — remove?`}1505 </button>1506 }>1507 <span class="peach-settings-value" style="color:var(--peach-sync-ok)">1508 {dedupDone() === 0 ? "already clean" : `removed ${dedupDone()}`}1509 </span>1510 </Show>1511 </div>1512 <Show when={dedupCount() !== null && dedupCount()! > 0 && dedupDone() === null}>1513 <div class="peach-settings-row peach-settings-row--meta" style="flex-direction:column;align-items:stretch;gap:6px">1514 <div class="peach-restore-warning">1515 {dedupCount()} duplicate {dedupCount() === 1 ? "entry" : "entries"} found. The newest copy of each will be kept; older duplicates will be moved to trash.1516 </div>1517 <div style="display:flex;gap:6px">1518 <button1519 class="peach-btn peach-btn--subtle peach-btn--sm"1520 onClick={() => setDedupCount(null)}1521 >1522 cancel1523 </button>1524 <button1525 class="peach-btn peach-btn--accent peach-btn--sm"1526 onClick={() => void handleDeduplicate()}1527 disabled={dedupRunning()}1528 >1529 {dedupRunning() ? "removing..." : "remove duplicates"}1530 </button>1531 </div>1532 </div>1533 </Show>15341535 <p class="peach-settings-sub-label">MAINTENANCE</p>1536 <div class="peach-settings-row peach-settings-row--meta">1537 <span>Trash auto-delete</span>1538 <select1539 class="peach-settings-select"1540 value={String(props.trashRetentionDays)}1541 onChange={(e) => void props.onTrashRetentionChange(Number(e.currentTarget.value))}1542 >1543 <option value="7">7 days</option>1544 <option value="30">30 days</option>1545 <option value="90">90 days</option>1546 <option value="0">Never</option>1547 </select>1548 </div>1549 <div class="peach-settings-row peach-settings-row--meta">1550 <span>Advanced Vault Health</span>1551 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={props.onOpenHealth}>1552 open1553 </button>1554 </div>1555 <Show when={declinedCardCount() > 0}>1556 <div class="peach-settings-row peach-settings-row--meta">1557 <span>{declinedCardCount()} card{declinedCardCount() === 1 ? '' : 's'} set to never save</span>1558 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => void handleClearDeclinedCards()}>1559 Clear1560 </button>1561 </div>1562 </Show>15631564 <p class="peach-settings-sub-label">DATA</p>1565 <div class="peach-settings-row peach-settings-row--meta">1566 <span>Import passwords</span>1567 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={props.onImport}>1568 open1569 </button>1570 </div>1571 <div class="peach-settings-row peach-settings-row--meta">1572 <span>Export backup</span>1573 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={props.onExport}>1574 open1575 </button>1576 </div>1577 <div class="peach-settings-row peach-settings-row--meta">1578 <span>1579 Peach Codex1580 <Show when={!isPro()}>1581 <span class="peach-pro-badge">Pro</span>1582 </Show>1583 </span>1584 <button1585 class="peach-btn peach-btn--subtle peach-btn--sm"1586 onClick={() => props.onOpenCodexGenerate?.()}1587 >1588 open1589 </button>1590 </div>1591 {1592}1593 <div class="peach-settings-row peach-settings-row--meta">1594 <span>Restore from Codex</span>1595 <button1596 class="peach-btn peach-btn--subtle peach-btn--sm"1597 onClick={() => props.onOpenCodexRestore?.()}1598 >1599 open1600 </button>1601 </div>16021603 <Show when={hasReleaseNotes()}>1604 <p class="peach-settings-sub-label">RELEASE NOTES</p>1605 <div class="peach-settings-row peach-settings-row--meta">1606 <span>v{PEACH_VERSION}</span>1607 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => setShowWhatsNew(true)}>1608 view1609 </button>1610 </div>1611 </Show>16121613 <span class="peach-settings-sub-label">VAULT HISTORY</span>1614 <Show when={historyLoading()}>1615 <p class="peach-settings-hint">Loading…</p>1616 </Show>1617 <Show when={!historyLoading() && historySnapshots().length === 0}>1618 <p class="peach-settings-hint">1619 No snapshots yet. Peach saves automatically before every change —1620 saves, syncs, and imports.1621 </p>1622 </Show>1623 <Show when={!historyLoading() && historySnapshots().length > 0}>1624 <p class="peach-settings-hint">1625 Restoring locks your vault. Unlock with the password that1626 encrypted that snapshot to confirm.1627 </p>1628 <div class="peach-history-list">1629 <For each={historySnapshots().slice(0, historyShowAll() ? undefined : 3)}>1630 {(snap) => (1631 <div class="peach-history-row">1632 <div class="peach-history-meta">1633 <span class="peach-history-time">1634 {formatSnapshotTime(snap.savedAt)}1635 </span>1636 <span class="peach-history-sub">1637 {[1638 snap.entryCount !== null1639 ? `up to ${snap.entryCount} ${snap.entryCount === 1 ? "entry" : "entries"}`1640 : null,1641 reasonLabel(snap.reason),1642 ]1643 .filter(Boolean)1644 .join(" · ")}1645 </span>1646 </div>1647 <button1648 class={`peach-btn peach-btn--subtle peach-btn--sm peach-history-btn${1649 historyRestoring() === snap.id ? " is-busy" : ""1650 }`}1651 onClick={() => void handleRestoreVaultSnapshot(snap.id)}1652 disabled={historyRestoring() !== null}1653 >1654 <Show when={historyRestoring() === snap.id} fallback="Restore">1655 …1656 </Show>1657 </button>1658 </div>1659 )}1660 </For>1661 </div>1662 <Show when={historySnapshots().length > 3}>1663 <button1664 class="peach-settings-advanced-toggle"1665 onClick={() => setHistoryShowAll((v) => !v)}1666 aria-expanded={historyShowAll()}1667 >1668 <span class="peach-settings-hint" style="margin:0">1669 {historyShowAll() ? "show less" : `${historySnapshots().length - 3} older`}1670 </span>1671 <span class="peach-settings-advanced-chevron">1672 {historyShowAll() ? "▲" : "▼"}1673 </span>1674 </button>1675 </Show>1676 <p class="peach-history-footer">1677 {historySnapshots().length} of 10 snapshots1678 </p>1679 </Show>16801681 <button1682 class="peach-settings-advanced-toggle"1683 onClick={() => setShowVaultAdvanced((v) => !v)}1684 aria-expanded={showVaultAdvanced()}1685 >1686 <span class="peach-settings-sub-label" style="margin:0">ADVANCED</span>1687 <span class="peach-settings-advanced-chevron">1688 {showVaultAdvanced() ? "▲" : "▼"}1689 </span>1690 </button>16911692 <Show when={showVaultAdvanced()}>1693 <div class="peach-danger-card">1694 <div class="peach-danger-card-head">1695 <span class="peach-danger-card-glyph" aria-hidden="true">⟳</span>1696 <h3 class="peach-danger-card-title">Replace vault from backup</h3>1697 </div>1698 <p class="peach-danger-card-copy">1699 Wipes the current vault and restores from a backup file.1700 Recoverable only if your backup is good.1701 </p>1702 <button1703 class="peach-danger-card-button"1704 onClick={() => props.onOpenFileImport?.()}1705 >1706 Choose backup file1707 </button>1708 </div>17091710 <Show when={props.onOpenPanic}>1711 <div class="peach-danger-card peach-danger-card--hazard">1712 <div class="peach-danger-card-head">1713 <span class="peach-danger-card-glyph" aria-hidden="true">⚠</span>1714 <h3 class="peach-danger-card-title">Destroy vault</h3>1715 </div>1716 <p class="peach-danger-card-copy">1717 Permanently wipes every entry, setting, and license on this1718 device. There is no recovery.1719 </p>1720 <button1721 class="peach-danger-card-button"1722 onClick={() => props.onOpenPanic?.()}1723 >1724 Begin destruction1725 </button>1726 </div>1727 </Show>1728 </Show>1729 </div>1730 </div>1731 );1732 }17331734 function renderSync() {1735 return (1736 <div class="peach-settings-body">1737 <div class="peach-settings-group">1738 <p class="peach-settings-sub-label" style="margin-top:0">SYNC STATUS</p>1739 <Show when={trustDataCorrupted()}>1740 <p class="peach-settings-value" role="alert" style="color:var(--peach-danger,#e5805c);line-height:1.5">1741 Device trust data is damaged — re-pair your devices after updating1742 </p>1743 </Show>1744 <div1745 class="peach-settings-row peach-settings-row--meta"1746 style="align-items:center;gap:8px"1747 aria-label={syncLightLabel()}1748 title={syncLightLabel()}1749 >1750 <span class={`stk-pip stk-pip--sync is-${syncLight()}`} aria-hidden="true" />1751 <span class="peach-settings-value" style="color:var(--peach-t2);line-height:1.5;flex:1;min-width:0;overflow-wrap:anywhere">1752 {syncFlash() ?? lastSyncLine()}1753 </span>1754 {17551756}1757 <Show when={pairedDevices().length > 0}>1758 <button1759 class="peach-btn peach-btn--subtle peach-btn--sm"1760 aria-label="Sync this vault now"1761 disabled={syncStatus() === "syncing"}1762 onClick={() => void syncNow()}1763 >{syncStatus() === "syncing" ? "syncing…" : "sync now"}</button>1764 </Show>1765 </div>17661767 {17681769}1770 <Show when={generation()?.state && generation()?.state !== "V2_ACTIVE"}>1771 <p class="peach-settings-sub-label">SECURE SYNC RESET</p>1772 <div class="peach-settings-row peach-settings-row--top">1773 <div class="peach-settings-row-main">1774 <span class="peach-settings-value" style="color:var(--peach-t1)">1775 {secureResetHeadline(generation()?.state)}1776 </span>1777 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1778 {secureResetDetail(generation()?.state)}1779 </span>1780 </div>1781 <Show1782 when={1783 generation()?.state === "LEGACY_ACTIVE" ||1784 generation()?.state === "RESET_REQUIRED" ||1785 generation()?.state === "RESET_CONFIRMED"1786 }1787 >1788 <button1789 class="peach-btn peach-btn--subtle peach-btn--sm"1790 onClick={() => {1791 setResetError(null);1792 setResetPassword("");1793 setResetOpen(true);1794 }}1795 >reset sync</button>1796 </Show>1797 </div>1798 <Show when={resetError()}>1799 <p1800 class="peach-settings-value"1801 role="alert"1802 style="color:var(--peach-danger,#e5805c);font-size:11px;line-height:1.5"1803 >{resetError()}</p>1804 </Show>1805 <Show when={resetOpen()}>1806 <div class="peach-settings-stack" style="padding: 4px 0 2px; gap: 6px;">1807 <p class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1808 {SECURE_RESET_DISCLOSURE}1809 </p>1810 <input1811 class="peach-settings-input"1812 type="password"1813 placeholder="master password"1814 value={resetPassword()}1815 onInput={(e) => setResetPassword((e.target as HTMLInputElement).value)}1816 autocomplete="current-password"1817 />1818 <div style="display:flex;gap:4px">1819 <button1820 class="peach-btn peach-btn--subtle peach-btn--sm"1821 disabled={resetting()}1822 onClick={() => void runSecureReset()}1823 >{resetting() ? "resetting…" : "reset"}</button>1824 <button1825 class="peach-btn peach-btn--subtle peach-btn--sm"1826 disabled={resetting()}1827 onClick={() => setResetOpen(false)}1828 >cancel</button>1829 </div>1830 </div>1831 </Show>1832 </Show>18331834 <Show when={pairedDevices().length > 0}>1835 <p class="peach-settings-sub-label">PAIRED DEVICES</p>1836 <For each={pairedDevices()}>1837 {(d) => (1838 <div class="peach-settings-row peach-settings-row--top">1839 <div class="peach-settings-row-main">1840 <Show1841 when={renameDeviceId() === d.deviceId}1842 fallback={<span>{d.localAlias ?? d.deviceName ?? "Unnamed device"}</span>}1843 >1844 <input1845 class="peach-settings-input"1846 aria-label={`Rename ${d.localAlias ?? d.deviceName ?? "device"}`}1847 maxlength={64}1848 value={renameDraft()}1849 onInput={(event) => setRenameDraft(event.currentTarget.value)}1850 onKeyDown={(event) => {1851 if (event.key === "Enter") void renameDevice(d.deviceId);1852 if (event.key === "Escape") setRenameDeviceId(null);1853 }}1854 />1855 </Show>1856 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1857 {deviceTypeLabel(d.deviceType)} · {syncRelativeTime(d.lastSyncedAt)}{isSyncStale(d) ? " · not seen recently" : ""}1858 </span>1859 </div>1860 <Show1861 when={confirmUnpair() === d.deviceId}1862 fallback={1863 <div style="display:flex;gap:4px;flex-shrink:0">1864 <Show1865 when={renameDeviceId() === d.deviceId}1866 fallback={1867 <button1868 class="peach-btn peach-btn--subtle peach-btn--sm"1869 onClick={() => {1870 setRenameDraft(d.localAlias ?? d.deviceName ?? "");1871 setRenameDeviceId(d.deviceId);1872 }}1873 >rename</button>1874 }1875 >1876 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => setRenameDeviceId(null)}>cancel</button>1877 <button class="peach-btn peach-btn--subtle peach-btn--sm" disabled={!renameDraft().trim()} onClick={() => void renameDevice(d.deviceId)}>save</button>1878 </Show>1879 <button1880 class="peach-btn peach-btn--subtle peach-btn--sm"1881 onClick={() => {1882 setUnpairError(null);1883 setConfirmUnpair(d.deviceId);1884 }}1885 >remove</button>1886 </div>1887 }1888 >1889 {18901891189218931894}1895 <div class="peach-unpair-confirm">1896 <p class="peach-unpair-confirm-note">1897 Stops this device receiving future changes. It doesn't1898 lock it out of what it already has — if it's lost or1899 stolen, also change your master password and generate1900 new recovery words.1901 </p>1902 <div style="display:flex;gap:6px;justify-content:flex-end">1903 <button class="peach-btn peach-btn--subtle peach-btn--sm" onClick={() => setConfirmUnpair(null)}>cancel</button>1904 <button1905 class="peach-btn peach-btn--sm"1906 style="background:var(--peach-breach);border-color:var(--peach-breach)"1907 onClick={() => void unpairDevice(d.deviceId)}1908 >remove</button>1909 </div>1910 </div>1911 <Show when={unpairError()}>1912 <p class="peach-settings-value" role="alert" style="color:var(--peach-danger,#e5805c);font-size:11px;line-height:1.5">1913 {unpairError()}1914 </p>1915 </Show>1916 </Show>1917 </div>1918 )}1919 </For>1920 </Show>19211922 <Show when={pendingVouched().length > 0}>1923 <p class="peach-settings-sub-label">1924 PENDING DEVICES1925 <span class="peach-pro-badge" style="background:#C8A840;color:#1a1a1a">{pendingVouched().length}</span>1926 </p>1927 <For each={pendingVouched()}>1928 {(dev) => (1929 <div class="peach-settings-row peach-settings-row--top">1930 <div class="peach-settings-row-main">1931 <span>{dev.deviceName}</span>1932 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">1933 Key {dev.longTermPublicKeyHex.slice(0, 12).match(/.{4}/g)?.join(" ")} ·1934 requested {new Date(dev.receivedAt).toISOString().slice(0, 16).replace("T", " ")} UTC ·1935 vouched by device {dev.vouchedByDeviceId}. Allowing it can read1936 existing vault contents and all future changes.1937 </span>1938 </div>1939 <div style="display:flex;gap:6px;flex-shrink:0">1940 <button1941 class="peach-btn peach-btn--sm"1942 disabled={vouchedBusy() === dev.deviceId}1943 onClick={() => void confirmVouched(dev.deviceId)}1944 >Allow</button>1945 <button1946 class="peach-btn peach-btn--subtle peach-btn--sm"1947 disabled={vouchedBusy() === dev.deviceId}1948 onClick={() => void rejectVouched(dev.deviceId)}1949 >Reject</button>1950 </div>1951 </div>1952 )}1953 </For>1954 </Show>19551956 <p class="peach-settings-sub-label">ADD A DEVICE</p>1957 <button1958 class="peach-sync-pair-option"1959 onClick={() => props.onOpenSyncPairing?.("code")}1960 >1961 <span class="peach-sync-pair-option-icon" aria-hidden="true">1962 <svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">1963 <rect x="6" y="2.5" width="8" height="15" rx="1.6" />1964 <path d="M9 15 L11 15" />1965 </svg>1966 </span>1967 <span class="peach-sync-pair-option-main">1968 <span class="peach-sync-pair-option-title">Show a code</span>1969 <span class="peach-sync-pair-option-sub">Scan it with Peach on your phone, then confirm one 8-digit code</span>1970 </span>1971 <span class="peach-sync-pair-option-chevron" aria-hidden="true">›</span>1972 </button>1973 <Show when={!isPro()}>1974 <p class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2);margin:8px 2px 0">1975 At least one device needs Peach Pro — pair with a Pro device and it carries over to here.1976 </p>1977 </Show>19781979 <button1980 class="peach-settings-advanced-toggle peach-sync-disclosure-toggle"1981 onClick={() => setShowSyncConnection((value) => !value)}1982 aria-expanded={showSyncConnection()}1983 aria-controls="peach-sync-connection"1984 >1985 <span>1986 <span class="peach-settings-sub-label" style="margin:0">CONNECTION</span>1987 <span class="peach-sync-disclosure-summary">Relay and privacy choices</span>1988 </span>1989 <span class="peach-settings-advanced-chevron">1990 {showSyncConnection() ? "▲" : "▼"}1991 </span>1992 </button>1993 <Show when={showSyncConnection()}>1994 <div id="peach-sync-connection" class="peach-sync-disclosure-content">1995 <SyncModeSelector />1996 </div>1997 </Show>19981999 <button2000 class="peach-settings-advanced-toggle peach-sync-disclosure-toggle"2001 onClick={() => setShowSyncRecovery((value) => !value)}2002 aria-expanded={showSyncRecovery()}2003 aria-controls="peach-sync-recovery"2004 >2005 <span>2006 <span class="peach-settings-sub-label" style="margin:0">RECOVERY & SECURITY</span>2007 <span class="peach-sync-disclosure-summary">For a lost or stolen device</span>2008 </span>2009 <span class="peach-settings-advanced-chevron">2010 {showSyncRecovery() ? "▲" : "▼"}2011 </span>2012 </button>2013 <Show when={showSyncRecovery()}>2014 <div id="peach-sync-recovery" class="peach-sync-disclosure-content">2015 <Show2016 when={rotateConfirmOpen()}2017 fallback={2018 <div class="peach-settings-row peach-settings-row--top">2019 <div class="peach-settings-row-main">2020 <span>Rotate sync identity</span>2021 <span class="peach-settings-value" style="font-size:11px;line-height:1.5;color:var(--peach-t2)">2022 Disconnects every device and replaces the keys used for sync.2023 </span>2024 </div>2025 <button2026 class="peach-btn peach-btn--subtle peach-btn--sm"2027 style="color:var(--peach-breach);border-color:color-mix(in srgb,var(--peach-breach) 40%,transparent)"2028 onClick={() => { setRotateError(null); setRotatePassword(""); setRotateConfirmOpen(true); }}2029 >rotate</button>2030 </div>2031 }2032 >2033 <div class="peach-info-notice" style="margin-top:8px;border-color:color-mix(in srgb,var(--peach-breach) 40%,transparent)">2034 This disconnects every paired device and changes your 12 recovery words. You'll be shown the new words next.2035 <label class="peach-label" for="rotate-master-password">master password</label>2036 <input2037 id="rotate-master-password"2038 class="peach-input"2039 type="password"2040 autocomplete="current-password"2041 value={rotatePassword()}2042 onInput={(event) => setRotatePassword(event.currentTarget.value)}2043 disabled={rotating()}2044 />2045 <Show when={rotateError()}>2046 <div style="color:var(--peach-breach);margin-top:6px">{rotateError()}</div>2047 </Show>2048 <div style="display:flex;gap:6px;margin-top:10px">2049 <button2050 class="peach-btn peach-btn--subtle peach-btn--sm"2051 disabled={rotating()}2052 onClick={() => { setRotatePassword(""); setRotateConfirmOpen(false); }}2053 >Cancel</button>2054 <button2055 class="peach-btn peach-btn--sm"2056 style="background:var(--peach-breach);border-color:var(--peach-breach)"2057 disabled={rotating() || !rotatePassword()}2058 onClick={() => void doRotateSyncIdentity()}2059 >{rotating() ? "Rotating…" : "Rotate sync identity"}</button>2060 </div>2061 </div>2062 </Show>2063 </div>2064 </Show>2065 </div>2066 </div>2067 );2068 }20692070 function renderAppearance() {2071 const sizeOptions: Array<{ id: "medium" | "large"; label: string }> = [2072 { id: "medium", label: "Default" },2073 { id: "large", label: "Large" },2074 ];2075 return (2076 <div class="peach-settings-body">2077 <div class="peach-settings-group">2078 <p class="peach-settings-sub-label">THEME</p>2079 <div class="peach-settings-row peach-settings-row--meta">2080 <span>Theme</span>2081 <button2082 class="peach-btn peach-btn--subtle peach-btn--sm"2083 onClick={() =>2084 props.onThemeChange(props.theme === "dark" ? "light" : "dark")2085 }2086 >2087 {props.theme === "dark" ? "Switch to light" : "Switch to dark"}2088 </button>2089 </div>20902091 <p class="peach-settings-sub-label">ACCENT</p>2092 <div class="peach-settings-row peach-settings-row--meta peach-settings-row--accent">2093 <span>Accent</span>2094 <div class="peach-accent-picker">2095 <For each={ACCENT_COLORS}>2096 {(color) => (2097 <button2098 class="peach-accent-swatch peach-swatch"2099 classList={{ "is-active": props.accentColor === color.name }}2100 style={{ background: color.hex }}2101 onClick={() => void props.onAccentChange(color.name)}2102 aria-label={color.name}2103 title={color.name}2104 />2105 )}2106 </For>2107 </div>2108 </div>21092110 <p class="peach-settings-sub-label">TEXT SIZE</p>2111 <div class="peach-settings-row peach-settings-row--meta">2112 <span>Size</span>2113 <div class="peach-pill-group">2114 <For each={sizeOptions}>2115 {(opt) => (2116 <button2117 class="peach-btn peach-btn--ghost peach-btn--sm"2118 classList={{ "is-active": props.textSize === opt.id }}2119 onClick={() => void props.onTextSizeChange(opt.id)}2120 >2121 {opt.label}2122 </button>2123 )}2124 </For>2125 </div>2126 </div>21272128 <p class="peach-settings-sub-label">MOTION</p>2129 <div class="peach-settings-row peach-settings-row--meta">2130 <span>Reduce motion</span>2131 <button2132 class="peach-btn peach-btn--subtle peach-btn--sm"2133 onClick={() => void props.onReduceMotionChange(!props.reduceMotion)}2134 >2135 {props.reduceMotion ? "On" : "Off"}2136 </button>2137 </div>2138 </div>2139 </div>2140 );2141 }21422143 function renderShortcuts() {2144 const [capturingAction, setCapturingAction] = createSignal<ShortcutAction | null>(null);2145 const [conflictMsg, setConflictMsg] = createSignal<string | null>(null);21462147 function startCapture(action: ShortcutAction) {2148 setConflictMsg(null);2149 setCapturingAction(action);2150 }2151 function cancelCapture() {2152 setCapturingAction(null);2153 setConflictMsg(null);2154 }2155 function commitBinding(action: ShortcutAction, binding: Keybinding) {2156 const conflict = findConflict(props.shortcuts, binding, action);2157 if (conflict) {2158 const other = SHORTCUT_DESCRIPTORS.find((d) => d.action === conflict);2159 setConflictMsg(`Already bound to "${other?.label ?? conflict}"`);2160 return;2161 }2162 const next = { ...props.shortcuts, [action]: binding };2163 setCapturingAction(null);2164 setConflictMsg(null);2165 void props.onShortcutsChange(next);2166 }2167 function resetAction(action: ShortcutAction) {2168 const next = { ...props.shortcuts, [action]: DEFAULT_BINDINGS[action] };2169 void props.onShortcutsChange(next);2170 }2171 function resetAll() {2172 void props.onShortcutsChange({ ...DEFAULT_BINDINGS });2173 }21742175 2176 2177 function handleCaptureKey(e: KeyboardEvent) {2178 e.preventDefault();2179 e.stopPropagation();2180 if (e.key === "Escape") { cancelCapture(); return; }2181 const binding = keybindingFromEvent(e);2182 if (!binding) return; 2183 const action = capturingAction();2184 if (action) commitBinding(action, binding);2185 }21862187 return (2188 <div class="peach-settings-body">2189 <div class="peach-settings-group peach-shortcuts-group">2190 <p class="peach-settings-sub-label">ENTRY VIEW</p>2191 <For each={SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "entry")}>2192 {(desc) => renderRow(desc, capturingAction, startCapture, cancelCapture, resetAction, handleCaptureKey)}2193 </For>2194 </div>21952196 <div class="peach-settings-group peach-shortcuts-group">2197 <p class="peach-settings-sub-label">ANYWHERE IN POPUP</p>2198 <For each={SHORTCUT_DESCRIPTORS.filter((d) => d.scope === "global")}>2199 {(desc) => renderRow(desc, capturingAction, startCapture, cancelCapture, resetAction, handleCaptureKey)}2200 </For>2201 </div>22022203 <Show when={conflictMsg()}>2204 <div class="peach-shortcuts-conflict">{conflictMsg()}</div>2205 </Show>22062207 <div class="peach-settings-group" style="display:flex;flex-direction:column;gap:8px">2208 <div class="peach-settings-row peach-settings-row--meta">2209 <span>Inline autofill on page</span>2210 <a2211 class="peach-settings-link"2212 href="chrome://extensions/shortcuts"2213 onClick={(e) => {2214 e.preventDefault();2215 chrome.tabs.create({ url: "chrome://extensions/shortcuts" });2216 }}2217 >2218 ⌘⇧P — customize ↗2219 </a>2220 </div>2221 <button2222 class="peach-btn peach-btn--subtle peach-btn--sm"2223 style="align-self:flex-start"2224 onClick={resetAll}2225 >2226 Reset all to defaults2227 </button>2228 </div>2229 </div>2230 );22312232 function renderRow(2233 desc: typeof SHORTCUT_DESCRIPTORS[number],2234 capturing: () => ShortcutAction | null,2235 onStart: (a: ShortcutAction) => void,2236 onCancel: () => void,2237 onReset: (a: ShortcutAction) => void,2238 onKey: (e: KeyboardEvent) => void,2239 ) {2240 const isActive = () => capturing() === desc.action;2241 const binding = () => props.shortcuts[desc.action];2242 const isCustom = () => {2243 const b = binding();2244 const d = DEFAULT_BINDINGS[desc.action];2245 return b.key !== d.key2246 || Boolean(b.ctrl) !== Boolean(d.ctrl)2247 || Boolean(b.meta) !== Boolean(d.meta)2248 || Boolean(b.shift) !== Boolean(d.shift)2249 || Boolean(b.alt) !== Boolean(d.alt);2250 };2251 return (2252 <div class="peach-shortcut-row">2253 <span class="peach-shortcut-row-label">{desc.label}</span>2254 <button2255 class="peach-shortcut-chip"2256 classList={{ "is-capturing": isActive(), "is-custom": isCustom() }}2257 onClick={() => isActive() ? onCancel() : onStart(desc.action)}2258 onKeyDown={(e) => { if (isActive()) onKey(e); }}2259 ref={(el) => {2260 2261 if (el) {2262 queueMicrotask(() => { if (isActive()) el.focus(); });2263 }2264 }}2265 >2266 {isActive() ? "Press a key…" : formatKeybinding(binding())}2267 </button>2268 <Show when={isCustom() && !isActive()}>2269 <button2270 class="peach-shortcut-reset"2271 title="Reset to default"2272 onClick={() => onReset(desc.action)}2273 >2274 ↺2275 </button>2276 </Show>2277 </div>2278 );2279 }2280 }22812282 const [licenseKey, setLicenseKey] = createSignal<string | null>(null);2283 const [showKey, setShowKey] = createSignal(false);22842285 const [deactivating, setDeactivating] = createSignal(false);22862287 async function handleDeactivateLicense() {2288 setDeactivating(true);2289 await sendMessage({ type: "DEACTIVATE_LICENSE" });2290 setLicenseInfo(null);2291 await props.onLicenseChange?.();2292 setDeactivating(false);2293 }22942295 async function handleTestCanary(entry: {id: string; title: string; canary: Canary}) {2296 setCanaryTestingId(entry.id);2297 setCanaryTestResult(null);2298 const res = await sendMessage({2299 type: "FIRE_CANARY_PING",2300 payload: { webhookUrl: entry.canary.webhookUrl, entryTitle: entry.title, trigger: "test" },2301 }) as { ok: boolean };2302 setCanaryTestResult({ id: entry.id, ok: res.ok });2303 setCanaryTestingId(null);2304 setTimeout(() => setCanaryTestResult((r) => r?.id === entry.id ? null : r), 3000);2305 }23062307 function renderLicense() {2308 async function onActivate() {2309 await handleActivateLicense();2310 if ((licenseInfo()?.valid ?? false) && licenseInfo()?.plan === "pro") {2311 await props.onLicenseChange?.();2312 }2313 }23142315 return (2316 <div class="peach-settings-body">2317 <Show2318 when={isPro()}2319 fallback={2320 <div class="peach-pro-upgrade">2321 <p class="peach-pro-eyebrow">PEACH PRO · ONE-TIME</p>23222323 <h2 class="peach-pro-headline">2324 Every<em>thing,</em><br />every<em>where.</em>2325 </h2>23262327 <p class="peach-pro-subtitle">2328 One key unlocks every Pro feature — for the lifetime of the app.2329 </p>23302331 <div class="peach-pro-grid">2332 <For each={PRO_FEATURES}>2333 {(item, i) => (2334 <div2335 class="peach-pro-grid-item"2336 classList={{ "is-highlighted": props.upgradeHighlight === item.feature }}2337 >2338 <span class="peach-pro-grid-num">{String(i() + 1).padStart(2, "0")}</span>2339 <span class="peach-pro-grid-name">{item.name}</span>2340 <span class="peach-pro-grid-desc">{item.desc}</span>2341 </div>2342 )}2343 </For>2344 </div>23452346 <p class="peach-pro-section-label">ADVANCED SECURITY</p>2347 <div class="peach-pro-grid">2348 <For each={PRO_SECURITY_FEATURES}>2349 {(item, i) => (2350 <div2351 class="peach-pro-grid-item"2352 classList={{ "is-highlighted": props.upgradeHighlight === item.feature }}2353 >2354 <span class="peach-pro-grid-num">{String(PRO_FEATURES.length + i() + 1).padStart(2, "0")}</span>2355 <span class="peach-pro-grid-name">{item.name}</span>2356 <span class="peach-pro-grid-desc">{item.desc}</span>2357 </div>2358 )}2359 </For>2360 </div>23612362 <div class="peach-pro-upgrade-actions">2363 <p class="peach-pro-pricing">2364 $39 <span class="peach-pro-pricing-sub">once · yours forever</span>2365 </p>2366 <a2367 href="https://buy.polar.sh/polar_cl_IXSFIPojx67rcOTksn8LkH5mnU3osPHtYqBIl1eyuIz"2368 target="_blank"2369 rel="noopener noreferrer"2370 class="peach-pro-upgrade-cta"2371 >2372 Get Peach Pro2373 </a>2374 <div class="peach-pro-key-divider"><span>ALREADY HAVE A KEY</span></div>2375 <div class="peach-pro-key-inline">2376 <input2377 class="peach-pro-key-inline-input"2378 type="text"2379 placeholder="PEACH-XXXX-XXXX-XXXX"2380 value={licenseKeyInput()}2381 onInput={(e) => setLicenseKeyInput(e.currentTarget.value)}2382 onKeyDown={(e) => { if (e.key === "Enter") void onActivate(); }}2383 autocomplete="off"2384 spellcheck={false}2385 />2386 <button2387 class="peach-pro-key-apply"2388 onClick={() => void onActivate()}2389 disabled={activatingLicense() || !licenseKeyInput().trim()}2390 >2391 {activatingLicense() ? "…" : "APPLY"}2392 </button>2393 </div>2394 <Show when={licenseError()}>2395 <p class="peach-pro-key-error">{licenseError()}</p>2396 </Show>2397 </div>2398 </div>2399 }2400 >2401 <div class="peach-pro-active">2402 <div class="peach-pro-active-hero">2403 <button2404 class="peach-pro-active-mark-wrap"2405 type="button"2406 aria-label="Celebrate"2407 onClick={handleProCelebrationClick}2408 >2409 <PeachMark class="peach-pro-active-mark" />2410 <Show when={justActivated()}>2411 <div class="peach-pro-sparks" aria-hidden="true">2412 <span class="peach-pro-spark" style="--spark-x:0px;--spark-y:-54px;--spark-delay:0ms">✦</span>2413 <span class="peach-pro-spark" style="--spark-x:38px;--spark-y:-38px;--spark-delay:50ms">✦</span>2414 <span class="peach-pro-spark" style="--spark-x:54px;--spark-y:0px;--spark-delay:110ms">·</span>2415 <span class="peach-pro-spark" style="--spark-x:38px;--spark-y:38px;--spark-delay:30ms">✦</span>2416 <span class="peach-pro-spark" style="--spark-x:0px;--spark-y:54px;--spark-delay:80ms">·</span>2417 <span class="peach-pro-spark" style="--spark-x:-38px;--spark-y:38px;--spark-delay:130ms">✦</span>2418 <span class="peach-pro-spark" style="--spark-x:-54px;--spark-y:0px;--spark-delay:55ms">·</span>2419 <span class="peach-pro-spark" style="--spark-x:-38px;--spark-y:-38px;--spark-delay:95ms">✦</span>2420 </div>2421 </Show>2422 </button>2423 <h2 class="peach-pro-active-title">Peach Pro</h2>2424 <p class="peach-pro-active-since">{formatActivatedSince(licenseInfo()?.issued)}</p>2425 <Show when={justActivated()}>2426 <p class="peach-pro-thankyou-text" aria-live="polite">thank you ✦</p>2427 </Show>2428 </div>24292430 <Show when={licenseKey()}>2431 <div class="peach-settings-license">2432 <span class="peach-settings-label">LICENSE KEY</span>2433 <div class="peach-settings-license-row">2434 <Show2435 when={showKey()}2436 fallback={2437 <span class="peach-settings-license-key peach-settings-license-key--masked" aria-label="License key hidden">2438 ••••••••••••••••••••••••••••2439 </span>2440 }2441 >2442 <span class="peach-settings-license-key">{licenseKey()!}</span>2443 </Show>2444 <div class="peach-settings-license-actions">2445 <button2446 class="peach-settings-license-copy"2447 title="Copy license key"2448 onClick={() => copyLicenseKey(licenseKey()!)}2449 >2450 {copied() ? "✓" : "copy"}2451 </button>2452 <button2453 class="peach-settings-license-toggle"2454 aria-label={showKey() ? "Hide license key" : "Reveal license key"}2455 title={showKey() ? "Hide" : "Reveal"}2456 onClick={() => setShowKey(v => !v)}2457 >2458 <Show2459 when={showKey()}2460 fallback={2461 <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">2462 <ellipse cx="7" cy="7" rx="5.5" ry="3.5" />2463 <circle cx="7" cy="7" r="1.5" fill="currentColor" stroke="none" />2464 </svg>2465 }2466 >2467 <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">2468 <ellipse cx="7" cy="7" rx="5.5" ry="3.5" />2469 <circle cx="7" cy="7" r="1.5" fill="currentColor" stroke="none" />2470 <line x1="2" y1="2" x2="12" y2="12" />2471 </svg>2472 </Show>2473 </button>2474 </div>2475 </div>2476 </div>2477 </Show>24782479 <div class="peach-pro-active-features">2480 <For each={[...PRO_FEATURES, ...PRO_SECURITY_FEATURES]}>2481 {(item) => (2482 <div class="peach-pro-active-feature">2483 <span class="peach-pro-active-feature-mark">✦</span>2484 <span class="peach-pro-active-feature-name">{item.name}</span>2485 </div>2486 )}2487 </For>2488 </div>24892490 <button2491 class="peach-pro-deactivate"2492 onClick={() => void handleDeactivateLicense()}2493 disabled={deactivating()}2494 >2495 {deactivating() ? "Deactivating…" : "Deactivate"}2496 </button>2497 </div>2498 </Show>2499 </div>2500 );2501 }25022503 function renderFeedback() {2504 return (2505 <div class="peach-settings-body">2506 <div class="peach-settings-group peach-feedback-group">2507 <Show2508 when={feedbackState() === 'sent'}2509 fallback={2510 <>2511 <p class="peach-feedback-intro">2512 Help us improve Peach. Every report goes directly to our inbox.2513 </p>25142515 <p class="peach-settings-sub-label">TYPE</p>2516 <div class="peach-feedback-chips">2517 <For each={FEEDBACK_CATEGORIES}>2518 {(cat) => {2519 const selected = () => fbCategory() === cat;2520 return (2521 <button2522 type="button"2523 class={`peach-feedback-chip ${selected() ? "is-active" : ""}`}2524 aria-pressed={selected()}2525 onClick={() => setFbCategory(cat)}2526 >2527 {cat}2528 </button>2529 );2530 }}2531 </For>2532 </div>25332534 <p class="peach-settings-sub-label">MESSAGE</p>2535 <textarea2536 class="peach-feedback-textarea"2537 placeholder="Describe the issue or idea..."2538 maxLength={MAX_FEEDBACK_MESSAGE_LENGTH}2539 value={fbMessage()}2540 onInput={(e) => setFbMessage(e.currentTarget.value)}2541 />25422543 <p class="peach-feedback-meta">2544 Version {version} · will be included automatically2545 </p>25462547 <button2548 type="button"2549 class="peach-btn peach-btn--accent peach-btn--sm peach-feedback-submit"2550 disabled={!fbMessage().trim() || feedbackState() === 'sending'}2551 onClick={() => void handleSubmitFeedback()}2552 >2553 <Switch>2554 <Match when={feedbackState() === 'idle'}>Send</Match>2555 <Match when={feedbackState() === 'sending'}>Sending...</Match>2556 <Match when={feedbackState() === 'error'}>Failed - try again</Match>2557 </Switch>2558 </button>25592560 <p class="peach-feedback-anon">2561 Sent anonymously · no account required2562 </p>2563 </>2564 }2565 >2566 <div class="peach-feedback-thanks" role="status" aria-live="polite">2567 <p class="peach-feedback-thanks-title">Thank you</p>2568 <p>2569 Your note is in the queue. Someone will process it soon.2570 </p>2571 </div>2572 </Show>2573 </div>2574 </div>2575 );2576 }25772578 const bodies: StackBodies = {2579 protection: renderSecurity(),2580 vault: renderVault(),2581 sync: renderSync(),2582 appearance: renderAppearance(),2583 shortcuts: renderShortcuts(),2584 pro: renderLicense(),2585 feedback: renderFeedback(),2586 };25872588 return (2589 <Show2590 when={showWhatsNew()}2591 fallback={2592 <Show2593 when={showNewRecoveryWords()}2594 fallback={2595 <div2596 class="peach-overlay-view peach-settings-overlay"2597 classList={{ "ov-enter-right": !props.isExiting, "ov-exit-right": !!props.isExiting }}2598 style="display:flex;flex-direction:column"2599 >2600 <StackDeck2601 active={activeCard()}2602 onActiveChange={setActiveCard}2603 onBack={props.onBack}2604 cards={cards()}2605 bodies={bodies}2606 version={version}2607 isFanning={isFanning()}2608 celebratingCardId={justActivated() ? "pro" : null}2609 isPro={isPro()}2610 />2611 </div>2612 }2613 >2614 <RecoveryWordDisplayView onDone={() => setShowNewRecoveryWords(false)} />2615 </Show>2616 }2617 >2618 <div class="peach-overlay-view peach-settings-overlay">2619 <WhatsNewView mode="history" onContinue={() => setShowWhatsNew(false)} />2620 </div>2621 </Show>2622 );2623}