import { C as Connection, u as CommonSession, j as SessionState, v as CommonSessionProps, T as Transport, w as ServerTransportOptions, r as ServerHandshakeOptions, x as ServerSession, e as ProvidedServerTransportOptions, D as DeleteSessionOptions } from './transport-DF2T202E.js'; import { O as OpaqueTransportMessage, g as HandshakeErrorResponseCodes, P as ProtocolVersion, b as TransportMessage, C as CustomHandshakeErrorCodeSchema, H as HandshakeErrorCode, T as TransportClientId } from './message-C2qDAau6.js'; import { Static, TSchema } from 'typebox'; import { T as Tags } from './index-CIMpdW6z.js'; import { S as SendResult } from './adapter-K2HsfQLt.js'; interface SessionWaitingForHandshakeListeners { onConnectionErrored: (err: unknown) => void; onConnectionClosed: () => void; onHandshake: (msg: OpaqueTransportMessage) => void; onInvalidHandshake: (reason: string, code: Static) => void; onHandshakeTimeout: () => void; } interface SessionWaitingForHandshakeProps extends CommonSessionProps { conn: ConnType; listeners: SessionWaitingForHandshakeListeners; } declare class SessionWaitingForHandshake extends CommonSession { readonly state: SessionState.WaitingForHandshake; conn: ConnType; listeners: SessionWaitingForHandshakeListeners; handshakeTimeout?: ReturnType; constructor(props: SessionWaitingForHandshakeProps); get loggingMetadata(): { protocolVersion?: ProtocolVersion | undefined; clientId: string; connectedTo?: string | undefined; sessionId?: string | undefined; connId: string; transportMessage?: Partial | undefined; validationErrors?: { path: string; message: string; }[] | undefined; tags?: Tags[] | undefined; telemetry?: { traceId: string; spanId: string; } | undefined; extras?: Record | undefined; }; onHandshakeData: (msg: Uint8Array) => void; sendHandshake(msg: TransportMessage): SendResult; _handleStateExit(): void; _handleClose(): void; } declare abstract class ServerTransport extends Transport> { /** * The options for this transport. */ protected options: ServerTransportOptions; /** * Optional handshake options for the server. */ handshakeExtensions?: ServerHandshakeOptions; /** * A map of session handshake data for each session. */ sessionHandshakeMetadata: Map; sessions: Map>; pendingSessions: Set>; constructor(clientId: TransportClientId, providedOptions?: ProvidedServerTransportOptions); extendHandshake: (options: ServerHandshakeOptions) => void; private isRejectionCode; protected deletePendingSession(pendingSession: SessionWaitingForHandshake): void; protected deleteSession(session: ServerSession, options?: DeleteSessionOptions): void; /** * Asks the connected client to re-handshake — re-construct and resend its * handshake metadata (e.g. a refreshed token). Returns false if there is no * live connection to send the request over. * * On a successful re-handshake the stored metadata is replaced and observed by * subsequent procedure calls. If the client does not respond with metadata that * re-validates before the response deadline — the shorter of * {@link SessionOptions.handshakeTimeoutMs} and the credential's remaining * lifetime — the session is torn down. */ requestRehandshake(to: TransportClientId): boolean; /** * Stores freshly validated handshake metadata for a client and hands the * credential's expiry to the session, which schedules and runs the next * re-handshake itself. Called on every successful (re)handshake, so the schedule * perpetuates itself and survives transparent reconnects. */ private storeSessionMetadata; protected handleRehandshakeMessage(message: OpaqueTransportMessage): void; /** * Re-validates handshake metadata sent by the client during a re-handshake and * replaces the stored metadata on success. Any failure (malformed metadata, * rejection, or a thrown validator) tears the session down. */ private onRehandshakeResponse; /** * Tears down a session whose re-handshake failed (rejected, malformed, timed * out, or a thrown validator). No-ops if {@link session} has been consumed or * is no longer the live session for its peer — a transparent reconnect keeps * the same id, so callers reaching here after an async gap can't accidentally * close the session that replaced it. */ private teardownForFailedRehandshake; protected handleConnection(conn: ConnType): void; private rejectHandshakeRequest; protected onHandshakeRequest(session: SessionWaitingForHandshake, msg: OpaqueTransportMessage): Promise; } export { ServerTransport as S, SessionWaitingForHandshake as a };