/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import type { Crypto } from "@matter/general"; import { Bytes, Observable } from "@matter/general"; import { type SubjectId, NodeId } from "@matter/types"; import type { IcdManagement } from "@matter/types/clusters/icd-management"; import { IcdPeerWakefulness } from "./IcdPeerWakefulness.js"; /** * Runtime per-fabric ICD state, available as {@link Fabric#icd}. * * Populated by owning behaviors at init; persistence stays with those behaviors. * * @see {@link MatterSpecification.v161.Core} § 9.16.6.4 (device-role registrations) * @see {@link MatterSpecification.v161.Core} § 4.22.4.2 (controller-role trial decryption) */ export declare class FabricIcd { #private; constructor(crypto: Crypto); /** * Emits the peer node ID when a peer's registration starts ({@link addPeer} of an unregistered peer), i.e. * {@link wakefulnessFor} starts returning its {@link IcdPeerWakefulness}. A sustained subscription running without * a wakefulness races this signal to observe the peer's mode from then on. */ get peerFed(): Observable<[NodeId], void>; /** All registered check-in clients for this fabric. */ get registrations(): FabricIcd.Registration[]; /** Adds or replaces a registration, keyed by checkInNodeId. */ setRegistration(registration: FabricIcd.Registration): void; deleteRegistration(checkInNodeId: NodeId): void; clearRegistrations(): void; /** * Register a peer's Check-In key and handler. The peer keeps one {@link IcdPeerWakefulness} for its lifetime on * this fabric, so a repeated registration updates the key and handler and resumes the wakefulness with its history. */ addPeer(peer: FabricIcd.Peer, handler: FabricIcd.CheckInHandler): void; /** * Set the key a key refresh offers the peer. Until the refresh is confirmed, Check-Ins decrypt with the current * key or this one, because the peer may have accepted it without the confirmation reaching us. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.4, § 9.16.7.1 */ setPendingKey(peerNodeId: NodeId, pendingKey: Bytes): void; /** * Whether the last Check-In accepted under the peer's current key requires a key refresh. Asked when the refresh * would start, so a key confirmed in the meantime answers false. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.4.1 */ refreshNeeded(peerNodeId: NodeId): boolean; /** * Apply the starting counter a key refresh response reported for `key`: * * - a pending `key` replaces the current one, starting at `counterStart`; * - a `key` a Check-In already promoted keeps its last accepted counter, now measured from `counterStart`; if that * counter lies before `counterStart`, the Check-In's baseline stays; * - any other `key` changes nothing. * * Returns false only in the last case. * * @see {@link MatterSpecification.v161.Core} § 4.22.3.4, § 9.16.7.1 */ confirmKey(peerNodeId: NodeId, key: Bytes, counterStart: number): boolean; peerFor(peerNodeId: NodeId): FabricIcd.Peer | undefined; /** The wakefulness of a registered peer. */ wakefulnessFor(peerNodeId: NodeId): IcdPeerWakefulness | undefined; /** * Remove a peer's registration. The controller no longer awaits its Check-Ins, so its wakefulness is suspended * until the peer is registered again. */ deletePeer(peerNodeId: NodeId): void; /** Remove a peer that left the fabric, with its wakefulness; a later peer with the same node ID starts afresh. */ removePeer(peerNodeId: NodeId): void; /** Record a message received from a peer, for its wakefulness. */ notePeerActive(peerNodeId: NodeId): void; get hasPeers(): boolean; /** * In-memory teardown for shutdown: cancel every peer's wakefulness timers so they do not outlive the fabric (e.g. * delaying node shutdown). Does not unpersist registrations. */ close(): void; [Symbol.dispose](): void; /** * Trial-decrypts a Check-In payload against all registered peer keys, and against a peer's pending key. * * The first Check-In under a pending key proves the peer switched to it, so that key replaces the current one. * * Returns true if a key matched (even when the counter was a replay), false when no key decrypted the payload. * * @see {@link MatterSpecification.v161.Core} § 4.22.4.2 */ processCheckIn(payload: Bytes): Promise; } export declare namespace FabricIcd { /** * A registered check-in client entry (mirrors IcdManagement RegisteredClients). * * @see {@link MatterSpecification.v161.Core} § 9.16.6.4 */ interface Registration { checkInNodeId: NodeId; monitoredSubject: SubjectId; key: Bytes; clientType: IcdManagement.ClientType; } /** A registered ICD peer on the controller side, with rolling counter state. */ interface Peer { peerNodeId: NodeId; key: Bytes; counterStart: number; lastOffset: number; /** Key offered to the peer by a key refresh that is not confirmed yet. */ pendingKey?: Bytes; } /** Data delivered to the handler when a check-in is successfully decrypted and validated. */ interface ReceivedCheckIn { peerNodeId: NodeId; counter: number; activeModeThreshold: number; } type CheckInHandler = (checkIn: ReceivedCheckIn) => void; } //# sourceMappingURL=FabricIcd.d.ts.map