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

@genation/sdk-server

v0.4.2

Published

OAuth 2.1 client for Node.js server environments. Uses confidential client flow with `client_secret`.

Readme

@genation/sdk-server

OAuth 2.1 client for Node.js server environments. Uses confidential client flow with client_secret.

Installation

npm install @genation/sdk-server

Requirements

  • Node.js 18+
  • Express.js (or compatible framework)

Quick Start

import { createConfidentialClient } from "@genation/sdk-server";

const client = createConfidentialClient({
    clientId: "your-client-id",
    clientSecret: "your-client-secret", // Server-side only!
    redirectUri: "http://localhost:3000/callback",
});

// Generate login URL
const { url, codeVerifier, state } = await client.signIn();
res.redirect(url);

// Handle callback
const tokens = await client.handleCallback(code, codeVerifier);
res.cookie("session", tokens.accessToken, { httpOnly: true, secure: true });

// Verify session from cookie
const session = await client.getSession(req.headers.cookie);

Configuration

createConfidentialClient({
    clientId: string;         // Required — your OAuth client ID
    clientSecret: string;     // Required — server-side only
    redirectUri: string;      // Required — callback URL
    scopes?: string[];        // Optional — default: []
    authUrl?: string;         // Optional — default: Genation Auth
    storage?: "cookie" | "memory"; // Default: "cookie"
    cookieOptions?: CookieOptions;
    ffApiUrl?: string;        // Optional — for license API
});

Auth Middleware

Express middleware for protecting routes:

import { createAuthMiddleware } from "@genation/sdk-server/middleware";

const { handler, getSession } = createAuthMiddleware({
    client,
    cookieName: "session",
});

app.use("/api/protected", handler);

app.get("/api/me", handler, async (req, res) => {
    const session = getSession(req);
    res.json(session?.user);
});

Middleware Options

createAuthMiddleware({
    client: ConfidentialClient;    // Required
    cookieName?: string;             // Default: "session"
    cookieOptions?: CookieOptions;   // Custom cookie settings
    optional?: boolean;              // Allow unauthenticated requests
    onUnauthenticated?: (req, res) => void; // Custom handler
});

API Reference

client.signIn()

Generates authorization URL with PKCE.

const { url, codeVerifier, state } = await client.signIn();
res.redirect(url);

client.handleCallback(code, codeVerifier)

Exchanges authorization code for tokens.

const tokens = await client.handleCallback(code, codeVerifier);

client.getSession(cookieHeader)

Verifies and returns session from cookie.

const session = await client.getSession(req.headers.cookie);

client.signOut(cookieHeader)

Revokes tokens and clears session.

await client.signOut(req.headers.cookie);

client.getLicenses()

Fetches licenses for the authenticated user.

const licenses = await client.getLicenses(cookieHeader);

Cookie Options

interface CookieOptions {
    name?: string;       // Cookie name
    httpOnly?: boolean;   // Default: true
    secure?: boolean;     // Default: true in production
    sameSite?: "strict" | "lax" | "none";
    maxAge?: number;      // Seconds
    path?: string;        // Default: "/"
    domain?: string;
}

Session Object

interface Session {
    accessToken: string;
    refreshToken?: string;
    expiresIn: number;
    expiresAt: number;
    user: User | null;
}

Security

  • client_secret is never exposed to the browser
  • Tokens stored in httpOnly cookies
  • PKCE + state parameter for CSRF protection
  • Automatic token refresh

License

MIT