@@ -14,6 +14,10 @@ import type { GetCurrentUserData, GetCurrentUserErrors, GetCurrentUserResponses
1414import { log , logCache } from "./log" ;
1515
1616export interface VRChatOptions extends Omit < NonNullable < Parameters < typeof createConfig > [ 0 ] > , "body" | "bodySerializer" | "credentials" | "global" | "method" | "mode" | "parseAs" | "querySerializer" > {
17+ /**
18+ * When using the VRChat API, you must provide an application name, version, and contact information.
19+ * This is used to identify your application to VRChat, and to provide support if needed.
20+ */
1721 application : {
1822 /**
1923 * The name of your application.
@@ -40,7 +44,13 @@ export const TwoFactorMethods = ["totp", "otp"] as const;
4044export type TwoFactorMethods = ( typeof TwoFactorMethods ) [ number ] ;
4145
4246export interface LoginCredentials {
47+ /**
48+ * The username or email of the VRChat account.
49+ */
4350 username : string ;
51+ /**
52+ * The password of the VRChat account.
53+ */
4454 password : string ;
4555 /**
4656 * The secret key for two-factor authentication.
@@ -59,7 +69,6 @@ type LoginOptions<ThrowOnError extends boolean> = LoginCredentials & Omit<Option
5969export const baseUrl = "https://api.vrchat.cloud/api/1/" ;
6070
6171export class VRChat extends _VRChat {
62- // private keyv: Keyv<unknown>;
6372 private cache : Cacheable ;
6473
6574 public constructor ( options : VRChatOptions ) {
@@ -181,6 +190,13 @@ export class VRChat extends _VRChat {
181190 await this . cache . set ( "cookies" , cookies ) ;
182191 }
183192
193+ /**
194+ * Logs in to the VRChat API using the provided credentials, and returns the current user.
195+ * This method handles two-factor authentication if required using the provided `twoFactorCode` function or `totpSecret`.
196+ *
197+ * @param options - The login options, including username, password, and optional two-factor authentication details.
198+ * @returns A promise that resolves to the current user data, or an error if the login fails.
199+ */
184200 public async login < ThrowOnError extends boolean = false > ( options : LoginOptions < ThrowOnError > ) : Promise < RequestResult < GetCurrentUserResponses , GetCurrentUserErrors , ThrowOnError > > {
185201 const { username, password, totpSecret, throwOnError } = options ;
186202 let { twoFactorCode } = options ;
0 commit comments