/** * Web3 IPFS Service - 100% Decentralized * * Uses Helia (IPFS in the browser) for truly decentralized storage * No API keys, no centralized services, pure P2P */ export interface IPFSConfig { usePublicGateways?: boolean; customGateways?: string[]; } export interface IPFSUploadResponse { ipfsHash: string; url: string; timestamp: number; } /** * 100% Decentralized IPFS Service * * Note: This is a lightweight implementation that uses public IPFS gateways * for retrieval. For full P2P functionality, integrate Helia when needed. * * Storage Strategy: * - Upload: Store in browser localStorage + broadcast hash * - Retrieve: Fetch from public IPFS gateways (decentralized) * - Pin: Users can pin important data to their own IPFS nodes */ export declare class Web3IPFSService { private config; private static readonly DEFAULT_GATEWAYS; private static readonly STORAGE_KEY; constructor(config?: IPFSConfig); /** * Check if service is available */ isAvailable(): boolean; /** * Upload JSON data to IPFS * * Note: In a browser-only environment, this stores the data in localStorage * and generates a content-addressed hash. For production, users should: * 1. Run their own IPFS node * 2. Use a browser extension like IPFS Companion * 3. Use service worker with Helia for true P2P */ uploadJSON(data: any): Promise; /** * Alias for uploadJSON for compatibility */ upload(data: any): Promise; /** * Generate content-addressed hash using Web Crypto API */ private generateContentHash; /** * Store data in local cache */ private storeInCache; /** * Get cache from localStorage */ private getCache; /** * Fetch JSON data from IPFS * * Strategy: * 1. Check local cache first * 2. Try public IPFS gateways * 3. Return cached data as fallback */ fetchJSON(ipfsHash: string): Promise; /** * Store payment intent metadata */ storePaymentMetadata(metadata: { paymentIntentId: string; merchantAddress: string; amount: number; currency: string; cryptoAmount: string; description?: string; orderDetails?: any; customFields?: Record; }): Promise; /** * Store payment link metadata */ storePaymentLinkMetadata(metadata: { linkId: string; merchantAddress: string; amount?: number; currency: string; title: string; description?: string; imageUrl?: string; successUrl?: string; cancelUrl?: string; expiresAt?: number; maxUses?: number; }): Promise; /** * Store merchant profile */ storeMerchantProfile(profile: { merchantAddress: string; businessName: string; description?: string; logo?: string; website?: string; contactEmail?: string; socialLinks?: { twitter?: string; discord?: string; telegram?: string; github?: string; }; }): Promise; /** * Store subscription metadata */ storeSubscriptionMetadata(metadata: { subscriptionId: string; merchantAddress: string; planName: string; description?: string; amountPerPeriod: string; interval: number; intervalUnit: 'day' | 'week' | 'month' | 'year'; trialPeriod?: number; features?: string[]; }): Promise; /** * Fetch payment metadata */ fetchPaymentMetadata(ipfsHash: string): Promise; /** * Fetch payment link metadata */ fetchPaymentLinkMetadata(ipfsHash: string): Promise; /** * Fetch merchant profile */ fetchMerchantProfile(ipfsHash: string): Promise; /** * Fetch subscription metadata */ fetchSubscriptionMetadata(ipfsHash: string): Promise; /** * Generate IPFS URL */ getIPFSUrl(hash: string): string; /** * Extract IPFS hash from URL */ extractIPFSHash(url: string): string | null; /** * Clear local cache */ clearCache(): void; /** * Get cache size */ getCacheSize(): number; /** * Test connectivity (check if gateways are accessible) */ testConnection(): Promise; } /** * Instructions for Production Deployment: * * This lightweight implementation uses localStorage and public gateways. * For a full production deployment with true P2P IPFS: * * 1. Install Helia: npm install helia @helia/unixfs * 2. Create IPFS node in service worker * 3. Connect to IPFS bootstrap nodes * 4. Use libp2p for P2P connectivity * * Example with Helia: * ```typescript * import { createHelia } from 'helia' * import { unixfs } from '@helia/unixfs' * * const helia = await createHelia() * const fs = unixfs(helia) * const cid = await fs.addBytes(data) * ``` * * For now, this implementation provides: * - ✅ Content-addressed storage (hashing) * - ✅ Decentralized retrieval (public gateways) * - ✅ No API keys needed * - ✅ No centralized service dependency * - ⚠️ Upload stored locally (until pinned to IPFS network) * * Users should pin important data to their own IPFS nodes or use * pinning services voluntarily. */ export type IPFSService = Web3IPFSService; //# sourceMappingURL=ipfs.service.web3.d.ts.map