SIWE auth, API proxy fixes, dashboard, login, usage pages
- SIWE auth flow: challenge/login/logout/me API routes + JWT middleware
- Fixed [...path] catch-all: Kubo proxy with matchRoute() + mapToKuboAPI()
- Fixed session_id → nonce field mismatch in AuthProvider
- Fixed dashboard pins crash: Kubo returns {Keys: {...}}, not array
- Added middleware route guard (307 redirect to /login)
- Added login, register, profile, usage, upload pages
- Added dashboard components (StorageGauge, FreeTierProgress)
- Added SWR hooks + AuthGuard + Providers + Toast/ErrorBoundary
- Added payment integration (smart contract ABI, tiers, tokens)
- Fixed IPNS key listing: Name/Id → name/id mapping
- Added PWA support (manifest, service worker, icons)
- Added tests for helpers, limits, search-index, wallet
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/* ════════════════════════════ Download ════════════════════════════
|
||||
* Utility om IPFS content te downloaden als bestand.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Download een bestand van IPFS via de explorer/cat proxy.
|
||||
* Maakt een Blob van de response en simuleert een klik op <a download>.
|
||||
*/
|
||||
export async function downloadFile(cid: string, filename?: string): Promise<void> {
|
||||
const res = await fetch(`/api/explorer/cat/${encodeURIComponent(cid)}`);
|
||||
if (!res.ok) throw new Error(`Download mislukt (${res.status})`);
|
||||
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
const ext = filename?.includes('.') ? '' : '.bin';
|
||||
const name = filename || `${cid.slice(0, 12)}${ext}`;
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = name;
|
||||
a.rel = 'noopener noreferrer';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
|
||||
// Cleanup
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download via gateway (alternatief als proxy traag is).
|
||||
*/
|
||||
export function downloadViaGateway(cid: string, filename?: string) {
|
||||
const gateway = process.env.NEXT_PUBLIC_GATEWAY_URL || 'https://maos.dedyn.io';
|
||||
const a = document.createElement('a');
|
||||
a.href = `${gateway}/ipfs/${cid}`;
|
||||
a.download = filename || cid;
|
||||
a.target = '_blank';
|
||||
a.rel = 'noopener noreferrer';
|
||||
a.click();
|
||||
}
|
||||
Reference in New Issue
Block a user