nodejs-cryptomus
Version:
A comprehensive Node.js client for the Cryptomus API
41 lines (40 loc) • 1.48 kB
TypeScript
import { WebhookPayload, PaymentWebhookPayload, PayoutWebhookPayload } from '../types';
/**
* Webhook service for handling and validating webhooks
*/
export declare class WebhookService {
private readonly apiKey;
/**
* Create a new webhook service
*
* @param apiKey - API key for signature verification
*/
constructor(apiKey: string);
/**
* Parse and validate a webhook payload
*
* @param payload - Raw webhook payload as string
* @param signature - Signature from webhook headers
* @returns Parsed webhook payload
* @throws Error if signature is invalid
*/
parseWebhook(payload: string, signature: string): WebhookPayload;
/**
* Parse and validate a payment webhook payload
*
* @param payload - Raw webhook payload as string
* @param signature - Signature from webhook headers
* @returns Parsed payment webhook payload
* @throws Error if signature is invalid or payload type is not payment
*/
parsePaymentWebhook(payload: string, signature: string): PaymentWebhookPayload;
/**
* Parse and validate a payout webhook payload
*
* @param payload - Raw webhook payload as string
* @param signature - Signature from webhook headers
* @returns Parsed payout webhook payload
* @throws Error if signature is invalid or payload type is not payout
*/
parsePayoutWebhook(payload: string, signature: string): PayoutWebhookPayload;
}