/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { OtaUpdateAvailableDetails, OtaUpdateStatus } from "#behavior/system/software-update/SoftwareUpdateManager.js";
import { OtaSoftwareUpdateProvider } from "#clusters/ota-software-update-provider";
import { Duration, MaybePromise, Timestamp } from "#general";
import { PeerAddress, ScopedStorage } from "#protocol";
import { FabricIndex, NodeId } from "#types";
import { OtaSoftwareUpdateProviderBehavior } from "./OtaSoftwareUpdateProviderBehavior.js";
interface OtaUpdateInProgressDetails {
    requestorNodeId: NodeId;
    fabricIndex: FabricIndex;
    lastState: OtaUpdateStatus;
    timestamp: Timestamp;
    versionToApply?: number;
    directConsentObtained?: boolean;
}
export declare enum OtaSoftwareUpdateConsentState {
    Granted = 0,
    Denied = 1,
    Obtaining = 2,
    Unknown = 3
}
/**
 * This is the default server implementation of {@link OtaSoftwareUpdateProviderBehavior}.
 *
 * This cluster is usually used by Controller nodes and allows Servers to handle OTA software updates.
 * For the state and detailed usage for Clients, please check the SoftwareUpdateManager behavior which provides
 * configurability for this.
 *
 *
 * For special use cases the cluster provides the following extension point methods:
 * * {@link checkUpdateAvailable}: By default, the implementation uses the SoftwareUpdatemanager to check for available
 *     updates from the DCL or being available in the local OTA storage. If this needs to be more vendor-specific, it
 *     can be implemented by overriding this method.
 *
 * * {@link requestUserConsentForUpdate}: If the client is able to gather user update consent via other means, then this can be
 *     implemented by overriding this method. One example could be that users state "automatic update" for certain peers
 *     or device types (e.g., sensors and lights but not sockets). This method then can be used to get such automatic
 *     consents that will be then applied in a queue.
 */
export declare class OtaSoftwareUpdateProviderServer extends OtaSoftwareUpdateProviderBehavior {
    #private;
    readonly internal: OtaSoftwareUpdateProviderServer.Internal;
    initialize(): Promise<void>;
    get updateStorage(): ScopedStorage;
    /**
     * Default implementation of the QueryImage command according to Matter specification.
     */
    queryImage(request: OtaSoftwareUpdateProvider.QueryImageRequest): Promise<OtaSoftwareUpdateProvider.QueryImageResponse>;
    /**
     * Default implementation of the ApplyUpdate command according to Matter specification.
     * We always allow updated to be executed immediately by the device.
     */
    applyUpdateRequest({ updateToken, newVersion, }: OtaSoftwareUpdateProvider.ApplyUpdateRequest): Promise<OtaSoftwareUpdateProvider.ApplyUpdateResponse>;
    /**
     * Default implementation of the NotifyUpdateApplied command according to Matter specification.
     */
    notifyUpdateApplied({ updateToken, softwareVersion, }: OtaSoftwareUpdateProvider.NotifyUpdateAppliedRequest): void;
    /**
     * Extension method if the node wants to handle automatic user consent gathering itself. By default, it declines
     * the update request and informs the node of the available update.
     */
    protected requestUserConsentForUpdate(_request: OtaSoftwareUpdateProvider.QueryImageRequest, _updateDetails: OtaUpdateAvailableDetails, _peerAddress: PeerAddress): MaybePromise<{
        consentState: OtaSoftwareUpdateConsentState;
        delayTime?: Duration;
    }>;
    /**
     * Override to customize how to check for available updates.
     * The default logic also validates the node details like vendorId and productId and the current version.
     * When the requestorCanConsent is true, we send the latest update we have also without a consent.
     * All additional data like hardware, location, and MetadataForProvider can be checked here for specific logic
     */
    protected checkUpdateAvailable(request: OtaSoftwareUpdateProvider.QueryImageRequest, peerAddress: PeerAddress): MaybePromise<OtaUpdateAvailableDetails | undefined>;
}
export declare namespace OtaSoftwareUpdateProviderServer {
    class Internal {
        /** Keyed by the requestorNodeId+fabricIndex+updateToken */
        inProgressDetails: Map<string, OtaUpdateInProgressDetails>;
        updateStorage: ScopedStorage;
    }
    const ExtensionInterface: {
        /**
         * Override to customize how to ask for user consent for an update.
         * This method should return the current state of the consent and potentially trigger a User consent request in
         * parallel. If the consent is not yet obtained, return `Obtaining`.
         * The default implementation always returns `Unknown` which declines all non-consented updates.
         * @param request
         * @param updateDetails
         * @param peerAddress
         * @returns The consent state and optionally a delay time in seconds after which the requestor should retry (mainly needed for "Obtaining" state.
         * @protected
         */
        requestUserConsentForUpdate(request: OtaSoftwareUpdateProvider.QueryImageRequest, updateDetails: OtaUpdateAvailableDetails, peerAddress: PeerAddress): MaybePromise<{
            consentState: OtaSoftwareUpdateConsentState;
            delayTime?: Duration;
        }>;
        /**
         * Override to customize how to check for available updates.
         * @param request
         * @param peerAddress
         */
        checkUpdateAvailable(request: OtaSoftwareUpdateProvider.QueryImageRequest, peerAddress: PeerAddress): MaybePromise<OtaUpdateAvailableDetails | undefined>;
    };
}
export {};
//# sourceMappingURL=OtaSoftwareUpdateProviderServer.d.ts.map