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

@pipobscure/auth

v0.1.2

Published

Authentication Server Library

Readme

@pipobscure/auth

Authentication and Account Management Library

@pipobscure/auth provides a minimal, extensible TypeScript API for managing user accounts, device keys, authentication challenges, and JWT token issuance.
It is built around strong cryptographic primitives, JWK keys, and WebAuthn-style challenge–response authentication.


✨ Features

  • 🔐 WebAuthn-style authentication using signed challenges
  • 🧩 Key registration and attestation handling
  • 🪪 JWT issuance and verification (via @pipobscure/jwt)
  • 🧾 Structured storage abstraction (via @pipobscure/store)
  • ⚙️ TypeScript-native and standards-aligned

📦 Installation

npm install @pipobscure/auth

or with Yarn:

yarn add @pipobscure/auth

🚀 Usage

import { Accounts } from '@pipobscure/auth'
import { MemoryBackend } from '@pipobscure/store'

// Create a store backend and signing key
const backend = new MemoryBackend()
const key = await crypto.subtle.generateKey(
  { name: 'HMAC', hash: 'SHA-256' },
  true,
  ['sign', 'verify']
)

const accounts = new Accounts(backend, key)

// Create an account
await accounts.createAccount('alice', 'Alice Doe', {
  kty: 'RSA',
  e: 'AQAB',
  n: '...' // recovery JWK
})

// Generate a login/registration challenge
const { challenge } = await accounts.challenge('device123', 'alice')

// Register a new key
await accounts.addKey(
  'device123',
  'BASE64_SIGNATURE',
  'alice',
  'key1',
  { kty: 'EC', crv: 'P-256', x: '...', y: '...' },
  'ES256'
)

// Verify a login response
const valid = await accounts.response(
  'device123',
  'alice',
  'BASE64_SIGNATURE',
  'key1',
  'ES256'
)

// Issue a JWT for authenticated sessions
if (valid) {
  const token = await accounts.jwtIssue('alice', { role: 'user' })
  console.log('JWT:', token)
}

🧠 Conceptual Flow

  1. Account CreationcreateAccount(username, displayname, recovery)
  2. Key Registrationchallenge()addAttestation() / addKey()
  3. Authenticationchallenge()response()
  4. JWT IssuancejwtIssue()

🧩 API Reference

class Accounts

Constructor

new Accounts(backend: Backend, key: CryptoKey)
  • backend: A persistence backend (e.g. from @pipobscure/store).
  • key: A CryptoKey used for signing JWTs.

getAccount(username: string): Promise<Account | null>

Retrieve an existing account or null if it doesn’t exist.


createAccount(username, displayname, recovery): Promise

Create a new account with:

  • username (canonicalized)
  • displayname
  • recovery (JWK)
  • Metadata: id, created, modified, and keys object

Throws if the account already exists.


challenge(devid, username): Promise<{ challenge, keys, userid } | null>

Generate a new authentication challenge for a given device and user.


addKey(devid, signature, username, keyid, key, algorithm): Promise

Register a new device key for a user after validating a signed challenge.


addAttestation(devid, signature, username, attestation, algorithm): Promise

Extracts key information from a CBOR-encoded attestation and registers it.
A convenience wrapper around addKey().


response(devid, username, signature, keyid, algorithm): Promise

Validate a challenge–response authentication attempt.
Returns true on success, false otherwise.


delKey(username, keyid): Promise

Delete a registered key from a user account.
Returns false if the key does not exist.


jwtIssue(username, claims): Promise<string | null>

Issue a signed JWT for the given user.
Automatically includes:

  • iss, iat, sub, and name claims

Returns the signed token string or null if issuance fails.


🪪 Types

type Account = {
  id: string
  username: string
  displayname: string
  recovery: JsonWebKey
  keys: Record<string, JsonWebKey>
  created: number
  modified: number
}

⚙️ Development

npm run build   # Compile TypeScript
npm test        # Run unit tests
npm run format  # Auto-format code

🧾 License

ISC License
© Philipp Dunkel