/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Bytes, type Cipher, MatterError, MaybePromise, Timer, Timestamp } from "@matter/general"; import { DoorLock } from "@matter/types/clusters/door-lock"; import { LockAuth } from "./LockAuth.js"; import { LockSchedule } from "./LockSchedule.js"; import OperationError = DoorLock.OperationError; /** * Thrown by {@link DoorLockBaseServer.handleLockOperation} when the lock hardware cannot complete an operation. * * The server reports {@link reason} in the `LockOperationError` event and answers the command with FAILURE, for * example `throw new LockOperationFailedError(DoorLock.OperationError.InsufficientBattery)`. The reason comes first * because it is what the server reports; the message defaults to one naming it. * * @see {@link MatterSpecification.v161.Cluster} § 5.2.6.14, § 5.2.11.4 */ export declare class LockOperationFailedError extends MatterError { readonly reason: OperationError; constructor(reason: OperationError, message?: string, options?: ErrorOptions); } declare const DoorLockBaseServerClass: import("../../index.js").ClusterBehavior.Type, import("@matter/types").ClusterType.Concrete, new () => {}, "doorLock">; /** * Full DoorLock server implementation covering all features including User and schedules. * * The server stores users, credentials, and schedules in nonvolatile extension fields on the State class. Credential * data is encrypted at rest with AES-128-CCM by default. Override {@link cipher} for custom encryption (e.g. HSM) or * {@link auth} to replace the entire storage backend. * * To drive real lock hardware, override {@link handleLockOperation} instead of the lock commands, so the hardware moves * only for an authorized operation. */ export declare class DoorLockBaseServer extends DoorLockBaseServerClass { #private; readonly state: DoorLockBaseServer.State; readonly internal: DoorLockBaseServer.Internal; initialize(): MaybePromise; [Symbol.asyncDispose](): MaybePromise; lockDoor(request: DoorLock.LockDoorRequest): Promise; unlockDoor(request: DoorLock.UnlockDoorRequest): Promise; unlockWithTimeout(request: DoorLock.UnlockWithTimeoutRequest): Promise; /** * Unbolting retracts the bolt without pulling the latch, so the lock ends up Unlocked and reports an Unlock. * * @see {@link MatterSpecification.v161.Cluster} § 5.2.10.25, § 5.2.11.3 */ unboltDoor(request: DoorLock.UnboltDoorRequest): Promise; /** * Moves the lock hardware. Override to drive a real lock; the default implementation does nothing. * * The server calls this once a remote lock command is authorized, before it sets `lockState` and reports the * operation, and for auto-relock. Both hold the lock of this behavior, so calls never overlap. Lock commands * invoked locally, without a fabric, are refused before this runs. * * To fail the operation, throw. `lockState` stays unchanged and `LockOperationError` reports the reason of a * {@link LockOperationFailedError}, or `Unspecified` for any other error, which is also logged with its stack. A * failed command is answered with FAILURE and state written here is discarded; a failed auto-relock keeps such * state and is not retried. Report a jam through the `doorLockAlarm` event. * * Override without `protected`: the {@link DoorLockBaseServer.ExtensionInterface} makes it public on the server * types derived with `with()`. * * @param operation what the hardware has to do and who asked for it * @see {@link MatterSpecification.v161.Cluster} § 5.2.10.1, § 5.2.10.2, § 5.2.10.3, § 5.2.10.25 */ protected handleLockOperation(_operation: DoorLockBaseServer.LockOperation): MaybePromise; /** * The cipher used for credential encryption. Override to integrate with an HSM or other secure storage. */ get cipher(): Cipher; /** * The credential/user store with integrated encryption. Override to replace the entire storage backend. */ get auth(): LockAuth.Store; setUser(request: DoorLock.SetUserRequest): MaybePromise; getUser(request: DoorLock.GetUserRequest): DoorLock.GetUserResponse; clearUser(request: DoorLock.ClearUserRequest): MaybePromise; setCredential(request: DoorLock.SetCredentialRequest): DoorLock.SetCredentialResponse; getCredentialStatus(request: DoorLock.GetCredentialStatusRequest): DoorLock.GetCredentialStatusResponse; clearCredential(request: DoorLock.ClearCredentialRequest): MaybePromise; setWeekDaySchedule(request: DoorLock.SetWeekDayScheduleRequest): MaybePromise; getWeekDaySchedule(request: DoorLock.GetWeekDayScheduleRequest): DoorLock.GetWeekDayScheduleResponse; clearWeekDaySchedule(request: DoorLock.ClearWeekDayScheduleRequest): MaybePromise; setYearDaySchedule(request: DoorLock.SetYearDayScheduleRequest): MaybePromise; getYearDaySchedule(request: DoorLock.GetYearDayScheduleRequest): DoorLock.GetYearDayScheduleResponse; clearYearDaySchedule(request: DoorLock.ClearYearDayScheduleRequest): MaybePromise; setHolidaySchedule(request: DoorLock.SetHolidayScheduleRequest): MaybePromise; getHolidaySchedule(request: DoorLock.GetHolidayScheduleRequest): DoorLock.GetHolidayScheduleResponse; clearHolidaySchedule(request: DoorLock.ClearHolidayScheduleRequest): MaybePromise; } export declare namespace DoorLockBaseServer { /** The movement a lock operation asks of the hardware; "unbolt" retracts the bolt without pulling the latch */ type Actuation = "lock" | "unlock" | "unbolt"; /** A lock operation {@link DoorLockBaseServer.handleLockOperation} carries out */ interface LockOperation { actuation: Actuation; /** `Remote` for a command, `Auto` for auto-relock */ source: DoorLock.OperationSource; /** The user the PIN of a remote operation identifies */ userIndex: number | null; } class State extends DoorLockBaseServerClass.State { /** * Internal user database. */ users: LockAuth.User[]; /** * Internal credential store. */ credentials: LockAuth.Credential[]; /** * Internal week day schedule store. */ weekDaySchedules: LockSchedule.WeekDay[]; /** * Internal year day schedule store. */ yearDaySchedules: LockSchedule.YearDay[]; /** * Internal holiday schedule store. */ holidaySchedules: LockSchedule.Holiday[]; /** * AES-128-CCM key for credential encryption. Auto-generated on first use. */ credentialKey?: Bytes; } class Internal { wrongCodeCount: number; lockoutEndsAt?: Timestamp; autoRelockTimer?: Timer; expiryTimers: Map; expireUser?: (userIndex: number) => void; autoRelock?: (timer: Timer) => void; } const ExtensionInterface: { handleLockOperation(operation: LockOperation): MaybePromise; }; } declare const DoorLockServer_base: import("../../index.js").ClusterBehavior.Type, { aliroBleuwb: false; aliroProvisioning: false; credentialOverTheAirAccess: false; doorPositionSensor: false; faceCredentials: false; fingerCredentials: false; holidaySchedules: false; pinCredential: false; rfidCredential: false; unbolting: false; user: false; weekDayAccessSchedules: false; yearDayAccessSchedules: false; }>, import("@matter/types").ClusterType.Concrete, typeof DoorLockBaseServer.Internal, "doorLock">; /** * Default DoorLock server with no features enabled. Use `.with()` to enable features. */ export declare class DoorLockServer extends DoorLockServer_base { } export {}; //# sourceMappingURL=DoorLockServer.d.ts.map