123456789101112import { ACCENT_COLORS, type PasswordPolicy, type SavedIdentity } from "../shared/types";13import { generatePassword } from "../shared/generate";14import { detectPasswordPolicy } from "./policy";1516let accentHex = "#E8956D";17let popupTheme: "dark" | "light" = "dark";18chrome.runtime.sendMessage({ type: "GET_SETTINGS" }, (resp: { ok: boolean; data?: { accentColor?: string; theme?: string } } | undefined) => {19 const data = resp?.data;20 const name = data?.accentColor ?? "peach";21 accentHex = ACCENT_COLORS.find(c => c.name === name)?.hex ?? "#E8956D";22 popupTheme = data?.theme === "light" ? "light" : "dark";23});2425262728function withAlpha(hex: string, alpha: string): string {29 30 31 32 return /^#[0-9a-f]{6}$/i.test(hex) ? hex + alpha : hex;33}3435export interface SelectorEntry {36 id: string;37 title: string;38 username?: string;39 email?: string;40 url?: string;41 hasTotp?: boolean;42 43 hasPasskey?: boolean;44}4546interface SelectorOptions {47 domain?: string;48 searchableEntries?: SelectorEntry[];49 50 isSignup?: boolean;51 52535455 savedIdentities?: SavedIdentity[];56 5758596061 onFillFields?: (username: string, password: string) => void;62 6364656667 locked?: boolean;68 69707172 onUnlocked?: () => void;73 7475767778 onDismiss?: () => void;79}8081function getDomainFromUrl(url: string): string {82 try { return new URL(url).hostname.replace(/^www\./, ""); } catch { return ""; }83}8485function keySvgStr(): string {86 return `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="13" viewBox="0 0 12 13" fill="none" stroke="rgba(240,232,216,0.35)" stroke-width="0.95" stroke-linecap="round"><rect x="2" y="5.5" width="8" height="6" rx="1.5"/><path d="M4 5.5V4.25A2 2 0 0 1 6 2.25A2 2 0 0 1 8 4.25V5.5"/></svg>`;87}8889function plusSvgStr(): string {90 return `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><path d="M6 1.5v9M1.5 6h9"/></svg>`;91}9293function searchSvgStr(): string {94 return `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><circle cx="5.25" cy="5.25" r="3.5"/><path d="M7.9 7.9l2.35 2.35"/></svg>`;95}9697function backSvgStr(): string {98 return `<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 2.5L3.5 6l4 3.5"/></svg>`;99}100101function peachIconSvg(): string {102 103 104 105 return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 240 240" fill="none" aria-hidden="true"><path d="M 124 64 C 134 32 168 16 200 22 C 198 56 168 72 130 66 Z" fill="#92AC65"/><path d="M 130 64 C 152 46 178 30 196 24" stroke="#5E7A42" stroke-width="2.6" fill="none" stroke-linecap="round"/><path d="M 120 60 C 75 45 28 75 22 130 C 18 185 65 222 125 222 C 185 222 222 185 220 130 C 218 78 170 45 120 60 Z" fill="#FFB082"/><path d="M 120 60 C 75 45 28 75 22 130 C 18 185 65 222 125 222 C 105 195 75 150 100 90 C 105 75 112 65 120 60 Z" fill="#E5805C"/><ellipse cx="178" cy="108" rx="20" ry="11" fill="#FFD0A8" opacity="0.7" transform="rotate(-26 178 108)"/></svg>`;106}107108function checkSvgStr(): string {109 return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="#5E7A42" stroke-width="1.5" stroke-linecap="round"><path d="M4 10.5L8 14.5L16 6.5"/></svg>`;110}111112function smartUrl(): { origin: string; title: string; loginSubdomain: boolean } {113 const { hostname, origin } = location;114 const parts = hostname.split(".");115 const AUTH_PREFIXES = ["accounts", "auth", "login", "signin", "sign-in", "sso",116 "id", "identity", "secure", "portal", "my", "am", "idp", "connect", "oauth",117 "oidc", "federation", "saml", "cas", "ldap"];118 const loginSubdomain = parts.length > 2 && AUTH_PREFIXES.includes(parts[0]!.toLowerCase());119 const rootName = parts.length >= 2 ? parts[parts.length - 2]! : parts[0]!;120 const title = rootName.charAt(0).toUpperCase() + rootName.slice(1);121 return { origin, title, loginSubdomain };122}123124125126127128129export function showRememberSiteToast(130 pageDomain: string,131 entryId: string,132): void {133 const host = document.createElement("div");134 host.style.cssText = "position:fixed;bottom:22px;left:50%;transform:translateX(-50%);z-index:2147483647;pointer-events:auto;";135 host.style.setProperty("--peach-accent", accentHex);136 const shadow = host.attachShadow({ mode: "closed" });137138 const style = document.createElement("style");139 style.textContent = `140 .bar {141 display:flex;align-items:center;gap:10px;padding:10px 14px;142 background:#131109;border:1px solid rgba(240,232,216,0.09);143 border-radius:10px;box-shadow:0 8px 32px rgba(0,0,0,0.75);144 font-family:Inter,sans-serif;white-space:nowrap;145 animation:tf-in 180ms cubic-bezier(0.16,1,0.3,1) both;146 }147 @keyframes tf-in { from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none} }148 .txt { font-size:11px;color:rgba(240,232,216,0.55);font-family:"IBM Plex Mono",monospace; }149 .yes {150 padding:5px 12px;border-radius:6px;border:none;cursor:pointer;font-size:11px;151 background:var(--peach-accent);color:#fff;transition:background 100ms;font-family:Inter,sans-serif;152 }153 .yes:hover { background:color-mix(in srgb, var(--peach-accent) 82%, #000); }154 .no {155 padding:5px 10px;border-radius:6px;border:none;cursor:pointer;font-size:11px;156 background:rgba(240,232,216,0.07);color:rgba(240,232,216,0.45);font-family:Inter,sans-serif;157 }158 `;159 shadow.appendChild(style);160161 const bar = document.createElement("div"); bar.className = "bar";162 const txt = document.createElement("span"); txt.className = "txt";163 txt.textContent = `Remember ${pageDomain} for this entry?`;164 const yesBtn = document.createElement("button"); yesBtn.className = "yes";165 yesBtn.textContent = "Remember";166 yesBtn.addEventListener("click", async () => {167 await chrome.runtime.sendMessage({168 type: "ADD_ADDITIONAL_URL",169 payload: { id: entryId, url: location.origin },170 });171 host.remove();172 });173 const noBtn = document.createElement("button"); noBtn.className = "no";174 noBtn.textContent = "Not now";175 noBtn.addEventListener("click", () => host.remove());176 bar.append(txt, yesBtn, noBtn);177 shadow.appendChild(bar);178 document.body.appendChild(host);179 setTimeout(() => host.remove(), 9000);180}181182interface SmartGenerator {183 root: HTMLElement;184 getPassword: () => string;185 186 copy: () => Promise<void>;187}188189interface SmartGeneratorOptions {190 191 policy: PasswordPolicy;192 193194195196197 initialPassword?: string;198 199 onChange?: (pw: string) => void;200}201202203204205206207208209function createSmartGenerator(opts: SmartGeneratorOptions): SmartGenerator {210 const policy = opts.policy ?? {};211212 213 let length = policy.maxLength ?? 64;214 if (policy.minLength) length = Math.max(length, policy.minLength);215 if (length < 8) length = 8;216 if (length > 128) length = 128;217218 let upper = true;219 let lower = true;220 let numbers = true;221 let symbols = !policy.forbidsSymbols;222 if (policy.requiresSymbols) symbols = true;223 const forbiddenChars = policy.forbiddenChars ?? "";224225 let password = "";226227 const root = document.createElement("div");228 root.className = "pwgen-block";229230 const displayRow = root.appendChild(document.createElement("div"));231 displayRow.className = "pwgen-display-row";232 const output = displayRow.appendChild(document.createElement("input")) as HTMLInputElement;233 output.type = "text";234 output.className = "pwgen-output";235 output.setAttribute("autocomplete", "off");236 output.setAttribute("spellcheck", "false");237 output.setAttribute("autocorrect", "off");238 output.setAttribute("autocapitalize", "off");239240 const regenBtn = displayRow.appendChild(document.createElement("button"));241 regenBtn.className = "pwgen-icon-btn";242 regenBtn.type = "button";243 regenBtn.setAttribute("aria-label", "Regenerate password");244 regenBtn.title = "Regenerate";245 regenBtn.innerHTML = `<svg width="13" height="13" viewBox="0 0 13 13" fill="none" stroke="currentColor" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"><path d="M11 2.5A5.5 5.5 0 1 0 12.5 7"/><path d="M9.5 2.5H11V1"/></svg>`;246247 const copyBtn = displayRow.appendChild(document.createElement("button"));248 copyBtn.className = "pwgen-icon-btn";249 copyBtn.type = "button";250 copyBtn.setAttribute("aria-label", "Copy password");251 copyBtn.title = "Copy";252 copyBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="8" height="9" rx="1.5"/><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"/></svg>`;253254 const controls = root.appendChild(document.createElement("div"));255 controls.className = "pwgen-controls-row";256 const slider = controls.appendChild(document.createElement("input"));257 slider.type = "range";258 slider.className = "pwgen-slider";259 slider.min = "8";260 slider.max = "128";261 slider.value = String(length);262 if (policy.minLength) slider.min = String(Math.max(8, policy.minLength));263 if (policy.maxLength) slider.max = String(Math.min(128, policy.maxLength));264 const lenNum = controls.appendChild(document.createElement("span"));265 lenNum.className = "pwgen-len-num pwgen-len-num--edit";266 lenNum.textContent = String(length);267 lenNum.addEventListener("click", () => {268 const li = document.createElement("input");269 li.type = "text"; li.inputMode = "numeric";270 li.className = "pwgen-len-input"; li.value = String(length);271 lenNum.replaceWith(li);272 requestAnimationFrame(() => li.select());273 function commitLenEdit() {274 const n = parseInt(li.value, 10);275 if (!isNaN(n)) {276 length = Math.max(parseInt(slider.min, 10), Math.min(parseInt(slider.max, 10), n));277 slider.value = String(length);278 regenerate();279 }280 lenNum.textContent = String(length);281 li.replaceWith(lenNum);282 }283 li.addEventListener("keydown", (e) => { if (e.key === "Enter") { e.preventDefault(); commitLenEdit(); } else if (e.key === "Escape") { li.replaceWith(lenNum); } });284 li.addEventListener("blur", commitLenEdit);285 });286287 const pills = root.appendChild(document.createElement("div"));288 pills.className = "pwgen-pills";289290 function makePill(label: string, on: boolean, onToggle: (next: boolean) => void): HTMLButtonElement {291 const b = document.createElement("button");292 b.type = "button";293 b.className = `pwgen-pill ${on ? "is-on" : ""}`;294 b.textContent = label;295 b.addEventListener("click", () => {296 const next = !b.classList.contains("is-on");297 b.classList.toggle("is-on", next);298 onToggle(next);299 });300 return b;301 }302 pills.appendChild(makePill("A-Z", upper, (next) => { upper = next; regenerate(); }));303 pills.appendChild(makePill("a-z", lower, (next) => { lower = next; regenerate(); }));304 pills.appendChild(makePill("0-9", numbers, (next) => { numbers = next; regenerate(); }));305 pills.appendChild(makePill("!@#", symbols, (next) => {306 307 symbols = next;308 regenerate();309 }));310311 312 313 314 const hintParts: string[] = [];315 if (policy.minLength) hintParts.push(`min ${policy.minLength}`);316 if (policy.maxLength) hintParts.push(`max ${policy.maxLength}`);317 if (policy.requiresSymbols) hintParts.push("requires symbols");318 if (policy.forbidsSymbols) hintParts.push("no symbols");319 if (policy.forbiddenChars) hintParts.push(`excludes ${policy.forbiddenChars.slice(0, 6)}${policy.forbiddenChars.length > 6 ? "…" : ""}`);320 if (hintParts.length > 0) {321 const hint = root.appendChild(document.createElement("div"));322 hint.className = "pwgen-policy-hint";323 const accent = document.createElement("span");324 accent.className = "pwgen-hint-accent";325 accent.textContent = "site rules · ";326 const text = document.createTextNode(hintParts.join(" · "));327 hint.appendChild(accent);328 hint.appendChild(text);329 }330331 function regenerate() {332 333 334 password = generatePassword({335 length,336 includeUppercase: upper,337 includeLowercase: lower,338 includeNumbers: numbers,339 includeSymbols: symbols,340 forbiddenChars,341 });342 output.value = password;343 opts.onChange?.(password);344 }345346 output.addEventListener("input", () => {347 password = output.value;348 length = password.length;349 slider.value = String(Math.max(8, Math.min(128, length)));350 lenNum.textContent = String(length);351 opts.onChange?.(password);352 });353354 slider.addEventListener("input", () => {355 length = parseInt(slider.value, 10);356 lenNum.textContent = String(length);357 regenerate();358 });359 regenBtn.addEventListener("click", regenerate);360361 let copyResetTimer: ReturnType<typeof setTimeout> | null = null;362 async function copy(): Promise<void> {363 try {364 await navigator.clipboard.writeText(password);365 copyBtn.classList.add("is-copied");366 if (copyResetTimer) clearTimeout(copyResetTimer);367 copyResetTimer = setTimeout(() => copyBtn.classList.remove("is-copied"), 1400);368 } catch {369 370 }371 }372 copyBtn.addEventListener("click", () => { void copy(); });373374 if (opts.initialPassword) {375 password = opts.initialPassword;376 output.value = password;377 opts.onChange?.(password);378 } else {379 regenerate();380 }381382 return {383 root,384 getPassword: () => password,385 copy,386 };387}388389export function observeAnchorPosition(390 anchorEl: HTMLElement,391 onUpdate: () => void392): () => void {393 let rafId = 0;394 let burstUntil = 0;395396 const runUpdate = () => {397 rafId = 0;398 onUpdate();399 if (performance.now() < burstUntil) rafId = requestAnimationFrame(runUpdate);400 };401 const scheduleUpdate = () => { if (!rafId) rafId = requestAnimationFrame(runUpdate); };402 const scheduleBurst = (ms = 220) => {403 burstUntil = Math.max(burstUntil, performance.now() + ms);404 scheduleUpdate();405 };406407 const resizeObserver = new ResizeObserver(() => scheduleBurst());408 resizeObserver.observe(anchorEl);409 if (anchorEl.parentElement) resizeObserver.observe(anchorEl.parentElement);410411 const mutationObserver = new MutationObserver(() => scheduleBurst());412 mutationObserver.observe(anchorEl, { attributes: true, attributeFilter: ["class", "style", "type", "hidden"] });413 if (anchorEl.parentElement) {414 mutationObserver.observe(anchorEl.parentElement, { attributes: true, attributeFilter: ["class", "style", "hidden"] });415 }416417 const onScroll = () => scheduleUpdate();418 window.addEventListener("scroll", onScroll, true);419 window.addEventListener("resize", onScroll);420 window.visualViewport?.addEventListener("resize", onScroll);421 window.visualViewport?.addEventListener("scroll", onScroll);422 anchorEl.addEventListener("focus", () => scheduleBurst());423 anchorEl.addEventListener("input", () => scheduleBurst());424425 scheduleBurst(260);426427 return () => {428 if (rafId) cancelAnimationFrame(rafId);429 resizeObserver.disconnect();430 mutationObserver.disconnect();431 window.removeEventListener("scroll", onScroll, true);432 window.removeEventListener("resize", onScroll);433 window.visualViewport?.removeEventListener("resize", onScroll);434 window.visualViewport?.removeEventListener("scroll", onScroll);435 };436}437438export function injectFieldIcon(field: HTMLInputElement, onClick: () => void): () => void {439 const button = document.createElement("button");440 button.type = "button";441 button.setAttribute("aria-label", "Peach autofill");442 button.title = "Fill with Peach";443 button.innerHTML = peachIconSvg();444 445 446 447 448 button.style.cssText = `449 position: fixed; z-index: 2147483646;450 width: 26px; height: 26px; cursor: pointer;451 pointer-events: auto; border: none; padding: 3px;452 display: inline-flex; align-items: center; justify-content: center;453 background: transparent; border-radius: 999px;454 transition: opacity 140ms ease, background 120ms ease, box-shadow 120ms ease, transform 80ms ease;455 opacity: 0;456 `;457 button.addEventListener("mouseenter", () => {458 button.style.background = `color-mix(in srgb, ${accentHex} 12%, transparent)`;459 button.style.boxShadow = `0 0 0 1px color-mix(in srgb, ${accentHex} 18%, transparent), 0 0 14px color-mix(in srgb, ${accentHex} 12%, transparent)`;460 button.style.transform = "scale(1.08)";461 });462 button.addEventListener("mouseleave", () => {463 button.style.background = "transparent";464 button.style.boxShadow = "none";465 button.style.transform = "none";466 });467 button.addEventListener("pointerdown", e => { e.stopPropagation(); e.preventDefault(); });468 button.addEventListener("click", e => { e.stopPropagation(); e.preventDefault(); onClick(); });469470 document.body.appendChild(button);471472 function updatePosition() {473 const rect = field.getBoundingClientRect();474 if (rect.width === 0 || rect.height === 0) {475 button.style.opacity = "0"; button.style.pointerEvents = "none";476 return;477 }478 const sz = 26;479 const inset = Math.max(5, Math.min(10, rect.height * 0.22));480 const top = rect.top + rect.height / 2 - sz / 2;481 482 483 const minLeft = rect.left + 4;484 const left = Math.max(minLeft, rect.right - sz - inset);485 486 if (rect.width < 40) {487 button.style.opacity = "0"; button.style.pointerEvents = "none";488 return;489 }490 button.style.top = `${top}px`;491 button.style.left = `${left}px`;492 button.style.opacity = "1"; button.style.pointerEvents = "auto";493 }494 updatePosition();495 requestAnimationFrame(() => { button.style.opacity = "1"; });496 const stopObserving = observeAnchorPosition(field, updatePosition);497 return () => { stopObserving(); button.remove(); };498}499500501502503504505506const SELECTOR_STYLES = `507 :host { all: initial; }508 *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }509510 .peach-inline-popup[data-theme="dark"] {511 --peach-bg: #1a1410;512 --peach-bg-card: #221c16;513 --peach-text: #f5f0ea;514 --peach-text-dim: #8a7a6a;515 --peach-text-muted: #4a3a2a;516 --peach-border: rgba(255,255,255,0.07);517 --peach-input-bg: rgba(255,255,255,0.05);518 --peach-input-border: rgba(255,255,255,0.08);519 }520 .peach-inline-popup[data-theme="light"] {521 --peach-bg: #fdf8f4;522 --peach-bg-card: #f5ede4;523 --peach-text: #1c1310;524 --peach-text-dim: #6b5a4a;525 --peach-text-muted: #a89080;526 --peach-border: rgba(0,0,0,0.08);527 --peach-input-bg: rgba(0,0,0,0.04);528 --peach-input-border: rgba(0,0,0,0.10);529 }530531 .peach-inline-popup {532 background: var(--peach-bg);533 border: 1px solid var(--peach-border-accent, var(--peach-border));534 border-radius: 14px;535 overflow: hidden;536 box-shadow:537 0 8px 40px var(--peach-glow, transparent),538 0 2px 12px rgba(0,0,0,0.5);539 font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;540 animation: peach-enter 200ms cubic-bezier(0.16,1,0.3,1) forwards;541 transition: height 220ms cubic-bezier(0.16,1,0.3,1);542 }543 /* Light theme: shadow against a light page is too strong otherwise — drop both544 the accent glow and the dark drop-shadow opacity to keep the popup elegant. */545 .peach-inline-popup[data-theme="light"] {546 box-shadow:547 0 8px 40px color-mix(in srgb, var(--peach-accent) 10%, transparent),548 0 2px 12px rgba(0,0,0,0.12);549 }550 .peach-inline-popup.is-exiting {551 animation: peach-exit 130ms cubic-bezier(0.4,0,1,1) forwards;552 pointer-events: none;553 }554555 @keyframes peach-enter {556 0% { opacity: 0; transform: translateY(-8px) scale(0.96); filter: blur(3px); }557 65% { opacity: 1; filter: blur(0); }558 100% { opacity: 1; transform: translateY(0) scale(1); }559 }560 @keyframes peach-exit {561 0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }562 100% { opacity: 0; transform: translateY(-4px) scale(0.98); filter: blur(2px); }563 }564 @keyframes peach-slide-in {565 from { opacity: 0; transform: translateX(12px); }566 to { opacity: 1; transform: translateX(0); }567 }568 @keyframes peach-slide-back {569 from { opacity: 0; transform: translateX(-12px); }570 to { opacity: 1; transform: translateX(0); }571 }572 .peach-content[data-dir="forward"] { animation: peach-slide-in 150ms cubic-bezier(0.16,1,0.3,1) both; }573 .peach-content[data-dir="back"] { animation: peach-slide-back 150ms cubic-bezier(0.16,1,0.3,1) both; }574575 /* Domain header */576 .domain-header {577 padding: 9px 13px 7px;578 border-bottom: 1px solid var(--peach-border);579 display: flex; align-items: center; justify-content: space-between;580 gap: 8px;581 }582 .domain-header-text {583 display: flex; flex-direction: column; gap: 2px;584 min-width: 0; flex: 1;585 }586 .domain-eyebrow {587 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;588 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;589 }590 .domain-name {591 font-size: 10px; color: color-mix(in srgb, var(--peach-accent) 60%, transparent);592 font-family: "IBM Plex Mono", monospace;593 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;594 }595 .domain-header-actions {596 display: inline-flex; align-items: center; gap: 5px;597 flex-shrink: 0;598 }599 .domain-add-btn,600 .domain-search-btn {601 flex-shrink: 0;602 width: 22px; height: 22px;603 display: inline-flex; align-items: center; justify-content: center;604 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);605 border: 1px solid color-mix(in srgb, var(--peach-accent) 28%, transparent);606 border-radius: 6px;607 color: var(--peach-accent);608 cursor: pointer; padding: 0;609 transition: background 120ms, border-color 120ms, transform 80ms;610 font-family: "IBM Plex Mono", monospace;611 font-size: 14px; line-height: 1;612 }613 .domain-add-btn:hover,614 .domain-search-btn:hover {615 background: color-mix(in srgb, var(--peach-accent) 22%, transparent);616 border-color: color-mix(in srgb, var(--peach-accent) 48%, transparent);617 transform: scale(1.06);618 }619 .domain-add-btn:active,620 .domain-search-btn:active { transform: scale(0.96); }621622 /* Search */623 .search-wrap {624 padding: 9px 12px 7px;625 border-bottom: 1px solid var(--peach-border);626 }627 .search {628 width: 100%; background: var(--peach-input-bg);629 border: 1px solid var(--peach-input-border);630 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;631 font-size: 12px; outline: none; font-family: "IBM Plex Mono", monospace;632 transition: border-color 120ms, box-shadow 120ms;633 }634 .search:focus {635 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);636 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);637 }638 .search::placeholder { color: var(--peach-text-muted); }639640 /* Results */641 .results { max-height: 256px; overflow-y: auto; scrollbar-width: none; }642 .results::-webkit-scrollbar { display: none; }643644 /* Entry rows */645 .entry {646 display: flex; align-items: center; padding: 8px 12px;647 cursor: pointer; border-bottom: 1px solid var(--peach-border);648 transition: background 70ms; position: relative; outline: none;649 }650 .entry:last-child { border-bottom: none; }651 .entry:hover { background: color-mix(in srgb, var(--peach-text) 4%, transparent); }652 .entry.focused { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }653 .entry.focused::before {654 content: ""; position: absolute; left: 0; top: 3px; bottom: 3px;655 width: 2px; border-radius: 2px;656 background: color-mix(in srgb, var(--peach-accent) 55%, transparent);657 }658659 .entry-icon {660 width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;661 background: var(--peach-input-bg); border: 1px solid var(--peach-border);662 display: flex; align-items: center; justify-content: center;663 overflow: hidden; margin-right: 10px;664 }665 .entry-icon img { width: 15px; height: 15px; border-radius: 2px; display: block; }666 .entry-icon.is-new {667 background: color-mix(in srgb, var(--peach-accent) 8%, transparent);668 border-color: color-mix(in srgb, var(--peach-accent) 15%, transparent);669 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);670 }671672 .entry-info { flex: 1; min-width: 0; }673 .entry-title {674 font-size: 12.5px; color: var(--peach-text);675 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;676 line-height: 1.3;677 }678 .entry-title.is-new { color: color-mix(in srgb, var(--peach-accent) 90%, transparent); font-size: 12px; }679 .entry-sub {680 font-size: 10px; color: var(--peach-text-dim);681 font-family: "IBM Plex Mono", monospace;682 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;683 margin-top: 1px;684 }685686 .totp-badge {687 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;688 border-radius: 4px; background: color-mix(in srgb, var(--peach-accent) 10%, transparent);689 color: color-mix(in srgb, var(--peach-accent) 75%, transparent);690 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 8px;691 }692 .passkey-badge {693 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;694 border-radius: 4px;695 background: color-mix(in srgb, var(--peach-accent) 14%, transparent);696 color: color-mix(in srgb, var(--peach-accent) 85%, transparent);697 border: 1px solid color-mix(in srgb, var(--peach-accent) 24%, transparent);698 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 6px;699 }700701 .divider { height: 1px; background: var(--peach-border); margin: 2px 0; }702703 .empty-hint {704 padding: 14px 13px; font-size: 11px; color: var(--peach-text-dim);705 font-family: "IBM Plex Mono", monospace;706 }707708 /* Create form */709 .create-form-wrap {710 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;711 }712 .create-head {713 display: flex; align-items: center; gap: 8px;714 padding: 10px 12px; border-bottom: 1px solid var(--peach-border);715 }716 .back-btn {717 background: transparent; border: none; cursor: pointer;718 color: var(--peach-text-dim); padding: 3px; border-radius: 5px;719 display: flex; align-items: center; line-height: 0;720 transition: color 100ms, background 100ms;721 }722 .back-btn:hover { color: var(--peach-text); background: var(--peach-input-bg); }723 .create-label { font-size: 12px; color: var(--peach-text); font-weight: 500; flex: 1; }724 /* minmax(0, 1fr) caps the grid track at the popup width — without it,725 long monospace content (e.g. a 60-char generated password) would726 auto-size the track wider than the popup and overflow the right edge. */727 .create-body { padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }728 .f-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }729 .f-label {730 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;731 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;732 }733 .f-input {734 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);735 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;736 font-size: 11px; font-family: "IBM Plex Mono", monospace;737 outline: none; width: 100%; transition: border-color 120ms, box-shadow 120ms;738 }739 .f-input:focus { border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent); }740 .f-input::placeholder { color: var(--peach-text-muted); }741 .f-input.url-f { font-size: 10px; color: var(--peach-text-dim); letter-spacing: 0.01em; }742 .f-row { display: flex; gap: 6px; }743 .f-row .f-input { flex: 1; min-width: 0; }744 .gen-btn {745 padding: 0 10px; border-radius: 7px; border: none;746 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);747 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);748 font-size: 10px; font-family: "IBM Plex Mono", monospace;749 cursor: pointer; white-space: nowrap; flex-shrink: 0;750 display: flex; align-items: center; gap: 4px;751 transition: background 100ms;752 }753 .gen-btn:hover { background: color-mix(in srgb, var(--peach-accent) 18%, transparent); }754 .gen-toggle-link {755 background: none; border: none; padding: 2px 0;756 color: color-mix(in srgb, var(--peach-accent) 60%, transparent);757 font-size: 10px; font-family: "IBM Plex Mono", monospace;758 cursor: pointer; text-align: left; transition: color 100ms;759 }760 .gen-toggle-link:hover { color: var(--peach-accent); }761 .save-btn {762 width: 100%; padding: 8px; border-radius: 8px; border: none;763 background: var(--peach-accent); color: #fff; font-size: 12px;764 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;765 transition: background 120ms, box-shadow 120ms, transform 80ms;766 letter-spacing: 0.01em;767 }768 .save-btn:hover {769 background: color-mix(in srgb, var(--peach-accent) 82%, #000);770 box-shadow: 0 4px 20px var(--peach-glow, transparent);771 }772 .save-btn:disabled { opacity: 0.4; cursor: not-allowed; }773 .url-hint {774 font-size: 9px; color: color-mix(in srgb, var(--peach-accent) 45%, transparent);775 font-family: "IBM Plex Mono", monospace; font-style: italic;776 }777778 /* Success */779 .success-wrap {780 display: flex; flex-direction: column; align-items: center;781 padding: 24px 16px 20px; gap: 8px;782 animation: su-in 280ms cubic-bezier(0.16,1,0.3,1) both;783 }784 @keyframes su-in { from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:none} }785 .success-ring {786 width: 40px; height: 40px; border-radius: 50%;787 background: rgba(123,144,96,0.10); border: 1.5px solid rgba(123,144,96,0.25);788 display: flex; align-items: center; justify-content: center;789 }790 .success-text { font-size: 12.5px; color: var(--peach-text); font-weight: 500; }791 .success-sub { font-size: 10px; color: var(--peach-text-dim); font-family:"IBM Plex Mono",monospace; }792793 /* Silver platter (State 1 — single match) */794 .silver-platter {795 padding: 14px 14px 12px;796 display: flex; flex-direction: column; gap: 6px;797 }798 .sp-title {799 font-size: 14px; font-weight: 500; color: var(--peach-text);800 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;801 line-height: 1.25;802 }803 .sp-identity-row {804 display: flex; align-items: baseline; gap: 5px; margin-bottom: 3px;805 }806 .sp-identity-label {807 font-size: 9px; font-weight: 600; letter-spacing: 0.05em;808 text-transform: uppercase; color: var(--peach-text-muted); flex-shrink: 0;809 }810 .sp-username {811 font-size: 12px; color: var(--peach-text-dim);812 font-family: "IBM Plex Mono", monospace;813 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;814 margin-bottom: 0;815 }816 .sp-identity-row + .sp-fill-btn, .sp-username + .sp-fill-btn { margin-top: 6px; }817 .sp-fill-btn {818 width: 100%; padding: 11px; border-radius: 9px; border: none;819 background: var(--peach-accent); color: #fff;820 font-size: 13px; font-weight: 500; cursor: pointer;821 font-family: Inter, sans-serif; letter-spacing: 0.01em;822 display: flex; align-items: center; justify-content: center; min-height: 38px;823 transition: filter 120ms ease, transform 80ms ease, box-shadow 120ms ease, background 120ms ease;824 }825 .sp-fill-btn:hover {826 filter: brightness(1.1);827 box-shadow: 0 4px 20px var(--peach-glow, transparent);828 transform: translateY(-1px);829 }830 .sp-fill-btn:active { transform: translateY(0); filter: brightness(0.95); }831 .sp-fill-btn.filled {832 background: #16a34a; transform: none; filter: none;833 box-shadow: 0 4px 16px rgba(22,163,74,0.35);834 cursor: default;835 }836 .sp-fill-btn:disabled { cursor: default; }837 .sp-actions-group {838 margin-top: 6px;839 display: flex; flex-direction: column; gap: 4px;840 }841 .sp-actions-label {842 font-size: 8px; letter-spacing: 0.18em; text-transform: uppercase;843 color: var(--peach-text-muted);844 font-family: "IBM Plex Mono", monospace;845 text-align: center;846 }847 .sp-actions {848 display: flex; gap: 4px; justify-content: space-between; align-items: center;849 }850 .sp-action-btn {851 flex: 1; height: 28px; border: none; border-radius: 6px;852 background: transparent; color: var(--peach-text-dim);853 font-size: 12px; cursor: pointer;854 transition: background 120ms ease, color 120ms ease;855 font-family: Inter, sans-serif; letter-spacing: 0.04em;856 display: inline-flex; align-items: center; justify-content: center; gap: 4px;857 white-space: nowrap; overflow: hidden;858 }859 .sp-action-btn:hover:not(:disabled) {860 background: color-mix(in srgb, var(--peach-text) 5%, transparent);861 color: var(--peach-text);862 }863 .sp-action-btn:disabled { opacity: 0.3; cursor: default; }864 .sp-action-btn.flashed {865 color: var(--peach-accent);866 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);867 }868869 /* TOTP tray — shown below the silver-platter secondary actions */870 .sp-tray {871 margin-top: 8px;872 padding: 10px 12px;873 border-radius: 9px;874 background: var(--peach-input-bg);875 border: 1px solid var(--peach-input-border);876 display: flex; align-items: center; gap: 12px;877 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;878 }879 .sp-tray-label {880 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;881 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;882 flex-shrink: 0;883 }884 .sp-totp-code {885 font-size: 18px; font-weight: 500;886 color: var(--peach-text);887 font-family: "IBM Plex Mono", monospace;888 letter-spacing: 0.12em;889 flex: 1;890 text-align: center;891 }892 .sp-totp-ring {893 width: 22px; height: 22px; flex-shrink: 0;894 }895 .sp-totp-ring .ring-track { stroke: var(--peach-input-border); }896 .sp-totp-ring .ring-fill {897 stroke: var(--peach-accent);898 transition: stroke-dashoffset 1s linear;899 transform: rotate(-90deg);900 transform-origin: center;901 }902 .sp-totp-copy {903 background: transparent; border: none; cursor: pointer;904 padding: 4px 8px; border-radius: 5px;905 color: var(--peach-text-dim); font-size: 11px;906 font-family: Inter, sans-serif;907 transition: background 120ms, color 120ms;908 }909 .sp-totp-copy:hover {910 background: color-mix(in srgb, var(--peach-text) 5%, transparent);911 color: var(--peach-text);912 }913914 /* Card silver platter (State 7) — reuses .sp-* primary action classes */915 .card-platter {916 padding: 12px 14px 10px;917 display: flex; flex-direction: column; gap: 4px;918 }919 .cp-network {920 font-size: 10px; font-weight: 600;921 color: var(--peach-accent);922 letter-spacing: 0.08em; text-transform: uppercase;923 font-family: Inter, sans-serif;924 }925 .cp-nickname {926 font-size: 14px; font-weight: 500; color: var(--peach-text);927 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;928 line-height: 1.2;929 }930 .cp-last4 {931 font-size: 12px; color: var(--peach-text-dim);932 font-family: "IBM Plex Mono", monospace;933 letter-spacing: 0.04em;934 margin-top: 2px;935 }936 .cp-meta {937 font-size: 11px; color: var(--peach-text-dim);938 font-family: "IBM Plex Mono", monospace;939 margin-top: 2px;940 display: flex; gap: 10px; align-items: center;941 }942 .cp-meta-sep { opacity: 0.5; }943 .cp-fill-wrap { margin-top: 10px; }944945 /* Locked state */946 .locked-wrap {947 display: flex; flex-direction: column; align-items: stretch;948 padding: 14px 13px 13px; gap: 9px;949 }950 .locked-head { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }951 .locked-icon {952 width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;953 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);954 display: flex; align-items: center; justify-content: center;955 }956 .locked-title { font-size: 11.5px; color: var(--peach-text); font-weight: 500; }957 .locked-sub { font-size: 10.5px; line-height: 1.4; color: var(--peach-text-muted); text-align: center; margin: 2px 0 2px; }958 .locked-input {959 width: 100%; background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);960 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;961 font-size: 11px; font-family: "IBM Plex Mono", monospace;962 outline: none; transition: border-color 120ms, box-shadow 120ms;963 }964 .locked-input:focus { border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent); }965 .locked-input::placeholder { color: var(--peach-text-muted); }966 .locked-btn {967 width: 100%; padding: 8px; border-radius: 8px; border: none;968 background: var(--peach-accent); color: #fff; font-size: 12px;969 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;970 transition: background 120ms;971 letter-spacing: 0.01em;972 box-shadow: 0 2px 16px var(--peach-glow, transparent);973 animation: peach-pulse-glow 2.4s ease-in-out infinite;974 }975 .locked-btn:hover { background: color-mix(in srgb, var(--peach-accent) 82%, #000); }976 .locked-btn:disabled { opacity: 0.4; cursor: not-allowed; animation: none; }977 .locked-error {978 font-size: 10px; color: rgba(220,80,60,0.85);979 font-family: "IBM Plex Mono", monospace;980 }981982 @keyframes peach-pulse-glow {983 0%, 100% { box-shadow: 0 2px 16px var(--peach-glow, transparent); }984 50% { box-shadow: 0 2px 28px var(--peach-glow, transparent),985 0 0 48px var(--peach-glow, transparent); }986 }987988 /* ── State 10: identity helper ─────────────────────────────── */989 .identity-list {990 max-height: 192px; overflow-y: auto; padding: 4px 0;991 scrollbar-width: none;992 }993 .identity-list::-webkit-scrollbar { display: none; }994 .peach-identity-row {995 display: flex; align-items: center; gap: 10px;996 padding: 9px 12px; cursor: pointer; border-radius: 8px;997 transition: background 100ms ease;998 }999 .peach-identity-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }1000 .peach-identity-value {1001 font-family: "IBM Plex Mono", monospace; font-size: 13px;1002 color: var(--peach-text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;1003 }1004 .peach-identity-meta { font-size: 10px; color: var(--peach-text-muted); flex-shrink: 0; }1005 .identity-alt-row {1006 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;1007 border-radius: 8px; transition: background 100ms ease;1008 color: var(--peach-text-dim); font-size: 12px; font-family: Inter, sans-serif;1009 }1010 .identity-alt-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }1011 .identity-escape-row {1012 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;1013 border-radius: 8px; transition: background 100ms ease; outline: none;1014 color: var(--peach-accent); font-size: 11px; font-family: Inter, sans-serif;1015 margin-top: 2px;1016 }1017 .identity-escape-row:hover, .identity-escape-row:focus { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }1018 .identity-alt-input-wrap { display: none; padding: 0 12px 8px; gap: 6px; align-items: center; }1019 .identity-alt-input-wrap.open { display: flex; }1020 .identity-alt-input {1021 flex: 1; height: 32px; padding: 0 10px; border-radius: 7px;1022 border: 1px solid var(--peach-input-border); background: var(--peach-input-bg);1023 color: var(--peach-text); font-family: "IBM Plex Mono", monospace; font-size: 12px;1024 outline: none; transition: border-color 120ms;1025 }1026 .identity-alt-input:focus {1027 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);1028 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);1029 }1030 .identity-alt-confirm {1031 height: 32px; padding: 0 12px; border-radius: 7px; border: none;1032 background: var(--peach-accent); color: #fff; font-size: 12px;1033 cursor: pointer; font-family: Inter, sans-serif; flex-shrink: 0;1034 }1035 /* ── Generator view (after identity picked) ────────────────── */1036 .gen-view { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1037 .gen-confirmed {1038 display: flex; align-items: center; gap: 8px; padding: 7px 10px;1039 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1040 border-radius: 8px;1041 }1042 .gen-confirmed-check { color: var(--peach-accent); font-size: 13px; font-weight: 600; }1043 .gen-confirmed-val {1044 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1045 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1046 }1047 .gen-label {1048 font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;1049 color: var(--peach-text-muted); font-family: "IBM Plex Mono", monospace;1050 }1051 .gen-pw-row { display: flex; gap: 6px; align-items: center; }1052 .gen-pw-val {1053 flex: 1; padding: 8px 10px; border-radius: 7px;1054 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1055 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1056 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;1057 }1058 .gen-regen-btn {1059 height: 34px; padding: 0 10px; border-radius: 7px; border: none;1060 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1061 color: var(--peach-text-dim); font-size: 11px; cursor: pointer;1062 font-family: "IBM Plex Mono", monospace; transition: background 100ms ease;1063 }1064 .gen-regen-btn:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1065 .gen-fill-btn {1066 padding: 10px; border-radius: 8px; border: none;1067 background: var(--peach-accent); color: #fff; font-size: 13px; font-weight: 500;1068 cursor: pointer; font-family: Inter, sans-serif; letter-spacing: 0.01em;1069 transition: filter 120ms ease, transform 80ms ease;1070 }1071 .gen-fill-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }1072 .gen-fill-btn:active { transform: translateY(0); }10731074 /* ── Smart password generator (parity with main UI compact mode) ─── */1075 .pwgen-block { display: flex; flex-direction: column; gap: 8px; }1076 .pwgen-display-row {1077 display: flex; align-items: center; gap: 6px;1078 padding: 8px 10px; border-radius: 7px;1079 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1080 }1081 .pwgen-output {1082 flex: 1; min-width: 0; width: 0;1083 font-family: "IBM Plex Mono", monospace; font-size: 12px;1084 color: var(--peach-text);1085 background: transparent; border: none; outline: none; padding: 0;1086 }1087 .pwgen-icon-btn {1088 flex-shrink: 0;1089 width: 26px; height: 26px;1090 display: inline-flex; align-items: center; justify-content: center;1091 background: transparent; border: 1px solid var(--peach-input-border);1092 border-radius: 6px; color: var(--peach-text-dim); cursor: pointer;1093 padding: 0; transition: background 100ms, color 100ms, border-color 100ms;1094 }1095 .pwgen-icon-btn:hover {1096 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1097 color: var(--peach-accent);1098 border-color: color-mix(in srgb, var(--peach-accent) 30%, transparent);1099 }1100 .pwgen-icon-btn.is-copied {1101 background: color-mix(in srgb, var(--peach-accent) 18%, transparent);1102 color: var(--peach-accent);1103 border-color: color-mix(in srgb, var(--peach-accent) 45%, transparent);1104 }1105 .pwgen-controls-row {1106 display: flex; align-items: center; gap: 8px;1107 flex-wrap: wrap;1108 }1109 .pwgen-slider {1110 flex: 1; min-width: 110px;1111 accent-color: var(--peach-accent);1112 cursor: pointer; height: 2px; background: transparent;1113 }1114 .pwgen-len-num {1115 font-family: "IBM Plex Mono", monospace; font-size: 11px;1116 color: var(--peach-accent); min-width: 22px; text-align: right;1117 }1118 .pwgen-len-num--edit { cursor: text; border-bottom: 1px dotted color-mix(in srgb, var(--peach-accent) 50%, transparent); }1119 .pwgen-len-input {1120 font-family: "IBM Plex Mono", monospace; font-size: 11px;1121 color: var(--peach-accent); width: 28px; text-align: right;1122 background: transparent; border: none; border-bottom: 1px solid var(--peach-accent);1123 outline: none; padding: 0; min-width: 22px;1124 }1125 @keyframes identity-suggest-in {1126 from { opacity: 0; transform: translateY(-4px); }1127 to { opacity: 1; transform: none; }1128 }1129 .identity-suggest-list { display: flex; flex-direction: column; gap: 1px; margin-top: 3px;1130 animation: identity-suggest-in 180ms cubic-bezier(0.16,1,0.3,1) both; }1131 .identity-filter-row { display: flex; align-items: center; gap: 4px; padding: 2px 0 4px; }1132 .identity-collapse-btn {1133 margin-left: auto; background: transparent; border: none; cursor: pointer;1134 color: var(--peach-text-muted); padding: 2px 4px; display: flex; align-items: center;1135 line-height: 0; border-radius: 3px;1136 transition: color 100ms ease, transform 220ms cubic-bezier(0.16,1,0.3,1);1137 }1138 .identity-collapse-btn:hover { color: var(--peach-text); }1139 .identity-collapse-btn.is-collapsed { transform: rotate(-90deg); }1140 .identity-rows { display: grid; grid-template-rows: 1fr;1141 transition: grid-template-rows 220ms cubic-bezier(0.16,1,0.3,1); }1142 .identity-rows.is-collapsed { grid-template-rows: 0fr; }1143 .identity-rows-inner { overflow-y: auto; min-height: 0; max-height: 148px;1144 scrollbar-width: thin; scrollbar-color: var(--peach-text-muted) transparent;1145 mask-image: linear-gradient(to bottom, black calc(100% - 18px), transparent 100%);1146 -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 18px), transparent 100%); }1147 .identity-rows-inner::-webkit-scrollbar { width: 4px; }1148 .identity-rows-inner::-webkit-scrollbar-track { background: transparent; }1149 .identity-rows-inner::-webkit-scrollbar-thumb { background: var(--peach-text-muted); border-radius: 2px; }1150 .identity-filter-pill {1151 padding: 2px 7px; border-radius: 999px;1152 border: 1px solid var(--peach-input-border);1153 background: transparent; color: var(--peach-text-muted);1154 font-family: "IBM Plex Mono", monospace; font-size: 9px;1155 cursor: pointer; transition: border-color 80ms, background 80ms, color 80ms;1156 }1157 .identity-filter-pill.is-on {1158 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1159 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1160 color: var(--peach-accent);1161 }1162 .identity-suggest-row {1163 display: flex; align-items: center; gap: 5px;1164 width: 100%; padding: 4px 6px; border-radius: 5px; border: none;1165 background: transparent; cursor: pointer; text-align: left;1166 transition: background 80ms;1167 }1168 .identity-suggest-row:hover,1169 .identity-suggest-row:focus { background: color-mix(in srgb, var(--peach-accent) 10%, transparent); outline: none; }1170 .identity-suggest-val {1171 font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--peach-text);1172 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;1173 }1174 .identity-suggest-type {1175 font-family: "IBM Plex Mono", monospace; font-size: 8px; font-weight: 600;1176 flex-shrink: 0; padding: 1px 3px; border-radius: 3px;1177 }1178 .identity-suggest-type--email {1179 color: color-mix(in srgb, var(--peach-accent) 70%, transparent);1180 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);1181 }1182 .identity-suggest-type--username {1183 color: var(--peach-text-muted);1184 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1185 }1186 .identity-suggest-meta {1187 font-family: "IBM Plex Mono", monospace; font-size: 9px;1188 color: var(--peach-text-muted); flex-shrink: 0;1189 }1190 .pwgen-pills { display: flex; gap: 5px; flex-wrap: wrap; }1191 .pwgen-pill {1192 padding: 3px 8px; border-radius: 999px;1193 border: 1px solid var(--peach-input-border);1194 background: transparent; color: var(--peach-text-muted);1195 font-family: "IBM Plex Mono", monospace; font-size: 9px;1196 letter-spacing: 0.06em; cursor: pointer;1197 transition: all 130ms ease;1198 }1199 .pwgen-pill.is-on {1200 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1201 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1202 color: var(--peach-accent);1203 }1204 .pwgen-pill:not(.is-on):hover {1205 color: var(--peach-text-dim);1206 border-color: var(--peach-text-muted);1207 }1208 .pwgen-policy-hint {1209 font-size: 10px; color: var(--peach-text-muted);1210 font-family: "IBM Plex Mono", monospace; letter-spacing: 0.04em;1211 line-height: 1.3;1212 }1213 .pwgen-policy-hint .pwgen-hint-accent { color: var(--peach-accent); }12141215 /* ── Save offer (after password filled) ───────────────────── */1216 .save-offer { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1217 .save-offer-title {1218 font-size: 12px; font-weight: 600; color: var(--peach-text); font-family: Inter, sans-serif;1219 }1220 .save-offer-row {1221 display: flex; align-items: center; gap: 8px; padding: 6px 8px;1222 border-radius: 7px; background: var(--peach-input-bg);1223 border: 1px solid var(--peach-input-border);1224 }1225 .save-offer-lbl {1226 font-size: 10px; color: var(--peach-text-muted); width: 54px; flex-shrink: 0;1227 font-family: "IBM Plex Mono", monospace;1228 }1229 .save-offer-val {1230 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1231 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1232 }1233 .save-offer-btns { display: flex; gap: 8px; margin-top: 4px; }1234 .save-offer-save {1235 flex: 1; padding: 9px; border-radius: 8px; border: none;1236 background: var(--peach-accent); color: #fff; font-size: 13px;1237 cursor: pointer; font-family: Inter, sans-serif; transition: filter 120ms ease;1238 }1239 .save-offer-save:hover { filter: brightness(1.08); }1240 .save-offer-skip {1241 flex: 1; padding: 9px; border-radius: 8px; border: none;1242 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1243 color: var(--peach-text-dim); font-size: 13px; cursor: pointer;1244 font-family: Inter, sans-serif; transition: background 100ms ease;1245 }1246 .save-offer-skip:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1247`;12481249export function showAutofillSelector(1250 anchorEl: HTMLInputElement,1251 entries: SelectorEntry[],1252 onSelect: (id: string) => void,1253 options: SelectorOptions = {}1254): () => void {1255 const host = document.createElement("div");1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 const modalAncestor = (1269 anchorEl.closest<HTMLElement>('form') ??1270 anchorEl.closest<HTMLElement>('dialog, [aria-modal="true"], [role="dialog"]') ??1271 (() => {1272 let cur: HTMLElement | null = anchorEl.parentElement;1273 while (cur && cur !== document.body) {1274 if (window.getComputedStyle(cur).position === 'fixed') return cur;1275 cur = cur.parentElement;1276 }1277 return null;1278 })()1279 );1280 host.style.cssText = `position: ${modalAncestor ? "fixed" : "absolute"}; z-index: 2147483647;`;1281 host.style.setProperty("--peach-accent", accentHex);1282 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));1283 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));1284 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));1285 const shadow = host.attachShadow({ mode: "closed" });12861287 const style = shadow.appendChild(document.createElement("style"));1288 style.textContent = SELECTOR_STYLES;12891290 const rect = anchorEl.getBoundingClientRect();1291 1292 host.style.top = `${rect.bottom + (modalAncestor ? 0 : window.scrollY) + 5}px`;1293 host.style.left = `${rect.left + (modalAncestor ? 0 : window.scrollX)}px`;1294 1295 1296 1297 1298 const popupWidth = Math.min(Math.max(rect.width, 320), 400);1299 host.style.width = `${popupWidth}px`;13001301 const container = shadow.appendChild(document.createElement("div"));1302 container.className = "peach-inline-popup";1303 container.setAttribute("data-theme", popupTheme);13041305 const searchableEntries = options.searchableEntries ?? [];1306 const { origin: sOrigin, title: sTitle, loginSubdomain } = smartUrl();13071308 let query = "";1309 let focusedIndex = -1;1310 let currentMode: "list" | "create" | "success" | "silver-platter" = "list";1311 let searchInput: HTMLInputElement | null = null;1312 1313 1314 1315 let silverPlatterOrigin: SelectorEntry | null = null;1316 1317 1318 const cleanupHooks: Array<() => void> = [];13191320 1321 1322 1323 {1324 let prevH = 0;1325 let blocked = false;1326 const heightRo = new ResizeObserver(([entry]) => {1327 if (blocked) return;1328 const h = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;1329 if (prevH > 0 && Math.abs(h - prevH) > 1) {1330 blocked = true;1331 container.style.height = `${prevH}px`;1332 requestAnimationFrame(() => requestAnimationFrame(() => {1333 container.style.height = `${h}px`;1334 prevH = h;1335 const onEnd = (e: TransitionEvent) => {1336 if (e.propertyName !== "height") return;1337 container.style.height = "";1338 blocked = false;1339 container.removeEventListener("transitionend", onEnd);1340 };1341 container.addEventListener("transitionend", onEnd);1342 }));1343 } else {1344 prevH = h;1345 }1346 });1347 heightRo.observe(container);1348 cleanupHooks.push(() => heightRo.disconnect());1349 }13501351 1352 const preUsername = (anchorEl.type !== "password") ? (anchorEl.value?.trim() ?? "") : "";1353 const pwInForm = anchorEl.closest("form")?.querySelector<HTMLInputElement>("input[type='password']");1354 const prePassword = pwInForm?.value?.trim() ?? (anchorEl.type === "password" ? anchorEl.value?.trim() : "") ?? "";13551356 function uniqueEntries(list: SelectorEntry[]): SelectorEntry[] {1357 const seen = new Set<string>();1358 return list.filter(e => { if (seen.has(e.id)) return false; seen.add(e.id); return true; });1359 }13601361 function filterEntries(source: SelectorEntry[], value: string): SelectorEntry[] {1362 const q = value.trim().toLowerCase();1363 const deduped = uniqueEntries(source);1364 if (!q) return deduped.slice(0, 8);1365 return deduped.filter(e =>1366 [e.title, e.username ?? "", e.url ?? ""].join(" ").toLowerCase().includes(q)1367 ).slice(0, 12);1368 }13691370 function activeEntries(): SelectorEntry[] {1371 1372 if (query.trim()) {1373 const merged = uniqueEntries([...entries, ...searchableEntries]);1374 return filterEntries(merged, query);1375 }1376 1377 if (entries.length > 0) return entries;1378 return filterEntries(searchableEntries, "").slice(0, 8);1379 }13801381 function makeEntryIcon(url?: string, isNew = false): HTMLDivElement {1382 const icon = document.createElement("div");1383 icon.className = `entry-icon${isNew ? " is-new" : ""}`;1384 if (isNew) {1385 icon.innerHTML = plusSvgStr();1386 } else {1387 1388 1389 1390 void url;1391 icon.innerHTML = keySvgStr();1392 }1393 return icon;1394 }13951396 function renderIdentityHelper() {1397 container.innerHTML = "";1398 const identities = options.savedIdentities ?? [];13991400 1401 const hdr = container.appendChild(document.createElement("div"));1402 hdr.className = "domain-header";1403 const eyebrow = hdr.appendChild(document.createElement("div"));1404 eyebrow.className = "domain-eyebrow";1405 eyebrow.textContent = "NEW ACCOUNT";1406 const domName = hdr.appendChild(document.createElement("div"));1407 domName.className = "domain-name";1408 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");14091410 1411 const list = container.appendChild(document.createElement("div"));1412 list.className = "identity-list";1413 for (const id of identities) {1414 const row = list.appendChild(document.createElement("div"));1415 row.className = "peach-identity-row";1416 row.setAttribute("tabindex", "-1");1417 const val = row.appendChild(document.createElement("div"));1418 val.className = "peach-identity-value";1419 val.textContent = id.value;1420 const meta = row.appendChild(document.createElement("div"));1421 meta.className = "peach-identity-meta";1422 meta.textContent = `used ${id.useCount}×`;1423 row.addEventListener("click", () => {1424 options.onFillFields?.(id.value, "");1425 renderGenerator(id.value);1426 });1427 }14281429 1430 if (identities.length > 0) {1431 container.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1432 }14331434 1435 const altRow = container.appendChild(document.createElement("div"));1436 altRow.className = "identity-alt-row";1437 altRow.textContent = "+ Use a different email…";14381439 const altInputWrap = container.appendChild(document.createElement("div"));1440 altInputWrap.className = "identity-alt-input-wrap";1441 const altInput = altInputWrap.appendChild(document.createElement("input"));1442 altInput.className = "identity-alt-input";1443 altInput.type = "email";1444 altInput.placeholder = "[email protected]";1445 altInput.setAttribute("autocomplete", "off");1446 const altConfirm = altInputWrap.appendChild(document.createElement("button"));1447 altConfirm.className = "identity-alt-confirm";1448 altConfirm.type = "button";1449 altConfirm.textContent = "✓";14501451 function fillCustomEmail() {1452 const v = altInput.value.trim();1453 if (!v) return;1454 options.onFillFields?.(v, "");1455 renderGenerator(v);1456 }14571458 altRow.addEventListener("click", () => {1459 altRow.style.display = "none";1460 altInputWrap.classList.add("open");1461 altInput.focus();1462 });1463 altConfirm.addEventListener("click", fillCustomEmail);1464 altInput.addEventListener("keydown", (e) => {1465 if (e.key === "Enter") { e.preventDefault(); fillCustomEmail(); }1466 });14671468 1469 1470 1471 1472 1473 if ((options.searchableEntries?.length ?? 0) > 0) {1474 const escapeRow = container.appendChild(document.createElement("div"));1475 escapeRow.className = "identity-escape-row";1476 escapeRow.textContent = "I already have an account →";1477 escapeRow.setAttribute("tabindex", "0");1478 escapeRow.addEventListener("click", () => renderList());1479 escapeRow.addEventListener("keydown", (e) => {1480 if (e.key === "Enter" || e.key === " ") { e.preventDefault(); renderList(); }1481 });1482 }1483 }14841485 function renderGenerator(filledEmail: string) {1486 container.innerHTML = "";1487 const sitePolicy = detectPasswordPolicy();14881489 const wrap = container.appendChild(document.createElement("div"));1490 wrap.className = "gen-view";14911492 1493 const hdrRow = wrap.appendChild(document.createElement("div"));1494 hdrRow.className = "domain-header";1495 const eyebrow2 = hdrRow.appendChild(document.createElement("div"));1496 eyebrow2.className = "domain-eyebrow";1497 eyebrow2.textContent = "NEW ACCOUNT";1498 const domName2 = hdrRow.appendChild(document.createElement("div"));1499 domName2.className = "domain-name";1500 domName2.textContent = options.domain ?? location.hostname.replace(/^www\./, "");15011502 1503 const conf = wrap.appendChild(document.createElement("div"));1504 conf.className = "gen-confirmed";1505 const confCheck = conf.appendChild(document.createElement("span"));1506 confCheck.className = "gen-confirmed-check";1507 confCheck.textContent = "✓";1508 const confVal = conf.appendChild(document.createElement("div"));1509 confVal.className = "gen-confirmed-val";1510 confVal.textContent = filledEmail;15111512 const lbl = wrap.appendChild(document.createElement("div"));1513 lbl.className = "gen-label";1514 lbl.textContent = "Generate a password";15151516 let currentPw = "";1517 const smartGen = createSmartGenerator({1518 policy: sitePolicy,1519 onChange: (pw) => { currentPw = pw; },1520 });1521 wrap.appendChild(smartGen.root);15221523 const fillBtn = wrap.appendChild(document.createElement("button"));1524 fillBtn.className = "gen-fill-btn";1525 fillBtn.type = "button";1526 fillBtn.textContent = "Copy & fill";1527 fillBtn.addEventListener("click", () => {1528 if (!currentPw) return;1529 options.onFillFields?.("", currentPw);1530 renderSaveOffer(filledEmail, currentPw);1531 });1532 }15331534 function renderSaveOffer(filledEmail: string, filledPassword: string) {1535 container.innerHTML = "";1536 const domain = options.domain ?? location.hostname.replace(/^www\./, "");15371538 const wrap = container.appendChild(document.createElement("div"));1539 wrap.className = "save-offer";15401541 const title = wrap.appendChild(document.createElement("div"));1542 title.className = "save-offer-title";1543 title.textContent = "Save this login to Peach?";15441545 function detailRow(label: string, value: string) {1546 const row = wrap.appendChild(document.createElement("div"));1547 row.className = "save-offer-row";1548 const lbl = row.appendChild(document.createElement("div"));1549 lbl.className = "save-offer-lbl";1550 lbl.textContent = label;1551 const val = row.appendChild(document.createElement("div"));1552 val.className = "save-offer-val";1553 val.textContent = value;1554 }15551556 detailRow("site", domain);1557 detailRow("email", filledEmail);1558 detailRow("password", "••••••••••••••••");15591560 const btns = wrap.appendChild(document.createElement("div"));1561 btns.className = "save-offer-btns";15621563 const saveBtn = btns.appendChild(document.createElement("button"));1564 saveBtn.className = "save-offer-save";1565 saveBtn.type = "button";1566 saveBtn.textContent = "Save";1567 saveBtn.addEventListener("click", async () => {1568 saveBtn.disabled = true;1569 saveBtn.textContent = "Saving…";1570 try {1571 const res = await chrome.runtime.sendMessage({1572 type: "ADD_ENTRY",1573 payload: { title: sTitle, url: sOrigin, username: filledEmail, password: filledPassword, type: "login" },1574 });1575 if ((res as { ok?: boolean }).ok) {1576 showSuccess(sTitle);1577 } else {1578 saveBtn.disabled = false;1579 saveBtn.textContent = "Save";1580 }1581 } catch { saveBtn.disabled = false; saveBtn.textContent = "Save"; }1582 });15831584 const skipBtn = btns.appendChild(document.createElement("button"));1585 skipBtn.className = "save-offer-skip";1586 skipBtn.type = "button";1587 skipBtn.textContent = "Not now";1588 skipBtn.addEventListener("click", () => { dismiss(true); });1589 }15901591 function renderList() {1592 container.innerHTML = "";1593 focusedIndex = -1;1594 searchInput = null;1595 currentMode = "list";15961597 const current = activeEntries();15981599 1600 1601 1602 const domHdr = document.createElement("div");1603 domHdr.className = "domain-header";1604 const headText = document.createElement("div");1605 headText.className = "domain-header-text";1606 const eyebrow = document.createElement("div");1607 eyebrow.className = "domain-eyebrow";1608 eyebrow.textContent = options.isSignup1609 ? "Sign up as"1610 : entries.length > 0 ? "Saved for this site" : "No saved login";1611 const domName = document.createElement("div");1612 domName.className = "domain-name";1613 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1614 headText.append(eyebrow, domName);1615 domHdr.appendChild(headText);16161617 if (!options.isSignup) {1618 const actions = document.createElement("div");1619 actions.className = "domain-header-actions";16201621 1622 1623 1624 if (silverPlatterOrigin) {1625 const backBtn = document.createElement("button");1626 backBtn.className = "domain-search-btn";1627 backBtn.type = "button";1628 backBtn.setAttribute("aria-label", "Back to suggested entry");1629 backBtn.title = "Back to suggested entry";1630 backBtn.innerHTML = backSvgStr();1631 backBtn.addEventListener("click", (e) => {1632 e.stopPropagation();1633 if (silverPlatterOrigin) renderSilverPlatter(silverPlatterOrigin);1634 });1635 actions.appendChild(backBtn);1636 }16371638 const addBtn = document.createElement("button");1639 addBtn.className = "domain-add-btn";1640 addBtn.type = "button";1641 addBtn.setAttribute("aria-label", "Create new entry");1642 addBtn.title = "Create new entry";1643 addBtn.textContent = "+";1644 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1645 actions.appendChild(addBtn);16461647 domHdr.appendChild(actions);1648 }16491650 container.appendChild(domHdr);16511652 1653 const sw = document.createElement("div"); sw.className = "search-wrap";1654 searchInput = document.createElement("input");1655 searchInput.className = "search";1656 searchInput.placeholder = entries.length > 0 ? "search for another entry…" : "search vault…";1657 searchInput.value = query;1658 searchInput.addEventListener("input", () => {1659 query = searchInput?.value ?? "";1660 renderList();1661 searchInput?.focus();1662 searchInput?.setSelectionRange(query.length, query.length);1663 });1664 sw.appendChild(searchInput);1665 container.appendChild(sw);16661667 1668 const results = document.createElement("div");1669 results.className = "results";1670 container.appendChild(results);16711672 if (current.length === 0 && entries.length > 0) {1673 1674 }16751676 for (let i = 0; i < current.length; i++) {1677 const e = current[i]!;1678 const entryEl = document.createElement("div");1679 entryEl.className = "entry";1680 entryEl.dataset.id = e.id;1681 entryEl.dataset.index = String(i);1682 entryEl.setAttribute("tabindex", "-1");16831684 entryEl.appendChild(makeEntryIcon(e.url));16851686 const info = document.createElement("div"); info.className = "entry-info";1687 const titleEl = document.createElement("div"); titleEl.className = "entry-title"; titleEl.textContent = e.title;1688 const subEl = document.createElement("div"); subEl.className = "entry-sub";1689 const domain = e.url ? getDomainFromUrl(e.url) : "";1690 subEl.textContent = domain || e.username || "";1691 info.append(titleEl, subEl);1692 entryEl.appendChild(info);16931694 if (e.hasTotp) {1695 const badge = document.createElement("span"); badge.className = "totp-badge"; badge.textContent = "TOTP";1696 entryEl.appendChild(badge);1697 }1698 if (e.hasPasskey) {1699 const badge = document.createElement("span"); badge.className = "passkey-badge"; badge.textContent = "passkey";1700 entryEl.appendChild(badge);1701 }17021703 entryEl.addEventListener("click", () => {1704 if (options.isSignup && options.onFillFields) {1705 1706 options.onFillFields(e.username ?? "", "");1707 dismiss();1708 } else {1709 onSelect(e.id);1710 dismiss();1711 }1712 });1713 results.appendChild(entryEl);1714 }17151716 1717 if (current.length > 0) {1718 results.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1719 }17201721 1722 const newEl = document.createElement("div");1723 newEl.className = "entry";1724 newEl.setAttribute("tabindex", "-1");1725 newEl.appendChild(makeEntryIcon(undefined, true));17261727 const newInfo = document.createElement("div"); newInfo.className = "entry-info";1728 const newTitle = document.createElement("div");1729 newTitle.className = "entry-title is-new";1730 newTitle.textContent = `New entry for ${sTitle}`;1731 const newSub = document.createElement("div");1732 newSub.className = "entry-sub";1733 newSub.textContent = sOrigin;1734 newInfo.append(newTitle, newSub);1735 newEl.appendChild(newInfo);1736 newEl.addEventListener("click", showCreateForm);1737 results.appendChild(newEl);17381739 1740 if (searchInput) {1741 requestAnimationFrame(() => {1742 searchInput?.focus();1743 1744 1745 searchInput?.setSelectionRange(query.length, query.length);1746 });1747 }1748 }17491750 function setFocused(idx: number) {1751 const all = container.querySelectorAll<HTMLElement>(".entry");1752 all.forEach((el, i) => el.classList.toggle("focused", i === idx));1753 focusedIndex = idx;1754 if (idx >= 0) (all[idx] as HTMLElement).scrollIntoView({ block: "nearest" });1755 }17561757 function attachIdentitySuggestions(g: HTMLDivElement, inp: HTMLInputElement, identities: SavedIdentity[], fieldType: "username" | "email"): void {1758 const typed = identities.filter(s => s.type === fieldType);1759 if (!typed.length) return;1760 let collapsed = false;1761 let suppressNextFocus = false;17621763 const list = g.appendChild(document.createElement("div"));1764 list.className = "identity-suggest-list";1765 list.style.display = "none";17661767 1768 const collapseRow = list.appendChild(document.createElement("div"));1769 collapseRow.className = "identity-filter-row";1770 collapseRow.style.justifyContent = "flex-end";1771 const collapseBtn = collapseRow.appendChild(document.createElement("button"));1772 collapseBtn.type = "button";1773 collapseBtn.className = "identity-collapse-btn";1774 collapseBtn.innerHTML = `<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 1L5 5L9 1"/></svg>`;1775 collapseBtn.addEventListener("mousedown", (e) => {1776 e.preventDefault();1777 collapsed = !collapsed;1778 collapseBtn.classList.toggle("is-collapsed", collapsed);1779 rowsWrapper.classList.toggle("is-collapsed", collapsed);1780 });17811782 const rowsWrapper = list.appendChild(document.createElement("div"));1783 rowsWrapper.className = "identity-rows";1784 const rows = rowsWrapper.appendChild(document.createElement("div"));1785 rows.className = "identity-rows-inner";17861787 function pick(value: string) {1788 inp.value = value;1789 list.style.display = "none";1790 suppressNextFocus = true;1791 inp.focus();1792 1793 1794 1795 1796 setTimeout(() => { suppressNextFocus = false; }, 120);1797 }17981799 function render() {1800 const q = inp.value.toLowerCase();1801 const filtered = typed.filter(s => !q || s.value.toLowerCase().includes(q)).slice(0, 8);1802 rows.innerHTML = "";1803 if (!filtered.length) { list.style.display = "none"; return; }1804 for (const s of filtered) {1805 const row = rows.appendChild(document.createElement("button"));1806 row.type = "button"; row.className = "identity-suggest-row";1807 const val = row.appendChild(document.createElement("span"));1808 val.className = "identity-suggest-val"; val.textContent = s.value;1809 const meta = row.appendChild(document.createElement("span"));1810 meta.className = "identity-suggest-meta"; meta.textContent = `${s.useCount}×`;1811 row.addEventListener("mousedown", (e) => { e.preventDefault(); pick(s.value); });1812 row.addEventListener("keydown", (e) => {1813 if (e.key === "ArrowDown") {1814 e.preventDefault();1815 (row.nextElementSibling as HTMLElement | null)?.focus();1816 } else if (e.key === "ArrowUp") {1817 e.preventDefault();1818 const prev = row.previousElementSibling as HTMLElement | null;1819 if (prev) prev.focus();1820 else inp.focus();1821 } else if (e.key === "Enter" || e.key === " ") {1822 e.preventDefault();1823 pick(s.value);1824 } else if (e.key === "Escape") {1825 e.preventDefault();1826 list.style.display = "none";1827 suppressNextFocus = true;1828 inp.focus();1829 }1830 });1831 row.addEventListener("blur", (e) => {1832 const rt = (e as FocusEvent).relatedTarget as Node | null;1833 if (rt && (rt === inp || list.contains(rt))) return;1834 setTimeout(() => { list.style.display = "none"; }, 150);1835 });1836 }1837 list.style.display = "";1838 }18391840 inp.addEventListener("focus", () => {1841 if (suppressNextFocus) { suppressNextFocus = false; return; }1842 render();1843 });1844 inp.addEventListener("input", render);1845 inp.addEventListener("keydown", (e) => {1846 if (list.style.display === "none") return;1847 if (e.key === "ArrowDown" && !collapsed) {1848 e.preventDefault();1849 (rows.firstElementChild as HTMLElement | null)?.focus();1850 } else if (e.key === "Escape") {1851 e.preventDefault();1852 list.style.display = "none";1853 }1854 });1855 inp.addEventListener("blur", (e) => {1856 const rt = (e as FocusEvent).relatedTarget as Node | null;1857 if (rt && list.contains(rt)) return;1858 1859 1860 1861 1862 if (rt === anchorEl) return;1863 setTimeout(() => { list.style.display = "none"; }, 150);1864 });1865 }18661867 async function showCreateForm() {1868 currentMode = "create";1869 container.innerHTML = "";18701871 1872 1873 1874 const statusRes = await chrome.runtime.sendMessage({ type: "GET_VAULT_STATUS" }).catch(() => null) as { unlocked?: boolean } | null;1875 if (!statusRes?.unlocked) {1876 renderLocked();1877 return;1878 }18791880 1881 1882 const sitePolicy = detectPasswordPolicy();18831884 1885 1886 let formIdentities: SavedIdentity[] = options.savedIdentities ?? [];1887 if (!formIdentities.length) {1888 try {1889 const idRes = await chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null) as { ok: boolean; data?: SavedIdentity[] } | null;1890 if (idRes?.ok && Array.isArray(idRes.data)) formIdentities = idRes.data;1891 } catch { }1892 }18931894 const wrap = document.createElement("div");1895 wrap.className = "create-form-wrap";18961897 1898 const head = document.createElement("div"); head.className = "create-head";1899 const backBtn = document.createElement("button"); backBtn.className = "back-btn";1900 backBtn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="7" height="12" viewBox="0 0 8 14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><path d="M6 1L1.5 7L6 13"/></svg>`;1901 backBtn.addEventListener("click", () => { currentMode = "list"; renderList(); });1902 const lbl = document.createElement("div"); lbl.className = "create-label"; lbl.textContent = "New entry";1903 head.append(backBtn, lbl);19041905 1906 const body = document.createElement("div"); body.className = "create-body";19071908 function fGroup(label: string): { g: HTMLDivElement; inp: HTMLInputElement } {1909 const g = document.createElement("div"); g.className = "f-group";1910 const l = document.createElement("div"); l.className = "f-label"; l.textContent = label;1911 const inp = document.createElement("input"); inp.className = "f-input";1912 g.append(l, inp); return { g, inp };1913 }19141915 1916 const tg = fGroup("title"); tg.inp.value = sTitle; tg.inp.placeholder = "e.g. Google";1917 body.appendChild(tg.g);19181919 1920 const ug = fGroup("website");1921 ug.inp.className = "f-input url-f"; ug.inp.value = sOrigin; ug.inp.placeholder = "https://";1922 if (loginSubdomain) {1923 const h = document.createElement("div"); h.className = "url-hint";1924 h.textContent = "⊘ Recognized sign-in subdomain"; ug.g.appendChild(h);1925 }1926 body.appendChild(ug.g);19271928 1929 const xg = fGroup("username");1930 xg.inp.value = preUsername && !preUsername.includes("@") ? preUsername : "";1931 xg.inp.placeholder = "johndoe";1932 xg.inp.setAttribute("autocomplete", "off");1933 if (formIdentities.length) attachIdentitySuggestions(xg.g, xg.inp, formIdentities, "username");1934 body.appendChild(xg.g);19351936 1937 const eg = fGroup("email");1938 (eg.inp as HTMLInputElement).type = "email";1939 eg.inp.value = preUsername && preUsername.includes("@") ? preUsername : "";1940 eg.inp.placeholder = "[email protected]";1941 eg.inp.setAttribute("autocomplete", "off");1942 if (formIdentities.length) attachIdentitySuggestions(eg.g, eg.inp, formIdentities, "email");1943 body.appendChild(eg.g);19441945 1946 1947 1948 const pg = fGroup("password");1949 pg.inp.remove(); 1950 let currentPassword = prePassword || "";1951 const smartGen = createSmartGenerator({1952 policy: sitePolicy,1953 initialPassword: prePassword || undefined,1954 onChange: (pw) => { currentPassword = pw; },1955 });1956 pg.g.appendChild(smartGen.root);1957 body.appendChild(pg.g);19581959 1960 const saveBtn = document.createElement("button"); saveBtn.className = "save-btn"; saveBtn.type = "button";1961 saveBtn.textContent = "Save entry";1962 const errEl = document.createElement("div"); errEl.className = "locked-error"; errEl.style.display = "none";1963 function showFormError(msg: string) { errEl.textContent = msg; errEl.style.display = ""; }1964 saveBtn.addEventListener("click", async () => {1965 const title = tg.inp.value.trim();1966 const pw = currentPassword.trim();1967 const username = xg.inp.value.trim();1968 const email = eg.inp.value.trim();1969 if (!title) {1970 tg.inp.style.borderColor = "rgba(220,70,60,0.5)"; tg.inp.focus();1971 showFormError("Entry needs a title");1972 return;1973 }1974 if (!pw) {1975 showFormError("Entry needs a password — tap regen to make one");1976 return;1977 }1978 errEl.style.display = "none";1979 saveBtn.disabled = true; saveBtn.textContent = "Saving…";1980 try {1981 const res = await chrome.runtime.sendMessage({1982 type: "ADD_ENTRY",1983 payload: { title, url: ug.inp.value.trim(), username, email: email || undefined, password: pw, type: "login" },1984 });1985 if ((res as { ok?: boolean }).ok) {1986 1987 1988 options.onFillFields?.(username || email, pw);1989 showSuccess(title);1990 } else {1991 const errMsg = (res as { error?: string }).error === "vault locked"1992 ? "Vault locked — open Peach to save"1993 : "Could not save entry";1994 showFormError(errMsg);1995 saveBtn.disabled = false; saveBtn.textContent = "Save entry";1996 }1997 } catch { showFormError("Could not reach Peach"); saveBtn.disabled = false; saveBtn.textContent = "Save entry"; }1998 });1999 body.appendChild(saveBtn);2000 body.appendChild(errEl);20012002 wrap.append(head, body);2003 container.appendChild(wrap);2004 requestAnimationFrame(() => { tg.inp.focus(); tg.inp.select(); });2005 }20062007 function showSuccess(title: string) {2008 currentMode = "success";2009 container.innerHTML = "";2010 const wrap = document.createElement("div"); wrap.className = "success-wrap";2011 const ring = document.createElement("div"); ring.className = "success-ring";2012 ring.innerHTML = checkSvgStr();2013 const t = document.createElement("div"); t.className = "success-text"; t.textContent = `${title} saved`;2014 const s = document.createElement("div"); s.className = "success-sub"; s.textContent = sOrigin;2015 wrap.append(ring, t, s);2016 container.appendChild(wrap);2017 setTimeout(() => dismiss(), 1600);2018 }20192020 function flashActionBtn(btn: HTMLButtonElement) {2021 btn.classList.add("flashed");2022 setTimeout(() => btn.classList.remove("flashed"), 700);2023 }20242025 2026 2027 function flashCopyError(btn: HTMLButtonElement) {2028 const original = btn.textContent ?? "";2029 btn.textContent = "Blocked";2030 btn.classList.add("flashed");2031 setTimeout(() => {2032 btn.classList.remove("flashed");2033 if (btn.isConnected) btn.textContent = original;2034 }, 1200);2035 }20362037 function renderSilverPlatter(entry: SelectorEntry) {2038 container.innerHTML = "";2039 searchInput = null;2040 focusedIndex = -1;2041 currentMode = "silver-platter";2042 silverPlatterOrigin = entry;20432044 const domHdr = document.createElement("div");2045 domHdr.className = "domain-header";2046 const headText = document.createElement("div");2047 headText.className = "domain-header-text";2048 const eyebrow = document.createElement("div");2049 eyebrow.className = "domain-eyebrow";2050 eyebrow.textContent = "Saved for this site";2051 const domName = document.createElement("div");2052 domName.className = "domain-name";2053 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");2054 headText.append(eyebrow, domName);2055 domHdr.appendChild(headText);2056 if (!options.isSignup) {2057 const actions = document.createElement("div");2058 actions.className = "domain-header-actions";20592060 2061 2062 2063 const searchBtn = document.createElement("button");2064 searchBtn.className = "domain-search-btn";2065 searchBtn.type = "button";2066 searchBtn.setAttribute("aria-label", "Search for a different entry");2067 searchBtn.title = "Search for a different entry";2068 searchBtn.innerHTML = searchSvgStr();2069 searchBtn.addEventListener("click", (e) => {2070 e.stopPropagation();2071 query = "";2072 renderList();2073 });2074 actions.appendChild(searchBtn);20752076 const addBtn = document.createElement("button");2077 addBtn.className = "domain-add-btn";2078 addBtn.type = "button";2079 addBtn.setAttribute("aria-label", "Create new entry");2080 addBtn.title = "Create new entry";2081 addBtn.textContent = "+";2082 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });2083 actions.appendChild(addBtn);20842085 domHdr.appendChild(actions);2086 }2087 container.appendChild(domHdr);20882089 const platter = document.createElement("div");2090 platter.className = "silver-platter";20912092 const titleEl = document.createElement("div");2093 titleEl.className = "sp-title";2094 titleEl.textContent = entry.title;2095 platter.appendChild(titleEl);20962097 if (entry.email) {2098 const emailEl = document.createElement("div");2099 emailEl.className = "sp-identity-row";2100 const emailLbl = document.createElement("span");2101 emailLbl.className = "sp-identity-label";2102 emailLbl.textContent = "email";2103 const emailVal = document.createElement("span");2104 emailVal.className = "sp-username";2105 emailVal.textContent = entry.email;2106 emailEl.append(emailLbl, emailVal);2107 platter.appendChild(emailEl);2108 }21092110 if (entry.username) {2111 const userEl = document.createElement("div");2112 userEl.className = "sp-identity-row";2113 const userLbl = document.createElement("span");2114 userLbl.className = "sp-identity-label";2115 userLbl.textContent = entry.username.includes("@") ? "email" : "username";2116 const userVal = document.createElement("span");2117 userVal.className = "sp-username";2118 userVal.textContent = entry.username;2119 userEl.append(userLbl, userVal);2120 platter.appendChild(userEl);2121 }21222123 const fillBtn = document.createElement("button");2124 fillBtn.className = "sp-fill-btn";2125 fillBtn.type = "button";2126 fillBtn.textContent = "Fill credentials";2127 fillBtn.addEventListener("click", () => {2128 if (fillBtn.disabled) return;2129 fillBtn.disabled = true;2130 fillBtn.classList.add("filled");2131 fillBtn.innerHTML = checkSvgStr();2132 2133 2134 2135 2136 onSelect(entry.id);2137 setTimeout(() => dismiss(), 400);2138 });2139 platter.appendChild(fillBtn);21402141 const actionsGroup = document.createElement("div");2142 actionsGroup.className = "sp-actions-group";2143 const actionsLabel = document.createElement("div");2144 actionsLabel.className = "sp-actions-label";2145 actionsLabel.textContent = "Copy";2146 actionsGroup.appendChild(actionsLabel);21472148 const actions = document.createElement("div");2149 actions.className = "sp-actions";2150 actionsGroup.appendChild(actions);21512152 if (entry.email) {2153 const copyEmail = document.createElement("button");2154 copyEmail.className = "sp-action-btn";2155 copyEmail.type = "button";2156 copyEmail.title = "Copy email";2157 copyEmail.textContent = "Email";2158 copyEmail.addEventListener("click", async (e) => {2159 e.stopPropagation();2160 let alreadyWritten = false;2161 try {2162 await navigator.clipboard.writeText(entry.email!);2163 alreadyWritten = true;2164 } catch (err) {2165 console.warn("[Peach] clipboard write denied:", err);2166 }2167 const resp = await chrome.runtime.sendMessage({2168 type: "COPY",2169 payload: { text: entry.email, label: "Email", alreadyWritten },2170 }).catch(() => null) as { ok?: boolean } | null;2171 if (alreadyWritten || resp?.ok) flashActionBtn(copyEmail);2172 else flashCopyError(copyEmail);2173 });2174 actions.appendChild(copyEmail);2175 }21762177 const copyU = document.createElement("button");2178 copyU.className = "sp-action-btn";2179 copyU.type = "button";2180 const usernameIsEmail = entry.username?.includes("@") ?? false;2181 copyU.title = usernameIsEmail ? "Copy email" : "Copy username";2182 copyU.textContent = usernameIsEmail ? "Email" : "Username";2183 copyU.disabled = !entry.username;2184 copyU.addEventListener("click", async (e) => {2185 e.stopPropagation();2186 if (!entry.username) return;2187 let alreadyWritten = false;2188 try {2189 await navigator.clipboard.writeText(entry.username);2190 alreadyWritten = true;2191 } catch (err) {2192 console.warn("[Peach] clipboard write denied:", err);2193 }2194 const resp = await chrome.runtime.sendMessage({2195 type: "COPY",2196 payload: { text: entry.username, label: entry.username.includes("@") ? "Email" : "Username", alreadyWritten },2197 }).catch(() => null) as { ok?: boolean } | null;2198 if (alreadyWritten || resp?.ok) flashActionBtn(copyU);2199 else flashCopyError(copyU);2200 });2201 actions.appendChild(copyU);22022203 const copyP = document.createElement("button");2204 copyP.className = "sp-action-btn";2205 copyP.type = "button";2206 copyP.title = "Copy password";2207 copyP.textContent = "Password";2208 copyP.addEventListener("click", async (e) => {2209 e.stopPropagation();2210 const resp = await chrome.runtime.sendMessage({2211 type: "GET_ENTRY_FOR_FILL",2212 payload: { id: entry.id },2213 }).catch(() => null) as { ok: boolean; data?: { password?: string } } | null;2214 if (!resp?.ok || !resp.data?.password) return;2215 let alreadyWritten = false;2216 try {2217 await navigator.clipboard.writeText(resp.data.password);2218 alreadyWritten = true;2219 } catch (err) {2220 console.warn("[Peach] clipboard write denied:", err);2221 }2222 const copyResp = await chrome.runtime.sendMessage({2223 type: "COPY",2224 payload: { text: resp.data.password, label: "Password", alreadyWritten },2225 }).catch(() => null) as { ok?: boolean } | null;2226 if (alreadyWritten || copyResp?.ok) flashActionBtn(copyP);2227 else flashCopyError(copyP);2228 });2229 actions.appendChild(copyP);22302231 let trayEl: HTMLDivElement | null = null;2232 let trayInterval: ReturnType<typeof setInterval> | null = null;22332234 function closeTray() {2235 if (trayInterval) { clearInterval(trayInterval); trayInterval = null; }2236 trayEl?.remove();2237 trayEl = null;2238 }2239 2240 2241 cleanupHooks.push(closeTray);22422243 async function openTOTPTray() {2244 2245 2246 2247 2248 async function fetchCode(): Promise<{ code: string; remaining: number } | null> {2249 const r = await chrome.runtime.sendMessage({2250 type: "GET_ENTRY_FOR_FILL",2251 payload: { id: entry.id },2252 }).catch(() => null) as { ok: boolean; data?: { totpCode?: string; totpRemaining?: number } } | null;2253 if (!r?.ok || !r.data?.totpCode) return null;2254 return { code: r.data.totpCode, remaining: r.data.totpRemaining ?? 30 };2255 }2256 let current = await fetchCode();2257 if (!current) return;22582259 trayEl = document.createElement("div");2260 trayEl.className = "sp-tray";22612262 const label = document.createElement("span");2263 label.className = "sp-tray-label";2264 label.textContent = "2FA";2265 trayEl.appendChild(label);22662267 const codeEl = document.createElement("div");2268 codeEl.className = "sp-totp-code";2269 trayEl.appendChild(codeEl);22702271 const ringNs = "http://www.w3.org/2000/svg";2272 const ring = document.createElementNS(ringNs, "svg");2273 ring.setAttribute("class", "sp-totp-ring");2274 ring.setAttribute("viewBox", "0 0 24 24");2275 const trackC = document.createElementNS(ringNs, "circle");2276 trackC.setAttribute("class", "ring-track");2277 trackC.setAttribute("cx", "12"); trackC.setAttribute("cy", "12"); trackC.setAttribute("r", "10");2278 trackC.setAttribute("fill", "none"); trackC.setAttribute("stroke-width", "2");2279 const fillC = document.createElementNS(ringNs, "circle");2280 fillC.setAttribute("class", "ring-fill");2281 fillC.setAttribute("cx", "12"); fillC.setAttribute("cy", "12"); fillC.setAttribute("r", "10");2282 fillC.setAttribute("fill", "none"); fillC.setAttribute("stroke-width", "2");2283 fillC.setAttribute("stroke-linecap", "round");2284 fillC.setAttribute("stroke-dasharray", "62.83");2285 ring.append(trackC, fillC);2286 trayEl.appendChild(ring);22872288 const copyBtn = document.createElement("button");2289 copyBtn.className = "sp-totp-copy";2290 copyBtn.type = "button";2291 copyBtn.textContent = "Copy";2292 trayEl.appendChild(copyBtn);22932294 function render() {2295 const { code, remaining } = current!;2296 2297 codeEl.textContent = code.length === 62298 ? `${code.slice(0, 3)} ${code.slice(3)}`2299 : code;2300 2301 2302 const fraction = (30 - remaining) / 30;2303 fillC.setAttribute("stroke-dashoffset", String(62.83 * fraction));2304 }2305 render();2306 trayInterval = setInterval(async () => {2307 if (!current) return;2308 current = { code: current.code, remaining: current.remaining - 1 };2309 2310 if (current.remaining <= 0) {2311 const next = await fetchCode();2312 current = next ?? { code: current.code, remaining: 30 };2313 }2314 render();2315 }, 1000);23162317 copyBtn.addEventListener("click", async (e) => {2318 e.stopPropagation();2319 const code = current?.code;2320 if (!code) return;2321 let alreadyWritten = false;2322 try {2323 await navigator.clipboard.writeText(code);2324 alreadyWritten = true;2325 } catch (err) {2326 console.warn("[Peach] clipboard write denied:", err);2327 }2328 const resp = await chrome.runtime.sendMessage({2329 type: "COPY",2330 payload: { text: code, label: "TOTP", alreadyWritten },2331 }).catch(() => null) as { ok?: boolean } | null;2332 copyBtn.textContent = alreadyWritten || resp?.ok ? "Copied" : "Blocked";2333 setTimeout(() => { if (copyBtn.isConnected) copyBtn.textContent = "Copy"; }, 1200);2334 });23352336 platter.appendChild(trayEl);2337 }23382339 const editBtn = document.createElement("button");2340 editBtn.className = "sp-action-btn sp-action-edit";2341 editBtn.type = "button";2342 editBtn.title = "Edit entry";2343 editBtn.textContent = "Edit";2344 editBtn.addEventListener("click", (e) => {2345 e.stopPropagation();2346 closeTray();2347 void renderInlineEdit(entry);2348 });2349 actions.appendChild(editBtn);23502351 2352 2353 2354 if (entry.hasTotp) void openTOTPTray();23552356 platter.appendChild(actionsGroup);2357 container.appendChild(platter);2358 }23592360 236123622363236423652366 async function renderInlineEdit(summary: SelectorEntry) {2367 container.innerHTML = "";2368 const wrap = document.createElement("div");2369 wrap.className = "create-form-wrap";23702371 const head = document.createElement("div");2372 head.className = "create-head";2373 const back = document.createElement("button");2374 back.className = "back-btn";2375 back.type = "button";2376 back.title = "Cancel";2377 back.innerHTML = `<svg width="11" height="11" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"><path d="M7 2L3 5.5L7 9"/></svg>`;2378 back.addEventListener("click", () => renderSilverPlatter(summary));2379 head.appendChild(back);2380 const headLbl = document.createElement("div");2381 headLbl.className = "create-label";2382 headLbl.textContent = "Edit entry";2383 head.appendChild(headLbl);2384 wrap.appendChild(head);23852386 const body = document.createElement("div");2387 body.className = "create-body";23882389 2390 const loading = document.createElement("div");2391 loading.className = "empty-hint";2392 loading.textContent = "loading…";2393 body.appendChild(loading);2394 wrap.appendChild(body);2395 container.appendChild(wrap);23962397 const [res, idRes] = await Promise.all([2398 2399 2400 chrome.runtime.sendMessage({2401 type: "GET_ENTRY_FOR_EDIT",2402 payload: { id: summary.id },2403 }).catch(() => null),2404 chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null),2405 ]);2406 const entryRes = res as { ok: boolean; data?: { title?: string; username?: string; email?: string; password?: string; url?: string; totp?: string; notes?: string } } | null;2407 const editIdentities: SavedIdentity[] = (idRes as { ok?: boolean; data?: SavedIdentity[] } | null)?.data ?? [];24082409 if (!entryRes || !entryRes.ok || !entryRes.data) {2410 loading.textContent = "couldn't load this entry. try again from the popup.";2411 return;2412 }2413 body.innerHTML = "";24142415 function field(label: string, value: string, type: "text" | "password" = "text"): { g: HTMLDivElement; inp: HTMLInputElement } {2416 const group = document.createElement("div");2417 group.className = "f-group";2418 const lbl = document.createElement("div");2419 lbl.className = "f-label";2420 lbl.textContent = label;2421 const input = document.createElement("input");2422 input.className = "f-input";2423 input.type = type;2424 input.value = value;2425 input.autocomplete = "off";2426 group.append(lbl, input);2427 body.appendChild(group);2428 return { g: group, inp: input };2429 }24302431 const titleInput = field("title", entryRes.data.title ?? "").inp;2432 const urlInput = field("url", entryRes.data.url ?? "").inp;2433 urlInput.classList.add("url-f");2434 const usernameLabel = (entryRes.data.username ?? "").includes("@") ? "email" : "username";2435 const { g: usernameGroup, inp: usernameInput } = field(usernameLabel, entryRes.data.username ?? "");2436 if (editIdentities.length) attachIdentitySuggestions(usernameGroup, usernameInput, editIdentities, "username");2437 const { g: emailGroup, inp: emailInput } = field("email", entryRes.data.email ?? "");2438 if (editIdentities.length) attachIdentitySuggestions(emailGroup, emailInput, editIdentities, "email");24392440 2441 const pwGroup = document.createElement("div");2442 pwGroup.className = "f-group";2443 const pwLbl = document.createElement("div");2444 pwLbl.className = "f-label";2445 pwLbl.textContent = "password";2446 const pwRow = document.createElement("div");2447 pwRow.className = "f-row";2448 const pwInput = document.createElement("input");2449 pwInput.className = "f-input";2450 pwInput.type = "password";2451 pwInput.value = entryRes.data.password ?? "";2452 pwInput.autocomplete = "new-password";2453 const revealBtn = document.createElement("button");2454 revealBtn.className = "gen-btn";2455 revealBtn.type = "button";2456 revealBtn.textContent = "show";2457 revealBtn.addEventListener("click", () => {2458 const reveal = pwInput.type === "password";2459 pwInput.type = reveal ? "text" : "password";2460 revealBtn.textContent = reveal ? "hide" : "show";2461 });2462 pwRow.append(pwInput, revealBtn);2463 const editSmartGen = createSmartGenerator({ policy: detectPasswordPolicy(), onChange: (pw) => { pwInput.value = pw; } });2464 editSmartGen.root.style.display = "none";2465 let editGenVisible = false;2466 const genToggleBtn = document.createElement("button");2467 genToggleBtn.className = "gen-toggle-link";2468 genToggleBtn.type = "button";2469 genToggleBtn.textContent = "⚙ generate";2470 genToggleBtn.addEventListener("click", () => {2471 editGenVisible = !editGenVisible;2472 pwRow.style.display = editGenVisible ? "none" : "";2473 editSmartGen.root.style.display = editGenVisible ? "" : "none";2474 genToggleBtn.textContent = editGenVisible ? "☰ hide generator" : "⚙ generate";2475 });2476 pwGroup.append(pwLbl, pwRow, genToggleBtn, editSmartGen.root);2477 body.appendChild(pwGroup);24782479 const totpInput = field("2fa secret", entryRes.data.totp ?? "").inp;24802481 2482 const notesGroup = document.createElement("div");2483 notesGroup.className = "f-group";2484 const notesLbl = document.createElement("div");2485 notesLbl.className = "f-label";2486 notesLbl.textContent = "notes";2487 const notesInput = document.createElement("textarea");2488 notesInput.className = "f-input";2489 notesInput.rows = 3;2490 notesInput.value = entryRes.data.notes ?? "";2491 notesInput.style.fontFamily = "Inter, sans-serif";2492 notesInput.style.resize = "vertical";2493 notesGroup.append(notesLbl, notesInput);2494 body.appendChild(notesGroup);24952496 2497 const actionsRow = document.createElement("div");2498 actionsRow.className = "f-row";2499 const saveBtn = document.createElement("button");2500 saveBtn.className = "save-btn";2501 saveBtn.type = "button";2502 saveBtn.textContent = "Save changes";2503 saveBtn.style.flex = "1";2504 const cancelBtn = document.createElement("button");2505 cancelBtn.className = "gen-btn";2506 cancelBtn.type = "button";2507 cancelBtn.textContent = "cancel";2508 cancelBtn.addEventListener("click", () => renderSilverPlatter(summary));2509 actionsRow.append(saveBtn, cancelBtn);2510 body.appendChild(actionsRow);25112512 saveBtn.addEventListener("click", async () => {2513 saveBtn.disabled = true;2514 const originalLabel = saveBtn.textContent;2515 saveBtn.textContent = "Saving…";2516 const patch: Record<string, unknown> = {2517 title: titleInput.value.trim(),2518 url: urlInput.value.trim(),2519 username: usernameInput.value.trim(),2520 email: emailInput.value.trim() || undefined,2521 password: pwInput.value,2522 totp: totpInput.value.trim(),2523 notes: notesInput.value,2524 };2525 const updateRes = (await chrome.runtime.sendMessage({2526 type: "UPDATE_ENTRY",2527 payload: { id: summary.id, patch },2528 }).catch(() => null)) as { ok: boolean; error?: string } | null;2529 if (!updateRes?.ok) {2530 saveBtn.disabled = false;2531 saveBtn.textContent = originalLabel;2532 const err = document.createElement("div");2533 err.className = "empty-hint";2534 err.style.color = "color-mix(in srgb, #e55 70%, transparent)";2535 err.textContent = updateRes?.error ?? "Couldn't save. Try the popup.";2536 body.appendChild(err);2537 setTimeout(() => err.remove(), 3000);2538 return;2539 }2540 2541 const refreshed: SelectorEntry = {2542 id: summary.id,2543 title: patch.title as string,2544 username: patch.username as string,2545 email: patch.email as string | undefined,2546 url: patch.url as string,2547 hasTotp: Boolean(patch.totp),2548 hasPasskey: summary.hasPasskey,2549 };2550 renderSilverPlatter(refreshed);2551 });25522553 queueMicrotask(() => titleInput.focus());2554 }25552556 function renderLocked() {2557 container.innerHTML = "";25582559 2560 const domHdr = document.createElement("div");2561 domHdr.className = "domain-header";2562 const eyebrow = document.createElement("div");2563 eyebrow.className = "domain-eyebrow";2564 eyebrow.textContent = "vault locked";2565 const domName = document.createElement("div");2566 domName.className = "domain-name";2567 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");2568 domHdr.append(eyebrow, domName);2569 container.appendChild(domHdr);25702571 const wrap = document.createElement("div");2572 wrap.className = "locked-wrap";25732574 2575 const head = document.createElement("div"); head.className = "locked-head";2576 const icon = document.createElement("div"); icon.className = "locked-icon";2577 icon.innerHTML = keySvgStr();2578 const title = document.createElement("div"); title.className = "locked-title";2579 title.textContent = "unlock to autofill";2580 head.append(icon, title);25812582 2583 2584 2585 2586 2587 2588 2589 2590 const sub = document.createElement("div");2591 sub.className = "locked-sub";2592 sub.textContent = "Unlock in Peach — your master password is never typed on this page.";25932594 const openBtn = document.createElement("button");2595 openBtn.className = "locked-btn";2596 openBtn.type = "button";2597 openBtn.textContent = "Open Peach to unlock";2598 openBtn.addEventListener("click", () => {2599 chrome.runtime.sendMessage({ type: "OPEN_POPUP" }).catch(() => {});2600 openBtn.textContent = "opening Peach…";2601 openBtn.disabled = true;2602 2603 2604 setTimeout(() => {2605 if (openBtn.isConnected) {2606 openBtn.textContent = "Open Peach to unlock";2607 openBtn.disabled = false;2608 }2609 }, 2500);2610 });26112612 wrap.append(head, sub, openBtn);2613 container.appendChild(wrap);2614 }26152616 function handleKeyDown(e: KeyboardEvent) {2617 if (options.locked) {2618 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2619 return;2620 }2621 if (currentMode === "create" || currentMode === "success" || currentMode === "silver-platter") {2622 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2623 return;2624 }2625 const allEntryEls = container.querySelectorAll(".entry:not(.empty-state)");2626 const count = allEntryEls.length;2627 if (document.activeElement === searchInput) {2628 if (e.key === "Escape" || e.key === "Tab") { e.preventDefault(); dismiss(true); return; }2629 if (count === 0) return;2630 if (!["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) return;2631 }2632 if (count === 0) return;2633 switch (e.key) {2634 case "ArrowDown": e.preventDefault(); setFocused(focusedIndex < count - 1 ? focusedIndex + 1 : 0); break;2635 case "ArrowUp": e.preventDefault(); setFocused(focusedIndex > 0 ? focusedIndex - 1 : count - 1); break;2636 case "Enter": {2637 if (focusedIndex >= 0) {2638 const el = allEntryEls[focusedIndex] as HTMLElement;2639 const id = el.dataset.id;2640 if (id) { onSelect(id); dismiss(); }2641 else if (el.classList.contains("is-new") || !id) {2642 2643 showCreateForm();2644 }2645 }2646 break;2647 }2648 case "Escape": case "Tab": e.preventDefault(); dismiss(true); break;2649 }2650 }26512652 document.addEventListener("keydown", handleKeyDown);26532654 2655 2656 2657 2658 2659 const silverPlatterTypeHandler = (e: KeyboardEvent) => {2660 if (currentMode !== "silver-platter") return;2661 if (e.ctrlKey || e.metaKey || e.altKey) return;2662 if (e.key.length !== 1) return;2663 e.preventDefault();2664 e.stopImmediatePropagation();2665 query = e.key;2666 renderList();2667 };2668 document.addEventListener("keydown", silverPlatterTypeHandler, true);2669 cleanupHooks.push(() => document.removeEventListener("keydown", silverPlatterTypeHandler, true));26702671 (modalAncestor ?? document.body).appendChild(host);26722673 function updatePosition() {2674 const r = anchorEl.getBoundingClientRect();2675 host.style.top = `${r.bottom + (modalAncestor ? 0 : window.scrollY) + 5}px`;2676 host.style.left = `${r.left + (modalAncestor ? 0 : window.scrollX)}px`;2677 host.style.width = `${popupWidth}px`;2678 }2679 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);26802681 if (options.locked) {2682 renderLocked();2683 } else if (options.isSignup && options.savedIdentities) {2684 2685 2686 renderIdentityHelper();2687 } else if (entries.length === 1 && !options.isSignup) {2688 2689 2690 renderSilverPlatter(entries[0]!);2691 } else {2692 renderList();2693 }26942695 let exitScheduled = false;2696 function dismiss(userAction = false) {2697 2698 2699 2700 if (exitScheduled) return;2701 exitScheduled = true;2702 2703 2704 2705 stopObserving();2706 document.removeEventListener("click", outsideClick, { capture: true });2707 document.removeEventListener("keydown", handleKeyDown);2708 for (const cleanup of cleanupHooks) {2709 try { cleanup(); } catch { }2710 }2711 if (userAction) options.onDismiss?.();2712 container.classList.add("is-exiting");2713 setTimeout(() => host.remove(), 130);2714 }27152716 function outsideClick(ev: MouseEvent) {2717 const path = ev.composedPath();2718 2719 2720 2721 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);2722 }2723 2724 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);27252726 return dismiss;2727}27282729export function showTOTPSelector(2730 anchorEl: HTMLInputElement,2731 entries: SelectorEntry[],2732 onFill: (id: string) => void,2733 options: { domain?: string; onDismiss?: () => void } = {}2734): () => void {2735 const host = document.createElement("div");2736 host.style.cssText = "position: absolute; z-index: 2147483647;";2737 host.style.setProperty("--peach-accent", accentHex);2738 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));2739 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));2740 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));2741 const shadow = host.attachShadow({ mode: "closed" });27422743 const style = shadow.appendChild(document.createElement("style"));2744 style.textContent = SELECTOR_STYLES;27452746 const rect = anchorEl.getBoundingClientRect();2747 host.style.top = `${rect.bottom + window.scrollY + 5}px`;2748 host.style.left = `${rect.left + window.scrollX}px`;2749 const popupWidth = Math.min(Math.max(rect.width, 300), 360);2750 host.style.width = `${popupWidth}px`;27512752 const container = shadow.appendChild(document.createElement("div"));2753 container.className = "peach-inline-popup";2754 container.setAttribute("data-theme", popupTheme);27552756 const domain = options.domain ?? location.hostname.replace(/^www\./, "");2757 const current = entries.filter((entry) => entry.hasTotp);2758 let focusedIndex = current.length === 1 ? 0 : -1;27592760 function updatePosition() {2761 const r = anchorEl.getBoundingClientRect();2762 host.style.top = `${r.bottom + window.scrollY + 5}px`;2763 host.style.left = `${r.left + window.scrollX}px`;2764 host.style.width = `${popupWidth}px`;2765 }27662767 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);27682769 function choose(entry: SelectorEntry) {2770 onFill(entry.id);2771 dismiss();2772 }27732774 function render() {2775 container.innerHTML = "";27762777 const domHdr = document.createElement("div");2778 domHdr.className = "domain-header";2779 const headText = document.createElement("div");2780 headText.className = "domain-header-text";2781 const eyebrow = document.createElement("div");2782 eyebrow.className = "domain-eyebrow";2783 eyebrow.textContent = "2FA code";2784 const domName = document.createElement("div");2785 domName.className = "domain-name";2786 domName.textContent = domain;2787 headText.append(eyebrow, domName);2788 domHdr.appendChild(headText);2789 container.appendChild(domHdr);27902791 if (current.length === 1) {2792 const entry = current[0]!;2793 const platter = document.createElement("div");2794 platter.className = "silver-platter";27952796 const title = document.createElement("div");2797 title.className = "sp-title";2798 title.textContent = entry.title;2799 platter.appendChild(title);28002801 const sub = document.createElement("div");2802 sub.className = "sp-username";2803 sub.textContent = entry.username ?? entry.email ?? entry.url ?? "";2804 platter.appendChild(sub);28052806 const fill = document.createElement("button");2807 fill.className = "sp-fill-btn";2808 fill.type = "button";2809 fill.textContent = "Fill 2FA code";2810 fill.addEventListener("click", () => choose(entry));2811 platter.appendChild(fill);28122813 container.appendChild(platter);2814 requestAnimationFrame(() => fill.focus({ preventScroll: true }));2815 return;2816 }28172818 const results = document.createElement("div");2819 results.className = "results";2820 container.appendChild(results);28212822 for (let i = 0; i < current.length; i++) {2823 const entry = current[i]!;2824 const row = document.createElement("div");2825 row.className = `entry${i === focusedIndex ? " focused" : ""}`;2826 row.dataset.index = String(i);2827 row.setAttribute("tabindex", "-1");28282829 const icon = document.createElement("div");2830 icon.className = "entry-icon";2831 icon.innerHTML = keySvgStr();2832 row.appendChild(icon);2833 const info = document.createElement("div");2834 info.className = "entry-info";2835 const title = document.createElement("div");2836 title.className = "entry-title";2837 title.textContent = entry.title;2838 const sub = document.createElement("div");2839 sub.className = "entry-sub";2840 sub.textContent = entry.username ?? entry.email ?? entry.url ?? "";2841 info.append(title, sub);2842 row.appendChild(info);28432844 const badge = document.createElement("span");2845 badge.className = "totp-badge";2846 badge.textContent = "Fill";2847 row.appendChild(badge);2848 row.addEventListener("click", () => choose(entry));2849 results.appendChild(row);2850 }2851 }28522853 function setFocused(index: number) {2854 focusedIndex = index;2855 container.querySelectorAll(".entry").forEach((el, i) => {2856 el.classList.toggle("focused", i === focusedIndex);2857 if (i === focusedIndex) (el as HTMLElement).scrollIntoView({ block: "nearest" });2858 });2859 }28602861 function handleKeyDown(e: KeyboardEvent) {2862 if (e.key === "Escape" || e.key === "Tab") {2863 e.preventDefault();2864 dismiss(true);2865 return;2866 }2867 if (current.length === 0) return;2868 if (e.key === "Enter") {2869 e.preventDefault();2870 choose(current[Math.max(0, focusedIndex)]!);2871 return;2872 }2873 if (current.length === 1) return;2874 if (e.key === "ArrowDown") {2875 e.preventDefault();2876 setFocused(focusedIndex < current.length - 1 ? focusedIndex + 1 : 0);2877 } else if (e.key === "ArrowUp") {2878 e.preventDefault();2879 setFocused(focusedIndex > 0 ? focusedIndex - 1 : current.length - 1);2880 }2881 }28822883 let exitScheduled = false;2884 function dismiss(userAction = false) {2885 if (exitScheduled) return;2886 exitScheduled = true;2887 stopObserving();2888 document.removeEventListener("click", outsideClick, { capture: true });2889 document.removeEventListener("keydown", handleKeyDown);2890 if (userAction) options.onDismiss?.();2891 container.classList.add("is-exiting");2892 setTimeout(() => host.remove(), 130);2893 }28942895 function outsideClick(ev: MouseEvent) {2896 const path = ev.composedPath();2897 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);2898 }28992900 document.addEventListener("keydown", handleKeyDown);2901 document.body.appendChild(host);2902 render();2903 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);29042905 return dismiss;2906}29072908export interface CardSelectorEntry {2909 id: string;2910 title: string;2911 cardholderName?: string;2912 last4?: string;2913 expMonth?: string;2914 expYear?: string;2915 network?: import("../shared/types").CardNetwork;2916}29172918interface CardSelectorOptions {2919 domain?: string;2920 2921 onFill: (entry: import("../shared/types").VaultEntry) => void;2922 2923 onDismiss?: () => void;2924}29252926292729282929293029312932export function showPasskeyProGate(): void {2933 const domain = location.hostname.replace(/^www\./, "");29342935 const host = document.createElement("div");2936 host.setAttribute("data-peach-passkey-gate", "1");2937 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483646;pointer-events:none;";2938 const shadow = host.attachShadow({ mode: "closed" });29392940 const style = document.createElement("style");2941 style.textContent = `2942 :host { all: initial; }2943 .gate-wrap {2944 position: fixed;2945 top: 50%;2946 left: 50%;2947 transform: translate(-50%, -50%);2948 width: 280px;2949 pointer-events: auto;2950 animation: g-in 220ms cubic-bezier(0.16,1,0.3,1) both;2951 }2952 @keyframes g-in {2953 from { opacity:0; transform: translate(-50%,-52%); }2954 to { opacity:1; transform: translate(-50%,-50%); }2955 }2956 .gate-wrap.is-exiting {2957 animation: g-out 130ms ease-in forwards;2958 }2959 @keyframes g-out {2960 to { opacity:0; transform: translate(-50%,-52%); }2961 }2962 .gate {2963 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2964 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2965 border-radius: 12px;2966 box-shadow: 0 12px 48px rgba(0,0,0,0.75);2967 padding: 16px;2968 font-family: Inter, sans-serif;2969 }2970 .gate-header {2971 display: flex;2972 align-items: center;2973 gap: 7px;2974 margin-bottom: 12px;2975 padding-bottom: 10px;2976 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2977 }2978 .gate-domain {2979 font-size: 12px;2980 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2981 font-family: "IBM Plex Mono", monospace;2982 overflow: hidden;2983 text-overflow: ellipsis;2984 white-space: nowrap;2985 }2986 .gate-title {2987 font-size: 14px;2988 font-weight: 500;2989 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2990 margin-bottom: 6px;2991 }2992 .gate-subtitle {2993 font-size: 12px;2994 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.45)"};2995 line-height: 1.5;2996 margin-bottom: 14px;2997 }2998 .gate-btn {2999 display: block;3000 width: 100%;3001 padding: 9px 0;3002 border-radius: 8px;3003 border: none;3004 cursor: pointer;3005 font-size: 13px;3006 font-family: Inter, sans-serif;3007 font-weight: 500;3008 transition: opacity 100ms;3009 margin-bottom: 7px;3010 text-align: center;3011 }3012 .gate-btn:last-child { margin-bottom: 0; }3013 .gate-btn--accent {3014 background: ${accentHex};3015 color: #fff;3016 }3017 .gate-btn--accent:hover { opacity: 0.88; }3018 .gate-btn--ghost {3019 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};3020 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.45)"};3021 }3022 .gate-btn--ghost:hover { opacity: 0.75; }3023 .backdrop {3024 position: fixed;3025 inset: 0;3026 pointer-events: auto;3027 }3028 `;3029 shadow.appendChild(style);30303031 const backdrop = document.createElement("div");3032 backdrop.className = "backdrop";3033 shadow.appendChild(backdrop);30343035 const wrap = document.createElement("div");3036 wrap.className = "gate-wrap";3037 shadow.appendChild(wrap);30383039 const gate = document.createElement("div");3040 gate.className = "gate";3041 wrap.appendChild(gate);30423043 3044 const header = document.createElement("div");3045 header.className = "gate-header";3046 const icon = document.createElement("span");3047 icon.innerHTML = peachIconSvg();3048 const domainEl = document.createElement("span");3049 domainEl.className = "gate-domain";3050 domainEl.textContent = domain;3051 header.append(icon, domainEl);3052 gate.appendChild(header);30533054 const title = document.createElement("div");3055 title.className = "gate-title";3056 title.textContent = "Passkeys are part of Peach Pro.";3057 gate.appendChild(title);30583059 const subtitle = document.createElement("div");3060 subtitle.className = "gate-subtitle";3061 subtitle.textContent = "Store and use passkeys across all your devices, securely.";3062 gate.appendChild(subtitle);30633064 const upgradeBtn = document.createElement("button");3065 upgradeBtn.className = "gate-btn gate-btn--accent";3066 upgradeBtn.type = "button";3067 upgradeBtn.textContent = "Upgrade to Pro";3068 gate.appendChild(upgradeBtn);30693070 const laterBtn = document.createElement("button");3071 laterBtn.className = "gate-btn gate-btn--ghost";3072 laterBtn.type = "button";3073 laterBtn.textContent = "Not right now";3074 gate.appendChild(laterBtn);30753076 function dismiss() {3077 wrap.classList.add("is-exiting");3078 setTimeout(() => host.remove(), 130);3079 }30803081 upgradeBtn.addEventListener("click", () => {3082 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: { feature: "passkeys" } }).catch(() => {});3083 dismiss();3084 });3085 laterBtn.addEventListener("click", dismiss);3086 backdrop.addEventListener("click", dismiss);30873088 document.addEventListener("keydown", function onEsc(e: KeyboardEvent) {3089 if (e.key === "Escape") { dismiss(); document.removeEventListener("keydown", onEsc); }3090 });30913092 document.body.appendChild(host);3093}309430953096309730983099310031013102export function showPasskeyRegistrationOffer(args: {3103 rpId: string;3104 rpName?: string;3105 userName?: string;3106 userDisplayName?: string;3107}): void {3108 const domain = location.hostname.replace(/^www\./, "");3109 const displayName = args.rpName || domain;31103111 const host = document.createElement("div");3112 host.setAttribute("data-peach-passkey-offer", "1");3113 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483645;pointer-events:none;";3114 const shadow = host.attachShadow({ mode: "closed" });31153116 const style = document.createElement("style");3117 style.textContent = `3118 :host { all: initial; }3119 .offer-wrap {3120 position: fixed;3121 top: 16px;3122 right: 16px;3123 width: 320px;3124 pointer-events: auto;3125 animation: o-in 220ms cubic-bezier(0.16,1,0.3,1) both;3126 }3127 @keyframes o-in {3128 from { opacity: 0; transform: translateY(-6px); }3129 to { opacity: 1; transform: translateY(0); }3130 }3131 .offer-wrap.is-exiting { animation: o-out 130ms ease-in forwards; }3132 @keyframes o-out { to { opacity: 0; transform: translateY(-6px); } }3133 .offer {3134 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};3135 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};3136 border-radius: 12px;3137 box-shadow: 0 12px 48px rgba(0,0,0,0.55);3138 padding: 14px 14px 12px;3139 font-family: Inter, sans-serif;3140 position: relative;3141 }3142 .offer-close {3143 position: absolute;3144 top: 8px;3145 right: 8px;3146 width: 18px;3147 height: 18px;3148 border: none;3149 background: transparent;3150 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};3151 cursor: pointer;3152 font-size: 14px;3153 line-height: 1;3154 padding: 0;3155 }3156 .offer-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }3157 .offer-header {3158 display: flex;3159 align-items: center;3160 gap: 7px;3161 margin-bottom: 8px;3162 padding-bottom: 8px;3163 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};3164 }3165 .offer-domain {3166 font-size: 12px;3167 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};3168 font-family: "IBM Plex Mono", monospace;3169 overflow: hidden;3170 text-overflow: ellipsis;3171 white-space: nowrap;3172 }3173 .offer-title {3174 font-size: 13px;3175 font-weight: 500;3176 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};3177 margin-bottom: 4px;3178 }3179 .offer-subtitle {3180 font-size: 11px;3181 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};3182 line-height: 1.45;3183 margin-bottom: 12px;3184 }3185 .offer-btn {3186 display: block;3187 width: 100%;3188 padding: 8px 0;3189 border-radius: 7px;3190 border: none;3191 cursor: pointer;3192 font-size: 12px;3193 font-family: Inter, sans-serif;3194 font-weight: 500;3195 transition: opacity 100ms;3196 margin-bottom: 6px;3197 text-align: center;3198 }3199 .offer-btn:last-child { margin-bottom: 0; }3200 .offer-btn--accent { background: ${accentHex}; color: #fff; }3201 .offer-btn--accent:hover { opacity: 0.88; }3202 .offer-btn--ghost {3203 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};3204 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};3205 }3206 .offer-btn--ghost:hover { opacity: 0.75; }3207 `;3208 shadow.appendChild(style);32093210 const wrap = document.createElement("div");3211 wrap.className = "offer-wrap";3212 shadow.appendChild(wrap);32133214 const offer = document.createElement("div");3215 offer.className = "offer";3216 wrap.appendChild(offer);32173218 const closeBtn = document.createElement("button");3219 closeBtn.className = "offer-close";3220 closeBtn.type = "button";3221 closeBtn.setAttribute("aria-label", "Dismiss");3222 closeBtn.textContent = "✕";3223 offer.appendChild(closeBtn);32243225 const header = document.createElement("div");3226 header.className = "offer-header";3227 const icon = document.createElement("span");3228 icon.innerHTML = peachIconSvg();3229 const domainEl = document.createElement("span");3230 domainEl.className = "offer-domain";3231 domainEl.textContent = domain;3232 header.append(icon, domainEl);3233 offer.appendChild(header);32343235 const title = document.createElement("div");3236 title.className = "offer-title";3237 title.textContent = "This site supports passkeys.";3238 offer.appendChild(title);32393240 const subtitle = document.createElement("div");3241 subtitle.className = "offer-subtitle";3242 subtitle.textContent = "Save one to Peach for faster, passwordless sign-in.";3243 offer.appendChild(subtitle);32443245 const saveBtn = document.createElement("button");3246 saveBtn.className = "offer-btn offer-btn--accent";3247 saveBtn.type = "button";3248 saveBtn.textContent = "Save passkey to Peach";3249 offer.appendChild(saveBtn);32503251 const laterBtn = document.createElement("button");3252 laterBtn.className = "offer-btn offer-btn--ghost";3253 laterBtn.type = "button";3254 laterBtn.textContent = "Not now";3255 offer.appendChild(laterBtn);32563257 function dismiss(decline: boolean) {3258 if (decline) {3259 chrome.runtime.sendMessage({3260 type: "PASSKEY_OFFER_DECLINE",3261 payload: { domain },3262 }).catch(() => {});3263 }3264 wrap.classList.add("is-exiting");3265 setTimeout(() => host.remove(), 130);3266 }32673268 saveBtn.addEventListener("click", () => {3269 chrome.runtime.sendMessage({3270 type: "INITIATE_FIREFOX_PASSKEY_CREATE",3271 payload: {3272 rpId: args.rpId,3273 rpName: args.rpName ?? displayName,3274 userName: args.userName ?? "user",3275 userDisplayName: args.userDisplayName,3276 },3277 }).catch(() => {});3278 dismiss(false);3279 });3280 laterBtn.addEventListener("click", () => dismiss(true));3281 closeBtn.addEventListener("click", () => dismiss(true));32823283 document.body.appendChild(host);3284}3285328632873288328932903291329232933294export function showPasskeyAvailable(args: {3295 rpId: string;3296 userName: string;3297 fromBrowser?: "chrome" | "firefox";3298 currentBrowser?: "chrome" | "firefox" | "unknown";3299}): void {3300 const domain = location.hostname.replace(/^www\./, "");3301 const crossBrowser =3302 args.fromBrowser &&3303 args.currentBrowser &&3304 args.currentBrowser !== "unknown" &&3305 args.fromBrowser !== args.currentBrowser;33063307 const host = document.createElement("div");3308 host.setAttribute("data-peach-passkey-available", "1");3309 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483644;pointer-events:none;";3310 const shadow = host.attachShadow({ mode: "closed" });33113312 const style = document.createElement("style");3313 style.textContent = `3314 :host { all: initial; }3315 .avail-wrap {3316 position: fixed;3317 top: 16px;3318 right: 16px;3319 width: 320px;3320 pointer-events: auto;3321 animation: a-in 220ms cubic-bezier(0.16,1,0.3,1) both;3322 }3323 @keyframes a-in {3324 from { opacity: 0; transform: translateY(-6px); }3325 to { opacity: 1; transform: translateY(0); }3326 }3327 .avail-wrap.is-exiting { animation: a-out 130ms ease-in forwards; }3328 @keyframes a-out { to { opacity: 0; transform: translateY(-6px); } }3329 .avail {3330 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};3331 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};3332 border-radius: 12px;3333 box-shadow: 0 12px 48px rgba(0,0,0,0.55);3334 padding: 14px 14px 12px;3335 font-family: Inter, sans-serif;3336 position: relative;3337 }3338 .avail-close {3339 position: absolute;3340 top: 8px;3341 right: 8px;3342 width: 18px;3343 height: 18px;3344 border: none;3345 background: transparent;3346 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};3347 cursor: pointer;3348 font-size: 14px;3349 line-height: 1;3350 padding: 0;3351 }3352 .avail-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }3353 .avail-header {3354 display: flex;3355 align-items: center;3356 gap: 7px;3357 margin-bottom: 8px;3358 padding-bottom: 8px;3359 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};3360 }3361 .avail-domain {3362 font-size: 12px;3363 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};3364 font-family: "IBM Plex Mono", monospace;3365 }3366 .avail-label {3367 font-size: 9px;3368 letter-spacing: 0.16em;3369 text-transform: uppercase;3370 color: ${accentHex};3371 margin-bottom: 4px;3372 }3373 .avail-user {3374 font-size: 13px;3375 font-weight: 500;3376 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};3377 margin-bottom: 12px;3378 overflow: hidden;3379 text-overflow: ellipsis;3380 white-space: nowrap;3381 }3382 .avail-cross {3383 font-size: 11px;3384 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};3385 line-height: 1.45;3386 margin-bottom: 12px;3387 padding: 8px;3388 background: ${popupTheme === "light" ? "rgba(0,0,0,0.04)" : "rgba(240,232,216,0.04)"};3389 border-radius: 6px;3390 }3391 .avail-btn {3392 display: block;3393 width: 100%;3394 padding: 8px 0;3395 border-radius: 7px;3396 border: none;3397 cursor: pointer;3398 font-size: 12px;3399 font-family: Inter, sans-serif;3400 font-weight: 500;3401 transition: opacity 100ms;3402 margin-bottom: 6px;3403 text-align: center;3404 }3405 .avail-btn:last-child { margin-bottom: 0; }3406 .avail-btn--accent { background: ${accentHex}; color: #fff; }3407 .avail-btn--accent:hover { opacity: 0.88; }3408 .avail-btn--ghost {3409 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};3410 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};3411 }3412 .avail-btn--ghost:hover { opacity: 0.75; }3413 `;3414 shadow.appendChild(style);34153416 const wrap = document.createElement("div");3417 wrap.className = "avail-wrap";3418 shadow.appendChild(wrap);34193420 const avail = document.createElement("div");3421 avail.className = "avail";3422 wrap.appendChild(avail);34233424 const closeBtn = document.createElement("button");3425 closeBtn.className = "avail-close";3426 closeBtn.type = "button";3427 closeBtn.setAttribute("aria-label", "Dismiss");3428 closeBtn.textContent = "✕";3429 avail.appendChild(closeBtn);34303431 const header = document.createElement("div");3432 header.className = "avail-header";3433 const icon = document.createElement("span");3434 icon.innerHTML = peachIconSvg();3435 const domainEl = document.createElement("span");3436 domainEl.className = "avail-domain";3437 domainEl.textContent = domain;3438 header.append(icon, domainEl);3439 avail.appendChild(header);34403441 const label = document.createElement("div");3442 label.className = "avail-label";3443 label.textContent = "PASSKEY";3444 avail.appendChild(label);34453446 const user = document.createElement("div");3447 user.className = "avail-user";3448 user.textContent = args.userName;3449 avail.appendChild(user);34503451 if (crossBrowser) {3452 const cross = document.createElement("div");3453 cross.className = "avail-cross";3454 cross.textContent =3455 args.fromBrowser === "chrome"3456 ? "This passkey was created on Chrome. To use it on Firefox, re-register it on this device."3457 : "This passkey was created on Firefox. To use it on Chrome, re-register it on this device.";3458 avail.appendChild(cross);3459 }34603461 const signInBtn = document.createElement("button");3462 signInBtn.className = "avail-btn avail-btn--accent";3463 signInBtn.type = "button";3464 signInBtn.textContent = "Sign in with passkey";3465 avail.appendChild(signInBtn);34663467 const passwordBtn = document.createElement("button");3468 passwordBtn.className = "avail-btn avail-btn--ghost";3469 passwordBtn.type = "button";3470 passwordBtn.textContent = "Use password instead";3471 avail.appendChild(passwordBtn);34723473 function dismiss() {3474 wrap.classList.add("is-exiting");3475 setTimeout(() => host.remove(), 130);3476 }34773478 signInBtn.addEventListener("click", () => {3479 3480 3481 3482 3483 3484 dismiss();3485 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: {} }).catch(() => {});3486 });3487 passwordBtn.addEventListener("click", dismiss);3488 closeBtn.addEventListener("click", dismiss);34893490 document.body.appendChild(host);3491}349234933494349534963497349834993500export function showCardSelector(3501 anchorEl: HTMLInputElement,3502 cards: CardSelectorEntry[],3503 options: CardSelectorOptions3504): () => void {3505 if (cards.length === 0) return () => {};3506 const card = cards[0]!;35073508 const host = document.createElement("div");3509 host.style.cssText = "position: absolute; z-index: 2147483647;";3510 host.style.setProperty("--peach-accent", accentHex);3511 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));3512 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));3513 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));3514 const shadow = host.attachShadow({ mode: "closed" });35153516 const style = shadow.appendChild(document.createElement("style"));3517 style.textContent = SELECTOR_STYLES;35183519 const rect = anchorEl.getBoundingClientRect();3520 host.style.top = `${rect.bottom + window.scrollY + 5}px`;3521 host.style.left = `${rect.left + window.scrollX}px`;3522 host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;35233524 const container = shadow.appendChild(document.createElement("div"));3525 container.className = "peach-inline-popup";3526 container.setAttribute("data-theme", popupTheme);35273528 3529 const domHdr = document.createElement("div");3530 domHdr.className = "domain-header";3531 const eyebrow = document.createElement("div");3532 eyebrow.className = "domain-eyebrow";3533 eyebrow.textContent = "Pay with Peach";3534 const domName = document.createElement("div");3535 domName.className = "domain-name";3536 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");3537 domHdr.append(eyebrow, domName);3538 container.appendChild(domHdr);35393540 const platter = document.createElement("div");3541 platter.className = "card-platter";35423543 if (card.network && card.network !== "unknown") {3544 const net = document.createElement("div");3545 net.className = "cp-network";3546 net.textContent = card.network;3547 platter.appendChild(net);3548 }35493550 const nick = document.createElement("div");3551 nick.className = "cp-nickname";3552 nick.textContent = card.title;3553 platter.appendChild(nick);35543555 if (card.last4) {3556 const l4 = document.createElement("div");3557 l4.className = "cp-last4";3558 l4.textContent = `•••• ${card.last4}`;3559 platter.appendChild(l4);3560 }35613562 const meta = document.createElement("div");3563 meta.className = "cp-meta";3564 if (card.cardholderName) {3565 const name = document.createElement("span");3566 name.textContent = card.cardholderName;3567 meta.appendChild(name);3568 }3569 if (card.expMonth && card.expYear) {3570 if (card.cardholderName) {3571 const sep = document.createElement("span");3572 sep.className = "cp-meta-sep";3573 sep.textContent = "·";3574 meta.appendChild(sep);3575 }3576 const exp = document.createElement("span");3577 const yy = card.expYear.length === 4 ? card.expYear.slice(-2) : card.expYear;3578 exp.textContent = `${card.expMonth.padStart(2, "0")}/${yy}`;3579 meta.appendChild(exp);3580 }3581 if (meta.childElementCount > 0) platter.appendChild(meta);35823583 const fillWrap = document.createElement("div");3584 fillWrap.className = "cp-fill-wrap";3585 const fillBtn = document.createElement("button");3586 fillBtn.className = "sp-fill-btn";3587 fillBtn.type = "button";3588 fillBtn.textContent = "Fill card details";3589 fillBtn.addEventListener("click", async () => {3590 if (fillBtn.disabled) return;3591 fillBtn.disabled = true;3592 fillBtn.classList.add("filled");3593 fillBtn.innerHTML = checkSvgStr();3594 const resp = await chrome.runtime.sendMessage({3595 type: "GET_ENTRY_FOR_FILL",3596 payload: { id: card.id },3597 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3598 if (resp?.ok && resp.data) options.onFill(resp.data);3599 setTimeout(() => dismiss(), 400);3600 });3601 fillWrap.appendChild(fillBtn);3602 platter.appendChild(fillWrap);36033604 3605 const actions = document.createElement("div");3606 actions.className = "sp-actions";36073608 function flashBtn(b: HTMLButtonElement) {3609 b.classList.add("flashed");3610 setTimeout(() => b.classList.remove("flashed"), 700);3611 }36123613 3614 function flashCopyError(b: HTMLButtonElement) {3615 const original = b.textContent ?? "";3616 b.textContent = "Blocked";3617 b.classList.add("flashed");3618 setTimeout(() => {3619 b.classList.remove("flashed");3620 if (b.isConnected) b.textContent = original;3621 }, 1200);3622 }36233624 async function fetchFullCard(): Promise<import("../shared/types").VaultEntry | null> {3625 const resp = await chrome.runtime.sendMessage({3626 type: "GET_ENTRY_FOR_FILL",3627 payload: { id: card.id },3628 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3629 return resp?.ok && resp.data ? resp.data : null;3630 }36313632 const copyNum = document.createElement("button");3633 copyNum.className = "sp-action-btn";3634 copyNum.type = "button";3635 copyNum.title = "Copy card number";3636 copyNum.textContent = "Copy number";3637 copyNum.addEventListener("click", async (e) => {3638 e.stopPropagation();3639 const full = await fetchFullCard();3640 if (!full?.cardNumber) return;3641 let alreadyWritten = false;3642 try {3643 await navigator.clipboard.writeText(full.cardNumber);3644 alreadyWritten = true;3645 } catch (err) {3646 console.warn("[Peach] clipboard write denied:", err);3647 }3648 const resp = await chrome.runtime.sendMessage({3649 type: "COPY",3650 payload: { text: full.cardNumber, label: "Card number", alreadyWritten },3651 }).catch(() => null) as { ok?: boolean } | null;3652 if (alreadyWritten || resp?.ok) flashBtn(copyNum);3653 else flashCopyError(copyNum);3654 });3655 actions.appendChild(copyNum);36563657 const copyCvc = document.createElement("button");3658 copyCvc.className = "sp-action-btn";3659 copyCvc.type = "button";3660 copyCvc.title = "Copy CVC";3661 copyCvc.textContent = "Copy CVC";3662 copyCvc.addEventListener("click", async (e) => {3663 e.stopPropagation();3664 const full = await fetchFullCard();3665 if (!full?.cvc) return;3666 let alreadyWritten = false;3667 try {3668 await navigator.clipboard.writeText(full.cvc);3669 alreadyWritten = true;3670 } catch (err) {3671 console.warn("[Peach] clipboard write denied:", err);3672 }3673 const resp = await chrome.runtime.sendMessage({3674 type: "COPY",3675 payload: { text: full.cvc, label: "CVC", alreadyWritten },3676 }).catch(() => null) as { ok?: boolean } | null;3677 if (alreadyWritten || resp?.ok) flashBtn(copyCvc);3678 else flashCopyError(copyCvc);3679 });3680 actions.appendChild(copyCvc);36813682 const closeBtn = document.createElement("button");3683 closeBtn.className = "sp-action-btn";3684 closeBtn.type = "button";3685 closeBtn.title = "Dismiss";3686 closeBtn.textContent = "✕";3687 closeBtn.addEventListener("click", (e) => {3688 e.stopPropagation();3689 dismiss(true);3690 });3691 actions.appendChild(closeBtn);36923693 platter.appendChild(actions);3694 container.appendChild(platter);36953696 document.body.appendChild(host);3697 function updatePosition() {3698 const r = anchorEl.getBoundingClientRect();3699 host.style.top = `${r.bottom + window.scrollY + 5}px`;3700 host.style.left = `${r.left + window.scrollX}px`;3701 }3702 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);37033704 function onKeyDown(e: KeyboardEvent) {3705 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }3706 }3707 document.addEventListener("keydown", onKeyDown);37083709 let exitScheduled = false;3710 function dismiss(userAction = false) {3711 if (exitScheduled) return;3712 exitScheduled = true;3713 stopObserving();3714 document.removeEventListener("click", outsideClick, { capture: true });3715 document.removeEventListener("keydown", onKeyDown);3716 if (userAction) options.onDismiss?.();3717 container.classList.add("is-exiting");3718 setTimeout(() => host.remove(), 130);3719 }37203721 function outsideClick(ev: MouseEvent) {3722 const path = ev.composedPath();3723 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);3724 }3725 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);37263727 return dismiss;3728}