import { NodeOperationError } from 'n8n-workflow'; /** * Zalo OA Transport Layer * * Shared utilities for making API requests, handling errors, * and verifying webhook signatures. */ /** * Zalo API Error Response Structure */ export interface IZaloApiError { error: number; message: string; } /** * HTTP Request options for Zalo API */ export interface IRequestOptions { method: 'GET' | 'POST' | 'PUT' | 'DELETE'; url: string; headers?: Record; body?: any; qs?: Record; formData?: any; timeout?: number; } /** * Make HTTP request with exponential backoff retry for rate limits (429) * * @param requestFn - Function that returns a promise for the HTTP request * @param maxRetries - Maximum number of retries (default: 3) * @param initialDelay - Initial delay in milliseconds (default: 1000ms) * @returns Promise with the response data */ export declare function makeRequestWithRetry(requestFn: () => Promise, maxRetries?: number, initialDelay?: number): Promise; /** * Handle Zalo API errors and wrap them in NodeOperationError * * @param error - The error object from the API request * @returns NodeOperationError with clear error message */ export declare function handleZaloError(error: any): NodeOperationError; /** * Verify Zalo webhook signature using HMAC-SHA256 * * @param payload - The webhook payload (as string or buffer) * @param signature - The signature from X-Zalo-Signature header * @param secret - The App Secret from Zalo credentials * @returns true if signature is valid, false otherwise */ export declare function verifyWebhookSignature(payload: string | Buffer, signature: string, secret: string): boolean; /** * Calculate exponential backoff delay * @param attempt - Current attempt number (0-indexed) * @param initialDelay - Initial delay in milliseconds * @returns Delay in milliseconds */ export declare function calculateBackoffDelay(attempt: number, initialDelay?: number): number;