import { AuditEvent, HooksAdapter } from "@authhero/adapter-interfaces";
import { EventDestination } from "../outbox-relay";
import type { WebhookInvoker } from "../../types/AuthHeroConfig";
/**
 * Mints a Bearer token for a given tenant. `scope` is forwarded so a custom
 * `webhookInvoker` can request a non-default scope for its outbound call.
 */
export type GetServiceToken = (tenantId: string, scope?: string) => Promise<string>;
interface WebhookInvocation {
    eventId: string;
    tenantId: string;
    triggerId: string;
    payload: {
        tenant_id: string;
        trigger_id: string;
        user?: unknown;
        request?: unknown;
    };
}
export interface WebhookDestinationOptions {
    timeoutMs?: number;
    /**
     * Replaces the default HTTP invoker. When set, each matching webhook is
     * dispatched by calling `webhookInvoker({ hook, data, tenant_id,
     * createServiceToken })` instead of issuing a raw `fetch` with a Bearer
     * token. `createServiceToken(scope?)` lazily mints a token bound to the
     * invocation's tenant, matching the shape passed to the legacy inline
     * dispatcher in `hooks/webhooks.ts`.
     */
    webhookInvoker?: WebhookInvoker;
}
/**
 * Delivers `hook.*` outbox events to HTTP webhooks configured for the matching
 * trigger_id. Each POST includes `Idempotency-Key: {event.id}` so downstream
 * webhook handlers can dedupe if the outbox retries.
 *
 * The destination is constructed per-request (via `outboxMiddleware`'s
 * `getDestinations(ctx)` factory) so it can close over a ctx-bound service
 * token generator. The same class is also used by the cron `runOutboxRelay`
 * helper — a consumer's `webhookInvoker` configured via `init()` propagates
 * to both paths so cron-drained deliveries don't diverge from per-request
 * ones.
 */
export declare class WebhookDestination implements EventDestination {
    name: string;
    private hooks;
    private getServiceToken;
    private timeoutMs;
    private webhookInvoker?;
    constructor(hooks: HooksAdapter, getServiceToken: GetServiceToken, options?: WebhookDestinationOptions);
    accepts(event: AuditEvent): boolean;
    transform(event: AuditEvent): WebhookInvocation;
    deliver(events: WebhookInvocation[]): Promise<void>;
    private invokeCustom;
    private invokeDefault;
}
export {};
