/** * 加密抽象层类型定义 */ /** * 异步加密策略接口 * * 支持 AES-256-CBC + HMAC-SHA256 方案。 */ interface AsyncEncryptionStrategy { /** 加密数据 */ encrypt(data: unknown, timestamp: number): Promise; /** 解密数据 */ decrypt(ciphertext: string, timestamp: number): Promise; } /** * AES 对称密钥配置(AES-256-CBC + HMAC-SHA256 方案使用) * * 密钥格式为 Hex 字符串(64 字符 = 32 字节 = 256 位) */ interface AESKeys { /** 请求加密密钥(Hex 字符串) */ requestKeyHex: string; /** 响应解密密钥(Hex 字符串) */ responseKeyHex: string; } /** * 加密配置 */ interface EncryptionConfig { /** 加密算法 */ algorithm: 'aes-cbc-hmac'; /** 密钥 */ keys: AESKeys; /** 通用选项 */ options?: { /** 防重放窗口 (秒), 默认 60 */ replayWindow?: number; /** 允许的前向时间偏差 (秒), 默认 5 */ forwardSkew?: number; }; } /** * 加密请求结果 */ interface EncryptedRequest { /** 加密后的数据 */ encrypted: string; /** 时间戳 */ timestamp: number; /** HMAC 签名 */ signature?: string; } export type { AESKeys as A, EncryptedRequest as E, AsyncEncryptionStrategy as a, EncryptionConfig as b };