/** * @license * Copyright 2022-2023 Project CHIP Authors * SPDX-License-Identifier: Apache-2.0 */ import { Subject } from "#action/server/Subject.js"; import { DecodedMessage, DecodedPacket, Message, Packet, SessionType } from "#codec/MessageCodec.js"; import type { Fabric } from "#fabric/Fabric.js"; import type { FabricManager } from "#fabric/FabricManager.js"; import type { MessageCounter } from "#protocol/MessageCounter.js"; import { Bytes, MatterFlowError, Transport } from "@matter/general"; import { FabricIndex, GroupId, NodeId } from "@matter/types"; import { SecureSession } from "./SecureSession.js"; import { Session } from "./Session.js"; import { SessionManager } from "./SessionManager.js"; /** Thrown by {@link GroupSession.decode} when no installed key can be a candidate for the received group message. */ export declare class GroupSessionNoKeyError extends MatterFlowError { /** * Group id of the message, when a key set decrypted it successfully but is not usable because no group maps to it. * The id is authenticated in that case, so Groupcast testing may derive the arrival address from it. */ readonly groupId?: GroupId; /** The fabric of the key set that authenticated the message, set together with {@link groupId} */ readonly fabric?: Fabric; constructor(message?: string, authenticated?: { groupId: GroupId; fabric: Fabric; }); } /** Thrown by {@link GroupSession.decode} when decryption failed with all candidate keys. */ export declare class GroupSessionDecodeError extends MatterFlowError { constructor(message?: string); } /** Secure Group session instance */ export declare class GroupSession extends SecureSession { #private; readonly supportsMRP = false; readonly closingAfterExchangeFinished = false; readonly keySetId: number; constructor(config: GroupSession.Config); /** IPv6 multicast destination address this group session sends to. */ get multicastAddress(): string; /** * Where a message on this session's group is addressed, in the form an IPv6 destination is * written: the multicast address in brackets and the port beside it. Group traffic goes to the * standard port, which is what makes the pair worth printing together — an address alone does not * say where a message went. A session created from a received packet reports the same pair, though * it sends nothing itself. */ get destination(): string; /** * Create an outbound group session. */ static create(options: { manager?: SessionManager; transports: Transport.Provider; id: number; fabric: Fabric; keySetId: number; groupNodeId: NodeId; operationalGroupKey: Bytes; messageCounter: MessageCounter; }): Promise; get type(): SessionType; /** * Core Specification, Secure Channel, "Sending a group message": the Security Flags SHALL have the P Flag set, so * group multicasts are always sent privacy-enhanced. */ get usePrivacy(): boolean; /** * The current Fabric object of this session's fabric. A replacement (UpdateNOC) can change the node ID this * session sends as, so the object it was created with is used only while the fabric is being removed. */ get fabric(): Fabric; get id(): number; get peerSessionId(): number; get via(): string; get nodeId(): NodeId; get peerNodeId(): NodeId; get associatedFabric(): Fabric; /** * The peer group's address. */ get peerAddress(): { fabricIndex: FabricIndex; nodeId: NodeId; }; subjectFor(message?: Message): Subject; /** * Whether this cached session was established for the given fabric, group session id and operational key. Session * ids are a 16-bit hash of the operational key, so two key sets can share one; a cached session must therefore be * matched by key (and fabric), never by session id alone, or a later message would be evaluated against a stale key. */ matches(fabricIndex: FabricIndex, id: number, operationalKey: Bytes): boolean; notifyActivity(_messageReceived: boolean): void; updateMessageCounter(messageCounter: number, sourceNodeId: NodeId, operationalKey: Bytes): void; encode(message: Message): Packet; decode(): DecodedMessage; static decode(fabrics: FabricManager, { header, applicationPayload, messageExtension, privacyHeader }: DecodedPacket, aad: Bytes): { message: DecodedMessage; key: Bytes; privacyKey?: Bytes; sessionId: number; sourceNodeId: NodeId; keySetId: number; fabric: Fabric; }; close(): Promise; } export declare namespace GroupSession { interface Config extends Session.CommonConfig { id: number; fabric: Fabric; keySetId: number; peerNodeId: NodeId; operationalGroupKey: Bytes; operationalPrivacyKey?: Bytes; multicastAddress: string; messageCounter: MessageCounter; } function assert(session?: Session, errorText?: string): asserts session is GroupSession; function is(session?: Session): session is GroupSession; } //# sourceMappingURL=GroupSession.d.ts.map