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 214 let length = policy.maxLength ?? 64;215 if (policy.minLength) length = Math.max(length, policy.minLength);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(parseInt(slider.min, 10), Math.min(parseInt(slider.max, 10), 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 length = password.length;350 slider.value = String(Math.max(8, Math.min(128, length)));351 lenNum.textContent = String(length);352 opts.onChange?.(password);353 });354355 slider.addEventListener("input", () => {356 length = parseInt(slider.value, 10);357 lenNum.textContent = String(length);358 regenerate();359 });360 regenBtn.addEventListener("click", regenerate);361362 let copyResetTimer: ReturnType<typeof setTimeout> | null = null;363 async function copy(): Promise<void> {364 try {365 await navigator.clipboard.writeText(password);366 copyBtn.classList.add("is-copied");367 if (copyResetTimer) clearTimeout(copyResetTimer);368 copyResetTimer = setTimeout(() => copyBtn.classList.remove("is-copied"), 1400);369 } catch {370 371 }372 }373 copyBtn.addEventListener("click", () => { void copy(); });374375 if (opts.initialPassword) {376 password = opts.initialPassword;377 output.value = password;378 opts.onChange?.(password);379 } else {380 regenerate();381 }382383 return {384 root,385 getPassword: () => password,386 copy,387 };388}389390export function observeAnchorPosition(391 anchorEl: HTMLElement,392 onUpdate: () => void393): () => void {394 let rafId = 0;395 let burstUntil = 0;396397 const runUpdate = () => {398 rafId = 0;399 onUpdate();400 if (performance.now() < burstUntil) rafId = requestAnimationFrame(runUpdate);401 };402 const scheduleUpdate = () => { if (!rafId) rafId = requestAnimationFrame(runUpdate); };403 const scheduleBurst = (ms = 220) => {404 burstUntil = Math.max(burstUntil, performance.now() + ms);405 scheduleUpdate();406 };407408 const resizeObserver = new ResizeObserver(() => scheduleBurst());409 resizeObserver.observe(anchorEl);410 if (anchorEl.parentElement) resizeObserver.observe(anchorEl.parentElement);411412 const mutationObserver = new MutationObserver(() => scheduleBurst());413 mutationObserver.observe(anchorEl, { attributes: true, attributeFilter: ["class", "style", "type", "hidden"] });414 if (anchorEl.parentElement) {415 mutationObserver.observe(anchorEl.parentElement, { attributes: true, attributeFilter: ["class", "style", "hidden"] });416 }417418 const onScroll = () => scheduleUpdate();419 window.addEventListener("scroll", onScroll, true);420 window.addEventListener("resize", onScroll);421 window.visualViewport?.addEventListener("resize", onScroll);422 window.visualViewport?.addEventListener("scroll", onScroll);423 anchorEl.addEventListener("focus", () => scheduleBurst());424 anchorEl.addEventListener("input", () => scheduleBurst());425426 scheduleBurst(260);427428 return () => {429 if (rafId) cancelAnimationFrame(rafId);430 resizeObserver.disconnect();431 mutationObserver.disconnect();432 window.removeEventListener("scroll", onScroll, true);433 window.removeEventListener("resize", onScroll);434 window.visualViewport?.removeEventListener("resize", onScroll);435 window.visualViewport?.removeEventListener("scroll", onScroll);436 };437}438439export function injectFieldIcon(field: HTMLInputElement, onClick: () => void): () => void {440 const button = document.createElement("button");441 button.type = "button";442 button.setAttribute("aria-label", "Peach autofill");443 button.title = "Fill with Peach";444 button.innerHTML = peachIconSvg();445 446 447 448 449 button.style.cssText = `450 position: fixed; z-index: 2147483646;451 width: 26px; height: 26px; cursor: pointer;452 pointer-events: auto; border: none; padding: 3px;453 display: inline-flex; align-items: center; justify-content: center;454 background: transparent; border-radius: 999px;455 transition: opacity 140ms ease, background 120ms ease, box-shadow 120ms ease, transform 80ms ease;456 opacity: 0;457 `;458 button.addEventListener("mouseenter", () => {459 button.style.background = `color-mix(in srgb, ${accentHex} 12%, transparent)`;460 button.style.boxShadow = `0 0 0 1px color-mix(in srgb, ${accentHex} 18%, transparent), 0 0 14px color-mix(in srgb, ${accentHex} 12%, transparent)`;461 button.style.transform = "scale(1.08)";462 });463 button.addEventListener("mouseleave", () => {464 button.style.background = "transparent";465 button.style.boxShadow = "none";466 button.style.transform = "none";467 });468 button.addEventListener("pointerdown", e => { e.stopPropagation(); e.preventDefault(); });469 button.addEventListener("click", e => { e.stopPropagation(); e.preventDefault(); onClick(); });470471 document.body.appendChild(button);472473 function updatePosition() {474 const rect = field.getBoundingClientRect();475 if (rect.width === 0 || rect.height === 0) {476 button.style.opacity = "0"; button.style.pointerEvents = "none";477 return;478 }479 const sz = 26;480 const inset = Math.max(5, Math.min(10, rect.height * 0.22));481 const top = rect.top + rect.height / 2 - sz / 2;482 483 484 const minLeft = rect.left + 4;485 const left = Math.max(minLeft, rect.right - sz - inset);486 487 if (rect.width < 40) {488 button.style.opacity = "0"; button.style.pointerEvents = "none";489 return;490 }491 button.style.top = `${top}px`;492 button.style.left = `${left}px`;493 button.style.opacity = "1"; button.style.pointerEvents = "auto";494 }495 updatePosition();496 requestAnimationFrame(() => { button.style.opacity = "1"; });497 const stopObserving = observeAnchorPosition(field, updatePosition);498 return () => { stopObserving(); button.remove(); };499}500501502503504505506507const SELECTOR_STYLES = `508 :host { all: initial; }509 *,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }510511 .peach-inline-popup[data-theme="dark"] {512 --peach-bg: #1a1410;513 --peach-bg-card: #221c16;514 --peach-text: #f5f0ea;515 --peach-text-dim: #8a7a6a;516 --peach-text-muted: #4a3a2a;517 --peach-border: rgba(255,255,255,0.07);518 --peach-input-bg: rgba(255,255,255,0.05);519 --peach-input-border: rgba(255,255,255,0.08);520 }521 .peach-inline-popup[data-theme="light"] {522 --peach-bg: #fdf8f4;523 --peach-bg-card: #f5ede4;524 --peach-text: #1c1310;525 --peach-text-dim: #6b5a4a;526 --peach-text-muted: #a89080;527 --peach-border: rgba(0,0,0,0.08);528 --peach-input-bg: rgba(0,0,0,0.04);529 --peach-input-border: rgba(0,0,0,0.10);530 }531532 .peach-inline-popup {533 background: var(--peach-bg);534 border: 1px solid var(--peach-border-accent, var(--peach-border));535 border-radius: 14px;536 overflow: hidden;537 box-shadow:538 0 8px 40px var(--peach-glow, transparent),539 0 2px 12px rgba(0,0,0,0.5);540 font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;541 animation: peach-enter 200ms cubic-bezier(0.16,1,0.3,1) forwards;542 transition: height 220ms cubic-bezier(0.16,1,0.3,1);543 }544 /* Light theme: shadow against a light page is too strong otherwise — drop both545 the accent glow and the dark drop-shadow opacity to keep the popup elegant. */546 .peach-inline-popup[data-theme="light"] {547 box-shadow:548 0 8px 40px color-mix(in srgb, var(--peach-accent) 10%, transparent),549 0 2px 12px rgba(0,0,0,0.12);550 }551 .peach-inline-popup.is-exiting {552 animation: peach-exit 130ms cubic-bezier(0.4,0,1,1) forwards;553 pointer-events: none;554 }555556 @keyframes peach-enter {557 0% { opacity: 0; transform: translateY(-8px) scale(0.96); filter: blur(3px); }558 65% { opacity: 1; filter: blur(0); }559 100% { opacity: 1; transform: translateY(0) scale(1); }560 }561 @keyframes peach-exit {562 0% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }563 100% { opacity: 0; transform: translateY(-4px) scale(0.98); filter: blur(2px); }564 }565 @keyframes peach-slide-in {566 from { opacity: 0; transform: translateX(12px); }567 to { opacity: 1; transform: translateX(0); }568 }569 @keyframes peach-slide-back {570 from { opacity: 0; transform: translateX(-12px); }571 to { opacity: 1; transform: translateX(0); }572 }573 .peach-content[data-dir="forward"] { animation: peach-slide-in 150ms cubic-bezier(0.16,1,0.3,1) both; }574 .peach-content[data-dir="back"] { animation: peach-slide-back 150ms cubic-bezier(0.16,1,0.3,1) both; }575576 /* Domain header */577 .domain-header {578 padding: 9px 13px 7px;579 border-bottom: 1px solid var(--peach-border);580 display: flex; align-items: center; justify-content: space-between;581 gap: 8px;582 }583 .domain-header-text {584 display: flex; flex-direction: column; gap: 2px;585 min-width: 0; flex: 1;586 }587 .domain-eyebrow {588 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;589 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;590 }591 .domain-name {592 font-size: 10px; color: color-mix(in srgb, var(--peach-accent) 60%, transparent);593 font-family: "IBM Plex Mono", monospace;594 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;595 }596 .domain-add-btn {597 flex-shrink: 0;598 width: 22px; height: 22px;599 display: inline-flex; align-items: center; justify-content: center;600 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);601 border: 1px solid color-mix(in srgb, var(--peach-accent) 28%, transparent);602 border-radius: 6px;603 color: var(--peach-accent);604 cursor: pointer; padding: 0;605 transition: background 120ms, border-color 120ms, transform 80ms;606 font-family: "IBM Plex Mono", monospace;607 font-size: 14px; line-height: 1;608 }609 .domain-add-btn:hover {610 background: color-mix(in srgb, var(--peach-accent) 22%, transparent);611 border-color: color-mix(in srgb, var(--peach-accent) 48%, transparent);612 transform: scale(1.06);613 }614 .domain-add-btn:active { transform: scale(0.96); }615616 /* Search */617 .search-wrap {618 padding: 9px 12px 7px;619 border-bottom: 1px solid var(--peach-border);620 }621 .search {622 width: 100%; background: var(--peach-input-bg);623 border: 1px solid var(--peach-input-border);624 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;625 font-size: 12px; outline: none; font-family: "IBM Plex Mono", monospace;626 transition: border-color 120ms, box-shadow 120ms;627 }628 .search:focus {629 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);630 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);631 }632 .search::placeholder { color: var(--peach-text-muted); }633634 /* Results */635 .results { max-height: 256px; overflow-y: auto; scrollbar-width: none; }636 .results::-webkit-scrollbar { display: none; }637638 /* Entry rows */639 .entry {640 display: flex; align-items: center; padding: 8px 12px;641 cursor: pointer; border-bottom: 1px solid var(--peach-border);642 transition: background 70ms; position: relative; outline: none;643 }644 .entry:last-child { border-bottom: none; }645 .entry:hover { background: color-mix(in srgb, var(--peach-text) 4%, transparent); }646 .entry.focused { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }647 .entry.focused::before {648 content: ""; position: absolute; left: 0; top: 3px; bottom: 3px;649 width: 2px; border-radius: 2px;650 background: color-mix(in srgb, var(--peach-accent) 55%, transparent);651 }652653 .entry-icon {654 width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;655 background: var(--peach-input-bg); border: 1px solid var(--peach-border);656 display: flex; align-items: center; justify-content: center;657 overflow: hidden; margin-right: 10px;658 }659 .entry-icon img { width: 15px; height: 15px; border-radius: 2px; display: block; }660 .entry-icon.is-new {661 background: color-mix(in srgb, var(--peach-accent) 8%, transparent);662 border-color: color-mix(in srgb, var(--peach-accent) 15%, transparent);663 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);664 }665666 .entry-info { flex: 1; min-width: 0; }667 .entry-title {668 font-size: 12.5px; color: var(--peach-text);669 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;670 line-height: 1.3;671 }672 .entry-title.is-new { color: color-mix(in srgb, var(--peach-accent) 90%, transparent); font-size: 12px; }673 .entry-sub {674 font-size: 10px; color: var(--peach-text-dim);675 font-family: "IBM Plex Mono", monospace;676 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;677 margin-top: 1px;678 }679680 .totp-badge {681 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;682 border-radius: 4px; background: color-mix(in srgb, var(--peach-accent) 10%, transparent);683 color: color-mix(in srgb, var(--peach-accent) 75%, transparent);684 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 8px;685 }686 .passkey-badge {687 font-size: 8px; letter-spacing: 0.04em; padding: 2px 6px;688 border-radius: 4px;689 background: color-mix(in srgb, var(--peach-accent) 14%, transparent);690 color: color-mix(in srgb, var(--peach-accent) 85%, transparent);691 border: 1px solid color-mix(in srgb, var(--peach-accent) 24%, transparent);692 font-family: "IBM Plex Mono", monospace; flex-shrink: 0; margin-left: 6px;693 }694695 .divider { height: 1px; background: var(--peach-border); margin: 2px 0; }696697 .empty-hint {698 padding: 14px 13px; font-size: 11px; color: var(--peach-text-dim);699 font-family: "IBM Plex Mono", monospace;700 }701702 /* Create form */703 .create-form-wrap {704 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;705 }706 .create-head {707 display: flex; align-items: center; gap: 8px;708 padding: 10px 12px; border-bottom: 1px solid var(--peach-border);709 }710 .back-btn {711 background: transparent; border: none; cursor: pointer;712 color: var(--peach-text-dim); padding: 3px; border-radius: 5px;713 display: flex; align-items: center; line-height: 0;714 transition: color 100ms, background 100ms;715 }716 .back-btn:hover { color: var(--peach-text); background: var(--peach-input-bg); }717 .create-label { font-size: 12px; color: var(--peach-text); font-weight: 500; flex: 1; }718 /* minmax(0, 1fr) caps the grid track at the popup width — without it,719 long monospace content (e.g. a 60-char generated password) would720 auto-size the track wider than the popup and overflow the right edge. */721 .create-body { padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }722 .f-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }723 .f-label {724 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;725 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;726 }727 .f-input {728 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);729 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;730 font-size: 11px; font-family: "IBM Plex Mono", monospace;731 outline: none; width: 100%; transition: border-color 120ms, box-shadow 120ms;732 }733 .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); }734 .f-input::placeholder { color: var(--peach-text-muted); }735 .f-input.url-f { font-size: 10px; color: var(--peach-text-dim); letter-spacing: 0.01em; }736 .f-row { display: flex; gap: 6px; }737 .f-row .f-input { flex: 1; min-width: 0; }738 .gen-btn {739 padding: 0 10px; border-radius: 7px; border: none;740 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);741 color: color-mix(in srgb, var(--peach-accent) 80%, transparent);742 font-size: 10px; font-family: "IBM Plex Mono", monospace;743 cursor: pointer; white-space: nowrap; flex-shrink: 0;744 display: flex; align-items: center; gap: 4px;745 transition: background 100ms;746 }747 .gen-btn:hover { background: color-mix(in srgb, var(--peach-accent) 18%, transparent); }748 .gen-toggle-link {749 background: none; border: none; padding: 2px 0;750 color: color-mix(in srgb, var(--peach-accent) 60%, transparent);751 font-size: 10px; font-family: "IBM Plex Mono", monospace;752 cursor: pointer; text-align: left; transition: color 100ms;753 }754 .gen-toggle-link:hover { color: var(--peach-accent); }755 .save-btn {756 width: 100%; padding: 8px; border-radius: 8px; border: none;757 background: var(--peach-accent); color: #fff; font-size: 12px;758 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;759 transition: background 120ms, box-shadow 120ms, transform 80ms;760 letter-spacing: 0.01em;761 }762 .save-btn:hover {763 background: color-mix(in srgb, var(--peach-accent) 82%, #000);764 box-shadow: 0 4px 20px var(--peach-glow, transparent);765 }766 .save-btn:disabled { opacity: 0.4; cursor: not-allowed; }767 .url-hint {768 font-size: 9px; color: color-mix(in srgb, var(--peach-accent) 45%, transparent);769 font-family: "IBM Plex Mono", monospace; font-style: italic;770 }771772 /* Success */773 .success-wrap {774 display: flex; flex-direction: column; align-items: center;775 padding: 24px 16px 20px; gap: 8px;776 animation: su-in 280ms cubic-bezier(0.16,1,0.3,1) both;777 }778 @keyframes su-in { from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:none} }779 .success-ring {780 width: 40px; height: 40px; border-radius: 50%;781 background: rgba(123,144,96,0.10); border: 1.5px solid rgba(123,144,96,0.25);782 display: flex; align-items: center; justify-content: center;783 }784 .success-text { font-size: 12.5px; color: var(--peach-text); font-weight: 500; }785 .success-sub { font-size: 10px; color: var(--peach-text-dim); font-family:"IBM Plex Mono",monospace; }786787 /* Silver platter (State 1 — single match) */788 .silver-platter {789 padding: 14px 14px 12px;790 display: flex; flex-direction: column; gap: 6px;791 }792 .sp-title {793 font-size: 14px; font-weight: 500; color: var(--peach-text);794 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;795 line-height: 1.25;796 }797 .sp-identity-row {798 display: flex; align-items: baseline; gap: 5px; margin-bottom: 3px;799 }800 .sp-identity-label {801 font-size: 9px; font-weight: 600; letter-spacing: 0.05em;802 text-transform: uppercase; color: var(--peach-text-muted); flex-shrink: 0;803 }804 .sp-username {805 font-size: 12px; color: var(--peach-text-dim);806 font-family: "IBM Plex Mono", monospace;807 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;808 margin-bottom: 0;809 }810 .sp-identity-row + .sp-fill-btn, .sp-username + .sp-fill-btn { margin-top: 6px; }811 .sp-fill-btn {812 width: 100%; padding: 11px; border-radius: 9px; border: none;813 background: var(--peach-accent); color: #fff;814 font-size: 13px; font-weight: 500; cursor: pointer;815 font-family: Inter, sans-serif; letter-spacing: 0.01em;816 display: flex; align-items: center; justify-content: center; min-height: 38px;817 transition: filter 120ms ease, transform 80ms ease, box-shadow 120ms ease, background 120ms ease;818 }819 .sp-fill-btn:hover {820 filter: brightness(1.1);821 box-shadow: 0 4px 20px var(--peach-glow, transparent);822 transform: translateY(-1px);823 }824 .sp-fill-btn:active { transform: translateY(0); filter: brightness(0.95); }825 .sp-fill-btn.filled {826 background: #16a34a; transform: none; filter: none;827 box-shadow: 0 4px 16px rgba(22,163,74,0.35);828 cursor: default;829 }830 .sp-fill-btn:disabled { cursor: default; }831 .sp-actions {832 display: flex; gap: 4px; justify-content: space-between; align-items: center;833 margin-top: 4px;834 }835 .sp-action-btn {836 flex: 1; height: 28px; border: none; border-radius: 6px;837 background: transparent; color: var(--peach-text-dim);838 font-size: 12px; cursor: pointer;839 transition: background 120ms ease, color 120ms ease;840 font-family: Inter, sans-serif; letter-spacing: 0.04em;841 display: inline-flex; align-items: center; justify-content: center; gap: 4px;842 white-space: nowrap; overflow: hidden;843 }844 .sp-action-btn:hover:not(:disabled) {845 background: color-mix(in srgb, var(--peach-text) 5%, transparent);846 color: var(--peach-text);847 }848 .sp-action-btn:disabled { opacity: 0.3; cursor: default; }849 .sp-action-btn.flashed {850 color: var(--peach-accent);851 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);852 }853854 /* TOTP tray — shown below the silver-platter secondary actions */855 .sp-tray {856 margin-top: 8px;857 padding: 10px 12px;858 border-radius: 9px;859 background: var(--peach-input-bg);860 border: 1px solid var(--peach-input-border);861 display: flex; align-items: center; gap: 12px;862 animation: peach-slide-in 180ms cubic-bezier(0.16,1,0.3,1) both;863 }864 .sp-tray-label {865 font-size: 8px; letter-spacing: 0.12em; text-transform: uppercase;866 color: var(--peach-text-dim); font-family: "IBM Plex Mono", monospace;867 flex-shrink: 0;868 }869 .sp-totp-code {870 font-size: 18px; font-weight: 500;871 color: var(--peach-text);872 font-family: "IBM Plex Mono", monospace;873 letter-spacing: 0.12em;874 flex: 1;875 text-align: center;876 }877 .sp-totp-ring {878 width: 22px; height: 22px; flex-shrink: 0;879 }880 .sp-totp-ring .ring-track { stroke: var(--peach-input-border); }881 .sp-totp-ring .ring-fill {882 stroke: var(--peach-accent);883 transition: stroke-dashoffset 1s linear;884 transform: rotate(-90deg);885 transform-origin: center;886 }887 .sp-totp-copy {888 background: transparent; border: none; cursor: pointer;889 padding: 4px 8px; border-radius: 5px;890 color: var(--peach-text-dim); font-size: 11px;891 font-family: Inter, sans-serif;892 transition: background 120ms, color 120ms;893 }894 .sp-totp-copy:hover {895 background: color-mix(in srgb, var(--peach-text) 5%, transparent);896 color: var(--peach-text);897 }898899 /* Card silver platter (State 7) — reuses .sp-* primary action classes */900 .card-platter {901 padding: 12px 14px 10px;902 display: flex; flex-direction: column; gap: 4px;903 }904 .cp-network {905 font-size: 10px; font-weight: 600;906 color: var(--peach-accent);907 letter-spacing: 0.08em; text-transform: uppercase;908 font-family: Inter, sans-serif;909 }910 .cp-nickname {911 font-size: 14px; font-weight: 500; color: var(--peach-text);912 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;913 line-height: 1.2;914 }915 .cp-last4 {916 font-size: 12px; color: var(--peach-text-dim);917 font-family: "IBM Plex Mono", monospace;918 letter-spacing: 0.04em;919 margin-top: 2px;920 }921 .cp-meta {922 font-size: 11px; color: var(--peach-text-dim);923 font-family: "IBM Plex Mono", monospace;924 margin-top: 2px;925 display: flex; gap: 10px; align-items: center;926 }927 .cp-meta-sep { opacity: 0.5; }928 .cp-fill-wrap { margin-top: 10px; }929930 /* Locked state */931 .locked-wrap {932 display: flex; flex-direction: column; align-items: stretch;933 padding: 14px 13px 13px; gap: 9px;934 }935 .locked-head { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }936 .locked-icon {937 width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;938 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);939 display: flex; align-items: center; justify-content: center;940 }941 .locked-title { font-size: 11.5px; color: var(--peach-text); font-weight: 500; }942 .locked-input {943 width: 100%; background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);944 border-radius: 7px; color: var(--peach-text); padding: 7px 10px;945 font-size: 11px; font-family: "IBM Plex Mono", monospace;946 outline: none; transition: border-color 120ms, box-shadow 120ms;947 }948 .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); }949 .locked-input::placeholder { color: var(--peach-text-muted); }950 .locked-btn {951 width: 100%; padding: 8px; border-radius: 8px; border: none;952 background: var(--peach-accent); color: #fff; font-size: 12px;953 font-family: Inter, sans-serif; cursor: pointer; font-weight: 500;954 transition: background 120ms;955 letter-spacing: 0.01em;956 box-shadow: 0 2px 16px var(--peach-glow, transparent);957 animation: peach-pulse-glow 2.4s ease-in-out infinite;958 }959 .locked-btn:hover { background: color-mix(in srgb, var(--peach-accent) 82%, #000); }960 .locked-btn:disabled { opacity: 0.4; cursor: not-allowed; animation: none; }961 .locked-error {962 font-size: 10px; color: rgba(220,80,60,0.85);963 font-family: "IBM Plex Mono", monospace;964 }965966 @keyframes peach-pulse-glow {967 0%, 100% { box-shadow: 0 2px 16px var(--peach-glow, transparent); }968 50% { box-shadow: 0 2px 28px var(--peach-glow, transparent),969 0 0 48px var(--peach-glow, transparent); }970 }971972 /* ── State 10: identity helper ─────────────────────────────── */973 .identity-list {974 max-height: 192px; overflow-y: auto; padding: 4px 0;975 scrollbar-width: none;976 }977 .identity-list::-webkit-scrollbar { display: none; }978 .peach-identity-row {979 display: flex; align-items: center; gap: 10px;980 padding: 9px 12px; cursor: pointer; border-radius: 8px;981 transition: background 100ms ease;982 }983 .peach-identity-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }984 .peach-identity-value {985 font-family: "IBM Plex Mono", monospace; font-size: 13px;986 color: var(--peach-text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;987 }988 .peach-identity-meta { font-size: 10px; color: var(--peach-text-muted); flex-shrink: 0; }989 .identity-alt-row {990 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;991 border-radius: 8px; transition: background 100ms ease;992 color: var(--peach-text-dim); font-size: 12px; font-family: Inter, sans-serif;993 }994 .identity-alt-row:hover { background: color-mix(in srgb, var(--peach-text) 6%, transparent); }995 .identity-escape-row {996 display: flex; align-items: center; padding: 8px 12px; cursor: pointer;997 border-radius: 8px; transition: background 100ms ease; outline: none;998 color: var(--peach-accent); font-size: 11px; font-family: Inter, sans-serif;999 margin-top: 2px;1000 }1001 .identity-escape-row:hover, .identity-escape-row:focus { background: color-mix(in srgb, var(--peach-accent) 8%, transparent); }1002 .identity-alt-input-wrap { display: none; padding: 0 12px 8px; gap: 6px; align-items: center; }1003 .identity-alt-input-wrap.open { display: flex; }1004 .identity-alt-input {1005 flex: 1; height: 32px; padding: 0 10px; border-radius: 7px;1006 border: 1px solid var(--peach-input-border); background: var(--peach-input-bg);1007 color: var(--peach-text); font-family: "IBM Plex Mono", monospace; font-size: 12px;1008 outline: none; transition: border-color 120ms;1009 }1010 .identity-alt-input:focus {1011 border-color: color-mix(in srgb, var(--peach-accent) 40%, transparent);1012 box-shadow: 0 0 0 2px color-mix(in srgb, var(--peach-accent) 10%, transparent);1013 }1014 .identity-alt-confirm {1015 height: 32px; padding: 0 12px; border-radius: 7px; border: none;1016 background: var(--peach-accent); color: #fff; font-size: 12px;1017 cursor: pointer; font-family: Inter, sans-serif; flex-shrink: 0;1018 }1019 /* ── Generator view (after identity picked) ────────────────── */1020 .gen-view { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1021 .gen-confirmed {1022 display: flex; align-items: center; gap: 8px; padding: 7px 10px;1023 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1024 border-radius: 8px;1025 }1026 .gen-confirmed-check { color: var(--peach-accent); font-size: 13px; font-weight: 600; }1027 .gen-confirmed-val {1028 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1029 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1030 }1031 .gen-label {1032 font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;1033 color: var(--peach-text-muted); font-family: "IBM Plex Mono", monospace;1034 }1035 .gen-pw-row { display: flex; gap: 6px; align-items: center; }1036 .gen-pw-val {1037 flex: 1; padding: 8px 10px; border-radius: 7px;1038 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1039 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1040 white-space: nowrap; overflow: hidden; text-overflow: ellipsis;1041 }1042 .gen-regen-btn {1043 height: 34px; padding: 0 10px; border-radius: 7px; border: none;1044 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1045 color: var(--peach-text-dim); font-size: 11px; cursor: pointer;1046 font-family: "IBM Plex Mono", monospace; transition: background 100ms ease;1047 }1048 .gen-regen-btn:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1049 .gen-fill-btn {1050 padding: 10px; border-radius: 8px; border: none;1051 background: var(--peach-accent); color: #fff; font-size: 13px; font-weight: 500;1052 cursor: pointer; font-family: Inter, sans-serif; letter-spacing: 0.01em;1053 transition: filter 120ms ease, transform 80ms ease;1054 }1055 .gen-fill-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }1056 .gen-fill-btn:active { transform: translateY(0); }10571058 /* ── Smart password generator (parity with main UI compact mode) ─── */1059 .pwgen-block { display: flex; flex-direction: column; gap: 8px; }1060 .pwgen-display-row {1061 display: flex; align-items: center; gap: 6px;1062 padding: 8px 10px; border-radius: 7px;1063 background: var(--peach-input-bg); border: 1px solid var(--peach-input-border);1064 }1065 .pwgen-output {1066 flex: 1; min-width: 0; width: 0;1067 font-family: "IBM Plex Mono", monospace; font-size: 12px;1068 color: var(--peach-text);1069 background: transparent; border: none; outline: none; padding: 0;1070 }1071 .pwgen-icon-btn {1072 flex-shrink: 0;1073 width: 26px; height: 26px;1074 display: inline-flex; align-items: center; justify-content: center;1075 background: transparent; border: 1px solid var(--peach-input-border);1076 border-radius: 6px; color: var(--peach-text-dim); cursor: pointer;1077 padding: 0; transition: background 100ms, color 100ms, border-color 100ms;1078 }1079 .pwgen-icon-btn:hover {1080 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1081 color: var(--peach-accent);1082 border-color: color-mix(in srgb, var(--peach-accent) 30%, transparent);1083 }1084 .pwgen-icon-btn.is-copied {1085 background: color-mix(in srgb, var(--peach-accent) 18%, transparent);1086 color: var(--peach-accent);1087 border-color: color-mix(in srgb, var(--peach-accent) 45%, transparent);1088 }1089 .pwgen-controls-row {1090 display: flex; align-items: center; gap: 8px;1091 flex-wrap: wrap;1092 }1093 .pwgen-slider {1094 flex: 1; min-width: 110px;1095 accent-color: var(--peach-accent);1096 cursor: pointer; height: 2px; background: transparent;1097 }1098 .pwgen-len-num {1099 font-family: "IBM Plex Mono", monospace; font-size: 11px;1100 color: var(--peach-accent); min-width: 22px; text-align: right;1101 }1102 .pwgen-len-num--edit { cursor: text; border-bottom: 1px dotted color-mix(in srgb, var(--peach-accent) 50%, transparent); }1103 .pwgen-len-input {1104 font-family: "IBM Plex Mono", monospace; font-size: 11px;1105 color: var(--peach-accent); width: 28px; text-align: right;1106 background: transparent; border: none; border-bottom: 1px solid var(--peach-accent);1107 outline: none; padding: 0; min-width: 22px;1108 }1109 @keyframes identity-suggest-in {1110 from { opacity: 0; transform: translateY(-4px); }1111 to { opacity: 1; transform: none; }1112 }1113 .identity-suggest-list { display: flex; flex-direction: column; gap: 1px; margin-top: 3px;1114 animation: identity-suggest-in 180ms cubic-bezier(0.16,1,0.3,1) both; }1115 .identity-filter-row { display: flex; align-items: center; gap: 4px; padding: 2px 0 4px; }1116 .identity-collapse-btn {1117 margin-left: auto; background: transparent; border: none; cursor: pointer;1118 color: var(--peach-text-muted); padding: 2px 4px; display: flex; align-items: center;1119 line-height: 0; border-radius: 3px;1120 transition: color 100ms ease, transform 220ms cubic-bezier(0.16,1,0.3,1);1121 }1122 .identity-collapse-btn:hover { color: var(--peach-text); }1123 .identity-collapse-btn.is-collapsed { transform: rotate(-90deg); }1124 .identity-rows { display: grid; grid-template-rows: 1fr;1125 transition: grid-template-rows 220ms cubic-bezier(0.16,1,0.3,1); }1126 .identity-rows.is-collapsed { grid-template-rows: 0fr; }1127 .identity-rows-inner { overflow-y: auto; min-height: 0; max-height: 148px;1128 scrollbar-width: thin; scrollbar-color: var(--peach-text-muted) transparent;1129 mask-image: linear-gradient(to bottom, black calc(100% - 18px), transparent 100%);1130 -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 18px), transparent 100%); }1131 .identity-rows-inner::-webkit-scrollbar { width: 4px; }1132 .identity-rows-inner::-webkit-scrollbar-track { background: transparent; }1133 .identity-rows-inner::-webkit-scrollbar-thumb { background: var(--peach-text-muted); border-radius: 2px; }1134 .identity-filter-pill {1135 padding: 2px 7px; border-radius: 999px;1136 border: 1px solid var(--peach-input-border);1137 background: transparent; color: var(--peach-text-muted);1138 font-family: "IBM Plex Mono", monospace; font-size: 9px;1139 cursor: pointer; transition: border-color 80ms, background 80ms, color 80ms;1140 }1141 .identity-filter-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 .identity-suggest-row {1147 display: flex; align-items: center; gap: 5px;1148 width: 100%; padding: 4px 6px; border-radius: 5px; border: none;1149 background: transparent; cursor: pointer; text-align: left;1150 transition: background 80ms;1151 }1152 .identity-suggest-row:hover,1153 .identity-suggest-row:focus { background: color-mix(in srgb, var(--peach-accent) 10%, transparent); outline: none; }1154 .identity-suggest-val {1155 font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--peach-text);1156 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;1157 }1158 .identity-suggest-type {1159 font-family: "IBM Plex Mono", monospace; font-size: 8px; font-weight: 600;1160 flex-shrink: 0; padding: 1px 3px; border-radius: 3px;1161 }1162 .identity-suggest-type--email {1163 color: color-mix(in srgb, var(--peach-accent) 70%, transparent);1164 background: color-mix(in srgb, var(--peach-accent) 12%, transparent);1165 }1166 .identity-suggest-type--username {1167 color: var(--peach-text-muted);1168 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1169 }1170 .identity-suggest-meta {1171 font-family: "IBM Plex Mono", monospace; font-size: 9px;1172 color: var(--peach-text-muted); flex-shrink: 0;1173 }1174 .pwgen-pills { display: flex; gap: 5px; flex-wrap: wrap; }1175 .pwgen-pill {1176 padding: 3px 8px; border-radius: 999px;1177 border: 1px solid var(--peach-input-border);1178 background: transparent; color: var(--peach-text-muted);1179 font-family: "IBM Plex Mono", monospace; font-size: 9px;1180 letter-spacing: 0.06em; cursor: pointer;1181 transition: all 130ms ease;1182 }1183 .pwgen-pill.is-on {1184 border-color: color-mix(in srgb, var(--peach-accent) 50%, transparent);1185 background: color-mix(in srgb, var(--peach-accent) 10%, transparent);1186 color: var(--peach-accent);1187 }1188 .pwgen-pill:not(.is-on):hover {1189 color: var(--peach-text-dim);1190 border-color: var(--peach-text-muted);1191 }1192 .pwgen-policy-hint {1193 font-size: 10px; color: var(--peach-text-muted);1194 font-family: "IBM Plex Mono", monospace; letter-spacing: 0.04em;1195 line-height: 1.3;1196 }1197 .pwgen-policy-hint .pwgen-hint-accent { color: var(--peach-accent); }11981199 /* ── Save offer (after password filled) ───────────────────── */1200 .save-offer { padding: 12px; display: flex; flex-direction: column; gap: 8px; }1201 .save-offer-title {1202 font-size: 12px; font-weight: 600; color: var(--peach-text); font-family: Inter, sans-serif;1203 }1204 .save-offer-row {1205 display: flex; align-items: center; gap: 8px; padding: 6px 8px;1206 border-radius: 7px; background: var(--peach-input-bg);1207 border: 1px solid var(--peach-input-border);1208 }1209 .save-offer-lbl {1210 font-size: 10px; color: var(--peach-text-muted); width: 54px; flex-shrink: 0;1211 font-family: "IBM Plex Mono", monospace;1212 }1213 .save-offer-val {1214 font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--peach-text);1215 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;1216 }1217 .save-offer-btns { display: flex; gap: 8px; margin-top: 4px; }1218 .save-offer-save {1219 flex: 1; padding: 9px; border-radius: 8px; border: none;1220 background: var(--peach-accent); color: #fff; font-size: 13px;1221 cursor: pointer; font-family: Inter, sans-serif; transition: filter 120ms ease;1222 }1223 .save-offer-save:hover { filter: brightness(1.08); }1224 .save-offer-skip {1225 flex: 1; padding: 9px; border-radius: 8px; border: none;1226 background: color-mix(in srgb, var(--peach-text) 8%, transparent);1227 color: var(--peach-text-dim); font-size: 13px; cursor: pointer;1228 font-family: Inter, sans-serif; transition: background 100ms ease;1229 }1230 .save-offer-skip:hover { background: color-mix(in srgb, var(--peach-text) 14%, transparent); }1231`;12321233export function showAutofillSelector(1234 anchorEl: HTMLInputElement,1235 entries: SelectorEntry[],1236 onSelect: (id: string) => void,1237 options: SelectorOptions = {}1238): () => void {1239 const host = document.createElement("div");1240 host.style.cssText = "position: absolute; z-index: 2147483647;";1241 host.style.setProperty("--peach-accent", accentHex);1242 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));1243 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));1244 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));1245 const shadow = host.attachShadow({ mode: "closed" });12461247 const style = shadow.appendChild(document.createElement("style"));1248 style.textContent = SELECTOR_STYLES;12491250 const rect = anchorEl.getBoundingClientRect();1251 host.style.top = `${rect.bottom + window.scrollY + 5}px`;1252 host.style.left = `${rect.left + window.scrollX}px`;1253 1254 1255 host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;12561257 const container = shadow.appendChild(document.createElement("div"));1258 container.className = "peach-inline-popup";1259 container.setAttribute("data-theme", popupTheme);12601261 const searchableEntries = options.searchableEntries ?? [];1262 const { origin: sOrigin, title: sTitle, loginSubdomain } = smartUrl();12631264 let query = "";1265 let focusedIndex = -1;1266 let currentMode: "list" | "create" | "success" | "silver-platter" = "list";1267 let searchInput: HTMLInputElement | null = null;1268 1269 1270 const cleanupHooks: Array<() => void> = [];12711272 1273 1274 1275 {1276 let prevH = 0;1277 let blocked = false;1278 const heightRo = new ResizeObserver(([entry]) => {1279 if (blocked) return;1280 const h = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;1281 if (prevH > 0 && Math.abs(h - prevH) > 1) {1282 blocked = true;1283 container.style.height = `${prevH}px`;1284 requestAnimationFrame(() => requestAnimationFrame(() => {1285 container.style.height = `${h}px`;1286 prevH = h;1287 const onEnd = (e: TransitionEvent) => {1288 if (e.propertyName !== "height") return;1289 container.style.height = "";1290 blocked = false;1291 container.removeEventListener("transitionend", onEnd);1292 };1293 container.addEventListener("transitionend", onEnd);1294 }));1295 } else {1296 prevH = h;1297 }1298 });1299 heightRo.observe(container);1300 cleanupHooks.push(() => heightRo.disconnect());1301 }13021303 1304 const preUsername = (anchorEl.type !== "password") ? (anchorEl.value?.trim() ?? "") : "";1305 const pwInForm = anchorEl.closest("form")?.querySelector<HTMLInputElement>("input[type='password']");1306 const prePassword = pwInForm?.value?.trim() ?? (anchorEl.type === "password" ? anchorEl.value?.trim() : "") ?? "";13071308 function uniqueEntries(list: SelectorEntry[]): SelectorEntry[] {1309 const seen = new Set<string>();1310 return list.filter(e => { if (seen.has(e.id)) return false; seen.add(e.id); return true; });1311 }13121313 function filterEntries(source: SelectorEntry[], value: string): SelectorEntry[] {1314 const q = value.trim().toLowerCase();1315 const deduped = uniqueEntries(source);1316 if (!q) return deduped.slice(0, 8);1317 return deduped.filter(e =>1318 [e.title, e.username ?? "", e.url ?? ""].join(" ").toLowerCase().includes(q)1319 ).slice(0, 12);1320 }13211322 function activeEntries(): SelectorEntry[] {1323 1324 if (query.trim()) {1325 const merged = uniqueEntries([...entries, ...searchableEntries]);1326 return filterEntries(merged, query);1327 }1328 1329 if (entries.length > 0) return entries;1330 return filterEntries(searchableEntries, "").slice(0, 8);1331 }13321333 function makeEntryIcon(url?: string, isNew = false): HTMLDivElement {1334 const icon = document.createElement("div");1335 icon.className = `entry-icon${isNew ? " is-new" : ""}`;1336 if (isNew) {1337 icon.innerHTML = plusSvgStr();1338 } else {1339 1340 1341 1342 void url;1343 icon.innerHTML = keySvgStr();1344 }1345 return icon;1346 }13471348 function renderIdentityHelper() {1349 container.innerHTML = "";1350 const identities = options.savedIdentities ?? [];13511352 1353 const hdr = container.appendChild(document.createElement("div"));1354 hdr.className = "domain-header";1355 const eyebrow = hdr.appendChild(document.createElement("div"));1356 eyebrow.className = "domain-eyebrow";1357 eyebrow.textContent = "NEW ACCOUNT";1358 const domName = hdr.appendChild(document.createElement("div"));1359 domName.className = "domain-name";1360 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");13611362 1363 const list = container.appendChild(document.createElement("div"));1364 list.className = "identity-list";1365 for (const id of identities) {1366 const row = list.appendChild(document.createElement("div"));1367 row.className = "peach-identity-row";1368 row.setAttribute("tabindex", "-1");1369 const val = row.appendChild(document.createElement("div"));1370 val.className = "peach-identity-value";1371 val.textContent = id.value;1372 const meta = row.appendChild(document.createElement("div"));1373 meta.className = "peach-identity-meta";1374 meta.textContent = `used ${id.useCount}×`;1375 row.addEventListener("click", () => {1376 options.onFillFields?.(id.value, "");1377 renderGenerator(id.value);1378 });1379 }13801381 1382 if (identities.length > 0) {1383 container.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1384 }13851386 1387 const altRow = container.appendChild(document.createElement("div"));1388 altRow.className = "identity-alt-row";1389 altRow.textContent = "+ Use a different email…";13901391 const altInputWrap = container.appendChild(document.createElement("div"));1392 altInputWrap.className = "identity-alt-input-wrap";1393 const altInput = altInputWrap.appendChild(document.createElement("input"));1394 altInput.className = "identity-alt-input";1395 altInput.type = "email";1396 altInput.placeholder = "[email protected]";1397 altInput.setAttribute("autocomplete", "off");1398 const altConfirm = altInputWrap.appendChild(document.createElement("button"));1399 altConfirm.className = "identity-alt-confirm";1400 altConfirm.type = "button";1401 altConfirm.textContent = "✓";14021403 function fillCustomEmail() {1404 const v = altInput.value.trim();1405 if (!v) return;1406 options.onFillFields?.(v, "");1407 renderGenerator(v);1408 }14091410 altRow.addEventListener("click", () => {1411 altRow.style.display = "none";1412 altInputWrap.classList.add("open");1413 altInput.focus();1414 });1415 altConfirm.addEventListener("click", fillCustomEmail);1416 altInput.addEventListener("keydown", (e) => {1417 if (e.key === "Enter") { e.preventDefault(); fillCustomEmail(); }1418 });14191420 1421 1422 1423 1424 1425 if ((options.searchableEntries?.length ?? 0) > 0) {1426 const escapeRow = container.appendChild(document.createElement("div"));1427 escapeRow.className = "identity-escape-row";1428 escapeRow.textContent = "I already have an account →";1429 escapeRow.setAttribute("tabindex", "0");1430 escapeRow.addEventListener("click", () => renderList());1431 escapeRow.addEventListener("keydown", (e) => {1432 if (e.key === "Enter" || e.key === " ") { e.preventDefault(); renderList(); }1433 });1434 }1435 }14361437 function renderGenerator(filledEmail: string) {1438 container.innerHTML = "";1439 const sitePolicy = detectPasswordPolicy();14401441 const wrap = container.appendChild(document.createElement("div"));1442 wrap.className = "gen-view";14431444 1445 const hdrRow = wrap.appendChild(document.createElement("div"));1446 hdrRow.className = "domain-header";1447 const eyebrow2 = hdrRow.appendChild(document.createElement("div"));1448 eyebrow2.className = "domain-eyebrow";1449 eyebrow2.textContent = "NEW ACCOUNT";1450 const domName2 = hdrRow.appendChild(document.createElement("div"));1451 domName2.className = "domain-name";1452 domName2.textContent = options.domain ?? location.hostname.replace(/^www\./, "");14531454 1455 const conf = wrap.appendChild(document.createElement("div"));1456 conf.className = "gen-confirmed";1457 const confCheck = conf.appendChild(document.createElement("span"));1458 confCheck.className = "gen-confirmed-check";1459 confCheck.textContent = "✓";1460 const confVal = conf.appendChild(document.createElement("div"));1461 confVal.className = "gen-confirmed-val";1462 confVal.textContent = filledEmail;14631464 const lbl = wrap.appendChild(document.createElement("div"));1465 lbl.className = "gen-label";1466 lbl.textContent = "Generate a password";14671468 let currentPw = "";1469 const smartGen = createSmartGenerator({1470 policy: sitePolicy,1471 onChange: (pw) => { currentPw = pw; },1472 });1473 wrap.appendChild(smartGen.root);14741475 const fillBtn = wrap.appendChild(document.createElement("button"));1476 fillBtn.className = "gen-fill-btn";1477 fillBtn.type = "button";1478 fillBtn.textContent = "Copy & fill";1479 fillBtn.addEventListener("click", () => {1480 if (!currentPw) return;1481 options.onFillFields?.("", currentPw);1482 renderSaveOffer(filledEmail, currentPw);1483 });1484 }14851486 function renderSaveOffer(filledEmail: string, filledPassword: string) {1487 container.innerHTML = "";1488 const domain = options.domain ?? location.hostname.replace(/^www\./, "");14891490 const wrap = container.appendChild(document.createElement("div"));1491 wrap.className = "save-offer";14921493 const title = wrap.appendChild(document.createElement("div"));1494 title.className = "save-offer-title";1495 title.textContent = "Save this login to Peach?";14961497 function detailRow(label: string, value: string) {1498 const row = wrap.appendChild(document.createElement("div"));1499 row.className = "save-offer-row";1500 const lbl = row.appendChild(document.createElement("div"));1501 lbl.className = "save-offer-lbl";1502 lbl.textContent = label;1503 const val = row.appendChild(document.createElement("div"));1504 val.className = "save-offer-val";1505 val.textContent = value;1506 }15071508 detailRow("site", domain);1509 detailRow("email", filledEmail);1510 detailRow("password", "••••••••••••••••");15111512 const btns = wrap.appendChild(document.createElement("div"));1513 btns.className = "save-offer-btns";15141515 const saveBtn = btns.appendChild(document.createElement("button"));1516 saveBtn.className = "save-offer-save";1517 saveBtn.type = "button";1518 saveBtn.textContent = "Save";1519 saveBtn.addEventListener("click", async () => {1520 saveBtn.disabled = true;1521 saveBtn.textContent = "Saving…";1522 try {1523 const res = await chrome.runtime.sendMessage({1524 type: "ADD_ENTRY",1525 payload: { title: sTitle, url: sOrigin, username: filledEmail, password: filledPassword, type: "login" },1526 });1527 if ((res as { ok?: boolean }).ok) {1528 showSuccess(sTitle);1529 } else {1530 saveBtn.disabled = false;1531 saveBtn.textContent = "Save";1532 }1533 } catch { saveBtn.disabled = false; saveBtn.textContent = "Save"; }1534 });15351536 const skipBtn = btns.appendChild(document.createElement("button"));1537 skipBtn.className = "save-offer-skip";1538 skipBtn.type = "button";1539 skipBtn.textContent = "Not now";1540 skipBtn.addEventListener("click", () => { dismiss(true); });1541 }15421543 function renderList() {1544 container.innerHTML = "";1545 focusedIndex = -1;1546 searchInput = null;15471548 const current = activeEntries();15491550 1551 1552 1553 const domHdr = document.createElement("div");1554 domHdr.className = "domain-header";1555 const headText = document.createElement("div");1556 headText.className = "domain-header-text";1557 const eyebrow = document.createElement("div");1558 eyebrow.className = "domain-eyebrow";1559 eyebrow.textContent = options.isSignup1560 ? "Sign up as"1561 : entries.length > 0 ? "Saved for this site" : "No saved login";1562 const domName = document.createElement("div");1563 domName.className = "domain-name";1564 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1565 headText.append(eyebrow, domName);1566 domHdr.appendChild(headText);15671568 if (!options.isSignup) {1569 const addBtn = document.createElement("button");1570 addBtn.className = "domain-add-btn";1571 addBtn.type = "button";1572 addBtn.setAttribute("aria-label", "Create new entry");1573 addBtn.title = "Create new entry";1574 addBtn.textContent = "+";1575 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1576 domHdr.appendChild(addBtn);1577 }15781579 container.appendChild(domHdr);15801581 1582 const sw = document.createElement("div"); sw.className = "search-wrap";1583 searchInput = document.createElement("input");1584 searchInput.className = "search";1585 searchInput.placeholder = entries.length > 0 ? "search for another entry…" : "search vault…";1586 searchInput.value = query;1587 searchInput.addEventListener("input", () => {1588 query = searchInput?.value ?? "";1589 renderList();1590 searchInput?.focus();1591 searchInput?.setSelectionRange(query.length, query.length);1592 });1593 sw.appendChild(searchInput);1594 container.appendChild(sw);15951596 1597 const results = document.createElement("div");1598 results.className = "results";1599 container.appendChild(results);16001601 if (current.length === 0 && entries.length > 0) {1602 1603 }16041605 for (let i = 0; i < current.length; i++) {1606 const e = current[i]!;1607 const entryEl = document.createElement("div");1608 entryEl.className = "entry";1609 entryEl.dataset.id = e.id;1610 entryEl.dataset.index = String(i);1611 entryEl.setAttribute("tabindex", "-1");16121613 entryEl.appendChild(makeEntryIcon(e.url));16141615 const info = document.createElement("div"); info.className = "entry-info";1616 const titleEl = document.createElement("div"); titleEl.className = "entry-title"; titleEl.textContent = e.title;1617 const subEl = document.createElement("div"); subEl.className = "entry-sub";1618 const domain = e.url ? getDomainFromUrl(e.url) : "";1619 subEl.textContent = domain || e.username || "";1620 info.append(titleEl, subEl);1621 entryEl.appendChild(info);16221623 if (e.hasTotp) {1624 const badge = document.createElement("span"); badge.className = "totp-badge"; badge.textContent = "TOTP";1625 entryEl.appendChild(badge);1626 }1627 if (e.hasPasskey) {1628 const badge = document.createElement("span"); badge.className = "passkey-badge"; badge.textContent = "passkey";1629 entryEl.appendChild(badge);1630 }16311632 entryEl.addEventListener("click", () => {1633 if (options.isSignup && options.onFillFields) {1634 1635 options.onFillFields(e.username ?? "", "");1636 dismiss();1637 } else {1638 onSelect(e.id);1639 dismiss();1640 }1641 });1642 results.appendChild(entryEl);1643 }16441645 1646 if (current.length > 0) {1647 results.appendChild(Object.assign(document.createElement("div"), { className: "divider" }));1648 }16491650 1651 const newEl = document.createElement("div");1652 newEl.className = "entry";1653 newEl.setAttribute("tabindex", "-1");1654 newEl.appendChild(makeEntryIcon(undefined, true));16551656 const newInfo = document.createElement("div"); newInfo.className = "entry-info";1657 const newTitle = document.createElement("div");1658 newTitle.className = "entry-title is-new";1659 newTitle.textContent = `New entry for ${sTitle}`;1660 const newSub = document.createElement("div");1661 newSub.className = "entry-sub";1662 newSub.textContent = sOrigin;1663 newInfo.append(newTitle, newSub);1664 newEl.appendChild(newInfo);1665 newEl.addEventListener("click", showCreateForm);1666 results.appendChild(newEl);16671668 1669 if (searchInput) {1670 requestAnimationFrame(() => searchInput?.focus());1671 }1672 }16731674 function setFocused(idx: number) {1675 const all = container.querySelectorAll<HTMLElement>(".entry");1676 all.forEach((el, i) => el.classList.toggle("focused", i === idx));1677 focusedIndex = idx;1678 if (idx >= 0) (all[idx] as HTMLElement).scrollIntoView({ block: "nearest" });1679 }16801681 function attachIdentitySuggestions(g: HTMLDivElement, inp: HTMLInputElement, identities: SavedIdentity[], fieldType: "username" | "email"): void {1682 const typed = identities.filter(s => s.type === fieldType);1683 if (!typed.length) return;1684 let collapsed = false;1685 let suppressNextFocus = false;16861687 const list = g.appendChild(document.createElement("div"));1688 list.className = "identity-suggest-list";1689 list.style.display = "none";16901691 1692 const collapseRow = list.appendChild(document.createElement("div"));1693 collapseRow.className = "identity-filter-row";1694 collapseRow.style.justifyContent = "flex-end";1695 const collapseBtn = collapseRow.appendChild(document.createElement("button"));1696 collapseBtn.type = "button";1697 collapseBtn.className = "identity-collapse-btn";1698 collapseBtn.innerHTML = `<svg width="10" height="6" viewBox="0 0 10 6" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 1L5 5L9 1"/></svg>`;1699 collapseBtn.addEventListener("mousedown", (e) => {1700 e.preventDefault();1701 collapsed = !collapsed;1702 collapseBtn.classList.toggle("is-collapsed", collapsed);1703 rowsWrapper.classList.toggle("is-collapsed", collapsed);1704 });17051706 const rowsWrapper = list.appendChild(document.createElement("div"));1707 rowsWrapper.className = "identity-rows";1708 const rows = rowsWrapper.appendChild(document.createElement("div"));1709 rows.className = "identity-rows-inner";17101711 function pick(value: string) {1712 inp.value = value;1713 list.style.display = "none";1714 suppressNextFocus = true;1715 inp.focus();1716 }17171718 function render() {1719 const q = inp.value.toLowerCase();1720 const filtered = typed.filter(s => !q || s.value.toLowerCase().includes(q)).slice(0, 8);1721 rows.innerHTML = "";1722 if (!filtered.length) { list.style.display = "none"; return; }1723 for (const s of filtered) {1724 const row = rows.appendChild(document.createElement("button"));1725 row.type = "button"; row.className = "identity-suggest-row";1726 const val = row.appendChild(document.createElement("span"));1727 val.className = "identity-suggest-val"; val.textContent = s.value;1728 const meta = row.appendChild(document.createElement("span"));1729 meta.className = "identity-suggest-meta"; meta.textContent = `${s.useCount}×`;1730 row.addEventListener("mousedown", (e) => { e.preventDefault(); pick(s.value); });1731 row.addEventListener("keydown", (e) => {1732 if (e.key === "ArrowDown") {1733 e.preventDefault();1734 (row.nextElementSibling as HTMLElement | null)?.focus();1735 } else if (e.key === "ArrowUp") {1736 e.preventDefault();1737 const prev = row.previousElementSibling as HTMLElement | null;1738 if (prev) prev.focus();1739 else inp.focus();1740 } else if (e.key === "Enter" || e.key === " ") {1741 e.preventDefault();1742 pick(s.value);1743 } else if (e.key === "Escape") {1744 e.preventDefault();1745 list.style.display = "none";1746 suppressNextFocus = true;1747 inp.focus();1748 }1749 });1750 row.addEventListener("blur", (e) => {1751 const rt = (e as FocusEvent).relatedTarget as Node | null;1752 if (rt && (rt === inp || list.contains(rt))) return;1753 setTimeout(() => { list.style.display = "none"; }, 150);1754 });1755 }1756 list.style.display = "";1757 }17581759 inp.addEventListener("focus", () => {1760 if (suppressNextFocus) { suppressNextFocus = false; return; }1761 render();1762 });1763 inp.addEventListener("input", render);1764 inp.addEventListener("keydown", (e) => {1765 if (list.style.display === "none") return;1766 if (e.key === "ArrowDown" && !collapsed) {1767 e.preventDefault();1768 (rows.firstElementChild as HTMLElement | null)?.focus();1769 } else if (e.key === "Escape") {1770 e.preventDefault();1771 list.style.display = "none";1772 }1773 });1774 inp.addEventListener("blur", (e) => {1775 const rt = (e as FocusEvent).relatedTarget as Node | null;1776 if (rt && list.contains(rt)) return;1777 setTimeout(() => { list.style.display = "none"; }, 150);1778 });1779 }17801781 async function showCreateForm() {1782 currentMode = "create";1783 container.innerHTML = "";17841785 1786 1787 1788 const statusRes = await chrome.runtime.sendMessage({ type: "GET_VAULT_STATUS" }).catch(() => null) as { unlocked?: boolean } | null;1789 if (!statusRes?.unlocked) {1790 renderLocked();1791 return;1792 }17931794 1795 1796 const sitePolicy = detectPasswordPolicy();17971798 1799 1800 let formIdentities: SavedIdentity[] = options.savedIdentities ?? [];1801 if (!formIdentities.length) {1802 try {1803 const idRes = await chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null) as { ok: boolean; data?: SavedIdentity[] } | null;1804 if (idRes?.ok && Array.isArray(idRes.data)) formIdentities = idRes.data;1805 } catch { }1806 }18071808 const wrap = document.createElement("div");1809 wrap.className = "create-form-wrap";18101811 1812 const head = document.createElement("div"); head.className = "create-head";1813 const backBtn = document.createElement("button"); backBtn.className = "back-btn";1814 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>`;1815 backBtn.addEventListener("click", () => { currentMode = "list"; renderList(); });1816 const lbl = document.createElement("div"); lbl.className = "create-label"; lbl.textContent = "New entry";1817 head.append(backBtn, lbl);18181819 1820 const body = document.createElement("div"); body.className = "create-body";18211822 function fGroup(label: string): { g: HTMLDivElement; inp: HTMLInputElement } {1823 const g = document.createElement("div"); g.className = "f-group";1824 const l = document.createElement("div"); l.className = "f-label"; l.textContent = label;1825 const inp = document.createElement("input"); inp.className = "f-input";1826 g.append(l, inp); return { g, inp };1827 }18281829 1830 const tg = fGroup("title"); tg.inp.value = sTitle; tg.inp.placeholder = "e.g. Google";1831 body.appendChild(tg.g);18321833 1834 const ug = fGroup("website");1835 ug.inp.className = "f-input url-f"; ug.inp.value = sOrigin; ug.inp.placeholder = "https://";1836 if (loginSubdomain) {1837 const h = document.createElement("div"); h.className = "url-hint";1838 h.textContent = "⊘ Recognized sign-in subdomain"; ug.g.appendChild(h);1839 }1840 body.appendChild(ug.g);18411842 1843 const xg = fGroup("username");1844 xg.inp.value = preUsername && !preUsername.includes("@") ? preUsername : "";1845 xg.inp.placeholder = "johndoe";1846 xg.inp.setAttribute("autocomplete", "off");1847 if (formIdentities.length) attachIdentitySuggestions(xg.g, xg.inp, formIdentities, "username");1848 body.appendChild(xg.g);18491850 1851 const eg = fGroup("email");1852 (eg.inp as HTMLInputElement).type = "email";1853 eg.inp.value = preUsername && preUsername.includes("@") ? preUsername : "";1854 eg.inp.placeholder = "[email protected]";1855 eg.inp.setAttribute("autocomplete", "off");1856 if (formIdentities.length) attachIdentitySuggestions(eg.g, eg.inp, formIdentities, "email");1857 body.appendChild(eg.g);18581859 1860 1861 1862 const pg = fGroup("password");1863 pg.inp.remove(); 1864 let currentPassword = prePassword || "";1865 const smartGen = createSmartGenerator({1866 policy: sitePolicy,1867 initialPassword: prePassword || undefined,1868 onChange: (pw) => { currentPassword = pw; },1869 });1870 pg.g.appendChild(smartGen.root);1871 body.appendChild(pg.g);18721873 1874 const saveBtn = document.createElement("button"); saveBtn.className = "save-btn"; saveBtn.type = "button";1875 saveBtn.textContent = "Save entry";1876 const errEl = document.createElement("div"); errEl.className = "locked-error"; errEl.style.display = "none";1877 function showFormError(msg: string) { errEl.textContent = msg; errEl.style.display = ""; }1878 saveBtn.addEventListener("click", async () => {1879 const title = tg.inp.value.trim();1880 const pw = currentPassword.trim();1881 const username = xg.inp.value.trim();1882 const email = eg.inp.value.trim();1883 if (!title) {1884 tg.inp.style.borderColor = "rgba(220,70,60,0.5)"; tg.inp.focus();1885 showFormError("Entry needs a title");1886 return;1887 }1888 if (!pw) {1889 showFormError("Entry needs a password — tap regen to make one");1890 return;1891 }1892 errEl.style.display = "none";1893 saveBtn.disabled = true; saveBtn.textContent = "Saving…";1894 try {1895 const res = await chrome.runtime.sendMessage({1896 type: "ADD_ENTRY",1897 payload: { title, url: ug.inp.value.trim(), username, email: email || undefined, password: pw, type: "login" },1898 });1899 if ((res as { ok?: boolean }).ok) {1900 1901 1902 options.onFillFields?.(username || email, pw);1903 showSuccess(title);1904 } else {1905 const errMsg = (res as { error?: string }).error === "vault locked"1906 ? "Vault locked — open Peach to save"1907 : "Could not save entry";1908 showFormError(errMsg);1909 saveBtn.disabled = false; saveBtn.textContent = "Save entry";1910 }1911 } catch { showFormError("Could not reach Peach"); saveBtn.disabled = false; saveBtn.textContent = "Save entry"; }1912 });1913 body.appendChild(saveBtn);1914 body.appendChild(errEl);19151916 wrap.append(head, body);1917 container.appendChild(wrap);1918 requestAnimationFrame(() => { tg.inp.focus(); tg.inp.select(); });1919 }19201921 function showSuccess(title: string) {1922 currentMode = "success";1923 container.innerHTML = "";1924 const wrap = document.createElement("div"); wrap.className = "success-wrap";1925 const ring = document.createElement("div"); ring.className = "success-ring";1926 ring.innerHTML = checkSvgStr();1927 const t = document.createElement("div"); t.className = "success-text"; t.textContent = `${title} saved`;1928 const s = document.createElement("div"); s.className = "success-sub"; s.textContent = sOrigin;1929 wrap.append(ring, t, s);1930 container.appendChild(wrap);1931 setTimeout(() => dismiss(), 1600);1932 }19331934 function flashActionBtn(btn: HTMLButtonElement) {1935 btn.classList.add("flashed");1936 setTimeout(() => btn.classList.remove("flashed"), 700);1937 }19381939 function renderSilverPlatter(entry: SelectorEntry) {1940 container.innerHTML = "";1941 searchInput = null;1942 focusedIndex = -1;1943 currentMode = "silver-platter";19441945 const domHdr = document.createElement("div");1946 domHdr.className = "domain-header";1947 const headText = document.createElement("div");1948 headText.className = "domain-header-text";1949 const eyebrow = document.createElement("div");1950 eyebrow.className = "domain-eyebrow";1951 eyebrow.textContent = "Saved for this site";1952 const domName = document.createElement("div");1953 domName.className = "domain-name";1954 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");1955 headText.append(eyebrow, domName);1956 domHdr.appendChild(headText);1957 if (!options.isSignup) {1958 const addBtn = document.createElement("button");1959 addBtn.className = "domain-add-btn";1960 addBtn.type = "button";1961 addBtn.setAttribute("aria-label", "Create new entry");1962 addBtn.title = "Create new entry";1963 addBtn.textContent = "+";1964 addBtn.addEventListener("click", (e) => { e.stopPropagation(); void showCreateForm(); });1965 domHdr.appendChild(addBtn);1966 }1967 container.appendChild(domHdr);19681969 const platter = document.createElement("div");1970 platter.className = "silver-platter";19711972 const titleEl = document.createElement("div");1973 titleEl.className = "sp-title";1974 titleEl.textContent = entry.title;1975 platter.appendChild(titleEl);19761977 if (entry.email) {1978 const emailEl = document.createElement("div");1979 emailEl.className = "sp-identity-row";1980 const emailLbl = document.createElement("span");1981 emailLbl.className = "sp-identity-label";1982 emailLbl.textContent = "email";1983 const emailVal = document.createElement("span");1984 emailVal.className = "sp-username";1985 emailVal.textContent = entry.email;1986 emailEl.append(emailLbl, emailVal);1987 platter.appendChild(emailEl);1988 }19891990 if (entry.username) {1991 const userEl = document.createElement("div");1992 userEl.className = "sp-identity-row";1993 const userLbl = document.createElement("span");1994 userLbl.className = "sp-identity-label";1995 userLbl.textContent = entry.username.includes("@") ? "email" : "username";1996 const userVal = document.createElement("span");1997 userVal.className = "sp-username";1998 userVal.textContent = entry.username;1999 userEl.append(userLbl, userVal);2000 platter.appendChild(userEl);2001 }20022003 const fillBtn = document.createElement("button");2004 fillBtn.className = "sp-fill-btn";2005 fillBtn.type = "button";2006 fillBtn.textContent = "Fill credentials";2007 fillBtn.addEventListener("click", () => {2008 if (fillBtn.disabled) return;2009 fillBtn.disabled = true;2010 fillBtn.classList.add("filled");2011 fillBtn.innerHTML = checkSvgStr();2012 2013 2014 2015 2016 onSelect(entry.id);2017 setTimeout(() => dismiss(), 400);2018 });2019 platter.appendChild(fillBtn);20202021 const actions = document.createElement("div");2022 actions.className = "sp-actions";20232024 if (entry.email) {2025 const copyEmail = document.createElement("button");2026 copyEmail.className = "sp-action-btn";2027 copyEmail.type = "button";2028 copyEmail.title = "Copy email";2029 copyEmail.textContent = "Copy email";2030 copyEmail.addEventListener("click", async (e) => {2031 e.stopPropagation();2032 let alreadyWritten = false;2033 try { await navigator.clipboard.writeText(entry.email!); alreadyWritten = true; } catch {}2034 await chrome.runtime.sendMessage({2035 type: "COPY",2036 payload: { text: entry.email, label: "Email", alreadyWritten },2037 }).catch(() => {});2038 flashActionBtn(copyEmail);2039 });2040 actions.appendChild(copyEmail);2041 }20422043 const copyU = document.createElement("button");2044 copyU.className = "sp-action-btn";2045 copyU.type = "button";2046 const copyULabel = entry.username?.includes("@") ? "Copy email" : "Copy username";2047 copyU.title = copyULabel;2048 copyU.textContent = copyULabel;2049 copyU.disabled = !entry.username;2050 copyU.addEventListener("click", async (e) => {2051 e.stopPropagation();2052 if (!entry.username) return;2053 let alreadyWritten = false;2054 try { await navigator.clipboard.writeText(entry.username); alreadyWritten = true; } catch {}2055 await chrome.runtime.sendMessage({2056 type: "COPY",2057 payload: { text: entry.username, label: entry.username.includes("@") ? "Email" : "Username", alreadyWritten },2058 }).catch(() => {});2059 flashActionBtn(copyU);2060 });2061 actions.appendChild(copyU);20622063 const copyP = document.createElement("button");2064 copyP.className = "sp-action-btn";2065 copyP.type = "button";2066 copyP.title = "Copy password";2067 copyP.textContent = "Copy password";2068 copyP.addEventListener("click", async (e) => {2069 e.stopPropagation();2070 const resp = await chrome.runtime.sendMessage({2071 type: "GET_ENTRY_FOR_FILL",2072 payload: { id: entry.id },2073 }).catch(() => null) as { ok: boolean; data?: { password?: string } } | null;2074 if (!resp?.ok || !resp.data?.password) return;2075 let alreadyWritten = false;2076 try { await navigator.clipboard.writeText(resp.data.password); alreadyWritten = true; } catch {}2077 await chrome.runtime.sendMessage({2078 type: "COPY",2079 payload: { text: resp.data.password, label: "Password", alreadyWritten },2080 }).catch(() => {});2081 flashActionBtn(copyP);2082 });2083 actions.appendChild(copyP);20842085 let trayEl: HTMLDivElement | null = null;2086 let trayInterval: ReturnType<typeof setInterval> | null = null;20872088 function closeTray() {2089 if (trayInterval) { clearInterval(trayInterval); trayInterval = null; }2090 trayEl?.remove();2091 trayEl = null;2092 }2093 2094 2095 cleanupHooks.push(closeTray);20962097 async function openTOTPTray() {2098 2099 2100 2101 const resp = await chrome.runtime.sendMessage({2102 type: "GET_ENTRY_FOR_FILL",2103 payload: { id: entry.id },2104 }).catch(() => null) as { ok: boolean; data?: { totp?: string } } | null;2105 const secret = resp?.ok ? resp.data?.totp : undefined;2106 if (!secret) return;21072108 trayEl = document.createElement("div");2109 trayEl.className = "sp-tray";21102111 const label = document.createElement("span");2112 label.className = "sp-tray-label";2113 label.textContent = "2FA";2114 trayEl.appendChild(label);21152116 const codeEl = document.createElement("div");2117 codeEl.className = "sp-totp-code";2118 trayEl.appendChild(codeEl);21192120 const ringNs = "http://www.w3.org/2000/svg";2121 const ring = document.createElementNS(ringNs, "svg");2122 ring.setAttribute("class", "sp-totp-ring");2123 ring.setAttribute("viewBox", "0 0 24 24");2124 const trackC = document.createElementNS(ringNs, "circle");2125 trackC.setAttribute("class", "ring-track");2126 trackC.setAttribute("cx", "12"); trackC.setAttribute("cy", "12"); trackC.setAttribute("r", "10");2127 trackC.setAttribute("fill", "none"); trackC.setAttribute("stroke-width", "2");2128 const fillC = document.createElementNS(ringNs, "circle");2129 fillC.setAttribute("class", "ring-fill");2130 fillC.setAttribute("cx", "12"); fillC.setAttribute("cy", "12"); fillC.setAttribute("r", "10");2131 fillC.setAttribute("fill", "none"); fillC.setAttribute("stroke-width", "2");2132 fillC.setAttribute("stroke-linecap", "round");2133 fillC.setAttribute("stroke-dasharray", "62.83");2134 ring.append(trackC, fillC);2135 trayEl.appendChild(ring);21362137 const copyBtn = document.createElement("button");2138 copyBtn.className = "sp-totp-copy";2139 copyBtn.type = "button";2140 copyBtn.textContent = "Copy";2141 trayEl.appendChild(copyBtn);21422143 function refresh() {2144 const { code, remaining } = generateTOTP(secret!);2145 2146 codeEl.textContent = code.length === 62147 ? `${code.slice(0, 3)} ${code.slice(3)}`2148 : code;2149 2150 2151 const fraction = (30 - remaining) / 30;2152 fillC.setAttribute("stroke-dashoffset", String(62.83 * fraction));2153 }2154 refresh();2155 trayInterval = setInterval(refresh, 1000);21562157 copyBtn.addEventListener("click", async (e) => {2158 e.stopPropagation();2159 const { code } = generateTOTP(secret!);2160 let alreadyWritten = false;2161 try { await navigator.clipboard.writeText(code); alreadyWritten = true; } catch {}2162 await chrome.runtime.sendMessage({2163 type: "COPY",2164 payload: { text: code, label: "TOTP", alreadyWritten },2165 }).catch(() => {});2166 copyBtn.textContent = "Copied";2167 setTimeout(() => { if (copyBtn.isConnected) copyBtn.textContent = "Copy"; }, 1200);2168 });21692170 platter.appendChild(trayEl);2171 }21722173 const editBtn = document.createElement("button");2174 editBtn.className = "sp-action-btn sp-action-edit";2175 editBtn.type = "button";2176 editBtn.title = "Edit entry";2177 editBtn.textContent = "Edit";2178 editBtn.addEventListener("click", (e) => {2179 e.stopPropagation();2180 closeTray();2181 void renderInlineEdit(entry);2182 });2183 actions.appendChild(editBtn);21842185 2186 2187 2188 if (entry.hasTotp) void openTOTPTray();21892190 platter.appendChild(actions);2191 container.appendChild(platter);2192 }21932194 219521962197219821992200 async function renderInlineEdit(summary: SelectorEntry) {2201 container.innerHTML = "";2202 const wrap = document.createElement("div");2203 wrap.className = "create-form-wrap";22042205 const head = document.createElement("div");2206 head.className = "create-head";2207 const back = document.createElement("button");2208 back.className = "back-btn";2209 back.type = "button";2210 back.title = "Cancel";2211 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>`;2212 back.addEventListener("click", () => renderSilverPlatter(summary));2213 head.appendChild(back);2214 const headLbl = document.createElement("div");2215 headLbl.className = "create-label";2216 headLbl.textContent = "Edit entry";2217 head.appendChild(headLbl);2218 wrap.appendChild(head);22192220 const body = document.createElement("div");2221 body.className = "create-body";22222223 2224 const loading = document.createElement("div");2225 loading.className = "empty-hint";2226 loading.textContent = "loading…";2227 body.appendChild(loading);2228 wrap.appendChild(body);2229 container.appendChild(wrap);22302231 const [res, idRes] = await Promise.all([2232 chrome.runtime.sendMessage({2233 type: "GET_ENTRY_FOR_FILL",2234 payload: { id: summary.id },2235 }).catch(() => null),2236 chrome.runtime.sendMessage({ type: "GET_IDENTITIES" }).catch(() => null),2237 ]);2238 const entryRes = res as { ok: boolean; data?: { title?: string; username?: string; email?: string; password?: string; url?: string; totp?: string; notes?: string } } | null;2239 const editIdentities: SavedIdentity[] = (idRes as { ok?: boolean; data?: SavedIdentity[] } | null)?.data ?? [];22402241 if (!entryRes || !entryRes.ok || !entryRes.data) {2242 loading.textContent = "couldn't load this entry. try again from the popup.";2243 return;2244 }2245 body.innerHTML = "";22462247 function field(label: string, value: string, type: "text" | "password" = "text"): { g: HTMLDivElement; inp: HTMLInputElement } {2248 const group = document.createElement("div");2249 group.className = "f-group";2250 const lbl = document.createElement("div");2251 lbl.className = "f-label";2252 lbl.textContent = label;2253 const input = document.createElement("input");2254 input.className = "f-input";2255 input.type = type;2256 input.value = value;2257 input.autocomplete = "off";2258 group.append(lbl, input);2259 body.appendChild(group);2260 return { g: group, inp: input };2261 }22622263 const titleInput = field("title", entryRes.data.title ?? "").inp;2264 const urlInput = field("url", entryRes.data.url ?? "").inp;2265 urlInput.classList.add("url-f");2266 const usernameLabel = (entryRes.data.username ?? "").includes("@") ? "email" : "username";2267 const { g: usernameGroup, inp: usernameInput } = field(usernameLabel, entryRes.data.username ?? "");2268 if (editIdentities.length) attachIdentitySuggestions(usernameGroup, usernameInput, editIdentities, "username");2269 const { g: emailGroup, inp: emailInput } = field("email", entryRes.data.email ?? "");2270 if (editIdentities.length) attachIdentitySuggestions(emailGroup, emailInput, editIdentities, "email");22712272 2273 const pwGroup = document.createElement("div");2274 pwGroup.className = "f-group";2275 const pwLbl = document.createElement("div");2276 pwLbl.className = "f-label";2277 pwLbl.textContent = "password";2278 const pwRow = document.createElement("div");2279 pwRow.className = "f-row";2280 const pwInput = document.createElement("input");2281 pwInput.className = "f-input";2282 pwInput.type = "password";2283 pwInput.value = entryRes.data.password ?? "";2284 pwInput.autocomplete = "new-password";2285 const revealBtn = document.createElement("button");2286 revealBtn.className = "gen-btn";2287 revealBtn.type = "button";2288 revealBtn.textContent = "show";2289 revealBtn.addEventListener("click", () => {2290 const reveal = pwInput.type === "password";2291 pwInput.type = reveal ? "text" : "password";2292 revealBtn.textContent = reveal ? "hide" : "show";2293 });2294 pwRow.append(pwInput, revealBtn);2295 const editSmartGen = createSmartGenerator({ onChange: (pw) => { pwInput.value = pw; } });2296 editSmartGen.root.style.display = "none";2297 let editGenVisible = false;2298 const genToggleBtn = document.createElement("button");2299 genToggleBtn.className = "gen-toggle-link";2300 genToggleBtn.type = "button";2301 genToggleBtn.textContent = "⚙ generate";2302 genToggleBtn.addEventListener("click", () => {2303 editGenVisible = !editGenVisible;2304 pwRow.style.display = editGenVisible ? "none" : "";2305 editSmartGen.root.style.display = editGenVisible ? "" : "none";2306 genToggleBtn.textContent = editGenVisible ? "☰ hide generator" : "⚙ generate";2307 });2308 pwGroup.append(pwLbl, pwRow, genToggleBtn, editSmartGen.root);2309 body.appendChild(pwGroup);23102311 const totpInput = field("2fa secret", entryRes.data.totp ?? "").inp;23122313 2314 const notesGroup = document.createElement("div");2315 notesGroup.className = "f-group";2316 const notesLbl = document.createElement("div");2317 notesLbl.className = "f-label";2318 notesLbl.textContent = "notes";2319 const notesInput = document.createElement("textarea");2320 notesInput.className = "f-input";2321 notesInput.rows = 3;2322 notesInput.value = entryRes.data.notes ?? "";2323 notesInput.style.fontFamily = "Inter, sans-serif";2324 notesInput.style.resize = "vertical";2325 notesGroup.append(notesLbl, notesInput);2326 body.appendChild(notesGroup);23272328 2329 const actionsRow = document.createElement("div");2330 actionsRow.className = "f-row";2331 const saveBtn = document.createElement("button");2332 saveBtn.className = "save-btn";2333 saveBtn.type = "button";2334 saveBtn.textContent = "Save changes";2335 saveBtn.style.flex = "1";2336 const cancelBtn = document.createElement("button");2337 cancelBtn.className = "gen-btn";2338 cancelBtn.type = "button";2339 cancelBtn.textContent = "cancel";2340 cancelBtn.addEventListener("click", () => renderSilverPlatter(summary));2341 actionsRow.append(saveBtn, cancelBtn);2342 body.appendChild(actionsRow);23432344 saveBtn.addEventListener("click", async () => {2345 saveBtn.disabled = true;2346 const originalLabel = saveBtn.textContent;2347 saveBtn.textContent = "Saving…";2348 const patch: Record<string, unknown> = {2349 title: titleInput.value.trim(),2350 url: urlInput.value.trim(),2351 username: usernameInput.value.trim(),2352 email: emailInput.value.trim() || undefined,2353 password: pwInput.value,2354 totp: totpInput.value.trim(),2355 notes: notesInput.value,2356 };2357 const updateRes = (await chrome.runtime.sendMessage({2358 type: "UPDATE_ENTRY",2359 payload: { id: summary.id, patch },2360 }).catch(() => null)) as { ok: boolean; error?: string } | null;2361 if (!updateRes?.ok) {2362 saveBtn.disabled = false;2363 saveBtn.textContent = originalLabel;2364 const err = document.createElement("div");2365 err.className = "empty-hint";2366 err.style.color = "color-mix(in srgb, #e55 70%, transparent)";2367 err.textContent = updateRes?.error ?? "Couldn't save. Try the popup.";2368 body.appendChild(err);2369 setTimeout(() => err.remove(), 3000);2370 return;2371 }2372 2373 const refreshed: SelectorEntry = {2374 id: summary.id,2375 title: patch.title as string,2376 username: patch.username as string,2377 email: patch.email as string | undefined,2378 url: patch.url as string,2379 hasTotp: Boolean(patch.totp),2380 hasPasskey: summary.hasPasskey,2381 };2382 renderSilverPlatter(refreshed);2383 });23842385 queueMicrotask(() => titleInput.focus());2386 }23872388 function renderLocked() {2389 container.innerHTML = "";23902391 2392 const domHdr = document.createElement("div");2393 domHdr.className = "domain-header";2394 const eyebrow = document.createElement("div");2395 eyebrow.className = "domain-eyebrow";2396 eyebrow.textContent = "vault locked";2397 const domName = document.createElement("div");2398 domName.className = "domain-name";2399 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");2400 domHdr.append(eyebrow, domName);2401 container.appendChild(domHdr);24022403 const wrap = document.createElement("div");2404 wrap.className = "locked-wrap";24052406 2407 const head = document.createElement("div"); head.className = "locked-head";2408 const icon = document.createElement("div"); icon.className = "locked-icon";2409 icon.innerHTML = keySvgStr();2410 const title = document.createElement("div"); title.className = "locked-title";2411 title.textContent = "unlock to autofill";2412 head.append(icon, title);24132414 2415 const pwInp = document.createElement("input");2416 pwInp.className = "locked-input";2417 pwInp.type = "password";2418 pwInp.placeholder = "master password";2419 pwInp.setAttribute("autocomplete", "current-password");24202421 2422 const errEl = document.createElement("div");2423 errEl.className = "locked-error";2424 errEl.style.display = "none";24252426 2427 const unlockBtn = document.createElement("button");2428 unlockBtn.className = "locked-btn";2429 unlockBtn.type = "button";2430 unlockBtn.textContent = "unlock";24312432 async function tryUnlock() {2433 const pw = pwInp.value.trim();2434 if (!pw) { pwInp.focus(); return; }2435 unlockBtn.disabled = true;2436 unlockBtn.textContent = "unlocking…";2437 errEl.style.display = "none";2438 try {2439 const res = await chrome.runtime.sendMessage({2440 type: "UNLOCK",2441 payload: { password: pw },2442 });2443 if ((res as { ok?: boolean }).ok) {2444 dismiss();2445 options.onUnlocked?.();2446 } else {2447 errEl.textContent = "incorrect password";2448 errEl.style.display = "block";2449 pwInp.value = "";2450 pwInp.focus();2451 unlockBtn.disabled = false;2452 unlockBtn.textContent = "unlock";2453 }2454 } catch {2455 errEl.textContent = "could not reach Peach";2456 errEl.style.display = "block";2457 unlockBtn.disabled = false;2458 unlockBtn.textContent = "unlock";2459 }2460 }24612462 pwInp.addEventListener("keydown", (e) => {2463 e.stopPropagation();2464 if (e.key === "Enter") void tryUnlock();2465 });2466 pwInp.addEventListener("keyup", (e) => e.stopPropagation());2467 pwInp.addEventListener("keypress", (e) => e.stopPropagation());2468 unlockBtn.addEventListener("click", () => void tryUnlock());24692470 wrap.append(head, pwInp, errEl, unlockBtn);2471 container.appendChild(wrap);24722473 2474 2475 2476 2477 2478 2479 const captureKeydown = (e: KeyboardEvent) => {2480 if (!host.isConnected) {2481 document.removeEventListener("keydown", captureKeydown, true);2482 return;2483 }2484 2485 if (e.ctrlKey || e.metaKey || e.altKey || e.key === "Tab") return;2486 2487 e.stopImmediatePropagation();2488 if (e.key === "Escape") { dismiss(true); return; }2489 if (e.key === "Enter") { void tryUnlock(); return; }2490 2491 2492 if (document.activeElement !== host) {2493 pwInp.focus({ preventScroll: true });2494 }2495 };2496 captureKeydownRef = captureKeydown;2497 document.addEventListener("keydown", captureKeydown, true);24982499 2500 2501 pwInp.focus({ preventScroll: true });2502 requestAnimationFrame(() => { if (host.isConnected) pwInp.focus({ preventScroll: true }); });2503 }25042505 function handleKeyDown(e: KeyboardEvent) {2506 if (options.locked) {2507 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2508 return;2509 }2510 if (currentMode === "create" || currentMode === "success" || currentMode === "silver-platter") {2511 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }2512 return;2513 }2514 const allEntryEls = container.querySelectorAll(".entry:not(.empty-state)");2515 const count = allEntryEls.length;2516 if (document.activeElement === searchInput) {2517 if (e.key === "Escape" || e.key === "Tab") { e.preventDefault(); dismiss(true); return; }2518 if (count === 0) return;2519 if (!["ArrowDown", "ArrowUp", "Enter"].includes(e.key)) return;2520 }2521 if (count === 0) return;2522 switch (e.key) {2523 case "ArrowDown": e.preventDefault(); setFocused(focusedIndex < count - 1 ? focusedIndex + 1 : 0); break;2524 case "ArrowUp": e.preventDefault(); setFocused(focusedIndex > 0 ? focusedIndex - 1 : count - 1); break;2525 case "Enter": {2526 if (focusedIndex >= 0) {2527 const el = allEntryEls[focusedIndex] as HTMLElement;2528 const id = el.dataset.id;2529 if (id) { onSelect(id); dismiss(); }2530 else if (el.classList.contains("is-new") || !id) {2531 2532 showCreateForm();2533 }2534 }2535 break;2536 }2537 case "Escape": case "Tab": e.preventDefault(); dismiss(true); break;2538 }2539 }25402541 document.addEventListener("keydown", handleKeyDown);25422543 document.body.appendChild(host);25442545 function updatePosition() {2546 const r = anchorEl.getBoundingClientRect();2547 host.style.top = `${r.bottom + window.scrollY + 5}px`;2548 host.style.left = `${r.left + window.scrollX}px`;2549 }2550 2551 2552 2553 2554 2555 2556 2557 let captureKeydownRef: ((e: KeyboardEvent) => void) | null = null;2558 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);25592560 if (options.locked) {2561 renderLocked();2562 } else if (options.isSignup && options.savedIdentities) {2563 2564 2565 renderIdentityHelper();2566 } else if (entries.length === 1 && !options.isSignup) {2567 2568 2569 renderSilverPlatter(entries[0]!);2570 } else {2571 renderList();2572 }25732574 let exitScheduled = false;2575 function dismiss(userAction = false) {2576 2577 2578 2579 if (exitScheduled) return;2580 exitScheduled = true;2581 2582 2583 2584 stopObserving();2585 document.removeEventListener("click", outsideClick, { capture: true });2586 document.removeEventListener("keydown", handleKeyDown);2587 if (captureKeydownRef) {2588 document.removeEventListener("keydown", captureKeydownRef, true);2589 captureKeydownRef = null;2590 }2591 for (const cleanup of cleanupHooks) {2592 try { cleanup(); } catch { }2593 }2594 if (userAction) options.onDismiss?.();2595 container.classList.add("is-exiting");2596 setTimeout(() => host.remove(), 130);2597 }25982599 function outsideClick(ev: MouseEvent) {2600 const path = ev.composedPath();2601 2602 2603 2604 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);2605 }2606 2607 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);26082609 return dismiss;2610}26112612export interface CardSelectorEntry {2613 id: string;2614 title: string;2615 cardholderName?: string;2616 last4?: string;2617 expMonth?: string;2618 expYear?: string;2619 network?: import("../shared/types").CardNetwork;2620}26212622interface CardSelectorOptions {2623 domain?: string;2624 2625 onFill: (entry: import("../shared/types").VaultEntry) => void;2626 2627 onDismiss?: () => void;2628}26292630263126322633263426352636export function showPasskeyProGate(): void {2637 const domain = location.hostname.replace(/^www\./, "");26382639 const host = document.createElement("div");2640 host.setAttribute("data-peach-passkey-gate", "1");2641 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483646;pointer-events:none;";2642 const shadow = host.attachShadow({ mode: "closed" });26432644 const style = document.createElement("style");2645 style.textContent = `2646 :host { all: initial; }2647 .gate-wrap {2648 position: fixed;2649 top: 50%;2650 left: 50%;2651 transform: translate(-50%, -50%);2652 width: 280px;2653 pointer-events: auto;2654 animation: g-in 220ms cubic-bezier(0.16,1,0.3,1) both;2655 }2656 @keyframes g-in {2657 from { opacity:0; transform: translate(-50%,-52%); }2658 to { opacity:1; transform: translate(-50%,-50%); }2659 }2660 .gate-wrap.is-exiting {2661 animation: g-out 130ms ease-in forwards;2662 }2663 @keyframes g-out {2664 to { opacity:0; transform: translate(-50%,-52%); }2665 }2666 .gate {2667 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2668 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2669 border-radius: 12px;2670 box-shadow: 0 12px 48px rgba(0,0,0,0.75);2671 padding: 16px;2672 font-family: Inter, sans-serif;2673 }2674 .gate-header {2675 display: flex;2676 align-items: center;2677 gap: 7px;2678 margin-bottom: 12px;2679 padding-bottom: 10px;2680 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2681 }2682 .gate-domain {2683 font-size: 12px;2684 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2685 font-family: "IBM Plex Mono", monospace;2686 overflow: hidden;2687 text-overflow: ellipsis;2688 white-space: nowrap;2689 }2690 .gate-title {2691 font-size: 14px;2692 font-weight: 500;2693 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2694 margin-bottom: 6px;2695 }2696 .gate-subtitle {2697 font-size: 12px;2698 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.45)"};2699 line-height: 1.5;2700 margin-bottom: 14px;2701 }2702 .gate-btn {2703 display: block;2704 width: 100%;2705 padding: 9px 0;2706 border-radius: 8px;2707 border: none;2708 cursor: pointer;2709 font-size: 13px;2710 font-family: Inter, sans-serif;2711 font-weight: 500;2712 transition: opacity 100ms;2713 margin-bottom: 7px;2714 text-align: center;2715 }2716 .gate-btn:last-child { margin-bottom: 0; }2717 .gate-btn--accent {2718 background: ${accentHex};2719 color: #fff;2720 }2721 .gate-btn--accent:hover { opacity: 0.88; }2722 .gate-btn--ghost {2723 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2724 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.45)"};2725 }2726 .gate-btn--ghost:hover { opacity: 0.75; }2727 .backdrop {2728 position: fixed;2729 inset: 0;2730 pointer-events: auto;2731 }2732 `;2733 shadow.appendChild(style);27342735 const backdrop = document.createElement("div");2736 backdrop.className = "backdrop";2737 shadow.appendChild(backdrop);27382739 const wrap = document.createElement("div");2740 wrap.className = "gate-wrap";2741 shadow.appendChild(wrap);27422743 const gate = document.createElement("div");2744 gate.className = "gate";2745 wrap.appendChild(gate);27462747 2748 const header = document.createElement("div");2749 header.className = "gate-header";2750 const icon = document.createElement("span");2751 icon.innerHTML = peachIconSvg();2752 const domainEl = document.createElement("span");2753 domainEl.className = "gate-domain";2754 domainEl.textContent = domain;2755 header.append(icon, domainEl);2756 gate.appendChild(header);27572758 const title = document.createElement("div");2759 title.className = "gate-title";2760 title.textContent = "Passkeys are part of Peach Pro.";2761 gate.appendChild(title);27622763 const subtitle = document.createElement("div");2764 subtitle.className = "gate-subtitle";2765 subtitle.textContent = "Store and use passkeys across all your devices, securely.";2766 gate.appendChild(subtitle);27672768 const upgradeBtn = document.createElement("button");2769 upgradeBtn.className = "gate-btn gate-btn--accent";2770 upgradeBtn.type = "button";2771 upgradeBtn.textContent = "Upgrade to Pro";2772 gate.appendChild(upgradeBtn);27732774 const laterBtn = document.createElement("button");2775 laterBtn.className = "gate-btn gate-btn--ghost";2776 laterBtn.type = "button";2777 laterBtn.textContent = "Not right now";2778 gate.appendChild(laterBtn);27792780 function dismiss() {2781 wrap.classList.add("is-exiting");2782 setTimeout(() => host.remove(), 130);2783 }27842785 upgradeBtn.addEventListener("click", () => {2786 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: { feature: "passkeys" } }).catch(() => {});2787 dismiss();2788 });2789 laterBtn.addEventListener("click", dismiss);2790 backdrop.addEventListener("click", dismiss);27912792 document.addEventListener("keydown", function onEsc(e: KeyboardEvent) {2793 if (e.key === "Escape") { dismiss(); document.removeEventListener("keydown", onEsc); }2794 });27952796 document.body.appendChild(host);2797}279827992800280128022803280428052806export function showPasskeyRegistrationOffer(args: {2807 rpId: string;2808 rpName?: string;2809 userName?: string;2810 userDisplayName?: string;2811}): void {2812 const domain = location.hostname.replace(/^www\./, "");2813 const displayName = args.rpName || domain;28142815 const host = document.createElement("div");2816 host.setAttribute("data-peach-passkey-offer", "1");2817 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483645;pointer-events:none;";2818 const shadow = host.attachShadow({ mode: "closed" });28192820 const style = document.createElement("style");2821 style.textContent = `2822 :host { all: initial; }2823 .offer-wrap {2824 position: fixed;2825 top: 16px;2826 right: 16px;2827 width: 320px;2828 pointer-events: auto;2829 animation: o-in 220ms cubic-bezier(0.16,1,0.3,1) both;2830 }2831 @keyframes o-in {2832 from { opacity: 0; transform: translateY(-6px); }2833 to { opacity: 1; transform: translateY(0); }2834 }2835 .offer-wrap.is-exiting { animation: o-out 130ms ease-in forwards; }2836 @keyframes o-out { to { opacity: 0; transform: translateY(-6px); } }2837 .offer {2838 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};2839 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};2840 border-radius: 12px;2841 box-shadow: 0 12px 48px rgba(0,0,0,0.55);2842 padding: 14px 14px 12px;2843 font-family: Inter, sans-serif;2844 position: relative;2845 }2846 .offer-close {2847 position: absolute;2848 top: 8px;2849 right: 8px;2850 width: 18px;2851 height: 18px;2852 border: none;2853 background: transparent;2854 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};2855 cursor: pointer;2856 font-size: 14px;2857 line-height: 1;2858 padding: 0;2859 }2860 .offer-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }2861 .offer-header {2862 display: flex;2863 align-items: center;2864 gap: 7px;2865 margin-bottom: 8px;2866 padding-bottom: 8px;2867 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};2868 }2869 .offer-domain {2870 font-size: 12px;2871 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};2872 font-family: "IBM Plex Mono", monospace;2873 overflow: hidden;2874 text-overflow: ellipsis;2875 white-space: nowrap;2876 }2877 .offer-title {2878 font-size: 13px;2879 font-weight: 500;2880 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};2881 margin-bottom: 4px;2882 }2883 .offer-subtitle {2884 font-size: 11px;2885 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};2886 line-height: 1.45;2887 margin-bottom: 12px;2888 }2889 .offer-btn {2890 display: block;2891 width: 100%;2892 padding: 8px 0;2893 border-radius: 7px;2894 border: none;2895 cursor: pointer;2896 font-size: 12px;2897 font-family: Inter, sans-serif;2898 font-weight: 500;2899 transition: opacity 100ms;2900 margin-bottom: 6px;2901 text-align: center;2902 }2903 .offer-btn:last-child { margin-bottom: 0; }2904 .offer-btn--accent { background: ${accentHex}; color: #fff; }2905 .offer-btn--accent:hover { opacity: 0.88; }2906 .offer-btn--ghost {2907 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};2908 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};2909 }2910 .offer-btn--ghost:hover { opacity: 0.75; }2911 `;2912 shadow.appendChild(style);29132914 const wrap = document.createElement("div");2915 wrap.className = "offer-wrap";2916 shadow.appendChild(wrap);29172918 const offer = document.createElement("div");2919 offer.className = "offer";2920 wrap.appendChild(offer);29212922 const closeBtn = document.createElement("button");2923 closeBtn.className = "offer-close";2924 closeBtn.type = "button";2925 closeBtn.setAttribute("aria-label", "Dismiss");2926 closeBtn.textContent = "✕";2927 offer.appendChild(closeBtn);29282929 const header = document.createElement("div");2930 header.className = "offer-header";2931 const icon = document.createElement("span");2932 icon.innerHTML = peachIconSvg();2933 const domainEl = document.createElement("span");2934 domainEl.className = "offer-domain";2935 domainEl.textContent = domain;2936 header.append(icon, domainEl);2937 offer.appendChild(header);29382939 const title = document.createElement("div");2940 title.className = "offer-title";2941 title.textContent = "This site supports passkeys.";2942 offer.appendChild(title);29432944 const subtitle = document.createElement("div");2945 subtitle.className = "offer-subtitle";2946 subtitle.textContent = "Save one to Peach for faster, passwordless sign-in.";2947 offer.appendChild(subtitle);29482949 const saveBtn = document.createElement("button");2950 saveBtn.className = "offer-btn offer-btn--accent";2951 saveBtn.type = "button";2952 saveBtn.textContent = "Save passkey to Peach";2953 offer.appendChild(saveBtn);29542955 const laterBtn = document.createElement("button");2956 laterBtn.className = "offer-btn offer-btn--ghost";2957 laterBtn.type = "button";2958 laterBtn.textContent = "Not now";2959 offer.appendChild(laterBtn);29602961 function dismiss(decline: boolean) {2962 if (decline) {2963 chrome.runtime.sendMessage({2964 type: "PASSKEY_OFFER_DECLINE",2965 payload: { domain },2966 }).catch(() => {});2967 }2968 wrap.classList.add("is-exiting");2969 setTimeout(() => host.remove(), 130);2970 }29712972 saveBtn.addEventListener("click", () => {2973 chrome.runtime.sendMessage({2974 type: "INITIATE_FIREFOX_PASSKEY_CREATE",2975 payload: {2976 rpId: args.rpId,2977 rpName: args.rpName ?? displayName,2978 userName: args.userName ?? "user",2979 userDisplayName: args.userDisplayName,2980 },2981 }).catch(() => {});2982 dismiss(false);2983 });2984 laterBtn.addEventListener("click", () => dismiss(true));2985 closeBtn.addEventListener("click", () => dismiss(true));29862987 document.body.appendChild(host);2988}2989299029912992299329942995299629972998export function showPasskeyAvailable(args: {2999 rpId: string;3000 userName: string;3001 fromBrowser?: "chrome" | "firefox";3002 currentBrowser?: "chrome" | "firefox" | "unknown";3003}): void {3004 const domain = location.hostname.replace(/^www\./, "");3005 const crossBrowser =3006 args.fromBrowser &&3007 args.currentBrowser &&3008 args.currentBrowser !== "unknown" &&3009 args.fromBrowser !== args.currentBrowser;30103011 const host = document.createElement("div");3012 host.setAttribute("data-peach-passkey-available", "1");3013 host.style.cssText = "all:initial;position:fixed;top:0;left:0;width:100%;height:100%;z-index:2147483644;pointer-events:none;";3014 const shadow = host.attachShadow({ mode: "closed" });30153016 const style = document.createElement("style");3017 style.textContent = `3018 :host { all: initial; }3019 .avail-wrap {3020 position: fixed;3021 top: 16px;3022 right: 16px;3023 width: 320px;3024 pointer-events: auto;3025 animation: a-in 220ms cubic-bezier(0.16,1,0.3,1) both;3026 }3027 @keyframes a-in {3028 from { opacity: 0; transform: translateY(-6px); }3029 to { opacity: 1; transform: translateY(0); }3030 }3031 .avail-wrap.is-exiting { animation: a-out 130ms ease-in forwards; }3032 @keyframes a-out { to { opacity: 0; transform: translateY(-6px); } }3033 .avail {3034 background: ${popupTheme === "light" ? "#f8f5f0" : "#1a1712"};3035 border: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.10)" : "rgba(240,232,216,0.09)"};3036 border-radius: 12px;3037 box-shadow: 0 12px 48px rgba(0,0,0,0.55);3038 padding: 14px 14px 12px;3039 font-family: Inter, sans-serif;3040 position: relative;3041 }3042 .avail-close {3043 position: absolute;3044 top: 8px;3045 right: 8px;3046 width: 18px;3047 height: 18px;3048 border: none;3049 background: transparent;3050 color: ${popupTheme === "light" ? "rgba(0,0,0,0.4)" : "rgba(240,232,216,0.4)"};3051 cursor: pointer;3052 font-size: 14px;3053 line-height: 1;3054 padding: 0;3055 }3056 .avail-close:hover { color: ${popupTheme === "light" ? "rgba(0,0,0,0.7)" : "rgba(240,232,216,0.7)"}; }3057 .avail-header {3058 display: flex;3059 align-items: center;3060 gap: 7px;3061 margin-bottom: 8px;3062 padding-bottom: 8px;3063 border-bottom: 1px solid ${popupTheme === "light" ? "rgba(0,0,0,0.07)" : "rgba(240,232,216,0.07)"};3064 }3065 .avail-domain {3066 font-size: 12px;3067 color: ${popupTheme === "light" ? "rgba(0,0,0,0.45)" : "rgba(240,232,216,0.45)"};3068 font-family: "IBM Plex Mono", monospace;3069 }3070 .avail-label {3071 font-size: 9px;3072 letter-spacing: 0.16em;3073 text-transform: uppercase;3074 color: ${accentHex};3075 margin-bottom: 4px;3076 }3077 .avail-user {3078 font-size: 13px;3079 font-weight: 500;3080 color: ${popupTheme === "light" ? "#1a1712" : "rgba(240,232,216,0.92)"};3081 margin-bottom: 12px;3082 overflow: hidden;3083 text-overflow: ellipsis;3084 white-space: nowrap;3085 }3086 .avail-cross {3087 font-size: 11px;3088 color: ${popupTheme === "light" ? "rgba(0,0,0,0.50)" : "rgba(240,232,216,0.50)"};3089 line-height: 1.45;3090 margin-bottom: 12px;3091 padding: 8px;3092 background: ${popupTheme === "light" ? "rgba(0,0,0,0.04)" : "rgba(240,232,216,0.04)"};3093 border-radius: 6px;3094 }3095 .avail-btn {3096 display: block;3097 width: 100%;3098 padding: 8px 0;3099 border-radius: 7px;3100 border: none;3101 cursor: pointer;3102 font-size: 12px;3103 font-family: Inter, sans-serif;3104 font-weight: 500;3105 transition: opacity 100ms;3106 margin-bottom: 6px;3107 text-align: center;3108 }3109 .avail-btn:last-child { margin-bottom: 0; }3110 .avail-btn--accent { background: ${accentHex}; color: #fff; }3111 .avail-btn--accent:hover { opacity: 0.88; }3112 .avail-btn--ghost {3113 background: ${popupTheme === "light" ? "rgba(0,0,0,0.06)" : "rgba(240,232,216,0.07)"};3114 color: ${popupTheme === "light" ? "rgba(0,0,0,0.55)" : "rgba(240,232,216,0.50)"};3115 }3116 .avail-btn--ghost:hover { opacity: 0.75; }3117 `;3118 shadow.appendChild(style);31193120 const wrap = document.createElement("div");3121 wrap.className = "avail-wrap";3122 shadow.appendChild(wrap);31233124 const avail = document.createElement("div");3125 avail.className = "avail";3126 wrap.appendChild(avail);31273128 const closeBtn = document.createElement("button");3129 closeBtn.className = "avail-close";3130 closeBtn.type = "button";3131 closeBtn.setAttribute("aria-label", "Dismiss");3132 closeBtn.textContent = "✕";3133 avail.appendChild(closeBtn);31343135 const header = document.createElement("div");3136 header.className = "avail-header";3137 const icon = document.createElement("span");3138 icon.innerHTML = peachIconSvg();3139 const domainEl = document.createElement("span");3140 domainEl.className = "avail-domain";3141 domainEl.textContent = domain;3142 header.append(icon, domainEl);3143 avail.appendChild(header);31443145 const label = document.createElement("div");3146 label.className = "avail-label";3147 label.textContent = "PASSKEY";3148 avail.appendChild(label);31493150 const user = document.createElement("div");3151 user.className = "avail-user";3152 user.textContent = args.userName;3153 avail.appendChild(user);31543155 if (crossBrowser) {3156 const cross = document.createElement("div");3157 cross.className = "avail-cross";3158 cross.textContent =3159 args.fromBrowser === "chrome"3160 ? "This passkey was created on Chrome. To use it on Firefox, re-register it on this device."3161 : "This passkey was created on Firefox. To use it on Chrome, re-register it on this device.";3162 avail.appendChild(cross);3163 }31643165 const signInBtn = document.createElement("button");3166 signInBtn.className = "avail-btn avail-btn--accent";3167 signInBtn.type = "button";3168 signInBtn.textContent = "Sign in with passkey";3169 avail.appendChild(signInBtn);31703171 const passwordBtn = document.createElement("button");3172 passwordBtn.className = "avail-btn avail-btn--ghost";3173 passwordBtn.type = "button";3174 passwordBtn.textContent = "Use password instead";3175 avail.appendChild(passwordBtn);31763177 function dismiss() {3178 wrap.classList.add("is-exiting");3179 setTimeout(() => host.remove(), 130);3180 }31813182 signInBtn.addEventListener("click", () => {3183 3184 3185 3186 3187 3188 dismiss();3189 chrome.runtime.sendMessage({ type: "OPEN_PRO_GATE", payload: {} }).catch(() => {});3190 });3191 passwordBtn.addEventListener("click", dismiss);3192 closeBtn.addEventListener("click", dismiss);31933194 document.body.appendChild(host);3195}319631973198319932003201320232033204export function showCardSelector(3205 anchorEl: HTMLInputElement,3206 cards: CardSelectorEntry[],3207 options: CardSelectorOptions3208): () => void {3209 if (cards.length === 0) return () => {};3210 const card = cards[0]!;32113212 const host = document.createElement("div");3213 host.style.cssText = "position: absolute; z-index: 2147483647;";3214 host.style.setProperty("--peach-accent", accentHex);3215 host.style.setProperty("--peach-accent-dim", withAlpha(accentHex, "28"));3216 host.style.setProperty("--peach-glow", withAlpha(accentHex, "18"));3217 host.style.setProperty("--peach-border-accent", withAlpha(accentHex, "30"));3218 const shadow = host.attachShadow({ mode: "closed" });32193220 const style = shadow.appendChild(document.createElement("style"));3221 style.textContent = SELECTOR_STYLES;32223223 const rect = anchorEl.getBoundingClientRect();3224 host.style.top = `${rect.bottom + window.scrollY + 5}px`;3225 host.style.left = `${rect.left + window.scrollX}px`;3226 host.style.width = `${Math.min(Math.max(rect.width, 320), 400)}px`;32273228 const container = shadow.appendChild(document.createElement("div"));3229 container.className = "peach-inline-popup";3230 container.setAttribute("data-theme", popupTheme);32313232 3233 const domHdr = document.createElement("div");3234 domHdr.className = "domain-header";3235 const eyebrow = document.createElement("div");3236 eyebrow.className = "domain-eyebrow";3237 eyebrow.textContent = "Pay with Peach";3238 const domName = document.createElement("div");3239 domName.className = "domain-name";3240 domName.textContent = options.domain ?? location.hostname.replace(/^www\./, "");3241 domHdr.append(eyebrow, domName);3242 container.appendChild(domHdr);32433244 const platter = document.createElement("div");3245 platter.className = "card-platter";32463247 if (card.network && card.network !== "unknown") {3248 const net = document.createElement("div");3249 net.className = "cp-network";3250 net.textContent = card.network;3251 platter.appendChild(net);3252 }32533254 const nick = document.createElement("div");3255 nick.className = "cp-nickname";3256 nick.textContent = card.title;3257 platter.appendChild(nick);32583259 if (card.last4) {3260 const l4 = document.createElement("div");3261 l4.className = "cp-last4";3262 l4.textContent = `•••• ${card.last4}`;3263 platter.appendChild(l4);3264 }32653266 const meta = document.createElement("div");3267 meta.className = "cp-meta";3268 if (card.cardholderName) {3269 const name = document.createElement("span");3270 name.textContent = card.cardholderName;3271 meta.appendChild(name);3272 }3273 if (card.expMonth && card.expYear) {3274 if (card.cardholderName) {3275 const sep = document.createElement("span");3276 sep.className = "cp-meta-sep";3277 sep.textContent = "·";3278 meta.appendChild(sep);3279 }3280 const exp = document.createElement("span");3281 const yy = card.expYear.length === 4 ? card.expYear.slice(-2) : card.expYear;3282 exp.textContent = `${card.expMonth.padStart(2, "0")}/${yy}`;3283 meta.appendChild(exp);3284 }3285 if (meta.childElementCount > 0) platter.appendChild(meta);32863287 const fillWrap = document.createElement("div");3288 fillWrap.className = "cp-fill-wrap";3289 const fillBtn = document.createElement("button");3290 fillBtn.className = "sp-fill-btn";3291 fillBtn.type = "button";3292 fillBtn.textContent = "Fill card details";3293 fillBtn.addEventListener("click", async () => {3294 if (fillBtn.disabled) return;3295 fillBtn.disabled = true;3296 fillBtn.classList.add("filled");3297 fillBtn.innerHTML = checkSvgStr();3298 const resp = await chrome.runtime.sendMessage({3299 type: "GET_ENTRY_FOR_FILL",3300 payload: { id: card.id },3301 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3302 if (resp?.ok && resp.data) options.onFill(resp.data);3303 setTimeout(() => dismiss(), 400);3304 });3305 fillWrap.appendChild(fillBtn);3306 platter.appendChild(fillWrap);33073308 3309 const actions = document.createElement("div");3310 actions.className = "sp-actions";33113312 function flashBtn(b: HTMLButtonElement) {3313 b.classList.add("flashed");3314 setTimeout(() => b.classList.remove("flashed"), 700);3315 }33163317 async function fetchFullCard(): Promise<import("../shared/types").VaultEntry | null> {3318 const resp = await chrome.runtime.sendMessage({3319 type: "GET_ENTRY_FOR_FILL",3320 payload: { id: card.id },3321 }).catch(() => null) as { ok: boolean; data?: import("../shared/types").VaultEntry } | null;3322 return resp?.ok && resp.data ? resp.data : null;3323 }33243325 const copyNum = document.createElement("button");3326 copyNum.className = "sp-action-btn";3327 copyNum.type = "button";3328 copyNum.title = "Copy card number";3329 copyNum.textContent = "Copy number";3330 copyNum.addEventListener("click", async (e) => {3331 e.stopPropagation();3332 const full = await fetchFullCard();3333 if (!full?.cardNumber) return;3334 let alreadyWritten = false;3335 try { await navigator.clipboard.writeText(full.cardNumber); alreadyWritten = true; } catch {}3336 await chrome.runtime.sendMessage({3337 type: "COPY",3338 payload: { text: full.cardNumber, label: "Card number", alreadyWritten },3339 }).catch(() => {});3340 flashBtn(copyNum);3341 });3342 actions.appendChild(copyNum);33433344 const copyCvc = document.createElement("button");3345 copyCvc.className = "sp-action-btn";3346 copyCvc.type = "button";3347 copyCvc.title = "Copy CVC";3348 copyCvc.textContent = "Copy CVC";3349 copyCvc.addEventListener("click", async (e) => {3350 e.stopPropagation();3351 const full = await fetchFullCard();3352 if (!full?.cvc) return;3353 let alreadyWritten = false;3354 try { await navigator.clipboard.writeText(full.cvc); alreadyWritten = true; } catch {}3355 await chrome.runtime.sendMessage({3356 type: "COPY",3357 payload: { text: full.cvc, label: "CVC", alreadyWritten },3358 }).catch(() => {});3359 flashBtn(copyCvc);3360 });3361 actions.appendChild(copyCvc);33623363 const closeBtn = document.createElement("button");3364 closeBtn.className = "sp-action-btn";3365 closeBtn.type = "button";3366 closeBtn.title = "Dismiss";3367 closeBtn.textContent = "✕";3368 closeBtn.addEventListener("click", (e) => {3369 e.stopPropagation();3370 dismiss(true);3371 });3372 actions.appendChild(closeBtn);33733374 platter.appendChild(actions);3375 container.appendChild(platter);33763377 document.body.appendChild(host);3378 function updatePosition() {3379 const r = anchorEl.getBoundingClientRect();3380 host.style.top = `${r.bottom + window.scrollY + 5}px`;3381 host.style.left = `${r.left + window.scrollX}px`;3382 }3383 const stopObserving = observeAnchorPosition(anchorEl, updatePosition);33843385 function onKeyDown(e: KeyboardEvent) {3386 if (e.key === "Escape") { e.preventDefault(); dismiss(true); }3387 }3388 document.addEventListener("keydown", onKeyDown);33893390 let exitScheduled = false;3391 function dismiss(userAction = false) {3392 if (exitScheduled) return;3393 exitScheduled = true;3394 stopObserving();3395 document.removeEventListener("click", outsideClick, { capture: true });3396 document.removeEventListener("keydown", onKeyDown);3397 if (userAction) options.onDismiss?.();3398 container.classList.add("is-exiting");3399 setTimeout(() => host.remove(), 130);3400 }34013402 function outsideClick(ev: MouseEvent) {3403 const path = ev.composedPath();3404 if (!path.includes(host) && !path.includes(anchorEl)) dismiss(true);3405 }3406 setTimeout(() => document.addEventListener("click", outsideClick, { capture: true }), 0);34073408 return dismiss;3409}