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

@x12i/authx-token-store

v1.0.1

Published

Storage abstractions for AuthX tokens, apps, revocations, and audit

Readme

@x12i/authx-token-store

Storage abstractions for AuthX: apps, secrets, tokens, revocations, and audit events. Includes an in-memory implementation for development and testing.

Part of the AuthX monorepo. See the root README for the full system.


Install

npm install @x12i/authx-token-store @x12i/authx-token-types

For production persistence, use @x12i/authx-token-store-mongo instead.


Purpose

This package defines interfaces (AuthxStores) that the token service and custom integrations implement against. Splitting storage from crypto (token-core) keeps the service testable and allows swapping backends.

token-service  →  AuthxStores  →  memory | mongo | (your adapter)

Store bundle

interface AuthxStores {
  apps: AuthxAppStore;
  tokens: AuthxTokenStore;
  revocations: AuthxRevocationStore;
  audit: AuthxAuditStore;
}

Interfaces

AuthxAppStore

| Method | Description | | --- | --- | | saveApp(app) | Create or replace app descriptor | | getAppById(appId) | Get app (no secret) | | listApps() | List all apps | | updateApp(appId, patch) | Partial update | | saveAppSecret(record) | Store signing secret separately | | getAppSecret(appId) | Load secret for verify/issue |

AuthxAppSecretRecord fields: appId, secretKeyRef, secretKey, keyVersion, previousSecretKey?, previousKeyVersion?, timestamps.

AuthxTokenStore

| Method | Description | | --- | --- | | saveToken(descriptor) | Persist issued token metadata | | getTokenById(tokenId) | Lookup by ID | | listTokens(filter?) | Filter by appId, ownerIdentityId, status, paginate with limit/offset | | updateTokenStatus(tokenId, status) | Mark active or revoked |

AuthxRevocationStore

| Method | Description | | --- | --- | | revokeToken(record) | Revoke single token | | isRevoked(tokenId) | Check revocation (used during verify) | | listRevokedByApp(appId) | List revocations for app | | listRevokedByIdentity(identityId) | List revocations for identity | | revokeAllForApp(appId, reason?) | Bulk revoke — returns count | | revokeAllForIdentity(identityId, reason?) | Bulk revoke — returns count |

AuthxAuditStore

| Method | Description | | --- | --- | | appendEvent(event) | Append audit event | | listEvents(filter?) | Filter by appId, tokenId, limit |


In-memory implementation

For local dev, tests, and ephemeral deployments:

import { createInMemoryStores, createAuditEvent } from "@x12i/authx-token-store";

const stores = createInMemoryStores();

await stores.apps.saveApp({ /* AuthxAppDescriptor */ });
await stores.apps.saveAppSecret({ /* AuthxAppSecretRecord */ });

await stores.audit.appendEvent(
  createAuditEvent({ eventType: "app.created", appId: "my-app" }),
);

Caveat: Data is lost when the process exits. The token service uses this when AUTHX_STORE=memory.


Implementing a custom backend

Implement all four interfaces and return them from a factory:

import type { AuthxStores } from "@x12i/authx-token-store";

export async function createPostgresStores(/* ... */): Promise<AuthxStores> {
  return {
    apps: { /* ... */ },
    tokens: { /* ... */ },
    revocations: { /* ... */ },
    audit: { /* ... */ },
  };
}

Wire into the service:

import { AuthxTokenService } from "@x12i/authx-token-service"; // see service README
const stores = await createPostgresStores();
const service = new AuthxTokenService(stores, "authx");

Reference implementation: @x12i/authx-token-store-mongo.


Audit helper

import { createAuditEvent } from "@x12i/authx-token-store";

const event = createAuditEvent({
  eventType: "token.issued",
  appId: "my-app",
  tokenId: "tok_abc",
  identityId: "user-1",
});
// Adds eventId (UUID) and createdAt automatically

Common event types used by the service: app.created, app.updated, token.issued, token.revoked, token.revoked.all.app, token.revoked.all.identity.


Development

npm run build -w @x12i/authx-token-store
npm test -w @x12i/authx-token-store

Source: src/interfaces.ts, src/memory.ts.


Related packages

| Package | Role | | --- | --- | | @x12i/authx-token-types | Descriptor and event types | | @x12i/authx-token-store-mongo | MongoDB implementation | | @x12i/authx-token-service | Uses stores via AuthxTokenService |