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

functions-auth

v1.0.2

Published

FunctionsAuth JavaScript/TypeScript SDK — Passwordless Passkeys, Device Fingerprinting & Adaptive Risk Authentication

Readme

🔐 functions-auth


🌟 Why FunctionsAuth?

  • 🔑 FIDO2 WebAuthn Passkeys: Native biometrics (TouchID, FaceID, YubiKey) built-in.
  • 🎨 Pre-Built UI Components: Glassmorphic dark theme authentication widget embeddable in 1 line of code.
  • 🔍 Device Fingerprinting: 10-signal SHA-256 canvas & WebGL trust verification.
  • Risk-Adaptive Security: 8-rule threat engine calculating real-time risk scores (0–100).
  • 🔒 Token Binding & RTR: Automatic Token Rotation (RTR) 60 seconds before JWT expiry.
  • 📦 Framework Agnostic: Native support for React, Next.js, Vue, Svelte, and Vanilla JS.

📦 Quick Installation

Install via your preferred package manager:

# npm
npm install functions-auth

# pnpm
pnpm add functions-auth

# yarn
yarn add functions-auth

🎨 Drop-In Authentication UI Component

functions-auth includes a pre-styled, fully customizable authentication component out-of-the-box.

⚛️ 1. React & Next.js Integration

import { useEffect, useRef } from 'react';
import { FunctionsAuth, renderAuthWidget } from 'functions-auth';

const auth = new FunctionsAuth({
  clientId: 'fa_client_prod_12345678',
  baseUrl: 'http://localhost:8080',
});

export default function AuthPage() {
  const containerRef = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (!containerRef.current) return;

    // Mount drop-in authentication component
    const widget = renderAuthWidget(containerRef.current, {
      auth,
      mode: 'login', // 'login' | 'signup'
      accentColor: '#6366f1',
      socialProviders: ['google', 'github'],
      onSuccess: (session) => {
        console.log('Logged in successfully!', session.user);
        window.location.href = '/dashboard';
      },
      onError: (error) => {
        console.error('Auth failure:', error.message);
      },
    });

    return () => widget.destroy();
  }, []);

  return (
    <div className="min-h-screen flex items-center justify-center bg-zinc-950 p-6">
      <div ref={containerRef} className="w-full max-w-md" />
    </div>
  );
}

🌐 2. Vanilla JS & HTML CDN Integration

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Sign In – FunctionsAuth</title>
</head>
<body style="background: #090d16; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0;">

  <!-- Widget Target Container -->
  <div id="auth-widget"></div>

  <script type="module">
    import { FunctionsAuth, renderAuthWidget } from 'https://esm.run/functions-auth';

    const auth = new FunctionsAuth({
      clientId: 'fa_client_prod_12345678'
    });

    renderAuthWidget(document.getElementById('auth-widget'), {
      auth,
      socialProviders: ['google', 'github'],
      onSuccess: (session) => {
        alert('Welcome back, ' + session.user.email);
        window.location.href = '/dashboard';
      }
    });
  </script>
</body>
</html>

⚡ Programmatic Core API Usage

If you prefer building a custom UI, call the SDK methods directly:

import { FunctionsAuth } from 'functions-auth';

// 1. Initialize SDK Instance
const auth = new FunctionsAuth({
  clientId: 'fa_client_prod_12345678',
  baseUrl: 'http://localhost:8080',
  autoRefresh: true, // Automatically rotates tokens 60s before expiry
});

// 2. Register New User
await auth.signup({
  username: 'santosh_dev',
  email: '[email protected]',
  password: 'SuperSecurePassword123!',
  tenantId: 'default'
});

// 3. Log In with Email & Password
const session = await auth.login({
  usernameOrEmail: '[email protected]',
  password: 'SuperSecurePassword123!',
});

// 4. Retrieve Active Credentials
console.log('JWT Access Token:', auth.getToken());
console.log('Active User Profile:', auth.getUser());

// 5. Revoke Session & Logout
await auth.logout();

🛠️ API Reference & Methods

| Method | Description | Return Type | |---|---|---| | login(options) | Authenticates user & establishes session | Promise<AuthSession> | | signup(options) | Registers new tenant user | Promise<AuthSession> | | logout() | Clears local tokens & revokes active session | Promise<void> | | verify() | Validates current session with backend | Promise<{ valid: boolean }> | | refresh() | Rotates refresh token manually | Promise<AuthSession> | | getUser() | Returns current active user object | User \| null | | getToken() | Returns active JWT bearer access token | string \| null | | silentLogin() | Checks validity or auto-refreshes on load | Promise<AuthSession \| null> |


🔒 Session Security Architecture

sequenceDiagram
    participant App as Client Web App
    participant SDK as FunctionsAuth SDK
    participant API as Backend Auth Service
    participant DB as PostgreSQL Ledger

    App->>SDK: Initialize(clientId)
    App->>SDK: login(email, password)
    SDK->>API: POST /api/v1/auth/login
    API->>DB: Verify credentials & generate session
    DB-->>API: Tokens (AccessToken, RefreshToken)
    API-->>SDK: 200 OK + AuthSession
    SDK->>SDK: Store encrypted tokens
    SDK-->>App: Return User session

    Note over App,API: Automatic Token Rotation (RTR)
    SDK->>API: Auto-refresh 60s before expiry
    API->>DB: Invalidate old refresh token
    DB-->>API: Issue new token pair
    API-->>SDK: Rotate new RefreshToken

👤 Author & Maintainer

Created and maintained by Santosh Patel.


📝 License

Distributed under the MIT License. See LICENSE for details.