@wu529778790/open-im 1.11.4-beta.13 → 1.11.4-beta.15

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.
@@ -13,6 +13,7 @@ import { jitteredDelay, isFatalReconnectError, SLOW_PROBE_MS } from '../shared/r
13
13
  import { cacheContextToken } from './message-sender.js';
14
14
  import { setClawbotContextToken, clearClawbotContextToken } from '../shared/active-chats.js';
15
15
  import { decryptAes256CbcMedia, saveBufferMedia, createMediaTargetPath } from '../shared/media-storage.js';
16
+ import { createDecipheriv } from 'node:crypto';
16
17
  import { CLAWBOT_POLL_INTERVAL_MS } from '../constants.js';
17
18
  const log = createLogger('ClawBot');
18
19
  const RECONNECT_DELAYS_MS = [3000, 5000, 10000, 20000, 30000];
@@ -261,8 +262,7 @@ async function extractImages(msg) {
261
262
  log.warn('Image item missing full_url/cdn_url');
262
263
  continue;
263
264
  }
264
- // AES key: 优先 media.aes_key (base64),其次 aeskey (hex)
265
- const aesKey = media?.aes_key || imageItem?.aeskey;
265
+ const aesKey = imageItem?.aeskey;
266
266
  try {
267
267
  // Download from CDN
268
268
  const response = await fetch(imageUrl, { signal: AbortSignal.timeout(30_000) });
@@ -271,10 +271,26 @@ async function extractImages(msg) {
271
271
  continue;
272
272
  }
273
273
  const buffer = Buffer.from(await response.arrayBuffer());
274
- // Decrypt if AES key provided
274
+ // 尝试解密,失败则直接使用原始数据
275
275
  let decrypted;
276
276
  if (aesKey) {
277
- decrypted = decryptAes256CbcMedia(buffer, aesKey);
277
+ try {
278
+ decrypted = decryptAes256CbcMedia(buffer, aesKey);
279
+ }
280
+ 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
+ }
293
+ }
278
294
  }
279
295
  else {
280
296
  decrypted = buffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.4-beta.13",
3
+ "version": "1.11.4-beta.15",
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",