feat: Mimic browser TLS fingerprint in node

- Fix Unknown Message (maybe)
This commit is contained in:
Elysia
2024-01-25 18:48:00 +07:00
parent 6d41b4e87c
commit 4692e5b7d1
4 changed files with 50 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ const makeFetchCookie = require('fetch-cookie');
const FormData = require('form-data');
const fetchOriginal = require('node-fetch');
const { CookieJar } = require('tough-cookie');
const { ciphers } = require('../util/Constants');
const cookieJar = new CookieJar();
const fetch = makeFetchCookie(fetchOriginal, cookieJar);
@@ -40,10 +41,19 @@ class APIRequest {
make(captchaKey, captchaRqToken) {
if (!agent) {
if (this.client.options.http.agent instanceof http.Agent) {
this.client.options.http.agent.keepAlive = true;
this.client.options.http.agent.options.keepAlive = true;
this.client.options.http.agent.options.honorCipherOrder = true;
this.client.options.http.agent.options.minVersion = 'TLSv1.2';
this.client.options.http.agent.options.ciphers = ciphers.join(':');
agent = this.client.options.http.agent;
} else {
agent = new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
agent = new https.Agent({
...this.client.options.http.agent,
keepAlive: true,
honorCipherOrder: true,
minVersion: 'TLSv1.2',
ciphers: ciphers.join(':'),
});
}
}
@@ -54,7 +64,6 @@ class APIRequest {
const url = API + this.path;
let headers = {
...this.client.options.http.headers,
authority: 'discord.com',
accept: '*/*',
'accept-language': 'en-US',
@@ -73,6 +82,7 @@ class APIRequest {
Referer: 'https://discord.com/channels/@me',
origin: 'https://discord.com',
'Referrer-Policy': 'strict-origin-when-cross-origin',
...this.client.options.http.headers,
'User-Agent': this.fullUserAgent,
};