123456789101112import { ACCENT_COLORS, type PasswordPolicy, type SavedIdentity } from "../shared/types";13import { generatePassword, generateSmartPassword } from "../shared/generate";14import { generateTOTP } from "../crypto/totp";15import { detectPasswordPolicy } from "./policy";1617let accentHex = "#E8956D";18let popupTheme: "dark" | "light" = "dark";19chrome.runtime.sendMessage({ type: "GET_SETTINGS" }, (resp: { ok: boolean; data?: { accentColor?: string; theme?: string } } | undefined) => {20 const data = resp?.data;21 const name = data?.accentColor ?? "peach";22 accentHex = ACCENT_COLORS.find(c => c.name === name)?.hex ?? "#E8956D";23 popupTheme = data?.theme === "light" ? "light" : "dark";24});2526272829function withAlpha(hex: string, alpha: string): string {30 31 32 33 return /^#[0-9a-f]{6}$/i.test(hex) ? hex + alpha : hex;34}3536export interface SelectorEntry {37 id: string;38 title: string;39 username?: string;40 email?: string;41 url?: string;42 hasTotp?: boolean;43 44 hasPasskey?: boolean;45}4647interface SelectorOptions {48 domain?: string;49 searchableEntries?: SelectorEntry[];50 51 isSignup?: boolean;52 53545556 savedIdentities?: SavedIdentity[];57 5859606162 onFillFields?: (username: string, password: string) => void;63 6465666768 locked?: boolean;69 70717273 onUnlocked?: () => void;74 7576777879 onDismiss?: () => void;80}8182function getDomainFromUrl(url: string): string {83 try { return new URL(url).hostname.replace(/^www\./, ""); } catch { return ""; }84}8586function keySvgStr(): string {87 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>`;88}8990function plusSvgStr(): string {91 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>`;92}9394function peachIconSvg(): string {95 96 97 98 return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 64 64" fill="none" aria-hidden="true"><path d="M32 54C16 54 8 44 8 31C8 18 17 10 27 10C28 7 30 5.5 32 5.5C34 5.5 36 7 37 10C47 10 56 18 56 31C56 44 48 54 32 54Z" fill="#D96830"/><path d="M37 8.5C40.5 3.5 48 5 46 10.5C42 11 37 8.5 37 8.5Z" fill="#7B9060"/></svg>`;99}100101function genSvgStr(): string {102 return `<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 11 11" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round"><path d="M9.5 2A4.5 4.5 0 1 0 10.5 5.5"/><path d="M8.5 2H9.5V1"/></svg>`;103}104105function checkSvgStr(): string {106 return `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 20 20" fill="none" stroke="#7B9060" stroke-width="1.5" stroke-linecap="round"><path d="M4 10.5L8 14.5L16 6.5"/></svg>`;107}108109function smartUrl(): { origin: string; title: string; loginSubdomain: boolean } {110 const { hostname, origin } = location;111 const parts = hostname.split(".");112 const AUTH_PREFIXES = ["accounts", "auth", "login", "signin", "sign-in", "sso",113 "id", "identity", "secure", "portal", "my", "am", "idp", "connect", "oauth",114 "oidc", "federation", "saml", "cas", "ldap"];115 const loginSubdomain = parts.length > 2 && AUTH_PREFIXES.includes(parts[0]!.toLowerCase());116 const rootName = parts.length >= 2 ? parts[parts.length - 2]! : parts[0]!;117 const title = rootName.charAt(0).toUpperCase() + rootName.slice(1);118 return { origin, title, loginSubdomain };119}120121122123124125126export function showRememberSiteToast(127 pageDomain: string,128 entryId: string,129): void {130 const host = document.createElement("div");131 host.style.cssText = "position:fixed;bottom:22px;left:50%;transform:translateX(-50%);z-index:2147483647;pointer-events:auto;";132 host.style.setProperty("--peach-accent", accentHex);133 const shadow = host.attachShadow({ mode: "closed" });134135 const style = document.createElement("style");136 style.textContent = `137 .bar {138 display:flex;align-items:center;gap:10px;padding:10px 14px;139 background:#131109;border:1px solid rgba(240,232,216,0.09);140 border-radius:10px;box-shadow:0 8px 32px rgba(0,0,0,0.75);141 font-family:Inter,sans-serif;white-space:nowrap;142 animation:tf-in 180ms cubic-bezier(0.16,1,0.3,1) both;143 }144 @keyframes tf-in { from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none} }145 .txt { font-size:11px;color:rgba(240,232,216,0.55);font-family:"IBM Plex Mono",monospace; }146 .yes {147 padding:5px 12px;border-radius:6px;border:none;cursor:pointer;font-size:11px;148 background:var(--peach-accent);color:#fff;transition:background 100ms;font-family:Inter,sans-serif;149 }150 .yes:hover { background:color-mix(in srgb, var(--peach-accent) 82%, #000); }151 .no {152 padding:5px 10px;border-radius:6px;border:none;cursor:pointer;font-size:11px;153 background:rgba(240,232,216,0.07);color:rgba(240,232,216,0.45);font-family:Inter,sans-serif;154 }155 `;156 shadow.appendChild(style);157158 const bar = document.createElement("div"); bar.className = "bar";159 const txt = document.createElement("span"); txt.className = "txt";160 txt.textContent = `Remember ${pageDomain} for this entry?`;161 const yesBtn = document.createElement("button"); yesBtn.className = "yes";162 yesBtn.textContent = "Remember";163 yesBtn.addEventListener("click", async () => {164 await chrome.runtime.sendMessage({165 type: "ADD_ADDITIONAL_URL",166 payload: { id: entryId, url: location.origin },167 });168 host.remove();169 });170 const noBtn = document.createElement("button"); noBtn.className = "no";171 noBtn.textContent = "Not now";172 noBtn.addEventListener("click", () => host.remove());173 bar.append(txt, yesBtn, noBtn);174 shadow.appendChild(bar);175 document.body.appendChild(host);176 setTimeout(() => host.remove(), 9000);177}178179function generatePasswordForSite(policy: PasswordPolicy = {}): string {180 return generateSmartPassword(policy);181}182183interface SmartGenerator {184 root: HTMLElement;185 getPassword: () => string;186 187 copy: () => Promise<void>;188}189190interface SmartGeneratorOptions {191 192 policy: PasswordPolicy;193 194195196197198 initialPassword?: string;199 200 onChange?: (pw: string) => void;201}202203204205206207208209210function createSmartGenerator(opts: SmartGeneratorOptions): SmartGenerator {211 const policy = opts.policy ?? {};212213 let length = 64;214 if (policy.minLength) length = Math.max(length, policy.minLength);215 if (policy.maxLength) length = Math.min(length, policy.maxLength);216 if (length < 8) length = 8;217 if (length > 128) length = 128;218219 let upper = true;220 let lower = true;221 let numbers = true;222 let symbols = !policy.forbidsSymbols;223 if (policy.requiresSymbols) symbols = true;224 const forbiddenChars = policy.forbiddenChars ?? "";225226 let password = "";227228 const root = document.createElement("div");229 root.className = "pwgen-block";230231 const displayRow = root.appendChild(document.createElement("div"));232 displayRow.className = "pwgen-display-row";233 const output = displayRow.appendChild(document.createElement("input")) as HTMLInputElement;234 output.type = "text";235 output.className = "pwgen-output";236 output.setAttribute("autocomplete", "off");237 output.setAttribute("spellcheck", "false");238 output.setAttribute("autocorrect", "off");239 output.setAttribute("autocapitalize", "off");240241 const regenBtn = displayRow.appendChild(document.createElement("button"));242 regenBtn.className = "pwgen-icon-btn";243 regenBtn.type = "button";244 regenBtn.setAttribute("aria-label", "Regenerate password");245 regenBtn.title = "Regenerate";246 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>`;247248 const copyBtn = displayRow.appendChild(document.createElement("button"));249 copyBtn.className = "pwgen-icon-btn";250 copyBtn.type = "button";251 copyBtn.setAttribute("aria-label", "Copy password");252 copyBtn.title = "Copy";253 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>`;254255 const controls = root.appendChild(document.createElement("div"));256 controls.className = "pwgen-controls-row";257 const slider = controls.appendChild(document.createElement("input"));258 slider.type = "range";259 slider.className = "pwgen-slider";260 slider.min = "8";261 slider.max = "128";262 slider.value = String(length);263 if (policy.minLength) slider.min = String(Math.max(8, policy.minLength));264 if (policy.maxLength) slider.max = String(Math.min(128, policy.maxLength));265 const lenNum = controls.appendChild(document.createElement("span"));266 lenNum.className = "pwgen-len-num pwgen-len-num--edit";267 lenNum.textContent = String(length);268 lenNum.addEventListener("click", () => {269 const li = document.createElement("input");270 li.type = "text"; li.inputMode = "numeric";271 li.className = "pwgen-len-input"; li.value = String(length);272 lenNum.replaceWith(li);273 requestAnimationFrame(() => li.select());274 function commitLenEdit() {275 const n = parseInt(li.value, 10);276 if (!isNaN(n)) {277 length = Math.max(8, Math.min(128, n));278 slider.value = String(length);279 regenerate();280 }281 lenNum.textContent = String(length);282 li.replaceWith(lenNum);283 }284 li.addEventListener("keydown", (e) => { if (e.key === "Enter") { e.preventDefault(); commitLenEdit(); } else if (e.key === "Escape") { li.replaceWith(lenNum); } });285 li.addEventListener("blur", commitLenEdit);286 });287288 const pills = root.appendChild(document.createElement("div"));289 pills.className = "pwgen-pills";290291 function makePill(label: string, on: boolean, onToggle: (next: boolean) => void): HTMLButtonElement {292 const b = document.createElement("button");293 b.type = "button";294 b.className = `pwgen-pill ${on ? "is-on" : ""}`;295 b.textContent = label;296 b.addEventListener("click", () => {297 const next = !b.classList.contains("is-on");298 b.classList.toggle("is-on", next);299 onToggle(next);300 });301 return b;302 }303 pills.appendChild(makePill("A-Z", upper, (next) => { upper = next; regenerate(); }));304 pills.appendChild(makePill("a-z", lower, (next) => { lower = next; regenerate(); }));305 pills.appendChild(makePill("0-9", numbers, (next) => { numbers = next; regenerate(); }));306 pills.appendChild(makePill("!@#", symbols, (next) => {307 308 symbols = next;309 regenerate();310 }));311312 313 314 315 const hintParts: string[] = [];316 if (policy.minLength) hintParts.push(`min ${policy.minLength}`);317 if (policy.maxLength) hintParts.push(`max ${policy.maxLength}`);318 if (policy.requiresSymbols) hintParts.push("requires symbols");319 if (policy.forbidsSymbols) hintParts.push("no symbols");320 if (policy.forbiddenChars) hintParts.push(`excludes ${policy.forbiddenChars.slice(0, 6)}${policy.forbiddenChars.length > 6 ? "…" : ""}`);321 if (hintParts.length > 0) {322 const hint = root.appendChild(document.createElement("div"));323 hint.className = "pwgen-policy-hint";324 const accent = document.createElement("span");325 accent.className = "pwgen-hint-accent";326 accent.textContent = "site rules · ";327 const text = document.createTextNode(hintParts.join(" · "));328 hint.appendChild(accent);329 hint.appendChild(text);330 }331332 function regenerate() {333 334 335 password = generatePassword({336 length,337 includeUppercase: upper,338 includeLowercase: lower,339 includeNumbers: numbers,340 includeSymbols: symbols,341 forbiddenChars,342 });343 output.value = password;344 opts.onChange?.(password);345 }346347 output.addEventListener("input", () => {348 password = output.value;349 opts.onChange?.(password);350 });351352 slider.addEventListener("input", () => {353 length = parseInt(slider.value, 10);354 lenNum.textContent = String(length);355 regenerate();356 });357 regenBtn.addEventListener("click", regenerate);358359 let copyResetTimer: ReturnType<typeof setTimeout> | null = null;360 async function copy(): Promise<void> {361 try {362 await navigator.clipboard.writeText(password);363 copyBtn.classList.add("is-copied");364 if (copyResetTimer) clearTimeout(copyResetTimer);365 copyResetTimer = setTimeout(() => copyBtn.classList.remove("is-copied"), 1400);366 } catch {367 368 }369 }370 copyBtn.addEventListener("click", () => { void copy(); });371372 if (opts.initialPassword) {373 password = opts.initialPassword;374 output.value = password;375 opts.onChange?.(password);376 } else {377 regenerate();378 }379380 return {381 root,382 getPassword: () => password,383 copy,384 };385}386387export function observeAnchorPosition(388 anchorEl: HTMLElement,389 onUpdate: () => void390): () => void {391 let rafId = 0;392 let burstUntil = 0;393394 const runUpdate = () => {395 rafId = 0;396 onUpdate();397 if (performance.now() < burstUntil) rafId = requestAnimationFrame(runUpdate);398 };399 const scheduleUpdate = () => { if (!rafId) rafId = requestAnimationFrame(runUpdate); };400 const scheduleBurst = (ms = 220) => {401 burstUntil = Math.max(burstUntil, performance.now() + ms);402 scheduleUpdate();403 };404405 const resizeObserver = new ResizeObserver(() => scheduleBurst());406 resizeObserver.observe(anchorEl);407 if (anchorEl.parentElement) resizeObserver.observe(anchorEl.parentElement);408409 const mutationObserver = new MutationObserver(() => scheduleBurst());410 mutationObserver.observe(anchorEl, { attributes: true, attributeFilter: ["class", "style", "type", "hidden"] });411 if (anchorEl.parentElement) {412 mutationObserver.observe(anchorEl.parentElement, { attributes: true, attributeFilter: ["class", "style", "hidden"] });413 }414415 const onScroll = () => scheduleUpdate();416 window.addEventListener("scroll", onScroll, true);417 window.addEventListener("resize", onScroll);418 window.visualViewport?.addEventListener("resize", onScroll);419 window.visualViewport?.addEventListener("scroll", onScroll);420 anchorEl.addEventListener("focus", () => scheduleBurst());421 anchorEl.addEventListener("input", () => scheduleBurst());422423 scheduleBurst(260);424425 return () => {426 if (rafId) cancelAnimationFrame(rafId);427 resizeObserver.disconnect();428 mutationObserver.disconnect();429 window.removeEventListener("scroll", onScroll, true);430 window.removeEventListener("resize", onScroll);431 window.visualViewport?.removeEventListener("resize", onScroll);432 window.visualViewport?.removeEventListener("scroll", onScroll);433 };434}435436export function injectFieldIcon(field: HTMLInputElement, onClick: () => void): () => void {437 const button = document.createElement("button");438 button.type = "button";439 button.setAttribute("aria-label", "Peach autofill");440 button.title = "Fill with Peach";441 button.innerHTML = peachIconSvg();442 443 444 445 446 button.style.cssText = `447 position: fixed; z-index: 2147483646;448 width: 26px; height: 26px; cursor: pointer;449 pointer-events: auto; border: none; padding: 3px;450 display: inline-flex; align-items: center; justify-content: center;451 background: transparent; border-radius: 999px;452 transition: opacity 140ms ease, background 120ms ease, box-shadow 120ms ease, transform 80ms ease;453 opacity: 0;454 `;455 button.addEventListener("mouseenter", () => {456 button.style.background = `color-mix(in srgb, ${accentHex} 12%, transparent)`;457 button.style.boxShadow = `0 0 0 1px color-mix(in srgb, ${accentHex} 18%, transparent), 0 0 14px color-mix(in srgb, ${accentHex} 12%, transparent)`;458 button.style.transform = "scale(1.08)";459 });460 button.addEventListener("mouseleave", () => {461 button.style.background = "transparent";462 button.style.boxShadow = "none";463 button.style.transform = "none";464 });465 button.addEventListener("pointerdown", e => { e.stopPropagation(); e.preventDefault(); });466 button.addEventListener("click", e => { e.stopPropagation(); e.preventDefault(); onClick(); });467468 document.body.appendChild(button);469470 function updatePosition() {471 const rect = field.getBoundingClientRect();472 if (rect.width === 0 || rect.height === 0) {473 button.style.opacity = "0"; button.style.pointerEvents = "none";474 return;475 }476 const sz = 26;477 const inset = Math.max(5, Math.min(10, rect.height * 0.22));478 const top = rect.top + rect.height / 2 - sz / 2;479 480 481 const minLeft = rect.left + 4;482 const left = Math.max(minLeft, rect.right - sz - inset);483 484 if (rect.width < 40) {485 button.style.opacity = "0"; button.style.pointerEvents = "none";486 return;487 }488 button.style.top = `${top}px`;489 button.style.left = `${left}px`;490 button.style.opacity = "1"; button.style.pointerEvents = "auto";491 }492 updatePosition();493 requestAnimationFrame(() => { button.style.opacity = "1"; });494 const stopObserving = observeAnchorPosition(field, updatePosition);495 return () => { stopObserving(); button.remove(); };496}497498499500501502503504const SELECTOR_STYLES = `505 :host { all: initial; }506 *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }507508 .peach-inline-popup[data-theme="dark"] {509 --peach-bg: #1a1410;510 --peach-bg-card: #221c16;511 --peach-text: #f5f0ea;512 --peach-text-dim: #8a7a6a;513 --peach-text-muted: #4a3a2a;514 --peach-border: rgba(255,255,255,0.07);515 --peach-input-bg: rgba(255,255,255,0.05);516 --peach-input-border: rgba(255,255,255,0.08);517 }518 .peach-inline-popup[data-theme="light"] {519 --peach-bg: #fdf8f4;520 --peach-bg-card: #f5ede4;521 --peach-text: #1c1310;522 --peach-text-dim: #6b5a4a;523 --peach-text-muted: #a89080;524 --peach-border: rgba(0,0,0,0.08);525 --peach-input-bg: rgba(0,0,0,0.04);526 --peach-input-border: rgba(0,0,0,0.10);527 }528529 .peach-inline-popup {530 background: var(--peach-bg);531 border: 1px solid var(--peach-border-accent, var(--peach-border));532 border-radius: 14px;533 overflow: hidden;534 box-shadow:535 0 8px 40px var(--peach-glow, transparent),536 0 2px 12px rgba(0,0,0,0.5);537 font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;538 animation: peach-enter 200ms cubic-bezier(0.16,1,0.3,1) forwards;539 }540 /* Light theme: shadow against a light page is too strong otherwise — drop both541 the accent glow and the dark drop-shadow opacity to keep the popup elegant. */542 .peach-inline-popup[data-theme="light"] {543 box-shadow:544 0 8px 40px color-mix(in srgb, var(--peach-accent) 10%, transparent),545 0 2px 12px rgba(0,0,0,0.12);546 }547 .peach-inline-popup.is-exiting {548 animation: peach-exit 130ms cubic-bezier(0.4,0,1,1) forwards;549 pointer-events: none;550 }551552 @keyframes peach-enter {553 0% { opacity: 0; transform: translateY(-8px) scale(0.96); filter: blur(3px); }554 65% { opacity: 1; filter: blur(0); }555 100% { opacity: 1; transform: translateY(0) scale(1); }556 }557 @keyframes peach-exit {558 0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }559 100% { opacity: 0; transform: translateY(-4px) scale(0.98); filter: blur(2px); }560 }561 @keyframes peach-slide-in {562 from { opacity: 0; transform: translateX(12px); }563 to { opacity: 1; transform: translateX(0); }564 }565 @keyframes peach-slide-back {566 from { opacity: 0; transform: translateX(-12px); }567 to { opacity: 1; transform: translateX(0); }568 }569 .peach-content[data-dir="forward"] { animation: peach-slide-in 150ms cubic-bezier(0.16,1,0.3,1) both; }570 .peach-content[data-dir="back"] { animation: peach-slide-back 150ms cubic-bezier(0.16,1,0.3,1) both; }571572 /* Domain header */573 .domain-header {574 padding: 9px 13px 7px;575 border-bottom: 1px solid var(--peach-border);576 display: flex; align-items: center; justify-content: space-between;577 gap: 8px;578 }579 .domain-header-text {580 display: flex; flex-direction: column; gap: 2px;581 min-width: 0; flex: 1;582 }583 .domain-eyebrow {584 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;585 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;586 }587 .domain-name {588 font-size: 10px; color: color-mix(in srgb, var(--peach-accent) 60%, transparent);589 font-family: "IBM Plex Mono", monospace;590 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;591 }592 .domain-add-btn {593 flex-shrink: 0;594 width: 22px; height: 22px;595 display: inline-flex; align-items: center; justify-content: center;596 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);597 border: 1px solid color-mix(in srgb, var(--peach-accent) 28%, transparent);598 border-radius: 6px;599 color: var(--peach-accent);600 cursor: pointer; padding: 0;601 transition: background 120ms, border-color 120ms, transform 80ms;602 font-family: "IBM Plex Mono", monospace;603 font-size: 14px; line-height: 1;604 }605 .domain-add-btn:hover {606 background: color-mix(in srgb, var(--peach-accent) 22%, transparent);607 border-color: color-mix(in srgb, var(--peach-accent) 48%, transparent);608 transform: scale(1.06);609 }610 .domain-add-btn:active { transform: scale(0.96); }611612 /* Search */613 .search-wrap {614 padding: 9px 12px 7px;615 border-bottom: 1px solid var(--peach-border);616 }617 .search {618 width: 100%; background: var(--peach-input-bg);619 border: 1px solid var(--peach-input-border);620 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;621 font-size: 12px; outline: none; font-family: "IBM Plex Mono", monospace;622 transition: border-color 120ms, box-shadow 120ms;623 }624 .search:focus {625 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);626 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);627 }628 .search::placeholder { color: var(--peach-text-muted); }629630 /* Results */631 .results { max-height: 256px; overflow-y: auto; scrollbar-width: none; }632 .results::-webkit-scrollbar { display: none; }633634 /* Entry rows */635 .entry {636 display: flex; align-items: center; padding: 8px 12px;637 cursor: pointer; border-bottom: 1px solid var(--peach-border);638 transition: background 70ms; position: relative; outline: none;639 }640 .entry:last-child { border-bottom: none; }641 .entry:hover { background: color-mix(in srgb, var(--peach-text) 4%, transparent); }642 .entry.focused { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }643 .entry.focused::before {644 content: ""; position: absolute; left: 0; top: 3px; bottom: 3px;645 width: 2px; border-radius: 2px;646 background: color-mix(in srgb, var(--peach-accent) 55%, transparent);647 }648649 .entry-icon {650 width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;651 background: var(--peach-input-bg); border: 1px solid var(--peach-border);652 display: flex; align-items: center; justify-content: center;653 overflow: hidden; margin-right: 10px;654 }655 .entry-icon img { width: 15px; height: 15px; border-radius: 2px; display: block; }656 .entry-icon.is-new {657 background: color-mix(in srgb, var(--peach-accent) 8%, transparent);658 border-color: color-mix(in srgb, var(--peach-accent) 15%, transparent);659 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);660 }661662 .entry-info { flex: 1; min-width: 0; }663 .entry-title {664 font-size: 12.5px; color: var(--peach-text);665 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;666 line-height: 1.3;667 }668 .entry-title.is-new { color: color-mix(in srgb, var(--peach-accent) 90%, transparent); font-size: 12px; }669 .entry-sub {670 font-size: 10px; color: var(--peach-text-dim);671 font-family: "IBM Plex Mono", monospace;672 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;673 margin-top: 1px;674 }675676 .totp-badge {677 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;678 border-radius: 4px; background: color-mix(in srgb, var(--peach-accent) 10%, transparent);679 color: color-mix(in srgb, var(--peach-accent) 75%, transparent);680 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 8px;681 }682 .passkey-badge {683 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;684 border-radius: 4px;685 background: color-mix(in srgb, var(--peach-accent) 14%, transparent);686 color: color-mix(in srgb, var(--peach-accent) 85%, transparent);687 border: 1px solid color-mix(in srgb, var(--peach-accent) 24%, transparent);688 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 6px;689 }690691 .divider { height: 1px; background: var(--peach-border); margin: 2px 0; }692693 .empty-hint {694 padding: 14px 13px; font-size: 11px; color: var(--peach-text-dim);695 font-family: "IBM Plex Mono", monospace;696 }697698 /* Create form */699 .create-form-wrap {700 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;701 }702 .create-head {703 display: flex; align-items: center; gap: 8px;704 padding: 10px 12px; border-bottom: 1px solid var(--peach-border);705 }706 .back-btn {707 background: transparent; border: none; cursor: pointer;708 color: var(--peach-text-dim); padding: 3px; border-radius: 5px;709 display: flex; align-items: center; line-height: 0;710 transition: color 100ms, background 100ms;711 }712 .back-btn:hover { color: var(--peach-text); background: var(--peach-input-bg); }713 .create-label { font-size: 12px; color: var(--peach-text); font-weight: 500; flex: 1; }714 /* minmax(0, 1fr) caps the grid track at the popup width — without it,715 long monospace content (e.g. a 60-char generated password) would716 auto-size the track wider than the popup and overflow the right edge. */717 .create-body { padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }718 .f-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }719 .f-label {720 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;721 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;722 }723 .f-input {724 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);725 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;726 font-size: 11px; font-family: "IBM Plex Mono", monospace;727 outline: none; width: 100%; transition: border-color 120ms, box-shadow 120ms;728 }729 .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); }730 .f-input::placeholder { color: var(--peach-text-muted); }731 .f-input.url-f { font-size: 10px; color: var(--peach-text-dim); letter-spacing: 0.01em; }732 .f-row { display: flex; gap: 6px; }733 .f-row .f-input { flex: 1; min-width: 0; }734 .gen-btn {735 padding: 0 10px; border-radius: 7px; border: none;736 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);737 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);738 font-size: 10px; font-family: "IBM Plex Mono", monospace;739 cursor: pointer; white-space: nowrap; flex-shrink: 0;740 display: flex; align-items: center; gap: 4px;741 transition: background 100ms;742 }743 .gen-btn:hover { background: color-mix(in srgb, var(--peach-accent) 18%, transparent); }744 .save-btn {745 width: 100%; padding: 8px; border-radius: 8px; border: none;746 background: var(--peach-accent); color: #fff; font-size: 12px;747 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;748 transition: background 120ms, box-shadow 120ms, transform 80ms;749 letter-spacing: 0.01em;750 }751 .save-btn:hover {752 background: color-mix(in srgb, var(--peach-accent) 82%, #000);753 box-shadow: 0 4px 20px var(--peach-glow, transparent);754 }755 .save-btn:disabled { opacity: 0.4; cursor: not-allowed; }756 .url-hint {757 font-size: 9px; color: color-mix(in srgb, var(--peach-accent) 45%, transparent);758 font-family: "IBM Plex Mono", monospace; font-style: italic;759 }760761 /* Success */762 .success-wrap {763 display: flex; flex-direction: column; align-items: center;764 padding: 24px 16px 20px; gap: 8px;765 animation: su-in 280ms cubic-bezier(0.16,1,0.3,1) both;766 }767 @keyframes su-in { from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:none} }768 .success-ring {769 width: 40px; height: 40px; border-radius: 50%;770 background: rgba(123,144,96,0.10); border: 1.5px solid rgba(123,144,96,0.25);771 display: flex; align-items: center; justify-content: center;772 }773 .success-text { font-size: 12.5px; color: var(--peach-text); font-weight: 500; }774 .success-sub { font-size: 10px; color: var(--peach-text-dim); font-family:"IBM Plex Mono",monospace; }775776 /* Silver platter (State 1 — single match) */777 .silver-platter {778 padding: 14px 14px 12px;779 display: flex; flex-direction: column; gap: 6px;780 }781 .sp-title {782 font-size: 14px; font-weight: 500; color: var(--peach-text);783 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;784 line-height: 1.25;785 }786 .sp-identity-row {787 display: flex; align-items: baseline; gap: 5px; margin-bottom: 3px;788 }789 .sp-identity-label {790 font-size: 9px; font-weight: 600; letter-spacing: 0.05em;791 text-transform: uppercase; color: var(--peach-text-muted); flex-shrink: 0;792 }793 .sp-username {794 font-size: 12px; color: var(--peach-text-dim);795 font-family: "IBM Plex Mono", monospace;796 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;797 margin-bottom: 0;798 }799 .sp-identity-row + .sp-fill-btn, .sp-username + .sp-fill-btn { margin-top: 6px; }800 .sp-fill-btn {801 width: 100%; padding: 11px; border-radius: 9px; border: none;802 background: var(--peach-accent); color: #fff;803 font-size: 13px; font-weight: 500; cursor: pointer;804 font-family: Inter, sans-serif; letter-spacing: 0.01em;805 display: flex; align-items: center; justify-content: center; min-height: 38px;806 transition: filter 120ms ease, transform 80ms ease, box-shadow 120ms ease, background 120ms ease;807 }808 .sp-fill-btn:hover {809 filter: brightness(1.1);810 box-shadow: 0 4px 20px var(--peach-glow, transparent);811 transform: translateY(-1px);812 }813 .sp-fill-btn:active { transform: translateY(0); filter: brightness(0.95); }814 .sp-fill-btn.filled {815 background: #16a34a; transform: none; filter: none;816 box-shadow: 0 4px 16px rgba(22,163,74,0.35);817 cursor: default;818 }819 .sp-fill-btn:disabled { cursor: default; }820 .sp-actions {821 display: flex; gap: 4px; justify-content: space-between; align-items: center;822 margin-top: 4px;823 }824 .sp-action-btn {825 flex: 1; height: 28px; border: none; border-radius: 6px;826 background: transparent; color: var(--peach-text-dim);827 font-size: 12px; cursor: pointer;828 transition: background 120ms ease, color 120ms ease;829 font-family: Inter, sans-serif; letter-spacing: 0.04em;830 display: inline-flex; align-items: center; justify-content: center; gap: 4px;831 white-space: nowrap; overflow: hidden;832 }833 .sp-action-btn:hover:not(:disabled) {834 background: color-mix(in srgb, var(--peach-text) 5%, transparent);835 color: var(--peach-text);836 }837 .sp-action-btn:disabled { opacity: 0.3; cursor: default; }838 .sp-action-btn.flashed {839 color: var(--peach-accent);840 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);841 }842843 /* TOTP tray — shown below the silver-platter secondary actions */844 .sp-tray {845 margin-top: 8px;846 padding: 10px 12px;847 border-radius: 9px;848 background: var(--peach-input-bg);849 border: 1px solid var(--peach-input-border);850 display: flex; align-items: center; gap: 12px;851 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;852 }853 .sp-tray-label {854 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;855 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;856 flex-shrink: 0;857 }858 .sp-totp-code {859 font-size: 18px; font-weight: 500;860 color: var(--peach-text);861 font-family: "IBM Plex Mono", monospace;862 letter-spacing: 0.12em;863 flex: 1;864 text-align: center;865 }866 .sp-totp-ring {867 width: 22px; height: 22px; flex-shrink: 0;868 }869 .sp-totp-ring .ring-track { stroke: var(--peach-input-border); }870 .sp-totp-ring .ring-fill {871 stroke: var(--peach-accent);872 transition: stroke-dashoffset 1s linear;873 transform: rotate(-90deg);874 transform-origin: center;875 }876 .sp-totp-copy {877 background: transparent; border: none; cursor: pointer;878 padding: 4px 8px; border-radius: 5px;879 color: var(--peach-text-dim); font-size: 11px;880 font-family: Inter, sans-serif;881 transition: background 120ms, color 120ms;882 }883 .sp-totp-copy:hover {884 background: color-mix(in srgb, var(--peach-text) 5%, transparent);885 color: var(--peach-text);886 }887888 /* Card silver platter (State 7) — reuses .sp-* primary action classes */889 .card-platter {890 padding: 12px 14px 10px;891 display: flex; flex-direction: column; gap: 4px;892 }893 .cp-network {894 font-size: 10px; font-weight: 600;895 color: var(--peach-accent);896 letter-spacing: 0.08em; text-transform: uppercase;897 font-family: Inter, sans-serif;898 }899 .cp-nickname {900 font-size: 14px; font-weight: 500; color: var(--peach-text);901 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;902 line-height: 1.2;903 }904 .cp-last4 {905 font-size: 12px; color: var(--peach-text-dim);906 font-family: "IBM Plex Mono", monospace;907 letter-spacing: 0.04em;908 margin-top: 2px;909 }910 .cp-meta {911 font-size: 11px; color: var(--peach-text-dim);912 font-family: "IBM Plex Mono", monospace;913 margin-top: 2px;914 display: flex; gap: 10px; align-items: center;915 }916 .cp-meta-sep { opacity: 0.5; }917 .cp-fill-wrap { margin-top: 10px; }918919 /* Locked state */920 .locked-wrap {921 display: flex; flex-direction: column; align-items: stretch;922 padding: 14px 13px 13px; gap: 9px;923 }924 .locked-head { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }925 .locked-icon {926 width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;927 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);928 display: flex; align-items: center; justify-content: center;929 }930 .locked-title { font-size: 11.5px; color: var(--peach-text); font-weight: 500; }931 .locked-input {932 width: 100%; background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);933 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;934 font-size: 11px; font-family: "IBM Plex Mono", monospace;935 outline: none; transition: border-color 120ms, box-shadow 120ms;936 }937 .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); }938 .locked-input::placeholder { color: var(--peach-text-muted); }939 .locked-btn {940 width: 100%; padding: 8px; border-radius: 8px; border: none;941 background: var(--peach-accent); color: #fff; font-size: 12px;942 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;943 transition: background 120ms;944 letter-spacing: 0.01em;945 box-shadow: 0 2px 16px var(--peach-glow, transparent);946 animation: peach-pulse-glow 2.4s ease-in-out infinite;947 }948 .locked-btn:hover { background: color-mix(in srgb, var(--peach-accent) 82%, #000); }949 .locked-btn:disabled { opacity: 0.4; cursor: not-allowed; animation: none; }950 .locked-error {951 font-size: 10px; color: rgba(220,80,60,0.85);952 font-family: "IBM Plex Mono", monospace;953 }954955 @keyframes peach-pulse-glow {956 0%, 100% { box-shadow: 0 2px 16px var(--peach-glow, transparent); }957 50% { box-shadow: 0 2px 28px var(--peach-glow, transparent),958 0 0 48px var(--peach-glow, transparent); }959 }960961 /* ── State 10: identity helper ─────────────────────────────── */962 .identity-list {963 max-height: 192px; overflow-y: auto; padding: 4px 0;964 scrollbar-width: none;965 }966 .identity-list::-webkit-scrollbar { display: none; }967 .peach-identity-row {968 display: flex; align-items: center; gap: 10px;969 padding: 9px 12px; cursor: pointer; border-radius: 8px;970 transition: background 100ms ease;971 }972 .peach-identity-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }973 .peach-identity-value {974 font-family: "IBM Plex Mono", monospace; font-size: 13px;975 color: var(--peach-text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;976 }977 .peach-identity-meta { font-size: 10px; color: var(--peach-text-muted); flex-shrink: 0; }978 .identity-alt-row {979 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;980 border-radius: 8px; transition: background 100ms ease;981 color: var(--peach-text-dim); font-size: 12px; font-family: Inter, sans-serif;982 }983 .identity-alt-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }984 .identity-alt-input-wrap { display: none; padding: 0 12px 8px; gap: 6px; align-items: center; }985 .identity-alt-input-wrap.open { display: flex; }986 .identity-alt-input {987 flex: 1; height: 32px; padding: 0 10px; border-radius: 7px;988 border: 1px solid var(--peach-input-border); background: var(--peach-input-bg);989 color: var(--peach-text); font-family: "IBM Plex Mono", monospace; font-size: 12px;990 outline: none; transition: border-color 120ms;991 }992 .identity-alt-input:focus {993 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);994 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);995 }996 .identity-alt-confirm {997 height: 32px; padding: 0 12px; border-radius: 7px; border: none;998 background: var(--peach-accent); color: #fff; font-size: 12px;999 cursor: pointer; font-family: Inter, sans-serif; flex-shrink: 0;1000 }1001 /* ── Generator view (after identity picked) ────────────────── */1002 .gen-view { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1003 .gen-confirmed {1004 display: flex; align-items: center; gap: 8px; padding: 7px 10px;1005 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1006 border-radius: 8px;1007 }1008 .gen-confirmed-check { color: var(--peach-accent); font-size: 13px; font-weight: 600; }1009 .gen-confirmed-val {1010 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1011 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1012 }1013 .gen-label {1014 font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;1015 color: var(--peach-text-muted); font-family: "IBM Plex Mono", monospace;1016 }1017 .gen-pw-row { display: flex; gap: 6px; align-items: center; }1018 .gen-pw-val {1019 flex: 1; padding: 8px 10px; border-radius: 7px;1020 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1021 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1022 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;1023 }1024 .gen-regen-btn {1025 height: 34px; padding: 0 10px; border-radius: 7px; border: none;1026 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1027 color: var(--peach-text-dim); font-size: 11px; cursor: pointer;1028 font-family: "IBM Plex Mono", monospace; transition: background 100ms ease;1029 }1030 .gen-regen-btn:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1031 .gen-fill-btn {1032 padding: 10px; border-radius: 8px; border: none;1033 background: var(--peach-accent); color: #fff; font-size: 13px; font-weight: 500;1034 cursor: pointer; font-family: Inter, sans-serif; letter-spacing: 0.01em;1035 transition: filter 120ms ease, transform 80ms ease;1036 }1037 .gen-fill-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }1038 .gen-fill-btn:active { transform: translateY(0); }10391040 /* ── Smart password generator (parity with main UI compact mode) ─── */1041 .pwgen-block { display: flex; flex-direction: column; gap: 8px; }1042 .pwgen-display-row {1043 display: flex; align-items: center; gap: 6px;1044 padding: 8px 10px; border-radius: 7px;1045 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1046 }1047 .pwgen-output {1048 flex: 1; min-width: 0; width: 0;1049 font-family: "IBM Plex Mono", monospace; font-size: 12px;1050 color: var(--peach-text);1051 background: transparent; border: none; outline: none; padding: 0;1052 }1053 .pwgen-icon-btn {1054 flex-shrink: 0;1055 width: 26px; height: 26px;1056 display: inline-flex; align-items: center; justify-content: center;1057 background: transparent; border: 1px solid var(--peach-input-border);1058 border-radius: 6px; color: var(--peach-text-dim); cursor: pointer;1059 padding: 0; transition: background 100ms, color 100ms, border-color 100ms;1060 }1061 .pwgen-icon-btn:hover {1062 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1063 color: var(--peach-accent);1064 border-color: color-mix(in srgb, var(--peach-accent) 30%, transparent);1065 }1066 .pwgen-icon-btn.is-copied {1067 background: color-mix(in srgb, var(--peach-accent) 18%, transparent);1068 color: var(--peach-accent);1069 border-color: color-mix(in srgb, var(--peach-accent) 45%, transparent);1070 }1071 .pwgen-controls-row {1072 display: flex; align-items: center; gap: 8px;1073 flex-wrap: wrap;1074 }1075 .pwgen-slider {1076 flex: 1; min-width: 110px;1077 accent-color: var(--peach-accent);1078 cursor: pointer; height: 2px; background: transparent;1079 }1080 .pwgen-len-num {1081 font-family: "IBM Plex Mono", monospace; font-size: 11px;1082 color: var(--peach-accent); min-width: 22px; text-align: right;1083 }1084 .pwgen-len-num--edit { cursor: text; border-bottom: 1px dotted color-mix(in srgb, var(--peach-accent) 50%, transparent); }1085 .pwgen-len-input {1086 font-family: "IBM Plex Mono", monospace; font-size: 11px;1087 color: var(--peach-accent); width: 28px; text-align: right;1088 background: transparent; border: none; border-bottom: 1px solid var(--peach-accent);1089 outline: none; padding: 0; min-width: 22px;1090 }1091 .identity-suggest-list { display: flex; flex-direction: column; gap: 1px; margin-top: 3px; }1092 .identity-filter-row { display: flex; gap: 4px; padding: 2px 0 4px; }1093 .identity-filter-pill {1094 padding: 2px 7px; border-radius: 999px;1095 border: 1px solid var(--peach-input-border);1096 background: transparent; color: var(--peach-text-muted);1097 font-family: "IBM Plex Mono", monospace; font-size: 9px;1098 cursor: pointer; transition: border-color 80ms, background 80ms, color 80ms;1099 }1100 .identity-filter-pill.is-on {1101 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1102 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1103 color: var(--peach-accent);1104 }1105 .identity-suggest-row {1106 display: flex; align-items: center; gap: 5px;1107 width: 100%; padding: 4px 6px; border-radius: 5px; border: none;1108 background: transparent; cursor: pointer; text-align: left;1109 transition: background 80ms;1110 }1111 .identity-suggest-row:hover { background: color-mix(in srgb, var(--peach-accent) 10%, transparent); }1112 .identity-suggest-val {1113 font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--peach-text);1114 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;1115 }1116 .identity-suggest-type {1117 font-family: "IBM Plex Mono", monospace; font-size: 8px; font-weight: 600;1118 flex-shrink: 0; padding: 1px 3px; border-radius: 3px;1119 }1120 .identity-suggest-type--email {1121 color: color-mix(in srgb, var(--peach-accent) 70%, transparent);1122 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);1123 }1124 .identity-suggest-type--username {1125 color: var(--peach-text-muted);1126 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1127 }1128 .identity-suggest-meta {1129 font-family: "IBM Plex Mono", monospace; font-size: 9px;1130 color: var(--peach-text-muted); flex-shrink: 0;1131 }1132 .pwgen-pills { display: flex; gap: 5px; flex-wrap: wrap; }1133 .pwgen-pill {1134 padding: 3px 8px; border-radius: 999px;1135 border: 1px solid var(--peach-input-border);1136 background: transparent; color: var(--peach-text-muted);1137 font-family: "IBM Plex Mono", monospace; font-size: 9px;1138 letter-spacing: 0.06em; cursor: pointer;1139 transition: all 130ms ease;1140 }1141 .pwgen-pill.is-on {1142 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1143 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1144 color: var(--peach-accent);1145 }1146 .pwgen-pill:not(.is-on):hover {1147 color: var(--peach-text-dim);1148 border-color: var(--peach-text-muted);1149 }1150 .pwgen-policy-hint {1151 font-size: 10px; color: var(--peach-text-muted);1152 font-family: "IBM Plex Mono", monospace; letter-spacing: 0.04em;1153 line-height: 1.3;1154 }1155 .pwgen-policy-hint .pwgen-hint-accent { color: var(--peach-accent); }11561157 /* ── Save offer (after password filled) ───────────────────── */1158 .save-offer { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1159 .save-offer-title {1160 font-size: 12px; font-weight: 600; color: var(--peach-text); font-family: Inter, sans-serif;1161 }1162 .save-offer-row {1163 display: flex; align-items: center; gap: 8px; padding: 6px 8px;1164 border-radius: 7px; background: var(--peach-input-bg);1165 border: 1px solid var(--peach-input-border);1166 }1167 .save-offer-lbl {1168 font-size: 10px; color: var(--peach-text-muted); width: 54px; flex-shrink: 0;1169 font-family: "IBM Plex Mono", monospace;1170 }1171 .save-offer-val {1172 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1173 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1174 }1175 .save-offer-btns { display: flex; gap: 8px; margin-top: 4px; }1176 .save-offer-save {1177 flex: 1; padding: 9px; border-radius: 8px; border: none;1178 background: var(--peach-accent); color: #fff; font-size: 13px;1179 cursor: pointer; font-family: Inter, sans-serif; transition: filter 120ms ease;1180 }1181 .save-offer-save:hover { filter: brightness(1.08); }1182 .save-offer-skip {1183 flex: 1; padding: 9px; border-radius: 8px; border: none;1184 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1185 color: var(--peach-text-dim); font-size: 13px; cursor: pointer;1186 font-family: Inter, sans-serif; transition: background 100ms ease;1187 }1188 .save-offer-skip:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1189`;11901191export function showAutofillSelector(1192 anchorEl: HTMLInputElement,1193 entries: SelectorEntry[],1194 onSelect: (id: string) => void,1195 options: SelectorOptions = {}1196): () => void {1197 const host = document.createElement("div");1198 host.style.cssText = "position: absolute; z-index: 2147483647;";1199 host.style.setProperty("--peach-accent", accentHex);1200 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));1201 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));1202 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));1203 const shadow = host.attachShadow({ mode: "closed" });12041205 const style = shadow.appendChild(document.createElement("style"));1206 style.textContent = SELECTOR_STYLES;12071208 const rect = anchorEl.getBoundingClientRect();1209 host.style.top = `${rect.bottom + window.scrollY + 5}px`;1210 host.style.left = `${rect.left + window.scrollX}px`;1211 1212 1213 host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;12141215 const container = shadow.appendChild(document.createElement("div"));1216 container.className = "peach-inline-popup";1217 container.setAttribute("data-theme", popupTheme);12181219 const searchableEntries = options.searchableEntries ?? [];1220 const { origin: sOrigin, title: sTitle, loginSubdomain } = smartUrl();12211222 let query = "";1223 let focusedIndex = -1;1224 let currentMode: "list" | "create" | "success" | "silver-platter" = "list";1225 let searchInput: HTMLInputElement | null = null;1226 1227 1228 const cleanupHooks: Array<() => void> = [];12291230 1231 const preUsername = (anchorEl.type !== "password") ? (anchorEl.value?.trim() ?? "") : "";1232 const pwInForm = anchorEl.closest("form")?.querySelector<HTMLInputElement>("input[type='password']");1233 const prePassword = pwInForm?.value?.trim() ?? (anchorEl.type === "password" ? anchorEl.value?.trim() : "") ?? "";12341235 function uniqueEntries(list: SelectorEntry[]): SelectorEntry[] {1236 const seen = new Set<string>();1237 return list.filter(e => { if (seen.has(e.id)) return false; seen.add(e.id); return true; });1238 }12391240 function filterEntries(source: SelectorEntry[], value: string): SelectorEntry[] {1241 const q = value.trim().toLowerCase();1242 const deduped = uniqueEntries(source);1243 if (!q) return deduped.slice(0, 8);1244 return deduped.filter(e =>1245 [e.title, e.username ?? "", e.url ?? ""].join(" ").toLowerCase().includes(q)1246 ).slice(0, 12);1247 }12481249 function activeEntries(): SelectorEntry[] {1250 1251 if (query.trim()) {1252 const merged = uniqueEntries([...entries, ...searchableEntries]);1253 return filterEntries(merged, query);1254 }1255 1256 if (entries.length > 0) return entries;1257 return filterEntries(searchableEntries, "").slice(0, 8);1258 }12591260 function makeEntryIcon(url?: string, isNew = false): HTMLDivElement {1261 const icon = document.createElement("div");1262 icon.className = `entry-icon${isNew ? " is-new" : ""}`;1263 if (isNew) {1264 icon.innerHTML = plusSvgStr();1265 } else {1266 1267 1268 1269 void url;1270 icon.innerHTML = keySvgStr();1271 }1272 return icon;1273 }12741275 function renderIdentityHelper() {1276 container.innerHTML = "";1277 const identities = options.savedIdentities ?? [];12781279 1280 const hdr = container.appendChild(document.createElement("div"));1281 hdr.className = "domain-header";1282 const eyebrow = hdr.appendChild(document.createElement("div"));1283 eyebrow.className = "domain-eyebrow";1284 eyebrow.textContent = "NEW ACCOUNT";1285 const domName = hdr.appendChild(document.createElement("div"));1286 domName.className = "domain-name";1287 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");12881289 1290 const list = container.appendChild(document.createElement("div"));1291 list.className = "identity-list";1292 for (const id of identities) {1293 const row = list.appendChild(document.createElement("div"));1294 row.className = "peach-identity-row";1295 row.setAttribute("tabindex", "-1");1296 const val = row.appendChild(document.createElement("div"));1297 val.className = "peach-identity-value";1298 val.textContent = id.value;1299 const meta = row.appendChild(document.createElement("div"));1300 meta.className = "peach-identity-meta";1301 meta.textContent = `used ${id.useCount}×`;1302 row.addEventListener("click", () => {1303 options.onFillFields?.(id.value, "");1304 renderGenerator(id.value);1305 });1306 }13071308 1309 if (identities.length > 0) {1310 container.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1311 }13121313 1314 const altRow = container.appendChild(document.createElement("div"));1315 altRow.className = "identity-alt-row";1316 altRow.textContent = "+ Use a different email…";13171318 const altInputWrap = container.appendChild(document.createElement("div"));1319 altInputWrap.className = "identity-alt-input-wrap";1320 const altInput = altInputWrap.appendChild(document.createElement("input"));1321 altInput.className = "identity-alt-input";1322 altInput.type = "email";1323 altInput.placeholder = "[email protected]";1324 altInput.setAttribute("autocomplete", "off");1325 const altConfirm = altInputWrap.appendChild(document.createElement("button"));1326 altConfirm.className = "identity-alt-confirm";1327 altConfirm.type = "button";1328 altConfirm.textContent = "✓";13291330 function fillCustomEmail() {1331 const v = altInput.value.trim();1332 if (!v) return;1333 options.onFillFields?.(v, "");1334 renderGenerator(v);1335 }13361337 altRow.addEventListener("click", () => {1338 altRow.style.display = "none";1339 altInputWrap.classList.add("open");1340 altInput.focus();1341 });1342 altConfirm.addEventListener("click", fillCustomEmail);1343 altInput.addEventListener("keydown", (e) => {1344 if (e.key === "Enter") { e.preventDefault(); fillCustomEmail(); }1345 });1346 }13471348 function renderGenerator(filledEmail: string) {1349 container.innerHTML = "";1350 const sitePolicy = detectPasswordPolicy();13511352 const wrap = container.appendChild(document.createElement("div"));1353 wrap.className = "gen-view";13541355 1356 const hdrRow = wrap.appendChild(document.createElement("div"));1357 hdrRow.className = "domain-header";1358 const eyebrow2 = hdrRow.appendChild(document.createElement("div"));1359 eyebrow2.className = "domain-eyebrow";1360 eyebrow2.textContent = "NEW ACCOUNT";1361 const domName2 = hdrRow.appendChild(document.createElement("div"));1362 domName2.className = "domain-name";1363 domName2.textContent = options.domain ?? location.hostname.replace(/^www\./, "");13641365 1366 const conf = wrap.appendChild(document.createElement("div"));1367 conf.className = "gen-confirmed";1368 const confCheck = conf.appendChild(document.createElement("span"));1369 confCheck.className = "gen-confirmed-check";1370 confCheck.textContent = "✓";1371 const confVal = conf.appendChild(document.createElement("div"));1372 confVal.className = "gen-confirmed-val";1373 confVal.textContent = filledEmail;13741375 const lbl = wrap.appendChild(document.createElement("div"));1376 lbl.className = "gen-label";1377 lbl.textContent = "Generate a password";13781379 let currentPw = "";1380 const smartGen = createSmartGenerator({1381 policy: sitePolicy,1382 onChange: (pw) => { currentPw = pw; },1383 });1384 wrap.appendChild(smartGen.root);13851386 const fillBtn = wrap.appendChild(document.createElement("button"));1387 fillBtn.className = "gen-fill-btn";1388 fillBtn.type = "button";1389 fillBtn.textContent = "Copy & fill";1390 fillBtn.addEventListener("click", () => {1391 if (!currentPw) return;1392 options.onFillFields?.("", currentPw);1393 renderSaveOffer(filledEmail, currentPw);1394 });1395 }13961397 function renderSaveOffer(filledEmail: string, filledPassword: string) {1398 container.innerHTML = "";1399 const domain = options.domain ?? location.hostname.replace(/^www\./, "");14001401 const wrap = container.appendChild(document.createElement("div"));1402 wrap.className = "save-offer";14031404 const title = wrap.appendChild(document.createElement("div"));1405 title.className = "save-offer-title";1406 title.textContent = "Save this login to Peach?";14071408 function detailRow(label: string, value: string) {1409 const row = wrap.appendChild(document.createElement("div"));1410 row.className = "save-offer-row";1411 const lbl = row.appendChild(document.createElement("div"));1412 lbl.className = "save-offer-lbl";1413 lbl.textContent = label;1414 const val = row.appendChild(document.createElement("div"));1415 val.className = "save-offer-val";1416 val.textContent = value;1417 }14181419 detailRow("site", domain);1420 detailRow("email", filledEmail);1421 detailRow("password", "••••••••••••••••");14221423 const btns = wrap.appendChild(document.createElement("div"));1424 btns.className = "save-offer-btns";14251426 const saveBtn = btns.appendChild(document.createElement("button"));1427 saveBtn.className = "save-offer-save";1428 saveBtn.type = "button";1429 saveBtn.textContent = "Save";1430 saveBtn.addEventListener("click", async () => {1431 saveBtn.disabled = true;1432 saveBtn.textContent = "Saving…";1433 try {1434 const res = await chrome.runtime.sendMessage({1435 type: "ADD_ENTRY",1436 payload: { title: sTitle, url: sOrigin, username: filledEmail, password: filledPassword, type: "login" },1437 });1438 if ((res as { ok?: boolean }).ok) {1439 showSuccess(sTitle);1440 } else {1441 saveBtn.disabled = false;1442 saveBtn.textContent = "Save";1443 }1444 } catch { saveBtn.disabled = false; saveBtn.textContent = "Save"; }1445 });14461447 const skipBtn = btns.appendChild(document.createElement("button"));1448 skipBtn.className = "save-offer-skip";1449 skipBtn.type = "button";1450 skipBtn.textContent = "Not now";1451 skipBtn.addEventListener("click", () => { dismiss(true); });1452 }14531454 function renderList() {1455 container.innerHTML = "";1456 focusedIndex = -1;1457 searchInput = null;14581459 const current = activeEntries();14601461 1462 1463 1464 const domHdr = document.createElement("div");1465 domHdr.className = "domain-header";1466 const headText = document.createElement("div");1467 headText.className = "domain-header-text";1468 const eyebrow = document.createElement("div");1469 eyebrow.className = "domain-eyebrow";1470 eyebrow.textContent = options.isSignup1471 ? "Sign up as"1472 : entries.length > 0 ? "Saved for this site" : "No saved login";1473 const domName = document.createElement("div");1474 domName.className = "domain-name";1475 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1476 headText.append(eyebrow, domName);1477 domHdr.appendChild(headText);14781479 if (!options.isSignup) {1480 const addBtn = document.createElement("button");1481 addBtn.className = "domain-add-btn";1482 addBtn.type = "button";1483 addBtn.setAttribute("aria-label", "Create new entry");1484 addBtn.title = "Create new entry";1485 addBtn.textContent = "+";1486 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1487 domHdr.appendChild(addBtn);1488 }14891490 container.appendChild(domHdr);14911492 1493 const sw = document.createElement("div"); sw.className = "search-wrap";1494 searchInput = document.createElement("input");1495 searchInput.className = "search";1496 searchInput.placeholder = entries.length > 0 ? "search for another entry…" : "search vault…";1497 searchInput.value = query;1498 searchInput.addEventListener("input", () => {1499 query = searchInput?.value ?? "";1500 renderList();1501 searchInput?.focus();1502 searchInput?.setSelectionRange(query.length, query.length);1503 });1504 sw.appendChild(searchInput);1505 container.appendChild(sw);15061507 1508 const results = document.createElement("div");1509 results.className = "results";1510 container.appendChild(results);15111512 if (current.length === 0 && entries.length > 0) {1513 1514 }15151516 for (let i = 0; i < current.length; i++) {1517 const e = current[i]!;1518 const entryEl = document.createElement("div");1519 entryEl.className = "entry";1520 entryEl.dataset.id = e.id;1521 entryEl.dataset.index = String(i);1522 entryEl.setAttribute("tabindex", "-1");15231524 entryEl.appendChild(makeEntryIcon(e.url));15251526 const info = document.createElement("div"); info.className = "entry-info";1527 const titleEl = document.createElement("div"); titleEl.className = "entry-title"; titleEl.textContent = e.title;1528 const subEl = document.createElement("div"); subEl.className = "entry-sub";1529 const domain = e.url ? getDomainFromUrl(e.url) : "";1530 subEl.textContent = domain || e.username || "";1531 info.append(titleEl, subEl);1532 entryEl.appendChild(info);15331534 if (e.hasTotp) {1535 const badge = document.createElement("span"); badge.className = "totp-badge"; badge.textContent = "TOTP";1536 entryEl.appendChild(badge);1537 }1538 if (e.hasPasskey) {1539 const badge = document.createElement("span"); badge.className = "passkey-badge"; badge.textContent = "passkey";1540 entryEl.appendChild(badge);1541 }15421543 entryEl.addEventListener("click", () => {1544 if (options.isSignup && options.onFillFields) {1545 1546 options.onFillFields(e.username ?? "", "");1547 dismiss();1548 } else {1549 onSelect(e.id);1550 dismiss();1551 }1552 });1553 results.appendChild(entryEl);1554 }15551556 1557 if (current.length > 0) {1558 results.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1559 }15601561 1562 const newEl = document.createElement("div");1563 newEl.className = "entry";1564 newEl.setAttribute("tabindex", "-1");1565 newEl.appendChild(makeEntryIcon(undefined, true));15661567 const newInfo = document.createElement("div"); newInfo.className = "entry-info";1568 const newTitle = document.createElement("div");1569 newTitle.className = "entry-title is-new";1570 newTitle.textContent = `New entry for ${sTitle}`;1571 const newSub = document.createElement("div");1572 newSub.className = "entry-sub";1573 newSub.textContent = sOrigin;1574 newInfo.append(newTitle, newSub);1575 newEl.appendChild(newInfo);1576 newEl.addEventListener("click", showCreateForm);1577 results.appendChild(newEl);15781579 1580 if (searchInput) {1581 requestAnimationFrame(() => searchInput?.focus());1582 }1583 }15841585 function setFocused(idx: number) {1586 const all = container.querySelectorAll<HTMLElement>(".entry");1587 all.forEach((el, i) => el.classList.toggle("focused", i === idx));1588 focusedIndex = idx;1589 if (idx >= 0) (all[idx] as HTMLElement).scrollIntoView({ block: "nearest" });1590 }15911592 function attachIdentitySuggestions(g: HTMLDivElement, inp: HTMLInputElement, identities: SavedIdentity[]): void {1593 if (!identities.length) return;1594 let activeFilter: "all" | "username" | "email" = "all";15951596 const list = g.appendChild(document.createElement("div"));1597 list.className = "identity-suggest-list";1598 list.style.display = "none";15991600 1601 const filterRow = list.appendChild(document.createElement("div"));1602 filterRow.className = "identity-filter-row";1603 function makePill(label: string, value: "all" | "username" | "email") {1604 const b = filterRow.appendChild(document.createElement("button"));1605 b.type = "button"; b.className = "identity-filter-pill"; b.textContent = label;1606 b.addEventListener("mousedown", (e) => {1607 e.preventDefault();1608 activeFilter = value;1609 filterRow.querySelectorAll(".identity-filter-pill").forEach(p => p.classList.remove("is-on"));1610 b.classList.add("is-on");1611 render();1612 });1613 if (value === "all") b.classList.add("is-on");1614 return b;1615 }1616 makePill("all", "all");1617 makePill("user", "username");1618 makePill("email", "email");16191620 const rows = list.appendChild(document.createElement("div"));16211622 function render() {1623 const q = inp.value.toLowerCase();1624 const filtered = identities1625 .filter(s => (activeFilter === "all" || s.type === activeFilter) && (!q || s.value.toLowerCase().includes(q)))1626 .slice(0, 8);1627 rows.innerHTML = "";1628 if (!filtered.length) { list.style.display = rows.children.length === 0 ? "none" : ""; return; }1629 for (const s of filtered) {1630 const row = rows.appendChild(document.createElement("button"));1631 row.type = "button"; row.className = "identity-suggest-row";1632 const val = row.appendChild(document.createElement("span"));1633 val.className = "identity-suggest-val"; val.textContent = s.value;1634 const badge = row.appendChild(document.createElement("span"));1635 badge.className = `identity-suggest-type identity-suggest-type--${s.type}`;1636 badge.textContent = s.type === "email" ? "@" : "u";1637 const meta = row.appendChild(document.createElement("span"));1638 meta.className = "identity-suggest-meta"; meta.textContent = `${s.useCount}×`;1639 row.addEventListener("mousedown", (e) => {1640 e.preventDefault();1641 inp.value = s.value;1642 list.style.display = "none";1643 });1644 }1645 list.style.display = "";1646 }1647 inp.addEventListener("focus", render);1648 inp.addEventListener("input", render);1649 inp.addEventListener("blur", () => setTimeout(() => { list.style.display = "none"; }, 150));1650 }16511652 async function showCreateForm() {1653 currentMode = "create";1654 container.innerHTML = "";16551656 1657 1658 1659 const statusRes = await chrome.runtime.sendMessage({ type: "GET_VAULT_STATUS" }).catch(() => null) as { unlocked?: boolean } | null;1660 if (!statusRes?.unlocked) {1661 renderLocked();1662 return;1663 }16641665 1666 1667 const sitePolicy = detectPasswordPolicy();16681669 1670 1671 let formIdentities: SavedIdentity[] = options.savedIdentities ?? [];1672 if (!formIdentities.length) {1673 try {1674 const idRes = await chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null) as { ok: boolean; data?: SavedIdentity[] } | null;1675 if (idRes?.ok && Array.isArray(idRes.data)) formIdentities = idRes.data;1676 } catch { }1677 }16781679 const wrap = document.createElement("div");1680 wrap.className = "create-form-wrap";16811682 1683 const head = document.createElement("div"); head.className = "create-head";1684 const backBtn = document.createElement("button"); backBtn.className = "back-btn";1685 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>`;1686 backBtn.addEventListener("click", () => { currentMode = "list"; renderList(); });1687 const lbl = document.createElement("div"); lbl.className = "create-label"; lbl.textContent = "New entry";1688 head.append(backBtn, lbl);16891690 1691 const body = document.createElement("div"); body.className = "create-body";16921693 function fGroup(label: string): { g: HTMLDivElement; inp: HTMLInputElement } {1694 const g = document.createElement("div"); g.className = "f-group";1695 const l = document.createElement("div"); l.className = "f-label"; l.textContent = label;1696 const inp = document.createElement("input"); inp.className = "f-input";1697 g.append(l, inp); return { g, inp };1698 }16991700 1701 const tg = fGroup("title"); tg.inp.value = sTitle; tg.inp.placeholder = "e.g. Google";1702 body.appendChild(tg.g);17031704 1705 const ug = fGroup("website");1706 ug.inp.className = "f-input url-f"; ug.inp.value = sOrigin; ug.inp.placeholder = "https://";1707 if (loginSubdomain) {1708 const h = document.createElement("div"); h.className = "url-hint";1709 h.textContent = "⊘ Recognized sign-in subdomain"; ug.g.appendChild(h);1710 }1711 body.appendChild(ug.g);17121713 1714 const xg = fGroup("username");1715 xg.inp.value = preUsername && !preUsername.includes("@") ? preUsername : "";1716 xg.inp.placeholder = "johndoe";1717 xg.inp.setAttribute("autocomplete", "off");1718 if (formIdentities.length) attachIdentitySuggestions(xg.g, xg.inp, formIdentities);1719 body.appendChild(xg.g);17201721 1722 const eg = fGroup("email");1723 (eg.inp as HTMLInputElement).type = "email";1724 eg.inp.value = preUsername && preUsername.includes("@") ? preUsername : "";1725 eg.inp.placeholder = "[email protected]";1726 eg.inp.setAttribute("autocomplete", "off");1727 if (formIdentities.length) attachIdentitySuggestions(eg.g, eg.inp, formIdentities);1728 body.appendChild(eg.g);17291730 1731 1732 1733 const pg = fGroup("password");1734 let currentPassword = prePassword || "";1735 const smartGen = createSmartGenerator({1736 policy: sitePolicy,1737 initialPassword: prePassword || undefined,1738 onChange: (pw) => { currentPassword = pw; },1739 });1740 pg.g.appendChild(smartGen.root);1741 body.appendChild(pg.g);17421743 1744 const saveBtn = document.createElement("button"); saveBtn.className = "save-btn"; saveBtn.type = "button";1745 saveBtn.textContent = "Save entry";1746 const errEl = document.createElement("div"); errEl.className = "locked-error"; errEl.style.display = "none";1747 function showFormError(msg: string) { errEl.textContent = msg; errEl.style.display = ""; }1748 saveBtn.addEventListener("click", async () => {1749 const title = tg.inp.value.trim();1750 const pw = currentPassword.trim();1751 const username = xg.inp.value.trim();1752 const email = eg.inp.value.trim();1753 if (!title) {1754 tg.inp.style.borderColor = "rgba(220,70,60,0.5)"; tg.inp.focus();1755 showFormError("Entry needs a title");1756 return;1757 }1758 if (!pw) {1759 showFormError("Entry needs a password — tap regen to make one");1760 return;1761 }1762 errEl.style.display = "none";1763 saveBtn.disabled = true; saveBtn.textContent = "Saving…";1764 try {1765 const res = await chrome.runtime.sendMessage({1766 type: "ADD_ENTRY",1767 payload: { title, url: ug.inp.value.trim(), username, email: email || undefined, password: pw, type: "login" },1768 });1769 if ((res as { ok?: boolean }).ok) {1770 1771 1772 options.onFillFields?.(username || email, pw);1773 showSuccess(title);1774 } else {1775 const errMsg = (res as { error?: string }).error === "vault locked"1776 ? "Vault locked — open Peach to save"1777 : "Could not save entry";1778 showFormError(errMsg);1779 saveBtn.disabled = false; saveBtn.textContent = "Save entry";1780 }1781 } catch { showFormError("Could not reach Peach"); saveBtn.disabled = false; saveBtn.textContent = "Save entry"; }1782 });1783 body.appendChild(saveBtn);1784 body.appendChild(errEl);17851786 wrap.append(head, body);1787 container.appendChild(wrap);1788 requestAnimationFrame(() => { tg.inp.focus(); tg.inp.select(); });1789 }17901791 function showSuccess(title: string) {1792 currentMode = "success";1793 container.innerHTML = "";1794 const wrap = document.createElement("div"); wrap.className = "success-wrap";1795 const ring = document.createElement("div"); ring.className = "success-ring";1796 ring.innerHTML = checkSvgStr();1797 const t = document.createElement("div"); t.className = "success-text"; t.textContent = `${title} saved`;1798 const s = document.createElement("div"); s.className = "success-sub"; s.textContent = sOrigin;1799 wrap.append(ring, t, s);1800 container.appendChild(wrap);1801 setTimeout(() => dismiss(), 1600);1802 }18031804 function flashActionBtn(btn: HTMLButtonElement) {1805 btn.classList.add("flashed");1806 setTimeout(() => btn.classList.remove("flashed"), 700);1807 }18081809 function renderSilverPlatter(entry: SelectorEntry) {1810 container.innerHTML = "";1811 searchInput = null;1812 focusedIndex = -1;1813 currentMode = "silver-platter";18141815 const domHdr = document.createElement("div");1816 domHdr.className = "domain-header";1817 const headText = document.createElement("div");1818 headText.className = "domain-header-text";1819 const eyebrow = document.createElement("div");1820 eyebrow.className = "domain-eyebrow";1821 eyebrow.textContent = "Saved for this site";1822 const domName = document.createElement("div");1823 domName.className = "domain-name";1824 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1825 headText.append(eyebrow, domName);1826 domHdr.appendChild(headText);1827 if (!options.isSignup) {1828 const addBtn = document.createElement("button");1829 addBtn.className = "domain-add-btn";1830 addBtn.type = "button";1831 addBtn.setAttribute("aria-label", "Create new entry");1832 addBtn.title = "Create new entry";1833 addBtn.textContent = "+";1834 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1835 domHdr.appendChild(addBtn);1836 }1837 container.appendChild(domHdr);18381839 const platter = document.createElement("div");1840 platter.className = "silver-platter";18411842 const titleEl = document.createElement("div");1843 titleEl.className = "sp-title";1844 titleEl.textContent = entry.title;1845 platter.appendChild(titleEl);18461847 if (entry.email) {1848 const emailEl = document.createElement("div");1849 emailEl.className = "sp-identity-row";1850 const emailLbl = document.createElement("span");1851 emailLbl.className = "sp-identity-label";1852 emailLbl.textContent = "email";1853 const emailVal = document.createElement("span");1854 emailVal.className = "sp-username";1855 emailVal.textContent = entry.email;1856 emailEl.append(emailLbl, emailVal);1857 platter.appendChild(emailEl);1858 }18591860 if (entry.username) {1861 const userEl = document.createElement("div");1862 userEl.className = "sp-identity-row";1863 const userLbl = document.createElement("span");1864 userLbl.className = "sp-identity-label";1865 userLbl.textContent = entry.username.includes("@") ? "email" : "username";1866 const userVal = document.createElement("span");1867 userVal.className = "sp-username";1868 userVal.textContent = entry.username;1869 userEl.append(userLbl, userVal);1870 platter.appendChild(userEl);1871 }18721873 const fillBtn = document.createElement("button");1874 fillBtn.className = "sp-fill-btn";1875 fillBtn.type = "button";1876 fillBtn.textContent = "Fill credentials";1877 fillBtn.addEventListener("click", () => {1878 if (fillBtn.disabled) return;1879 fillBtn.disabled = true;1880 fillBtn.classList.add("filled");1881 fillBtn.innerHTML = checkSvgStr();1882 1883 1884 1885 1886 onSelect(entry.id);1887 setTimeout(() => dismiss(), 400);1888 });1889 platter.appendChild(fillBtn);18901891 const actions = document.createElement("div");1892 actions.className = "sp-actions";18931894 if (entry.email) {1895 const copyEmail = document.createElement("button");1896 copyEmail.className = "sp-action-btn";1897 copyEmail.type = "button";1898 copyEmail.title = "Copy email";1899 copyEmail.textContent = "Copy email";1900 copyEmail.addEventListener("click", async (e) => {1901 e.stopPropagation();1902 let alreadyWritten = false;1903 try { await navigator.clipboard.writeText(entry.email!); alreadyWritten = true; } catch {}1904 await chrome.runtime.sendMessage({1905 type: "COPY",1906 payload: { text: entry.email, label: "Email", alreadyWritten },1907 }).catch(() => {});1908 flashActionBtn(copyEmail);1909 });1910 actions.appendChild(copyEmail);1911 }19121913 const copyU = document.createElement("button");1914 copyU.className = "sp-action-btn";1915 copyU.type = "button";1916 const copyULabel = entry.username?.includes("@") ? "Copy email" : "Copy username";1917 copyU.title = copyULabel;1918 copyU.textContent = copyULabel;1919 copyU.disabled = !entry.username;1920 copyU.addEventListener("click", async (e) => {1921 e.stopPropagation();1922 if (!entry.username) return;1923 let alreadyWritten = false;1924 try { await navigator.clipboard.writeText(entry.username); alreadyWritten = true; } catch {}1925 await chrome.runtime.sendMessage({1926 type: "COPY",1927 payload: { text: entry.username, label: entry.username.includes("@") ? "Email" : "Username", alreadyWritten },1928 }).catch(() => {});1929 flashActionBtn(copyU);1930 });1931 actions.appendChild(copyU);19321933 const copyP = document.createElement("button");1934 copyP.className = "sp-action-btn";1935 copyP.type = "button";1936 copyP.title = "Copy password";1937 copyP.textContent = "Copy password";1938 copyP.addEventListener("click", async (e) => {1939 e.stopPropagation();1940 const resp = await chrome.runtime.sendMessage({1941 type: "GET_ENTRY_FOR_FILL",1942 payload: { id: entry.id },1943 }).catch(() => null) as { ok: boolean; data?: { password?: string } } | null;1944 if (!resp?.ok || !resp.data?.password) return;1945 let alreadyWritten = false;1946 try { await navigator.clipboard.writeText(resp.data.password); alreadyWritten = true; } catch {}1947 await chrome.runtime.sendMessage({1948 type: "COPY",1949 payload: { text: resp.data.password, label: "Password", alreadyWritten },1950 }).catch(() => {});1951 flashActionBtn(copyP);1952 });1953 actions.appendChild(copyP);19541955 let trayEl: HTMLDivElement | null = null;1956 let trayInterval: ReturnType<typeof setInterval> | null = null;19571958 function closeTray() {1959 if (trayInterval) { clearInterval(trayInterval); trayInterval = null; }1960 trayEl?.remove();1961 trayEl = null;1962 }1963 1964 1965 cleanupHooks.push(closeTray);19661967 async function openTOTPTray() {1968 1969 1970 1971 const resp = await chrome.runtime.sendMessage({1972 type: "GET_ENTRY_FOR_FILL",1973 payload: { id: entry.id },1974 }).catch(() => null) as { ok: boolean; data?: { totp?: string } } | null;1975 const secret = resp?.ok ? resp.data?.totp : undefined;1976 if (!secret) return;19771978 trayEl = document.createElement("div");1979 trayEl.className = "sp-tray";19801981 const label = document.createElement("span");1982 label.className = "sp-tray-label";1983 label.textContent = "2FA";1984 trayEl.appendChild(label);19851986 const codeEl = document.createElement("div");1987 codeEl.className = "sp-totp-code";1988 trayEl.appendChild(codeEl);19891990 const ringNs = "http://www.w3.org/2000/svg";1991 const ring = document.createElementNS(ringNs, "svg");1992 ring.setAttribute("class", "sp-totp-ring");1993 ring.setAttribute("viewBox", "0 0 24 24");1994 const trackC = document.createElementNS(ringNs, "circle");1995 trackC.setAttribute("class", "ring-track");1996 trackC.setAttribute("cx", "12"); trackC.setAttribute("cy", "12"); trackC.setAttribute("r", "10");1997 trackC.setAttribute("fill", "none"); trackC.setAttribute("stroke-width", "2");1998 const fillC = document.createElementNS(ringNs, "circle");1999 fillC.setAttribute("class", "ring-fill");2000 fillC.setAttribute("cx", "12"); fillC.setAttribute("cy", "12"); fillC.setAttribute("r", "10");2001 fillC.setAttribute("fill", "none"); fillC.setAttribute("stroke-width", "2");2002 fillC.setAttribute("stroke-linecap", "round");2003 fillC.setAttribute("stroke-dasharray", "62.83");2004 ring.append(trackC, fillC);2005 trayEl.appendChild(ring);20062007 const copyBtn = document.createElement("button");2008 copyBtn.className = "sp-totp-copy";2009 copyBtn.type = "button";2010 copyBtn.textContent = "Copy";2011 trayEl.appendChild(copyBtn);20122013 function refresh() {2014 const { code, remaining } = generateTOTP(secret!);2015 2016 codeEl.textContent = code.length === 62017 ? `${code.slice(0, 3)} ${code.slice(3)}`2018 : code;2019 2020 2021 const fraction = (30 - remaining) / 30;2022 fillC.setAttribute("stroke-dashoffset", String(62.83 * fraction));2023 }2024 refresh();2025 trayInterval = setInterval(refresh, 1000);20262027 copyBtn.addEventListener("click", async (e) => {2028 e.stopPropagation();2029 const { code } = generateTOTP(secret!);2030 let alreadyWritten = false;2031 try { await navigator.clipboard.writeText(code); alreadyWritten = true; } catch {}2032 await chrome.runtime.sendMessage({2033 type: "COPY",2034 payload: { text: code, label: "TOTP", alreadyWritten },2035 }).catch(() => {});2036 copyBtn.textContent = "Copied";2037 setTimeout(() => { if (copyBtn.isConnected) copyBtn.textContent = "Copy"; }, 1200);2038 });20392040 platter.appendChild(trayEl);2041 }20422043 const editBtn = document.createElement("button");2044 editBtn.className = "sp-action-btn sp-action-edit";2045 editBtn.type = "button";2046 editBtn.title = "Edit entry";2047 editBtn.textContent = "Edit";2048 editBtn.addEventListener("click", (e) => {2049 e.stopPropagation();2050 closeTray();2051 void renderInlineEdit(entry);2052 });2053 actions.appendChild(editBtn);20542055 2056 2057 2058 if (entry.hasTotp) void openTOTPTray();20592060 platter.appendChild(actions);2061 container.appendChild(platter);2062 }20632064 206520662067206820692070 async function renderInlineEdit(summary: SelectorEntry) {2071 container.innerHTML = "";2072 const wrap = document.createElement("div");2073 wrap.className = "create-form-wrap";20742075 const head = document.createElement("div");2076 head.className = "create-head";2077 const back = document.createElement("button");2078 back.className = "back-btn";2079 back.type = "button";2080 back.title = "Cancel";2081 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>`;2082 back.addEventListener("click", () => renderSilverPlatter(summary));2083 head.appendChild(back);2084 const headLbl = document.createElement("div");2085 headLbl.className = "create-label";2086 headLbl.textContent = "Edit entry";2087 head.appendChild(headLbl);2088 wrap.appendChild(head);20892090 const body = document.createElement("div");2091 body.className = "create-body";20922093 2094 const loading = document.createElement("div");2095 loading.className = "empty-hint";2096 loading.textContent = "loading…";2097 body.appendChild(loading);2098 wrap.appendChild(body);2099 container.appendChild(wrap);21002101 const res = (await chrome.runtime.sendMessage({2102 type: "GET_ENTRY_FOR_FILL",2103 payload: { id: summary.id },2104 }).catch(() => null)) as { ok: boolean; data?: { title?: string; username?: string; email?: string; password?: string; url?: string; totp?: string; notes?: string } } | null;21052106 if (!res || !res.ok || !res.data) {2107 loading.textContent = "couldn't load this entry. try again from the popup.";2108 return;2109 }2110 body.innerHTML = "";21112112 function field(label: string, value: string, type: "text" | "password" = "text"): HTMLInputElement {2113 const group = document.createElement("div");2114 group.className = "f-group";2115 const lbl = document.createElement("div");2116 lbl.className = "f-label";2117 lbl.textContent = label;2118 const input = document.createElement("input");2119 input.className = "f-input";2120 input.type = type;2121 input.value = value;2122 input.autocomplete = "off";2123 group.append(lbl, input);2124 body.appendChild(group);2125 return input;2126 }21272128 const titleInput = field("title", res.data.title ?? "");2129 const urlInput = field("url", res.data.url ?? "");2130 urlInput.classList.add("url-f");2131 const usernameLabel = (res.data.username ?? "").includes("@") ? "email" : "username";2132 const usernameInput = field(usernameLabel, res.data.username ?? "");2133 const emailInput = field("email", res.data.email ?? "");21342135 2136 const pwGroup = document.createElement("div");2137 pwGroup.className = "f-group";2138 const pwLbl = document.createElement("div");2139 pwLbl.className = "f-label";2140 pwLbl.textContent = "password";2141 const pwRow = document.createElement("div");2142 pwRow.className = "f-row";2143 const pwInput = document.createElement("input");2144 pwInput.className = "f-input";2145 pwInput.type = "password";2146 pwInput.value = res.data.password ?? "";2147 pwInput.autocomplete = "new-password";2148 const revealBtn = document.createElement("button");2149 revealBtn.className = "gen-btn";2150 revealBtn.type = "button";2151 revealBtn.textContent = "show";2152 revealBtn.addEventListener("click", () => {2153 const reveal = pwInput.type === "password";2154 pwInput.type = reveal ? "text" : "password";2155 revealBtn.textContent = reveal ? "hide" : "show";2156 });2157 pwRow.append(pwInput, revealBtn);2158 pwGroup.append(pwLbl, pwRow);2159 body.appendChild(pwGroup);21602161 const totpInput = field("2fa secret", res.data.totp ?? "");21622163 2164 const notesGroup = document.createElement("div");2165 notesGroup.className = "f-group";2166 const notesLbl = document.createElement("div");2167 notesLbl.className = "f-label";2168 notesLbl.textContent = "notes";2169 const notesInput = document.createElement("textarea");2170 notesInput.className = "f-input";2171 notesInput.rows = 3;2172 notesInput.value = res.data.notes ?? "";2173 notesInput.style.fontFamily = "Inter, sans-serif";2174 notesInput.style.resize = "vertical";2175 notesGroup.append(notesLbl, notesInput);2176 body.appendChild(notesGroup);21772178 2179 const actionsRow = document.createElement("div");2180 actionsRow.className = "f-row";2181 const saveBtn = document.createElement("button");2182 saveBtn.className = "save-btn";2183 saveBtn.type = "button";2184 saveBtn.textContent = "Save changes";2185 saveBtn.style.flex = "1";2186 const cancelBtn = document.createElement("button");2187 cancelBtn.className = "gen-btn";2188 cancelBtn.type = "button";2189 cancelBtn.textContent = "cancel";2190 cancelBtn.addEventListener("click", () => renderSilverPlatter(summary));2191 actionsRow.append(saveBtn, cancelBtn);2192 body.appendChild(actionsRow);21932194 saveBtn.addEventListener("click", async () => {2195 saveBtn.disabled = true;2196 const originalLabel = saveBtn.textContent;2197 saveBtn.textContent = "Saving…";2198 const patch: Record<string, unknown> = {2199 title: titleInput.value.trim(),2200 url: urlInput.value.trim(),2201 username: usernameInput.value.trim(),2202 email: emailInput.value.trim() || undefined,2203 password: pwInput.value,2204 totp: totpInput.value.trim(),2205 notes: notesInput.value,2206 };2207 const updateRes = (await chrome.runtime.sendMessage({2208 type: "UPDATE_ENTRY",2209 payload: { id: summary.id, patch },2210 }).catch(() => null)) as { ok: boolean; error?: string } | null;2211 if (!updateRes?.ok) {2212 saveBtn.disabled = false;2213 saveBtn.textContent = originalLabel;2214 const err = document.createElement("div");2215 err.className = "empty-hint";2216 err.style.color = "color-mix(in srgb, #e55 70%, transparent)";2217 err.textContent = updateRes?.error ?? "Couldn't save. Try the popup.";2218 body.appendChild(err);2219 setTimeout(() => err.remove(), 3000);2220 return;2221 }2222 2223 const refreshed: SelectorEntry = {2224 id: summary.id,2225 title: patch.title as string,2226 username: patch.username as string,2227 email: patch.email as string | undefined,2228 url: patch.url as string,2229 hasTotp: Boolean(patch.totp),2230 hasPasskey: summary.hasPasskey,2231 };2232 renderSilverPlatter(refreshed);2233 });22342235 queueMicrotask(() => titleInput.focus());2236 }22372238 function renderLocked() {2239 container.innerHTML = "";22402241 2242 const domHdr = document.createElement("div");2243 domHdr.className = "domain-header";2244 const eyebrow = document.createElement("div");2245 eyebrow.className = "domain-eyebrow";2246 eyebrow.textContent = "vault locked";2247 const domName = document.createElement("div");2248 domName.className = "domain-name";2249 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");2250 domHdr.append(eyebrow, domName);2251 container.appendChild(domHdr);22522253 const wrap = document.createElement("div");2254 wrap.className = "locked-wrap";22552256 2257 const head = document.createElement("div"); head.className = "locked-head";2258 const icon = document.createElement("div"); icon.className = "locked-icon";2259 icon.innerHTML = keySvgStr();2260 const title = document.createElement("div"); title.className = "locked-title";2261 title.textContent = "unlock to autofill";2262 head.append(icon, title);22632264 2265 const pwInp = document.createElement("input");2266 pwInp.className = "locked-input";2267 pwInp.type = "password";2268 pwInp.placeholder = "master password";2269 pwInp.setAttribute("autocomplete", "current-password");22702271 2272 const errEl = document.createElement("div");2273 errEl.className = "locked-error";2274 errEl.style.display = "none";22752276 2277 const unlockBtn = document.createElement("button");2278 unlockBtn.className = "locked-btn";2279 unlockBtn.type = "button";2280 unlockBtn.textContent = "unlock";22812282 async function tryUnlock() {2283 const pw = pwInp.value.trim();2284 if (!pw) { pwInp.focus(); return; }2285 unlockBtn.disabled = true;2286 unlockBtn.textContent = "unlocking…";2287 errEl.style.display = "none";2288 try {2289 const res = await chrome.runtime.sendMessage({2290 type: "UNLOCK",2291 payload: { password: pw },2292 });2293 if ((res as { ok?: boolean }).ok) {2294 dismiss();2295 options.onUnlocked?.();2296 } else {2297 errEl.textContent = "incorrect password";2298 errEl.style.display = "block";2299 pwInp.value = "";2300 pwInp.focus();2301 unlockBtn.disabled = false;2302 unlockBtn.textContent = "unlock";2303 }2304 } catch {2305 errEl.textContent = "could not reach Peach";2306 errEl.style.display = "block";2307 unlockBtn.disabled = false;2308 unlockBtn.textContent = "unlock";2309 }2310 }23112312 pwInp.addEventListener("keydown", (e) => {2313 e.stopPropagation();2314 if (e.key === "Enter") void tryUnlock();2315 });2316 pwInp.addEventListener("keyup", (e) => e.stopPropagation());2317 pwInp.addEventListener("keypress", (e) => e.stopPropagation());2318 unlockBtn.addEventListener("click", () => void tryUnlock());23192320 wrap.append(head, pwInp, errEl, unlockBtn);2321 container.appendChild(wrap);23222323 2324 2325 2326 2327 2328 2329 const captureKeydown = (e: KeyboardEvent) => {2330 if (!host.isConnected) {2331 document.removeEventListener("keydown", captureKeydown, true);2332 return;2333 }2334 2335 if (e.ctrlKey || e.metaKey || e.altKey || e.key === "Tab") return;2336 2337 e.stopImmediatePropagation();2338 if (e.key === "Escape") { dismiss(true); return; }2339 if (e.key === "Enter") { void tryUnlock(); return; }2340 2341 2342 if (document.activeElement !== host) {2343 pwInp.focus({ preventScroll: true });2344 }2345 };2346 captureKeydownRef = captureKeydown;2347 document.addEventListener("keydown", captureKeydown, true);23482349 2350 2351 pwInp.focus({ preventScroll: true });2352 requestAnimationFrame(() => { if (host.isConnected) pwInp.focus({ preventScroll: true }); });2353 }23542355 function handleKeyDown(e: KeyboardEvent) {2356 if (options.locked) {2357 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2358 return;2359 }2360 if (currentMode === "create" || currentMode === "success" || currentMode === "silver-platter") {2361 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2362 return;2363 }2364 const allEntryEls = container.querySelectorAll(".entry:not(.empty-state)");2365 const count = allEntryEls.length;2366 if (document.activeElement === searchInput) {2367 if (e.key === "Escape" || e.key === "Tab") { e.preventDefault(); dismiss(true); return; }2368 if (count === 0) return;2369 if (!["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) return;2370 }2371 if (count === 0) return;2372 switch (e.key) {2373 case "ArrowDown": e.preventDefault(); setFocused(focusedIndex < count - 1 ? focusedIndex + 1 : 0); break;2374 case "ArrowUp": e.preventDefault(); setFocused(focusedIndex > 0 ? focusedIndex - 1 : count - 1); break;2375 case "Enter": {2376 if (focusedIndex >= 0) {2377 const el = allEntryEls[focusedIndex] as HTMLElement;2378 const id = el.dataset.id;2379 if (id) { onSelect(id); dismiss(); }2380 else if (el.classList.contains("is-new") || !id) {2381 2382 showCreateForm();2383 }2384 }2385 break;2386 }2387 case "Escape": case "Tab": e.preventDefault(); dismiss(true); break;2388 }2389 }23902391 document.addEventListener("keydown", handleKeyDown);23922393 document.body.appendChild(host);23942395 function updatePosition() {2396 const r = anchorEl.getBoundingClientRect();2397 host.style.top = `${r.bottom + window.scrollY + 5}px`;2398 host.style.left = `${r.left + window.scrollX}px`;2399 }2400 2401 2402 2403 2404 2405 2406 2407 let captureKeydownRef: ((e: KeyboardEvent) => void) | null = null;2408 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);24092410 if (options.locked) {2411 renderLocked();2412 } else if (options.isSignup && options.savedIdentities) {2413 2414 2415 renderIdentityHelper();2416 } else if (entries.length === 1 && !options.isSignup) {2417 2418 2419 renderSilverPlatter(entries[0]!);2420 } else {2421 renderList();2422 }24232424 let exitScheduled = false;2425 function dismiss(userAction = false) {2426 2427 2428 2429 if (exitScheduled) return;2430 exitScheduled = true;2431 2432 2433 2434 stopObserving();2435 document.removeEventListener("click", outsideClick, { capture: true });2436 document.removeEventListener("keydown", handleKeyDown);2437 if (captureKeydownRef) {2438 document.removeEventListener("keydown", captureKeydownRef, true);2439 captureKeydownRef = null;2440 }2441 for (const cleanup of cleanupHooks) {2442 try { cleanup(); } catch { }2443 }2444 if (userAction) options.onDismiss?.();2445 container.classList.add("is-exiting");2446 setTimeout(() => host.remove(), 130);2447 }24482449 function outsideClick(ev: MouseEvent) {2450 const path = ev.composedPath();2451 2452 2453 2454 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);2455 }2456 2457 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);24582459 return dismiss;2460}24612462export interface CardSelectorEntry {2463 id: string;2464 title: string;2465 cardholderName?: string;2466 last4?: string;2467 expMonth?: string;2468 expYear?: string;2469 network?: import("../shared/types").CardNetwork;2470}24712472interface CardSelectorOptions {2473 domain?: string;2474 2475 onFill: (entry: import("../shared/types").VaultEntry) => void;2476 2477 onDismiss?: () => void;2478}24792480248124822483248424852486export function showPasskeyProGate(): void {2487 const domain = location.hostname.replace(/^www\./, "");24882489 const host = document.createElement("div");2490 host.setAttribute("data-peach-passkey-gate", "1");2491 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483646;pointer-events:none;";2492 const shadow = host.attachShadow({ mode: "closed" });24932494 const style = document.createElement("style");2495 style.textContent = `2496 :host { all: initial; }2497 .gate-wrap {2498 position: fixed;2499 top: 50%;2500 left: 50%;2501 transform: translate(-50%, -50%);2502 width: 280px;2503 pointer-events: auto;2504 animation: g-in 220ms cubic-bezier(0.16,1,0.3,1) both;2505 }2506 @keyframes g-in {2507 from { opacity:0; transform: translate(-50%,-52%); }2508 to { opacity:1; transform: translate(-50%,-50%); }2509 }2510 .gate-wrap.is-exiting {2511 animation: g-out 130ms ease-in forwards;2512 }2513 @keyframes g-out {2514 to { opacity:0; transform: translate(-50%,-52%); }2515 }2516 .gate {2517 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2518 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2519 border-radius: 12px;2520 box-shadow: 0 12px 48px rgba(0,0,0,0.75);2521 padding: 16px;2522 font-family: Inter, sans-serif;2523 }2524 .gate-header {2525 display: flex;2526 align-items: center;2527 gap: 7px;2528 margin-bottom: 12px;2529 padding-bottom: 10px;2530 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2531 }2532 .gate-domain {2533 font-size: 12px;2534 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2535 font-family: "IBM Plex Mono", monospace;2536 overflow: hidden;2537 text-overflow: ellipsis;2538 white-space: nowrap;2539 }2540 .gate-title {2541 font-size: 14px;2542 font-weight: 500;2543 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2544 margin-bottom: 6px;2545 }2546 .gate-subtitle {2547 font-size: 12px;2548 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.45)"};2549 line-height: 1.5;2550 margin-bottom: 14px;2551 }2552 .gate-btn {2553 display: block;2554 width: 100%;2555 padding: 9px 0;2556 border-radius: 8px;2557 border: none;2558 cursor: pointer;2559 font-size: 13px;2560 font-family: Inter, sans-serif;2561 font-weight: 500;2562 transition: opacity 100ms;2563 margin-bottom: 7px;2564 text-align: center;2565 }2566 .gate-btn:last-child { margin-bottom: 0; }2567 .gate-btn--accent {2568 background: ${accentHex};2569 color: #fff;2570 }2571 .gate-btn--accent:hover { opacity: 0.88; }2572 .gate-btn--ghost {2573 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2574 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.45)"};2575 }2576 .gate-btn--ghost:hover { opacity: 0.75; }2577 .backdrop {2578 position: fixed;2579 inset: 0;2580 pointer-events: auto;2581 }2582 `;2583 shadow.appendChild(style);25842585 const backdrop = document.createElement("div");2586 backdrop.className = "backdrop";2587 shadow.appendChild(backdrop);25882589 const wrap = document.createElement("div");2590 wrap.className = "gate-wrap";2591 shadow.appendChild(wrap);25922593 const gate = document.createElement("div");2594 gate.className = "gate";2595 wrap.appendChild(gate);25962597 2598 const header = document.createElement("div");2599 header.className = "gate-header";2600 const icon = document.createElement("span");2601 icon.innerHTML = peachIconSvg();2602 const domainEl = document.createElement("span");2603 domainEl.className = "gate-domain";2604 domainEl.textContent = domain;2605 header.append(icon, domainEl);2606 gate.appendChild(header);26072608 const title = document.createElement("div");2609 title.className = "gate-title";2610 title.textContent = "Passkeys are part of Peach Pro.";2611 gate.appendChild(title);26122613 const subtitle = document.createElement("div");2614 subtitle.className = "gate-subtitle";2615 subtitle.textContent = "Store and use passkeys across all your devices, securely.";2616 gate.appendChild(subtitle);26172618 const upgradeBtn = document.createElement("button");2619 upgradeBtn.className = "gate-btn gate-btn--accent";2620 upgradeBtn.type = "button";2621 upgradeBtn.textContent = "Upgrade to Pro";2622 gate.appendChild(upgradeBtn);26232624 const laterBtn = document.createElement("button");2625 laterBtn.className = "gate-btn gate-btn--ghost";2626 laterBtn.type = "button";2627 laterBtn.textContent = "Not right now";2628 gate.appendChild(laterBtn);26292630 function dismiss() {2631 wrap.classList.add("is-exiting");2632 setTimeout(() => host.remove(), 130);2633 }26342635 upgradeBtn.addEventListener("click", () => {2636 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: { feature: "passkeys" } }).catch(() => {});2637 dismiss();2638 });2639 laterBtn.addEventListener("click", dismiss);2640 backdrop.addEventListener("click", dismiss);26412642 document.addEventListener("keydown", function onEsc(e: KeyboardEvent) {2643 if (e.key === "Escape") { dismiss(); document.removeEventListener("keydown", onEsc); }2644 });26452646 document.body.appendChild(host);2647}264826492650265126522653265426552656export function showPasskeyRegistrationOffer(args: {2657 rpId: string;2658 rpName?: string;2659 userName?: string;2660 userDisplayName?: string;2661}): void {2662 const domain = location.hostname.replace(/^www\./, "");2663 const displayName = args.rpName || domain;26642665 const host = document.createElement("div");2666 host.setAttribute("data-peach-passkey-offer", "1");2667 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483645;pointer-events:none;";2668 const shadow = host.attachShadow({ mode: "closed" });26692670 const style = document.createElement("style");2671 style.textContent = `2672 :host { all: initial; }2673 .offer-wrap {2674 position: fixed;2675 top: 16px;2676 right: 16px;2677 width: 320px;2678 pointer-events: auto;2679 animation: o-in 220ms cubic-bezier(0.16,1,0.3,1) both;2680 }2681 @keyframes o-in {2682 from { opacity: 0; transform: translateY(-6px); }2683 to { opacity: 1; transform: translateY(0); }2684 }2685 .offer-wrap.is-exiting { animation: o-out 130ms ease-in forwards; }2686 @keyframes o-out { to { opacity: 0; transform: translateY(-6px); } }2687 .offer {2688 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2689 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2690 border-radius: 12px;2691 box-shadow: 0 12px 48px rgba(0,0,0,0.55);2692 padding: 14px 14px 12px;2693 font-family: Inter, sans-serif;2694 position: relative;2695 }2696 .offer-close {2697 position: absolute;2698 top: 8px;2699 right: 8px;2700 width: 18px;2701 height: 18px;2702 border: none;2703 background: transparent;2704 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};2705 cursor: pointer;2706 font-size: 14px;2707 line-height: 1;2708 padding: 0;2709 }2710 .offer-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }2711 .offer-header {2712 display: flex;2713 align-items: center;2714 gap: 7px;2715 margin-bottom: 8px;2716 padding-bottom: 8px;2717 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2718 }2719 .offer-domain {2720 font-size: 12px;2721 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2722 font-family: "IBM Plex Mono", monospace;2723 overflow: hidden;2724 text-overflow: ellipsis;2725 white-space: nowrap;2726 }2727 .offer-title {2728 font-size: 13px;2729 font-weight: 500;2730 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2731 margin-bottom: 4px;2732 }2733 .offer-subtitle {2734 font-size: 11px;2735 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};2736 line-height: 1.45;2737 margin-bottom: 12px;2738 }2739 .offer-btn {2740 display: block;2741 width: 100%;2742 padding: 8px 0;2743 border-radius: 7px;2744 border: none;2745 cursor: pointer;2746 font-size: 12px;2747 font-family: Inter, sans-serif;2748 font-weight: 500;2749 transition: opacity 100ms;2750 margin-bottom: 6px;2751 text-align: center;2752 }2753 .offer-btn:last-child { margin-bottom: 0; }2754 .offer-btn--accent { background: ${accentHex}; color: #fff; }2755 .offer-btn--accent:hover { opacity: 0.88; }2756 .offer-btn--ghost {2757 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2758 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};2759 }2760 .offer-btn--ghost:hover { opacity: 0.75; }2761 `;2762 shadow.appendChild(style);27632764 const wrap = document.createElement("div");2765 wrap.className = "offer-wrap";2766 shadow.appendChild(wrap);27672768 const offer = document.createElement("div");2769 offer.className = "offer";2770 wrap.appendChild(offer);27712772 const closeBtn = document.createElement("button");2773 closeBtn.className = "offer-close";2774 closeBtn.type = "button";2775 closeBtn.setAttribute("aria-label", "Dismiss");2776 closeBtn.textContent = "✕";2777 offer.appendChild(closeBtn);27782779 const header = document.createElement("div");2780 header.className = "offer-header";2781 const icon = document.createElement("span");2782 icon.innerHTML = peachIconSvg();2783 const domainEl = document.createElement("span");2784 domainEl.className = "offer-domain";2785 domainEl.textContent = domain;2786 header.append(icon, domainEl);2787 offer.appendChild(header);27882789 const title = document.createElement("div");2790 title.className = "offer-title";2791 title.textContent = "This site supports passkeys.";2792 offer.appendChild(title);27932794 const subtitle = document.createElement("div");2795 subtitle.className = "offer-subtitle";2796 subtitle.textContent = "Save one to Peach for faster, passwordless sign-in.";2797 offer.appendChild(subtitle);27982799 const saveBtn = document.createElement("button");2800 saveBtn.className = "offer-btn offer-btn--accent";2801 saveBtn.type = "button";2802 saveBtn.textContent = "Save passkey to Peach";2803 offer.appendChild(saveBtn);28042805 const laterBtn = document.createElement("button");2806 laterBtn.className = "offer-btn offer-btn--ghost";2807 laterBtn.type = "button";2808 laterBtn.textContent = "Not now";2809 offer.appendChild(laterBtn);28102811 function dismiss(decline: boolean) {2812 if (decline) {2813 chrome.runtime.sendMessage({2814 type: "PASSKEY_OFFER_DECLINE",2815 payload: { domain },2816 }).catch(() => {});2817 }2818 wrap.classList.add("is-exiting");2819 setTimeout(() => host.remove(), 130);2820 }28212822 saveBtn.addEventListener("click", () => {2823 chrome.runtime.sendMessage({2824 type: "INITIATE_FIREFOX_PASSKEY_CREATE",2825 payload: {2826 rpId: args.rpId,2827 rpName: args.rpName ?? displayName,2828 userName: args.userName ?? "user",2829 userDisplayName: args.userDisplayName,2830 },2831 }).catch(() => {});2832 dismiss(false);2833 });2834 laterBtn.addEventListener("click", () => dismiss(true));2835 closeBtn.addEventListener("click", () => dismiss(true));28362837 document.body.appendChild(host);2838}2839284028412842284328442845284628472848export function showPasskeyAvailable(args: {2849 rpId: string;2850 userName: string;2851 fromBrowser?: "chrome" | "firefox";2852 currentBrowser?: "chrome" | "firefox" | "unknown";2853}): void {2854 const domain = location.hostname.replace(/^www\./, "");2855 const crossBrowser =2856 args.fromBrowser &&2857 args.currentBrowser &&2858 args.currentBrowser !== "unknown" &&2859 args.fromBrowser !== args.currentBrowser;28602861 const host = document.createElement("div");2862 host.setAttribute("data-peach-passkey-available", "1");2863 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483644;pointer-events:none;";2864 const shadow = host.attachShadow({ mode: "closed" });28652866 const style = document.createElement("style");2867 style.textContent = `2868 :host { all: initial; }2869 .avail-wrap {2870 position: fixed;2871 top: 16px;2872 right: 16px;2873 width: 320px;2874 pointer-events: auto;2875 animation: a-in 220ms cubic-bezier(0.16,1,0.3,1) both;2876 }2877 @keyframes a-in {2878 from { opacity: 0; transform: translateY(-6px); }2879 to { opacity: 1; transform: translateY(0); }2880 }2881 .avail-wrap.is-exiting { animation: a-out 130ms ease-in forwards; }2882 @keyframes a-out { to { opacity: 0; transform: translateY(-6px); } }2883 .avail {2884 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2885 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2886 border-radius: 12px;2887 box-shadow: 0 12px 48px rgba(0,0,0,0.55);2888 padding: 14px 14px 12px;2889 font-family: Inter, sans-serif;2890 position: relative;2891 }2892 .avail-close {2893 position: absolute;2894 top: 8px;2895 right: 8px;2896 width: 18px;2897 height: 18px;2898 border: none;2899 background: transparent;2900 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};2901 cursor: pointer;2902 font-size: 14px;2903 line-height: 1;2904 padding: 0;2905 }2906 .avail-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }2907 .avail-header {2908 display: flex;2909 align-items: center;2910 gap: 7px;2911 margin-bottom: 8px;2912 padding-bottom: 8px;2913 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2914 }2915 .avail-domain {2916 font-size: 12px;2917 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2918 font-family: "IBM Plex Mono", monospace;2919 }2920 .avail-label {2921 font-size: 9px;2922 letter-spacing: 0.16em;2923 text-transform: uppercase;2924 color: ${accentHex};2925 margin-bottom: 4px;2926 }2927 .avail-user {2928 font-size: 13px;2929 font-weight: 500;2930 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2931 margin-bottom: 12px;2932 overflow: hidden;2933 text-overflow: ellipsis;2934 white-space: nowrap;2935 }2936 .avail-cross {2937 font-size: 11px;2938 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};2939 line-height: 1.45;2940 margin-bottom: 12px;2941 padding: 8px;2942 background: ${popupTheme === "light" ? "rgba(0,0,0,0.04)" : "rgba(240,232,216,0.04)"};2943 border-radius: 6px;2944 }2945 .avail-btn {2946 display: block;2947 width: 100%;2948 padding: 8px 0;2949 border-radius: 7px;2950 border: none;2951 cursor: pointer;2952 font-size: 12px;2953 font-family: Inter, sans-serif;2954 font-weight: 500;2955 transition: opacity 100ms;2956 margin-bottom: 6px;2957 text-align: center;2958 }2959 .avail-btn:last-child { margin-bottom: 0; }2960 .avail-btn--accent { background: ${accentHex}; color: #fff; }2961 .avail-btn--accent:hover { opacity: 0.88; }2962 .avail-btn--ghost {2963 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2964 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};2965 }2966 .avail-btn--ghost:hover { opacity: 0.75; }2967 `;2968 shadow.appendChild(style);29692970 const wrap = document.createElement("div");2971 wrap.className = "avail-wrap";2972 shadow.appendChild(wrap);29732974 const avail = document.createElement("div");2975 avail.className = "avail";2976 wrap.appendChild(avail);29772978 const closeBtn = document.createElement("button");2979 closeBtn.className = "avail-close";2980 closeBtn.type = "button";2981 closeBtn.setAttribute("aria-label", "Dismiss");2982 closeBtn.textContent = "✕";2983 avail.appendChild(closeBtn);29842985 const header = document.createElement("div");2986 header.className = "avail-header";2987 const icon = document.createElement("span");2988 icon.innerHTML = peachIconSvg();2989 const domainEl = document.createElement("span");2990 domainEl.className = "avail-domain";2991 domainEl.textContent = domain;2992 header.append(icon, domainEl);2993 avail.appendChild(header);29942995 const label = document.createElement("div");2996 label.className = "avail-label";2997 label.textContent = "PASSKEY";2998 avail.appendChild(label);29993000 const user = document.createElement("div");3001 user.className = "avail-user";3002 user.textContent = args.userName;3003 avail.appendChild(user);30043005 if (crossBrowser) {3006 const cross = document.createElement("div");3007 cross.className = "avail-cross";3008 cross.textContent =3009 args.fromBrowser === "chrome"3010 ? "This passkey was created on Chrome. To use it on Firefox, re-register it on this device."3011 : "This passkey was created on Firefox. To use it on Chrome, re-register it on this device.";3012 avail.appendChild(cross);3013 }30143015 const signInBtn = document.createElement("button");3016 signInBtn.className = "avail-btn avail-btn--accent";3017 signInBtn.type = "button";3018 signInBtn.textContent = "Sign in with passkey";3019 avail.appendChild(signInBtn);30203021 const passwordBtn = document.createElement("button");3022 passwordBtn.className = "avail-btn avail-btn--ghost";3023 passwordBtn.type = "button";3024 passwordBtn.textContent = "Use password instead";3025 avail.appendChild(passwordBtn);30263027 function dismiss() {3028 wrap.classList.add("is-exiting");3029 setTimeout(() => host.remove(), 130);3030 }30313032 signInBtn.addEventListener("click", () => {3033 3034 3035 3036 3037 3038 dismiss();3039 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: {} }).catch(() => {});3040 });3041 passwordBtn.addEventListener("click", dismiss);3042 closeBtn.addEventListener("click", dismiss);30433044 document.body.appendChild(host);3045}304630473048304930503051305230533054export function showCardSelector(3055 anchorEl: HTMLInputElement,3056 cards: CardSelectorEntry[],3057 options: CardSelectorOptions3058): () => void {3059 if (cards.length === 0) return () => {};3060 const card = cards[0]!;30613062 const host = document.createElement("div");3063 host.style.cssText = "position: absolute; z-index: 2147483647;";3064 host.style.setProperty("--peach-accent", accentHex);3065 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));3066 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));3067 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));3068 const shadow = host.attachShadow({ mode: "closed" });30693070 const style = shadow.appendChild(document.createElement("style"));3071 style.textContent = SELECTOR_STYLES;30723073 const rect = anchorEl.getBoundingClientRect();3074 host.style.top = `${rect.bottom + window.scrollY + 5}px`;3075 host.style.left = `${rect.left + window.scrollX}px`;3076 host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;30773078 const container = shadow.appendChild(document.createElement("div"));3079 container.className = "peach-inline-popup";3080 container.setAttribute("data-theme", popupTheme);30813082 3083 const domHdr = document.createElement("div");3084 domHdr.className = "domain-header";3085 const eyebrow = document.createElement("div");3086 eyebrow.className = "domain-eyebrow";3087 eyebrow.textContent = "Pay with Peach";3088 const domName = document.createElement("div");3089 domName.className = "domain-name";3090 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");3091 domHdr.append(eyebrow, domName);3092 container.appendChild(domHdr);30933094 const platter = document.createElement("div");3095 platter.className = "card-platter";30963097 if (card.network && card.network !== "unknown") {3098 const net = document.createElement("div");3099 net.className = "cp-network";3100 net.textContent = card.network;3101 platter.appendChild(net);3102 }31033104 const nick = document.createElement("div");3105 nick.className = "cp-nickname";3106 nick.textContent = card.title;3107 platter.appendChild(nick);31083109 if (card.last4) {3110 const l4 = document.createElement("div");3111 l4.className = "cp-last4";3112 l4.textContent = `•••• ${card.last4}`;3113 platter.appendChild(l4);3114 }31153116 const meta = document.createElement("div");3117 meta.className = "cp-meta";3118 if (card.cardholderName) {3119 const name = document.createElement("span");3120 name.textContent = card.cardholderName;3121 meta.appendChild(name);3122 }3123 if (card.expMonth && card.expYear) {3124 if (card.cardholderName) {3125 const sep = document.createElement("span");3126 sep.className = "cp-meta-sep";3127 sep.textContent = "·";3128 meta.appendChild(sep);3129 }3130 const exp = document.createElement("span");3131 const yy = card.expYear.length === 4 ? card.expYear.slice(-2) : card.expYear;3132 exp.textContent = `${card.expMonth.padStart(2, "0")}/${yy}`;3133 meta.appendChild(exp);3134 }3135 if (meta.childElementCount > 0) platter.appendChild(meta);31363137 const fillWrap = document.createElement("div");3138 fillWrap.className = "cp-fill-wrap";3139 const fillBtn = document.createElement("button");3140 fillBtn.className = "sp-fill-btn";3141 fillBtn.type = "button";3142 fillBtn.textContent = "Fill card details";3143 fillBtn.addEventListener("click", async () => {3144 if (fillBtn.disabled) return;3145 fillBtn.disabled = true;3146 fillBtn.classList.add("filled");3147 fillBtn.innerHTML = checkSvgStr();3148 const resp = await chrome.runtime.sendMessage({3149 type: "GET_ENTRY_FOR_FILL",3150 payload: { id: card.id },3151 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3152 if (resp?.ok && resp.data) options.onFill(resp.data);3153 setTimeout(() => dismiss(), 400);3154 });3155 fillWrap.appendChild(fillBtn);3156 platter.appendChild(fillWrap);31573158 3159 const actions = document.createElement("div");3160 actions.className = "sp-actions";31613162 function flashBtn(b: HTMLButtonElement) {3163 b.classList.add("flashed");3164 setTimeout(() => b.classList.remove("flashed"), 700);3165 }31663167 async function fetchFullCard(): Promise<import("../shared/types").VaultEntry | null> {3168 const resp = await chrome.runtime.sendMessage({3169 type: "GET_ENTRY_FOR_FILL",3170 payload: { id: card.id },3171 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3172 return resp?.ok && resp.data ? resp.data : null;3173 }31743175 const copyNum = document.createElement("button");3176 copyNum.className = "sp-action-btn";3177 copyNum.type = "button";3178 copyNum.title = "Copy card number";3179 copyNum.textContent = "Copy number";3180 copyNum.addEventListener("click", async (e) => {3181 e.stopPropagation();3182 const full = await fetchFullCard();3183 if (!full?.cardNumber) return;3184 let alreadyWritten = false;3185 try { await navigator.clipboard.writeText(full.cardNumber); alreadyWritten = true; } catch {}3186 await chrome.runtime.sendMessage({3187 type: "COPY",3188 payload: { text: full.cardNumber, label: "Card number", alreadyWritten },3189 }).catch(() => {});3190 flashBtn(copyNum);3191 });3192 actions.appendChild(copyNum);31933194 const copyCvc = document.createElement("button");3195 copyCvc.className = "sp-action-btn";3196 copyCvc.type = "button";3197 copyCvc.title = "Copy CVC";3198 copyCvc.textContent = "Copy CVC";3199 copyCvc.addEventListener("click", async (e) => {3200 e.stopPropagation();3201 const full = await fetchFullCard();3202 if (!full?.cvc) return;3203 let alreadyWritten = false;3204 try { await navigator.clipboard.writeText(full.cvc); alreadyWritten = true; } catch {}3205 await chrome.runtime.sendMessage({3206 type: "COPY",3207 payload: { text: full.cvc, label: "CVC", alreadyWritten },3208 }).catch(() => {});3209 flashBtn(copyCvc);3210 });3211 actions.appendChild(copyCvc);32123213 const closeBtn = document.createElement("button");3214 closeBtn.className = "sp-action-btn";3215 closeBtn.type = "button";3216 closeBtn.title = "Dismiss";3217 closeBtn.textContent = "✕";3218 closeBtn.addEventListener("click", (e) => {3219 e.stopPropagation();3220 dismiss(true);3221 });3222 actions.appendChild(closeBtn);32233224 platter.appendChild(actions);3225 container.appendChild(platter);32263227 document.body.appendChild(host);3228 function updatePosition() {3229 const r = anchorEl.getBoundingClientRect();3230 host.style.top = `${r.bottom + window.scrollY + 5}px`;3231 host.style.left = `${r.left + window.scrollX}px`;3232 }3233 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);32343235 function onKeyDown(e: KeyboardEvent) {3236 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }3237 }3238 document.addEventListener("keydown", onKeyDown);32393240 let exitScheduled = false;3241 function dismiss(userAction = false) {3242 if (exitScheduled) return;3243 exitScheduled = true;3244 stopObserving();3245 document.removeEventListener("click", outsideClick, { capture: true });3246 document.removeEventListener("keydown", onKeyDown);3247 if (userAction) options.onDismiss?.();3248 container.classList.add("is-exiting");3249 setTimeout(() => host.remove(), 130);3250 }32513252 function outsideClick(ev: MouseEvent) {3253 const path = ev.composedPath();3254 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);3255 }3256 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);32573258 return dismiss;3259}