UNPKG

@huddle01/server-sdk

Version:

The Huddle01 Server SDK allows you to perform protected admin actions on your server side, like generating peer access tokens and starting and stopping meeting recordings and livestreams.

53 lines (50 loc) 1.72 kB
import { WebhookEvents } from './types.cjs'; type Config = { apiKey: string; }; type WebhookData = { id: string; event: keyof WebhookEvents; payload: WebhookEvents[keyof WebhookEvents][0]; }; declare class WebhookReceiver { #private; private algMap; constructor(config: Config); /** * Verify the webhook request and extract the webhook content * * @param body Body of the webhook request * @param header Signature header of the webhook request * @returns Extracted webhook data */ receive(body: any, header?: string | null): Promise<WebhookData>; /** * Helper method to extract the body, signature, alogorithm and hashpayload * from the webhook request. WARNING: This method does not verify the signature * * @param body Body of the webhook request * @param header Signature header of the webhook request * @returns body, signature, alogorithm and hashpayload */ getBodyAndSignature(body: any, header?: string | null): { hashPayload: string; signatureAlgorithm: string; signature: string; data: Record<any, any>; }; /** * Helper function to create a typed webhook data object */ createTypedWebhookData<T extends keyof WebhookEvents>(event: T, data: WebhookEvents[keyof WebhookEvents][0]): { event: T; data: WebhookEvents[T][0]; }; private static asyncGenerateHmac; /** * Function to check if two strings are time safe equal. * Based on: https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy */ private static timingSafeEqual; } export { WebhookReceiver };