mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 22:51:23 +08:00
compatibility fix of rumtime and legacy node
This commit is contained in:
+3
-2
@@ -151,7 +151,8 @@ const decrypt = (cipher) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const aesEcbEncrypt = (key, plaintext) => {
|
const aesEcbEncrypt = (key, plaintext) => {
|
||||||
const cipher = crypto.createCipheriv(`aes-${key.length * 8}-ecb`, key, null)
|
// 某些运行时不允许使用 null 作为 IV,因此使用 Buffer.alloc(0) ,同时与上下文deriveX25519AesKey等函数保持一致
|
||||||
|
const cipher = crypto.createCipheriv(`aes-${key.length * 8}-ecb`, key, Buffer.alloc(0))
|
||||||
return Buffer.concat([cipher.update(Buffer.from(plaintext)), cipher.final()])
|
return Buffer.concat([cipher.update(Buffer.from(plaintext)), cipher.final()])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +160,7 @@ const aesEcbDecrypt = (key, ciphertext) => {
|
|||||||
const decipher = crypto.createDecipheriv(
|
const decipher = crypto.createDecipheriv(
|
||||||
`aes-${key.length * 8}-ecb`,
|
`aes-${key.length * 8}-ecb`,
|
||||||
key,
|
key,
|
||||||
null,
|
Buffer.alloc(0),
|
||||||
)
|
)
|
||||||
return Buffer.concat([decipher.update(ciphertext), decipher.final()])
|
return Buffer.concat([decipher.update(ciphertext), decipher.final()])
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -440,7 +440,11 @@ const createRequest = async (uri, data, options) => {
|
|||||||
!cookie.NMTID
|
!cookie.NMTID
|
||||||
) {
|
) {
|
||||||
NMTID_RETRIES_LEFT--
|
NMTID_RETRIES_LEFT--
|
||||||
answer.cookie = setCookies.map((x) => {
|
answer.cookie = (
|
||||||
|
typeof res.headers['set-cookie'] === 'string' // node 20 版本以前,可能解析为String
|
||||||
|
? [res.headers['set-cookie']]
|
||||||
|
: res.headers['set-cookie'] || []
|
||||||
|
).map((x) => {
|
||||||
const cleaned = cleanCookie(x)
|
const cleaned = cleanCookie(x)
|
||||||
const match = x.match(/(?:^|;\s*)NMTID=([^;]+)/)
|
const match = x.match(/(?:^|;\s*)NMTID=([^;]+)/)
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|||||||
Reference in New Issue
Block a user