import "../server-only.js"; import type { StandardSchemaV1 } from "@standard-schema/spec"; import { type ChannelDefinition, type InferChannelEvent, type InferChannelParams } from "./index.js"; /** Server-authenticated scope captured at the originating HTTP boundary. JSON-safe for jobs. */ export interface BroadcastOrigin { readonly version: 1; readonly clientId: string; readonly scope: string; } /** Validate an origin already captured by a trusted server for a job payload. */ export declare const broadcastOriginSchema: StandardSchemaV1; /** Never derive principal, tenant, or namespace from the optional client header. */ export declare function resolveBroadcastOrigin(options: { headers: Headers; principalId?: string | null; tenantId?: string | null; namespace: string; }): BroadcastOrigin | undefined; export type BroadcastPublication = InferChannelEvent & { params: InferChannelParams; excludeOrigin?: BroadcastOrigin; }; /** Readiness proves initial subscription only. Continuity loss requires reconnect and refetch. */ export interface BroadcastSubscription { readonly ready: Promise; unsubscribe(): Promise; } export interface BroadcastPort { /** Resolves when accepted by the provider, including when nobody is subscribed. */ publish(channel: C, publication: BroadcastPublication): Promise; subscribe(channel: C, options: { params: InferChannelParams; onEvent: (event: InferChannelEvent, metadata: { excludeOrigin?: BroadcastOrigin; }) => void; onDisconnect: () => void; }): BroadcastSubscription; } /** Internal transport envelope carried by broadcast providers, never a browser payload. */ export interface BroadcastEnvelope { version: 1; channel: string; params: Record; event: string; data: unknown; excludeOrigin?: BroadcastOrigin; } /** Low-level adapter contract. Subscription callbacks must be isolated from publishers. */ export interface BroadcastTransport { publish(key: string, envelope: BroadcastEnvelope): Promise; subscribe(key: string, options: { onMessage: (envelope: unknown) => void; onDisconnect: () => void; }): BroadcastSubscription; } /** Shared validation and cleanup for provider implementations. */ export declare function createBroadcastPort(transport: BroadcastTransport): BroadcastPort; export interface ChannelBinding { readonly kind: "channel-binding"; readonly channel: ChannelDefinition; authorize: (args: { ctx: Ctx; params: Record; }) => void | Promise; } export interface ChannelRegistry { readonly kind: "channel-registry"; readonly bindings: readonly ChannelBinding[]; get(name: string): ChannelBinding | undefined; } /** Bind every channel explicitly, including public channels. */ export declare function createBroadcasting(): { defineChannelBinding: (channel: C, options: { authorize: (args: { ctx: Ctx; params: InferChannelParams; }) => void | Promise; }) => ChannelBinding; defineChannelRegistry: (bindings: readonly ChannelBinding[]) => ChannelRegistry; }; /** Validate a configurable deadline without allowing an unbounded stream. */ export declare function broadcastLifetime(value?: number): number; //# sourceMappingURL=server.d.ts.map