/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Message } from "#codec/MessageCodec.js"; import { Fabric as RealFabric } from "#fabric/Fabric.js"; import { NodeSession as RealNodeSession } from "#session/NodeSession.js"; import { Session } from "#session/Session.js"; import { AsyncObservable, Bytes, Channel, ChannelType, Crypto, MaybePromise, Observable, ServerAddressUdp, UdpNetworkChannel } from "@matter/general"; import { Status } from "@matter/types"; import { MessageChannel as RealMessageChannel } from "./MessageChannel.js"; import { MessageExchange, MessageExchangeContext } from "./MessageExchange.js"; export declare namespace ProtocolMocks { /** * A fabric that will fill any fields not provided with placeholder values. */ class Fabric extends RealFabric { constructor(config?: Partial, crypto?: Crypto); } namespace Fabric { const defaults: RealFabric.SyncConfig; } /** * A mock {@link NodeSession} that supports functional tests without full mock networking. */ class NodeSession extends RealNodeSession { constructor(config?: NodeSession.Config); static create(config: NodeSession.CreateConfig): Promise; } namespace NodeSession { type Config = Partial & MockSessionConfig; type CreateConfig = Partial; } /** * A mock channel that can act as a placeholder without full mock networking. */ class NetworkChannel implements UdpNetworkChannel { #private; maxPayloadSize: number; isReliable: boolean; supportsLargeMessages: boolean; name: string; type: ChannelType; networkAddressChanged: Observable<[ServerAddressUdp], void>; constructor(config: MockNetworkConfig); get networkAddress(): ServerAddressUdp; set networkAddress(networkAddress: ServerAddressUdp); send(): Promise; close(): Promise; } /** * A mock message channel that stores outbound messages for later analysis. */ class MessageChannel extends RealMessageChannel { #private; constructor(config?: { channel?: Channel; session?: Session; onClose?: () => MaybePromise; index?: number; fabricIndex?: number; }); send(message: Message): Promise; read(): Promise; get readReady(): AsyncObservable<[], void>; } /** * A mock message exchange that "transports" messages via internal queues. */ class Exchange extends MessageExchange { #private; constructor(config?: Omit, "context"> & MockSessionConfig & { context?: Partial; fabric?: Fabric; }); /** * Enqueue a mock response. */ write(message: Message): Promise; /** * Enqueue a mock status response. */ writeStatus(status?: Status): Promise; /** * Wait for a mock request. */ read(): Promise; /** * Emits when read() won't block. */ get readReady(): AsyncObservable<[], void>; nextMessage(): Promise; } interface MockNetworkConfig { index?: number; maxPayloadSize?: number; } interface MockSessionConfig extends MockNetworkConfig { fabricIndex?: number; } } //# sourceMappingURL=ProtocolMocks.d.ts.map