Update RemoteAuth.js
This commit is contained in:
parent
4401388dfd
commit
fbaf7ed7c8
@ -107,15 +107,15 @@ class DiscordAuthWebsocket extends EventEmitter {
|
|||||||
* @returns {Promise<string>} Captcha token
|
* @returns {Promise<string>} Captcha token
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
this.captchaHandler = data =>
|
this.captchaSolver = data =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
reject(
|
reject(
|
||||||
new Error(`
|
new Error(`
|
||||||
Captcha Handler not found - Please set captchaHandler option
|
Captcha Handler not found - Please set captchaSolver option
|
||||||
Example captchaHandler function:
|
Example captchaSolver function:
|
||||||
|
|
||||||
new DiscordAuthWebsocket({
|
new DiscordAuthWebsocket({
|
||||||
captchaHandler: async (data) => {
|
captchaSolver: async (data) => {
|
||||||
const token = await hcaptchaSolver(data.captcha_sitekey, 'discord.com');
|
const token = await hcaptchaSolver(data.captcha_sitekey, 'discord.com');
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ new DiscordAuthWebsocket({
|
|||||||
apiVersion: 9,
|
apiVersion: 9,
|
||||||
userAgent: defaultUA,
|
userAgent: defaultUA,
|
||||||
wsProperties: defaultClientOptions.ws.properties,
|
wsProperties: defaultClientOptions.ws.properties,
|
||||||
captchaHandler: () => new Error('Captcha Handler not found. Please set captchaHandler option.'),
|
captchaSolver: () => new Error('Captcha Handler not found. Please set captchaSolver option.'),
|
||||||
};
|
};
|
||||||
if (typeof options == 'object') {
|
if (typeof options == 'object') {
|
||||||
if (typeof options.debug == 'boolean') this.options.debug = options.debug;
|
if (typeof options.debug == 'boolean') this.options.debug = options.debug;
|
||||||
@ -168,7 +168,7 @@ new DiscordAuthWebsocket({
|
|||||||
if (typeof options.apiVersion == 'number') this.options.apiVersion = options.apiVersion;
|
if (typeof options.apiVersion == 'number') this.options.apiVersion = options.apiVersion;
|
||||||
if (typeof options.userAgent == 'string') this.options.userAgent = options.userAgent;
|
if (typeof options.userAgent == 'string') this.options.userAgent = options.userAgent;
|
||||||
if (typeof options.wsProperties == 'object') this.options.wsProperties = options.wsProperties;
|
if (typeof options.wsProperties == 'object') this.options.wsProperties = options.wsProperties;
|
||||||
if (typeof options.captchaHandler == 'function') this.captchaHandler = options.captchaHandler;
|
if (typeof options.captchaSolver == 'function') this.captchaSolver = options.captchaSolver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_createWebSocket(url) {
|
_createWebSocket(url) {
|
||||||
@ -474,8 +474,8 @@ new DiscordAuthWebsocket({
|
|||||||
});
|
});
|
||||||
if (!res && this.captchaCache) {
|
if (!res && this.captchaCache) {
|
||||||
this._logger('default', 'Captcha is detected. Please solve the captcha to continue.');
|
this._logger('default', 'Captcha is detected. Please solve the captcha to continue.');
|
||||||
this._logger('debug', 'Try call captchaHandler()', this.captchaCache);
|
this._logger('debug', 'Try call captchaSolver()', this.captchaCache);
|
||||||
const token = await this.options.captchaHandler(this.captchaCache);
|
const token = await this.options.captchaSolver(this.captchaCache);
|
||||||
return this._findRealToken(token);
|
return this._findRealToken(token);
|
||||||
}
|
}
|
||||||
this.realToken = this._decryptPayload(res.data.encrypted_token).toString();
|
this.realToken = this._decryptPayload(res.data.encrypted_token).toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user