refactor(WS): Ws data + Rest Headers
This commit is contained in:
parent
54e1dbb6b0
commit
324e05915d
@ -688,9 +688,7 @@ class WebSocketShard extends EventEmitter {
|
||||
|
||||
// Clone the identify payload and assign the token and shard info
|
||||
client.options.ws.properties = Object.assign(client.options.ws.properties, {
|
||||
$browser_user_agent:
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
||||
$browser_version: '103.0.0.0',
|
||||
browser_user_agent: client.options.http.headers['User-Agent'],
|
||||
});
|
||||
const d = {
|
||||
...client.options.ws,
|
||||
|
@ -1,10 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const Buffer = require('node:buffer').Buffer;
|
||||
const https = require('node:https');
|
||||
const { setTimeout } = require('node:timers');
|
||||
const FormData = require('form-data');
|
||||
const JSONBig = require('json-bigint');
|
||||
const fetch = require('node-fetch');
|
||||
const { randomUA } = require('../util/Constants');
|
||||
|
||||
let agent = null;
|
||||
|
||||
@ -17,8 +18,10 @@ class APIRequest {
|
||||
this.options = options;
|
||||
this.retries = 0;
|
||||
|
||||
/* Remove
|
||||
const { userAgentSuffix } = this.client.options;
|
||||
this.fullUserAgent = `${randomUA()}${userAgentSuffix.length ? `, ${userAgentSuffix.join(', ')}` : ''}`;
|
||||
*/
|
||||
|
||||
let queryString = '';
|
||||
if (options.query) {
|
||||
@ -41,11 +44,29 @@ class APIRequest {
|
||||
|
||||
let headers = {
|
||||
...this.client.options.http.headers,
|
||||
'User-Agent': this.fullUserAgent,
|
||||
Accept: '*/*',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
'Sec-Ch-Ua': `"Not A;Brand";v="99", "Chromium";v="${
|
||||
this.client.options.ws.properties.browser_version.split('.')[0]
|
||||
}", "Google Chrome";v="${this.client.options.ws.properties.browser_version.split('.')[0]}`,
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'X-Debug-Options': 'bugReporterEnabled',
|
||||
'X-Super-Properties': `${Buffer.from(JSONBig.stringify(this.client.options.ws.properties), 'ascii').toString(
|
||||
'base64',
|
||||
)}`,
|
||||
'X-Discord-Locale': 'en-US',
|
||||
'User-Agent': this.client.options.http.headers['User-Agent'],
|
||||
};
|
||||
|
||||
// Edit UA
|
||||
/* Remove
|
||||
this.client.options.http.headers['User-Agent'] = this.fullUserAgent;
|
||||
*/
|
||||
|
||||
if (this.options.auth !== false) headers.Authorization = this.rest.getAuth();
|
||||
if (this.options.reason) headers['X-Audit-Log-Reason'] = encodeURIComponent(this.options.reason);
|
||||
|
@ -1,8 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
// Not used: const process = require('node:process');
|
||||
const Buffer = require('node:buffer').Buffer;
|
||||
const JSONBig = require('json-bigint');
|
||||
const { randomUA } = require('../util/Constants');
|
||||
/**
|
||||
* Rate limit data
|
||||
* @typedef {Object} RateLimitData
|
||||
@ -171,23 +170,21 @@ class Options extends null {
|
||||
large_threshold: 50,
|
||||
compress: false,
|
||||
properties: {
|
||||
// $os: 'iPhone14,5',
|
||||
// $browser: 'Discord iOS',
|
||||
// $device: 'iPhone14,5 OS 15.2',
|
||||
os: 'Windows',
|
||||
browser: 'Discord Client',
|
||||
device: 'ASUS ROG Phone 5', // :)
|
||||
// Add
|
||||
browser: 'Chrome',
|
||||
device: '',
|
||||
system_locale: 'en-US',
|
||||
browser_version: '103.0.0.0',
|
||||
os_version: '10',
|
||||
referrer: '',
|
||||
referring_domain: '',
|
||||
referrer_current: '',
|
||||
referring_domain_current: '',
|
||||
release_channel: 'stable',
|
||||
client_build_number: 127546,
|
||||
client_build_number: 139460,
|
||||
client_event_source: null,
|
||||
},
|
||||
// ? capabilities: 253,
|
||||
// ? capabilities: 509,
|
||||
version: 9,
|
||||
client_state: {
|
||||
guild_hashes: {},
|
||||
@ -198,40 +195,10 @@ class Options extends null {
|
||||
},
|
||||
},
|
||||
http: {
|
||||
headers: {
|
||||
Accept: '*/*',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Cache-Control': 'no-cache',
|
||||
Pragma: 'no-cache',
|
||||
// Referer: 'https://discord.com/channels/@me',
|
||||
'Sec-Ch-Ua': '"Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100',
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Ch-Ua-Platform': '"Windows"',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'X-Debug-Options': 'bugReporterEnabled',
|
||||
// https://github.com/Merubokkusu/Discord-S.C.U.M/issues/66#issuecomment-1009171667
|
||||
'X-Super-Properties': `${Buffer.from(
|
||||
JSONBig.stringify({
|
||||
os: 'Windows',
|
||||
browser: 'Discord Client',
|
||||
release_channel: 'stable',
|
||||
client_version: '1.0.9004',
|
||||
os_version: '10.0.22000',
|
||||
os_arch: 'x64',
|
||||
system_locale: 'en-US',
|
||||
client_build_number: 127546,
|
||||
client_event_source: null,
|
||||
}),
|
||||
'ascii',
|
||||
).toString('base64')}`,
|
||||
'X-Discord-Locale': 'en-US',
|
||||
// Origin: 'https://discord.com', Webhook Error
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9004 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36',
|
||||
},
|
||||
agent: {},
|
||||
headers: {
|
||||
'User-Agent': randomUA(),
|
||||
},
|
||||
version: 9,
|
||||
api: 'https://discord.com/api',
|
||||
cdn: 'https://cdn.discordapp.com',
|
||||
|
Loading…
Reference in New Issue
Block a user