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

@dofek/xert

v0.1.5

Published

Unofficial Xert API client with password authentication, token refresh, and activity parsing

Readme

@dofek/xert

TypeScript client for Xert authentication, token refresh, observed activity paging, runtime response validation, and conversion to provider-agnostic activity records.

Xert publishes an API reference that documents its password and refresh-token grants, including the xert_public client credentials. The paginated activity response consumed here is an observed Xert web API shape rather than the activity-list representation in that reference. See the Xert API documentation.

This package is not affiliated with, endorsed by, or supported by Xert or Baron Biosystems. Undocumented endpoints and response shapes may change without notice.

Requirements and installation

Requires Node.js 22.14 or newer and its built-in fetch implementation.

npm install @dofek/xert

Quick start

import { XertClient } from "@dofek/xert";
import { parseXertActivity } from "@dofek/xert/parsing";

const email = process.env.XERT_EMAIL;
const password = process.env.XERT_PASSWORD;
if (!email || !password) {
  throw new Error("Set XERT_EMAIL and XERT_PASSWORD");
}

const token = await XertClient.signIn(email, password);
const client = new XertClient(token.accessToken);
const activities = await client.listActivities({
  from: Math.floor(Date.parse("2026-07-01T00:00:00Z") / 1000),
});

console.log(activities.map(parseXertActivity));

from is a Unix timestamp in seconds. page defaults to 0, and limit defaults to 50.

Authentication and token refresh

XertClient.signIn(email, password, fetch?, credentials?) uses the resource owner password grant documented by Xert. It returns:

  • accessToken
  • refreshToken
  • expiresAt
  • scopes

The library defaults to the documented xert_public client ID and secret. To use different credentials, pass them explicitly:

const token = await XertClient.signIn(
  email,
  password,
  fetch,
  { clientId: "client-id", clientSecret: "client-secret" },
);

The library never reads environment variables. Applications decide how to load configuration and must store account passwords, access tokens, and refresh tokens as password-equivalent secrets.

Refresh before expiresAt:

const refreshed = await XertClient.refreshToken(token.refreshToken!);

The standalone signInToXert and refreshXertToken functions expose the same operations. If Xert does not return a replacement refresh token, refreshXertToken retains the supplied token.

Public API

  • new XertClient(accessToken, fetch?)
  • XertClient.signIn(email, password, fetch?, credentials?)
  • XertClient.refreshToken(refreshToken, fetch?, credentials?)
  • client.listActivities({ from, page?, limit? })
  • signInToXert(...)
  • refreshXertToken(...)
  • DEFAULT_XERT_CLIENT_CREDENTIALS
  • XertAuthenticationError
  • XertApiError

Supported deep imports:

  • @dofek/xert/client — authentication, refresh, and API client.
  • @dofek/xert/parsing — sport mapping and normalized activity parsing.
  • @dofek/xert/types — Zod schemas and TypeScript types.

All token and activity responses cross a Zod runtime-validation boundary. A response-shape change therefore throws ZodError instead of returning unchecked data.

Errors and rate limits

Rejected authentication and refresh requests throw XertAuthenticationError. Other unsuccessful activity requests throw XertApiError. Both expose statusCode and responseBody.

The shared HTTP wrapper throws ProviderRateLimitError for 429 and ProviderServiceUnavailableError for 502, 503, and 504, retaining a parsed Retry-After value when supplied.

If your application handles these classes directly, declare @dofek/provider-http as a direct dependency:

import {
  ProviderRateLimitError,
  ProviderServiceUnavailableError,
} from "@dofek/provider-http/rate-limit";

Project