@@ -14,6 +14,10 @@ import type { GetCurrentUserData, GetCurrentUserErrors, GetCurrentUserResponses
14
14
import { log , logCache } from "./log" ;
15
15
16
16
export 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
+ */
17
21
application : {
18
22
/**
19
23
* The name of your application.
@@ -40,7 +44,13 @@ export const TwoFactorMethods = ["totp", "otp"] as const;
40
44
export type TwoFactorMethods = ( typeof TwoFactorMethods ) [ number ] ;
41
45
42
46
export interface LoginCredentials {
47
+ /**
48
+ * The username or email of the VRChat account.
49
+ */
43
50
username : string ;
51
+ /**
52
+ * The password of the VRChat account.
53
+ */
44
54
password : string ;
45
55
/**
46
56
* The secret key for two-factor authentication.
@@ -59,7 +69,6 @@ type LoginOptions<ThrowOnError extends boolean> = LoginCredentials & Omit<Option
59
69
export const baseUrl = "https://api.vrchat.cloud/api/1/" ;
60
70
61
71
export class VRChat extends _VRChat {
62
- // private keyv: Keyv<unknown>;
63
72
private cache : Cacheable ;
64
73
65
74
public constructor ( options : VRChatOptions ) {
@@ -181,6 +190,13 @@ export class VRChat extends _VRChat {
181
190
await this . cache . set ( "cookies" , cookies ) ;
182
191
}
183
192
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
+ */
184
200
public async login < ThrowOnError extends boolean = false > ( options : LoginOptions < ThrowOnError > ) : Promise < RequestResult < GetCurrentUserResponses , GetCurrentUserErrors , ThrowOnError > > {
185
201
const { username, password, totpSecret, throwOnError } = options ;
186
202
let { twoFactorCode } = options ;
0 commit comments