fix: normalize TOTPKey format and enhance debug messages in RequestHandler

This commit is contained in:
Elysia
2025-07-10 21:11:24 +07:00
parent 780dfe8078
commit 23c669bef9
2 changed files with 7 additions and 2 deletions

View File

@@ -874,6 +874,10 @@ class Client extends BaseClient {
) { ) {
throw new TypeError('CLIENT_INVALID_OPTION', 'rejectOnRateLimit', 'an array or a function'); throw new TypeError('CLIENT_INVALID_OPTION', 'rejectOnRateLimit', 'an array or a function');
} }
if (typeof options.TOTPKey === 'string') {
// Convert to base32 if not already
options.TOTPKey = options.TOTPKey.replace(/ +/g, '').toUpperCase();
}
// Hardcode // Hardcode
this.options.shardCount = 1; this.options.shardCount = 1;
this.options.shards = [0]; this.options.shards = [0];

View File

@@ -332,7 +332,7 @@ class RequestHandler {
this.manager.client.emit( this.manager.client.emit(
DEBUG, DEBUG,
`Hit a 429 while executing a request. `[Request Handler] Hit a 429 while executing a request.
Global : ${isGlobal} Global : ${isGlobal}
Method : ${request.method} Method : ${request.method}
Path : ${request.path} Path : ${request.path}
@@ -397,6 +397,7 @@ class RequestHandler {
* ticket: string; * ticket: string;
* methods: { * methods: {
* type: "password" | "totp" | "sms" | "backup" | "webauthn"; * type: "password" | "totp" | "sms" | "backup" | "webauthn";
* backup_codes_allowed?: boolean;
* }[]; * }[];
* }; * };
* }; * };
@@ -409,7 +410,7 @@ class RequestHandler {
const otp = this.manager.client.authenticator.generate(this.manager.client.options.TOTPKey); const otp = this.manager.client.authenticator.generate(this.manager.client.options.TOTPKey);
this.manager.client.emit( this.manager.client.emit(
DEBUG, DEBUG,
`${data.message} `[Request Handler] ${data.message}
Method : ${request.method} Method : ${request.method}
Path : ${request.path} Path : ${request.path}
Route : ${request.route} Route : ${request.route}