redai-automation-web-sdk
Version:
TypeScript SDK for RedAI Automation Web API - Zalo Personal automation, messaging, advanced sticker search, and bulk operations. 100% compatible with automation-web backend. v1.8.0: Added SessionProxyService for managing proxy assignments to sessions with
523 lines • 10.6 kB
TypeScript
/**
* Authentication related types and interfaces
*/
/**
* Session status enum - Chuẩn theo automation-web controller
*/
export declare enum SessionStatus {
PENDING = "pending",
SCANNING = "scanning",
SUCCESS = "success",
FAILED = "failed",
EXPIRED = "expired",
QR_EXPIRED = "qr_expired"
}
/**
* Zalo credentials for login - Chuẩn theo automation-web shared types
*/
export interface ZaloCredentials {
/**
* Cookie array from browser - as received from SDK login
*/
cookie: Array<Record<string, unknown>>;
/**
* Device IMEI
*/
imei: string;
/**
* Browser user agent
*/
userAgent: string;
/**
* Language preference
* @default 'vi'
*/
language?: string;
}
/**
* Zalo user data - Chuẩn theo automation-web shared types
*/
export interface ZaloUserData {
/**
* Zalo platform user ID (stringified number)
*/
userId: string;
/**
* Display name
*/
displayName: string;
/**
* Avatar URL
*/
avatar: string;
/**
* Optional details, may be absent depending on SDK method
*/
username?: string;
/**
* Phone number (if available)
*/
phoneNumber?: string;
/**
* Gender (0/1)
*/
gender?: number;
/**
* Status
*/
status?: string;
/**
* Cover image URL
*/
cover?: string;
/**
* Global ID
*/
globalId?: string;
/**
* Is active (0/1)
*/
isActive?: number;
/**
* Last action time (epoch millis)
*/
lastActionTime?: number;
/**
* Created timestamp (epoch seconds)
*/
createdTs?: number;
/**
* Email (rarely present)
*/
email?: string;
/**
* Additional properties
*/
[key: string]: unknown;
}
/**
* QR Login Options - Tùy chọn cho QR login
*/
export interface QRLoginOptions {
/**
* Thời gian timeout cho QR code (giây)
* @default 120
* @min 30
* @max 300
*/
timeout?: number;
/**
* Tự động đăng nhập sau khi quét QR
* @default true
*/
autoLogin?: boolean;
/**
* ID của proxy muốn sử dụng (nếu muốn chỉ định cụ thể)
*/
proxyId?: string;
/**
* Region của proxy muốn sử dụng (nếu không chỉ định proxyId)
*/
proxyRegion?: string;
}
/**
* QR Code login request - Chuẩn theo automation-web QRLoginRequestDto
*/
export interface QRLoginRequest {
/**
* UUID của user từ redai-v201-be-app
*/
userUuid: string;
/**
* Session ID tùy chọn, sẽ auto-generate nếu không cung cấp
*/
sessionId?: string;
/**
* Tùy chọn cho QR login
*/
options?: QRLoginOptions;
}
/**
* QR Login Data - Dữ liệu QR Code
*/
export interface QRLoginData {
/**
* Session ID để tracking
*/
sessionId: string;
/**
* QR Code dưới dạng base64
*/
qrCode: string;
/**
* Thời gian hết hạn QR code (timestamp)
*/
expiresAt: number;
/**
* URL để polling status
*/
pollUrl: string;
}
/**
* QR Code login response - Chuẩn theo automation-web QRLoginResponseDto
*/
export interface QRLoginResponse {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
/**
* Dữ liệu response
*/
data?: QRLoginData;
}
/**
* Session Info - Thông tin session
*/
export interface SessionInfo {
/**
* Session ID
*/
sessionId: string;
/**
* Thời gian tạo session (timestamp)
*/
createdAt: number;
/**
* Thời gian hết hạn session (timestamp)
*/
expiresAt: number;
/**
* Thời gian hết hạn QR code (timestamp)
*/
qrExpiresAt?: number;
/**
* Lần hoạt động cuối (timestamp)
*/
lastActivity: number;
}
/**
* Login Status Data - Dữ liệu trạng thái đăng nhập
*/
export interface LoginStatusData {
/**
* Trạng thái session
*/
status: SessionStatus;
/**
* Thông tin user Zalo (khi đăng nhập thành công)
*/
userData?: ZaloUserData;
/**
* Credentials để reuse (khi đăng nhập thành công)
*/
credentials?: ZaloCredentials;
/**
* Thông tin session
*/
sessionInfo: SessionInfo;
}
/**
* Login status response - Chuẩn theo automation-web LoginStatusResponseDto
*/
export interface LoginStatusResponse {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
/**
* Dữ liệu status
*/
data?: LoginStatusData;
}
/**
* Credentials Login Options - Chuẩn theo automation-web CredentialsLoginOptionsDto
*/
export interface CredentialsLoginOptions {
/**
* Chỉ validate credentials, không tạo session
* @default false
*/
validateOnly?: boolean;
}
/**
* Credentials login request - Chuẩn theo automation-web CredentialsLoginRequestDto
*/
export interface CredentialsLoginRequest {
/**
* UUID của user từ redai-v201-be-app
*/
userUuid: string;
/**
* Zalo credentials để đăng nhập
*/
credentials: ZaloCredentials;
/**
* Tùy chọn cho credentials login
*/
options?: CredentialsLoginOptions;
}
/**
* Credentials Login Data - Dữ liệu credentials login
*/
export interface CredentialsLoginData {
/**
* Session ID được tạo
*/
sessionId: string;
/**
* Thông tin user Zalo
*/
userData: ZaloUserData;
/**
* Credentials có hợp lệ không
*/
isValid: boolean;
}
/**
* Credentials login response - Chuẩn theo automation-web CredentialsLoginResponseDto
*/
export interface CredentialsLoginResponse {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
/**
* Dữ liệu response
*/
data?: CredentialsLoginData;
}
/**
* Session Item - Chuẩn theo automation-web SessionItemDto
*/
export interface SessionItem {
/**
* Session ID
*/
sessionId: string;
/**
* Trạng thái session
*/
status: SessionStatus;
/**
* Thông tin user (nếu đã đăng nhập thành công)
*/
userData?: ZaloUserData;
/**
* Thời gian tạo (timestamp)
*/
createdAt: number;
/**
* Lần hoạt động cuối (timestamp)
*/
lastActivity: number;
/**
* Thời gian hết hạn (timestamp)
*/
expiresAt: number;
/**
* Session có hết hạn chưa
*/
isExpired: boolean;
}
/**
* Session List Data - Dữ liệu danh sách sessions
*/
export interface SessionListData {
/**
* Danh sách sessions
*/
sessions: SessionItem[];
/**
* Tổng số sessions
*/
total: number;
/**
* Số sessions đang active
*/
activeCount: number;
}
/**
* Session list response - Chuẩn theo automation-web SessionListResponseDto
*/
export interface SessionListResponse {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
/**
* Dữ liệu sessions
*/
data?: SessionListData;
}
/**
* Session delete response - Chuẩn theo automation-web SessionDeleteResponseDto
*/
export interface SessionDeleteResponse {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
}
/**
* Bulk delete sessions request - Chuẩn theo automation-web BulkDeleteSessionsDto
*/
export interface BulkDeleteSessionsRequest {
/**
* Danh sách session IDs cần xóa
*/
sessionIds: string[];
}
/**
* Bulk delete sessions response - Chuẩn theo automation-web BulkDeleteSessionsResponseDto
*/
export interface BulkDeleteSessionsResponse {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
/**
* Số lượng sessions đã xóa thành công
*/
deletedCount: number;
/**
* Danh sách session IDs đã xóa thành công
*/
deletedIds: string[];
/**
* Số lượng sessions xóa thất bại
*/
failedCount?: number;
/**
* Danh sách session IDs xóa thất bại
*/
failedIds?: string[];
/**
* Danh sách lỗi chi tiết
*/
errors?: string[];
}
/**
* Session Debug Data - Dữ liệu debug session
*/
export interface SessionDebugData {
/**
* Session ID
*/
sessionId: string;
/**
* User UUID
*/
userUuid: string;
/**
* Trạng thái session
*/
status: SessionStatus;
/**
* QR Code (truncated)
*/
qrCode: string | null;
/**
* Thời gian hết hạn QR code
*/
qrExpiresAt?: number;
/**
* Có credentials không
*/
hasCredentials: boolean;
/**
* Thông tin credentials
*/
credentialsInfo?: {
cookieCount: number;
hasImei: boolean;
hasUserAgent: boolean;
language?: string;
};
/**
* Có user data không
*/
hasUserData: boolean;
/**
* Thông tin user data
*/
userDataInfo?: {
userId?: string;
displayName?: string;
hasAvatar: boolean;
};
/**
* Thông tin timestamps
*/
timestamps: {
createdAt: number;
expiresAt: number;
lastActivity: number;
};
/**
* Trạng thái hết hạn
*/
isExpired: boolean;
/**
* Trạng thái QR hết hạn
*/
isQRExpired: boolean;
/**
* Thông tin instance
*/
instanceInfo?: {
hasInstance: boolean;
isConnected?: boolean;
lastPing?: number;
};
}
/**
* Session debug information - Chuẩn theo automation-web debugSession response
*/
export interface SessionDebugInfo {
/**
* Trạng thái thành công
*/
success: boolean;
/**
* Thông báo
*/
message: string;
/**
* Dữ liệu debug (nếu thành công)
*/
data?: SessionDebugData;
/**
* Thông tin lỗi (nếu thất bại)
*/
error?: string;
/**
* Timestamp
*/
timestamp?: number;
}
//# sourceMappingURL=auth.types.d.ts.map