/* ── IPFS Portal API — IPFS Explorer ── */ import { apiFetch, API_BASE } from './client'; export interface IPFSEntry { name: string; type: 'file' | 'dir'; size: number; hash: string; } export async function explorerLs(cid: string): Promise { return apiFetch(`/explorer/ls/${encodeURIComponent(cid)}`, { method: 'POST' }); } export async function explorerCat(cid: string): Promise { const res = await fetch(`${API_BASE}/api/explorer/cat/${encodeURIComponent(cid)}`, { method: 'POST', credentials: 'include', }); if (!res.ok) { const text = await res.text().catch(() => ''); throw new Error(`${res.status} ${res.statusText}: ${text.slice(0, 200)}`); } return res.text(); } export async function explorerStat(cid: string): Promise> { return apiFetch(`/explorer/stat/${encodeURIComponent(cid)}`, { method: 'POST' }); }