Files
webmail/stores/favicon-refresh-store.ts
T
Linus Rath cf0eb03c4a feat: show the sender's BIMI logo as the sender icon when the message passes DMARC
Stalwart does no BIMI, so sender icons were only ever favicons, which
anyone controls for any domain. The webmail server now does the
receiver side itself at /api/bimi, and avatars ask it only for
messages whose own Authentication-Results say dmarc=pass for the exact
From domain.

- `lib/bimi/`: DMARC policy check (quarantine or reject, pct=100, the
  parent domain's sp and p for subdomains), the assertion record with
  fallback to the parent domain, mark certificate validation (chain to
  pinned DigiCert, GlobalSign and SSL.com VMC roots, BIMI key purpose,
  validity, SAN, SCTs present, CRL revocation, logo from the logotype
  extension), SVG Tiny PS checks and rendering to PNG, caching
- logos backed only by the DNS record show by default; the admin
  setting "Require a mark certificate" (`BIMI_REQUIRE_CERTIFICATE`)
  limits them to VMC and CMC backed ones
- a check mark beside the sender's name for certificate-backed logos
- avatars try contact photo, BIMI logo, plugin avatar, favicon; the
  sender warning shield still wins, and logos follow the sender icons
  setting and the no-third-party-traffic mode
- the two-label public suffix list moved to `lib/root-domain.ts`

SCT signatures are not verified and only the default selector is used.
2026-10-30 00:12:24 +01:00

33 lines
1.2 KiB
TypeScript

import { create } from 'zustand';
import { persist } from 'zustand/middleware';
// Domains whose favicon failed to load in this tab. Avatars skip them so a
// missing icon isn't requested again on every render.
export const failedFaviconDomains = new Set<string>();
// The same for BIMI logos (/api/bimi), by From domain.
export const failedBrandDomains = new Set<string>();
interface FaviconRefreshState {
/** When the user last asked for fresh sender icons (ms), 0 if never. */
refreshedAt: number;
refresh: () => void;
}
// Sender favicons are cached for two weeks by the browser and by the
// /api/favicon proxy. Refreshing stamps a new time that avatars append to the
// favicon URL (so the browser and any proxy in between miss their cache) and
// that the route compares against its own cache entry (issue #960).
export const useFaviconRefreshStore = create<FaviconRefreshState>()(
persist(
(set) => ({
refreshedAt: 0,
refresh: () => {
failedFaviconDomains.clear();
failedBrandDomains.clear();
set({ refreshedAt: Date.now() });
},
}),
{ name: 'favicon-refresh', partialize: (s) => ({ refreshedAt: s.refreshedAt }) },
),
);