1import { createEffect, createMemo, createSignal, For, onCleanup, Show } from "solid-js";2import type { ProFeature, VaultEntry } from "../../shared/types";3import { isPasskeyOnly } from "../../shared/types";4import { detectBrowser } from "../../shared/browser";5import { detectHomograph, getDisplayDomain } from "../../shared/domain";6import { faviconUrl, faviconImgSig, globeFaviconSig, titleInitials, titleBackground } from "../../shared/favicon";7import { generateTOTP, parseOtpauthURI } from "../../crypto/totp";8import { sendMessage, triggerPipPulse, triggerRing } from "../App";9import { popupCopy } from "../copy";10import { GeneratorDrawer } from "../components/GeneratorDrawer";11import { NoteEditorInline, Toolbar } from "./NoteEditor";12import { IdentitySuggestList } from "./Add";1314type EditableField = "title" | "url" | "username" | "email" | "password" | "notes" | "totp" | null;15161718function timeSince(when: number): string {19 const secs = Math.max(0, Math.floor((Date.now() - when) / 1000));20 if (secs < 60) return "just now";21 const mins = Math.floor(secs / 60);22 if (mins < 60) return `${mins}m ago`;23 const hours = Math.floor(mins / 60);24 if (hours < 24) return `${hours}h ago`;25 const days = Math.floor(hours / 24);26 if (days < 30) return `${days}d ago`;27 const months = Math.floor(days / 30);28 if (months < 12) return `${months}mo ago`;29 return `${Math.floor(months / 12)}y ago`;30}3132interface EntryProps {33 entry: VaultEntry | null;34 3536373839 currentTabUrl?: string;40 onDelete: () => void;41 42 onFieldSaved: () => void | Promise<void>;43 onEscape?: () => void;44 entries?: VaultEntry[];45 4647 isPro?: boolean;48 4950 onProGate?: (feature: ProFeature) => void;51}52535455function DomainFavicon(props: { domain: string; title: string }) {56 const src = props.domain ? faviconUrl(props.domain) : null;57 const [isReal, setIsReal] = createSignal(false);58 const label = () => titleInitials(props.title || props.domain);59 const bg = () => titleBackground(props.title || props.domain);60 const chipStyle = () =>61 `display:inline-flex;align-items:center;justify-content:center;` +62 `width:16px;height:16px;border-radius:3px;background:${bg()};` +63 `font-family:"IBM Plex Mono",monospace;font-size:0.4375rem;font-weight:600;` +64 `letter-spacing:0.04em;color:rgba(240,232,216,0.92);flex-shrink:0;margin-right:5px;`;65 return (66 <Show67 when={isReal()}68 fallback={69 <>70 <span style={chipStyle()} aria-hidden="true">{label()}</span>71 {src && (72 <img73 src={src}74 style="display:none"75 onError={() => {}}76 onLoad={async (e) => {77 const img = e.currentTarget as HTMLImageElement;78 if (img.naturalWidth <= 16) return;79 const sig = faviconImgSig(img);80 if (sig !== null) {81 const gSig = await globeFaviconSig();82 if (gSig !== null && sig === gSig) return;83 }84 setIsReal(true);85 }}86 />87 )}88 </>89 }90 >91 <img src={src!} width="16" height="16" alt="" style="border-radius:3px;margin-right:5px;flex-shrink:0;" />92 </Show>93 );94}9596export function EntryView(props: EntryProps) {97 const [editingField, setEditingField] = createSignal<EditableField>(null);98 const [draft, setDraft] = createSignal("");99 const [saving, setSaving] = createSignal(false);100 const [showPassword, setShowPassword] = createSignal(false);101 const [showGenerator, setShowGenerator] = createSignal(false);102 const [showHistory, setShowHistory] = createSignal(false);103 const [revealedHistory, setRevealedHistory] = createSignal<Set<number>>(new Set());104 const [copied, setCopied] = createSignal<string | null>(null);105 106 107 const [additionalUrlsDraft, setAdditionalUrlsDraft] = createSignal<string[]>([]);108 const [editingTags, setEditingTags] = createSignal(false);109 const [tagsDraft, setTagsDraft] = createSignal<string[]>([]);110 const [tagInput, setTagInput] = createSignal("");111 const [showCardNumber, setShowCardNumber] = createSignal(false);112 const [showCardCvc, setShowCardCvc] = createSignal(false);113 const [totpTick, setTotpTick] = createSignal(0);114 const [confirmDelete, setConfirmDelete] = createSignal(false);115 const [totpHot, setTotpHot] = createSignal(false);116 const [noteEditorEl, setNoteEditorEl] = createSignal<HTMLDivElement | null>(null);117 118 const [showAdvanced, setShowAdvanced] = createSignal(false);119 const [identityHelperSuppressed, setIdentityHelperSuppressed] = createSignal(false);120 let usernameInlineInput: HTMLInputElement | undefined;121 let emailInlineInput: HTMLInputElement | undefined;122 let usernameIdentityEl: HTMLDivElement | undefined;123 let emailIdentityEl: HTMLDivElement | undefined;124 let lastSavedNote: string | null = null;125 let totpClickTimer: ReturnType<typeof setTimeout> | null = null;126 onCleanup(() => { if (totpClickTimer) clearTimeout(totpClickTimer); });127128 function noteExec(cmd: string, val?: string) {129 document.execCommand(cmd, false, val);130 noteEditorEl()?.focus();131 }132133 async function saveNoteInline(html: string) {134 const entry = props.entry;135 if (!entry) return;136 const currentStored = entry.notes ?? "";137 if (html === currentStored) return;138 if (lastSavedNote !== null && html === lastSavedNote) return;139 lastSavedNote = html;140 setSaving(true);141 try {142 await sendMessage({143 type: "UPDATE_ENTRY",144 payload: { id: entry.id, patch: { notes: html } },145 });146 triggerRing();147 await props.onFieldSaved();148 } catch {149 lastSavedNote = null;150 } finally {151 setSaving(false);152 }153 }154155 const allIdentities = createMemo(() => {156 const emailMap = new Map<string, number>();157 const usernameMap = new Map<string, number>();158 for (const e of props.entries ?? []) {159 const uname = e.username?.trim() ?? "";160 const em = e.email?.trim() ?? "";161 if (uname) {162 if (uname.includes("@")) emailMap.set(uname, (emailMap.get(uname) ?? 0) + 1);163 else usernameMap.set(uname, (usernameMap.get(uname) ?? 0) + 1);164 }165 if (em) emailMap.set(em, (emailMap.get(em) ?? 0) + 1);166 }167 const result: Array<{ value: string; count: number; type: "email" | "username" }> = [];168 const seen = new Set<string>();169 for (const v of new Set([...emailMap.keys(), ...usernameMap.keys()])) {170 if (seen.has(v)) continue;171 seen.add(v);172 const ec = emailMap.get(v) ?? 0;173 const uc = usernameMap.get(v) ?? 0;174 result.push({ value: v, count: Math.max(ec, uc), type: ec >= uc ? "email" : "username" });175 }176 return result.sort((a, b) => b.count - a.count);177 });178179 const identitySuggestions = createMemo(() => {180 const field = editingField();181 if (field !== "username" && field !== "email") return [];182 return allIdentities()183 184 185 186 .filter(s => s.type === field)187 .slice(0, 8);188 });189190 const interval = window.setInterval(() => setTotpTick((n) => n + 1), 1000);191 onCleanup(() => window.clearInterval(interval));192193 const displayDomain = createMemo(() =>194 props.entry?.url ? getDisplayDomain(props.entry.url) : ""195 );196197 198 199 200 201 202 let lastEntryId: string | null = null;203 createEffect(() => {204 const id = props.entry?.id ?? null;205 if (id === lastEntryId) return;206 lastEntryId = id;207 setConfirmDelete(false);208 setEditingField(null);209 setEditingTags(false);210 setShowAdvanced(false);211 });212213 const totpState = createMemo(() => {214 void totpTick();215 if (!props.entry?.totp) return null;216 return generateTOTP(217 props.entry.totp,218 props.entry.totpAlgorithm,219 props.entry.totpDigits,220 props.entry.totpPeriod,221 );222 });223224 let prevTotpCode: string | undefined;225 createEffect(() => {226 const state = totpState();227 if (!state) { prevTotpCode = undefined; return; }228 if (prevTotpCode !== undefined && state.code !== prevTotpCode) {229 setTotpHot(true);230 window.setTimeout(() => setTotpHot(false), 3000);231 }232 prevTotpCode = state.code;233 });234235 const totpProgress = createMemo(() => {236 const state = totpState();237 if (!state) return 0;238 return ((state.remaining - 1) / 29) * 100;239 });240241 createEffect(() => {242 const shell = document.getElementById("hd-shell");243 if (!shell) return;244245 const state = totpState();246 if (!state) {247 delete shell.dataset.totpActive;248 shell.style.removeProperty("--peach-totp-progress");249 return;250 }251252 shell.dataset.totpActive = "true";253 shell.style.setProperty(254 "--peach-totp-progress",255 `${Math.max(0, totpProgress())}%`256 );257258 onCleanup(() => {259 delete shell.dataset.totpActive;260 shell.style.removeProperty("--peach-totp-progress");261 });262 });263264 const titleSizeClass = createMemo(() => {265 const length = props.entry?.title.length ?? 0;266 if (length >= 28) return "peach-entry-name--xxl";267 if (length >= 20) return "peach-entry-name--xl";268 if (length >= 14) return "peach-entry-name--lg";269 return "";270 });271 const useAnimatedTitle = createMemo(() => (props.entry?.title.length ?? 0) <= 13);272273 274275 function startEdit(field: EditableField, value: string) {276 setEditingField(field);277 setDraft(value);278 setIdentityHelperSuppressed(false);279 setShowGenerator(false);280 setShowHistory(false);281 setRevealedHistory(new Set<number>());282 setConfirmDelete(false);283 if (field === "url") {284 setAdditionalUrlsDraft([...(props.entry?.additionalUrls ?? [])]);285 }286 }287288 289 290 291 function urlMatchesAny(candidate: string, primary: string, others: string[]): boolean {292 const c = candidate.trim();293 if (!c) return true;294 if (primary.trim() === c) return true;295 return others.some((u) => u.trim() === c);296 }297298 function addCurrentSite(url: string) {299 if (!url) return;300 if (!draft().trim()) {301 setDraft(url);302 return;303 }304 if (urlMatchesAny(url, draft(), additionalUrlsDraft())) return;305 setAdditionalUrlsDraft((arr) => [...arr, url]);306 }307308 async function saveField() {309 const field = editingField();310 const entry = props.entry;311 if (!field || !entry) return;312 313 let value = field === "password" ? draft() : draft().trim();314 if (field === "totp" && value.startsWith("otpauth://")) {315 const parsed = parseOtpauthURI(value);316 value = parsed?.secret ?? value;317 }318 if (field === "password" && entry.type !== "note" && !value) {319 return;320 }321 setSaving(true);322 try {323 const patch: Partial<VaultEntry> = { [field]: value };324 if (field === "url") {325 326 patch.additionalUrls = additionalUrlsDraft();327 }328 await sendMessage({329 type: "UPDATE_ENTRY",330 payload: { id: entry.id, patch },331 });332 triggerRing();333 setEditingField(null);334 setShowGenerator(false);335 setShowHistory(false);336 setRevealedHistory(new Set<number>());337 await props.onFieldSaved();338 } catch {339 340 } finally {341 setSaving(false);342 }343 }344345 function startEditTags() {346 setTagsDraft([...(props.entry?.tags ?? [])]);347 setTagInput("");348 setEditingTags(true);349 }350351 function addTag(value: string) {352 const n = value.toLowerCase().trim();353 if (!n || n.length > 32 || tagsDraft().includes(n) || tagsDraft().length >= 10) return;354 setTagsDraft([...tagsDraft(), n]);355 setTagInput("");356 }357358 async function saveTags() {359 if (tagInput()) addTag(tagInput());360 const entry = props.entry;361 if (!entry) return;362 const next = tagsDraft().length > 0 ? tagsDraft() : undefined;363 setEditingTags(false);364 setSaving(true);365 try {366 await sendMessage({367 type: "UPDATE_ENTRY",368 payload: { id: entry.id, patch: { tags: next } },369 });370 triggerRing();371 await props.onFieldSaved();372 } catch {373 374 } finally {375 setSaving(false);376 }377 }378379 function cancelEdit() {380 setEditingField(null);381 setDraft("");382 setShowGenerator(false);383 setShowHistory(false);384 setRevealedHistory(new Set<number>());385 }386387 388 389 390 391 392 393 394 395 396 async function addOtherIdentity(target: "username" | "email") {397 const entry = props.entry;398 if (!entry) return;399 const current = editingField();400 const draftValue = draft().trim();401 const savedUsername = entry.username ?? "";402 const savedEmail = entry.email ?? "";403404 if (current === "username" && target === "username") {405 406 407 if (savedUsername.includes("@") && !entry.email) {408 setSaving(true);409 try {410 await sendMessage({411 type: "UPDATE_ENTRY",412 payload: { id: entry.id, patch: { email: savedUsername, username: "" } },413 });414 await props.onFieldSaved();415 } finally {416 setSaving(false);417 }418 }419 startEdit("username", "");420 return;421 }422423 if (current === "username" && target === "email") {424 if (draftValue && draftValue !== savedUsername) {425 setSaving(true);426 try {427 await sendMessage({428 type: "UPDATE_ENTRY",429 payload: { id: entry.id, patch: { username: draftValue } },430 });431 await props.onFieldSaved();432 } finally {433 setSaving(false);434 }435 }436 startEdit("email", "");437 return;438 }439440 if (current === "email" && target === "username") {441 if (draftValue && draftValue !== savedEmail) {442 setSaving(true);443 try {444 await sendMessage({445 type: "UPDATE_ENTRY",446 payload: { id: entry.id, patch: { email: draftValue } },447 });448 await props.onFieldSaved();449 } finally {450 setSaving(false);451 }452 }453 startEdit("username", "");454 return;455 }456 }457458 function fieldValue(entry: VaultEntry, field: Exclude<EditableField, null>): string {459 switch (field) {460 case "title":461 return entry.title;462 case "url":463 return entry.url ?? "";464 case "username":465 return entry.username ?? "";466 case "email":467 return entry.email ?? "";468 case "password":469 return entry.password ?? "";470 case "notes":471 return entry.notes ?? "";472 case "totp":473 return entry.totp ?? "";474 }475 }476477 function handleEditorFocusOut(478 field: Exclude<EditableField, null>,479 event: FocusEvent & { currentTarget: HTMLElement; relatedTarget: EventTarget | null }480 ) {481 const nextTarget = event.relatedTarget;482 if (nextTarget instanceof Node && event.currentTarget.contains(nextTarget)) return;483484 485 486 487 if (editingField() !== field) return;488489 const entry = props.entry;490 if (!entry) return;491492 const currentValue = fieldValue(entry, field);493 const nextValue = field === "password" ? draft() : draft().trim();494 if (nextValue === currentValue) {495 cancelEdit();496 }497 }498499 500501 async function copyField(text: string, label: string, button?: HTMLButtonElement) {502 const entry = props.entry;503 const ok = await popupCopy(504 text,505 label,506 entry?.canary?.webhookUrl ? { webhookUrl: entry.canary.webhookUrl, entryTitle: entry.title } : undefined,507 );508 if (ok) {509 triggerRing();510 triggerPipPulse();511 setCopied(null);512 requestAnimationFrame(() => setCopied(label));513 if (button) {514 button.classList.remove("is-copied", "is-retreat");515 void button.offsetWidth;516 const drain = document.createElement("span");517 drain.className = "peach-copy-drain";518 const bar = document.createElement("span"); bar.className = "peach-copy-drain-bar";519 drain.appendChild(bar);520 button.appendChild(drain);521 window.setTimeout(() => {522 button.classList.remove("is-copied");523 button.classList.add("is-retreat");524 drain.remove();525 window.setTimeout(() => button.classList.remove("is-retreat"), 160);526 }, 1800);527 }528 window.setTimeout(() => setCopied(null), 1800);529 }530 }531532 533534 createEffect(() => {535 if (!props.entry) return;536 const handler = (e: KeyboardEvent) => {537 const inInput = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement || (e.target as HTMLElement).isContentEditable;538 if (inInput) return;539 switch (e.key) {540 case "c": e.preventDefault();541 if (props.entry?.password) void copyField(props.entry.password, "password"); break;542 case "u": e.preventDefault();543 if (props.entry?.username) void copyField(props.entry.username, "username"); break;544 case "Escape": e.preventDefault(); props.onEscape?.(); break;545 }546 };547 window.addEventListener("keydown", handler);548 onCleanup(() => window.removeEventListener("keydown", handler));549 });550551 552553 function autoFocus(el: HTMLInputElement | HTMLTextAreaElement) {554 requestAnimationFrame(() => { el.focus(); el.select?.(); });555 }556557 function onEditKeyDown(e: KeyboardEvent) {558 if (e.key === "Enter" && !(e.target instanceof HTMLTextAreaElement)) {559 e.preventDefault();560 void saveField();561 }562 if (e.key === "Escape") { e.preventDefault(); cancelEdit(); }563 }564565 function identityKeyDown(e: KeyboardEvent, field: "username" | "email") {566 const listEl = field === "username" ? usernameIdentityEl : emailIdentityEl;567 if (e.key === "ArrowDown" && listEl) {568 e.preventDefault();569 listEl.querySelector<HTMLElement>(".peach-identity-suggestion")?.focus();570 return;571 }572 onEditKeyDown(e);573 }574575 return (576 <>577 <div578 class="peach-ghost"579 aria-hidden="true"580 style="position:absolute;top:30px;left:12px;right:0;font-family:'Cormorant Garamond',Georgia,serif;font-size:150px;font-style:italic;font-weight:400;color:var(--t0);opacity:var(--peach-ghost-opacity,0.03);pointer-events:none;line-height:1.25;overflow:hidden;white-space:nowrap;z-index:0;"581 >582 {props.entry?.title || "empty"}583 </div>584585 <div class="peach-stage" style="position:relative;">586 <Show when={props.entry} fallback={<EmptyVaultState />}>587 {(entry) => (588 <>589 {}590 <Show when={entry().type !== "note" && entry().type !== "card" && (entry().breach ?? 0) > 0}>591 <div class="peach-breach-badge">592 <svg width="10" height="10" viewBox="0 0 12 12" fill="none" stroke="var(--breach)" stroke-width="1.5" stroke-linecap="round">593 <path d="M6 1L11 10H1L6 1z" />594 <line x1="6" y1="5" x2="6" y2="7.5" />595 <circle cx="6" cy="9" r="0.5" fill="var(--breach)" stroke="none" />596 </svg>597 <span style="flex:1">found in a known data breach</span>598 </div>599 </Show>600601 {}602 <div class="peach-entry-header">603 <div class="peach-entry-header-name">604 <Show605 when={editingField() === "title"}606 fallback={607 <button608 class="peach-entry-name-button"609 title="Click to edit title"610 onClick={() => startEdit("title", entry().title)}611 >612 <h1 class={`peach-entry-name ${titleSizeClass()}`} aria-label={entry().title}>613 <span class="peach-entry-name-text">614 <Show615 when={useAnimatedTitle()}616 fallback={entry().title}617 >618 <For each={entry().title.split("")}>619 {(ch, i) => (620 <span class="peach-entry-name-char" style={`--char-index:${i()}`}>621 {ch === " " ? "\u00A0" : ch}622 </span>623 )}624 </For>625 </Show>626 </span>627 </h1>628 </button>629 }630 >631 <div632 class="peach-inline-title-wrap"633 onFocusOut={(event) => handleEditorFocusOut("title", event)}634 >635 <input636 class="peach-inline-title-input"637 value={draft()}638 onInput={(e) => setDraft(e.currentTarget.value)}639 onKeyDown={onEditKeyDown}640 ref={autoFocus}641 disabled={saving()}642 />643 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />644 </div>645 </Show>646 </div>647648 {}649 <Show when={editingField() !== "title"}>650 <Show651 when={confirmDelete()}652 fallback={653 <button654 class="peach-entry-trash-btn"655 onClick={() => setConfirmDelete(true)}656 aria-label="Move to trash"657 title="Delete entry"658 >659 <svg width="12" height="13" viewBox="0 0 12 13" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">660 <path d="M1 3h10M4 3V2h4v1M2 3l.7 8.5a1 1 0 0 0 1 .9h4.6a1 1 0 0 0 1-.9L10 3" />661 <path d="M4.5 6l.3 3.5M7.5 6l-.3 3.5" />662 </svg>663 </button>664 }665 >666 <div class="peach-entry-trash-confirm">667 <span class="peach-entry-trash-confirm-label">trash?</span>668 <button669 class="peach-btn peach-btn--sm peach-btn--danger"670 style="font-size:10px;padding:2px 8px;min-height:22px;"671 onClick={() => { setConfirmDelete(false); props.onDelete(); }}672 >673 yes674 </button>675 <button676 class="peach-btn peach-btn--ghost peach-btn--sm"677 style="font-size:10px;padding:2px 8px;min-height:22px;"678 onClick={() => setConfirmDelete(false)}679 >680 no681 </button>682 </div>683 </Show>684 </Show>685 </div>686687 {}688 <Show when={entry().type !== "note" && entry().type !== "card"}>689 <div class="peach-domain" style="position:relative;z-index:1;">690 <Show691 when={editingField() === "url"}692 fallback={693 <div694 class="peach-domain-row peach-inline-clickable"695 title="Click to edit URL"696 onClick={() => startEdit("url", entry().url ?? "")}697 >698 <DomainFavicon domain={displayDomain()} title={entry().title ?? ""} />699 <span class="peach-domain-value">700 {displayDomain() || (entry().url ? entry().url : "add a website url")}701 </span>702 <span class="peach-inline-edit-hint">edit</span>703 </div>704 }705 >706 <div707 class="peach-inline-field-wrap peach-inline-field-wrap--url"708 onFocusOut={(event) => handleEditorFocusOut("url", event)}709 >710 <div class="peach-inline-field-row">711 <input712 class="peach-inline-input"713 type="url"714 placeholder="https://"715 value={draft()}716 onInput={(e) => setDraft(e.currentTarget.value)}717 onKeyDown={onEditKeyDown}718 ref={autoFocus}719 disabled={saving()}720 />721 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />722 </div>723 <Show724 when={725 detectHomograph(draft()) ||726 additionalUrlsDraft().some((u) => detectHomograph(u))727 }728 >729 {}730 <p class="peach-homograph-warning">731 ⚠ This URL contains non-ASCII or punycode characters.732 Verify it's the site you intend.733 </p>734 </Show>735 <div class="peach-additional-urls">736 <Show when={additionalUrlsDraft().length > 0}>737 <span class="peach-label peach-additional-urls-label">also matches</span>738 </Show>739 <For each={additionalUrlsDraft()}>740 {(value, i) => (741 <div class="peach-additional-url-row">742 <input743 class="peach-inline-input"744 type="url"745 placeholder="https://"746 value={value}747 onInput={(e) => setAdditionalUrlsDraft((arr) => {748 const next = [...arr];749 next[i()] = e.currentTarget.value;750 return next;751 })}752 disabled={saving()}753 />754 <button755 class="peach-additional-url-remove"756 type="button"757 aria-label="Remove URL"758 onMouseDown={(e) => e.preventDefault()}759 onClick={() => setAdditionalUrlsDraft((arr) => arr.filter((_, idx) => idx !== i()))}760 disabled={saving()}761 >×</button>762 </div>763 )}764 </For>765 <button766 class="peach-add-field-link peach-additional-urls-add"767 type="button"768 onMouseDown={(e) => e.preventDefault()}769 onClick={() => setAdditionalUrlsDraft((arr) => [...arr, ""])}770 disabled={saving()}771 >772 + add another url773 </button>774 <Show when={props.currentTabUrl && !urlMatchesAny(props.currentTabUrl!, draft(), additionalUrlsDraft())}>775 <button776 class="peach-add-field-link peach-additional-urls-add peach-additional-urls-add-current"777 type="button"778 title={props.currentTabUrl}779 onMouseDown={(e) => e.preventDefault()}780 onClick={() => addCurrentSite(props.currentTabUrl!)}781 disabled={saving()}782 >783 + add current site784 </button>785 </Show>786 </div>787 </div>788 </Show>789 </div>790 </Show>791792 {}793 <Show when={!editingTags() && entry().tags && entry().tags!.length > 0}>794 <div795 style="display:flex;flex-wrap:wrap;gap:5px;margin:2px 0;position:relative;z-index:1;cursor:pointer;"796 onClick={startEditTags}797 title="Click to edit tags"798 >799 <For each={entry().tags!}>800 {(tag) => <span class="peach-tag-chip" style="font-size:10px;padding:2px 8px;">{tag}</span>}801 </For>802 </div>803 </Show>804805 {}806 <Show when={entry().type === "note"}>807 <div class="peach-entry-note-toolbar-row">808 <Toolbar exec={noteExec} class="peach-note-toolbar-inline" />809 </div>810 <section class="peach-fields peach-note-body" style="position:relative;z-index:1;">811 <NoteEditorInline812 entryKey={entry().id}813 initialContent={entry().notes ?? ""}814 onReady={(el) => { setNoteEditorEl(el); lastSavedNote = null; }}815 onBlur={saveNoteInline}816 autoFocus={false}817 />818 </section>819 </Show>820821 {}822 <Show when={entry().type === "card"}>823 <section class="peach-fields" style="position:relative;z-index:1;">824 {}825 <Show when={entry().last4}>826 <div class="peach-field-card" style="padding-bottom:4px;">827 <span class="peach-label">828 <Show when={entry().network && entry().network !== "unknown"}>829 <span class="peach-card-network-badge" style="margin-left:0;margin-right:6px;">{entry().network}</span>830 </Show>831 {entry().cardNickname || `•••• ${entry().last4}`}832 </span>833 </div>834 </Show>835836 {}837 <div class="peach-field-card">838 <span class="peach-label">cardholder name</span>839 <div class="peach-field-value-row">840 <span class="peach-field-value">{entry().cardholderName || "—"}</span>841 <Show when={entry().cardholderName}>842 <button843 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "cardholderName" ? "is-copied" : ""}`}844 onClick={(e) => void copyField(entry().cardholderName!, "cardholderName", e.currentTarget as HTMLButtonElement)}845 aria-label="Copy cardholder name"846 >847 <CopyGlyph /><span class="peach-copy-sheen" />848 </button>849 </Show>850 </div>851 </div>852853 {}854 <div class="peach-field-card">855 <span class="peach-label">card number</span>856 <div class="peach-field-value-row">857 <span class={`peach-field-value peach-card-number`}>858 <Show when={showCardNumber()} fallback={859 <span>{`•••• •••• •••• ${entry().last4 ?? "••••"}`}</span>860 }>861 <span>{entry().cardNumber ?? ""}</span>862 </Show>863 </span>864 <div class="peach-field-actions">865 <button866 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"867 onClick={() => setShowCardNumber(!showCardNumber())}868 aria-label={showCardNumber() ? "Hide card number" : "Reveal card number"}869 >870 <Show when={showCardNumber()} fallback={<EyeOpenGlyph />}>871 <EyeClosedGlyph />872 </Show>873 </button>874 <Show when={entry().cardNumber}>875 <button876 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "cardNumber" ? "is-copied" : ""}`}877 onClick={(e) => {878 const cardNum = entry().cardNumber!;879 if (entry().canary?.webhookUrl) {880 void sendMessage({881 type: "FIRE_CANARY_PING",882 payload: { webhookUrl: entry().canary!.webhookUrl, entryTitle: entry().title, trigger: "password_copied" },883 });884 }885 void copyField(cardNum, "cardNumber", e.currentTarget as HTMLButtonElement);886 }}887 aria-label="Copy card number"888 >889 <CopyGlyph /><span class="peach-copy-sheen" />890 </button>891 </Show>892 </div>893 </div>894 </div>895896 {}897 <Show when={entry().expMonth || entry().expYear}>898 <div class="peach-field-card">899 <span class="peach-label">expiry</span>900 <div class="peach-field-value-row">901 <span class="peach-field-value">{entry().expMonth} / {entry().expYear}</span>902 <button903 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "expiry" ? "is-copied" : ""}`}904 onClick={(e) => void copyField(`${entry().expMonth}/${entry().expYear}`, "expiry", e.currentTarget as HTMLButtonElement)}905 aria-label="Copy expiry"906 >907 <CopyGlyph /><span class="peach-copy-sheen" />908 </button>909 </div>910 </div>911 </Show>912913 {}914 <Show when={entry().cvc}>915 <div class="peach-field-card">916 <span class="peach-label">CVC</span>917 <div class="peach-field-value-row">918 <span class="peach-field-value">919 <Show when={showCardCvc()} fallback={<span class="peach-password-mask">•••</span>}>920 <span>{entry().cvc}</span>921 </Show>922 </span>923 <div class="peach-field-actions">924 <button925 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"926 onClick={() => setShowCardCvc(!showCardCvc())}927 aria-label={showCardCvc() ? "Hide CVC" : "Show CVC"}928 >929 <Show when={showCardCvc()} fallback={<EyeOpenGlyph />}>930 <EyeClosedGlyph />931 </Show>932 </button>933 <button934 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "cvc" ? "is-copied" : ""}`}935 onClick={(e) => void copyField(entry().cvc!, "cvc", e.currentTarget as HTMLButtonElement)}936 aria-label="Copy CVC"937 >938 <CopyGlyph /><span class="peach-copy-sheen" />939 </button>940 </div>941 </div>942 </div>943 </Show>944 </section>945 </Show>946947 {}948 <Show when={entry().type !== "note" && entry().type !== "card" && !isPasskeyOnly(entry())}>949 <section class="peach-fields" style="position:relative;z-index:1;">950951 {952953}954 <Show when={entry().username || (!entry().username && !entry().email) || editingField() === "username"}>955 <div class="peach-field-card" classList={{ "is-editing": editingField() === "username" }}>956 <span class="peach-label">{entry().username?.includes("@") && !entry().email ? "email" : "username"}</span>957 <Show958 when={editingField() === "username"}959 fallback={960 <div class="peach-field-value-row">961 <span962 class="peach-field-value peach-inline-clickable"963 title="Click to edit"964 onClick={() => startEdit("username", entry().username ?? "")}965 >966 {entry().username || <span style="color:var(--t2);font-style:italic;">click to add username</span>}967 </span>968 <Show when={entry().username}>969 <button970 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "username" ? "is-copied" : ""}`}971 onClick={(e) => void copyField(entry().username!, "username", e.currentTarget as HTMLButtonElement)}972 aria-label="Copy username"973 >974 <CopyGlyph /><span class="peach-copy-sheen" />975 </button>976 </Show>977 </div>978 }979 >980 <div981 class="peach-inline-field-wrap"982 onFocusOut={(event) => handleEditorFocusOut("username", event)}983 >984 <input985 class="peach-inline-input"986 value={draft()}987 onInput={(e) => setDraft(e.currentTarget.value)}988 onKeyDown={(e) => identityKeyDown(e, "username")}989 ref={(el) => { usernameInlineInput = el; autoFocus(el); }}990 disabled={saving()}991 autocomplete="off"992 />993 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />994 <Show when={!identityHelperSuppressed() && identitySuggestions().length > 0 && editingField() === "username"}>995 <IdentitySuggestList996 listRef={(el) => (usernameIdentityEl = el)}997 inputRef={() => usernameInlineInput}998 suggestions={identitySuggestions()}999 onPick={(v) => { setDraft(v); setIdentityHelperSuppressed(true); usernameInlineInput?.focus(); }}1000 onClose={() => { setIdentityHelperSuppressed(true); usernameInlineInput?.focus(); }}1001 />1002 </Show>1003 {100410051006}1007 <Show when={!entry().email || !(entry().username && !entry().username?.includes("@"))}>1008 <button1009 class="peach-add-field-btn"1010 type="button"1011 onMouseDown={(e) => e.preventDefault()}1012 onClick={() => {1013 const isEmailShape = draft().includes("@") || (entry().username?.includes("@") ?? false);1014 const hasSeparateEmail = !!entry().email;1015 if (isEmailShape && !hasSeparateEmail) {1016 void addOtherIdentity("username");1017 } else {1018 void addOtherIdentity("email");1019 }1020 }}1021 >1022 {(() => {1023 const isEmailShape = draft().includes("@") || (entry().username?.includes("@") ?? false);1024 const hasSeparateEmail = !!entry().email;1025 return (isEmailShape && !hasSeparateEmail) || hasSeparateEmail ? "+ add username" : "+ add email";1026 })()}1027 </button>1028 </Show>1029 </div>1030 </Show>1031 </div>1032 </Show>10331034 {1035}1036 <Show when={entry().email || editingField() === "email"}>1037 <div class="peach-field-card" classList={{ "is-editing": editingField() === "email" }}>1038 <span class="peach-label">email</span>1039 <Show1040 when={editingField() === "email"}1041 fallback={1042 <div class="peach-field-value-row">1043 <span1044 class="peach-field-value peach-inline-clickable"1045 title="Click to edit"1046 onClick={() => startEdit("email", entry().email ?? "")}1047 >1048 {entry().email}1049 </span>1050 <Show when={entry().email}>1051 <button1052 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "email" ? "is-copied" : ""}`}1053 onClick={(e) => void copyField(entry().email!, "email", e.currentTarget as HTMLButtonElement)}1054 aria-label="Copy email"1055 >1056 <CopyGlyph /><span class="peach-copy-sheen" />1057 </button>1058 </Show>1059 </div>1060 }1061 >1062 <div1063 class="peach-inline-field-wrap"1064 onFocusOut={(event) => handleEditorFocusOut("email", event)}1065 >1066 <input1067 class="peach-inline-input"1068 value={draft()}1069 onInput={(e) => setDraft(e.currentTarget.value)}1070 onKeyDown={(e) => identityKeyDown(e, "email")}1071 ref={(el) => { emailInlineInput = el; autoFocus(el); }}1072 disabled={saving()}1073 autocomplete="email"1074 type="email"1075 />1076 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1077 <Show when={!identityHelperSuppressed() && identitySuggestions().length > 0 && editingField() === "email"}>1078 <IdentitySuggestList1079 listRef={(el) => (emailIdentityEl = el)}1080 inputRef={() => emailInlineInput}1081 suggestions={identitySuggestions()}1082 onPick={(v) => { setDraft(v); setIdentityHelperSuppressed(true); emailInlineInput?.focus(); }}1083 onClose={() => { setIdentityHelperSuppressed(true); emailInlineInput?.focus(); }}1084 />1085 </Show>1086 <Show when={!entry().username || entry().username?.includes("@")}>1087 <button1088 class="peach-add-field-btn"1089 type="button"1090 onMouseDown={(e) => e.preventDefault()}1091 onClick={() => void addOtherIdentity("username")}1092 >1093 + add username1094 </button>1095 </Show>1096 </div>1097 </Show>1098 </div>1099 </Show>11001101 {}1102 <div class="peach-field-card" classList={{ "is-editing": editingField() === "password" }}>1103 <span class="peach-label">password</span>1104 <Show1105 when={editingField() === "password"}1106 fallback={1107 <div class="peach-field-value-row">1108 <span1109 class="peach-password-value"1110 classList={{ "is-revealed": showPassword(), "is-breached": (entry().breach ?? 0) > 0 }}1111 style="cursor:pointer;"1112 title="Click to edit password"1113 onClick={() => startEdit("password", entry().password ?? "")}1114 >1115 <Show1116 when={showPassword()}1117 fallback={<span class="peach-password-mask" aria-label="password hidden">••••••••••••••</span>}1118 >1119 <span class="peach-password-text">{entry().password ?? ""}</span>1120 </Show>1121 </span>1122 <div class="peach-field-actions">1123 <button1124 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1125 onClick={() => setShowPassword(!showPassword())}1126 aria-label="Reveal password"1127 >1128 <Show when={showPassword()} fallback={<EyeOpenGlyph />}>1129 <EyeClosedGlyph />1130 </Show>1131 </button>1132 <button1133 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "password" ? "is-copied" : ""}`}1134 onClick={(e) => { if (entry().password) void copyField(entry().password!, "password", e.currentTarget as HTMLButtonElement); }}1135 aria-label="Copy password"1136 >1137 <CopyGlyph /><span class="peach-copy-sheen" />1138 </button>1139 </div>1140 </div>1141 }1142 >1143 {}1144 <div1145 class="peach-inline-field-wrap"1146 onFocusOut={(event) => handleEditorFocusOut("password", event)}1147 >1148 <div class="peach-password-edit-row">1149 <input1150 class="peach-inline-input"1151 type={showPassword() ? "text" : "password"}1152 placeholder="paste or type a password"1153 value={draft()}1154 onInput={(e) => setDraft(e.currentTarget.value)}1155 onKeyDown={(e) => {1156 if (e.key === "Enter") { e.preventDefault(); void saveField(); }1157 if (e.key === "Escape") { e.preventDefault(); cancelEdit(); }1158 }}1159 ref={autoFocus}1160 disabled={saving()}1161 autocomplete="new-password"1162 />1163 <button1164 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1165 type="button"1166 onClick={() => setShowPassword(!showPassword())}1167 aria-label={showPassword() ? "Hide" : "Show"}1168 >1169 <Show when={showPassword()} fallback={<EyeOpenGlyph />}>1170 <EyeClosedGlyph />1171 </Show>1172 </button>1173 </div>1174 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1175 <div class="peach-password-edit-links">1176 <button1177 class="peach-generate-toggle-link"1178 type="button"1179 onClick={() => { setShowGenerator(!showGenerator()); if (!showGenerator()) setShowHistory(false); }}1180 >1181 <svg width="10" height="10" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">1182 <path d="M11 2.5A5.5 5.5 0 1 0 12.5 7" />1183 <path d="M9.5 2.5H11V1" />1184 </svg>1185 {showGenerator() ? "hide generator" : "generate"}1186 </button>1187 <button1188 class="peach-generate-toggle-link"1189 type="button"1190 onClick={() => { setShowHistory(!showHistory()); if (!showHistory()) setShowGenerator(false); }}1191 >1192 <svg width="10" height="10" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">1193 <path d="M6.5 1a5.5 5.5 0 1 0 5.5 5.5" />1194 <path d="M6.5 3.5V6.5L8.5 8" />1195 <path d="M1 1.5V4H3.5" />1196 </svg>1197 {showHistory()1198 ? "hide history"1199 : (entry().passwordHistory?.length ? `history (${entry().passwordHistory!.length})` : "history")}1200 </button>1201 </div>1202 <Show when={showGenerator()}>1203 <GeneratorDrawer1204 open={true}1205 compact={true}1206 onUse={(pw) => { setDraft(pw); setShowGenerator(false); }}1207 />1208 </Show>1209 <Show when={showHistory()}>1210 <div class="peach-password-history">1211 <Show when={(entry().passwordHistory?.length ?? 0) === 0}>1212 <div class="peach-history-empty">1213 No earlier passwords yet. When you change this password, the old one is saved here so you can copy or restore it.1214 </div>1215 </Show>1216 <For each={entry().passwordHistory ?? []}>1217 {(item, i) => (1218 <div class="peach-history-row">1219 <div class="peach-history-main">1220 <span class="peach-history-pw" classList={{ "is-revealed": revealedHistory().has(i()) }}>1221 <Show1222 when={revealedHistory().has(i())}1223 fallback={<span class="peach-password-mask">••••••••••••</span>}1224 >1225 {item.password}1226 </Show>1227 </span>1228 <span class="peach-history-age">{timeSince(item.changedAt)}</span>1229 </div>1230 <div class="peach-history-actions">1231 <button1232 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1233 type="button"1234 title={revealedHistory().has(i()) ? "Hide" : "Reveal"}1235 onClick={() => setRevealedHistory((prev) => {1236 const next = new Set(prev);1237 if (next.has(i())) next.delete(i()); else next.add(i());1238 return next;1239 })}1240 >1241 <Show when={revealedHistory().has(i())} fallback={<EyeOpenGlyph />}>1242 <EyeClosedGlyph />1243 </Show>1244 </button>1245 <button1246 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === `history-${i()}` ? "is-copied" : ""}`}1247 type="button"1248 title="Copy"1249 onClick={(e) => void copyField(item.password, `history-${i()}`, e.currentTarget as HTMLButtonElement)}1250 >1251 <CopyGlyph /><span class="peach-copy-sheen" />1252 </button>1253 <button1254 class="peach-btn peach-btn--ghost peach-btn--sm peach-history-use"1255 type="button"1256 title="Use this password again"1257 onClick={() => { setDraft(item.password); setShowPassword(true); setShowHistory(false); }}1258 >1259 use1260 </button>1261 </div>1262 </div>1263 )}1264 </For>1265 </div>1266 </Show>1267 </div>1268 </Show>1269 </div>12701271 </section>1272 </Show>12731274 {}1275 <Show when={entry().type !== "note" && entry().type !== "card"}>1276 <Show1277 when={entry().notes || editingField() === "notes"}1278 fallback={1279 <button1280 class="peach-add-field-link peach-entry-add-link"1281 onClick={() => startEdit("notes", "")}1282 >1283 + notes1284 </button>1285 }1286 >1287 <div style="position:relative;z-index:1;margin-top:6px;">1288 <span class="peach-label" style="display:block;margin-bottom:4px;">notes</span>1289 <Show1290 when={editingField() === "notes"}1291 fallback={1292 <div1293 class="peach-note-content peach-inline-clickable"1294 style="cursor:text;white-space:pre-wrap;"1295 onClick={() => startEdit("notes", entry().notes ?? "")}1296 >1297 {entry().notes}1298 </div>1299 }1300 >1301 <div1302 class="peach-inline-field-wrap"1303 onFocusOut={(event) => handleEditorFocusOut("notes", event)}1304 >1305 <textarea1306 class="peach-inline-textarea"1307 value={draft()}1308 onInput={(e) => setDraft(e.currentTarget.value)}1309 onKeyDown={(e) => { if (e.key === "Escape") { e.preventDefault(); cancelEdit(); } }}1310 ref={(el) => requestAnimationFrame(() => el?.focus())}1311 rows={4}1312 disabled={saving()}1313 />1314 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1315 </div>1316 </Show>1317 </div>1318 </Show>1319 </Show>13201321 {}1322 <Show1323 when={editingTags()}1324 fallback={1325 <Show when={!entry().tags || entry().tags!.length === 0}>1326 <button1327 class="peach-add-field-link peach-entry-add-link"1328 onClick={startEditTags}1329 >1330 + tags1331 </button>1332 </Show>1333 }1334 >1335 <div1336 class="peach-inline-tag-editor"1337 onFocusOut={(e) => {1338 const next = e.relatedTarget;1339 if (next instanceof Node && e.currentTarget.contains(next)) return;1340 void saveTags();1341 }}1342 >1343 <span class="peach-label">tags</span>1344 <div class="peach-tag-input-wrap">1345 <For each={tagsDraft()}>1346 {(tag) => (1347 <span class="peach-tag-chip">1348 {tag}1349 <button1350 class="peach-tag-chip-remove"1351 onMouseDown={(e) => e.preventDefault()}1352 onClick={() => setTagsDraft(tagsDraft().filter(t => t !== tag))}1353 aria-label={`Remove ${tag}`}1354 >×</button>1355 </span>1356 )}1357 </For>1358 <input1359 class="peach-tag-input"1360 placeholder={tagsDraft().length === 0 ? "type and press Enter…" : ""}1361 value={tagInput()}1362 onInput={(e) => setTagInput(e.currentTarget.value)}1363 onKeyDown={(e) => {1364 if (e.key === "Enter" || e.key === ",") {1365 e.preventDefault();1366 addTag(tagInput());1367 } else if (e.key === "Backspace" && !tagInput() && tagsDraft().length > 0) {1368 setTagsDraft(tagsDraft().slice(0, -1));1369 } else if (e.key === "Escape") {1370 e.preventDefault();1371 setEditingTags(false);1372 setTagInput("");1373 }1374 }}1375 ref={(el) => requestAnimationFrame(() => el?.focus())}1376 style="flex:1;min-width:80px;background:transparent;border:none;outline:none;color:var(--t1);font-size:12px;padding:2px;"1377 />1378 </div>1379 </div>1380 </Show>13811382 {}1383 <Show when={entry().type === "login"}>1384 <Show1385 when={totpState() || editingField() === "totp"}1386 fallback={1387 <button1388 class="peach-add-field-link peach-entry-add-link"1389 onClick={() => startEdit("totp", "")}1390 >1391 + 2FA1392 </button>1393 }1394 >1395 <section class="peach-totp-band">1396 <Show1397 when={editingField() === "totp"}1398 fallback={1399 <Show when={totpState()}>1400 {(state) => (1401 <>1402 <div1403 class="peach-totp-main"1404 onClick={() => {1405 1406 1407 if (totpClickTimer) return;1408 totpClickTimer = setTimeout(() => {1409 totpClickTimer = null;1410 void copyField(state().code.replace(" ", ""), "totp");1411 }, 220);1412 }}1413 onDblClick={() => {1414 if (totpClickTimer) { clearTimeout(totpClickTimer); totpClickTimer = null; }1415 startEdit("totp", entry().totp ?? "");1416 }}1417 title="Click to copy · double-click to edit"1418 >1419 <span class="peach-label">2-factor</span>1420 <div class="peach-totp-code-row">1421 <p class={`peach-totp-code${totpHot() ? " is-hot" : ""}${copied() === "totp" ? " is-copied" : ""}`}>1422 <span class="peach-totp-code-text">1423 {state().code.slice(0, 3)} {state().code.slice(3)}1424 </span>1425 </p>1426 </div>1427 </div>1428 <div class="peach-totp-meta">1429 <span class="peach-label">expires</span>1430 <div class="peach-totp-countdown">{state().remaining}s</div>1431 <svg class="peach-totp-ring" width="44" height="44" viewBox="0 0 44 44">1432 <circle cx="22" cy="22" r="17" class="peach-totp-ring-track" />1433 <circle cx="22" cy="22" r="17" class="peach-totp-ring-progress"1434 stroke-dasharray="106.8"1435 stroke-dashoffset={(1 - state().remaining / 30) * 106.8}1436 />1437 </svg>1438 </div>1439 </>1440 )}1441 </Show>1442 }1443 >1444 <div1445 class="peach-inline-field-wrap peach-inline-field-wrap--totp"1446 onFocusOut={(event) => handleEditorFocusOut("totp", event)}1447 >1448 <span class="peach-label">2-factor</span>1449 <input1450 class="peach-inline-input"1451 value={draft()}1452 onInput={(e) => setDraft(e.currentTarget.value)}1453 onKeyDown={onEditKeyDown}1454 ref={autoFocus}1455 disabled={saving()}1456 placeholder="otpauth://... or base32 secret"1457 autocomplete="off"1458 />1459 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1460 </div>1461 </Show>1462 </section>1463 </Show>1464 </Show>14651466 {}1467 <Show when={entry().type !== "note" && entry().type !== "card"}>1468 <button1469 class="peach-add-field-link peach-entry-add-link"1470 onClick={() => setShowAdvanced((v) => !v)}1471 aria-expanded={showAdvanced()}1472 >1473 {showAdvanced() ? "− Advanced" : "+ Advanced"}1474 </button>1475 <Show when={showAdvanced()}>1476 <Show when={!isPasskeyOnly(entry())}>1477 <CanarySection entry={entry()} onSaved={props.onFieldSaved} isPro={props.isPro ?? false} onProGate={props.onProGate} />1478 </Show>14791480 <Show when={entry().passkey}>1481 {(passkey) => {1482 const currentBrowser = detectBrowser();1483 const crossBrowser =1484 passkey().browser &&1485 currentBrowser !== "unknown" &&1486 passkey().browser !== currentBrowser;1487 const algorithmLabel =1488 passkey().algorithm === -8 ? "EdDSA (Ed25519)" : "ES256 (P-256)";1489 const formatDate = (ts?: number) =>1490 ts ? new Date(ts).toLocaleDateString() : "Never";1491 return (1492 <section1493 class="peach-fields peach-passkey-section"1494 style="position:relative;z-index:1;margin-top:6px;"1495 >1496 <div class="peach-field-card">1497 <span class="peach-label">passkey · {passkey().rpId}</span>1498 <div class="peach-field-value-row">1499 <span class="peach-field-value">{passkey().userName}</span>1500 <span class="peach-passkey-badge">passkey</span>1501 </div>1502 </div>15031504 <div class="peach-field-card">1505 <span class="peach-label">algorithm</span>1506 <div class="peach-field-value-row">1507 <span class="peach-field-value">{algorithmLabel}</span>1508 </div>1509 </div>15101511 <div class="peach-field-card">1512 <span class="peach-label">activity</span>1513 <div class="peach-field-value-row peach-passkey-activity">1514 <span class="peach-field-value">1515 used {passkey().signCount} time{passkey().signCount === 1 ? "" : "s"}1516 </span>1517 <span class="peach-passkey-meta">1518 created {formatDate(passkey().createdAt)}1519 </span>1520 <span class="peach-passkey-meta">1521 last used {formatDate(passkey().lastUsedAt)}1522 </span>1523 </div>1524 </div>15251526 <Show when={crossBrowser}>1527 <div class="peach-info-notice peach-info-notice--warn">1528 {`This passkey was created on ${1529 passkey().browser === "chrome" ? "Chrome" : "Firefox"1530 }. To use it on ${1531 currentBrowser === "chrome" ? "Chrome" : "Firefox"1532 }, re-register it on this device.`}1533 </div>1534 </Show>15351536 <div class="peach-info-notice">1537 {passkey().browser === "firefox"1538 ? "This passkey is held by your platform authenticator. Peach stores only the metadata."1539 : "The private key is stored encrypted in your Peach vault and is never shown in the UI."}1540 </div>15411542 <button1543 class="peach-add-field-link peach-entry-add-link"1544 style="color:rgba(220,38,38,0.7);"1545 onClick={async () => {1546 const id = entry().id;1547 await sendMessage({1548 type: "UPDATE_ENTRY",1549 payload: { id, patch: { passkey: undefined } },1550 });1551 await props.onFieldSaved();1552 }}1553 >1554 − remove passkey1555 </button>1556 </section>1557 );1558 }}1559 </Show>1560 </Show>1561 </Show>15621563 {}1564 <div style="height:4px;" />1565 </>1566 )}1567 </Show>1568 </div>15691570 </>1571 );1572}1573157415751576function InlineSaveCancelRow(props: { onSave: () => void; onCancel: () => void; saving: boolean }) {1577 return (1578 <div class="peach-inline-actions">1579 <button1580 class="peach-inline-save-btn"1581 onClick={props.onSave}1582 disabled={props.saving}1583 aria-label="Save"1584 title="Save (Enter)"1585 >1586 <svg width="11" height="9" viewBox="0 0 11 9" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">1587 <path d="M1 4.5L4 7.5L10 1.5" />1588 </svg>1589 </button>1590 <button1591 class="peach-inline-cancel-btn"1592 onClick={props.onCancel}1593 disabled={props.saving}1594 aria-label="Cancel"1595 title="Cancel (Esc)"1596 >1597 <svg width="9" height="9" viewBox="0 0 9 9" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round">1598 <path d="M1 1L8 8M8 1L1 8" />1599 </svg>1600 </button>1601 </div>1602 );1603}16041605function EmptyVaultState() {1606 return (1607 <>1608 <div class="peach-entry-name-wrap" style="position:relative;z-index:1;">1609 <div class="peach-entry-name">1610 <span class="peach-entry-name-text">1611 <span class="peach-entry-name-char" style="--char-index:0">e</span>1612 <span class="peach-entry-name-char" style="--char-index:1">m</span>1613 <span class="peach-entry-name-char" style="--char-index:2">p</span>1614 <span class="peach-entry-name-char" style="--char-index:3">t</span>1615 <span class="peach-entry-name-char" style="--char-index:4">y</span>1616 </span>1617 </div>1618 </div>1619 <div class="peach-empty-copy">1620 <span class="peach-label">vault</span>1621 <p>Your vault is ready for its first entry.</p>1622 </div>1623 </>1624 );1625}16261627function CopyGlyph() {1628 return (1629 <span class="peach-copy-icon">1630 <svg class="peach-copy-icon-svg" width="12" height="12" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">1631 <rect x="4" y="4" width="8" height="9" rx="1.5" />1632 <path d="M10 4V2.5A1.5 1.5 0 0 0 8.5 1h-6A1.5 1.5 0 0 0 1 2.5v7A1.5 1.5 0 0 0 2.5 11H4" />1633 </svg>1634 </span>1635 );1636}16371638function EyeClosedGlyph() {1639 return (1640 <svg width="14" height="10" viewBox="0 0 14 10" fill="none" stroke="currentColor" stroke-width="0.9" stroke-linecap="round">1641 <path d="M1 2C3 4.5 5 6 7 6C9 6 11 4.5 13 2" />1642 <path d="M3.5 5.5L2.5 7.5" />1643 <path d="M7 6.5V8.5" />1644 <path d="M10.5 5.5L11.5 7.5" />1645 </svg>1646 );1647}16481649function EyeOpenGlyph() {1650 return (1651 <svg width="14" height="10" viewBox="0 0 14 10" fill="none" stroke="currentColor" stroke-width="0.9" stroke-linecap="round">1652 <path d="M1 5C1 5 2.8 1 7 1C11.2 1 13 5 13 5C13 5 11.2 9 7 9C2.8 9 1 5 1 5Z" />1653 <circle cx="7" cy="5" r="1.75" />1654 </svg>1655 );1656}16571658function CanarySection(props: { entry: VaultEntry; onSaved: () => void | Promise<void>; isPro: boolean; onProGate?: (feature: ProFeature) => void }) {1659 const [enabled, setEnabled] = createSignal(Boolean(props.entry.canary));1660 const [webhookUrl, setWebhookUrl] = createSignal(props.entry.canary?.webhookUrl ?? "");1661 const [label, setLabel] = createSignal(props.entry.canary?.label ?? "");1662 const [testResult, setTestResult] = createSignal<string | null>(null);1663 const [testing, setTesting] = createSignal(false);16641665 1666 1667 1668 1669 1670 1671 const isProGated = () => !props.isPro && !props.entry.canary;16721673 async function save() {1674 const url = webhookUrl().trim();1675 const nextLabel = label().trim() || undefined;1676 const canary = enabled() && url1677 ? {1678 webhookUrl: url,1679 label: nextLabel,1680 lastPinged: props.entry.canary?.lastPinged,1681 pingCount: props.entry.canary?.pingCount,1682 }1683 : undefined;1684 await sendMessage({1685 type: "UPDATE_ENTRY",1686 payload: { id: props.entry.id, patch: { canary } },1687 });1688 await props.onSaved();1689 }16901691 async function testPing() {1692 const url = webhookUrl().trim();1693 if (!url) return;1694 setTesting(true);1695 setTestResult(null);1696 const res = await sendMessage({1697 type: "FIRE_CANARY_PING",1698 payload: { webhookUrl: url, entryTitle: props.entry.title, trigger: "test" },1699 }) as { ok: boolean; error?: string };1700 setTestResult(res.ok ? "sent ✓" : `failed — ${res.error ?? "check URL"}`);1701 setTesting(false);1702 }17031704 return (1705 <div class="peach-canary-section">1706 <div class="peach-field-value-row">1707 <span class="peach-field-value" style="font-size:12px;">1708 canary alert1709 <Show when={isProGated()}>1710 <span class="peach-pro-mark" aria-label="Pro feature" style="margin-left:6px">✦</span>1711 </Show>1712 </span>1713 <button1714 class={`peach-toggle ${enabled() ? "is-on" : ""}`}1715 onClick={() => {1716 if (isProGated()) {1717 1718 1719 1720 props.onProGate?.("canary_entry");1721 return;1722 }1723 setEnabled(!enabled());1724 void save();1725 }}1726 aria-label="Toggle canary"1727 aria-disabled={isProGated() ? "true" : "false"}1728 >1729 <span class="peach-toggle-knob" />1730 </button>1731 </div>1732 <p style="font-size:10px;color:var(--peach-t2);margin:4px 0 0;line-height:1.5;">1733 Fires a silent webhook when this entry's password or username is copied. Great for honeypot credentials.1734 </p>1735 <Show when={enabled()}>1736 <div class="peach-inline-field-wrap" style="margin-top:8px;">1737 <input1738 class="peach-inline-input"1739 placeholder="https://hooks.zapier.com/..."1740 value={webhookUrl()}1741 onInput={(e) => setWebhookUrl(e.currentTarget.value)}1742 onBlur={() => void save()}1743 />1744 <p style="font-size:10px;color:var(--peach-t2);margin:4px 0 0;line-height:1.5;">1745 When triggered, the entry title is sent to this URL. Use an endpoint you control.1746 </p>1747 <input1748 class="peach-inline-input"1749 placeholder="label (optional, e.g. AWS decoy)"1750 value={label()}1751 onInput={(e) => setLabel(e.currentTarget.value)}1752 onBlur={() => void save()}1753 />1754 <div style="display:flex;align-items:center;gap:8px;margin-top:4px;">1755 <button1756 class="peach-btn peach-btn--ghost peach-btn--sm"1757 onClick={() => void testPing()}1758 disabled={testing() || !webhookUrl().trim()}1759 >1760 {testing() ? "sending..." : "test ping"}1761 </button>1762 <Show when={testResult()}>1763 <span style="font-size:10px;color:var(--peach-t2);font-family:var(--font-mono);">{testResult()}</span>1764 </Show>1765 </div>1766 <Show when={props.entry.canary?.lastPinged}>1767 <p style="font-size:10px;color:var(--peach-t2);margin-top:4px;">1768 Last triggered: {new Date(props.entry.canary!.lastPinged!).toLocaleDateString()}1769 {" · "}{props.entry.canary?.pingCount ?? 0} total alerts1770 </p>1771 </Show>1772 </div>1773 </Show>1774 </div>1775 );1776}