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

@openape/auth

v0.10.1

Published

OpenApe authentication: IdP + SP OIDC protocol logic

Downloads

1,945

Readme

@openape/auth

DDISA protocol implementation for both Identity Providers (IdP) and Service Providers (SP). Framework-agnostic — provides the authorization flow logic, token exchange, WebAuthn integration, and store interfaces without binding to any HTTP framework.

Note: The DDISA protocol uses an authorize/token/callback pattern but is its own protocol — not a standard OAuth or federation profile. Tokens are called assertions, not ID tokens.

Installation

npm install @openape/auth

Peer dependency: @openape/core

IdP API

Functions for building an Identity Provider.

Authorization

  • validateAuthorizeRequest(params) — Validate incoming authorization request parameters
  • evaluatePolicy(params) — Evaluate IdP policy for a given SP and user

Token Exchange

  • handleTokenExchange(params, stores) — Exchange authorization code for a signed assertion
  • issueAssertion(params) — Issue a signed DDISA assertion JWT

JWKS

  • generateJWKS(keyStore) — Generate a JWKS response from stored keys
  • serveJWKS(handler, keyStore) — Serve the /.well-known/jwks.json endpoint

WebAuthn

Registration and authentication using passkeys.

  • createRegistrationOptions(rpConfig, credential, challenge) — Generate WebAuthn registration options
  • createAuthenticationOptions(challenge) — Generate WebAuthn authentication options
  • verifyRegistration(response, challenge, credential) — Verify registration response, returns WebAuthnCredential
  • verifyAuthentication(response, challenge, credential) — Verify authentication response
  • uint8ArrayToBase64URL(array) / base64URLToUint8Array(str) — Encoding helpers

WebAuthn Config

interface RPConfig {
  name: string    // Relying party display name
  id: string      // Relying party ID (domain)
  origin: string  // Expected origin
}

SP API

Functions for building a Service Provider.

  • discoverIdP(domain) — Discover IdP configuration via DNS
  • createAuthorizationURL(options) — Build authorization URL with PKCE
  • handleCallback(params, options) — Handle callback, exchange code for assertion
  • createSPManifest(config) — Create an SP manifest object
  • serveSPManifest(handler, manifest) — Serve the /.well-known/sp-manifest.json endpoint

Store Interfaces

The IdP requires several stores for state management. In-memory implementations are included for development.

CodeStore

interface CodeStore {
  save(entry: CodeEntry): Promise<void>
  find(code: string): Promise<CodeEntry | null>
  delete(code: string): Promise<void>
}

KeyStore

interface KeyStore {
  getSigningKey(): Promise<KeyEntry>
  getAllPublicKeys(): Promise<KeyEntry[]>
}

ConsentStore

interface ConsentStore {
  hasConsent(userId: string, clientId: string): Promise<boolean>
  save(entry: ConsentEntry): Promise<void>
}

ChallengeStore

interface ChallengeStore {
  save(challenge: WebAuthnChallenge): Promise<void>
  find(challengeId: string): Promise<WebAuthnChallenge | null>
  delete(challengeId: string): Promise<void>
}

CredentialStore

interface CredentialStore {
  save(credential: WebAuthnCredential): Promise<void>
  find(id: string): Promise<WebAuthnCredential | null>
  list(userId: string): Promise<WebAuthnCredential[]>
  delete(id: string): Promise<void>
}

RegistrationUrlStore

interface RegistrationUrlStore {
  save(entry: RegistrationUrl): Promise<void>
  find(token: string): Promise<RegistrationUrl | null>
  delete(token: string): Promise<void>
  list(userId: string): Promise<RegistrationUrl[]>
}

In-memory implementations: InMemoryCodeStore, InMemoryConsentStore, InMemoryKeyStore.

Example: SP Login Flow

import { discoverIdP, createAuthorizationURL, handleCallback } from '@openape/auth'
import { resolveIdP } from '@openape/core'

// 1. Discover the user's IdP via DNS
const idpUrl = await resolveIdP('[email protected]'.split('@')[1])

// 2. Build the authorization URL with PKCE
const { authorizationUrl, codeVerifier, state, nonce } = await createAuthorizationURL({
  idpUrl,
  clientId: 'sp.example.com',
  redirectUri: 'https://sp.example.com/callback',
})
// → Redirect user to authorizationUrl

// 3. Handle the callback after user authenticates
const { user } = await handleCallback(
  { code, state },
  { codeVerifier, nonce, idpUrl, clientId: 'sp.example.com', redirectUri: 'https://sp.example.com/callback' }
)
// user.sub = '[email protected]', user.act = 'human'

License

MIT