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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@veraid/kliento

v1.3.1

Published

Self-contained client authentication tokens

Readme

Kliento JavaScript Library

This is the JavaScript implementation of Kliento, a client authentication protocol where tokens contain all the data required to be verified offline without pre-distributing public keys or accessing remote servers. Think JWTs, without JWKS documents to pre-distribute or download during verification.

Kliento is a very simple protocol based on VeraId. Each token is distributed as part of a token bundle, which is a binary blob that contains the token itself along with the VeraId chain of trust.

Simply put, Kliento extends the idea of AWS roles, Azure managed identities, GCP service accounts and Kubernetes service accounts to the entire Internet in a vendor-neutral manner.

Installation

This library is available on NPM as @veraid/kliento.

Usage

Server-side verification

To verify a token bundle, the server simply has to use the TokenBundle.verify() method.

For example, in an HTTP server, the bundle can be passed Base64-encoded in an Authorization request header with the Kliento scheme (i.e. Authorization: Kliento <base64-encoded-bundle>), and the server could verify it as follows:

import { TokenBundle, type TokenBundleVerification } from '@veraid/kliento';

// Replace with a unique identifier for your server
const AUDIENCE = 'https://api.example.com';

async function verifyTokenBundle(authHeaderValue: string): Promise<TokenBundleVerification> {
    const tokenBundle = TokenBundle.deserialiseFromAuthHeader(authHeaderValue);
    return await tokenBundle.verify(AUDIENCE);
}

Alternatively, if the bundle is already available as an ArrayBuffer or Buffer, it should be deserialised with the TokenBundle.deserialise() method instead.

As long as the Kliento token bundle is valid and bound to the specified audience, TokenBundle.verify() will output:

  • subjectId: The id of the VeraId member to whom the token bundle is attributed (e.g. example.com, [email protected]).
  • claims: The claims in the token. This is an optional key/value map analogous to JWT claims. It's up to the server to define what claims are present and what they mean.

If the deserialisation input is malformed, deserialiseFromAuthHeader() and deserialise() will throw an error. Similarly, if the token is invalid or bound to a different audience, verify() will throw an error.

Client-side token acquisition

To obtain token bundles, clients must first register the signature specification for such bundles in VeraId Authority. The payload of the signature specification must be set to a Kliento token, which is a JSON document with the following properties:

  • audience (string, required): The audience for which the token is valid.
  • claims (object, optional): A map of key/value pairs, where keys and values are strings.

For example:

{
  "audience": "https://api.example.com",
  "claims": { "permission": "read-only" }
}

Once the signature specification is registered, clients can obtain token bundles for that specification by making a simple HTTP request to VeraId Authority. No Kliento or VeraId libraries are required at runtime, but clients may use a high-level library to simplify the process, such as @veraid/authority-credentials for JS.

For example, to send a token bundle to an HTTP server in the Authorization request header, the client could use the following code to encode the header value:

function encodeAuthHeaderValue(tokenBundle: Buffer): string {
    const bundleEncoded = tokenBundle.toString('base64');
    return `Kliento ${bundleEncoded}`;
}

Custom trust anchors

TokenBundle.verify() allows for custom DNSSEC trust anchors to be passed, but there are only two legitimate reasons to do this:

  • To test token bundle verification in unit or integration tests.
  • To reflect an official change to the root zone trust anchors, if you're not able to use a version of this library that uses the new trust anchors.

API docs

The API documentation can be found on docs.veraid.net.

Contributions

We love contributions! If you haven't contributed to a Relaycorp project before, please take a minute to read our guidelines first.

Issues are tracked on the KLIB project on Jira.