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

@callowayisweird/steam-auth

v0.1.0

Published

Zero-dependency, framework-agnostic Steam OpenID 2.0 authentication. Secure by default.

Downloads

113

Readme

@callowayisweird/steam-auth

Zero-dependency, framework-agnostic Steam OpenID 2.0 authentication. Secure by default.

Install

npm install @callowayisweird/steam-auth

Quick Start

Hono

import { Hono } from "hono";
import { SteamAuth } from "@callowayisweird/steam-auth";

const steam = new SteamAuth({
  realm: "https://yoursite.com",
  returnUrl: "https://yoursite.com/auth/callback",
});

const app = new Hono();

app.get("/auth/login", (c) => {
  return c.redirect(steam.getRedirectUrl());
});

app.get("/auth/callback", async (c) => {
  const steamId = await steam.verify(new URL(c.req.url).searchParams);
  const profile = await steam.getProfile(steamId);
  return c.json(profile);
});

Express

import express from "express";
import { SteamAuth } from "@callowayisweird/steam-auth";

const steam = new SteamAuth({
  realm: "https://yoursite.com",
  returnUrl: "https://yoursite.com/auth/callback",
});

const app = express();

app.get("/auth/login", (req, res) => {
  res.redirect(steam.getRedirectUrl());
});

app.get("/auth/callback", async (req, res) => {
  const steamId = await steam.verify(req.query as Record<string, string>);
  const profile = await steam.getProfile(steamId);
  res.json(profile);
});

Fastify

import Fastify from "fastify";
import { SteamAuth } from "@callowayisweird/steam-auth";

const steam = new SteamAuth({
  realm: "https://yoursite.com",
  returnUrl: "https://yoursite.com/auth/callback",
});

const app = Fastify();

app.get("/auth/login", async (req, reply) => {
  return reply.redirect(steam.getRedirectUrl());
});

app.get("/auth/callback", async (req, reply) => {
  const steamId = await steam.verify(req.query as Record<string, string>);
  const profile = await steam.getProfile(steamId);
  return profile;
});

Security

This library fixes the passport-steam authentication bypass vulnerability and performs 6 security checks on every callback:

  1. Mode validation -- Ensures openid.mode is id_res
  2. Return URL verification -- Validates openid.return_to matches your configured returnUrl exactly. This is the check that passport-steam skipped, allowing attackers to forge authentication responses.
  3. Endpoint validation -- Confirms openid.op_endpoint is the real Steam endpoint (https://steamcommunity.com/openid/login)
  4. Claimed ID format check -- Validates openid.claimed_id matches the expected Steam URL pattern
  5. Replay protection -- Tracks nonces to prevent replay attacks. Nonces are automatically cleaned up after 5 minutes.
  6. Server-side verification -- POSTs back to Steam's check_authentication endpoint to confirm the assertion is genuine

API Reference

new SteamAuth(options)

| Option | Type | Description | | ----------- | ---------- | ------------------------------------------------- | | realm | string | Your site URL, e.g. "https://yoursite.com" | | returnUrl | string | Callback URL, e.g. "https://yoursite.com/auth/callback" | | fetch | function | Optional custom fetch implementation for testing |

steam.getRedirectUrl(): string

Returns the Steam OpenID login URL. Redirect the user here.

steam.verify(query): Promise<string>

Verifies the OpenID callback and returns the user's SteamID64. Accepts either a Record<string, string> or URLSearchParams.

Throws one of the typed errors below on failure.

steam.getProfile(steamId): Promise<SteamProfile>

Fetches the user's public Steam profile (no API key required). Returns:

interface SteamProfile {
  steamId: string;
  name: string;
  avatarUrl: string;      // 64x64
  avatarMedium: string;   // 184x184
  avatarFull: string;     // Full size
  profileUrl: string;
  personaState: number;   // 0=offline, 1=online, etc.
}

steam.destroy(): void

Stops the nonce cleanup interval and clears stored nonces. Call this when shutting down.

Error Handling

All errors extend SteamAuthError and have a code property for programmatic handling:

import {
  SteamAuth,
  VerificationError,
  ReturnUrlMismatchError,
  SteamUnavailableError,
} from "@callowayisweird/steam-auth";

try {
  const steamId = await steam.verify(query);
} catch (err) {
  if (err instanceof ReturnUrlMismatchError) {
    // Possible attack -- return_to was tampered with
  } else if (err instanceof SteamUnavailableError) {
    // Steam is down, retry later
  } else if (err instanceof VerificationError) {
    // Verification failed
  }
}

| Error Class | Code | Description | | ------------------------ | ---------------------- | ------------------------------------------ | | SteamAuthError | (varies) | Base class for all errors | | VerificationError | VERIFICATION_FAILED | Steam's check_authentication returned invalid | | ReturnUrlMismatchError | RETURN_URL_MISMATCH | return_to doesn't match configured returnUrl | | InvalidClaimedIdError | INVALID_CLAIMED_ID | claimed_id doesn't match Steam format | | InvalidEndpointError | INVALID_ENDPOINT | op_endpoint isn't the real Steam endpoint | | ReplayAttackError | REPLAY_ATTACK | Nonce was already used | | SteamUnavailableError | STEAM_UNAVAILABLE | Steam didn't respond or returned non-200 | | ProfileFetchError | PROFILE_FETCH_FAILED | Failed to fetch Steam profile |

License

MIT