import { P as Provider } from "../packem_shared/provider.d-Dh32nRm9.js"; import { b as ChatPayload, S as SmsPayload } from "../packem_shared/types.d-C7l7qdMG.js"; import { I as InboundMessage, a as InboundReplyFunction, b as InboundReplyInput, c as InboundReply, R as Receiver } from "../packem_shared/types.d-4T7bNo4x.js"; export type { d as InboundAttachment, e as InboundChannel, f as InboundContext, g as InboundErrorReason, h as InboundHandler, i as InboundMessageType, j as InboundParticipant, k as InboundResponse, l as ReceiverOptions } from "../packem_shared/types.d-4T7bNo4x.js"; import "../packem_shared/types.d-BXfGenMH.js"; /** * Verifies an Ed25519 signature over `timestamp + body`, Discord's interaction signing * scheme. Edge-safe — uses Web Crypto's Ed25519 primitive only (available on Node 22+ and * Cloudflare Workers). Any malformed input or unsupported-algorithm error resolves to * `false` rather than throwing. * @param publicKeyHex The application's Ed25519 public key (hex), from the Discord dashboard. * @param signatureHex The `X-Signature-Ed25519` header value (hex). * @param timestamp The `X-Signature-Timestamp` header value. * @param body The raw request body. * @returns `true` when the signature is valid. */ declare const verifyEd25519: (publicKeyHex: string, signatureHex: string, timestamp: string, body: string) => Promise; /** * Verifies an Ed25519 signature over an arbitrary message, with the public key and signature * supplied as base64 (Telnyx's webhook signing scheme, where the signed message is * `{timestamp}|{body}`). Any malformed input resolves to `false` rather than throwing. * @param publicKeyBase64 The Ed25519 public key (base64). * @param signatureBase64 The header signature to check (base64). * @param message The exact string that was signed (e.g. `{timestamp}|{body}` for Telnyx). * @returns `true` when the signature is valid. */ declare const verifyEd25519Base64: (publicKeyBase64: string, signatureBase64: string, message: string) => Promise; /** * Computes the lowercase hex SHA-256 digest of a UTF-8 string — the encoding used by the * `payload_hash` / `url_hash` claims in MessageBird and Vonage signed webhooks. * @param value The string to hash. * @returns The hex digest. */ declare const sha256Hex: (value: string) => Promise; /** * Verifies a compact HS256 JWT against `secret` and returns its decoded payload claims, or * `undefined` when the token is malformed, uses a different algorithm, or the signature does * not match. Signature comparison is constant-time. Edge-safe — Web Crypto only. * @param token The compact JWT (`header.payload.signature`). * @param secret The shared signing secret. * @returns The verified payload claims, or `undefined`. */ declare const verifyHs256Jwt: (token: string, secret: string) => Promise | undefined>; /** * Checks that a JWT's `exp` (and optional `nbf`) claims place `now` within the token's validity * window, allowing a small clock-skew tolerance. Missing claims are treated as unbounded. * @param payload The decoded claims. * @param toleranceSeconds The allowed clock skew (default 5 seconds). * @returns `true` when the token is temporally valid. */ declare const isJwtTimeValid: (payload: Record, toleranceSeconds?: number) => boolean; /** * Normalises the shorthand string form of a reply into an {@link InboundReply}. * @param input The reply content, as an object or a plain string. * @returns The reply as an object, wrapping a bare string as `{ text }`. */ declare const normaliseReply: (input: InboundReplyInput) => InboundReply; /** * Creates the reply sender for a chat channel (Slack, Discord, Telegram), mapping the inbound * message and reply into a {@link ChatPayload} sent through `outbound`. The reply targets the * originating conversation and thread. The returned function rejects when `outbound` is absent. * @param provider The provider id, used in the not-configured error. * @param message The inbound message being replied to. * @param outbound The matching outbound chat provider, or `undefined`. * @returns A reply sender bound to `message`. */ declare const chatReply: (provider: string, message: InboundMessage, outbound: Provider | undefined) => InboundReplyFunction; /** * Creates the reply sender for an SMS channel (Twilio, Telnyx, Vonage, MessageBird), mapping the * inbound message and reply into an {@link SmsPayload} sent through `outbound`. The reply is * addressed back to the sender from the receiving number, re-applying the `whatsapp:` prefix for * WhatsApp. The returned function rejects when `outbound` is absent. * @param message The inbound message being replied to. * @param outbound The matching outbound SMS provider, or `undefined`. * @returns A reply sender bound to `message`. */ declare const smsReply: (message: InboundMessage, outbound: Provider | undefined) => InboundReplyFunction; /** * A web-standard request handler: the shape returned by {@link createInboundRouter} and the * signature platforms like Cloudflare Workers, Deno, Bun and Node's `fetch` server expect. * @param request The inbound request. * @returns The response. */ type FetchHandler = (request: Request) => Promise; /** * Mounts several {@link Receiver}s behind a single fetch handler, dispatching by URL * path. Each key is matched against the request's path — exactly, or as a suffix beginning at a * path-segment boundary, so a mount base path does not need to be known ahead of time. The most * specific route wins; unmatched paths get a `404`. * * The result is directly usable as a Cloudflare Workers / Deno / Bun `fetch` export, or via a * Node/Express/Hono web-request adapter. * @param routes A map of path (e.g. `"/webhooks/slack"`) to channel receiver. * @returns A fetch handler dispatching to the matching channel. */ declare const createInboundRouter: (routes: Record) => FetchHandler; export { type FetchHandler, type InboundMessage, type InboundReply, type InboundReplyFunction, type InboundReplyInput, type Receiver, chatReply, createInboundRouter, isJwtTimeValid, normaliseReply, sha256Hex, smsReply, verifyEd25519, verifyEd25519Base64, verifyHs256Jwt };