/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { FabricGroups } from "#groups/FabricGroups.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<Fabric>;
    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<void>;
    get vidVerificationStatement(): AllowSharedBufferSource | undefined;
    updateVendorVerificationData(vendorId: VendorId | undefined, vidVerificationStatement: Bytes | undefined, vvsc: Bytes | undefined): Promise<void>;
    get vvsc(): AllowSharedBufferSource | undefined;
    get rootPublicKey(): AllowSharedBufferSource;
    get rootVendorId(): VendorId;
    set storage(storage: StorageContext);
    get storage(): StorageContext | undefined;
    get groups(): FabricGroups;
    get accessControl(): FabricAccessControl;
    get publicKey(): AllowSharedBufferSource;
    get isDeleting(): boolean | undefined;
    get leaving(): AsyncObservable<[], void>;
    get deleting(): AsyncObservable<[], void>;
    get deleted(): AsyncObservable<[], void>;
    sign(data: Bytes): MaybePromise<import("@matter/general").EcdsaSignature>;
    verifyCredentials(operationalCert: Bytes, intermediateCACert?: Bytes): Promise<void>;
    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<AllowSharedBufferSource>;
    /**
     * 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<AllowSharedBufferSource[]>;
    addSession(session: SecureSession): void;
    deleteSession(session: SecureSession): void;
    hasSessionForPeer(peerNodeId: NodeId): true | undefined;
    set persistCallback(callback: (isUpdate?: boolean) => MaybePromise<void>);
    /**
     * Handles actions when a fabric got replaced.
     *
     * It flushes subscriptions to ensure fabric updates are reported and closes sessions.
     */
    replaced(currentExchange?: MessageExchange): Promise<void>;
    /**
     * 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<void>;
    /**
     * Permanently remove the fabric.
     *
     * Does not emit the leave event.
     */
    delete(currentExchange?: MessageExchange): Promise<void>;
    persist(isUpdate?: boolean): MaybePromise<void> | 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<FabricBuilder>;
    get publicKey(): AllowSharedBufferSource;
    get fabricIndex(): FabricIndex | undefined;
    createCertificateSigningRequest(): Promise<AllowSharedBufferSource>;
    setRootCert(rootCert: Bytes): Promise<this>;
    get rootCert(): AllowSharedBufferSource | undefined;
    setOperationalCert(operationalCert: Bytes, intermediateCACert?: Bytes): Promise<this>;
    setRootVendorId(rootVendorId: VendorId): this;
    setRootNodeId(rootNodeId: NodeId): this;
    setIdentityProtectionKey(key: Bytes): this;
    setLabel(label: string): this;
    initializeFromFabricForUpdate(fabric: Fabric): void;
    get globalId(): Promise<GlobalFabricId>;
    get nodeId(): NodeId | undefined;
    get fabricId(): FabricId | undefined;
    get keyPair(): PrivateKey;
    build(fabricIndex: FabricIndex): Promise<Fabric>;
}
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<SyncConfig, "globalId"> & ({
        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