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

@notoofly/auth-client

v1.0.2

Published

Notoofly Authentication Client - Complete auth solution for frontend applications

Readme

Notoofly Auth Client TypeScript

A TypeScript client for Notoofly authentication API with automatic token management and MFA support.

Installation

npm install @notoofly/auth-client

Quick Start

import NotooflyAuthClient from '@notoofly/auth-client';

// Initialize the client
const authClient = new NotooflyAuthClient({
  authUrl: 'https://your-auth-api.com',
  jwksUrl: 'https://your-auth-api.com/.well-known/jwks.json',
  issuer: 'https://your-auth-api.com',
  audience: 'your-app-id',
  namespace: 'my-app' // Optional: for token isolation
});

// Sign up a new user
const signUpResult = await authClient.signUp({
  email: '[email protected]',
  password: 'securePassword123',
  confirmPassword: 'securePassword123'
});

if (signUpResult.success) {
  console.log('Sign up successful!');
  
  // Check if OTP is required
  if (signUpResult.requiresOtp) {
    // Send OTP
    const otpResult = await authClient.sendOtp();
    if (otpResult.success) {
      // Verify OTP
      const verifyResult = await authClient.verifyOtp({ otp: '123456' });
      if (verifyResult.success) {
        console.log('Account verified!');
      }
    }
  }
}

Authentication Flow

Basic Sign In

const signInResult = await authClient.signIn({
  email: '[email protected]',
  password: 'securePassword123'
});

if (signInResult.success) {
  if (signInResult.requiresOtp) {
    // Handle OTP verification
    const otpResult = await authClient.sendOtp();
    // ... verify OTP
  } else if (signInResult.requiresTotp) {
    // Handle TOTP verification
    console.log('TOTP required');
  } else {
    console.log('Signed in successfully!');
  }
}

Check Authentication Status

if (authClient.isAuthenticated()) {
  console.log('User is authenticated');
  
  // Get user profile
  const profileResult = await authClient.getProfile();
  if (profileResult.success && profileResult.profile) {
    console.log('User profile:', profileResult.profile);
  }
}

Token Management

// Get current tokens
const accessToken = authClient.getAccessToken();
const preAuthToken = authClient.getPreAuthToken();

// Manually set tokens (if needed)
authClient.setAccessToken('your-access-token', 3600000); // 1 hour TTL
authClient.setPreAuthToken('your-pre-auth-token');

// Clear all tokens
authClient.clearTokens();

// Clean up expired tokens
const cleanedCount = authClient.cleanupExpiredTokens();

// Get token statistics
const stats = authClient.getTokenStats();
console.log('Token stats:', stats);

Making Authenticated Requests

// Generic authenticated request
const response = await authClient.authenticatedRequest<any>('/api/protected-data', {
  method: 'GET'
});

if (response.success) {
  console.log('Protected data:', response.data);
}

OTP Management

// Get OTP status
const statusResult = await authClient.getOtpStatus();
if (statusResult.success) {
  console.log('OTP status:', statusResult.data);
}

// Enable/disable OTP
const toggleResult = await authClient.toggleOtp(true); // Enable OTP
if (toggleResult.success) {
  console.log('OTP enabled');
}

API Reference

Constructor Options

interface NotooflyAuthClientOptions {
  authUrl: string;        // Base URL for auth API
  jwksUrl: string;        // JWKS endpoint for token verification
  issuer: string;         // Token issuer
  audience: string;       // Expected audience
  namespace?: string;     // Optional namespace for token isolation
}

AuthResult Interface

All authentication methods return an AuthResult:

interface AuthResult {
  success: boolean;        // Whether the operation succeeded
  data?: AuthResponseData; // Response data from the API
  error?: string;         // Error message if failed
  requiresOtp?: boolean;   // Whether OTP verification is required
  requiresTotp?: boolean;  // Whether TOTP verification is required
  preAuthToken?: string;   // Pre-authentication token
  accessToken?: string;    // Access token
}

Key Methods

Authentication

  • signUp(data: SignupRequest): Promise<AuthResult>
  • signIn(credentials: SigninRequest): Promise<AuthResult>
  • verifyAccount(data: VerifyAccountRequest): Promise<AuthResult>
  • logout(): Promise<AuthResult>

OTP/MFA

  • sendOtp(): Promise<AuthResult>
  • verifyOtp(otpData: OtpRequest): Promise<AuthResult>
  • getOtpStatus(): Promise<AuthResult>
  • toggleOtp(enable: boolean): Promise<AuthResult>

Token Management

  • refreshToken(): Promise<AuthResult>
  • getAccessToken(): string | null
  • getPreAuthToken(): string | null
  • setAccessToken(token: string, ttl?: number): void
  • setPreAuthToken(token: string, ttl?: number): void
  • clearTokens(): void
  • isAuthenticated(): boolean

User Data

  • getProfile(): Promise<AuthResult & { profile?: UserProfile }>
  • authenticatedRequest<T>(endpoint: string, options?: RequestInit): Promise<AuthResult & { data?: T }>

Development

To install dependencies:

bun install

To run:

bun run index.ts

License

MIT License – see LICENSE file for details.