Ignore:
Timestamp:
06/28/2026 04:46:38 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
99989f9
Parents:
f79a471
Message:

feat(images): downscale remote (fediverse) avatars via a signed proxy

Remote avatars live on other servers, so the browser shrank full-res line-art to ~44px
(jagged). Fetch them once (SSRF-safe via safeFetch), downscale identically (lanczos -> WebP),
cache, serve. HMAC-signed proxy URLs → not an open resizer.

  • services/ActivityPubService.js — export safeFetch
  • services/ThumbnailService.js — getRemoteThumbnail + signed imgProxyUrl/verifyImg; +128px size
  • server.js — GET /img/a/:w signed proxy route
  • middleware/render.js — avatar(url,w) helper (local thumb / remote proxy)
  • views: news.ejs, fedi-node.ejs, following.ejs avatars -> avatar()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rf79a471 r74c5abc  
    6060  if (!addrs.length || addrs.some((a) => isBlockedIp(a.address))) throw new Error('ssrf-blocked-host');
    6161}
    62 async function safeFetch(url, opts = {}, maxRedirects = 3) {
     62export async function safeFetch(url, opts = {}, maxRedirects = 3) {
    6363  let target = url;
    6464  for (let hop = 0; ; hop++) {
Note: See TracChangeset for help on using the changeset viewer.