/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { TransientPeerCommunicationError } from "#peer/PeerCommunicationError.js"; import { Bytes, Duration } from "@matter/general"; import { GeneralStatusCode, SecureChannelStatusCode, SecureMessageType, TlvSchema, VendorId } from "@matter/types"; import { Message, PayloadHeader } from "../codec/MessageCodec.js"; import { ExchangeSendOptions, MessageExchange } from "../protocol/MessageExchange.js"; /** Error base Class for all errors related to the status response messages. */ export declare class ChannelStatusResponseError extends TransientPeerCommunicationError { readonly generalStatusCode: GeneralStatusCode; readonly protocolStatusCode: SecureChannelStatusCode; readonly vendorId?: VendorId | undefined; readonly protocolData?: Bytes | undefined; busyDelay?: Duration; constructor(message: string, generalStatusCode: GeneralStatusCode, protocolStatusCode: SecureChannelStatusCode, vendorId?: VendorId | undefined, protocolData?: Bytes | undefined); } /** Chip SDK uses this value when performance wise heavy crypto operations are expected. */ export declare const EXPECTED_CRYPTO_PROCESSING_TIME: Duration; /** This value is used by chip SDK when normal processing time is expected. */ export declare const DEFAULT_NORMAL_PROCESSING_TIME: Duration; export declare class SecureChannelMessenger { #private; readonly exchange: MessageExchange; constructor(exchange: MessageExchange, defaultExpectedProcessingTime?: Duration); get channel(): import("../index.js").MessageChannel; get via(): string; /** * Waits for the next message and returns it. * * {@link expectedProcessingTime} defaults to {@link EXPECTED_CRYPTO_PROCESSING_TIME}. */ nextMessage({ type, expectedProcessingTime, description, abort, }?: SecureChannelMessenger.ReadOptions): Promise; /** * Waits for the next message and decodes it. * * When no expectedProcessingTimeMs is provided, the default value of EXPECTED_CRYPTO_PROCESSING_TIME is used. */ nextMessageDecoded(schema: TlvSchema, options?: SecureChannelMessenger.ReadOptions): Promise; /** * Decodes the payload of a message received from the peer. * * A payload that violates the schema is data the peer sent, so the error is an {@link UnexpectedDataError} * naming the message and field, with the {@link ValidationError} as cause. */ protected decode(schema: TlvSchema, { payload, payloadHeader: { messageType }, }: Pick & { payloadHeader: Pick; }): T; /** * Waits for the next message and returns it. * * When no expectedProcessingTimeMs is provided, the default value of EXPECTED_CRYPTO_PROCESSING_TIME is used. */ waitForSuccess(options?: Omit): Promise; /** * Sends a message of the given type with the given payload. * * If no ExchangeSendOptions are provided, the expectedProcessingTimeMs will be set to * EXPECTED_CRYPTO_PROCESSING_TIME. */ send(message: T, type: number, schema: TlvSchema, options?: ExchangeSendOptions): Promise; sendError(code: SecureChannelStatusCode, abort?: AbortSignal): Promise; sendSuccess(abort?: AbortSignal): Promise; sendBusy(minimumRetryInterval: Duration, abort?: AbortSignal): Promise; sendCloseSession(abort?: AbortSignal): Promise; get channelName(): string; [Symbol.asyncDispose](): Promise; close(): Promise; protected throwIfErrorStatusReport(message: Message, logHint?: string): void; } export declare namespace SecureChannelMessenger { /** * Controls message read. */ interface ReadOptions { /** * The expected type of the message. * * The messenger throws an error if a message arrives that is not of this type. */ type?: SecureMessageType; /** * Processing time used as input to timeout algorithms. */ expectedProcessingTime?: Duration; /** * Description of read operation used in diagnostic messages. */ description?: string; /** * Aborts the read. */ abort?: AbortSignal; } } //# sourceMappingURL=SecureChannelMessenger.d.ts.map