Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(ipfs): drop gateways that now answer 429 and read every server and client path from one shared gateway ladder
nirholasb07414fd0434
diff --git a/api/_lib/ipfs-gateways.js b/api/_lib/ipfs-gateways.jsindex dcc72f4c6..89003203f 100644--- a/api/_lib/ipfs-gateways.js+++ b/api/_lib/ipfs-gateways.js@@ -8,16 +8,16 @@// and take the first answer.//// The IPFS list is the one api/_lib/ipfs-pin.js verifies manifests against-// (imported, not copied) plus 4everland, the extra mirror api/img.js races.-// cloudflare-ipfs.com / cf-ipfs.com (retired 2024) and flk-ipfs.xyz (refusing-// connections) are deliberately absent: a dead host in a ladder burns the-// timeout budget and reports a network error as a miss.+// (imported, not copied), so every server-side reader, api/img.js included,+// walks the same gateways. Why each retired gateway is absent is recorded on+// IPFS_READ_GATEWAYS: a dead host in a ladder burns the timeout budget and+// reports a network error as a miss.import { IPFS_READ_GATEWAYS } from './ipfs-pin.js';import { fetchFirst } from '../../src/shared/failover-fetch.js';/** Ordered IPFS gateway prefixes (each ends in `/ipfs/`). */-export const IPFS_GATEWAYS = [...IPFS_READ_GATEWAYS, 'https://4everland.io/ipfs/'];+export const IPFS_GATEWAYS = [...IPFS_READ_GATEWAYS];/** Ordered Arweave gateway prefixes (each ends in `/`). */export const ARWEAVE_GATEWAYS = [diff --git a/api/_lib/ipfs-pin.js b/api/_lib/ipfs-pin.jsindex c7a9fb89b..ad756f928 100644--- a/api/_lib/ipfs-pin.js+++ b/api/_lib/ipfs-pin.js@@ -32,15 +32,16 @@ export function ipfsGatewayUrl(cid) {* pinned CID takes minutes to hours to propagate across the DHT, and until it* does the public gateways answer 504 for a document that is perfectly pinned.*- * Deliberately absent: cloudflare-ipfs.com and cf-ipfs.com (Cloudflare retired- * both in 2024, so they fail DNS, see src/ipfs.js) and flk-ipfs.xyz (no longer- * accepting connections). A dead host in a fallback chain is worse than no- * fallback: it burns the retry budget and reports a network error as a miss.+ * Deliberately absent, because a dead host in a fallback chain burns the retry+ * budget and reports a network error as a miss: cloudflare-ipfs.com and+ * cf-ipfs.com (retired 2024, DNS fails), flk-ipfs.xyz (DNS fails), and ipfs.io,+ * dweb.link, w3s.link and nftstorage.link, which since Oct 2026 answer every+ * programmatic read with 429 "switching to a service worker gateway only"+ * (the client-side list in src/ipfs.js carries the same history).*/export const IPFS_READ_GATEWAYS = [- 'https://ipfs.io/ipfs/',- 'https://dweb.link/ipfs/',- 'https://w3s.link/ipfs/',+ 'https://ipfs.filebase.io/ipfs/',+ 'https://4everland.io/ipfs/','https://gateway.pinata.cloud/ipfs/',];diff --git a/api/_lib/onchain.js b/api/_lib/onchain.jsindex 6882807f5..7e23d967e 100644--- a/api/_lib/onchain.js+++ b/api/_lib/onchain.js@@ -20,6 +20,7 @@ import {} from './erc8004-chains.js';import { KIND_GLB_SCHEMA, responsePassed } from '../../src/erc8004/validation-report.js';import { fetchSafePublicUrlPinned } from './ssrf-guard.js';+import { IPFS_GATEWAYS } from './ipfs-gateways.js';const IDENTITY_ABI = ['function tokenURI(uint256 tokenId) external view returns (string)',@@ -217,7 +218,7 @@ export const SERVER_CHAIN_META = {},};-const IPFS_GATEWAY = 'https://ipfs.io/ipfs/';+const IPFS_GATEWAY = IPFS_GATEWAYS[0];const AR_GATEWAY = 'https://arweave.net/';// Shared via Upstash when configured — see api/_lib/cache.js. Falls back todiff --git a/api/_lib/solana-agents-normalize.js b/api/_lib/solana-agents-normalize.jsindex 6ed56b658..ae509e828 100644--- a/api/_lib/solana-agents-normalize.js+++ b/api/_lib/solana-agents-normalize.js@@ -2,6 +2,8 @@// I/O (no db, no RPC) so the field-parsing logic is unit-testable in isolation// and can be imported without dragging in the serverless DB driver.+import { IPFS_GATEWAYS } from '../../src/ipfs.js';+export const MAX_NAME = 200;export const MAX_DESC = 1000;@@ -18,9 +20,9 @@ export function resolveGateway(uri) {if (!uri) return null;const s = String(uri).trim();if (!s) return null;- if (s.startsWith('ipfs://')) return `https://ipfs.io/ipfs/${s.slice(7).replace(/^ipfs\//, '')}`;+ if (s.startsWith('ipfs://')) return `${IPFS_GATEWAYS[0]}${s.slice(7).replace(/^ipfs\//, '')}`;if (s.startsWith('ar://')) return `https://arweave.net/${s.slice(5)}`;- if (/^[a-zA-Z0-9]{46,59}$/.test(s) && !s.includes('.')) return `https://ipfs.io/ipfs/${s}`;+ if (/^[a-zA-Z0-9]{46,59}$/.test(s) && !s.includes('.')) return `${IPFS_GATEWAYS[0]}${s}`;return s;}diff --git a/api/_lib/solana-token-meta.js b/api/_lib/solana-token-meta.jsindex 8a76584db..8e46d1457 100644--- a/api/_lib/solana-token-meta.js+++ b/api/_lib/solana-token-meta.js@@ -17,6 +17,7 @@ import {import { getConnection, solanaPubkey } from './pump.js';import { isRpcOutageError, rpcUnavailableError } from './rpc-degrade.js';import { fetchSafePublicUrlPinned } from './ssrf-guard.js';+import { IPFS_GATEWAYS, ipfsPath } from './ipfs-gateways.js';const METADATA_PROGRAM = new PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');const NAME_MAX = 32;@@ -104,10 +105,10 @@ function resolveOffchainUrl(uri) {if (!uri) return null;const trimmed = uri.trim();if (!trimmed) return null;- if (trimmed.startsWith('ipfs://')) {- const cid = trimmed.slice('ipfs://'.length).replace(/^ipfs\//, '');- return `https://ipfs.io/ipfs/${cid}`;- }+ // ipfs:// and URLs pinned to a gateway that stopped serving (pump.fun still+ // hands out ipfs.io) both re-point at the first live shared gateway.+ const cidPath = ipfsPath(trimmed);+ if (cidPath) return IPFS_GATEWAYS[0] + cidPath;if (trimmed.startsWith('ar://')) {return `https://arweave.net/${trimmed.slice('ar://'.length)}`;}diff --git a/api/agents/_id/brain.js b/api/agents/_id/brain.jsindex 152d8c2f3..a4723ecfa 100644--- a/api/agents/_id/brain.js+++ b/api/agents/_id/brain.js@@ -25,6 +25,7 @@ import { getSessionUser, authenticateBearer, extractBearer } from '../../_lib/auimport { sql } from '../../_lib/db.js';import { cors, json, method, readJson, error } from '../../_lib/http.js';import { requireCsrf } from '../../_lib/csrf.js';+import { IPFS_GATEWAYS } from '../../_lib/ipfs-gateways.js';import { parse } from '../../_lib/validate.js';import { z } from 'zod';@@ -198,7 +199,7 @@ async function getPassport(res, agent) {filename: p.filename,bytes: p.bytes,created_at: p.created_at,- gateway_url: `https://dweb.link/ipfs/${p.cid}`,+ gateway_url: `${IPFS_GATEWAYS[0]}${p.cid}`,})),anchor: anchorState.anchor,current_brain_hash: anchorState.currentBrainHash,diff --git a/api/agents/_id/memory/[cid].js b/api/agents/_id/memory/[cid].jsindex 7edc661aa..d651a7012 100644--- a/api/agents/_id/memory/[cid].js+++ b/api/agents/_id/memory/[cid].js@@ -2,12 +2,7 @@ import { sql } from '../../../_lib/db.js';import { getSessionUser, authenticateBearer, extractBearer } from '../../../_lib/auth.js';import { cors, method, wrap, error, rateLimited } from '../../../_lib/http.js';import { limits, clientIp } from '../../../_lib/rate-limit.js';--const IPFS_GATEWAYS = [- 'https://dweb.link/ipfs/',- 'https://flk-ipfs.xyz/ipfs/',- 'https://ipfs.io/ipfs/',-];+import { IPFS_GATEWAYS } from '../../../_lib/ipfs-gateways.js';const CID_RE = /^[a-zA-Z0-9]+$/;diff --git a/api/cron/[name].js b/api/cron/[name].jsindex 6453088e2..fe514b4d5 100644--- a/api/cron/[name].js+++ b/api/cron/[name].js@@ -72,6 +72,7 @@ import { runPumpAlertRules } from '../_lib/pump-alert-runner.js';import { publishUserEvent } from '../_lib/feed.js';import { confirmSkillPurchase } from '../_lib/purchase-confirm.js';import { requireCron } from '../_lib/cron-auth.js';+import { resolveURI } from '../../src/ipfs.js';import {OUTCOME,applyChargeFailure,@@ -1078,10 +1079,8 @@ async function erc8004FetchAgentMetadata(uri) {function erc8004ResolveGateway(uri) {if (!uri || typeof uri !== 'string') return '';- if (uri.startsWith('ipfs://')) return 'https://ipfs.io/ipfs/' + uri.slice(7);- if (uri.startsWith('ar://')) return 'https://arweave.net/' + uri.slice(5);- if (uri.startsWith('http://') || uri.startsWith('https://')) return uri;- return '';+ const url = resolveURI(uri);+ return url.startsWith('http://') || url.startsWith('https://') ? url : '';}function erc8004Truncate(s, max) {diff --git a/api/erc8004/[action].js b/api/erc8004/[action].jsindex ecd1c8ff3..d82913ea4 100644--- a/api/erc8004/[action].js+++ b/api/erc8004/[action].js@@ -30,6 +30,7 @@ import { fetchSafePublicUrlPinned, SsrfBlockedError, MaxBytesExceededError } froimport { redactUrlSecrets } from '../_lib/scrub-secrets.js';import { fetchUpstream } from '../_lib/upstream-fetch.js';+import { IPFS_GATEWAYS, ipfsPath } from '../_lib/ipfs-gateways.js';export default wrap(async (req, res) => {const action = req.query?.action;@@ -469,9 +470,11 @@ async function handleMetadataProxy(req, res) {if (!raw) return error(res, 400, 'bad_request', 'uri is required');// Resolve the decentralized-storage schemes to their public gateways, the- // same mapping the client applies before it ever reaches this endpoint.+ // same mapping the client applies before it ever reaches this endpoint. A URL+ // already pinned to a gateway is re-pointed too, since some stopped serving.let url = raw;- if (raw.startsWith('ipfs://')) url = 'https://ipfs.io/ipfs/' + raw.slice(7);+ const cidPath = ipfsPath(raw);+ if (cidPath) url = IPFS_GATEWAYS[0] + cidPath;else if (raw.startsWith('ar://')) url = 'https://arweave.net/' + raw.slice(5);if (!/^https?:\/\//i.test(url)) {@@ -635,7 +638,7 @@ async function uploadToWeb3Storage(token, ext, body, ct) {// web3.storage and nft.storage guarantee content-addressable uploads:// same bytes → same CID every time, idempotent by design.const uri = `ipfs://${cid}/${filename}`;- const url = `https://w3s.link/ipfs/${cid}/${filename}`;+ const url = `${IPFS_GATEWAYS[0]}${cid}/${filename}`;return { cid, uri, url };}@@ -663,7 +666,7 @@ async function uploadToNftStorage(token, ext, body, ct) {// nft.storage guarantees content-addressable uploads: same bytes → same CID.const uri = `ipfs://${cid}/${filename}`;- const url = `https://w3s.link/ipfs/${cid}/${filename}`;+ const url = `${IPFS_GATEWAYS[0]}${cid}/${filename}`;return { cid, uri, url };}diff --git a/api/erc8004/register-confirm.js b/api/erc8004/register-confirm.jsindex 927b82a13..c74c08d15 100644--- a/api/erc8004/register-confirm.js+++ b/api/erc8004/register-confirm.js@@ -8,6 +8,7 @@ import { limits, clientIp } from '../_lib/rate-limit.js';import { CHAIN_BY_ID } from '../_lib/erc8004-chains.js';import { evmRpcEndpoints } from '../_lib/evm/rpc.js';import { fetchSafePublicUrlPinned, SsrfBlockedError, MaxBytesExceededError } from '../_lib/ssrf-guard.js';+import { resolveURI } from '../../src/ipfs.js';const REGISTERED_TOPIC = keccakId('Registered(uint256,string,address)');const TIMEOUT_MS = 10_000;@@ -179,9 +180,8 @@ async function rpcCall(chainId, m, params) {function resolveGateway(uri) {if (!uri) return '';- if (uri.startsWith('ipfs://')) return 'https://ipfs.io/ipfs/' + uri.slice(7);- if (uri.startsWith('ar://')) return 'https://arweave.net/' + uri.slice(5);- return uri.startsWith('http') ? uri : '';+ const url = resolveURI(uri);+ return url.startsWith('http') ? url : '';}async function enrichMetadata(chainId, agentId, uri) {diff --git a/api/ibm/vision.js b/api/ibm/vision.jsindex 14aee7930..0a4db1a0e 100644--- a/api/ibm/vision.js+++ b/api/ibm/vision.js@@ -24,6 +24,7 @@ import { limits, clientIp } from '../_lib/rate-limit.js';import { publicUrl, thumbnailUrl } from '../_lib/r2.js';import { watsonxConfig, watsonxChatComplete } from '../_lib/watsonx.js';import { assertSafePublicUrl } from '../_lib/ssrf-guard.js';+import { normalizeGatewayURL } from '../../src/ipfs.js';// Granite Vision 3.2 (2B) is the default multimodal model on watsonx.ai. Override// per account/region with WATSONX_VISION_MODEL_ID.@@ -70,6 +71,9 @@ export function allowedImageHost(host) {'.pinata.cloud','ipfs.io','.ipfs.dweb.link',+ 'ipfs.filebase.io',+ '4everland.io',+ '.4everland.io','cf-ipfs.com','arweave.net','.arweave.net',@@ -240,11 +244,14 @@ async function resolveImage(body) {}if (/^https:\/\//i.test(imageUrl)) {- const host = hostOf(imageUrl);+ // Token art pinned to a retired IPFS gateway (pump.fun still hands out+ // ipfs.io) is re-pointed at a live one before it is fetched.+ const target = normalizeGatewayURL(imageUrl);+ const host = hostOf(target);if (!host || !allowedImageHost(host)) {throw fail(400, 'image_host_not_allowed', 'imageUrl host is not allowed');}- return await fetchImageAsDataUrl(imageUrl);+ return await fetchImageAsDataUrl(target);}throw fail(400, 'bad_image', 'provide image (data URL) or imageUrl (https)');diff --git a/api/img.js b/api/img.jsindex 6ae415907..a441774de 100644--- a/api/img.js+++ b/api/img.js@@ -41,7 +41,7 @@import { wrap, cors, method, error, rateLimited } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';import { fetchModel } from './_lib/fetch-model.js';-import { safeFetchJson } from './_lib/ssrf.js';+import { IPFS_GATEWAYS } from './_lib/ipfs-gateways.js';// `?w=<px>` resizes a raster upstream to at most that width and re-encodes it// as WebP. Gallery surfaces (the Forge showcase, the marketplace grid) paint@@ -106,20 +106,6 @@ const TOTAL_BUDGET_MS = 25_000;// flush the placeholder SVG (or the real image) after the last upstream attempt.const RESPONSE_HEADROOM_MS = 1_000;-// Public IPFS gateways. ipfs.io is the canonical resolver the rest of the platform-// pins to (api/_lib/onchain.js) but is also the one most likely to ORB-block or-// stall, so we fan out across healthy mirrors and race them: the first to return a-// valid image wins. cloudflare-ipfs.com is intentionally absent: Cloudflare sunset-// its public IPFS gateway, so every request to it is a guaranteed failure that only-// wastes a connection.-const IPFS_GATEWAYS = [- 'https://ipfs.io/ipfs/',- 'https://dweb.link/ipfs/',- 'https://gateway.pinata.cloud/ipfs/',- 'https://w3s.link/ipfs/',- 'https://4everland.io/ipfs/',-];-// Pull the `<cid>/<path?>` portion out of any recognised IPFS URL form so we can// re-point it at a different gateway. Returns null for non-IPFS URLs.function ipfsPath(rawUrl) {@@ -128,7 +114,10 @@ function ipfsPath(rawUrl) {return m ? m[1] : null;}-// Build the ordered list of candidate URLs to try for one logical image.+// Build the ordered list of candidate URLs to try for one logical image. The+// gateways are the shared server-side list (api/_lib/ipfs-gateways.js), so a+// gateway that stops serving is dropped in one place; api/_lib/ipfs-pin.js+// records why each retired host is absent.function candidates(rawUrl) {const path = ipfsPath(rawUrl);if (path) return IPFS_GATEWAYS.map((g) => g + path);@@ -269,17 +258,14 @@ function imageFromMetaDoc(data) {return trimmed;}-// Resolve a token's artwork URL from its metadata JSON document, fetched through-// the SSRF-hardened JSON client. Backs the explicit `?meta=` parameter; the-// `?url=` path reaches the same place via raceCandidates()'s JSON detection.-async function resolveImageFromMeta(metaUri, timeoutMs = META_TIMEOUT_MS) {- try {- const { ok, data } = await safeFetchJson(metaUri, { timeoutMs });- if (!ok) return null;- return imageFromMetaDoc(data);- } catch {- return null;- }+// Resolve a token's artwork URL from its metadata JSON document. Backs the+// explicit `?meta=` parameter; the `?url=` path reaches the same place via+// raceCandidates()'s JSON detection. The document is raced across every+// gateway exactly like art is, because a metadata URI pinned to one gateway+// host (pump.fun hands out ipfs.io) dies with that host otherwise.+async function resolveImageFromMeta(metaUri, budgetMs) {+ const doc = await raceCandidates(candidates(metaUri), META_TIMEOUT_MS, budgetMs, true);+ return doc?.kind === 'json' ? imageFromMetaDoc(doc.data) : null;}// Whatever this endpoint returns is a remote party's bytes served from thediff --git a/api/oracle/og.js b/api/oracle/og.jsindex c56284749..1c45680f1 100644--- a/api/oracle/og.js+++ b/api/oracle/og.js@@ -23,6 +23,7 @@ import { fetchOgImage } from '../_lib/og-avatar.js';import { isQuoteMint } from '../_lib/quote-mints.js';import { pumpFetchJson } from '../_lib/pump-feed-fetch.js';import { fetchTokenMarketData } from '../_lib/market/token-market.js';+import { resolveURI } from '../../src/ipfs.js';const MINT_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;const PUMP_FRONTEND_V3 = 'https://frontend-api-v3.pump.fun';@@ -81,9 +82,7 @@ function tierLabel(tier) {async function fetchLogoBase64(imageUri) {if (!imageUri) return null;- const url = imageUri.startsWith('ipfs://')- ? `https://ipfs.io/ipfs/${imageUri.slice(7)}`- : imageUri;+ const url = resolveURI(imageUri);// The logo URI is chosen by whoever launched the coin. fetchOgImage refuses// private and metadata addresses on every redirect hop, caps the bytes, and// only accepts a bare image media type, so neither internal responses nor adiff --git a/api/pump/launch-og.js b/api/pump/launch-og.jsindex d30edd3a9..bb7c55d7f 100644--- a/api/pump/launch-og.js+++ b/api/pump/launch-og.js@@ -29,6 +29,7 @@ import { cors, method, wrap } from '../_lib/http.js';import { sql } from '../_lib/db.js';import { fetchOgImage } from '../_lib/og-avatar.js';import { pumpFetchJson } from '../_lib/pump-feed-fetch.js';+import { resolveURI } from '../../src/ipfs.js';const MINT_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;const PUMP_FRONTEND_V3 = 'https://frontend-api-v3.pump.fun';@@ -67,9 +68,7 @@ function fmtNum(v) {// we just omit the image; the card still renders fine without it.async function fetchLogoBase64(imageUri) {if (!imageUri) return null;- const url = imageUri.startsWith('ipfs://')- ? `https://ipfs.io/ipfs/${imageUri.slice(7)}`- : imageUri;+ const url = resolveURI(imageUri);// The logo URI is chosen by whoever launched the coin. fetchOgImage refuses// private and metadata addresses on every redirect hop, caps the bytes, and// only accepts a bare image media type, so neither internal responses nor adiff --git a/scripts/event-dependency-failover.mjs b/scripts/event-dependency-failover.mjsindex 402f595cb..c09ff61a8 100644--- a/scripts/event-dependency-failover.mjs+++ b/scripts/event-dependency-failover.mjs@@ -21,6 +21,7 @@ import { writeFileSync } from 'node:fs';import process from 'node:process';import { makeRotatingFetch, solanaRpcEndpoints } from '../api/_lib/solana/connection.js';+import { IPFS_GATEWAYS } from '../api/_lib/ipfs-gateways.js';const THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';// The canonical $THREE coin image the event link carries, as an IPFS path.@@ -120,17 +121,7 @@ async function checkSolanaRpc() {// -- IPFS: the coin image the event link and every OG card resolve ---------------// Mirrors the gateway order in api/img.js. Kept as a literal list rather than an-// import because api/img.js is a request handler, not a module with an exported-// gateway table, and duplicating five strings is cheaper than reshaping a live-// endpoint the day before an event.-const IPFS_GATEWAYS = [- 'https://ipfs.io/ipfs/',- 'https://dweb.link/ipfs/',- 'https://gateway.pinata.cloud/ipfs/',- 'https://w3s.link/ipfs/',- 'https://4everland.io/ipfs/',-];+// The same gateways api/img.js races: the shared server-side list.async function checkIpfs() {const rungs = [];diff --git a/src/clash.js b/src/clash.jsindex 89f1d127c..b63f248e5 100644--- a/src/clash.js+++ b/src/clash.js@@ -116,7 +116,10 @@ async function apiPost(action, payload) {// ── Avatar (image or seeded initials) ────────────────────────────────────────function avatar(side, cls = 'cl-avatar') {- if (side.image) return el('img', { class: cls, src: side.image, alt: side.symbol || '', loading: 'lazy', referrerpolicy: 'no-referrer' });+ // Coin art lives on public IPFS gateways that the browser blocks cross-origin;+ // /api/img fetches it server-side and always answers a valid image.+ const src = proxiedImageURL(side.image || '', side.token || '', { width: 128 });+ if (src) return el('img', { class: cls, src, alt: side.symbol || '', loading: 'lazy' });const label = (side.symbol || side.token || '?').replace(/^\$/, '').slice(0, 2).toUpperCase();return el('div', { class: `${cls} cl-avatar-ph`, text: label, 'aria-hidden': 'true' });}diff --git a/src/coin3d/main.js b/src/coin3d/main.jsindex 679224703..80e98fa14 100644--- a/src/coin3d/main.js+++ b/src/coin3d/main.js@@ -61,7 +61,7 @@ import { fetchFirstOrNull } from '../shared/failover-fetch.js';import { dextoolsUrl } from '../shared/dextools.js';import { dextoolsTokenUrl } from '../shared/trading-terminals.js';import { applyCinematicDefaults, detectQualityTier, loadEnvironment } from '../shared/cinematic-render.js';-import { resolveURI, IPFS_GATEWAYS } from '../ipfs.js';+import { proxiedImageURL, resolveURI } from '../ipfs.js';const MCP_ENDPOINT = '/api/pump-fun-mcp';// The one and only coin — featured on the no-mint landing.@@ -196,7 +196,7 @@ async function loadSnapshot() {const name = d.name || d.metadata?.name || gt?.name || 'Unknown token';const symbol = (d.symbol || d.metadata?.symbol || gt?.symbol || '').toUpperCase();- const image = (await resolveImage(d)) || gt?.image || null;+ const images = coinFaceCandidates(d, gt);return {mint,@@ -204,7 +204,8 @@ async function loadSnapshot() {answered,name,symbol,- image,+ image: images[0] || null,+ images,marketCapUsd: numOrNull(d.marketCapUsd ?? d.usdMarketCap ?? d.market_cap) ?? gt?.marketCapUsd ?? null,priceUsd: gt?.priceUsd ?? null,volume24: gt?.volume24 ?? null,@@ -309,45 +310,27 @@ async function fetchTokenMeta(mintAddr) {], { timeoutMs: 7000, label: 'token-meta' });}-// The token logo lives in the off-chain metadata JSON pointed to by the-// on-chain `uri`, not in getTokenDetails directly. Resolve it (best-effort):-// a direct image field wins; otherwise fetch the uri JSON and read .image.-async function resolveImage(d) {+// Coin face art, best source first, every entry a same-origin /api/img URL.+// The logo usually lives in the off-chain metadata JSON the on-chain `uri`+// points at; /api/img follows that `.image` server-side with gateway retry, so+// the page never fetches an IPFS gateway itself (they send no CORS headers, and+// ipfs.io now answers fetch clients with a service-worker notice instead of the+// file). Same origin also keeps the WebGL texture untainted. GeckoTerminal's+// logo is the last resort for coins whose metadata carries no image.+const FACE_WIDTH = 480;++function coinFaceCandidates(d, gt) {+ const opts = { width: FACE_WIDTH, fallback: 'none' };const direct = d.image || d.imageUrl || d.metadata?.image;- if (direct) return ipfsToHttp(direct);const uri = d.uri || d.metadata?.uri;- if (!uri) return null;- try {- const res = await fetch(ipfsToHttp(uri), { signal: AbortSignal.timeout(6000) });- if (!res.ok) return null;- const meta = await res.json();- return meta?.image ? ipfsToHttp(meta.image) : null;- } catch {- return null;+ const candidates = [];+ if (direct) candidates.push(proxiedImageURL(direct, '', opts));+ else if (typeof uri === 'string' && uri) {+ const q = new URLSearchParams({ meta: resolveURI(uri), w: String(FACE_WIDTH), fallback: 'none' });+ candidates.push(`/api/img?${q}`);}-}--function ipfsToHttp(url) {- if (typeof url !== 'string') return null;- // Resolve through the shared gateway list so this page inherits every gateway- // the rest of the platform rotates through, instead of pinning one host.- if (url.startsWith('ipfs://')) return resolveURI(url);- return url;-}--// If a gateway URL fails, the content is usually still pinned elsewhere — retry-// the same CID on a second gateway before degrading. Returns null when the URL-// isn't a known gateway URL (nothing useful to retry).-function altIpfsGateway(url) {- if (typeof url !== 'string') return null;- // Find which shared gateway this URL currently uses and hand back the next- // one in the list, so a retry walks the whole chain rather than bouncing- // between the same two hosts.- const idx = IPFS_GATEWAYS.findIndex((gw) => url.startsWith(gw));- if (idx === -1) return null;- const cid = url.slice(IPFS_GATEWAYS[idx].length);- const next = IPFS_GATEWAYS[(idx + 1) % IPFS_GATEWAYS.length];- return next === IPFS_GATEWAYS[idx] ? null : `${next}${cid}`;+ if (gt?.image) candidates.push(proxiedImageURL(gt.image, '', opts));+ return [...new Set(candidates.filter(Boolean))];}function numOrNull(v) {@@ -586,7 +569,7 @@ function buildCoin(snapshot) {spin.add(coin);coinFaceMats = [faceMat];- if (snapshot.image) {+ if (snapshot.images.length) {const loader = new TextureLoader();loader.setCrossOrigin('anonymous');@@ -603,17 +586,15 @@ function buildCoin(snapshot) {coinFaceMats = [lit];};- const loadFrom = (src, allowRetry) => {- loader.load(src, applyTexture, undefined, () => {- // The primary gateway dropped the logo. The CID is usually pinned on- // other gateways too, so retry once on an alternate before degrading- // to the tinted disc.- const alt = allowRetry ? altIpfsGateway(src) : null;- if (alt) loadFrom(alt, false);- });+ // Walk the candidates in order; when every source misses, the coin keeps+ // its tinted disc.+ const loadFrom = (i) => {+ const src = snapshot.images[i];+ if (!src) return;+ loader.load(src, applyTexture, undefined, () => loadFrom(i + 1));};- loadFrom(snapshot.image, true);+ loadFrom(0);}}diff --git a/src/dashboard-next/pages/settings.js b/src/dashboard-next/pages/settings.jsindex 09061edf2..1d272e1f6 100644--- a/src/dashboard-next/pages/settings.js+++ b/src/dashboard-next/pages/settings.js@@ -31,6 +31,7 @@ import { mountShell } from '../shell.js';import { requireUser, get, post, put, del, patch, esc, relTime, ApiError } from '../api.js';import { emptyStateHTML, errorStateHTML, ensureStateKitStyles, attachRetry } from '../../shared/state-kit.js';import { toast } from '../../shared/toast.js';+import { IPFS_GATEWAYS } from '../../ipfs.js';const MONO = `'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace`;@@ -568,7 +569,7 @@ function renderNotificationPrefs(resp, onRetry) {// `stub:` pseudo-CID, which is a recorded content hash and not a pin. The row// says exactly that rather than showing a CID that resolves nowhere.-const IPFS_GATEWAY = 'https://ipfs.io/ipfs/';+const IPFS_GATEWAY = IPFS_GATEWAYS[0];function isRealCid(cid) {return typeof cid === 'string' && cid.length > 0 && !cid.startsWith('stub:');diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.jsindex ddb30ac50..4fd7cba9d 100644--- a/src/dashboard/dashboard.js+++ b/src/dashboard/dashboard.js@@ -9,6 +9,7 @@ import { emptyStateHTML } from '/src/shared/state-kit.js';import { renderError as renderAsyncError } from '/src/shared/async-state.js';import { log } from '../shared/log.js';import { safeUrl } from '../safe-url.js';+import { resolveURI } from '../ipfs.js';function escapeHtml(s) {return String(s == null ? '' : s)@@ -2873,10 +2874,7 @@ async function fetchTokenMeta(registry, tokenId) {}function uriToHttp(uri) {- if (!uri) return '';- if (uri.startsWith('ipfs://')) return `https://ipfs.io/ipfs/${uri.slice(7)}`;- if (uri.startsWith('ar://')) return `https://arweave.net/${uri.slice(5)}`;- return uri;+ return uri ? resolveURI(uri) : '';}// Re-pin the agent's on-chain manifest with the current animations. Fetches thediff --git a/src/erc8004/badge.js b/src/erc8004/badge.jsindex 3642155a3..e066790db 100644--- a/src/erc8004/badge.js+++ b/src/erc8004/badge.js@@ -43,8 +43,10 @@ async function sha256Hex(bytes) {return [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, '0')).join('');}+// Standalone embed (no imports), so the gateway is inlined. It matches the+// head of IPFS_GATEWAYS in src/ipfs.js; w3s.link stopped serving reads.function ipfsToHttp(uri) {- if (uri.startsWith('ipfs://')) return `https://w3s.link/ipfs/${uri.slice(7)}`;+ if (uri.startsWith('ipfs://')) return `https://ipfs.filebase.io/ipfs/${uri.slice(7)}`;return uri;}diff --git a/src/erc8004/enumeration.js b/src/erc8004/enumeration.jsindex 4ef2ffb18..ab620c8e5 100644--- a/src/erc8004/enumeration.js+++ b/src/erc8004/enumeration.js@@ -10,12 +10,7 @@*/import { getIdentityRegistry } from './agent-registry.js';--const IPFS_GATEWAYS = [- (cid) => `https://ipfs.io/ipfs/${cid}`,- (cid) => `https://flk-ipfs.xyz/ipfs/${cid}`,- (cid) => `https://dweb.link/ipfs/${cid}`,-];+import { IPFS_GATEWAYS } from '../ipfs.js';/*** Resolve an ipfs://, ar://, or https:// URI to an HTTP URL.@@ -25,7 +20,7 @@ const IPFS_GATEWAYS = [*/export function uriToHttp(uri) {if (!uri) return '';- if (uri.startsWith('ipfs://')) return IPFS_GATEWAYS[0](uri.slice(7));+ if (uri.startsWith('ipfs://')) return IPFS_GATEWAYS[0] + uri.slice(7);if (uri.startsWith('ar://')) return `https://arweave.net/${uri.slice(5)}`;return uri;}@@ -38,7 +33,7 @@ export function uriToHttp(uri) {export function ipfsFallbackUrls(uri) {if (!uri?.startsWith('ipfs://')) return [uri];const cid = uri.slice(7);- return IPFS_GATEWAYS.map((fn) => fn(cid));+ return IPFS_GATEWAYS.map((gw) => gw + cid);}/**diff --git a/src/erc8004/queries.js b/src/erc8004/queries.jsindex 3c89c1a1e..85b126887 100644--- a/src/erc8004/queries.js+++ b/src/erc8004/queries.js@@ -11,6 +11,7 @@import { BrowserProvider, Contract } from 'ethers';import { IDENTITY_REGISTRY_ABI, REGISTRY_DEPLOYMENTS } from './abi.js';import { CHAIN_META, readProvider } from './chain-meta.js';+import { resolveURI } from '../ipfs.js';/*** Return a read-only ethers provider. Uses the connected wallet provider if@@ -230,9 +231,7 @@ export async function fetchAgentMetadata(uri, { apiOrigin = '' } = {}) {}}- let url = uri;- if (uri.startsWith('ipfs://')) url = 'https://ipfs.io/ipfs/' + uri.slice(7);- else if (uri.startsWith('ar://')) url = 'https://arweave.net/' + uri.slice(5);+ const url = resolveURI(uri);if (isSameOrigin(url)) return fetchAgentMetadataDirect(url);diff --git a/src/erc8004/register-ui.js b/src/erc8004/register-ui.jsindex d893ff5fd..48aad4b50 100644--- a/src/erc8004/register-ui.js+++ b/src/erc8004/register-ui.js@@ -64,6 +64,7 @@ import {import { onchainBadgeHTML, ensureOnchainBadgeStyles } from '../shared/onchain-badge.js';import { apiFetch } from '../api.js';import { log } from '../shared/log.js';+import { resolveURI } from '../ipfs.js';ensureOnchainBadgeStyles();// ───────────────────────────────────────────────────────────────────────────@@ -2189,9 +2190,7 @@ export class RegisterUI {else url = f.glbUrl || (f.pastedGlbUrl || '').trim();if (!url) throw new Error('No 3D model to attach — choose an avatar in the Avatar step first.');- const fetchUrl = url.startsWith('ipfs://')- ? url.replace('ipfs://', 'https://ipfs.io/ipfs/')- : url;+ const fetchUrl = resolveURI(url);const sameOrigin = (() => { try { return new URL(fetchUrl, location.href).origin === location.origin; } catch { return false; } })();say('Fetching 3D model…');let resp;@@ -3683,9 +3682,7 @@ export class RegisterUI {let glbFile = null;if (existingGlb) {glbFile = await this._fetchUrlAsFile(- existingGlb.startsWith('ipfs://')- ? 'https://ipfs.io/ipfs/' + existingGlb.slice(7)- : existingGlb,+ resolveURI(existingGlb),say,'3D body',);@@ -4013,8 +4010,5 @@ export class RegisterUI {// ───────────────────────────────────────────────────────────────────────────function resolveGateway(uri) {- if (!uri) return '';- if (uri.startsWith('ipfs://')) return 'https://ipfs.io/ipfs/' + uri.slice(7);- if (uri.startsWith('ar://')) return 'https://arweave.net/' + uri.slice(5);- return uri;+ return uri ? resolveURI(uri) : '';}diff --git a/src/erc8004/resolver.js b/src/erc8004/resolver.jsindex 93b517e44..e1d4178ad 100644--- a/src/erc8004/resolver.js+++ b/src/erc8004/resolver.js@@ -20,7 +20,7 @@import { getAgentOnchain, fetchAgentMetadata, findAvatar3D } from './queries.js';import { REGISTRY_DEPLOYMENTS, agentRegistryId } from './abi.js';import { CHAIN_META } from './chain-meta.js';-import { uriCandidates } from '../ipfs.js';+import { IPFS_GATEWAYS, uriCandidates } from '../ipfs.js';// ---------------------------------------------------------------------------// Parsing@@ -105,7 +105,7 @@ export function toPublicUrl(ref, { embed = false, origin } = {}) {// duplicated here: src/ipfs.js owns the canonical, dead-host-free gateway list// and the CID re-extraction that makes an already-baked gateway URL rotatable,// so `resolveUrlCandidates` below delegates to it rather than drifting from it.-const PRIMARY_IPFS_GATEWAY = 'https://ipfs.io/ipfs/';+const PRIMARY_IPFS_GATEWAY = IPFS_GATEWAYS[0];const AR_GATEWAY = 'https://arweave.net/';/**diff --git a/src/ipfs.js b/src/ipfs.jsindex a2dca732b..92a16a4c3 100644--- a/src/ipfs.js+++ b/src/ipfs.js@@ -4,21 +4,26 @@* Translates decentralised storage URIs into HTTPS gateway URLs* so the Three.js loader can fetch them normally.*- * ipfs://QmXyz... → https://dweb.link/ipfs/QmXyz...- * ipfs://bafkreiXyz... → https://dweb.link/ipfs/bafkreiXyz...+ * ipfs://QmXyz... → https://ipfs.filebase.io/ipfs/QmXyz...+ * ipfs://bafkreiXyz... → https://ipfs.filebase.io/ipfs/bafkreiXyz...* ar://txId → https://arweave.net/txId*/-// Cloudflare retired both cf-ipfs.com and cloudflare-ipfs.com (Aug 2024);-// requests to either now fail DNS (ERR_NAME_NOT_RESOLVED). pump.fun metadata-// still hands out cf-ipfs.com image URLs, so we keep this list dead-host-free-// and rewrite any lingering dead-gateway URL via normalizeGatewayURL().+// Only gateways that serve subresource and fetch() reads with open CORS. The+// first entry is what an ipfs:// URI renders through, so it is the fastest one+// measured (Filebase and 4everland answer in ~150ms; Pinata's public gateway+// works but takes 4 to 7s). Every host below was dropped because it stopped+// serving, and normalizeGatewayURL() rewrites URLs still pointing at one:+// - cf-ipfs.com, cloudflare-ipfs.com: Cloudflare retired both (Aug 2024), DNS fails.+// - flk-ipfs.xyz: DNS fails.+// - ipfs.io, dweb.link, w3s.link, nftstorage.link: since Oct 2026 they answer+// every non-navigation request with 429/403 "switching to a service worker+// gateway only" (gatewaychanges.ipfs.io), so <img>, fetch() and texture+// loads against them all fail. pump.fun metadata still hands out ipfs.io URLs.export const IPFS_GATEWAYS = [- 'https://dweb.link/ipfs/',- 'https://ipfs.io/ipfs/',- 'https://flk-ipfs.xyz/ipfs/',- 'https://w3s.link/ipfs/',- 'https://nftstorage.link/ipfs/',+ 'https://ipfs.filebase.io/ipfs/',+ 'https://4everland.io/ipfs/',+ 'https://gateway.pinata.cloud/ipfs/',];const AR_GATEWAY = 'https://arweave.net/';@@ -27,9 +32,10 @@ const AR_GATEWAY = 'https://arweave.net/';// never answer; without a deadline the first such host holds the whole chain.const GATEWAY_TIMEOUT_MS = 8_000;-// Hosts that no longer resolve. Any HTTPS gateway URL using one of these is-// rewritten onto the primary working gateway (preserving the /ipfs/<cid>/path).-const DEAD_GATEWAY_HOST_RE = /^https?:\/\/(?:cf-ipfs\.com|cloudflare-ipfs\.com)\/ipfs\/(.+)$/i;+// Gateways that no longer serve reads (see IPFS_GATEWAYS above). Any HTTPS URL+// on one of these is rewritten onto a working gateway, keeping /ipfs/<cid>/path.+const DEAD_GATEWAY_HOST_RE =+ /^https?:\/\/(?:cf-ipfs\.com|cloudflare-ipfs\.com|flk-ipfs\.xyz|ipfs\.io|dweb\.link|w3s\.link|nftstorage\.link)\/ipfs\/(.+)$/i;/*** Returns true when the URL uses a decentralised storage scheme.diff --git a/src/watchlist.js b/src/watchlist.jsindex a5e75db9e..d005e6b94 100644--- a/src/watchlist.js+++ b/src/watchlist.js@@ -22,6 +22,7 @@import { mountCoinStatus, formatMcap, NO_VALUE } from './pump/coin-status-card.js';import { updateValue, flipReorder } from './ui-juice.js';+import { proxiedImageURL } from './ipfs.js';const WATCH_KEY = 'ld_watchlist'; // shared with src/launch-detail.jsconst LAST_TIERS_KEY = 'wl_last_tiers'; // mint → tier, for upgrade detection@@ -110,6 +111,16 @@ function mulberry32(seed) {return ((t ^ (t >>> 14)) >>> 0) / 4294967296;};}+// Trending logos come straight from launch metadata: an ipfs.io URL (which the+// browser blocks as NotSameOrigin behind the gateway's 429), a raw ipfs:// URI,+// or a metadata JSON document rather than an image (ORB-blocked). /api/img+// resolves all three server-side, so the chip gets real art or a placeholder.+// The chip paints at 20 px; 40 is the 2x rung.+function suggestLogo(c) {+ const src = proxiedImageURL(c.logo || '', c.mint, { width: 40 });+ return src ? el('img', { class: 'wl-suggest-img', src, alt: '', loading: 'lazy' }) : null;+}+function mintIdenticon(mint) {const rand = mulberry32(hashString(String(mint)));const svg = svgEl('svg', { viewBox: '0 0 64 64', 'aria-hidden': 'true' });@@ -349,7 +360,7 @@ async function loadSuggestions(wrap) {if (addMint(c.mint) !== 'already') showAddMsg(`Added ${label} — building your list.`, 'ok');},}, [- c.logo ? el('img', { class: 'wl-suggest-img', src: c.logo, alt: '', loading: 'lazy' }) : null,+ suggestLogo(c),el('span', { text: label }),el('span', { class: 'wl-suggest-plus', text: '+', 'aria-hidden': 'true' }),]);diff --git a/tests/api-img-proxy.test.js b/tests/api-img-proxy.test.jsindex 3035ab2eb..ce36bba09 100644--- a/tests/api-img-proxy.test.js+++ b/tests/api-img-proxy.test.js@@ -4,7 +4,8 @@//// 1. ?seed=<x> alone yields the on-brand SVG placeholder (no upstream call).// 2. ?meta=<json-uri> resolves the document's `.image` server-side and proxies-// the real artwork bytes back.+// the real artwork bytes back. The document is raced across every IPFS+// gateway like art is, so a metadata URI pinned to a dead gateway resolves.// 3. A metadata `image` that is a data: URI is rejected → placeholder (we never// serve attacker-supplied inline content from our own origin).// 4. A metadata fetch failure falls through to the placeholder, never an error.@@ -30,9 +31,6 @@ vi.mock('../api/_lib/rate-limit.js', () => ({clientIp: vi.fn(() => '127.0.0.1'),}));-const safeFetchJson = vi.fn();-vi.mock('../api/_lib/ssrf.js', () => ({ safeFetchJson: (...a) => safeFetchJson(...a) }));-const fetchModel = vi.fn();vi.mock('../api/_lib/fetch-model.js', () => ({ fetchModel: (...a) => fetchModel(...a) }));@@ -55,10 +53,28 @@ function mockRes() {}beforeEach(() => {- safeFetchJson.mockReset();fetchModel.mockReset();});+// Serve `doc` as a JSON response and `art` as image bytes, keyed by URL, so a+// single mock can satisfy both hops of the follow.+function mockUpstream({ jsonAt = {}, imageAt = {} } = {}) {+ fetchModel.mockImplementation(async (url) => {+ if (url in jsonAt) {+ return {+ bytes: new TextEncoder().encode(JSON.stringify(jsonAt[url])),+ url,+ contentType: 'application/json; charset=utf-8',+ filename: 'token.json',+ };+ }+ if (url in imageAt) {+ return { bytes: imageAt[url], url, contentType: 'image/png', filename: 'art.png' };+ }+ throw new Error(`upstream 404 ${url}`);+ });+}+describe('api/img metadata resolution', () => {it('serves the branded SVG placeholder for a seed-only request', async () => {const res = mockRes();@@ -66,26 +82,19 @@ describe('api/img metadata resolution', () => {expect(res.statusCode).toBe(200);expect(res.headers['content-type']).toMatch(/image\/svg\+xml/);expect(String(res.body)).toContain('<svg');- expect(safeFetchJson).not.toHaveBeenCalled();expect(fetchModel).not.toHaveBeenCalled();});it('resolves .image from token metadata and proxies the real artwork', async () => {- safeFetchJson.mockResolvedValue({- ok: true,- data: { name: 'VOID', image: 'https://cdn.example/art.png' },- });- fetchModel.mockResolvedValue({- bytes: new Uint8Array([1, 2, 3]),- url: 'https://cdn.example/art.png',- contentType: 'image/png',- filename: 'art.png',+ mockUpstream({+ jsonAt: { 'https://meta.example/token.json': { name: 'VOID', image: 'https://cdn.example/art.png' } },+ imageAt: { 'https://cdn.example/art.png': new Uint8Array([1, 2, 3]) },});const res = mockRes();await handler(mockReq('?meta=https%3A%2F%2Fmeta.example%2Ftoken.json&seed=VOID'), res);- expect(safeFetchJson).toHaveBeenCalledWith(+ expect(fetchModel).toHaveBeenCalledWith('https://meta.example/token.json',expect.any(Object),);@@ -100,29 +109,52 @@ describe('api/img metadata resolution', () => {});it('rejects a data: image in metadata and falls back to the placeholder', async () => {- safeFetchJson.mockResolvedValue({- ok: true,- data: { image: 'data:image/svg+xml,<svg onload=alert(1)>' },+ mockUpstream({+ jsonAt: { 'https://meta.example/evil.json': { image: 'data:image/svg+xml,<svg onload=alert(1)>' } },});const res = mockRes();await handler(mockReq('?meta=https%3A%2F%2Fmeta.example%2Fevil.json&seed=EVIL'), res);- expect(fetchModel).not.toHaveBeenCalled();+ expect(fetchModel).toHaveBeenCalledTimes(1); // the document only, never the data: URIexpect(res.statusCode).toBe(200);expect(res.headers['content-type']).toMatch(/image\/svg\+xml/);expect(String(res.body)).toContain('<svg');});it('falls back to the placeholder when the metadata fetch fails', async () => {- safeFetchJson.mockRejectedValue(new Error('ssrf refused'));+ mockUpstream({});const res = mockRes();await handler(mockReq('?meta=https%3A%2F%2Fmeta.example%2Fdown.json&seed=DOWN'), res);expect(res.statusCode).toBe(200);expect(res.headers['content-type']).toMatch(/image\/svg\+xml/);- expect(fetchModel).not.toHaveBeenCalled();+ expect(fetchModel).toHaveBeenCalledTimes(1); // the document only+ });++ it('resolves a metadata URI pinned to a dead gateway through a live one', async () => {+ // pump.fun hands out ipfs.io metadata URIs; ipfs.io now refuses+ // programmatic reads, so the document must come from another gateway.+ const CID = 'bafkreimeta';+ const art = 'https://cdn.example/coin.png';+ fetchModel.mockImplementation(async (url) => {+ if (url.startsWith('https://ipfs.io/')) throw new Error('429 service worker gateway only');+ if (url.endsWith(`/ipfs/${CID}`)) {+ return { bytes: new TextEncoder().encode(JSON.stringify({ image: art })), url, contentType: 'application/json', filename: 'x' };+ }+ if (url === art) return { bytes: new Uint8Array([9]), url, contentType: 'image/png', filename: 'a' };+ throw new Error('nope');+ });++ const res = mockRes();+ await handler(mockReq(`?meta=${encodeURIComponent(`https://ipfs.io/ipfs/${CID}`)}&fallback=none`), res);++ const tried = fetchModel.mock.calls.map((c) => c[0]).filter((u) => u.endsWith(`/ipfs/${CID}`));+ expect(tried.length).toBeGreaterThan(1);+ expect(res.statusCode).toBe(200);+ expect(res.headers['content-type']).toBe('image/png');+ expect([...res.body]).toEqual([9]);});it('400s when no url, meta, or seed is supplied', async () => {@@ -140,7 +172,6 @@ describe('api/img metadata resolution', () => {// the <img>, which is what swaps in the disc.describe('api/img ?fallback=none', () => {beforeEach(() => {- safeFetchJson.mockReset();fetchModel.mockReset();});@@ -184,25 +215,6 @@ describe('api/img ?fallback=none', () => {});});-// Serve `doc` as a JSON response and `art` as image bytes, keyed by URL, so a-// single mock can satisfy both hops of the follow.-function mockUpstream({ jsonAt = {}, imageAt = {} } = {}) {- fetchModel.mockImplementation(async (url) => {- if (url in jsonAt) {- return {- bytes: new TextEncoder().encode(JSON.stringify(jsonAt[url])),- url,- contentType: 'application/json; charset=utf-8',- filename: 'token.json',- };- }- if (url in imageAt) {- return { bytes: imageAt[url], url, contentType: 'image/png', filename: 'art.png' };- }- throw new Error(`upstream 404 ${url}`);- });-}-describe('api/img ?url= metadata follow', () => {const DOC = 'https://meta.example/token.json';const ART = 'https://cdn.example/art.png';@@ -256,11 +268,11 @@ describe('api/img ?url= metadata follow', () => {});it('does not treat a JSON body as artwork on the ?meta= path', async () => {- safeFetchJson.mockResolvedValue({ ok: true, data: { image: DOC } });- mockUpstream({ jsonAt: { [DOC]: { image: ART } }, imageAt: { [ART]: new Uint8Array([5]) } });+ const META = 'https://meta.example/meta.json';+ mockUpstream({ jsonAt: { [META]: { image: DOC }, [DOC]: { image: ART } }, imageAt: { [ART]: new Uint8Array([5]) } });const res = mockRes();- await handler(mockReq(`?meta=${encodeURIComponent(DOC)}&seed=META`), res);+ await handler(mockReq(`?meta=${encodeURIComponent(META)}&seed=META`), res);expect(fetchModel).not.toHaveBeenCalledWith(ART, expect.any(Object));expect(res.headers['content-type']).toMatch(/image\/svg\+xml/);diff --git a/tests/erc8004-gateway-candidates.test.js b/tests/erc8004-gateway-candidates.test.jsindex c6fdaaccf..48c7b0ab0 100644--- a/tests/erc8004-gateway-candidates.test.js+++ b/tests/erc8004-gateway-candidates.test.js@@ -63,8 +63,8 @@ function resolved(overrides = {}) {describe('toManifest gateway candidates', () => {it('leaves image and body.uri exactly as they were', () => {const m = toManifest(resolved({ image: `ipfs://${CID}/a.png`, glbUrl: `ipfs://${CID}/a.glb` }));- expect(m.image).toBe(`https://ipfs.io/ipfs/${CID}/a.png`);- expect(m.body.uri).toBe(`https://ipfs.io/ipfs/${CID}/a.glb`);+ expect(m.image).toBe(`${IPFS_GATEWAYS[0]}${CID}/a.png`);+ expect(m.body.uri).toBe(`${IPFS_GATEWAYS[0]}${CID}/a.glb`);});it('adds a retry chain whose first entry is the single URL beside it', () => {diff --git a/tests/erc8004-metadata-proxy.test.js b/tests/erc8004-metadata-proxy.test.jsindex b3d51fa5d..fe7ea10a1 100644--- a/tests/erc8004-metadata-proxy.test.js+++ b/tests/erc8004-metadata-proxy.test.js@@ -110,7 +110,7 @@ describe('GET /api/erc8004/metadata', () => {pinned.mockResolvedValue({ ok: true, status: 200, text: async () => '{}' });await call({ uri: 'ipfs://bafyagent' });- expect(pinned.mock.calls[0][0]).toBe('https://ipfs.io/ipfs/bafyagent');+ expect(pinned.mock.calls[0][0]).toBe('https://ipfs.filebase.io/ipfs/bafyagent');pinned.mockClear();await call({ uri: 'ar://txid123' });diff --git a/tests/ipfs-gateway-fetch.test.js b/tests/ipfs-gateway-fetch.test.jsindex 2f553cc20..e413b1bc5 100644--- a/tests/ipfs-gateway-fetch.test.js+++ b/tests/ipfs-gateway-fetch.test.js@@ -39,19 +39,28 @@ function stubFetch(plan) {}describe('IPFS_READ_GATEWAYS', () => {- // Cloudflare retired both of its public gateways in 2024 and flk-ipfs.xyz- // stopped accepting connections. A dead host in a fallback chain is worse- // than a missing one: it consumes the retry budget and reports a DNS failure- // as though the document were unretrievable.+ // Cloudflare retired both of its public gateways in 2024, flk-ipfs.xyz+ // stopped accepting connections, and since Oct 2026 ipfs.io, dweb.link,+ // w3s.link and nftstorage.link answer programmatic reads with 429. A dead+ // host in a fallback chain is worse than a missing one: it consumes the retry+ // budget and reports a refusal as though the document were unretrievable.it('lists no retired gateway hosts', () => {- const retired = ['cloudflare-ipfs.com', 'cf-ipfs.com', 'flk-ipfs.xyz'];+ const retired = [+ 'cloudflare-ipfs.com',+ 'cf-ipfs.com',+ 'flk-ipfs.xyz',+ '//ipfs.io',+ 'dweb.link',+ 'w3s.link',+ 'nftstorage.link',+ ];for (const host of retired) {expect(IPFS_READ_GATEWAYS.some((g) => g.includes(host))).toBe(false);}});it('leads with gateways that are independent of the platform and its pinning vendor', () => {- expect(IPFS_READ_GATEWAYS[0]).toContain('ipfs.io');+ expect(IPFS_READ_GATEWAYS[0]).not.toContain('pinata');expect(IPFS_READ_GATEWAYS.some((g) => g.includes('three.ws'))).toBe(false);});@@ -65,17 +74,16 @@ describe('IPFS_READ_GATEWAYS', () => {describe('fetchFromGateways', () => {it('returns the body and the gateway that actually served it', async () => {- stubFetch({ 'ipfs.io': { body: '{"ok":true}' } });+ stubFetch({ 'filebase': { body: '{"ok":true}' } });const got = await fetchFromGateways(CID);expect(JSON.parse(got.text)).toEqual({ ok: true });- expect(got.gateway).toBe(`https://ipfs.io/ipfs/${CID}`);+ expect(got.gateway).toBe(`https://ipfs.filebase.io/ipfs/${CID}`);});it('takes the one gateway holding the document when the rest 504', async () => {stubFetch({- 'ipfs.io': { status: 504 },- 'dweb.link': { status: 504 },- 'w3s.link': { status: 504 },+ 'filebase': { status: 504 },+ '4everland': { status: 504 },'pinata': { body: '{"pinned":true}' },});const got = await fetchFromGateways(CID);@@ -88,9 +96,8 @@ describe('fetchFromGateways', () => {// immediately sat behind the timeouts of the ones that could not.it('queries every gateway concurrently rather than waiting out the slow ones', async () => {const seen = stubFetch({- 'ipfs.io': { delayMs: 60, status: 504 },- 'dweb.link': { delayMs: 60, status: 504 },- 'w3s.link': { delayMs: 60, status: 504 },+ 'filebase': { delayMs: 60, status: 504 },+ '4everland': { delayMs: 60, status: 504 },'pinata': { body: '{"fast":true}' },});const started = Date.now();@@ -99,15 +106,14 @@ describe('fetchFromGateways', () => {expect(got.gateway).toContain('pinata');expect(seen).toHaveLength(IPFS_READ_GATEWAYS.length);- // Serial would have paid all three 60ms delays before reaching the winner.+ // Serial would have paid both 60ms delays before reaching the winner.expect(elapsed).toBeLessThan(120);});it('reports every gateway it tried when none of them serve the CID', async () => {stubFetch({- 'ipfs.io': { status: 504 },- 'dweb.link': { throws: 'ENOTFOUND' },- 'w3s.link': { status: 404 },+ 'filebase': { status: 504 },+ '4everland': { throws: 'ENOTFOUND' },'pinata': { status: 403 },});await expect(fetchFromGateways(CID)).rejects.toMatchObject({ code: 'gateway_unreachable' });@@ -115,7 +121,7 @@ describe('fetchFromGateways', () => {});it('refuses a body larger than the budget the caller set', async () => {- stubFetch({ 'ipfs.io': { body: 'x'.repeat(500), length: 500 } });+ stubFetch({ 'filebase': { body: 'x'.repeat(500), length: 500 } });await expect(fetchFromGateways(CID, { maxBytes: 100 })).rejects.toMatchObject({code: 'gateway_unreachable',});diff --git a/tests/ipfs-image-url-safety.test.js b/tests/ipfs-image-url-safety.test.jsindex 4a25f6406..5f4a5c5c1 100644--- a/tests/ipfs-image-url-safety.test.js+++ b/tests/ipfs-image-url-safety.test.js@@ -137,7 +137,7 @@ describe('proxiedImageURL', () => {const out = proxiedImageURL('https://ipfs.io/ipfs/bafyexample', MINT);expect(out.startsWith('/api/img?')).toBe(true);const q = new URLSearchParams(out.slice(out.indexOf('?') + 1));- expect(q.get('url')).toBe('https://ipfs.io/ipfs/bafyexample');+ expect(q.get('url')).toBe('https://ipfs.filebase.io/ipfs/bafyexample');expect(q.get('seed')).toBe(MINT);});diff --git a/tests/ipfs-uri-candidates.test.js b/tests/ipfs-uri-candidates.test.jsindex 250a98faa..8a2f29956 100644--- a/tests/ipfs-uri-candidates.test.js+++ b/tests/ipfs-uri-candidates.test.js@@ -22,19 +22,24 @@ describe('uriCandidates', () => {});it('re-extracts the CID from a URL whose gateway was already chosen', () => {- const out = uriCandidates('https://ipfs.io/ipfs/bafyCID');+ const out = uriCandidates('https://4everland.io/ipfs/bafyCID');// The caller's own choice stays first (most likely warm in a CDN), and the// other gateways follow as recovery options.- expect(out[0]).toBe('https://ipfs.io/ipfs/bafyCID');+ expect(out[0]).toBe('https://4everland.io/ipfs/bafyCID');expect(out.length).toBeGreaterThan(1);- expect(out.some((url) => url.startsWith('https://dweb.link/ipfs/bafyCID'))).toBe(true);+ expect(out.some((url) => url.startsWith('https://ipfs.filebase.io/ipfs/bafyCID'))).toBe(true);});- it('rewrites a retired gateway host onto a live one', () => {- const out = uriCandidates('https://cloudflare-ipfs.com/ipfs/bafyCID');- expect(out.every((url) => !url.includes('cloudflare-ipfs.com'))).toBe(true);- expect(out.every((url) => url.endsWith('bafyCID'))).toBe(true);- });+ // Cloudflare's gateways fail DNS; ipfs.io and its sibling hosts answer every+ // programmatic read with 429. pump.fun still hands out ipfs.io URLs.+ it.each(['cloudflare-ipfs.com', 'ipfs.io', 'dweb.link', 'w3s.link', 'nftstorage.link'])(+ 'rewrites the retired gateway host %s onto a live one',+ (host) => {+ const out = uriCandidates(`https://${host}/ipfs/bafyCID`);+ expect(out.every((url) => !url.startsWith(`https://${host}/`))).toBe(true);+ expect(out.every((url) => url.endsWith('bafyCID'))).toBe(true);+ },+ );it('returns one entry for a plain URL so callers can loop unconditionally', () => {expect(uriCandidates('https://cdn.example/model.glb')).toEqual(['https://cdn.example/model.glb']);diff --git a/tests/native-launch-endpoint.test.js b/tests/native-launch-endpoint.test.jsindex 4e6f0101f..cca6bea30 100644--- a/tests/native-launch-endpoint.test.js+++ b/tests/native-launch-endpoint.test.js@@ -393,7 +393,7 @@ describe('launches', () => {expect(first.lane).toBe('native');// cf-ipfs.com stopped resolving in 2024, so a stored URL on it has to be// rewritten onto a live gateway before it reaches a client.- expect(first.metadata_uri).toBe('https://dweb.link/ipfs/bafkreiabc');+ expect(first.metadata_uri).toBe('https://ipfs.filebase.io/ipfs/bafkreiabc');expect(first.agent).toEqual({id: 'agent-1',name: 'Scout',diff --git a/tests/solana-agents-crawl.test.js b/tests/solana-agents-crawl.test.jsindex 69d40b822..37a83f95e 100644--- a/tests/solana-agents-crawl.test.js+++ b/tests/solana-agents-crawl.test.js@@ -21,15 +21,15 @@ describe('solana-agents-crawl helpers', () => {describe('resolveGateway', () => {it('rewrites ipfs:// to a https gateway', () => {- expect(resolveGateway('ipfs://bafyhash')).toBe('https://ipfs.io/ipfs/bafyhash');- expect(resolveGateway('ipfs://ipfs/bafyhash')).toBe('https://ipfs.io/ipfs/bafyhash');+ expect(resolveGateway('ipfs://bafyhash')).toBe('https://ipfs.filebase.io/ipfs/bafyhash');+ expect(resolveGateway('ipfs://ipfs/bafyhash')).toBe('https://ipfs.filebase.io/ipfs/bafyhash');});it('rewrites ar:// to arweave', () => {expect(resolveGateway('ar://txid123')).toBe('https://arweave.net/txid123');});it('treats a bare CID as ipfs', () => {const cid = 'QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR';- expect(resolveGateway(cid)).toBe(`https://ipfs.io/ipfs/${cid}`);+ expect(resolveGateway(cid)).toBe(`https://ipfs.filebase.io/ipfs/${cid}`);});it('leaves http(s) URLs untouched and nulls empties', () => {expect(resolveGateway('https://example.com/a.json')).toBe('https://example.com/a.json');diff --git a/tests/src/agent-skills.test.js b/tests/src/agent-skills.test.jsindex 674ccd063..f2f4c26bb 100644--- a/tests/src/agent-skills.test.js+++ b/tests/src/agent-skills.test.js@@ -268,18 +268,18 @@ describe('SkillRegistry – manifest loading', () => {expect(skill.uri).toBe('https://example.com/skill/');});- it('resolves an ipfs:// URI to a dweb.link gateway URL before fetching', async () => {- // ipfs://QmTest → https://dweb.link/ipfs/QmTest/+ it('resolves an ipfs:// URI to the primary gateway URL before fetching', async () => {+ // ipfs://QmTest → https://ipfs.filebase.io/ipfs/QmTest/const fetchFn = makeFetch({- 'dweb.link/ipfs/QmTest/manifest.json': makeResponse(fixtureManifest()),- 'dweb.link/ipfs/QmTest/SKILL.md': makeResponse('', { asText: true }),- 'dweb.link/ipfs/QmTest/tools.json': makeResponse({ tools: [] }),- 'dweb.link/ipfs/QmTest/handlers.js': makeResponse('', { asText: true }),+ 'ipfs.filebase.io/ipfs/QmTest/manifest.json': makeResponse(fixtureManifest()),+ 'ipfs.filebase.io/ipfs/QmTest/SKILL.md': makeResponse('', { asText: true }),+ 'ipfs.filebase.io/ipfs/QmTest/tools.json': makeResponse({ tools: [] }),+ 'ipfs.filebase.io/ipfs/QmTest/handlers.js': makeResponse('', { asText: true }),});const registry = new SkillRegistry({ fetchFn, trust: 'any' });const skill = await registry.install({ uri: 'ipfs://QmTest' });expect(skill).toBeDefined();- expect(skill.uri).toContain('dweb.link/ipfs/QmTest');+ expect(skill.uri).toContain('ipfs.filebase.io/ipfs/QmTest');});});