@wu529778790/open-im 1.11.4-beta.14 → 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,6 @@ async function extractImages(msg) {
261
262
  log.warn('Image item missing full_url/cdn_url');
262
263
  continue;
263
264
  }
264
- // AES key: aeskey 字段是 hex 格式,media.aes_key 是 base64 格式
265
- // decryptAes256CbcMedia 需要 hex 格式的 key
266
265
  const aesKey = imageItem?.aeskey;
267
266
  try {
268
267
  // Download from CDN
@@ -272,10 +271,26 @@ async function extractImages(msg) {
272
271
  continue;
273
272
  }
274
273
  const buffer = Buffer.from(await response.arrayBuffer());
275
- // Decrypt if AES key provided
274
+ // 尝试解密,失败则直接使用原始数据
276
275
  let decrypted;
277
276
  if (aesKey) {
278
- 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
+ }
279
294
  }
280
295
  else {
281
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.14",
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",