c9432a16ba
- 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
20 lines
743 B
TypeScript
20 lines
743 B
TypeScript
/* ── Format bytes to human-readable size ── */
|
|
export function formatBytes(bytes: number): string {
|
|
if (bytes === 0) return '0 B';
|
|
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
|
|
const val = bytes / Math.pow(1024, i);
|
|
return val < 10 ? val.toFixed(1) + ' ' + units[i] : Math.round(val) + ' ' + units[i];
|
|
}
|
|
|
|
/* ── Gateway link for CID ── */
|
|
export function gatewayLink(cid: string): string {
|
|
return `https://maos.dedyn.io/ipfs/${cid}`;
|
|
}
|
|
|
|
/* ── Truncate CID for display ── */
|
|
export function truncateCid(cid: string, chars: number = 12): string {
|
|
if (cid.length <= chars) return cid;
|
|
return `${cid.slice(0, chars)}...`;
|
|
}
|