/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { FabricGroups } from "#groups/FabricGroups.js"; import { FabricIcd } from "#icd/FabricIcd.js"; import { FabricAccessControl } from "#interaction/FabricAccessControl.js"; import { PeerAddress } from "#peer/PeerAddress.js"; import { MessageExchange } from "#protocol/MessageExchange.js"; import { SecureSession } from "#session/SecureSession.js"; import { AsyncObservable, BinaryKeyPair, Bytes, Crypto, Key, MatterError, MaybePromise, PrivateKey, StorageContext } from "@matter/general"; import { FabricId, FabricIndex, GlobalFabricId, GroupId, NodeId, VendorId } from "@matter/types"; export declare class PublicKeyError extends MatterError { } export type ExposedFabricInformation = { fabricIndex: FabricIndex; fabricId: FabricId; nodeId: NodeId; rootNodeId: NodeId; rootVendorId: VendorId; label: string; }; export declare class Fabric { #private; readonly fabricIndex: FabricIndex; readonly fabricId: FabricId; readonly nodeId: NodeId; readonly rootNodeId: NodeId; readonly globalId: GlobalFabricId; readonly rootCert: Bytes; readonly identityProtectionKey: Bytes; readonly operationalIdentityProtectionKey: Bytes; readonly intermediateCACert: Bytes | undefined; readonly operationalCert: Bytes; /** * Create a fabric synchronously. * * Certain derived fields that require async crypto operations to compute must be supplied here. Use {@link create} * to populate these fields automatically. */ constructor(crypto: Crypto, config: Fabric.ConstructorConfig); /** * Create a fabric. * * This async creation path populates derived fields that require async crypto operations to compute. */ static create(crypto: Crypto, config: Fabric.Config): Promise; get crypto(): Crypto; /** * Obtain configuration required to recreate fabric. * * TODO - we currently use this for persistence; remove when we move to OperationalCredentials as "source of truth" */ get config(): Fabric.SyncConfig; get label(): string; setLabel(label: string): Promise; get vidVerificationStatement(): AllowSharedBufferSource | undefined; updateVendorVerificationData(vendorId: VendorId | undefined, vidVerificationStatement: Bytes | undefined, vvsc: Bytes | undefined): Promise; get vvsc(): AllowSharedBufferSource | undefined; get rootPublicKey(): AllowSharedBufferSource; get rootVendorId(): VendorId; set storage(storage: StorageContext); get storage(): StorageContext | undefined; get groups(): FabricGroups; get icd(): FabricIcd; /** * Take over the runtime state of {@link previous}, the object this one replaces for the same fabric: groups, access * control, ICD state and the storage context. Both objects then share the same instances, so sessions still bound * to {@link previous} see every change. The derived group keys depend on the root, fabric ID and IPK, so these * must be unchanged. */ takeOverRuntimeStateOf(previous: Fabric): void; /** * Release in-memory resources that must not outlive the fabric — currently the ICD wakefulness timers, which would * otherwise keep firing and delay node shutdown. Does not delete or unpersist the fabric. * * The instances are shared with replaced objects of the same fabric, so only `FabricManager` disposes. */ [Symbol.dispose](): void; /** * True when this fabric has controller-role ICD peers whose Check-Ins we receive. Lets inbound Check-In processing * skip fabrics with no receive path — in particular a pure ICD device, which holds only device-role registrations * (it sends Check-Ins, never receives them) and must not trial-decrypt inbound Check-In messages. */ get icdActive(): boolean; /** Record a message received from a peer, for its ICD wakefulness. */ notePeerActive(peerNodeId: NodeId): void; get accessControl(): FabricAccessControl; get publicKey(): AllowSharedBufferSource; get isDeleting(): boolean; get leaving(): AsyncObservable<[], void>; get deleting(): AsyncObservable<[], void>; get deleted(): AsyncObservable<[], void>; sign(data: Bytes): MaybePromise; verifyCredentials(operationalCert: Bytes, intermediateCACert?: Bytes): Promise; matchesFabricIdAndRootPublicKey(fabricId: FabricId, rootPublicKey: Bytes): boolean; matchesKeyPair(keyPair: Key): boolean; /** * Returns the destination IDs for a given nodeId, random value and optional groupId. When groupId is provided, it * returns the time-wise valid operational keys for that groupId. */ currentDestinationIdFor(nodeId: NodeId, random: Bytes): Promise; /** * Returns the destination IDs for a given nodeId, random value and optional groupId. When groupId is provided, it * returns all operational keys for that groupId. */ destinationIdsFor(nodeId: NodeId, random: Bytes): Promise; addSession(session: SecureSession): void; deleteSession(session: SecureSession): void; hasSessionForPeer(peerNodeId: NodeId): true | undefined; set persistCallback(callback: ((isUpdate?: boolean) => MaybePromise) | undefined); /** * Handles actions when a fabric got replaced. * * It flushes subscriptions to ensure fabric updates are reported and closes sessions. */ replaced(currentExchange?: MessageExchange): Promise; /** * Gracefully exit the fabric. * * Devices should use this to cleanly exit a fabric. It flushes subscriptions to ensure the "leave" event emits * and closes sessions. */ leave(currentExchange?: MessageExchange): Promise; /** * Permanently remove the fabric. * * Does not emit the leave event. */ delete(currentExchange?: MessageExchange): Promise; persist(isUpdate?: boolean): MaybePromise | undefined; get externalInformation(): ExposedFabricInformation; addressOf(nodeId: NodeId): PeerAddress; groupAddressOf(groupId: GroupId): { fabricIndex: FabricIndex; nodeId: NodeId; }; } export declare class FabricBuilder { #private; constructor(crypto: Crypto, key: PrivateKey); static create(crypto: Crypto): Promise; get publicKey(): AllowSharedBufferSource; get fabricIndex(): FabricIndex | undefined; createCertificateSigningRequest(): Promise; setRootCert(rootCert: Bytes): Promise; get rootCert(): AllowSharedBufferSource | undefined; setOperationalCert(operationalCert: Bytes, intermediateCACert?: Bytes): Promise; /** * Take over the data of {@link fabric} and install a new NOC for it, as UpdateNOC and NOC rotation do. The NOC * must chain to the fabric's root and carry its fabric ID. * * @see {@link MatterSpecification.v161.Core} § 11.18.6.9.1 */ updateOperationalCert(fabric: Fabric, operationalCert: Bytes, intermediateCACert?: Bytes): Promise; setRootVendorId(rootVendorId: VendorId): this; setRootNodeId(rootNodeId: NodeId): this; setIdentityProtectionKey(key: Bytes): this; setLabel(label: string): this; get globalId(): Promise; get nodeId(): NodeId | undefined; get fabricId(): FabricId | undefined; get keyPair(): PrivateKey; build(fabricIndex: FabricIndex): Promise; } export declare namespace Fabric { /** * Configuration required to initialize a fabric. */ type Config = { fabricIndex: FabricIndex; fabricId: FabricId; nodeId: NodeId; rootNodeId: NodeId; keyPair: BinaryKeyPair; rootVendorId: VendorId; rootCert: Bytes; identityProtectionKey: Bytes; vidVerificationStatement?: Bytes; vvsc?: Bytes; intermediateCACert: Bytes | undefined; operationalCert: Bytes; label: string; rootPublicKey?: Bytes; globalId?: GlobalFabricId; operationalIdentityProtectionKey?: Bytes; }; /** * Configuration required to initialize a fabric without asynchronous crypto operations. */ type SyncConfig = Config & { operationalIdentityProtectionKey: Bytes; globalId: GlobalFabricId; }; /** * Configuration passed to fabric constructor. * * Provides deprecated fields for backwards compatibility. */ type ConstructorConfig = Omit & ({ globalId: GlobalFabricId; } | { /** @deprecated */ operationalId: Bytes; }); /** * An object that may be used to identify a fabric. */ type Identifier = FabricIndex | GlobalFabricId | { fabricIndex: FabricIndex; }; } //# sourceMappingURL=Fabric.d.ts.map