import { ESPCDFAPIResponse, ESPCDFPaginatedAPIResponse, ESPCDFAPIDataResponse } from "../../types"; import type { GroupStoreCallbacks } from "../callbacks"; import type { ESPCDFProvisionResponse, AddOnNetworkDeviceParams } from "../provision"; import { ESPCDFGroup } from "../../entities/ESPCDFGroup"; import { ESPCDFGroupSharingRequest } from "../../entities/ESPCDFGroupSharingRequest"; import { ESPCDFNode } from "../../entities/ESPCDFNode"; import { ESPCDFProvisioningDevice } from "../../entities/ESPCDFProvisioningDevice"; /** * Operation types that can trigger callbacks */ export type ESPCDFUserOperationType = "getUserInfo" | "updateUserInfo" | "getCustomData" | "setCustomData" | "changePassword" | "updateName" | "requestAccountDeletion" | "confirmAccountDeletion" | "registerForNotification" | "unregisterForNotification" | "getIssuedGroupSharingRequests" | "getReceivedGroupSharingRequests" | "removeGroupSharingRequest" | "logout" | "setTimeZone" | "createGroup" | "createFabric" | "getGroups" | "getNodeDetails" | "syncHomeWithNodes" | "setCurrentHome" | "createHome" | "addDevice" | "addOnNetworkDevice" | "subscribeToNodeUpdates" | "unsubscribeFromNodeUpdates" | "sessionEnded"; /** * Why the SDK session ended without a logout call: a 401 (`unauthorized`), * the backend rejected the refresh token (`refreshRejected`), or the SDK found * no stored tokens (`missingTokens`). Adaptors may pass other strings. */ export type ESPCDFSessionEndReason = "unauthorized" | "refreshRejected" | "missingTokens" | string; /** Data of the `sessionEnded` user event. */ export interface ESPCDFSessionEndedData { reason: ESPCDFSessionEndReason; } export interface ESPCDFUserInfo { id: string; name: string; email: string; nickname?: string; phone?: string; [key: string]: any; } export interface ESPCDFUserOperation { getUserInfo(): Promise>; updateUserInfo(userInfo: Partial): Promise; getCustomData(): Promise; setCustomData(customData: ESPCDFUserCustomDataRequest): Promise; changePassword(oldPassword: string, newPassword: string): Promise; logout(): Promise; updateName(name: string): Promise; requestAccountDeletion(): Promise; confirmAccountDeletion(code: string): Promise; registerForNotification(platform: string, deviceToken: string): Promise; unregisterForNotification(deviceToken: string): Promise; getIssuedGroupSharingRequests(count?: number): Promise>; getReceivedGroupSharingRequests(count?: number): Promise>; setTimeZone(timeZone: string): Promise; createGroup(groupRequest: ESPCDFCreateGroupRequest): Promise; /** Creates a Matter fabric (`ESPRMUser.createFabric`). */ createFabric?(groupRequest: ESPCDFCreateGroupRequest): Promise; getGroups(): Promise>; createProvisioningDevice(name: string, transport: string, security?: number, proofOfPossession?: string, softAPPassword?: string, username?: string): Promise; searchESPDevices(prefix: string, transport: string): Promise; searchESPBLEDevices(customerId: number): Promise; getGroupById(groupId: string, options: Record): Promise; subscribeToEvent(event: string, callback: (data: any) => void): Promise; unsubscribeFromEvent(event: string, callback: (data: any) => void): Promise; setMultipleNodesParams(payload: { nodeId: string; payload: any; }[]): Promise; getNodeDetails(nodeId: string): Promise; getAccessToken(): Promise; syncHomeWithNodes?(user: ESPCDFUserInterface, callbacks: GroupStoreCallbacks): Promise; setCurrentHome?(user: ESPCDFUserInterface, callbacks: GroupStoreCallbacks, home: ESPCDFGroup): Promise; createHome?(params: ESPCDFCreateHomeRequestParams, callbacks: GroupStoreCallbacks): Promise; addDevice?(user: ESPCDFUserInterface, params: AddDeviceParams, callbacks: GroupStoreCallbacks): Promise; /** * Add a device that is already on the user's local network using the * challenge-response flow over LAN HTTP. No Wi-Fi credentials are required. * Optional: adaptors that do not implement on-network provisioning may omit it. */ addOnNetworkDevice?(user: ESPCDFUserInterface, params: AddOnNetworkDeviceParams, callbacks: GroupStoreCallbacks): Promise; /** * Subscribe to node updates via the SDK subscription manager (e.g. notification channel). * Updates are forwarded to the CDF subscription store. */ subscribeToNodeUpdates?(params: ESPCDFSubscribeToNodeUpdatesRequestParams): Promise; /** * Unsubscribe from node updates and release subscription manager resources. */ unsubscribeFromNodeUpdates?(): Promise; /** * Obtain short-lived AWS credentials scoped to the requested role/resources. * Optional: adaptors that do not support this operation may omit it. */ assumeRole?(request: ESPCDFAssumeRoleRequest): Promise; getGroupsAndFabrics?(): Promise; isUserNocAvailableForFabric?(fabricId: string): Promise; storePrecommissionInfo?(info: ESPCDFMatterPrecommissionInfo): Promise; createCmdRespRequest?(params: T): Promise; getCmdRespRequestById?(requestId: string, nodeId?: string): Promise; getCmdRespRequestList?(params?: T): Promise; cancelCmdRespRequest?(params: T): Promise; createFileUploadRequest?(params: T): Promise; uploadFile?(content: Blob | ArrayBuffer | Uint8Array, params: T, onProgress?: (progress: unknown) => void): Promise; getFiles?(params?: T): Promise; getFileById?(fileId: string, params?: T): Promise; downloadFile?(fileId: string, params?: T): Promise; } export interface ESPCDFSubscribeToNodeUpdatesRequestParams { nodeList: ESPCDFNode[]; onNodeUpdate?: (update: Record) => void; extraPayload?: Record; } /** * Parameters for creating a home via user.createHome */ export interface ESPCDFCreateHomeRequestParams { /** Display name for the home; if omitted, a unique default name is used */ name: string; /** Node IDs to include in the home */ nodeIds?: string[]; /** Extra payload to include in the home creation request */ extraPayload?: Record; } /** * Parameters for adding a device via user.addDevice */ export interface AddDeviceParams { provisioningDevice: ESPCDFProvisioningDevice; groupId: string; deviceName?: string; ssid: string; password: string; onProgress?: (response: ESPCDFProvisionResponse) => void; } /** * SDK-agnostic request payload for the assume-role operation. */ export interface ESPCDFAssumeRoleRequest { /** The role to assume */ userRole?: string; /** The group IDs to assume the role for */ groupIds?: string[]; /** The node IDs to assume the role for */ nodeIds?: string[]; /** Extra payload to include in the assume-role request */ extraPayload?: Record; } /** * SDK-agnostic response returned by the assume-role operation. * Contains short-lived AWS credentials for accessing cloud resources. */ export interface ESPCDFAssumeRoleResponse { accessKey: string; secretKey: string; sessionToken: string; } export interface ESPCDFUserInterface { identifier: string; userInfo: ESPCDFUserInfo; customData?: Record; operations: ESPCDFUserOperation; _raw: any; setStoreCallbacks?(callbacks: GroupStoreCallbacks): void; } interface PermissionType { read?: string[]; write?: string[]; } /** * Represents the data entry for custom data. */ interface DataEntry { value?: T; perms?: PermissionType[] | null; } /** * Represents the request payload for user custom data. */ export type ESPCDFUserCustomDataRequest = Record; export interface ESPCDFCreateGroupRequest { name: string; nodeIds?: string[]; description?: string; customData?: Record; type?: string; mutuallyExclusive?: boolean; metadata?: Record; } export interface ESPCDFMatterPrecommissionInfo { groupId: string; fabricId: string; name: string; userNoc: string; matterUserId: string; rootCa: string; ipk?: string; groupCatIdOperate?: string; groupCatIdAdmin?: string; userCatId?: string; } export {};