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

@eleven-am/launchpad-auth

v0.1.1

Published

TypeScript SDK for integrating Launchpad authentication into client applications

Readme

@eleven-am/launchpad-auth

TypeScript SDK for integrating Launchpad authentication into client applications.

Installation

npm install @eleven-am/launchpad-auth

Quick Start

import { LaunchpadAuth } from '@eleven-am/launchpad-auth'

const auth = new LaunchpadAuth({
  baseUrl: 'https://auth.myapp.com'
})

// Sign up
const { user } = await auth.signUp({
  email: '[email protected]',
  password: 'password123',
  name: 'John Doe'
})

// Sign in
const result = await auth.signIn({ email, password })
if ('twoFactorRequired' in result) {
  const { user } = await auth.verifyLoginCode(result.challengeToken, code)
} else {
  console.log('Logged in as', result.user.email)
}

// Check auth state
if (auth.isAuthenticated()) {
  console.log(auth.getUser())
}

Configuration

interface LaunchpadAuthConfig {
  baseUrl: string                                    // Launchpad server URL
  storage?: 'localStorage' | 'memory' | TokenStorage // Token storage (default: localStorage)
  onTokenChange?: (token: string | null) => void     // Token change callback
}

API Reference

Email/Password Authentication

// Sign up a new user
auth.signUp({ email, password, name? }): Promise<AuthResult>

// Sign in an existing user
auth.signIn({ email, password }): Promise<AuthResult | TwoFactorChallenge>

// Sign out the current user
auth.signOut(): void

// Request password reset email
auth.forgotPassword(email): Promise<void>

// Reset password with token
auth.resetPassword({ token, password }): Promise<void>

OAuth Authentication

// Get available OAuth providers
auth.getProviders(): Promise<string[]>

// Start OAuth flow (redirects browser)
auth.beginOAuth(provider, redirectUri?): void

// Handle OAuth callback (call on redirect page)
auth.handleOAuthCallback(): AuthResult

Two-Factor Authentication

// Enable 2FA for current user
auth.enable2FA(): Promise<TwoFactorSetup>

// Verify and activate 2FA
auth.verify2FA(code): Promise<void>

// Disable 2FA
auth.disable2FA(code): Promise<void>

// Complete login with 2FA code
auth.verifyLoginCode(challengeToken, code): Promise<AuthResult>

// Complete login with backup code
auth.verifyBackupCode(challengeToken, code): Promise<AuthResult>

// Regenerate backup codes
auth.regenerateBackupCodes(code): Promise<string[]>

Passkey (WebAuthn) Authentication

// Check if passkeys are supported
auth.isPasskeySupported(): boolean

// Register a new passkey (requires authentication)
auth.registerPasskey(name?): Promise<void>

// List user's passkeys (requires authentication)
auth.listPasskeys(): Promise<Passkey[]>

// Delete a passkey (requires authentication)
auth.deletePasskey(id): Promise<void>

// Start passkey authentication (requires challengeToken from sign-in)
auth.beginPasskeyAuth(challengeToken): Promise<PasskeyChallenge>

// Complete passkey authentication
auth.completePasskeyAuth(challenge): Promise<AuthResult>

Token Management

// Get current JWT token
auth.getToken(): string | null

// Get current user (decoded from token)
auth.getUser(): User | null

// Check if user is authenticated
auth.isAuthenticated(): boolean

// Subscribe to auth state changes (returns unsubscribe function)
auth.onAuthStateChange(callback): () => void

Types

interface AuthResult {
  token: string
  user: User
}

interface User {
  id: string
  email: string
  name: string
  emailVerified: boolean
  provider: string
}

interface TwoFactorChallenge {
  twoFactorRequired: true
  challengeToken: string
}

interface TwoFactorSetup {
  secret: string
  qrCodeUrl: string
  backupCodes: string[]
}

interface PasskeyChallenge {
  challengeToken: string
  options: PublicKeyCredentialRequestOptions
}

interface Passkey {
  id: string
  name: string
  createdAt: string
}

Error Handling

The SDK throws typed errors for different failure scenarios:

import {
  LaunchpadError,
  AuthenticationError,
  ValidationError,
  NetworkError
} from '@eleven-am/launchpad-auth'

try {
  await auth.signIn({ email, password })
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log('Invalid credentials')
  } else if (error instanceof ValidationError) {
    console.log('Invalid input:', error.message)
  } else if (error instanceof NetworkError) {
    console.log('Network error:', error.message)
  }
}

Custom Storage

Implement the TokenStorage interface for custom storage solutions:

interface TokenStorage {
  get(): string | null
  set(token: string): void
  remove(): void
}

// Example: Cookie storage
const cookieStorage: TokenStorage = {
  get: () => document.cookie.match(/token=([^;]+)/)?.[1] ?? null,
  set: (token) => { document.cookie = `token=${token}; path=/` },
  remove: () => { document.cookie = 'token=; expires=Thu, 01 Jan 1970' }
}

const auth = new LaunchpadAuth({
  baseUrl: 'https://auth.myapp.com',
  storage: cookieStorage
})

Auth State Subscription

Subscribe to authentication state changes:

const unsubscribe = auth.onAuthStateChange((user) => {
  if (user) {
    console.log('User logged in:', user.email)
  } else {
    console.log('User logged out')
  }
})

// Later, to stop listening
unsubscribe()

License

MIT