@wu529778790/open-im 1.11.4-beta.16 → 1.11.4-beta.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,7 @@ import { createLogger } from '../logger.js';
12
12
  import { jitteredDelay, isFatalReconnectError, SLOW_PROBE_MS } from '../shared/reconnect.js';
13
13
  import { cacheContextToken } from './message-sender.js';
14
14
  import { setClawbotContextToken, clearClawbotContextToken } from '../shared/active-chats.js';
15
- import { decryptAes256CbcMedia, createMediaTargetPath } from '../shared/media-storage.js';
15
+ import { createMediaTargetPath } from '../shared/media-storage.js';
16
16
  import { createDecipheriv } from 'node:crypto';
17
17
  import { CLAWBOT_POLL_INTERVAL_MS } from '../constants.js';
18
18
  const log = createLogger('ClawBot');
@@ -262,7 +262,8 @@ async function extractImages(msg) {
262
262
  log.warn('Image item missing full_url/cdn_url');
263
263
  continue;
264
264
  }
265
- const aesKey = imageItem?.aeskey;
265
+ // AES key: aeskey 字段是 32 字符 hex(16 字节),需要直接用作 AES-128-CBC key
266
+ const aesKeyHex = imageItem?.aeskey;
266
267
  try {
267
268
  // Download from CDN
268
269
  const response = await fetch(imageUrl, { signal: AbortSignal.timeout(30_000) });
@@ -271,25 +272,18 @@ async function extractImages(msg) {
271
272
  continue;
272
273
  }
273
274
  const buffer = Buffer.from(await response.arrayBuffer());
274
- // 尝试解密,失败则直接使用原始数据
275
+ // 解密:aeskey 是 hex 编码的 16 字节密钥,用 AES-128-CBC 解密
275
276
  let decrypted;
276
- if (aesKey) {
277
+ if (aesKeyHex && aesKeyHex.length === 32) {
277
278
  try {
278
- decrypted = decryptAes256CbcMedia(buffer, aesKey);
279
+ const keyBuf = Buffer.from(aesKeyHex, 'hex');
280
+ const iv = keyBuf.subarray(0, 16);
281
+ const decipher = createDecipheriv('aes-128-cbc', keyBuf, iv);
282
+ decrypted = Buffer.concat([decipher.update(buffer), decipher.final()]);
279
283
  }
280
284
  catch {
281
- // AES-256 解密失败,尝试 AES-128 (16字节 hex key)
282
- try {
283
- const keyBuf = Buffer.from(aesKey, 'hex');
284
- const iv = keyBuf.subarray(0, 16);
285
- const decipher = createDecipheriv('aes-128-cbc', keyBuf, iv);
286
- decrypted = Buffer.concat([decipher.update(buffer), decipher.final()]);
287
- }
288
- catch {
289
- // 都失败了,直接用原始数据
290
- log.info('AES decryption failed, using raw image data');
291
- decrypted = buffer;
292
- }
285
+ log.info('AES-128 decryption failed, using raw image data');
286
+ decrypted = buffer;
293
287
  }
294
288
  }
295
289
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.4-beta.16",
3
+ "version": "1.11.4-beta.18",
4
4
  "description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",