feat: Mimic browser TLS fingerprint in node
- Fix Unknown Message (maybe)
This commit is contained in:
parent
6d41b4e87c
commit
4692e5b7d1
@ -8,6 +8,7 @@ const makeFetchCookie = require('fetch-cookie');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fetchOriginal = require('node-fetch');
|
const fetchOriginal = require('node-fetch');
|
||||||
const { CookieJar } = require('tough-cookie');
|
const { CookieJar } = require('tough-cookie');
|
||||||
|
const { ciphers } = require('../util/Constants');
|
||||||
|
|
||||||
const cookieJar = new CookieJar();
|
const cookieJar = new CookieJar();
|
||||||
const fetch = makeFetchCookie(fetchOriginal, cookieJar);
|
const fetch = makeFetchCookie(fetchOriginal, cookieJar);
|
||||||
@ -40,10 +41,19 @@ class APIRequest {
|
|||||||
make(captchaKey, captchaRqToken) {
|
make(captchaKey, captchaRqToken) {
|
||||||
if (!agent) {
|
if (!agent) {
|
||||||
if (this.client.options.http.agent instanceof http.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;
|
agent = this.client.options.http.agent;
|
||||||
} else {
|
} 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;
|
const url = API + this.path;
|
||||||
|
|
||||||
let headers = {
|
let headers = {
|
||||||
...this.client.options.http.headers,
|
|
||||||
authority: 'discord.com',
|
authority: 'discord.com',
|
||||||
accept: '*/*',
|
accept: '*/*',
|
||||||
'accept-language': 'en-US',
|
'accept-language': 'en-US',
|
||||||
@ -73,6 +82,7 @@ class APIRequest {
|
|||||||
Referer: 'https://discord.com/channels/@me',
|
Referer: 'https://discord.com/channels/@me',
|
||||||
origin: 'https://discord.com',
|
origin: 'https://discord.com',
|
||||||
'Referrer-Policy': 'strict-origin-when-cross-origin',
|
'Referrer-Policy': 'strict-origin-when-cross-origin',
|
||||||
|
...this.client.options.http.headers,
|
||||||
'User-Agent': this.fullUserAgent,
|
'User-Agent': this.fullUserAgent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,31 @@ const { Error, RangeError, TypeError } = require('../errors');
|
|||||||
exports.MaxBulkDeletableMessageAge = 1_209_600_000;
|
exports.MaxBulkDeletableMessageAge = 1_209_600_000;
|
||||||
|
|
||||||
exports.UserAgent =
|
exports.UserAgent =
|
||||||
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.9031 Chrome/108.0.5359.215 Electron/22.3.26 Safari/537.36';
|
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5359.215 Electron/22.3.26 Safari/537.36';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Google Chrome v108 TLS ciphers
|
||||||
|
* @see {@link https://tls.browserleaks.com/tls}
|
||||||
|
* @see {@link https://github.com/yifeikong/curl-impersonate}
|
||||||
|
* @typedef {Array<string>} Ciphers
|
||||||
|
*/
|
||||||
|
exports.ciphers = [
|
||||||
|
'TLS_AES_128_GCM_SHA256',
|
||||||
|
'TLS_AES_256_GCM_SHA384',
|
||||||
|
'TLS_CHACHA20_POLY1305_SHA256',
|
||||||
|
'ECDHE-ECDSA-AES128-GCM-SHA256',
|
||||||
|
'ECDHE-RSA-AES128-GCM-SHA256',
|
||||||
|
'ECDHE-ECDSA-AES256-GCM-SHA384',
|
||||||
|
'ECDHE-RSA-AES256-GCM-SHA384',
|
||||||
|
'ECDHE-ECDSA-CHACHA20-POLY1305',
|
||||||
|
'ECDHE-RSA-CHACHA20-POLY1305',
|
||||||
|
'ECDHE-RSA-AES128-SHA',
|
||||||
|
'ECDHE-RSA-AES256-SHA',
|
||||||
|
'AES128-GCM-SHA256',
|
||||||
|
'AES256-GCM-SHA384',
|
||||||
|
'AES128-SHA',
|
||||||
|
'AES256-SHA',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The types of WebSocket error codes:
|
* The types of WebSocket error codes:
|
||||||
|
@ -177,17 +177,18 @@ class Options extends null {
|
|||||||
capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities
|
capabilities: 0, // https://discord-userdoccers.vercel.app/topics/gateway#gateway-capabilities
|
||||||
properties: {
|
properties: {
|
||||||
os: 'Windows',
|
os: 'Windows',
|
||||||
browser: 'Discord Client',
|
browser: 'Chrome',
|
||||||
release_channel: 'stable',
|
device: '',
|
||||||
client_version: '1.0.9031',
|
system_locale: 'vi-VN',
|
||||||
os_version: '10.0.19045',
|
|
||||||
os_arch: 'x64',
|
|
||||||
app_arch: 'ia32',
|
|
||||||
system_locale: 'en-US',
|
|
||||||
browser_user_agent: UserAgent,
|
browser_user_agent: UserAgent,
|
||||||
browser_version: '22.3.26',
|
browser_version: '108.0.5359.215',
|
||||||
client_build_number: 260725,
|
os_version: '10',
|
||||||
native_build_number: 42899,
|
referrer: '',
|
||||||
|
referring_domain: '',
|
||||||
|
referrer_current: '',
|
||||||
|
referring_domain_current: '',
|
||||||
|
release_channel: 'stable',
|
||||||
|
client_build_number: 261141,
|
||||||
client_event_source: null,
|
client_event_source: null,
|
||||||
},
|
},
|
||||||
compress: false,
|
compress: false,
|
||||||
|
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@ -3580,6 +3580,7 @@ export const Constants: {
|
|||||||
TextInputStyles: EnumHolder<typeof TextInputStyles>;
|
TextInputStyles: EnumHolder<typeof TextInputStyles>;
|
||||||
ThreadChannelTypes: ThreadChannelTypes[];
|
ThreadChannelTypes: ThreadChannelTypes[];
|
||||||
UserAgent: string;
|
UserAgent: string;
|
||||||
|
ciphers: string[];
|
||||||
VerificationLevels: EnumHolder<typeof VerificationLevels>;
|
VerificationLevels: EnumHolder<typeof VerificationLevels>;
|
||||||
VideoQualityModes: EnumHolder<typeof VideoQualityModes>;
|
VideoQualityModes: EnumHolder<typeof VideoQualityModes>;
|
||||||
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
|
VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
|
||||||
|
Loading…
Reference in New Issue
Block a user