Added VRChat Login

This commit is contained in:
2023-04-23 17:51:25 +07:00
parent dd6dd4e3fa
commit 33dd68219d
3 changed files with 193 additions and 0 deletions
+2
View File
@@ -26,6 +26,7 @@ import Discord_InteractionManager from '../discord/InteractionManager';
import Discord_MembershipScreening from '../discord/MembershipScreening';
import Discord_osu from '../discord/osu';
import Discord_VRChat from '../discord/VRChat';
import Discord_VRChatLogin from '../discord/Developer/VRChatLogin';
import Discord_UserInfo from '../discord/UserInfo';
import Discord_Stats from '../discord/Stats';
import Discord_Support from '../discord/Support';
@@ -80,6 +81,7 @@ class Discord {
new Discord_InteractionManager(),
new Discord_osu(),
new Discord_VRChat(),
new Discord_VRChatLogin(),
new Discord_Settings(),
new Discord_Support(),
+26
View File
@@ -97,6 +97,32 @@ class VRChatAPI {
}, VRC_CACHE_DURATION);
}
public async reInit() {
Logger.info(LOGGING_TAG, 'Re-initializing VRChat API');
this.ready = false;
this.client = null;
this.configuration = null;
await this.init();
}
public async loginEmailOtp(otp: string) {
if (this.ready) throw new Error('Already logged in');
let res;
try {
res = await this.client!.AuthenticationApi.verify2FAEmailCode({
code: otp
});
} catch (err: any) {
if (err.response?.status === 400) {
Logger.error(LOGGING_TAG, 'Unable to log in, invalid OTP');
throw new Error('Invalid OTP');
} else if (err.response?.status === 401) {
Logger.error(LOGGING_TAG, 'Unable to log in, invalid auth cookie');
throw new Error('Invalid auth cookie');
} else throw err;
}
}
public isReady(): boolean {
return this.ready;
}