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

@ossy/tokens

v1.13.3

Published

Token domain — aggregate and events for the Ossy token model

Readme

@ossy/tokens

Token domain package for the Ossy platform — event-sourced token entities for API keys, sign-in verification, and workspace invitations.

What this package provides

| Primitive | File | Id / export | |---|---|---| | Schema | token.schema.js | @ossy/tokens/schema/token | | Schema ids | schema-ids.js | TokenSchema | | Aggregate | token.aggregate.js | Token (kind: 'entity') | | Events | token.events.js | TokenEvents.Created, TokenEvents.Revoked | | Queries | tokens.queries.js | TokensQueries.GetTokens | | Action | get.action.js | @ossy/tokens/actions/get (GetToken) | | Task | get.task.js | @ossy/tokens/tasks/get |

@ossy/authentication, @ossy/users, and @ossy/workspaces create and revoke tokens via TokenEvents. @ossy/platform validates API tokens in UsersMiddleware.

Token schema (ADR 0006)

| Schema | Id | Purpose | |---|---|---| | Token | @ossy/tokens/schema/token | Token metadata (type, subject, description) |

Token secrets (JWT strings) live in event payloads and are redacted via Token.Redacted before returning to clients.

Getting a token

Call POST /actions with:

{
  "action": "@ossy/tokens/actions/get",
  "payload": {
    "tokenId": "token-abc"
  }
}

Returns the redacted token view (no raw JWT in the response).

Server usage

import { Token, TokenEvents, TokensQueries, TokenSchema } from '@ossy/tokens/server'

TokenSchema.token
// => '@ossy/tokens/schema/token'

const tokens = await TokensQueries.GetTokens({ subject: 'user-1' })
const view = Token.Redacted(aggregate.events, aggregate.state)

Creating tokens

Token creation is handled by feature packages that sign JWTs and emit events:

import { Aggregate } from '@ossy/event-store'
import { Token, TokenEvents } from '@ossy/tokens/server'

const event = TokenEvents.Created({
  createdBy: 'user-1',
  type: 'Api',
  subject: 'user-1',
  description: 'CLI token',
  token: signedJwt,
  expiresAt: Date.now() + 86400000,
  scopes: ['*'],
})

await Aggregate.Of(Token, event).then(Aggregate.Add(event))

The caller supplies the pre-computed token (JWT) and expiresAt — this package stays free of signing/config concerns.

Event model (ADR 0008)

| Event | Effect | |---|---| | Created | Sets id, schemaId, payload fields, scopes (default ['*']), status: 'Active' | | Revoked | Sets status: 'Revoked', revokedAt |

TokenEvents.Created emits type: '@ossy/tokens/schema/token', event: 'Created', and resourceId for the token id.

Migration

| Before | After | |---|---| | tokens/actions/get | @ossy/tokens/actions/get | | (task shared action id) | @ossy/tokens/tasks/get | | Aggregate query type: 'Token' | type: '@ossy/tokens/schema/token' | | Event aggregateId | resourceId | | Event type: 'Created' | event: 'Created' with schema type |