/** * Storefront client for Space Data Network * * Provides methods for interacting with the SDN marketplace: * - Browse and search listings * - Purchase data access * - Manage subscriptions * - Post reviews */ import type { Listing, AccessGrant, PurchaseRequest, Review, ReviewStats, SearchQuery, SearchResult, CreditsBalance, CreateListingRequest, CreatePurchaseRequest, CreateReviewRequest, PurchaseStatus, PaymentMethod, FiatGatewayRequest, FiatGatewayResult, CreditsTransaction, SellerDashboard, BuyerDashboard, TrustScore, ManualDevPaymentConfirmation, ManualDevPaymentResult, PaymentAuditEvent, CreateCryptoIntentRequest, CryptoBuyerIntent, SubmitCryptoPaymentRequest, UsageSummary, Invoice } from './types'; export interface DeliveryTopicSubscription { unsubscribe?: () => void | Promise; } export type DeliveryTopicMessage = Uint8Array | ArrayBuffer | { data?: Uint8Array | ArrayBuffer; payload?: Uint8Array | ArrayBuffer; }; export interface StorefrontPubSub { subscribe(topic: string, handler: (message: DeliveryTopicMessage) => void | Promise): void | DeliveryTopicSubscription | Promise; } export interface StorefrontLibp2pPubSub { subscribe(topic: string): void | Promise; unsubscribe?(topic: string): void | Promise; addEventListener(type: 'message', listener: (event: unknown) => void, options?: { signal?: AbortSignal; }): void; removeEventListener?(type: 'message', listener: (event: unknown) => void): void; } export interface DeliverySubscription { grantId: string; topic: string; unsubscribe: () => Promise; } /** Storefront client configuration */ export interface StorefrontClientConfig { /** API base URL for server-side operations */ apiBaseUrl?: string; /** PubSub instance for real-time updates */ pubsub?: StorefrontPubSub; /** Peer ID for this client */ peerId: string; /** Signing function for requests */ sign?: (data: Uint8Array) => Promise; /** Encryption public key for receiving data */ encryptionPubkey?: Uint8Array; /** Key algorithm (x25519, secp256k1, p256) */ keyAlgorithm?: string; } /** Storefront events */ export interface StorefrontEvents { 'listing:new': Listing; 'listing:updated': Listing; 'purchase:status': { requestId: string; status: PurchaseStatus; }; 'grant:issued': AccessGrant; 'data:received': { grantId: string; data: Uint8Array; }; 'data:subscribed': { grantId: string; topic: string; }; } /** Event handler type */ type EventHandler = (event: T) => void; /** * Storefront client for interacting with SDN marketplace */ export declare class StorefrontClient { private config; private eventHandlers; constructor(config: StorefrontClientConfig); /** * Search for listings */ searchListings(query: SearchQuery): Promise; /** * Get a listing by ID */ getListing(listingId: string): Promise; /** * Create a new listing (for providers) */ createListing(request: CreateListingRequest): Promise; /** * Update a listing */ updateListing(listingId: string, updates: Partial): Promise; /** * Deactivate a listing */ deactivateListing(listingId: string): Promise; /** * Create a purchase request */ createPurchase(request: CreatePurchaseRequest): Promise; /** * Confirm a crypto payment */ confirmCryptoPayment(requestId: string, txHash: string, chain: string): Promise; /** * Create a server-authored crypto buyer intent for a purchase. */ createCryptoBuyerIntent(requestId: string, request: CreateCryptoIntentRequest): Promise; /** * Submit a crypto transaction reference against a server-created buyer intent. */ submitCryptoPayment(requestId: string, request: SubmitCryptoPaymentRequest): Promise; /** * Pay with SDN credits */ payWithCredits(requestId: string): Promise; /** * Get purchase status */ getPurchaseStatus(requestId: string): Promise; /** * Get access grants for the current buyer */ getMyGrants(): Promise; /** * Get a specific grant */ getGrant(grantId: string): Promise; /** * Create a review */ createReview(request: CreateReviewRequest): Promise; /** * Get reviews for a listing */ getListingReviews(listingId: string, limit?: number, offset?: number): Promise<{ reviews: Review[]; stats: ReviewStats; }>; /** * Vote on a review's helpfulness */ voteReview(reviewId: string, helpful: boolean): Promise; /** * Get credits balance */ getCreditsBalance(): Promise; /** * Purchase credits (returns payment intent or address) */ purchaseCredits(amount: number, paymentMethod: PaymentMethod): Promise<{ paymentTarget: string; }>; /** * Subscribe to real-time events */ on(event: K, handler: EventHandler): void; /** * Unsubscribe from events */ off(event: K, handler: EventHandler): void; /** * Initiate a fiat payment via Stripe gateway */ createFiatPayment(requestId: string, req: FiatGatewayRequest): Promise; /** * Complete a purchase with an explicit manual/dev paid state. */ completeManualDevPayment(requestId: string, confirmation?: ManualDevPaymentConfirmation): Promise; /** * Get payment/grant audit history for a purchase. */ getPurchaseAudit(requestId: string): Promise; /** * Get credits transaction history */ getCreditsTransactions(limit?: number, offset?: number): Promise; /** * Subscribe to a data delivery stream for a grant */ subscribeToDelivery(grantId: string): Promise; /** * Get the seller dashboard data */ getSellerDashboard(): Promise; /** * Get the buyer dashboard data */ getBuyerDashboard(): Promise; /** * Respond to a review (as a provider) */ respondToReview(reviewId: string, response: string): Promise; /** * Get provider trust score */ getProviderTrust(peerId: string): Promise; /** * Get usage summary for a listing/buyer over a date range. * GET /storefront/usage/{listingId}/summary?buyer={peerId}&from={from}&to={to} */ getUsageSummary(listingId: string, from: string, to: string): Promise; /** * List invoices for the authenticated buyer. * GET /storefront/invoices?buyer={peerId}&limit={limit}&offset={offset} */ getMyInvoices(limit?: number, offset?: number): Promise; /** * Get a single invoice by ID. * GET /storefront/invoices/{invoiceId} */ getInvoice(invoiceId: string): Promise; /** * Start listening for PubSub messages */ startListening(): Promise; /** * Stop listening */ stopListening(): Promise; /** * Emit an event to registered handlers */ private emit; } /** * Create a storefront client */ export declare function createStorefrontClient(config: StorefrontClientConfig): StorefrontClient; export declare function createStorefrontLibp2pPubSubAdapter(pubsub: StorefrontLibp2pPubSub): StorefrontPubSub; export {}; //# sourceMappingURL=client.d.ts.map