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 }531532533 534 535 createEffect(() => {536 if (!props.entry) return;537 const handler = (e: KeyboardEvent) => {538 const inInput = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLSelectElement || (e.target as HTMLElement).isContentEditable;539 if (inInput || e.ctrlKey || e.metaKey || e.altKey) return;540 switch (e.key) {541 case "c": e.preventDefault();542 if (props.entry?.password) void copyField(props.entry.password, "password"); break;543 case "u": e.preventDefault();544 if (props.entry?.username) void copyField(props.entry.username, "username"); break;545 case "Escape": e.preventDefault(); props.onEscape?.(); break;546 }547 };548 window.addEventListener("keydown", handler);549 onCleanup(() => window.removeEventListener("keydown", handler));550 });551552 553554 function autoFocus(el: HTMLInputElement | HTMLTextAreaElement) {555 requestAnimationFrame(() => { el.focus(); el.select?.(); });556 }557558 function onEditKeyDown(e: KeyboardEvent) {559 if (e.key === "Enter" && !(e.target instanceof HTMLTextAreaElement)) {560 e.preventDefault();561 void saveField();562 }563 if (e.key === "Escape") { e.preventDefault(); cancelEdit(); }564 }565566 function identityKeyDown(e: KeyboardEvent, field: "username" | "email") {567 const listEl = field === "username" ? usernameIdentityEl : emailIdentityEl;568 if (e.key === "ArrowDown" && listEl) {569 e.preventDefault();570 listEl.querySelector<HTMLElement>(".peach-identity-suggestion")?.focus();571 return;572 }573 onEditKeyDown(e);574 }575576 return (577 <>578 <div579 class="peach-ghost"580 aria-hidden="true"581 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;"582 >583 {props.entry?.title || "empty"}584 </div>585586 <div class="peach-stage" style="position:relative;">587 <Show when={props.entry} fallback={<EmptyVaultState />}>588 {(entry) => (589 <>590 {}591 <Show when={entry().type !== "note" && entry().type !== "card" && (entry().breach ?? 0) > 0}>592 <div class="peach-breach-badge">593 <svg width="10" height="10" viewBox="0 0 12 12" fill="none" stroke="var(--breach)" stroke-width="1.5" stroke-linecap="round">594 <path d="M6 1L11 10H1L6 1z" />595 <line x1="6" y1="5" x2="6" y2="7.5" />596 <circle cx="6" cy="9" r="0.5" fill="var(--breach)" stroke="none" />597 </svg>598 <span style="flex:1">found in a known data breach</span>599 </div>600 </Show>601602 {}603 <div class="peach-entry-header">604 <div class="peach-entry-header-name">605 <Show606 when={editingField() === "title"}607 fallback={608 <button609 class="peach-entry-name-button"610 title="Click to edit title"611 onClick={() => startEdit("title", entry().title)}612 >613 <h1 class={`peach-entry-name ${titleSizeClass()}`} aria-label={entry().title}>614 <span class="peach-entry-name-text">615 <Show616 when={useAnimatedTitle()}617 fallback={entry().title}618 >619 <For each={entry().title.split("")}>620 {(ch, i) => (621 <span class="peach-entry-name-char" style={`--char-index:${i()}`}>622 {ch === " " ? "\u00A0" : ch}623 </span>624 )}625 </For>626 </Show>627 </span>628 </h1>629 </button>630 }631 >632 <div633 class="peach-inline-title-wrap"634 onFocusOut={(event) => handleEditorFocusOut("title", event)}635 >636 <input637 class="peach-inline-title-input"638 value={draft()}639 onInput={(e) => setDraft(e.currentTarget.value)}640 onKeyDown={onEditKeyDown}641 ref={autoFocus}642 disabled={saving()}643 />644 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />645 </div>646 </Show>647 </div>648649 {}650 <Show when={editingField() !== "title"}>651 <Show652 when={confirmDelete()}653 fallback={654 <button655 class="peach-entry-trash-btn"656 onClick={() => setConfirmDelete(true)}657 aria-label="Move to trash"658 title="Delete entry"659 >660 <svg width="12" height="13" viewBox="0 0 12 13" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">661 <path d="M1 3h10M4 3V2h4v1M2 3l.7 8.5a1 1 0 0 0 1 .9h4.6a1 1 0 0 0 1-.9L10 3" />662 <path d="M4.5 6l.3 3.5M7.5 6l-.3 3.5" />663 </svg>664 </button>665 }666 >667 <div class="peach-entry-trash-confirm">668 <span class="peach-entry-trash-confirm-label">trash?</span>669 <button670 class="peach-btn peach-btn--sm peach-btn--danger"671 style="font-size:10px;padding:2px 8px;min-height:22px;"672 onClick={() => { setConfirmDelete(false); props.onDelete(); }}673 >674 yes675 </button>676 <button677 class="peach-btn peach-btn--ghost peach-btn--sm"678 style="font-size:10px;padding:2px 8px;min-height:22px;"679 onClick={() => setConfirmDelete(false)}680 >681 no682 </button>683 </div>684 </Show>685 </Show>686 </div>687688 {}689 <Show when={entry().type !== "note" && entry().type !== "card"}>690 <div class="peach-domain" style="position:relative;z-index:1;">691 <Show692 when={editingField() === "url"}693 fallback={694 <div695 class="peach-domain-row peach-inline-clickable"696 title="Click to edit URL"697 onClick={() => startEdit("url", entry().url ?? "")}698 >699 <DomainFavicon domain={displayDomain()} title={entry().title ?? ""} />700 <span class="peach-domain-value">701 {displayDomain() || (entry().url ? entry().url : "add a website url")}702 </span>703 <span class="peach-inline-edit-hint">edit</span>704 </div>705 }706 >707 <div708 class="peach-inline-field-wrap peach-inline-field-wrap--url"709 onFocusOut={(event) => handleEditorFocusOut("url", event)}710 >711 <div class="peach-inline-field-row">712 <input713 class="peach-inline-input"714 type="url"715 placeholder="https://"716 value={draft()}717 onInput={(e) => setDraft(e.currentTarget.value)}718 onKeyDown={onEditKeyDown}719 ref={autoFocus}720 disabled={saving()}721 />722 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />723 </div>724 <Show725 when={726 detectHomograph(draft()) ||727 additionalUrlsDraft().some((u) => detectHomograph(u))728 }729 >730 {}731 <p class="peach-homograph-warning">732 ⚠ This URL contains non-ASCII or punycode characters.733 Verify it's the site you intend.734 </p>735 </Show>736 <div class="peach-additional-urls">737 <Show when={additionalUrlsDraft().length > 0}>738 <span class="peach-label peach-additional-urls-label">also matches</span>739 </Show>740 <For each={additionalUrlsDraft()}>741 {(value, i) => (742 <div class="peach-additional-url-row">743 <input744 class="peach-inline-input"745 type="url"746 placeholder="https://"747 value={value}748 onInput={(e) => setAdditionalUrlsDraft((arr) => {749 const next = [...arr];750 next[i()] = e.currentTarget.value;751 return next;752 })}753 disabled={saving()}754 />755 <button756 class="peach-additional-url-remove"757 type="button"758 aria-label="Remove URL"759 onMouseDown={(e) => e.preventDefault()}760 onClick={() => setAdditionalUrlsDraft((arr) => arr.filter((_, idx) => idx !== i()))}761 disabled={saving()}762 >×</button>763 </div>764 )}765 </For>766 <button767 class="peach-add-field-link peach-additional-urls-add"768 type="button"769 onMouseDown={(e) => e.preventDefault()}770 onClick={() => setAdditionalUrlsDraft((arr) => [...arr, ""])}771 disabled={saving()}772 >773 + add another url774 </button>775 <Show when={props.currentTabUrl && !urlMatchesAny(props.currentTabUrl!, draft(), additionalUrlsDraft())}>776 <button777 class="peach-add-field-link peach-additional-urls-add peach-additional-urls-add-current"778 type="button"779 title={props.currentTabUrl}780 onMouseDown={(e) => e.preventDefault()}781 onClick={() => addCurrentSite(props.currentTabUrl!)}782 disabled={saving()}783 >784 + add current site785 </button>786 </Show>787 </div>788 </div>789 </Show>790 </div>791 </Show>792793 {}794 <Show when={!editingTags() && entry().tags && entry().tags!.length > 0}>795 <div796 style="display:flex;flex-wrap:wrap;gap:5px;margin:2px 0;position:relative;z-index:1;cursor:pointer;"797 onClick={startEditTags}798 title="Click to edit tags"799 >800 <For each={entry().tags!}>801 {(tag) => <span class="peach-tag-chip" style="font-size:10px;padding:2px 8px;">{tag}</span>}802 </For>803 </div>804 </Show>805806 {}807 <Show when={entry().type === "note"}>808 <div class="peach-entry-note-toolbar-row">809 <Toolbar exec={noteExec} class="peach-note-toolbar-inline" />810 </div>811 <section class="peach-fields peach-note-body" style="position:relative;z-index:1;">812 <NoteEditorInline813 entryKey={entry().id}814 initialContent={entry().notes ?? ""}815 onReady={(el) => { setNoteEditorEl(el); lastSavedNote = null; }}816 onBlur={saveNoteInline}817 autoFocus={false}818 />819 </section>820 </Show>821822 {}823 <Show when={entry().type === "card"}>824 <section class="peach-fields" style="position:relative;z-index:1;">825 {}826 <Show when={entry().last4}>827 <div class="peach-field-card" style="padding-bottom:4px;">828 <span class="peach-label">829 <Show when={entry().network && entry().network !== "unknown"}>830 <span class="peach-card-network-badge" style="margin-left:0;margin-right:6px;">{entry().network}</span>831 </Show>832 {entry().cardNickname || `•••• ${entry().last4}`}833 </span>834 </div>835 </Show>836837 {}838 <div class="peach-field-card">839 <span class="peach-label">cardholder name</span>840 <div class="peach-field-value-row">841 <span class="peach-field-value">{entry().cardholderName || "—"}</span>842 <Show when={entry().cardholderName}>843 <button844 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "cardholderName" ? "is-copied" : ""}`}845 onClick={(e) => void copyField(entry().cardholderName!, "cardholderName", e.currentTarget as HTMLButtonElement)}846 aria-label="Copy cardholder name"847 >848 <CopyGlyph /><span class="peach-copy-sheen" />849 </button>850 </Show>851 </div>852 </div>853854 {}855 <div class="peach-field-card">856 <span class="peach-label">card number</span>857 <div class="peach-field-value-row">858 <span class={`peach-field-value peach-card-number`}>859 <Show when={showCardNumber()} fallback={860 <span>{`•••• •••• •••• ${entry().last4 ?? "••••"}`}</span>861 }>862 <span>{entry().cardNumber ?? ""}</span>863 </Show>864 </span>865 <div class="peach-field-actions">866 <button867 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"868 onClick={() => setShowCardNumber(!showCardNumber())}869 aria-label={showCardNumber() ? "Hide card number" : "Reveal card number"}870 >871 <Show when={showCardNumber()} fallback={<EyeOpenGlyph />}>872 <EyeClosedGlyph />873 </Show>874 </button>875 <Show when={entry().cardNumber}>876 <button877 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "cardNumber" ? "is-copied" : ""}`}878 onClick={(e) => {879 const cardNum = entry().cardNumber!;880 if (entry().canary?.webhookUrl) {881 void sendMessage({882 type: "FIRE_CANARY_PING",883 payload: { webhookUrl: entry().canary!.webhookUrl, entryTitle: entry().title, trigger: "password_copied" },884 });885 }886 void copyField(cardNum, "cardNumber", e.currentTarget as HTMLButtonElement);887 }}888 aria-label="Copy card number"889 >890 <CopyGlyph /><span class="peach-copy-sheen" />891 </button>892 </Show>893 </div>894 </div>895 </div>896897 {}898 <Show when={entry().expMonth || entry().expYear}>899 <div class="peach-field-card">900 <span class="peach-label">expiry</span>901 <div class="peach-field-value-row">902 <span class="peach-field-value">{entry().expMonth} / {entry().expYear}</span>903 <button904 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "expiry" ? "is-copied" : ""}`}905 onClick={(e) => void copyField(`${entry().expMonth}/${entry().expYear}`, "expiry", e.currentTarget as HTMLButtonElement)}906 aria-label="Copy expiry"907 >908 <CopyGlyph /><span class="peach-copy-sheen" />909 </button>910 </div>911 </div>912 </Show>913914 {}915 <Show when={entry().cvc}>916 <div class="peach-field-card">917 <span class="peach-label">CVC</span>918 <div class="peach-field-value-row">919 <span class="peach-field-value">920 <Show when={showCardCvc()} fallback={<span class="peach-password-mask">•••</span>}>921 <span>{entry().cvc}</span>922 </Show>923 </span>924 <div class="peach-field-actions">925 <button926 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"927 onClick={() => setShowCardCvc(!showCardCvc())}928 aria-label={showCardCvc() ? "Hide CVC" : "Show CVC"}929 >930 <Show when={showCardCvc()} fallback={<EyeOpenGlyph />}>931 <EyeClosedGlyph />932 </Show>933 </button>934 <button935 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "cvc" ? "is-copied" : ""}`}936 onClick={(e) => void copyField(entry().cvc!, "cvc", e.currentTarget as HTMLButtonElement)}937 aria-label="Copy CVC"938 >939 <CopyGlyph /><span class="peach-copy-sheen" />940 </button>941 </div>942 </div>943 </div>944 </Show>945 </section>946 </Show>947948 {}949 <Show when={entry().type !== "note" && entry().type !== "card" && !isPasskeyOnly(entry())}>950 <section class="peach-fields" style="position:relative;z-index:1;">951952 {953954}955 <Show when={entry().username || (!entry().username && !entry().email) || editingField() === "username"}>956 <div class="peach-field-card" classList={{ "is-editing": editingField() === "username" }}>957 <span class="peach-label">{entry().username?.includes("@") && !entry().email ? "email" : "username"}</span>958 <Show959 when={editingField() === "username"}960 fallback={961 <div class="peach-field-value-row">962 <span963 class="peach-field-value peach-inline-clickable"964 title="Click to edit"965 onClick={() => startEdit("username", entry().username ?? "")}966 >967 {entry().username || <span style="color:var(--t2);font-style:italic;">click to add username</span>}968 </span>969 <Show when={entry().username}>970 <button971 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "username" ? "is-copied" : ""}`}972 onClick={(e) => void copyField(entry().username!, "username", e.currentTarget as HTMLButtonElement)}973 aria-label="Copy username"974 >975 <CopyGlyph /><span class="peach-copy-sheen" />976 </button>977 </Show>978 </div>979 }980 >981 <div982 class="peach-inline-field-wrap"983 onFocusOut={(event) => handleEditorFocusOut("username", event)}984 >985 <input986 class="peach-inline-input"987 value={draft()}988 onInput={(e) => setDraft(e.currentTarget.value)}989 onKeyDown={(e) => identityKeyDown(e, "username")}990 ref={(el) => { usernameInlineInput = el; autoFocus(el); }}991 disabled={saving()}992 autocomplete="off"993 />994 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />995 <Show when={!identityHelperSuppressed() && identitySuggestions().length > 0 && editingField() === "username"}>996 <IdentitySuggestList997 listRef={(el) => (usernameIdentityEl = el)}998 inputRef={() => usernameInlineInput}999 suggestions={identitySuggestions()}1000 onPick={(v) => { setDraft(v); setIdentityHelperSuppressed(true); usernameInlineInput?.focus(); }}1001 onClose={() => { setIdentityHelperSuppressed(true); usernameInlineInput?.focus(); }}1002 />1003 </Show>1004 {100510061007}1008 <Show when={!entry().email || !(entry().username && !entry().username?.includes("@"))}>1009 <button1010 class="peach-add-field-btn"1011 type="button"1012 onMouseDown={(e) => e.preventDefault()}1013 onClick={() => {1014 const isEmailShape = draft().includes("@") || (entry().username?.includes("@") ?? false);1015 const hasSeparateEmail = !!entry().email;1016 if (isEmailShape && !hasSeparateEmail) {1017 void addOtherIdentity("username");1018 } else {1019 void addOtherIdentity("email");1020 }1021 }}1022 >1023 {(() => {1024 const isEmailShape = draft().includes("@") || (entry().username?.includes("@") ?? false);1025 const hasSeparateEmail = !!entry().email;1026 return (isEmailShape && !hasSeparateEmail) || hasSeparateEmail ? "+ add username" : "+ add email";1027 })()}1028 </button>1029 </Show>1030 </div>1031 </Show>1032 </div>1033 </Show>10341035 {1036}1037 <Show when={entry().email || editingField() === "email"}>1038 <div class="peach-field-card" classList={{ "is-editing": editingField() === "email" }}>1039 <span class="peach-label">email</span>1040 <Show1041 when={editingField() === "email"}1042 fallback={1043 <div class="peach-field-value-row">1044 <span1045 class="peach-field-value peach-inline-clickable"1046 title="Click to edit"1047 onClick={() => startEdit("email", entry().email ?? "")}1048 >1049 {entry().email}1050 </span>1051 <Show when={entry().email}>1052 <button1053 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "email" ? "is-copied" : ""}`}1054 onClick={(e) => void copyField(entry().email!, "email", e.currentTarget as HTMLButtonElement)}1055 aria-label="Copy email"1056 >1057 <CopyGlyph /><span class="peach-copy-sheen" />1058 </button>1059 </Show>1060 </div>1061 }1062 >1063 <div1064 class="peach-inline-field-wrap"1065 onFocusOut={(event) => handleEditorFocusOut("email", event)}1066 >1067 <input1068 class="peach-inline-input"1069 value={draft()}1070 onInput={(e) => setDraft(e.currentTarget.value)}1071 onKeyDown={(e) => identityKeyDown(e, "email")}1072 ref={(el) => { emailInlineInput = el; autoFocus(el); }}1073 disabled={saving()}1074 autocomplete="email"1075 type="email"1076 />1077 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1078 <Show when={!identityHelperSuppressed() && identitySuggestions().length > 0 && editingField() === "email"}>1079 <IdentitySuggestList1080 listRef={(el) => (emailIdentityEl = el)}1081 inputRef={() => emailInlineInput}1082 suggestions={identitySuggestions()}1083 onPick={(v) => { setDraft(v); setIdentityHelperSuppressed(true); emailInlineInput?.focus(); }}1084 onClose={() => { setIdentityHelperSuppressed(true); emailInlineInput?.focus(); }}1085 />1086 </Show>1087 <Show when={!entry().username || entry().username?.includes("@")}>1088 <button1089 class="peach-add-field-btn"1090 type="button"1091 onMouseDown={(e) => e.preventDefault()}1092 onClick={() => void addOtherIdentity("username")}1093 >1094 + add username1095 </button>1096 </Show>1097 </div>1098 </Show>1099 </div>1100 </Show>11011102 {}1103 <div class="peach-field-card" classList={{ "is-editing": editingField() === "password" }}>1104 <span class="peach-label">password</span>1105 <Show1106 when={editingField() === "password"}1107 fallback={1108 <div class="peach-field-value-row">1109 <span1110 class="peach-password-value"1111 classList={{ "is-revealed": showPassword(), "is-breached": (entry().breach ?? 0) > 0 }}1112 style="cursor:pointer;"1113 title="Click to edit password"1114 onClick={() => startEdit("password", entry().password ?? "")}1115 >1116 <Show1117 when={showPassword()}1118 fallback={<span class="peach-password-mask" aria-label="password hidden">••••••••••••••</span>}1119 >1120 <span class="peach-password-text">{entry().password ?? ""}</span>1121 </Show>1122 </span>1123 <div class="peach-field-actions">1124 <button1125 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1126 onClick={() => setShowPassword(!showPassword())}1127 aria-label="Reveal password"1128 >1129 <Show when={showPassword()} fallback={<EyeOpenGlyph />}>1130 <EyeClosedGlyph />1131 </Show>1132 </button>1133 <button1134 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === "password" ? "is-copied" : ""}`}1135 onClick={(e) => { if (entry().password) void copyField(entry().password!, "password", e.currentTarget as HTMLButtonElement); }}1136 aria-label="Copy password"1137 >1138 <CopyGlyph /><span class="peach-copy-sheen" />1139 </button>1140 </div>1141 </div>1142 }1143 >1144 {}1145 <div1146 class="peach-inline-field-wrap"1147 onFocusOut={(event) => handleEditorFocusOut("password", event)}1148 >1149 <div class="peach-password-edit-row">1150 <input1151 class="peach-inline-input"1152 type={showPassword() ? "text" : "password"}1153 placeholder="paste or type a password"1154 value={draft()}1155 onInput={(e) => setDraft(e.currentTarget.value)}1156 onKeyDown={(e) => {1157 if (e.key === "Enter") { e.preventDefault(); void saveField(); }1158 if (e.key === "Escape") { e.preventDefault(); cancelEdit(); }1159 }}1160 ref={autoFocus}1161 disabled={saving()}1162 autocomplete="new-password"1163 />1164 <button1165 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1166 type="button"1167 onClick={() => setShowPassword(!showPassword())}1168 aria-label={showPassword() ? "Hide" : "Show"}1169 >1170 <Show when={showPassword()} fallback={<EyeOpenGlyph />}>1171 <EyeClosedGlyph />1172 </Show>1173 </button>1174 </div>1175 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1176 <div class="peach-password-edit-links">1177 <button1178 class="peach-generate-toggle-link"1179 type="button"1180 onClick={() => { setShowGenerator(!showGenerator()); if (!showGenerator()) setShowHistory(false); }}1181 >1182 <svg width="10" height="10" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">1183 <path d="M11 2.5A5.5 5.5 0 1 0 12.5 7" />1184 <path d="M9.5 2.5H11V1" />1185 </svg>1186 {showGenerator() ? "hide generator" : "generate"}1187 </button>1188 <button1189 class="peach-generate-toggle-link"1190 type="button"1191 onClick={() => { setShowHistory(!showHistory()); if (!showHistory()) setShowGenerator(false); }}1192 >1193 <svg width="10" height="10" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">1194 <path d="M6.5 1a5.5 5.5 0 1 0 5.5 5.5" />1195 <path d="M6.5 3.5V6.5L8.5 8" />1196 <path d="M1 1.5V4H3.5" />1197 </svg>1198 {showHistory()1199 ? "hide history"1200 : (entry().passwordHistory?.length ? `history (${entry().passwordHistory!.length})` : "history")}1201 </button>1202 </div>1203 <Show when={showGenerator()}>1204 <GeneratorDrawer1205 open={true}1206 compact={true}1207 onUse={(pw) => { setDraft(pw); setShowGenerator(false); }}1208 />1209 </Show>1210 <Show when={showHistory()}>1211 <div class="peach-password-history">1212 <Show when={(entry().passwordHistory?.length ?? 0) === 0}>1213 <div class="peach-history-empty">1214 No earlier passwords yet. When you change this password, the old one is saved here so you can copy or restore it.1215 </div>1216 </Show>1217 <For each={entry().passwordHistory ?? []}>1218 {(item, i) => (1219 <div class="peach-history-row">1220 <div class="peach-history-main">1221 <span class="peach-history-pw" classList={{ "is-revealed": revealedHistory().has(i()) }}>1222 <Show1223 when={revealedHistory().has(i())}1224 fallback={<span class="peach-password-mask">••••••••••••</span>}1225 >1226 {item.password}1227 </Show>1228 </span>1229 <span class="peach-history-age">{timeSince(item.changedAt)}</span>1230 </div>1231 <div class="peach-history-actions">1232 <button1233 class="peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn"1234 type="button"1235 title={revealedHistory().has(i()) ? "Hide" : "Reveal"}1236 onClick={() => setRevealedHistory((prev) => {1237 const next = new Set(prev);1238 if (next.has(i())) next.delete(i()); else next.add(i());1239 return next;1240 })}1241 >1242 <Show when={revealedHistory().has(i())} fallback={<EyeOpenGlyph />}>1243 <EyeClosedGlyph />1244 </Show>1245 </button>1246 <button1247 class={`peach-btn peach-btn--ghost peach-btn--sm peach-icon-btn peach-copy-btn ${copied() === `history-${i()}` ? "is-copied" : ""}`}1248 type="button"1249 title="Copy"1250 onClick={(e) => void copyField(item.password, `history-${i()}`, e.currentTarget as HTMLButtonElement)}1251 >1252 <CopyGlyph /><span class="peach-copy-sheen" />1253 </button>1254 <button1255 class="peach-btn peach-btn--ghost peach-btn--sm peach-history-use"1256 type="button"1257 title="Use this password again"1258 onClick={() => { setDraft(item.password); setShowPassword(true); setShowHistory(false); }}1259 >1260 use1261 </button>1262 </div>1263 </div>1264 )}1265 </For>1266 </div>1267 </Show>1268 </div>1269 </Show>1270 </div>12711272 </section>1273 </Show>12741275 {}1276 <Show when={entry().type !== "note" && entry().type !== "card"}>1277 <Show1278 when={entry().notes || editingField() === "notes"}1279 fallback={1280 <button1281 class="peach-add-field-link peach-entry-add-link"1282 onClick={() => startEdit("notes", "")}1283 >1284 + notes1285 </button>1286 }1287 >1288 <div style="position:relative;z-index:1;margin-top:6px;">1289 <span class="peach-label" style="display:block;margin-bottom:4px;">notes</span>1290 <Show1291 when={editingField() === "notes"}1292 fallback={1293 <div1294 class="peach-note-content peach-inline-clickable"1295 style="cursor:text;white-space:pre-wrap;"1296 onClick={() => startEdit("notes", entry().notes ?? "")}1297 >1298 {entry().notes}1299 </div>1300 }1301 >1302 <div1303 class="peach-inline-field-wrap"1304 onFocusOut={(event) => handleEditorFocusOut("notes", event)}1305 >1306 <textarea1307 class="peach-inline-textarea"1308 value={draft()}1309 onInput={(e) => setDraft(e.currentTarget.value)}1310 onKeyDown={(e) => { if (e.key === "Escape") { e.preventDefault(); cancelEdit(); } }}1311 ref={(el) => requestAnimationFrame(() => el?.focus())}1312 rows={4}1313 disabled={saving()}1314 />1315 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1316 </div>1317 </Show>1318 </div>1319 </Show>1320 </Show>13211322 {}1323 <Show1324 when={editingTags()}1325 fallback={1326 <Show when={!entry().tags || entry().tags!.length === 0}>1327 <button1328 class="peach-add-field-link peach-entry-add-link"1329 onClick={startEditTags}1330 >1331 + tags1332 </button>1333 </Show>1334 }1335 >1336 <div1337 class="peach-inline-tag-editor"1338 onFocusOut={(e) => {1339 const next = e.relatedTarget;1340 if (next instanceof Node && e.currentTarget.contains(next)) return;1341 void saveTags();1342 }}1343 >1344 <span class="peach-label">tags</span>1345 <div class="peach-tag-input-wrap">1346 <For each={tagsDraft()}>1347 {(tag) => (1348 <span class="peach-tag-chip">1349 {tag}1350 <button1351 class="peach-tag-chip-remove"1352 onMouseDown={(e) => e.preventDefault()}1353 onClick={() => setTagsDraft(tagsDraft().filter(t => t !== tag))}1354 aria-label={`Remove ${tag}`}1355 >×</button>1356 </span>1357 )}1358 </For>1359 <input1360 class="peach-tag-input"1361 placeholder={tagsDraft().length === 0 ? "type and press Enter…" : ""}1362 value={tagInput()}1363 onInput={(e) => setTagInput(e.currentTarget.value)}1364 onKeyDown={(e) => {1365 if (e.key === "Enter" || e.key === ",") {1366 e.preventDefault();1367 addTag(tagInput());1368 } else if (e.key === "Backspace" && !tagInput() && tagsDraft().length > 0) {1369 setTagsDraft(tagsDraft().slice(0, -1));1370 } else if (e.key === "Escape") {1371 e.preventDefault();1372 setEditingTags(false);1373 setTagInput("");1374 }1375 }}1376 ref={(el) => requestAnimationFrame(() => el?.focus())}1377 style="flex:1;min-width:80px;background:transparent;border:none;outline:none;color:var(--t1);font-size:12px;padding:2px;"1378 />1379 </div>1380 </div>1381 </Show>13821383 {}1384 <Show when={entry().type === "login"}>1385 <Show1386 when={totpState() || editingField() === "totp"}1387 fallback={1388 <button1389 class="peach-add-field-link peach-entry-add-link"1390 onClick={() => startEdit("totp", "")}1391 >1392 + 2FA1393 </button>1394 }1395 >1396 <section class="peach-totp-band">1397 <Show1398 when={editingField() === "totp"}1399 fallback={1400 <Show when={totpState()}>1401 {(state) => (1402 <>1403 <div1404 class="peach-totp-main"1405 onClick={() => {1406 1407 1408 if (totpClickTimer) return;1409 totpClickTimer = setTimeout(() => {1410 totpClickTimer = null;1411 void copyField(state().code.replace(" ", ""), "totp");1412 }, 220);1413 }}1414 onDblClick={() => {1415 if (totpClickTimer) { clearTimeout(totpClickTimer); totpClickTimer = null; }1416 startEdit("totp", entry().totp ?? "");1417 }}1418 title="Click to copy · double-click to edit"1419 >1420 <span class="peach-label">2-factor</span>1421 <div class="peach-totp-code-row">1422 <p class={`peach-totp-code${totpHot() ? " is-hot" : ""}${copied() === "totp" ? " is-copied" : ""}`}>1423 <span class="peach-totp-code-text">1424 {state().code.slice(0, 3)} {state().code.slice(3)}1425 </span>1426 </p>1427 </div>1428 </div>1429 <div class="peach-totp-meta">1430 <span class="peach-label">expires</span>1431 <div class="peach-totp-countdown">{state().remaining}s</div>1432 <svg class="peach-totp-ring" width="44" height="44" viewBox="0 0 44 44">1433 <circle cx="22" cy="22" r="17" class="peach-totp-ring-track" />1434 <circle cx="22" cy="22" r="17" class="peach-totp-ring-progress"1435 stroke-dasharray="106.8"1436 stroke-dashoffset={(1 - state().remaining / 30) * 106.8}1437 />1438 </svg>1439 </div>1440 </>1441 )}1442 </Show>1443 }1444 >1445 <div1446 class="peach-inline-field-wrap peach-inline-field-wrap--totp"1447 onFocusOut={(event) => handleEditorFocusOut("totp", event)}1448 >1449 <span class="peach-label">2-factor</span>1450 <input1451 class="peach-inline-input"1452 value={draft()}1453 onInput={(e) => setDraft(e.currentTarget.value)}1454 onKeyDown={onEditKeyDown}1455 ref={autoFocus}1456 disabled={saving()}1457 placeholder="otpauth://... or base32 secret"1458 autocomplete="off"1459 />1460 <InlineSaveCancelRow onSave={saveField} onCancel={cancelEdit} saving={saving()} />1461 </div>1462 </Show>1463 </section>1464 </Show>1465 </Show>14661467 {}1468 <Show when={entry().type !== "note" && entry().type !== "card"}>1469 <button1470 class="peach-add-field-link peach-entry-add-link"1471 onClick={() => setShowAdvanced((v) => !v)}1472 aria-expanded={showAdvanced()}1473 >1474 {showAdvanced() ? "− Advanced" : "+ Advanced"}1475 </button>1476 <Show when={showAdvanced()}>1477 <Show when={!isPasskeyOnly(entry())}>1478 <CanarySection entry={entry()} onSaved={props.onFieldSaved} isPro={props.isPro ?? false} onProGate={props.onProGate} />1479 </Show>14801481 <Show when={entry().passkey}>1482 {(passkey) => {1483 const currentBrowser = detectBrowser();1484 const crossBrowser =1485 passkey().browser &&1486 currentBrowser !== "unknown" &&1487 passkey().browser !== currentBrowser;1488 const algorithmLabel =1489 passkey().algorithm === -8 ? "EdDSA (Ed25519)" : "ES256 (P-256)";1490 const formatDate = (ts?: number) =>1491 ts ? new Date(ts).toLocaleDateString() : "Never";1492 return (1493 <section1494 class="peach-fields peach-passkey-section"1495 style="position:relative;z-index:1;margin-top:6px;"1496 >1497 <div class="peach-field-card">1498 <span class="peach-label">passkey · {passkey().rpId}</span>1499 <div class="peach-field-value-row">1500 <span class="peach-field-value">{passkey().userName}</span>1501 <span class="peach-passkey-badge">passkey</span>1502 </div>1503 </div>15041505 <div class="peach-field-card">1506 <span class="peach-label">algorithm</span>1507 <div class="peach-field-value-row">1508 <span class="peach-field-value">{algorithmLabel}</span>1509 </div>1510 </div>15111512 <div class="peach-field-card">1513 <span class="peach-label">activity</span>1514 <div class="peach-field-value-row peach-passkey-activity">1515 <span class="peach-field-value">1516 used {passkey().signCount} time{passkey().signCount === 1 ? "" : "s"}1517 </span>1518 <span class="peach-passkey-meta">1519 created {formatDate(passkey().createdAt)}1520 </span>1521 <span class="peach-passkey-meta">1522 last used {formatDate(passkey().lastUsedAt)}1523 </span>1524 </div>1525 </div>15261527 <Show when={crossBrowser}>1528 <div class="peach-info-notice peach-info-notice--warn">1529 {`This passkey was created on ${1530 passkey().browser === "chrome" ? "Chrome" : "Firefox"1531 }. To use it on ${1532 currentBrowser === "chrome" ? "Chrome" : "Firefox"1533 }, re-register it on this device.`}1534 </div>1535 </Show>15361537 <div class="peach-info-notice">1538 {passkey().browser === "firefox"1539 ? "This passkey is held by your platform authenticator. Peach stores only the metadata."1540 : "The private key is stored encrypted in your Peach vault and is never shown in the UI."}1541 </div>15421543 <button1544 class="peach-add-field-link peach-entry-add-link"1545 style="color:rgba(220,38,38,0.7);"1546 onClick={async () => {1547 const id = entry().id;1548 await sendMessage({1549 type: "UPDATE_ENTRY",1550 payload: { id, patch: { passkey: undefined } },1551 });1552 await props.onFieldSaved();1553 }}1554 >1555 − remove passkey1556 </button>1557 </section>1558 );1559 }}1560 </Show>1561 </Show>1562 </Show>15631564 {}1565 <div style="height:4px;" />1566 </>1567 )}1568 </Show>1569 </div>15701571 </>1572 );1573}1574157515761577function InlineSaveCancelRow(props: { onSave: () => void; onCancel: () => void; saving: boolean }) {1578 return (1579 <div class="peach-inline-actions">1580 <button1581 class="peach-inline-save-btn"1582 onClick={props.onSave}1583 disabled={props.saving}1584 aria-label="Save"1585 title="Save (Enter)"1586 >1587 <svg width="11" height="9" viewBox="0 0 11 9" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">1588 <path d="M1 4.5L4 7.5L10 1.5" />1589 </svg>1590 </button>1591 <button1592 class="peach-inline-cancel-btn"1593 onClick={props.onCancel}1594 disabled={props.saving}1595 aria-label="Cancel"1596 title="Cancel (Esc)"1597 >1598 <svg width="9" height="9" viewBox="0 0 9 9" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round">1599 <path d="M1 1L8 8M8 1L1 8" />1600 </svg>1601 </button>1602 </div>1603 );1604}16051606function EmptyVaultState() {1607 return (1608 <>1609 <div class="peach-entry-name-wrap" style="position:relative;z-index:1;">1610 <div class="peach-entry-name">1611 <span class="peach-entry-name-text">1612 <span class="peach-entry-name-char" style="--char-index:0">e</span>1613 <span class="peach-entry-name-char" style="--char-index:1">m</span>1614 <span class="peach-entry-name-char" style="--char-index:2">p</span>1615 <span class="peach-entry-name-char" style="--char-index:3">t</span>1616 <span class="peach-entry-name-char" style="--char-index:4">y</span>1617 </span>1618 </div>1619 </div>1620 <div class="peach-empty-copy">1621 <span class="peach-label">vault</span>1622 <p>Your vault is ready for its first entry.</p>1623 </div>1624 </>1625 );1626}16271628function CopyGlyph() {1629 return (1630 <span class="peach-copy-icon">1631 <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">1632 <rect x="4" y="4" width="8" height="9" rx="1.5" />1633 <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" />1634 </svg>1635 </span>1636 );1637}16381639function EyeClosedGlyph() {1640 return (1641 <svg width="14" height="10" viewBox="0 0 14 10" fill="none" stroke="currentColor" stroke-width="0.9" stroke-linecap="round">1642 <path d="M1 2C3 4.5 5 6 7 6C9 6 11 4.5 13 2" />1643 <path d="M3.5 5.5L2.5 7.5" />1644 <path d="M7 6.5V8.5" />1645 <path d="M10.5 5.5L11.5 7.5" />1646 </svg>1647 );1648}16491650function EyeOpenGlyph() {1651 return (1652 <svg width="14" height="10" viewBox="0 0 14 10" fill="none" stroke="currentColor" stroke-width="0.9" stroke-linecap="round">1653 <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" />1654 <circle cx="7" cy="5" r="1.75" />1655 </svg>1656 );1657}16581659function CanarySection(props: { entry: VaultEntry; onSaved: () => void | Promise<void>; isPro: boolean; onProGate?: (feature: ProFeature) => void }) {1660 const [enabled, setEnabled] = createSignal(Boolean(props.entry.canary));1661 const [webhookUrl, setWebhookUrl] = createSignal(props.entry.canary?.webhookUrl ?? "");1662 const [label, setLabel] = createSignal(props.entry.canary?.label ?? "");1663 const [testResult, setTestResult] = createSignal<string | null>(null);1664 const [testing, setTesting] = createSignal(false);16651666 1667 1668 1669 1670 1671 1672 const isProGated = () => !props.isPro && !props.entry.canary;16731674 async function save() {1675 const url = webhookUrl().trim();1676 const nextLabel = label().trim() || undefined;1677 const canary = enabled() && url1678 ? {1679 webhookUrl: url,1680 label: nextLabel,1681 lastPinged: props.entry.canary?.lastPinged,1682 pingCount: props.entry.canary?.pingCount,1683 }1684 : undefined;1685 await sendMessage({1686 type: "UPDATE_ENTRY",1687 payload: { id: props.entry.id, patch: { canary } },1688 });1689 await props.onSaved();1690 }16911692 async function testPing() {1693 const url = webhookUrl().trim();1694 if (!url) return;1695 setTesting(true);1696 setTestResult(null);1697 const res = await sendMessage({1698 type: "FIRE_CANARY_PING",1699 payload: { webhookUrl: url, entryTitle: props.entry.title, trigger: "test" },1700 }) as { ok: boolean; error?: string };1701 setTestResult(res.ok ? "sent ✓" : `failed — ${res.error ?? "check URL"}`);1702 setTesting(false);1703 }17041705 return (1706 <div class="peach-canary-section">1707 <div class="peach-field-value-row">1708 <span class="peach-field-value" style="font-size:12px;">1709 canary alert1710 <Show when={isProGated()}>1711 <span class="peach-pro-mark" aria-label="Pro feature" style="margin-left:6px">✦</span>1712 </Show>1713 </span>1714 <button1715 class={`peach-toggle ${enabled() ? "is-on" : ""}`}1716 onClick={() => {1717 if (isProGated()) {1718 1719 1720 1721 props.onProGate?.("canary_entry");1722 return;1723 }1724 setEnabled(!enabled());1725 void save();1726 }}1727 aria-label="Toggle canary"1728 aria-disabled={isProGated() ? "true" : "false"}1729 >1730 <span class="peach-toggle-knob" />1731 </button>1732 </div>1733 <p style="font-size:10px;color:var(--peach-t2);margin:4px 0 0;line-height:1.5;">1734 Fires a silent webhook when this entry's password or username is copied. Great for honeypot credentials.1735 </p>1736 <Show when={enabled()}>1737 <div class="peach-inline-field-wrap" style="margin-top:8px;">1738 <input1739 class="peach-inline-input"1740 placeholder="https://hooks.zapier.com/..."1741 value={webhookUrl()}1742 onInput={(e) => setWebhookUrl(e.currentTarget.value)}1743 onBlur={() => void save()}1744 />1745 <p style="font-size:10px;color:var(--peach-t2);margin:4px 0 0;line-height:1.5;">1746 When triggered, the entry title is sent to this URL. Use an endpoint you control.1747 </p>1748 <input1749 class="peach-inline-input"1750 placeholder="label (optional, e.g. AWS decoy)"1751 value={label()}1752 onInput={(e) => setLabel(e.currentTarget.value)}1753 onBlur={() => void save()}1754 />1755 <div style="display:flex;align-items:center;gap:8px;margin-top:4px;">1756 <button1757 class="peach-btn peach-btn--ghost peach-btn--sm"1758 onClick={() => void testPing()}1759 disabled={testing() || !webhookUrl().trim()}1760 >1761 {testing() ? "sending..." : "test ping"}1762 </button>1763 <Show when={testResult()}>1764 <span style="font-size:10px;color:var(--peach-t2);font-family:var(--font-mono);">{testResult()}</span>1765 </Show>1766 </div>1767 <Show when={props.entry.canary?.lastPinged}>1768 <p style="font-size:10px;color:var(--peach-t2);margin-top:4px;">1769 Last triggered: {new Date(props.entry.canary!.lastPinged!).toLocaleDateString()}1770 {" · "}{props.entry.canary?.pingCount ?? 0} total alerts1771 </p>1772 </Show>1773 </div>1774 </Show>1775 </div>1776 );1777}