vrchat 1.18.0 → 1.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,20 +26,36 @@ npm install vrchat
26
26
  Below is an example on how to login to the API and fetch your own user information.
27
27
 
28
28
  ```javascript
29
- // Step 1. We begin with creating a Configuration, which contains the username and password for authentication.
29
+ // Step 1. We begin with creating a Configuration, which contains the username and password for authentication, as well as an options dictionary, which contains the user agent header.
30
30
  const vrchat = require("vrchat");
31
+
31
32
  const configuration = new vrchat.Configuration({
32
33
  username: "username",
33
34
  password: "password"
34
35
  });
35
36
 
37
+ const options = { headers: { "User-Agent": "ExampleProgram/0.0.1 my@email.com"}};
38
+
36
39
  // Step 2. VRChat consists of several API's (WorldsApi, UsersApi, FilesApi, NotificationsApi, FriendsApi, etc...)
37
40
  // Here we instantiate the Authentication API which is required for logging in.
38
41
  const AuthenticationApi = new vrchat.AuthenticationApi(configuration);
39
42
 
40
43
  // Step 3. Calling getCurrentUser on Authentication API logs you in if the user isn't already logged in.
41
- AuthenticationApi.getCurrentUser().then(resp => {
42
- const currentUser = resp.data;
44
+ AuthenticationApi.getCurrentUser(options).then(async resp => {
45
+ var currentUser = resp.data;
46
+
47
+ // Step 3.5. Calling email verify2fa if the account has 2FA disabled
48
+ if (currentUser["requiresTwoFactorAuth"] && currentUser["requiresTwoFactorAuth"][0] === "emailOtp") {
49
+ await AuthenticationApi.verify2FAEmailCode({ code: "123456" }, options)
50
+ currentUser = (await AuthenticationApi.getCurrentUser(options)).data;
51
+ }
52
+
53
+ // Step 3.5. Calling verify2fa if the account has 2FA enabled
54
+ if (currentUser["requiresTwoFactorAuth"] && currentUser["requiresTwoFactorAuth"][0] === "totp") {
55
+ await AuthenticationApi.verify2FA({ code: "123456" }, options)
56
+ currentUser = (await AuthenticationApi.getCurrentUser(options)).data;
57
+ }
58
+
43
59
  console.log(`Logged in as: ${currentUser.displayName}`);
44
60
  });
45
61
  ```