fix(router/twitter): replace zstd decoder with native zlib decompression (#20485)
* fix(twitter): replace zstd decoder with native zlib decompression * fix(twitter): update node version compatibility and enable experimental features
This commit is contained in:
parent
d9d807ab12
commit
daf9460e6a
|
|
@ -300,7 +300,8 @@ export default [
|
|||
'n/no-unsupported-features/node-builtins': [
|
||||
'error',
|
||||
{
|
||||
version: '>=22.16.0',
|
||||
version: '^22.16.0 || ^24.0.0',
|
||||
allowExperimental: true,
|
||||
ignores: [],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ import cache from '@/utils/cache';
|
|||
import { twitterGot, paginationTweets, gatherLegacyFromData } from './utils';
|
||||
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { Decoder } from '@toondepauw/node-zstd';
|
||||
const decoder = new Decoder();
|
||||
import { zstdDecompressSync } from 'node:zlib';
|
||||
|
||||
const fetchThirdPartyApi = async (endpoint: string, params: Record<string, any>) => {
|
||||
const response = await ofetch.raw(`${config.twitter.thirdPartyApi}${endpoint}`, {
|
||||
|
|
@ -18,7 +17,7 @@ const fetchThirdPartyApi = async (endpoint: string, params: Record<string, any>)
|
|||
let body = Buffer.from(response._data as ArrayBuffer);
|
||||
|
||||
if (encoding.includes('zstd')) {
|
||||
body = await decoder.decode(body);
|
||||
body = zstdDecompressSync(body);
|
||||
}
|
||||
|
||||
return JSON.parse(body.toString('utf-8'));
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ import logger from '@/utils/logger';
|
|||
import ofetch from '@/utils/ofetch';
|
||||
import proxy from '@/utils/proxy';
|
||||
import login from './login';
|
||||
import { Decoder } from '@toondepauw/node-zstd';
|
||||
const decoder = new Decoder();
|
||||
import { zstdDecompressSync } from 'node:zlib';
|
||||
|
||||
let authTokenIndex = 0;
|
||||
|
||||
|
|
@ -26,7 +25,7 @@ const fetchThirdPartyTimeline = async (endpoint: string, params: Record<string,
|
|||
let body = Buffer.from(response._data as ArrayBuffer);
|
||||
|
||||
if (encoding.includes('zstd')) {
|
||||
body = await decoder.decode(body);
|
||||
body = zstdDecompressSync(body);
|
||||
}
|
||||
|
||||
return JSON.parse(body.toString('utf-8'));
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@
|
|||
"@rss3/sdk": "0.0.25",
|
||||
"@scalar/hono-api-reference": "0.9.24",
|
||||
"@sentry/node": "10.25.0",
|
||||
"@toondepauw/node-zstd": "^1.2.0",
|
||||
"aes-js": "3.1.2",
|
||||
"art-template": "4.13.2",
|
||||
"cheerio": "1.1.2",
|
||||
|
|
|
|||
|
|
@ -69,9 +69,6 @@ importers:
|
|||
'@sentry/node':
|
||||
specifier: 10.25.0
|
||||
version: 10.25.0
|
||||
'@toondepauw/node-zstd':
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0
|
||||
aes-js:
|
||||
specifier: 3.1.2
|
||||
version: 3.1.2
|
||||
|
|
@ -2311,58 +2308,6 @@ packages:
|
|||
peerDependencies:
|
||||
eslint: '>=9.0.0'
|
||||
|
||||
'@toondepauw/node-zstd-darwin-arm64@1.2.0':
|
||||
resolution: {integrity: sha512-fdBGlRSrf19M1+IJ98aJCLK6/HKQRnRlhE5i6EZ7kVfD2r6h5Bq9NqHAmQ5MgwtmfB9VMmiIrQAMIxKVeT54pg==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@toondepauw/node-zstd-darwin-x64@1.2.0':
|
||||
resolution: {integrity: sha512-ZVu4zkQUgCQ8z1lLd7/LZzIYDKL48tPguIN8L4SRfLuWWlTq2/4OT6AmchztDbe5soLCDuw64t5X5otDvgsGJA==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@toondepauw/node-zstd-freebsd-x64@1.2.0':
|
||||
resolution: {integrity: sha512-kDK+l3uP7htiWvM/klY32siEGIBk3K5Da4/DcXV2q/Vp+Ph86FWpQRzC46wJIpJB60xEU67pxFGLBH/8/RB02g==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@toondepauw/node-zstd-linux-arm64-gnu@1.2.0':
|
||||
resolution: {integrity: sha512-KteUWam7McA0moNiRgu7KSgPu3FE+KXuh3ObqWoco5JK53Sp4Pgr/q1IYsdN6TYYbgJMkJpof62NIbyi6tnVfg==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@toondepauw/node-zstd-linux-arm64-musl@1.2.0':
|
||||
resolution: {integrity: sha512-KjbGOXvPmorhWGD4kEVjdBz/gJgUOw1Eu0xziBwsq03URrI0XSDAY6YiJZpZtGnSjm7XonEpnBZcVwXH1HZz3Q==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@toondepauw/node-zstd-linux-x64-gnu@1.2.0':
|
||||
resolution: {integrity: sha512-qNJDZGd/jplK/1J+8V87dYdrviAxNt1iwI/SQ0JR3HTz5Jdbu+BnVB9oMklCc/bGWa8zTkiZkl/EwA3gtbpo+Q==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@toondepauw/node-zstd-linux-x64-musl@1.2.0':
|
||||
resolution: {integrity: sha512-Cw1qnMXde8caitDMbk0vWrqnVHTSK+JB/Dp3XnZghQjBrD7JLj2qNzh0eTkxNFa+nijbo8HyyslWGswCugYZCw==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@toondepauw/node-zstd-win32-x64-msvc@1.2.0':
|
||||
resolution: {integrity: sha512-7cD2/R7DLZHMxHTsQNtOX3vJCT4qd74a3nWjYYthJ89gqXwwEoC8BwttQxvHd0qCZ3S/cZ/BYoTikXMwMNmCEg==}
|
||||
engines: {node: '>= 14'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@toondepauw/node-zstd@1.2.0':
|
||||
resolution: {integrity: sha512-vVDvPUstF9gKEX+Kqp654bL+4UNus6pkmY8mlcJQpIw/Sn6sO9fl1PEwxB0d0unH5PmVfBUicf1lOXu74OLrCg==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
'@tootallnate/quickjs-emscripten@0.23.0':
|
||||
resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==}
|
||||
|
||||
|
|
@ -8260,41 +8205,6 @@ snapshots:
|
|||
estraverse: 5.3.0
|
||||
picomatch: 4.0.3
|
||||
|
||||
'@toondepauw/node-zstd-darwin-arm64@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-darwin-x64@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-freebsd-x64@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-linux-arm64-gnu@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-linux-arm64-musl@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-linux-x64-gnu@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-linux-x64-musl@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd-win32-x64-msvc@1.2.0':
|
||||
optional: true
|
||||
|
||||
'@toondepauw/node-zstd@1.2.0':
|
||||
optionalDependencies:
|
||||
'@toondepauw/node-zstd-darwin-arm64': 1.2.0
|
||||
'@toondepauw/node-zstd-darwin-x64': 1.2.0
|
||||
'@toondepauw/node-zstd-freebsd-x64': 1.2.0
|
||||
'@toondepauw/node-zstd-linux-arm64-gnu': 1.2.0
|
||||
'@toondepauw/node-zstd-linux-arm64-musl': 1.2.0
|
||||
'@toondepauw/node-zstd-linux-x64-gnu': 1.2.0
|
||||
'@toondepauw/node-zstd-linux-x64-musl': 1.2.0
|
||||
'@toondepauw/node-zstd-win32-x64-msvc': 1.2.0
|
||||
|
||||
'@tootallnate/quickjs-emscripten@0.23.0': {}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
|
|
|
|||
Loading…
Reference in New Issue