npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@enterlink/vrchat

v1.8.0

Published

Hand written package for the VRChat API.

Downloads

321

Readme

vrchat

VRChat API package focused on abstracting session management.

Installation

yarn add @enterlink/vrchat

Usage

Accounts with no totp key must define a ClientOptions#onRequestOtpKey for fetching the relevant otp.

import { Client, CurrentUser, Routes, World } from "@enterlink/vrchat";

const client = new Client({
  email: '[email protected]',
  password: 'some-secret-password',
  totpKey: 'totp-private-key'
});

;(async () => {
  const user = await client.get<CurrentUser>(Routes.currentUser());
  console.log("Logged in as", user.displayName);

  const world = await client.get<World>(Routes.world("wrld_2851d12c-57d0-4754-84cf-aa494ce7a03a"));
  console.log("Found World:", world.name);

  await client.put(Routes.logout());
  console.log("Logged out!");
})().catch(console.error);

Pooled Usage Example

Our specfic scenario demands us having a pool of accounts. You can achieve this with using the pooler. The pooler expects a constructed implementation of StorageAdapter. In this example we will use the Memory Adapter.

It is highly recommended to use an adapter that will persist session states across restarts. VRChat has a limit to how many active sessions an account can have.

import { CurrentUser, Pooler, Routes } from "@enterlink/vrchat";
import { MemoryStorageAdapter } from '@enterlink/vrchat/adapter/memory';

const adapter = new MemoryStorageAdapter([
  {
    email: '[email protected]',
    password: 'some-secret-password',
    totpKey: 'totp-private-key'
  },
  {
    email: '[email protected]',
    password: 'some-secret-password',
    totpKey: 'totp-private-key'
  },
  {
    email: '[email protected]',
    password: 'some-secret-password',
    totpKey: 'totp-private-key'
  }
]);

const pooler = new Pooler(adapter);

;(async () => {
  const users = await pooler.getAll<CurrentUser>(Routes.currentUser());

  for (const user of users) {
    console.log("Logged in as:", user.displayName);
  }

  await pooler.putAll(Routes.logout());
  console.log("Logged out all users");
})().catch(console.error);

Notes

We use otplib internally for generating TOTP codes. I've noticed that on Node.js versions 20 and 21, authentication failures occur because one of otplib's dependencies, thirty-two, uses new Buffer() internally. This results in a Node.js error: TypeError: Cannot read properties of undefined (reading '0'). Since there isn't a straightforward fix for this issue, we are running Node.js v22+ to avoid the problem.

Backlog

  • [x] Implement Prisma adapter for our use case.
  • [x] Prisma adapter optional encryption.
  • [x] Way to select an account to use in pooler.
  • [x] Way to request on all accounts in pooler.
  • [x] Support for accounts all 2fa types (see src/client.ts).
  • [ ] Implement all API endpoints (see src/api.ts).
  • [ ] Support setting ratelimits.
  • [ ] Pooler single account transactions.