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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@skhashaev/steam-login

v1.0.0

Published

A lightweight library for Steam OpenID authentication, with adapter for Supabase Edge Functions.

Downloads

171

Readme

@skhashaev/steam-login

A lightweight TypeScript library for Steam OpenID authentication with adapters for different platforms.

Features

  • 🔐 Simple Steam OpenID 2.0 authentication
  • 🎯 Platform-specific adapters (Supabase Edge Functions, and more coming soon, if will be needed)
  • 📦 TypeScript support with full type definitions
  • 🚀 Easy to use API
  • ✨ No dependencies on the core library

Installation

For Deno (Supabase Edge Functions)

import { SupabaseSteamAuth } from "npm:@skhashaev/steam-login";

For Node.js

npm install @skhashaev/steam-login

Try the Demo

Want to see it in action? Clone the repository and run the demo:

git clone https://github.com/skhashaev/steam-login.git
cd steam-login
npm install
npm run demo

This will start a local server at http://localhost:3000 with a working Steam login example.

Quick Start

Using the Supabase Adapter

import { SupabaseSteamAuth } from "@skhashaev/steam-login";

const steamAuth = new SupabaseSteamAuth({
  realm: "https://your-site.com",
  returnUrl: "https://your-site.com/auth/callback",
});

// Handle the request automatically
const result = await steamAuth.handleRequest(req);

switch (result.type) {
  case "redirect":
    return result.response; // Redirects to Steam
  case "success":
    console.log(result.steamId); // User's Steam ID
    break;
  case "error":
    console.error(result.error);
    break;
}

Using the Core Library

import { SteamAuth } from "@skhashaev/steam-login";

const steamAuth = new SteamAuth({
  realm: "https://your-site.com",
  returnUrl: "https://your-site.com/auth/callback",
});

// Get the redirect URL
const redirectUrl = steamAuth.getRedirectUrl();

// Verify the callback
const steamId = await steamAuth.verify(requestUrl);

Platform Adapters

This library includes adapters for different platforms (currently only one) to make integration easier:

More adapters coming soon! Contributions are welcome.

How It Works

This library implements the Steam OpenID 2.0 authentication flow:

  1. Redirect: User is redirected to Steam's login page
  2. Authentication: User logs in with their Steam account
  3. Callback: Steam redirects back to your site with authentication data
  4. Verification: The library verifies the response with Steam's servers
  5. Result: You receive the user's 64-bit Steam ID

Getting User Profile Data

The Steam ID alone doesn't contain profile information. To get the user's profile (avatar, name, etc.), you need to use the Steam Web API.

Using the Steam Web API directly

const STEAM_API_KEY = "your-api-key"; // Get from https://steamcommunity.com/dev/apikey

async function getUserProfile(steamId: string) {
  const response = await fetch(
    `http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${STEAM_API_KEY}&steamids=${steamId}`
  );
  const data = await response.json();
  return data.response.players[0];
}

Using steamapi-ts (Recommended)

For a better developer experience with full TypeScript support and auto-generated types for all Steam Web API endpoints, check out my other library @skhashaev/steamapi-ts:

npm install @skhashaev/steamapi-ts
import { createSteamClient } from "@skhashaev/steamapi-ts";
import "dotenv/config";

const steam = createSteamClient(process.env.API_KEY!);

async function getUserProfile(steamId: string) {
  // Call API methods with full type safety
  const response = await steam.ISteamUser.GetPlayerSummaries_v2({
    steamids: steamId,
  });
  const data = await response.json();
  return data.response.players[0];
}

API Reference

SteamAuth

Core class for Steam OpenID authentication.

Constructor Options

interface SteamAuthOptions {
  realm: string; // Your site's base URL
  returnUrl: string; // Where Steam redirects after login
}

Methods

  • getRedirectUrl(): string - Returns the Steam login URL
  • verify(requestUrl: string): Promise<string | null> - Verifies the callback and returns the Steam ID

SupabaseSteamAuth

Adapter for Supabase Edge Functions.

Methods

  • redirect(): Response - Returns a redirect Response to Steam
  • verify(request: Request): Promise<string | null> - Verifies the callback
  • handleRequest(request: Request): Promise<SteamAuthResult> - Automatically handles both redirect and verification

Contributing

Contributions are welcome! Feel free to:

  • Add new platform adapters
  • Report bugs
  • Suggest features
  • Improve documentation

License

ISC

Resources