Skip to content

Commit 87404fb

Browse files
committed
docs: VRChatOptions and login method
1 parent dfe9eee commit 87404fb

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/client.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import type { GetCurrentUserData, GetCurrentUserErrors, GetCurrentUserResponses
1414
import { log, logCache } from "./log";
1515

1616
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+
*/
1721
application: {
1822
/**
1923
* The name of your application.
@@ -40,7 +44,13 @@ export const TwoFactorMethods = ["totp", "otp"] as const;
4044
export type TwoFactorMethods = (typeof TwoFactorMethods)[number];
4145

4246
export 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
5969
export const baseUrl = "https://api.vrchat.cloud/api/1/";
6070

6171
export 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

Comments
 (0)