@proofrails/sdk 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/common.ts","../src/client.ts","../src/modules/projects.ts","../src/modules/receipts.ts","../src/modules/verification.ts","../src/modules/statements.ts","../src/modules/events.ts","../src/modules/embed.ts","../src/templates/payment.ts","../src/templates/donation.ts","../src/templates/escrow.ts","../src/templates/grant.ts","../src/templates/refund.ts","../src/sdk.ts","../src/react.ts"],"names":[],"mappings":";;;;;AAsCO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EACvC,WAAA,CACI,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACT;AACE,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EAChB;AACJ,CAAA;;;AClCO,IAAM,YAAN,MAAgB;AAAA,EASnB,WAAA,CAAY,MAAA,GAAoB,EAAC,EAAG;AAFpC,IAAA,IAAA,CAAQ,aAAA,GAAsC,IAAA;AAI1C,IAAA,MAAM,UAAA,GAAa,OAAO,OAAA,KAAY,WAAA,IAAe,QAAQ,GAAA,EAAK,+BAAA;AAGlE,IAAA,MAAM,cAAA,GAAiB,kDAAA;AAEvB,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA,CAAO,OAAA,IAAW,UAAA,IAAc,cAAA;AAC/C,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AACrB,IAAA,IAAA,CAAK,aAAa,MAAA,CAAO,UAAA;AACzB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAO,OAAA,IAAW,GAAA;AACjC,IAAA,IAAA,CAAK,OAAA,GAAU,OA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AAA;AAEA,EAAA,OAAO;AAAA,IACH,aAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,GACJ;AACJ","file":"react.mjs","sourcesContent":["/**\r\n * Common types used across the SDK\r\n */\r\n\r\nexport type Network = 'coston2' | 'flare';\r\n\r\nexport type ReceiptStatus = 'pending' | 'anchored' | 'failed';\r\n\r\nexport interface SDKConfig {\r\n /** Your ProofRails API key */\r\n apiKey?: string;\r\n /** Admin token for administrative operations */\r\n adminToken?: string;\r\n /** Network to use (coston2 or flare) */\r\n network?: Network;\r\n /** Base URL of the middleware (optional, defaults to production) */\r\n baseUrl?: string;\r\n /** Request timeout in milliseconds */\r\n timeout?: number;\r\n /** Number of retry attempts for failed requests (default: 3) */\r\n retries?: number;\r\n /** Delay between retries in milliseconds (default: 1000) */\r\n retryDelay?: number;\r\n}\r\n\r\nexport interface APIResponse<T> {\r\n data: T;\r\n success: boolean;\r\n error?: string;\r\n}\r\n\r\nexport interface PaginatedResponse<T> {\r\n items: T[];\r\n total: number;\r\n page: number;\r\n limit: number;\r\n}\r\n\r\nexport class ProofRailsError extends Error {\r\n constructor(\r\n message: string,\r\n public code?: string,\r\n public statusCode?: number,\r\n public details?: unknown\r\n ) {\r\n super(message);\r\n this.name = 'ProofRailsError';\r\n }\r\n}\r\n","/**\r\n * Core HTTP client for ProofRails API\r\n */\r\n\r\nimport type { SDKConfig } from './types/common';\r\nimport { ProofRailsError } from './types/common';\r\n\r\nexport interface RateLimitInfo {\r\n limit: number;\r\n remaining: number;\r\n reset: number; // Unix timestamp\r\n resetDate: Date;\r\n}\r\n\r\nexport class APIClient {\r\n private baseUrl: string;\r\n private apiKey?: string;\r\n private adminToken?: string;\r\n private timeout: number;\r\n private retries: number;\r\n private retryDelay: number;\r\n private rateLimitInfo: RateLimitInfo | null = null;\r\n\r\n constructor(config: SDKConfig = {}) {\r\n // Read from environment variable if available (Next.js)\r\n const envBaseUrl = typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_PROOFRAILS_BASE_URL;\r\n\r\n // Production API endpoint\r\n const defaultBaseUrl = 'https://proofrails-clone-middleware.onrender.com';\r\n\r\n this.baseUrl = config.baseUrl || envBaseUrl || defaultBaseUrl;\r\n this.apiKey = config.apiKey;\r\n this.adminToken = config.adminToken;\r\n this.timeout = config.timeout || 30000;\r\n this.retries = config.retries ?? 3; // Default 3 retries\r\n this.retryDelay = config.retryDelay ?? 1000; // Default 1s delay\r\n }\r\n\r\n getRateLimitInfo(): RateLimitInfo | null {\r\n return this.rateLimitInfo;\r\n }\r\n\r\n async get<T>(endpoint: string, options: RequestInit = {}): Promise<T> {\r\n return this.request<T>('GET', endpoint, undefined, options);\r\n }\r\n\r\n async post<T>(endpoint: string, body?: unknown, options: RequestInit = {}): Promise<T> {\r\n return this.request<T>('POST', endpoint, body, options);\r\n }\r\n\r\n async put<T>(endpoint: string, body?: unknown, options: RequestInit = {}): Promise<T> {\r\n return this.request<T>('PUT', endpoint, body, options);\r\n }\r\n\r\n async delete<T>(endpoint: string, options: RequestInit = {}): Promise<T> {\r\n return this.request<T>('DELETE', endpoint, undefined, options);\r\n }\r\n\r\n private async request<T>(\r\n method: string,\r\n endpoint: string,\r\n body?: unknown,\r\n options: RequestInit = {},\r\n attempt: number = 0\r\n ): Promise<T> {\r\n const url = `${this.baseUrl}${endpoint}`;\r\n const headers: Record<string, string> = {\r\n 'Content-Type': 'application/json',\r\n ...((options.headers as Record<string, string>) || {}),\r\n };\r\n\r\n if (this.apiKey) {\r\n headers['X-API-Key'] = this.apiKey;\r\n }\r\n\r\n if (this.adminToken) {\r\n headers['Authorization'] = `Bearer ${this.adminToken}`;\r\n }\r\n\r\n const controller = new AbortController();\r\n const timeoutId = setTimeout(() => controller.abort(), this.timeout);\r\n\r\n try {\r\n console.log(`[ProofRails SDK] ${method} ${url}${attempt > 0 ? ` (retry ${attempt}/${this.retries})` : ''}`);\r\n const response = await fetch(url, {\r\n method,\r\n headers,\r\n body: body ? JSON.stringify(body) : undefined,\r\n signal: controller.signal,\r\n ...options,\r\n });\r\n\r\n clearTimeout(timeoutId);\r\n\r\n // Extract rate limit info from headers\r\n this.extractRateLimitInfo(response);\r\n\r\n if (!response.ok) {\r\n const errorData = await response.json().catch(() => ({}));\r\n const error = new ProofRailsError(\r\n errorData.message || errorData.detail || `HTTP ${response.status}: ${response.statusText}`,\r\n errorData.code,\r\n response.status,\r\n errorData\r\n );\r\n\r\n // Retry on 5xx errors or rate limit (429)\r\n if (this.shouldRetry(response.status, attempt)) {\r\n return this.retryRequest(method, endpoint, body, options, attempt);\r\n }\r\n\r\n throw error;\r\n }\r\n\r\n return await response.json();\r\n } catch (error) {\r\n clearTimeout(timeoutId);\r\n\r\n if (error instanceof ProofRailsError) {\r\n // Retry on network errors\r\n if (this.shouldRetry(0, attempt)) {\r\n return this.retryRequest(method, endpoint, body, options, attempt);\r\n }\r\n throw error;\r\n }\r\n\r\n if (error instanceof Error) {\r\n if (error.name === 'AbortError') {\r\n throw new ProofRailsError(`Request timeout after ${this.timeout}ms`, 'TIMEOUT');\r\n }\r\n\r\n // Retry on network errors\r\n if (this.shouldRetry(0, attempt)) {\r\n return this.retryRequest(method, endpoint, body, options, attempt);\r\n }\r\n\r\n throw new ProofRailsError(error.message, 'NETWORK_ERROR');\r\n }\r\n\r\n throw new ProofRailsError('Unknown error occurred', 'UNKNOWN_ERROR');\r\n }\r\n }\r\n\r\n private shouldRetry(statusCode: number, attempt: number): boolean {\r\n if (attempt >= this.retries) return false;\r\n\r\n // Retry on network errors (statusCode 0)\r\n if (statusCode === 0) return true;\r\n\r\n // Retry on 5xx server errors\r\n if (statusCode >= 500 && statusCode < 600) return true;\r\n\r\n // Retry on rate limit (429)\r\n if (statusCode === 429) return true;\r\n\r\n return false;\r\n }\r\n\r\n private async retryRequest<T>(\r\n method: string,\r\n endpoint: string,\r\n body: unknown,\r\n options: RequestInit,\r\n attempt: number\r\n ): Promise<T> {\r\n const delay = this.retryDelay * Math.pow(2, attempt); // Exponential backoff\r\n console.log(`[ProofRails SDK] Retrying in ${delay}ms...`);\r\n await new Promise(resolve => setTimeout(resolve, delay));\r\n return this.request<T>(method, endpoint, body, options, attempt + 1);\r\n }\r\n\r\n private extractRateLimitInfo(response: Response): void {\r\n const limit = response.headers.get('X-RateLimit-Limit');\r\n const remaining = response.headers.get('X-RateLimit-Remaining');\r\n const reset = response.headers.get('X-RateLimit-Reset');\r\n\r\n if (limit && remaining && reset) {\r\n const resetTimestamp = parseInt(reset, 10);\r\n this.rateLimitInfo = {\r\n limit: parseInt(limit, 10),\r\n remaining: parseInt(remaining, 10),\r\n reset: resetTimestamp,\r\n resetDate: new Date(resetTimestamp * 1000)\r\n };\r\n }\r\n }\r\n\r\n setApiKey(apiKey: string): void {\r\n this.apiKey = apiKey;\r\n }\r\n\r\n setAdminToken(adminToken: string): void {\r\n this.adminToken = adminToken;\r\n }\r\n\r\n getBaseUrl(): string {\r\n return this.baseUrl;\r\n }\r\n}\r\n","/**\r\n * Project and API key management module\r\n */\r\n\r\nimport type { APIClient } from '../client';\r\nimport type {\r\n Project,\r\n APIKey,\r\n CreateProjectOptions,\r\n CreateAPIKeyOptions,\r\n WhoAmIResponse,\r\n} from '../types/project';\r\n\r\nexport class ProjectsModule {\r\n constructor(private client: APIClient) { }\r\n\r\n async getInfo(): Promise<WhoAmIResponse> {\r\n return this.client.get<WhoAmIResponse>('/v1/whoami');\r\n }\r\n\r\n async rotateKey(): Promise<APIKey> {\r\n return this.client.post<APIKey>('/v1/api-keys/rotate');\r\n }\r\n\r\n async create(options: CreateProjectOptions = {}): Promise<APIKey> {\r\n return this.client.post<APIKey>('/v1/public/api-keys', options);\r\n }\r\n}\r\n\r\nexport class AdminModule {\r\n constructor(private client: APIClient) { }\r\n\r\n async createKey(options: CreateAPIKeyOptions): Promise<APIKey> {\r\n return this.client.post<APIKey>('/v1/admin/api-keys', options);\r\n }\r\n\r\n async deleteKey(keyId: string): Promise<void> {\r\n return this.client.delete(`/v1/admin/api-keys/${keyId}`);\r\n }\r\n}\r\n","/**\r\n * Receipt operations module\r\n */\r\n\r\nimport type { APIClient } from '../client';\r\nimport type {\r\n CreateReceiptOptions,\r\n Receipt,\r\n ReceiptArtifacts,\r\n ListReceiptsOptions,\r\n} from '../types/receipt';\r\nimport type { PaginatedResponse } from '../types/common';\r\nimport type { ISOMessage } from '../types/iso';\r\n\r\nexport class ReceiptsModule {\r\n constructor(private client: APIClient) { }\r\n\r\n async create(options: CreateReceiptOptions): Promise<Receipt> {\r\n const payload = {\r\n tip_tx_hash: options.transactionHash,\r\n chain: options.chain,\r\n amount: String(options.amount),\r\n currency: options.currency,\r\n sender_wallet: options.sender,\r\n receiver_wallet: options.receiver,\r\n reference: options.reference,\r\n callback_url: options.callbackUrl,\r\n };\r\n\r\n const response = await this.client.post<{ receipt_id: string; status: string }>(\r\n '/v1/iso/record-tip',\r\n payload\r\n );\r\n\r\n return {\r\n id: response.receipt_id,\r\n status: response.status as any,\r\n transactionHash: options.transactionHash,\r\n chain: options.chain,\r\n amount: String(options.amount),\r\n currency: options.currency,\r\n sender: options.sender,\r\n receiver: options.receiver,\r\n reference: options.reference,\r\n createdAt: new Date().toISOString(),\r\n };\r\n }\r\n\r\n async get(receiptId: string): Promise<Receipt> {\r\n return this.client.get<Receipt>(`/v1/iso/receipts/${receiptId}`);\r\n }\r\n\r\n async list(options: ListReceiptsOptions = {}): Promise<PaginatedResponse<Receipt>> {\r\n const params = new URLSearchParams();\r\n if (options.limit) params.append('limit', String(options.limit));\r\n if (options.page) params.append('page', String(options.page));\r\n if (options.status) params.append('status', options.status);\r\n\r\n const query = params.toString();\r\n const endpoint = `/v1/iso/receipts${query ? `?${query}` : ''}`;\r\n\r\n // Check if response is array (direct list) or object (paginated)\r\n const response: any = await this.client.get(endpoint);\r\n const items = Array.isArray(response) ? response : (response.items || []);\r\n\r\n return {\r\n items: items,\r\n total: items.length,\r\n page: options.page || 1,\r\n limit: options.limit || 10,\r\n };\r\n }\r\n\r\n async getArtifacts(receiptId: string): Promise<ReceiptArtifacts> {\r\n const messages = await this.client.get<ISOMessage[]>(`/v1/iso/messages/${receiptId}`);\r\n const baseUrl = this.client.getBaseUrl();\r\n\r\n const artifacts: ReceiptArtifacts = {};\r\n\r\n messages.forEach((msg) => {\r\n switch (msg.type) {\r\n case 'pain.001':\r\n artifacts.pain001Url = msg.url;\r\n break;\r\n case 'pain.002':\r\n artifacts.pain002Url = msg.url;\r\n break;\r\n case 'pain.007':\r\n artifacts.pain007Url = msg.url;\r\n break;\r\n case 'pain.008':\r\n artifacts.pain008Url = msg.url;\r\n break;\r\n case 'camt.054':\r\n artifacts.camt054Url = msg.url;\r\n break;\r\n }\r\n });\r\n\r\n artifacts.bundleUrl = `${baseUrl}/files/${receiptId}/evidence.zip`;\r\n artifacts.manifestUrl = `${baseUrl}/files/${receiptId}/manifest.json`;\r\n\r\n return artifacts;\r\n }\r\n}\r\n","/**\r\n * Verification module\r\n */\r\n\r\nimport type { APIClient } from '../client';\r\nimport type { VerificationResult, VerificationProof } from '../types/verification';\r\n\r\nexport class VerificationModule {\r\n constructor(private client: APIClient) { }\r\n\r\n async byReceiptId(receiptId: string): Promise<VerificationResult> {\r\n const receipt = await this.client.get<any>(`/v1/iso/receipts/${receiptId}`);\r\n\r\n return {\r\n valid: receipt.status === 'anchored',\r\n bundleHash: receipt.bundle_hash || receipt.bundleHash || '',\r\n onChain: !!receipt.anchor_tx || !!receipt.anchorTx,\r\n anchorTx: receipt.anchor_tx || receipt.anchorTx,\r\n timestamp: receipt.anchored_at || receipt.anchoredAt,\r\n };\r\n }\r\n\r\n async byUrl(bundleUrl: string): Promise<VerificationResult> {\r\n return this.client.post<VerificationResult>('/v1/iso/verify', {\r\n bundle_url: bundleUrl,\r\n });\r\n }\r\n\r\n async byHash(bundleHash: string): Promise<VerificationResult> {\r\n return this.client.post<VerificationResult>('/v1/iso/verify', {\r\n bundle_hash: bundleHash,\r\n });\r\n }\r\n\r\n async getProof(receiptId: string): Promise<VerificationProof> {\r\n const receipt = await this.client.get<any>(`/v1/iso/receipts/${receiptId}`);\r\n\r\n return {\r\n receiptId,\r\n bundleHash: receipt.bundle_hash || receipt.bundleHash,\r\n anchorTx: receipt.anchor_tx || receipt.anchorTx,\r\n blockNumber: receipt.block_number || 0,\r\n timestamp: receipt.anchored_at || receipt.anchoredAt,\r\n signature: receipt.signature || '',\r\n network: receipt.chain,\r\n contractAddress: receipt.contract_address || '',\r\n };\r\n }\r\n}\r\n","/**\r\n * Statements module\r\n */\r\n\r\nimport type { APIClient } from '../client';\r\nimport type { GenerateStatementOptions, Statement } from '../types/iso';\r\n\r\nexport class StatementsModule {\r\n constructor(private client: APIClient) { }\r\n\r\n async intraday(options: GenerateStatementOptions = {}): Promise<Statement> {\r\n const response = await this.client.post<any>('/v1/iso/statement/camt052', {\r\n date_from: options.dateFrom,\r\n date_to: options.dateTo,\r\n account_id: options.accountId,\r\n });\r\n\r\n return {\r\n type: 'camt.052',\r\n url: response.url,\r\n downloadUrl: response.download_url || response.url,\r\n messageId: response.message_id || response.messageId,\r\n createdAt: response.created_at || new Date().toISOString(),\r\n };\r\n }\r\n\r\n async endOfDay(options: GenerateStatementOptions = {}): Promise<Statement> {\r\n const response = await this.client.post<any>('/v1/iso/statement/camt053', {\r\n date: options.dateTo || options.dateFrom,\r\n account_id: options.accountId,\r\n });\r\n\r\n return {\r\n type: 'camt.053',\r\n url: response.url,\r\n downloadUrl: response.download_url || response.url,\r\n messageId: response.message_id || response.messageId,\r\n createdAt: response.created_at || new Date().toISOString(),\r\n };\r\n }\r\n}\r\n","/**\r\n * Events module for live updates\r\n */\r\n\r\nimport type { APIClient } from '../client';\r\nimport type { ReceiptUpdate } from '../types/receipt';\r\n\r\nexport interface EventListener {\r\n stop: () => void;\r\n}\r\n\r\nexport class EventsModule {\r\n constructor(private client: APIClient) { }\r\n\r\n listen(receiptId: string, callback: (update: ReceiptUpdate) => void): EventListener {\r\n const baseUrl = this.client.getBaseUrl();\r\n const url = `${baseUrl}/v1/iso/events/${receiptId}`;\r\n\r\n const eventSource = new EventSource(url);\r\n\r\n eventSource.onmessage = (event) => {\r\n try {\r\n const data = JSON.parse(event.data);\r\n callback({\r\n id: receiptId,\r\n status: data.status,\r\n anchorTx: data.anchor_tx || data.anchorTx,\r\n bundleHash: data.bundle_hash || data.bundleHash,\r\n timestamp: data.timestamp || new Date().toISOString(),\r\n });\r\n } catch (error) {\r\n console.error('Failed to parse SSE event:', error);\r\n }\r\n };\r\n\r\n eventSource.onerror = (error) => {\r\n console.error('SSE connection error:', error);\r\n eventSource.close();\r\n };\r\n\r\n return {\r\n stop: () => eventSource.close(),\r\n };\r\n }\r\n}\r\n","/**\r\n * Embed module for generating embeddable widgets\r\n */\r\n\r\nimport type { APIClient } from '../client';\r\n\r\nexport interface EmbedOptions {\r\n theme?: 'light' | 'dark';\r\n width?: string;\r\n height?: string;\r\n}\r\n\r\nexport interface WidgetResult {\r\n iframeHtml: string;\r\n embedUrl: string;\r\n}\r\n\r\nexport class EmbedModule {\r\n constructor(private client: APIClient) { }\r\n\r\n widget(receiptId: string, options: EmbedOptions = {}): WidgetResult {\r\n const baseUrl = this.client.getBaseUrl();\r\n const theme = options.theme || 'light';\r\n const width = options.width || '100%';\r\n const height = options.height || '400px';\r\n\r\n const embedUrl = `${baseUrl}/embed/receipt?rid=${receiptId}&theme=${theme}`;\r\n\r\n const iframeHtml = `<iframe src=\"${embedUrl}\" width=\"${width}\" height=\"${height}\" frameborder=\"0\" style=\"border: none;\"></iframe>`;\r\n\r\n return {\r\n iframeHtml,\r\n embedUrl,\r\n };\r\n }\r\n\r\n fullPage(receiptId: string): string {\r\n const baseUrl = this.client.getBaseUrl();\r\n return `${baseUrl}/receipt/${receiptId}`;\r\n }\r\n}\r\n","/**\r\n * Payment template - For simple payments between two parties\r\n */\r\n\r\nimport type { ReceiptsModule } from '../modules/receipts';\r\nimport type { Receipt } from '../types/receipt';\r\n\r\nexport interface PaymentTemplateOptions {\r\n /** Payment amount */\r\n amount: number;\r\n /** Who is sending the payment */\r\n from: string;\r\n /** Who is receiving the payment */\r\n to: string;\r\n /** What the payment is for */\r\n purpose: string;\r\n /** Blockchain transaction hash */\r\n transactionHash: string;\r\n /** Sender's wallet address (optional, defaults to transaction sender) */\r\n senderWallet?: string;\r\n /** Receiver's wallet address (optional, defaults to transaction receiver) */\r\n receiverWallet?: string;\r\n /** Chain/network (optional, auto-detected if not provided) */\r\n chain?: 'coston2' | 'flare';\r\n /** Currency (optional, auto-detected if not provided) */\r\n currency?: string;\r\n}\r\n\r\nexport async function createPaymentReceipt(\r\n receiptsModule: ReceiptsModule,\r\n options: PaymentTemplateOptions\r\n): Promise<Receipt> {\r\n return receiptsModule.create({\r\n transactionHash: options.transactionHash,\r\n chain: options.chain || 'coston2', // Smart default\r\n amount: options.amount,\r\n currency: options.currency || 'C2FLR', // Smart default\r\n sender: options.senderWallet || options.from,\r\n receiver: options.receiverWallet || options.to,\r\n reference: `Payment: ${options.purpose} (Tx: ${options.transactionHash})`,\r\n });\r\n}\r\n","/**\r\n * Donation template - For charitable donations\r\n */\r\n\r\nimport type { ReceiptsModule } from '../modules/receipts';\r\nimport type { Receipt } from '../types/receipt';\r\n\r\nexport interface DonationTemplateOptions {\r\n /** Donation amount */\r\n amount: number;\r\n /** Name of the donor */\r\n donor: string;\r\n /** Name of the organization receiving the donation */\r\n organization: string;\r\n /** Campaign or cause name */\r\n campaign: string;\r\n /** Blockchain transaction hash */\r\n transactionHash: string;\r\n /** Donor's wallet address (optional) */\r\n donorWallet?: string;\r\n /** Organization's wallet address (optional) */\r\n organizationWallet?: string;\r\n}\r\n\r\nexport async function createDonationReceipt(\r\n receiptsModule: ReceiptsModule,\r\n options: DonationTemplateOptions\r\n): Promise<Receipt> {\r\n return receiptsModule.create({\r\n transactionHash: options.transactionHash,\r\n chain: 'coston2',\r\n amount: options.amount,\r\n currency: 'FLR',\r\n sender: options.donorWallet || options.donor,\r\n receiver: options.organizationWallet || options.organization,\r\n reference: `Donation: ${options.campaign} (Donor: ${options.donor}, Organization: ${options.organization})`,\r\n });\r\n}\r\n","/**\r\n * Escrow template - For escrow releases\r\n */\r\n\r\nimport type { ReceiptsModule } from '../modules/receipts';\r\nimport type { Receipt } from '../types/receipt';\r\n\r\nexport interface EscrowTemplateOptions {\r\n /** Amount being released from escrow */\r\n amount: number;\r\n /** Buyer's name */\r\n buyer: string;\r\n /** Seller's name */\r\n seller: string;\r\n /** Escrow identifier */\r\n escrowId: string;\r\n /** Reason for release */\r\n releaseReason: string;\r\n /** Blockchain transaction hash */\r\n transactionHash: string;\r\n /** Buyer's wallet address (optional) */\r\n buyerWallet?: string;\r\n /** Seller's wallet address (optional) */\r\n sellerWallet?: string;\r\n}\r\n\r\nexport async function createEscrowReceipt(\r\n receiptsModule: ReceiptsModule,\r\n options: EscrowTemplateOptions\r\n): Promise<Receipt> {\r\n return receiptsModule.create({\r\n transactionHash: options.transactionHash,\r\n chain: 'coston2',\r\n amount: options.amount,\r\n currency: 'FLR',\r\n sender: options.buyerWallet || options.buyer,\r\n receiver: options.sellerWallet || options.seller,\r\n reference: `Escrow Release: ${options.escrowId} - ${options.releaseReason} (Buyer: ${options.buyer}, Seller: ${options.seller})`,\r\n });\r\n}\r\n","/**\r\n * Grant template - For grant disbursements\r\n */\r\n\r\nimport type { ReceiptsModule } from '../modules/receipts';\r\nimport type { Receipt } from '../types/receipt';\r\n\r\nexport interface GrantTemplateOptions {\r\n /** Grant amount */\r\n amount: number;\r\n /** Name of the grantee (recipient) */\r\n grantee: string;\r\n /** Name of the grantor (funder) */\r\n grantor: string;\r\n /** Grant identifier */\r\n grantId: string;\r\n /** Purpose of the grant */\r\n purpose: string;\r\n /** Blockchain transaction hash */\r\n transactionHash: string;\r\n /** Grantor's wallet address (optional) */\r\n grantorWallet?: string;\r\n /** Grantee's wallet address (optional) */\r\n granteeWallet?: string;\r\n}\r\n\r\nexport async function createGrantReceipt(\r\n receiptsModule: ReceiptsModule,\r\n options: GrantTemplateOptions\r\n): Promise<Receipt> {\r\n return receiptsModule.create({\r\n transactionHash: options.transactionHash,\r\n chain: 'coston2',\r\n amount: options.amount,\r\n currency: 'FLR',\r\n sender: options.grantorWallet || options.grantor,\r\n receiver: options.granteeWallet || options.grantee,\r\n reference: `Grant: ${options.grantId} - ${options.purpose} (Grantor: ${options.grantor}, Grantee: ${options.grantee})`,\r\n });\r\n}\r\n","/**\r\n * Refund template - For refunds\r\n */\r\n\r\nimport type { ReceiptsModule } from '../modules/receipts';\r\nimport type { Receipt } from '../types/receipt';\r\n\r\nexport interface RefundTemplateOptions {\r\n /** Refund amount */\r\n amount: number;\r\n /** Original receipt ID being refunded */\r\n originalPayment: string;\r\n /** Reason for refund */\r\n reason: string;\r\n /** Customer name */\r\n customer: string;\r\n /** Blockchain transaction hash */\r\n transactionHash: string;\r\n /** Business wallet address (optional) */\r\n businessWallet?: string;\r\n /** Customer wallet address (optional) */\r\n customerWallet?: string;\r\n}\r\n\r\nexport async function createRefundReceipt(\r\n receiptsModule: ReceiptsModule,\r\n options: RefundTemplateOptions\r\n): Promise<Receipt> {\r\n return receiptsModule.create({\r\n transactionHash: options.transactionHash,\r\n chain: 'coston2',\r\n amount: options.amount,\r\n currency: 'FLR',\r\n sender: options.businessWallet || 'Business',\r\n receiver: options.customerWallet || options.customer,\r\n reference: `Refund: ${options.originalPayment} - ${options.reason} (Customer: ${options.customer})`,\r\n });\r\n}\r\n","/**\r\n * Main ProofRails SDK class\r\n */\r\n\r\nimport { APIClient } from './client';\r\nimport { ProjectsModule, AdminModule } from './modules/projects';\r\nimport { ReceiptsModule } from './modules/receipts';\r\nimport { VerificationModule } from './modules/verification';\r\nimport { StatementsModule } from './modules/statements';\r\nimport { EventsModule } from './modules/events';\r\nimport { EmbedModule } from './modules/embed';\r\nimport {\r\n createPaymentReceipt,\r\n createDonationReceipt,\r\n createEscrowReceipt,\r\n createGrantReceipt,\r\n createRefundReceipt,\r\n} from './templates';\r\nimport type { SDKConfig, Network } from './types/common';\r\nimport type { APIKey } from './types/project';\r\nimport type {\r\n PaymentTemplateOptions,\r\n DonationTemplateOptions,\r\n EscrowTemplateOptions,\r\n GrantTemplateOptions,\r\n RefundTemplateOptions,\r\n} from './templates';\r\n\r\nexport class ProofRails {\r\n private client: APIClient;\r\n\r\n /** Project and API key management */\r\n public readonly project: ProjectsModule;\r\n\r\n /** Admin operations (requires admin token) */\r\n public readonly admin: AdminModule;\r\n\r\n /** Receipt operations */\r\n public readonly receipts: ReceiptsModule;\r\n\r\n /** Verification operations */\r\n public readonly verify: VerificationModule;\r\n\r\n /** Statement generation */\r\n public readonly statements: StatementsModule;\r\n\r\n /** Live event updates */\r\n public readonly events: EventsModule;\r\n\r\n /** Embeddable widgets */\r\n public readonly embed: EmbedModule;\r\n\r\n /** Beginner-friendly templates */\r\n public readonly templates: {\r\n payment: (options: PaymentTemplateOptions) => ReturnType<typeof createPaymentReceipt>;\r\n donation: (options: DonationTemplateOptions) => ReturnType<typeof createDonationReceipt>;\r\n escrow: (options: EscrowTemplateOptions) => ReturnType<typeof createEscrowReceipt>;\r\n grant: (options: GrantTemplateOptions) => ReturnType<typeof createGrantReceipt>;\r\n refund: (options: RefundTemplateOptions) => ReturnType<typeof createRefundReceipt>;\r\n };\r\n\r\n constructor(config: SDKConfig = {}) {\r\n this.client = new APIClient(config);\r\n\r\n this.project = new ProjectsModule(this.client);\r\n this.admin = new AdminModule(this.client);\r\n this.receipts = new ReceiptsModule(this.client);\r\n this.verify = new VerificationModule(this.client);\r\n this.statements = new StatementsModule(this.client);\r\n this.events = new EventsModule(this.client);\r\n this.embed = new EmbedModule(this.client);\r\n\r\n this.templates = {\r\n payment: (options) => createPaymentReceipt(this.receipts, options),\r\n donation: (options) => createDonationReceipt(this.receipts, options),\r\n escrow: (options) => createEscrowReceipt(this.receipts, options),\r\n grant: (options) => createGrantReceipt(this.receipts, options),\r\n refund: (options) => createRefundReceipt(this.receipts, options),\r\n };\r\n }\r\n\r\n /**\r\n * Create a new project with API key (self-serve)\r\n * This is a convenience method for beginners\r\n */\r\n static async createProject(options: {\r\n label?: string;\r\n network?: Network;\r\n baseUrl?: string;\r\n } = {}): Promise<{ client: ProofRails; apiKey: string; projectId: string }> {\r\n const tempClient = new ProofRails({ network: options.network, baseUrl: options.baseUrl });\r\n const result = await tempClient.project.create({ label: options.label }) as any;\r\n\r\n const apiKey = result.api_key || result.apiKey;\r\n const projectId = result.project_id || result.projectId;\r\n\r\n const client = new ProofRails({\r\n apiKey,\r\n network: options.network,\r\n baseUrl: options.baseUrl // Propagate baseUrl\r\n });\r\n\r\n return {\r\n client,\r\n apiKey,\r\n projectId,\r\n };\r\n }\r\n\r\n /**\r\n * Update the API key for this client\r\n */\r\n setApiKey(apiKey: string): void {\r\n this.client.setApiKey(apiKey);\r\n }\r\n\r\n /**\r\n * Update the admin token for this client\r\n */\r\n setAdminToken(adminToken: string): void {\r\n this.client.setAdminToken(adminToken);\r\n }\r\n}\r\n\r\nexport default ProofRails;\r\n","import React, { createContext, useContext, useEffect, useState } from 'react';\r\nimport { ProofRails } from './index';\r\nimport type { SDKConfig } from './types/common';\r\n\r\n// Context to hold the initialized SDK client\r\nconst ProofRailsContext = createContext<ProofRails | null>(null);\r\n\r\nexport interface ProofRailsProviderProps {\r\n apiKey?: string;\r\n config?: Omit<SDKConfig, 'apiKey'>;\r\n children: React.ReactNode;\r\n}\r\n\r\n/**\r\n * ProofRails Provider\r\n * Wrap your application with this to use ProofRails hooks\r\n */\r\nexport const ProofRailsProvider: React.FC<ProofRailsProviderProps> = ({\r\n apiKey,\r\n config = {},\r\n children\r\n}) => {\r\n const [client, setClient] = useState<ProofRails | null>(null);\r\n\r\n useEffect(() => {\r\n // Initialize the client\r\n const instance = new ProofRails({\r\n apiKey,\r\n ...config,\r\n });\r\n setClient(instance);\r\n }, [apiKey]);\r\n\r\n if (!client) return null;\r\n\r\n return React.createElement(\r\n ProofRailsContext.Provider,\r\n { value: client },\r\n children\r\n );\r\n};\r\n\r\n/**\r\n * Hook to access the ProofRails client\r\n */\r\nexport const useProofRails = (): ProofRails => {\r\n const context = useContext(ProofRailsContext);\r\n if (!context) {\r\n throw new Error('useProofRails must be used within a ProofRailsProvider');\r\n }\r\n return context;\r\n};\r\n\r\n/**\r\n * Hook to handle payments\r\n * Matches your usage: import { useProofRailsPayment } ...\r\n */\r\nexport const useProofRailsPayment = () => {\r\n const client = useProofRails();\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [error, setError] = useState<Error | null>(null);\r\n const [receipt, setReceipt] = useState<any | null>(null);\r\n\r\n const createPayment = async (options: {\r\n amount: number;\r\n from: string;\r\n to: string;\r\n purpose: string;\r\n transactionHash: string;\r\n }) => {\r\n setIsLoading(true);\r\n setError(null);\r\n try {\r\n const result = await client.templates.payment(options);\r\n setReceipt(result);\r\n return result;\r\n } catch (err) {\r\n const errorObj = err instanceof Error ? err : new Error('Payment creation failed');\r\n setError(errorObj);\r\n throw errorObj;\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return {\r\n createPayment,\r\n receipt,\r\n isLoading,\r\n error\r\n };\r\n};\r\n"]}
@@ -0,0 +1,459 @@
1
+ /**
2
+ * Common types used across the SDK
3
+ */
4
+ type Network = 'coston2' | 'flare';
5
+ type ReceiptStatus = 'pending' | 'anchored' | 'failed';
6
+ interface SDKConfig {
7
+ /** Your ProofRails API key */
8
+ apiKey?: string;
9
+ /** Admin token for administrative operations */
10
+ adminToken?: string;
11
+ /** Network to use (coston2 or flare) */
12
+ network?: Network;
13
+ /** Base URL of the middleware (optional, defaults to production) */
14
+ baseUrl?: string;
15
+ /** Request timeout in milliseconds */
16
+ timeout?: number;
17
+ /** Number of retry attempts for failed requests (default: 3) */
18
+ retries?: number;
19
+ /** Delay between retries in milliseconds (default: 1000) */
20
+ retryDelay?: number;
21
+ }
22
+ interface APIResponse<T> {
23
+ data: T;
24
+ success: boolean;
25
+ error?: string;
26
+ }
27
+ interface PaginatedResponse<T> {
28
+ items: T[];
29
+ total: number;
30
+ page: number;
31
+ limit: number;
32
+ }
33
+ declare class ProofRailsError extends Error {
34
+ code?: string | undefined;
35
+ statusCode?: number | undefined;
36
+ details?: unknown | undefined;
37
+ constructor(message: string, code?: string | undefined, statusCode?: number | undefined, details?: unknown | undefined);
38
+ }
39
+
40
+ /**
41
+ * Core HTTP client for ProofRails API
42
+ */
43
+
44
+ interface RateLimitInfo {
45
+ limit: number;
46
+ remaining: number;
47
+ reset: number;
48
+ resetDate: Date;
49
+ }
50
+ declare class APIClient {
51
+ private baseUrl;
52
+ private apiKey?;
53
+ private adminToken?;
54
+ private timeout;
55
+ private retries;
56
+ private retryDelay;
57
+ private rateLimitInfo;
58
+ constructor(config?: SDKConfig);
59
+ getRateLimitInfo(): RateLimitInfo | null;
60
+ get<T>(endpoint: string, options?: RequestInit): Promise<T>;
61
+ post<T>(endpoint: string, body?: unknown, options?: RequestInit): Promise<T>;
62
+ put<T>(endpoint: string, body?: unknown, options?: RequestInit): Promise<T>;
63
+ delete<T>(endpoint: string, options?: RequestInit): Promise<T>;
64
+ private request;
65
+ private shouldRetry;
66
+ private retryRequest;
67
+ private extractRateLimitInfo;
68
+ setApiKey(apiKey: string): void;
69
+ setAdminToken(adminToken: string): void;
70
+ getBaseUrl(): string;
71
+ }
72
+
73
+ /**
74
+ * Project and API key related types
75
+ */
76
+ interface Project {
77
+ projectId: string;
78
+ label?: string;
79
+ createdAt: string;
80
+ receiptsCount?: number;
81
+ }
82
+ interface APIKey {
83
+ apiKey: string;
84
+ projectId: string;
85
+ label?: string;
86
+ createdAt: string;
87
+ }
88
+ interface CreateProjectOptions {
89
+ label?: string;
90
+ }
91
+ interface CreateAPIKeyOptions {
92
+ projectId: string;
93
+ label?: string;
94
+ }
95
+ interface WhoAmIResponse {
96
+ projectId: string;
97
+ label?: string;
98
+ }
99
+
100
+ /**
101
+ * Project and API key management module
102
+ */
103
+
104
+ declare class ProjectsModule {
105
+ private client;
106
+ constructor(client: APIClient);
107
+ getInfo(): Promise<WhoAmIResponse>;
108
+ rotateKey(): Promise<APIKey>;
109
+ create(options?: CreateProjectOptions): Promise<APIKey>;
110
+ }
111
+ declare class AdminModule {
112
+ private client;
113
+ constructor(client: APIClient);
114
+ createKey(options: CreateAPIKeyOptions): Promise<APIKey>;
115
+ deleteKey(keyId: string): Promise<void>;
116
+ }
117
+
118
+ /**
119
+ * Receipt related types
120
+ */
121
+
122
+ interface CreateReceiptOptions {
123
+ transactionHash: string;
124
+ chain: Network;
125
+ amount: string | number;
126
+ currency: string;
127
+ sender: string;
128
+ receiver: string;
129
+ reference: string;
130
+ callbackUrl?: string;
131
+ }
132
+ interface Receipt {
133
+ id: string;
134
+ status: ReceiptStatus;
135
+ transactionHash: string;
136
+ chain: Network;
137
+ amount: string;
138
+ currency: string;
139
+ sender: string;
140
+ receiver: string;
141
+ reference: string;
142
+ createdAt: string;
143
+ anchoredAt?: string;
144
+ anchorTx?: string;
145
+ bundleHash?: string;
146
+ projectId?: string;
147
+ onChain?: boolean;
148
+ valid?: boolean;
149
+ }
150
+ interface ReceiptArtifacts {
151
+ pain001Url?: string;
152
+ pain002Url?: string;
153
+ pain007Url?: string;
154
+ pain008Url?: string;
155
+ camt054Url?: string;
156
+ bundleUrl?: string;
157
+ manifestUrl?: string;
158
+ }
159
+ interface ListReceiptsOptions {
160
+ limit?: number;
161
+ page?: number;
162
+ status?: ReceiptStatus;
163
+ }
164
+ interface ReceiptUpdate {
165
+ id: string;
166
+ status: ReceiptStatus;
167
+ anchorTx?: string;
168
+ bundleHash?: string;
169
+ timestamp: string;
170
+ }
171
+
172
+ /**
173
+ * Receipt operations module
174
+ */
175
+
176
+ declare class ReceiptsModule {
177
+ private client;
178
+ constructor(client: APIClient);
179
+ create(options: CreateReceiptOptions): Promise<Receipt>;
180
+ get(receiptId: string): Promise<Receipt>;
181
+ list(options?: ListReceiptsOptions): Promise<PaginatedResponse<Receipt>>;
182
+ getArtifacts(receiptId: string): Promise<ReceiptArtifacts>;
183
+ }
184
+
185
+ /**
186
+ * Verification related types
187
+ */
188
+ interface VerificationResult {
189
+ valid: boolean;
190
+ bundleHash: string;
191
+ onChain: boolean;
192
+ anchorTx?: string;
193
+ blockNumber?: number;
194
+ timestamp?: string;
195
+ signature?: string;
196
+ details?: Record<string, unknown>;
197
+ }
198
+ interface VerificationProof {
199
+ receiptId: string;
200
+ bundleHash: string;
201
+ anchorTx: string;
202
+ blockNumber: number;
203
+ timestamp: string;
204
+ signature: string;
205
+ network: string;
206
+ contractAddress: string;
207
+ }
208
+
209
+ /**
210
+ * Verification module
211
+ */
212
+
213
+ declare class VerificationModule {
214
+ private client;
215
+ constructor(client: APIClient);
216
+ byReceiptId(receiptId: string): Promise<VerificationResult>;
217
+ byUrl(bundleUrl: string): Promise<VerificationResult>;
218
+ byHash(bundleHash: string): Promise<VerificationResult>;
219
+ getProof(receiptId: string): Promise<VerificationProof>;
220
+ }
221
+
222
+ /**
223
+ * ISO 20022 message types
224
+ */
225
+ type ISOMessageType = 'pain.001' | 'pain.002' | 'pain.007' | 'pain.008' | 'camt.052' | 'camt.053' | 'camt.054';
226
+ interface ISOMessage {
227
+ type: ISOMessageType;
228
+ messageId: string;
229
+ url: string;
230
+ createdAt: string;
231
+ }
232
+ interface GenerateStatementOptions {
233
+ dateFrom?: string;
234
+ dateTo?: string;
235
+ accountId?: string;
236
+ }
237
+ interface Statement {
238
+ type: 'camt.052' | 'camt.053';
239
+ url: string;
240
+ downloadUrl: string;
241
+ messageId: string;
242
+ createdAt: string;
243
+ }
244
+
245
+ /**
246
+ * Statements module
247
+ */
248
+
249
+ declare class StatementsModule {
250
+ private client;
251
+ constructor(client: APIClient);
252
+ intraday(options?: GenerateStatementOptions): Promise<Statement>;
253
+ endOfDay(options?: GenerateStatementOptions): Promise<Statement>;
254
+ }
255
+
256
+ /**
257
+ * Events module for live updates
258
+ */
259
+
260
+ interface EventListener {
261
+ stop: () => void;
262
+ }
263
+ declare class EventsModule {
264
+ private client;
265
+ constructor(client: APIClient);
266
+ listen(receiptId: string, callback: (update: ReceiptUpdate) => void): EventListener;
267
+ }
268
+
269
+ /**
270
+ * Embed module for generating embeddable widgets
271
+ */
272
+
273
+ interface EmbedOptions {
274
+ theme?: 'light' | 'dark';
275
+ width?: string;
276
+ height?: string;
277
+ }
278
+ interface WidgetResult {
279
+ iframeHtml: string;
280
+ embedUrl: string;
281
+ }
282
+ declare class EmbedModule {
283
+ private client;
284
+ constructor(client: APIClient);
285
+ widget(receiptId: string, options?: EmbedOptions): WidgetResult;
286
+ fullPage(receiptId: string): string;
287
+ }
288
+
289
+ /**
290
+ * Payment template - For simple payments between two parties
291
+ */
292
+
293
+ interface PaymentTemplateOptions {
294
+ /** Payment amount */
295
+ amount: number;
296
+ /** Who is sending the payment */
297
+ from: string;
298
+ /** Who is receiving the payment */
299
+ to: string;
300
+ /** What the payment is for */
301
+ purpose: string;
302
+ /** Blockchain transaction hash */
303
+ transactionHash: string;
304
+ /** Sender's wallet address (optional, defaults to transaction sender) */
305
+ senderWallet?: string;
306
+ /** Receiver's wallet address (optional, defaults to transaction receiver) */
307
+ receiverWallet?: string;
308
+ /** Chain/network (optional, auto-detected if not provided) */
309
+ chain?: 'coston2' | 'flare';
310
+ /** Currency (optional, auto-detected if not provided) */
311
+ currency?: string;
312
+ }
313
+ declare function createPaymentReceipt(receiptsModule: ReceiptsModule, options: PaymentTemplateOptions): Promise<Receipt>;
314
+
315
+ /**
316
+ * Donation template - For charitable donations
317
+ */
318
+
319
+ interface DonationTemplateOptions {
320
+ /** Donation amount */
321
+ amount: number;
322
+ /** Name of the donor */
323
+ donor: string;
324
+ /** Name of the organization receiving the donation */
325
+ organization: string;
326
+ /** Campaign or cause name */
327
+ campaign: string;
328
+ /** Blockchain transaction hash */
329
+ transactionHash: string;
330
+ /** Donor's wallet address (optional) */
331
+ donorWallet?: string;
332
+ /** Organization's wallet address (optional) */
333
+ organizationWallet?: string;
334
+ }
335
+ declare function createDonationReceipt(receiptsModule: ReceiptsModule, options: DonationTemplateOptions): Promise<Receipt>;
336
+
337
+ /**
338
+ * Escrow template - For escrow releases
339
+ */
340
+
341
+ interface EscrowTemplateOptions {
342
+ /** Amount being released from escrow */
343
+ amount: number;
344
+ /** Buyer's name */
345
+ buyer: string;
346
+ /** Seller's name */
347
+ seller: string;
348
+ /** Escrow identifier */
349
+ escrowId: string;
350
+ /** Reason for release */
351
+ releaseReason: string;
352
+ /** Blockchain transaction hash */
353
+ transactionHash: string;
354
+ /** Buyer's wallet address (optional) */
355
+ buyerWallet?: string;
356
+ /** Seller's wallet address (optional) */
357
+ sellerWallet?: string;
358
+ }
359
+ declare function createEscrowReceipt(receiptsModule: ReceiptsModule, options: EscrowTemplateOptions): Promise<Receipt>;
360
+
361
+ /**
362
+ * Grant template - For grant disbursements
363
+ */
364
+
365
+ interface GrantTemplateOptions {
366
+ /** Grant amount */
367
+ amount: number;
368
+ /** Name of the grantee (recipient) */
369
+ grantee: string;
370
+ /** Name of the grantor (funder) */
371
+ grantor: string;
372
+ /** Grant identifier */
373
+ grantId: string;
374
+ /** Purpose of the grant */
375
+ purpose: string;
376
+ /** Blockchain transaction hash */
377
+ transactionHash: string;
378
+ /** Grantor's wallet address (optional) */
379
+ grantorWallet?: string;
380
+ /** Grantee's wallet address (optional) */
381
+ granteeWallet?: string;
382
+ }
383
+ declare function createGrantReceipt(receiptsModule: ReceiptsModule, options: GrantTemplateOptions): Promise<Receipt>;
384
+
385
+ /**
386
+ * Refund template - For refunds
387
+ */
388
+
389
+ interface RefundTemplateOptions {
390
+ /** Refund amount */
391
+ amount: number;
392
+ /** Original receipt ID being refunded */
393
+ originalPayment: string;
394
+ /** Reason for refund */
395
+ reason: string;
396
+ /** Customer name */
397
+ customer: string;
398
+ /** Blockchain transaction hash */
399
+ transactionHash: string;
400
+ /** Business wallet address (optional) */
401
+ businessWallet?: string;
402
+ /** Customer wallet address (optional) */
403
+ customerWallet?: string;
404
+ }
405
+ declare function createRefundReceipt(receiptsModule: ReceiptsModule, options: RefundTemplateOptions): Promise<Receipt>;
406
+
407
+ /**
408
+ * Main ProofRails SDK class
409
+ */
410
+
411
+ declare class ProofRails {
412
+ private client;
413
+ /** Project and API key management */
414
+ readonly project: ProjectsModule;
415
+ /** Admin operations (requires admin token) */
416
+ readonly admin: AdminModule;
417
+ /** Receipt operations */
418
+ readonly receipts: ReceiptsModule;
419
+ /** Verification operations */
420
+ readonly verify: VerificationModule;
421
+ /** Statement generation */
422
+ readonly statements: StatementsModule;
423
+ /** Live event updates */
424
+ readonly events: EventsModule;
425
+ /** Embeddable widgets */
426
+ readonly embed: EmbedModule;
427
+ /** Beginner-friendly templates */
428
+ readonly templates: {
429
+ payment: (options: PaymentTemplateOptions) => ReturnType<typeof createPaymentReceipt>;
430
+ donation: (options: DonationTemplateOptions) => ReturnType<typeof createDonationReceipt>;
431
+ escrow: (options: EscrowTemplateOptions) => ReturnType<typeof createEscrowReceipt>;
432
+ grant: (options: GrantTemplateOptions) => ReturnType<typeof createGrantReceipt>;
433
+ refund: (options: RefundTemplateOptions) => ReturnType<typeof createRefundReceipt>;
434
+ };
435
+ constructor(config?: SDKConfig);
436
+ /**
437
+ * Create a new project with API key (self-serve)
438
+ * This is a convenience method for beginners
439
+ */
440
+ static createProject(options?: {
441
+ label?: string;
442
+ network?: Network;
443
+ baseUrl?: string;
444
+ }): Promise<{
445
+ client: ProofRails;
446
+ apiKey: string;
447
+ projectId: string;
448
+ }>;
449
+ /**
450
+ * Update the API key for this client
451
+ */
452
+ setApiKey(apiKey: string): void;
453
+ /**
454
+ * Update the admin token for this client
455
+ */
456
+ setAdminToken(adminToken: string): void;
457
+ }
458
+
459
+ export { type APIResponse as A, type CreateProjectOptions as C, type DonationTemplateOptions as D, type EscrowTemplateOptions as E, type GrantTemplateOptions as G, type ISOMessageType as I, type ListReceiptsOptions as L, type Network as N, ProofRails as P, type Receipt as R, type SDKConfig as S, type VerificationResult as V, type WhoAmIResponse as W, type PaymentTemplateOptions as a, type RefundTemplateOptions as b, ProofRailsError as c, type RateLimitInfo as d, type ReceiptStatus as e, type PaginatedResponse as f, type Project as g, type APIKey as h, type CreateAPIKeyOptions as i, type CreateReceiptOptions as j, type ReceiptArtifacts as k, type ReceiptUpdate as l, type ISOMessage as m, type GenerateStatementOptions as n, type Statement as o, type VerificationProof as p };