/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { ClientInteraction } from "#action/client/ClientInteraction.js"; import type { NodeProtocol } from "#action/protocols.js"; import { PeerAddress } from "#peer/PeerAddress.js"; import type { ExchangeProvider, ReachabilityReason } from "#protocol/ExchangeProvider.js"; import type { NodeSession } from "#session/NodeSession.js"; import { SessionParameters } from "#session/SessionParameters.js"; import { AsyncObservable, BasicSet, ChannelType, DnssdNames, Duration, Identity, IpChannelType, IpService, Lifetime, Observable } from "@matter/general"; import { BasicInformation } from "@matter/types/clusters/basic-information"; import type { NetworkProfiles } from "./NetworkProfile.js"; import { PeerConnection } from "./PeerConnection.js"; import { PeerDescriptor } from "./PeerDescriptor.js"; import { PeerTimingParameters } from "./PeerTimingParameters.js"; import type { PhysicalDeviceProperties } from "./PhysicalDeviceProperties.js"; /** * Floor for the MRP idle retransmission interval when a peer operates as a LIT ICD. A LIT ICD omits SII from its * mDNS advertisement (§ 9.15.1.6.2), so the controller would otherwise fall back to the 500ms idle default and * retransmit far too aggressively at a sleeping peer. Mirrors CHIP's `minimumLITBackoffInterval`. */ export declare const LIT_MIN_IDLE_INTERVAL: Duration; /** * A node on a fabric we are a member of. */ export declare class Peer { #private; /** * Preferred transport for outgoing connections to this peer. * * Only `ChannelType.TCP` has meaning here — UDP is the default with no preference, and BLE is * not used for operational connections. Setting TCP is a soft hint: the connect path still falls * back to UDP if the peer does not advertise TCP server support. */ transportPreference?: ChannelType.TCP; constructor(descriptor: PeerDescriptor, context: Peer.Context); /** * Emits when metadata changes. */ get updated(): AsyncObservable<[peer: Peer], void>; /** * Emits when Sigma1 to one address has been retransmitted past the MRP budget without a response, counted across * the fresh Sigma1 messages that replace an unacknowledged one, indicating the peer is likely unresponsive. Emits * again only after the connection schedule of the address restarts, e.g. after another error or a kick. This is * only a signal; it does not change retransmission. */ get establishmentUnresponsive(): Observable<[]>; get lifetime(): Lifetime; get fabric(): import("../index.js").Fabric; get interaction(): ClientInteraction | undefined; set interaction(interaction: ClientInteraction | undefined); get protocol(): NodeProtocol | undefined; set protocol(protocol: NodeProtocol | undefined); get physicalProperties(): PhysicalDeviceProperties | undefined; set physicalProperties(props: PhysicalDeviceProperties | undefined); get basicInformation(): Peer.BasicInformation | undefined; get limits(): { simultaneousInvocationsSupported?: number; simultaneousWritesSupported?: number; readPathsSupported?: number; subscribePathsSupported?: number; caseSessionsPerFabric: number; subscriptionsPerFabric: number; }; get address(): PeerAddress; get descriptor(): PeerDescriptor; get sessions(): BasicSet; get subscriptions(): import("../index.js").Subscription[]; get exchangeProvider(): ExchangeProvider; get service(): IpService; /** * "Best guess" {@link SessionParameters} for the peer based on available information. */ get sessionParameters(): SessionParameters; /** * The transports the peer advertises in the DNS-SD `T` key. Reads the live TXT record when one is cached because * the descriptor lags it by a tick when TXT and addresses share one mDNS response. * * @see {@link MatterSpecification.v161.Core} § 4.3.4 */ get advertisedTransports(): import("../index.js").SupportedTransportsBitmap | undefined; get network(): import("./NetworkProfile.js").NetworkProfile; /** * Time that node has been unreachable. * * If we are actively attempting to connect to the peer, this is the time since the connection process started. * Otherwise it is zero. */ get timeOffline(): Duration; /** * Record that the peer does not serve TCP although a TCP session to it was attempted. Honored by * {@link resolveTransports} and persisted across restart until a later session reports TCP server support. */ markTcpUnsupported(): void; /** * Resolve the ordered list of transports to attempt for this peer. * * `requiredTransport` is a hard constraint. Otherwise, with an effective TCP preference * (`preferredTransport ?? transportPreference`), the `SUPPORTED_TRANSPORTS.tcpServer` session parameter (tag 8) * decides when present, falling back to the mDNS TXT `T` advertisement only when absent. Pre-1.5 peers resolve * to UDP. `undefined` means default UDP. */ resolveTransports(requiredTransport?: ChannelType, preferredTransport?: ChannelType): IpChannelType[] | undefined; /** * Obtain a session with the peer, establishing anew as necessary. */ connect(options?: Peer.ConnectOptions): Promise; /** * Kick the connection process. * * Aborts the current CASE handshake exchange and restarts it from scratch with a fresh MRP * backoff. Rate-limited; repeated calls within {@link PeerTimingParameters.kickRestartCooldown} * are suppressed. */ kick(): void; /** * Abort any outstanding connection attempts. * * When {@link cause} is provided, also force-close any active sessions with the peer — use this when the peer * is known to be unreachable (e.g. we just removed our fabric on the peer). Without a cause the existing * sessions are left alone so they can follow their normal graceful-close path. */ disconnect(cause?: Error): Promise; /** * Permanently forget the peer. */ delete(): Promise; /** * Close the peer without removing persistent state. */ close(): Promise; toString(): string; get hasSession(): boolean; newestSession(type?: ChannelType): NodeSession | undefined; /** * Verify this peer is reachable, driving recovery via the address monitor. * * Returns `true` if the session is usable afterward, `false` if it was closed. */ verifyReachability(options: { reason: ReachabilityReason; abort?: AbortSignal; }): Promise; } export declare namespace Peer { interface Context extends PeerConnection.Context { names: DnssdNames; networks: NetworkProfiles; closed(peer: Peer): void; } interface BasicInformation extends Identity<{ readonly [N in keyof BasicInformation.Attributes]?: BasicInformation.Attributes[N]; }> { } interface ConnectOptions { /** * Aborts the connection attempt (underlying connection however may continue). */ abort?: AbortSignal; /** * Network identifier used for timing parameters. */ network?: string; /** * Per-call override for the peer-medium MRP retransmission margin. When omitted the margin derives from * the peer's network medium, independent of any {@link network} throttle override. */ additionalMrpDelay?: Duration; /** * A timeout relative to beginning of connection process. * * If the peer is already connecting, connection time is reduced by this amount. * * If omitted, defaults to {@link PeerTimingParameters.defaultConnectionTimeout}. Pass `Forever` to wait * without bound (only appropriate for background sustain loops — invokes, reads, writes and non-sustained * subscribes should always allow the default to apply so a hung handshake cannot deadlock a request). */ connectionTimeout?: Duration; /** * If a connection is ongoing, kicks the process to increase MRP responsiveness. * * If true, {@link connectionTimeout} is not reduced if already connecting. */ kick?: boolean; /** * Per-call overrides for timing parameters. * * Merged on top of the global {@link PeerSet.timing} for this connection only. * Other concurrent or future connections are not affected. * * Note: if a connection process is already in progress for this peer, these overrides are not applied to the * ongoing attempt. */ timing?: Partial; /** * Hard transport constraint for this connection (e.g. Large Message Quality requires TCP). * When omitted, transports are resolved per {@link Peer.resolveTransports}. */ requiredTransport?: ChannelType; /** * Per-call soft transport preference. Overrides {@link Peer.transportPreference} for this * connection only and is honored only when the peer advertises matching server capability. */ preferredTransport?: ChannelType; /** * Per-call error handler, overrides {@link PeerConnection.Context.handleError} for this connection only. * * Note: if a connection process is already in progress for this peer, this handler is not applied to the * ongoing attempt. */ handleError?: (error: Error) => Duration | void; } } //# sourceMappingURL=Peer.d.ts.map