mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-03-21 17:34:19 -05:00
fix: fixed fetch not allowing host header to be modified
This commit is contained in:
parent
b05167d262
commit
45dde0be43
15
package-lock.json
generated
15
package-lock.json
generated
|
|
@ -24,6 +24,7 @@
|
|||
"pino": "^9.9.1",
|
||||
"pino-http": "^10.5.0",
|
||||
"pino-pretty": "^13.1.1",
|
||||
"undici": "^7.16.0",
|
||||
"xml-js": "^1.6.11",
|
||||
"xmlbuilder": "^15.1.1"
|
||||
},
|
||||
|
|
@ -9488,6 +9489,15 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-7.16.0.tgz",
|
||||
"integrity": "sha512-QEg3HPMll0o3t2ourKwOeUAZ159Kn9mx5pnzHRQO8+Wixmh88YdZRiIwat0iNzNNXn0yoEtXJqFpyW7eM8BV7g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20.18.1"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.20.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||
|
|
@ -16276,6 +16286,11 @@
|
|||
"which-boxed-primitive": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"undici": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-7.16.0.tgz",
|
||||
"integrity": "sha512-QEg3HPMll0o3t2ourKwOeUAZ159Kn9mx5pnzHRQO8+Wixmh88YdZRiIwat0iNzNNXn0yoEtXJqFpyW7eM8BV7g=="
|
||||
},
|
||||
"undici-types": {
|
||||
"version": "6.20.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
"pino": "^9.9.1",
|
||||
"pino-http": "^10.5.0",
|
||||
"pino-pretty": "^13.1.1",
|
||||
"undici": "^7.16.0",
|
||||
"xml-js": "^1.6.11",
|
||||
"xmlbuilder": "^15.1.1"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import fs from 'node:fs/promises';
|
||||
import { pipeline } from 'node:stream/promises';
|
||||
import { Readable } from 'node:stream';
|
||||
import { request } from 'undici';
|
||||
import { Command } from 'commander';
|
||||
import { decryptWiiU } from '@pretendonetwork/boss-crypto';
|
||||
import { getCliContext } from './utils';
|
||||
|
|
@ -76,18 +77,22 @@ const downloadCmd = new Command('download')
|
|||
}
|
||||
|
||||
const npdi = ctx.getNpdiUrl();
|
||||
const fetchResult = await fetch(`${npdi.url}/p01/data/1/${file.bossAppId}/${file.dataId}/${file.hash}`, {
|
||||
const { body, statusCode } = await request(`${npdi.url}/p01/data/1/${file.bossAppId}/${file.dataId}/${file.hash}`, {
|
||||
headers: {
|
||||
Host: npdi.host
|
||||
}
|
||||
});
|
||||
if (fetchResult.status > 299) {
|
||||
console.error(`Failed to download: invalid status code (${fetchResult.status})`);
|
||||
if (statusCode > 299) {
|
||||
console.error(`Failed to download: invalid status code (${statusCode})`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const arrayBuffer = await fetchResult.arrayBuffer();
|
||||
let buffer = Buffer.from(arrayBuffer);
|
||||
const chunks: Buffer[] = [];
|
||||
for await (const chunk of body) {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
}
|
||||
|
||||
let buffer: Buffer = Buffer.concat(chunks);
|
||||
|
||||
if (ops.decrypt) {
|
||||
const keys = ctx.getWiiUKeys();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user