2022-04-12 20:54:31 +00:00
|
|
|
const { get } = require('https');
|
|
|
|
const zlib = require('zlib');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
console.log('getting manifest...');
|
|
|
|
|
|
|
|
get('https://discord.com/api/updates/distributions/app/manifests/latest?channel=canary&platform=win&arch=x86', async (res) => {
|
|
|
|
let body = '';
|
|
|
|
res.on('data', (chunk) => {
|
|
|
|
body += chunk.toString();
|
|
|
|
});
|
|
|
|
|
|
|
|
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
|
|
|
|
|
|
|
|
const manifest = JSON.parse(body);
|
|
|
|
const downloadUrl = manifest.full.url;
|
|
|
|
|
|
|
|
console.log('downloading full.distro...');
|
|
|
|
|
|
|
|
get(downloadUrl, async (res) => {
|
|
|
|
let body = [];
|
|
|
|
res.on('data', (chunk) => {
|
|
|
|
body.push(chunk);
|
|
|
|
});
|
|
|
|
|
|
|
|
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
|
|
|
|
|
|
|
|
console.log('decompressing...');
|
|
|
|
|
2022-04-12 21:03:13 +00:00
|
|
|
body = Buffer.concat(body);
|
2022-04-12 20:54:31 +00:00
|
|
|
body = zlib.brotliDecompressSync(body);
|
|
|
|
|
|
|
|
fs.writeFileSync('client.tar', body);
|
|
|
|
});
|
|
|
|
});
|