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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@studio-vaai/js-client

v0.3.1

Published

TypeScript contract types for the studio vaai public HTTP API, plus an optional fetch-based transport (Hey API codegen under src/impl/generated).

Readme

@studio-vaai/js-client

TypeScript client for the studio vaai virtual try-on HTTP API.

This package is the public contract: request/response types, the StudioVaaiClient interface, and a ready-to-use fetch-based transport. It runs in both the browser and Node.

Install

npm install @studio-vaai/js-client

Usage

import { createFetchStudioVaaiClient } from "@studio-vaai/js-client";

const client = createFetchStudioVaaiClient({
  baseUrl: "https://api.studio-vaai.com",
  clientApiKey: "your-client-api-key",
});

const result = await client.session.createSession({
  dataProcessingConsent: true,
});

client implements StudioVaaiClient, with one namespace per API area:

| Namespace | Methods | | -------------------- | -------------------------------------------------------------------- | | client.meta | getHealth | | client.session | createSession, getSession, refreshSession, invalidateSession | | client.body | listBodies, createBody, setBodyHeight | | client.tryOn | createTryOn, getTryOn, getRecommendedSize | | client.analytics | createTrackingClient (local factory; no configuration request) | | client.experiments | evaluateFlag, evaluateFlagsBulk, getTryOnDecision | | client.catalog | getProductListing (optional member; the fetch client has it) |

Analytics

Create a tracking client locally using the API client's existing key and fetch implementation:

const tracking = client.analytics.createTrackingClient({
  sdkVersion: "[email protected]",
  distinctId: "anonymous-visitor-id",
});
tracking.trackEvent({
  name: "cart-item-added",
  data: { "product-id": "longsleeve", "variant-size": "M" },
});

Events POST immediately to https://a.studio-vaai.com/api/send using the existing client API key. Browser collection omits shopper credentials and cookies. trackEvent reports whether delivery was queued, not acknowledged.

React providers create this transport and send flow events automatically. Avoid duplicating those events; send storefront cart and order events yourself. For local development, set analyticsBaseUrl when creating the fetch API client.

Session transport

createFetchStudioVaaiClient({ clientApiKey, sessionTransport }) accepts:

  • auto (the default): in browsers, prepare cookie creation, then verify the preparation cookie while creating the session. Native/server environments use bearer.
  • cookie: require an HttpOnly cookie; return session_transport_unavailable when cookies cannot be used. Never fall back to bearer.
  • bearer: manage the token explicitly and send it in Authorization.

Cookie mode uses shop-scoped Secure, HttpOnly, SameSite=None, Partitioned cookies. It never returns the cookie credential to JavaScript. The returned session is a non-secret shop/API marker; pass it unchanged to SDK methods. Bearer handles remain tokens. Session results also include sessionTransport and expiresAt when using the fetch client.

Auto falls back only on session-cookie-unavailable, which guarantees no session was created, never after other errors or an uncertain creation request. The actual cookie session is checked after creation; subsequent failures never convert it to bearer. Restore existing handles with getSession; auto preserves existing bearer sessions, while explicit modes reject incompatible handles.

Handles are not persisted automatically. Always retain the handle returned by refresh.

Sessions expire after 60 minutes of inactivity; expiresAt includes this idle deadline. Accepted photo submissions, height calibrations and try-on requests, including companion renders, renew activity. Reads, polling, upload preparation and credential refresh do not. The server determines activity; callers cannot override it. onSessionActivity lets the supplied state machine follow accepted processing for each session. Custom transports must respect AbortSignal.

Cookie storage is managed by the browser; native/server cookie mode needs a custom cookie-aware fetch implementation. The wire API has separate cookie and bearer creation/refresh endpoints; auto is SDK policy.

See Authentication for examples and storage/expiry guidance.

Results and errors

Methods return an ApiResult<T> — a discriminated union you inspect, rather than a value that throws:

const result = await client.body.listBodies({/* … */});
if (result.ok) {
  result.data; // typed payload
} else {
  result.error; // StandardError — kind, message, details
}

ApiFailureError carries an ApiFailure payload for the cases where a failure is thrown rather than returned.

Versioning

Business API requests carry an X-Client-Version header so the server can match the contract. The value is a constant you can read:

import { API_VERSION, CLIENT_VERSION_HEADER_VALUE } from "@studio-vaai/js-client";

API_VERSION is a calendar-style contract date, independent of this package's npm version. Analytics POSTs use X-Client-Api-Key without a business API version or shopper session header.

License

MIT