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

@auth-gate/core

v0.6.0

Published

Core client library for [AuthGate](https://authgate.dev) — the OAuth proxy that handles provider configuration, token exchange, and user normalization so you don't have to.

Readme

@auth-gate/core

Core client library for AuthGate — the OAuth proxy that handles provider configuration, token exchange, and user normalization so you don't have to.

Installation

npm install @auth-gate/core

Setup

import { createAuthGateClient } from "@auth-gate/core";

const client = createAuthGateClient({
  apiKey: process.env.AUTHGATE_API_KEY!,
  baseUrl: "https://authgate.dev", // or your self-hosted instance
});

Features

OAuth Authentication

Supports Google, GitHub, Discord, Azure (Microsoft), and Apple.

// Generate the authorization URL (async — resolves project ID from API key)
const url = await client.getOAuthUrl("google", "https://yourapp.com/auth/callback");

// After callback, verify the JWT token from AuthGate
const result = await client.verifyToken(token);
if (result.valid) {
  console.log(result.user); // { id, email, name, picture, provider }
}

Session Encryption

Sessions are encrypted with AES-256-GCM using keys derived via HKDF-SHA256.

// Encrypt a user into a session cookie value
const cookieValue = await client.encryptSession(user);

// Decrypt a session cookie back to a user
const user = await client.decryptSession(cookieValue);

// Get full payload with timestamps
const payload = await client.decryptSessionPayload(cookieValue);
// { user, iat, exp }

CSRF / OAuth State

// Before redirect: create state + nonce
const { state, nonce } = await client.createState();
// Store nonce in a cookie, pass state in the OAuth URL

// After callback: verify state against nonce
const valid = await client.verifyState(state, nonce);

Email Authentication

// Sign up
await client.emailSignup({ email, password, name });

// Sign in
const result = await client.emailSignin({ email, password });

// Verify email with OTP code
await client.emailVerifyCode({ email, code });

// Password reset
await client.emailForgotPassword({ email });
await client.emailResetPassword({ token, password });

// Magic link
await client.magicLinkSend({ email, callbackUrl });

SMS Authentication

// Send verification code
await client.smsSendCode({ phone }); // E.164 format: +15551234567

// Verify code
const result = await client.smsVerifyCode({ phone, code });

Multi-Factor Authentication (MFA)

// TOTP setup
const setup = await client.mfaTotpSetup(jwt);
// { secret, qr_code, uri }

// Verify TOTP setup
await client.mfaTotpVerifySetup(jwt, { code });

// Complete MFA challenge during sign-in
const result = await client.mfaVerify({ mfa_challenge, code, method: "totp" });

// SMS-based MFA
await client.mfaSmsSendCode({ mfa_challenge });
await client.mfaVerify({ mfa_challenge, code, method: "sms" });

// Backup codes
const codes = await client.mfaBackupCodesGenerate(jwt);

Session Management

// Refresh an expired token
const result = await client.refreshToken(refreshToken);

// Revoke a session
await client.revokeSession(refreshToken);

Cookie Helpers

client.cookieName;              // "__authgate"
client.nonceCookieName;         // "__authgate_nonce"
client.refreshTokenCookieName;  // "__authgate_refresh"
client.sessionMaxAge;           // 604800 (7 days)

client.getSessionCookieOptions();
// { httpOnly: true, secure: true, sameSite: "lax", maxAge: 604800, path: "/" }

client.getNonceCookieOptions();
// { httpOnly: true, secure: true, sameSite: "lax", maxAge: 600, path: "/" }

Configuration

| Option | Type | Required | Description | |--------|------|----------|-------------| | apiKey | string | Yes | Your AuthGate API key (also used to resolve project ID) | | baseUrl | string | Yes | AuthGate instance URL | | cookieName | string | No | Session cookie name (default: __authgate) | | sessionMaxAge | number | No | Session TTL in seconds (default: 604800 / 7 days) | | callbackPath | string | No | OAuth callback path (default: /api/auth/callback) |

Types

import type {
  AuthGateUser,
  AuthGateConfig,
  OAuthProvider,
  TokenVerifyResult,
  SessionPayload,
  CookieOptions,
  MfaChallengeResponse,
  MfaStatus,
  TotpSetupResponse,
  BackupCodesResponse,
} from "@auth-gate/core";

AuthGateUser

interface AuthGateUser {
  id: string;
  email: string;
  phone?: string;
  name?: string;
  picture?: string;
  provider: string;
}

OAuthProvider

type OAuthProvider = "google" | "github" | "discord" | "azure" | "apple";

Error Handling

import {
  AuthGateError,
  TokenVerificationError,
  SessionDecryptionError,
  InvalidStateError,
} from "@auth-gate/core";

Framework SDKs

For framework-specific integrations with built-in route handlers, session helpers, and middleware:

License

MIT