export type CyncApiError = { status: number; statusText: string; body: unknown; code?: number; msg?: string; }; export interface CyncLoginSession { accessToken: string; userId: string; authorize?: string; refreshToken?: string; expiresAt?: number; raw: unknown; } export interface CyncDevice { id: string; name?: string; product_id?: string; device_id?: string; mac?: string; sn?: string; switch_id?: string; /** uint32 LAN controller ID, derived from raw_switch_id when the REST API returns a composite value */ switch_controller?: number | string; /** Original switchID from the Cync REST API — may be a composite value encoding a device index */ raw_switch_id?: number; /** Trailing device index encoded in raw_switch_id when it exceeds uint32 range (e.g. 1850364131001 → 1) */ switch_index?: number; mesh_id?: number | string; [key: string]: unknown; } export interface CyncDeviceMesh { id: string; name?: string; product_id: string; access_key?: string; mac?: string; properties?: Record; devices?: CyncDevice[]; [key: string]: unknown; } export interface CyncCloudConfig { meshes: CyncDeviceMesh[]; } export interface CyncRefreshResponse { accessToken: string; refreshToken?: string; expiresAt?: number; } export interface CyncLogger { debug(message: string, ...args: unknown[]): void; info(message: string, ...args: unknown[]): void; warn(message: string, ...args: unknown[]): void; error(message: string, ...args: unknown[]): void; } export declare class ConfigClient { private readonly log; private accessToken; private userId; private authorize; constructor(logger?: CyncLogger); /** * Request that Cync send a one-time 2FA verification code to the given email. * * This MUST be called before loginWithTwoFactor() for accounts that require 2FA. * The user reads the code from their email and provides it to loginWithTwoFactor. */ sendTwoFactorCode(email: string): Promise; /** * Perform the actual 2FA login and capture the access token + userId. * * You are expected to first call sendTwoFactorCode(), then prompt the user * for the emailed OTP code, then call loginWithTwoFactor() with that code. * * The access token is used for subsequent getCloudConfig() / getDeviceProperties() calls. */ loginWithTwoFactor(email: string, password: string, otpCode: string): Promise; /** * Password-only login for background refresh. * * This uses the /user_auth endpoint (no two_factor) and is intended * for automatic re-auth when the access token has expired, after an * initial 2FA bootstrap has already been completed. */ loginWithPassword(email: string, password: string): Promise; /** * Refresh the access token using a stored refresh token. * * This mirrors the 2FA login flow in shape, but only exchanges the * refresh_token for a new access_token (and possibly a new refresh_token). */ refreshAccessToken(refreshToken: string): Promise; /** * Fetch the list of meshes/devices for the current user from the cloud. * * This roughly matches CyncCloudAPI.get_devices() from cync-lan, but in a * simplified, single-call interface. */ getCloudConfig(): Promise; /** * Convenience to fetch the properties object for a single device. */ getDeviceProperties(productId: string, deviceId: string): Promise>; restoreSession(accessToken: string, userId: string): void; getSessionSnapshot(): { accessToken: string | null; userId: string | null; }; private readBodyOnce; private ensureSession; static buildLanLoginCode(userId: string, authorize: string): Uint8Array; private static randomLoginResource; }