/** * SSE-lane primitive. * * Standalone client for the platform's HTTP fallback transport * (`GET /v1/transport/stream` for receive, `POST /v1/transport/send` for * send). Suitable for environments where WebSocket upgrades are blocked * by a corporate firewall but plain HTTPS GET/POST work. * * v1 surface intentionally narrow: this exposes the bytes lane only. * Caller is responsible for parsing the protobuf Envelope (or using the * codec exported from the SDK). Full `init({ transport: 'sse' })` * integration into `MessagingClient` lands in 4.2.1b once the wire * shape stabilises with real-world feedback. * * @example * ```ts * import { SseTransport } from '@droponair/sdk-js'; * const sse = new SseTransport({ httpUrl: 'https://sdk.droponair.com', getJwt: async () => myJwt }); * sse.onFrame((bytes) => { ... your protobuf decode ... }); * await sse.connect(); * await sse.sendEnvelope(myEnvelopeBytes); * ``` */ export interface SseTransportOptions { /** Base URL of the platform's REST API (no trailing slash). */ httpUrl: string; /** Returns a fresh JWT. Called once per connect. */ getJwt: () => Promise; /** * Custom fetch implementation, useful for Node-side polyfills or test * doubles. Defaults to globalThis.fetch. */ fetchFn?: typeof fetch; /** * Custom EventSource constructor, useful for environments (e.g. Node) * that need the `eventsource` npm polyfill. Defaults to the global. */ eventSourceCtor?: typeof EventSource; } export type SseFrameHandler = (frame: Uint8Array) => void; export type SseStateHandler = (state: 'connecting' | 'open' | 'closed' | 'error') => void; export declare class SseTransport { private readonly httpUrl; private readonly getJwt; private readonly fetchFn; private readonly EventSourceCtor; private eventSource; private jwt; private frameHandler; private stateHandler; constructor(options: SseTransportOptions); /** Subscribe to incoming protobuf frames. Replaces any previous handler. */ onFrame(handler: SseFrameHandler): void; /** Subscribe to lifecycle state changes. Replaces any previous handler. */ onState(handler: SseStateHandler): void; /** Open the long-lived SSE stream. Resolves on first 'ready' event from the server. */ connect(): Promise; /** POST a single protobuf Envelope to the server. */ sendEnvelope(envelopeBytes: Uint8Array): Promise; /** Close the stream. Idempotent. */ close(): void; }