/** * HTTP/2 transport to APNs with a single, reused {@link ClientHttp2Session}. * * APNs strongly prefers long-lived HTTP/2 connections multiplexing many * requests. This module lazily opens one session per `(host, port)`, keeps it * warm, and transparently re-opens it after a `close`/`goaway`/error so callers * never deal with reconnection. It is intentionally generic over the * `:path`/headers so the same session powers device pushes, broadcasts, and * channel management. * * @packageDocumentation */ import * as http2 from 'node:http2'; /** A single APNs request to dispatch over the session. */ export interface Http2RequestSpec { /** HTTP method (`POST`, `GET`, `DELETE`, …). */ method: string; /** Request `:path`, e.g. `/3/device/`. */ path: string; /** Application headers (authorization, apns-*). The pseudo-headers are added. */ headers: http2.OutgoingHttpHeaders; /** Optional UTF-8 request body. */ body?: string; } /** The raw HTTP/2 response, before APNs-specific parsing. */ export interface Http2Response { /** The `:status` pseudo-header. */ status: number; /** All response headers (lowercased keys). */ headers: http2.IncomingHttpHeaders; /** The response body decoded as UTF-8 (often empty for 2xx). */ body: string; } /** Construction options for {@link Http2Client}. */ export interface Http2ClientOptions { /** Fully-qualified host, e.g. `api.push.apple.com`. */ host: string; /** Port (`443` / `2197` for push, `2196`/`2195` for channel management). */ port: number; /** Connect timeout in ms (default `10_000`). */ connectTimeoutMs?: number; /** Per-request timeout in ms (default `10_000`). */ requestTimeoutMs?: number; } /** * Reused, auto-reconnecting HTTP/2 client for one APNs endpoint. * * Not exported from the package surface directly — {@link createLiveActivityPusher} * and {@link createBroadcastChannelManager} own instances of it. */ export declare class Http2Client { private readonly authority; private readonly connectTimeoutMs; private readonly requestTimeoutMs; /** The live session, or `undefined` when disconnected. */ private session?; /** In-flight connect promise, so concurrent callers share one handshake. */ private connecting?; /** Set once {@link close} is called; further requests are refused. */ private closed; constructor(options: Http2ClientOptions); /** Lazily connect (or reuse) the session, sharing a concurrent handshake. */ private connect; /** * Send one request over the (lazily connected) session and resolve the parsed * status/headers/body. Rejects with an {@link ApnsError} of kind `'transport'` * on connection/stream failures or timeouts. */ request(spec: Http2RequestSpec): Promise; /** * Gracefully close the session and refuse further requests. Safe to call more * than once. In-flight streams are allowed to complete before the socket * closes (HTTP/2 graceful close semantics). */ close(): Promise; } //# sourceMappingURL=apns.d.ts.map