import { n as registerPluginHttpRoute } from "./http-registry-DzPZrmth.js"; import { f as FixedWindowRateLimiter, i as WebhookInFlightLimiter } from "./webhook-request-guards-CQf6yUy9.js"; import { IncomingMessage, ServerResponse } from "node:http"; //#region src/plugin-sdk/webhook-targets.d.ts type RegisteredWebhookTarget = { target: T; unregister: () => void; }; type RegisterWebhookTargetOptions = { onFirstPathTarget?: (params: { path: string; target: T; }) => void | (() => void); onLastPathTargetRemoved?: (params: { path: string; }) => void; }; type RegisterPluginHttpRouteParams = Parameters[0]; type RegisterWebhookPluginRouteOptions = Omit; /** Register a webhook target and lazily install the matching plugin HTTP route on first use. */ declare function registerWebhookTargetWithPluginRoute(params: { targetsByPath: Map; target: T; route: RegisterWebhookPluginRouteOptions; onLastPathTargetRemoved?: RegisterWebhookTargetOptions["onLastPathTargetRemoved"]; }): RegisteredWebhookTarget; /** Add a normalized target to a path bucket and clean up route state when the last target leaves. */ declare function registerWebhookTarget(targetsByPath: Map, target: T, opts?: RegisterWebhookTargetOptions): RegisteredWebhookTarget; /** Resolve all registered webhook targets for the incoming request path. */ declare function resolveWebhookTargets(req: IncomingMessage, targetsByPath: Map): { path: string; targets: T[]; } | null; /** Run common webhook guards, then dispatch only when the request path resolves to live targets. */ declare function withResolvedWebhookRequestPipeline(params: { req: IncomingMessage; res: ServerResponse; targetsByPath: Map; allowMethods?: readonly string[]; rateLimiter?: FixedWindowRateLimiter; rateLimitKey?: string; nowMs?: number; requireJsonContentType?: boolean; inFlightLimiter?: WebhookInFlightLimiter; inFlightKey?: string | ((args: { req: IncomingMessage; path: string; targets: T[]; }) => string); inFlightLimitStatusCode?: number; inFlightLimitMessage?: string; handle: (args: { path: string; targets: T[]; }) => Promise | boolean | void; }): Promise; type WebhookTargetMatchResult = { kind: "none"; } | { kind: "single"; target: T; } | { kind: "ambiguous"; }; /** Match exactly one synchronous target or report whether resolution was empty or ambiguous. */ declare function resolveSingleWebhookTarget(targets: readonly T[], isMatch: (target: T) => boolean): WebhookTargetMatchResult; /** Async variant of single-target resolution for auth checks that need I/O. */ declare function resolveSingleWebhookTargetAsync(targets: readonly T[], isMatch: (target: T) => Promise): Promise>; /** Resolve an authorized target and send the standard unauthorized or ambiguous response on failure. */ declare function resolveWebhookTargetWithAuthOrReject(params: { targets: readonly T[]; res: ServerResponse; isMatch: (target: T) => boolean | Promise; unauthorizedStatusCode?: number; unauthorizedMessage?: string; ambiguousStatusCode?: number; ambiguousMessage?: string; }): Promise; /** Synchronous variant of webhook auth resolution for cheap in-memory match checks. */ declare function resolveWebhookTargetWithAuthOrRejectSync(params: { targets: readonly T[]; res: ServerResponse; isMatch: (target: T) => boolean; unauthorizedStatusCode?: number; unauthorizedMessage?: string; ambiguousStatusCode?: number; ambiguousMessage?: string; }): T | null; /** Reject non-POST webhook requests with the conventional Allow header. */ declare function rejectNonPostWebhookRequest(req: IncomingMessage, res: ServerResponse): boolean; //#endregion export { RegisterWebhookPluginRouteOptions, RegisterWebhookTargetOptions, RegisteredWebhookTarget, WebhookTargetMatchResult, registerPluginHttpRoute, registerWebhookTarget, registerWebhookTargetWithPluginRoute, rejectNonPostWebhookRequest, resolveSingleWebhookTarget, resolveSingleWebhookTargetAsync, resolveWebhookTargetWithAuthOrReject, resolveWebhookTargetWithAuthOrRejectSync, resolveWebhookTargets, withResolvedWebhookRequestPipeline };