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

@scharfcsh/easyauth

v1.0.3

Published

Simplified Multi-Provider Authentication for Node.js Applications

Readme

@scharfcsh/easyauth

A lightweight, plug-and-play authentication library for Node.js that gives you Google, GitHub, Facebook, and Firebase authentication with minimal setup — no complex OAuth boilerplate, no SDK hell, no endless copy-paste.

It exposes clean provider functions that:

  • Generate login URLs,
  • Exchange auth codes for access tokens,
  • Return normalized user objects.

No CLI setup, no file generation — just install and use.


🚀 Installation

npm install @scharfcsh/easyauth

🧩 Supported Providers

  • Google
  • GitHub
  • Facebook
  • Firebase (Email/Password / Token login — depends on your implementation)

All providers expose the same interface:

{
  authURL: string;
  getAccessToken(code): Promise<{ access_token: string }>;
  getUser(token): Promise<NormalizedUser>;
}

NormalizedUser looks like:

{
  id: string;
  name: string;
  email: string;
  avatar?: string;
  provider: "google" | "github" | "facebook" | "firebase";
}

📦 Basic Usage Example (Node.js)

  1. Import the provider you need
import { createGoogleAuth } from "@scharfcsh/easyauth/google";
  1. Configure it
const google = createGoogleAuth({
  clientId: process.env.GOOGLE_ID!,
  clientSecret: process.env.GOOGLE_SECRET!,
  redirectURI: process.env.GOOGLE_REDIRECT!,
});
  1. Redirect user to login
console.log("Login:", google.authURL);
  1. Handle OAuth callback
const token = await google.getAccessToken(code);
const user = await google.getUser(token.access_token);

console.log(user);

🌍 Full Express Example (GitHub + Facebook)

A complete “real world” example:

import express from "express";
import dotenv from "dotenv";

dotenv.config();

import { createGitHubAuth } from "@scharfcsh/easyauth/github";
import { createFacebookAuth } from "@scharfcsh/easyauth/facebook";

const app = express();
const PORT = 3000;

// --- GitHub Config ---
const github = createGitHubAuth({
  clientId: process.env.GITHUB_ID!,
  clientSecret: process.env.GITHUB_SECRET!,
  redirectURI: process.env.GITHUB_REDIRECT!,
});

// GitHub login
app.get("/auth/github", (_, res) => {
  res.redirect(github.authURL);
});

app.get("/auth/github/callback", async (req, res) => {
  const code = req.query.code as string;

  try {
    const token = await github.getAccessToken(code);
    const user = await github.getUser(token.access_token);

    res.send(`GitHub Login Success → ${user.name} (${user.email})`);
  } catch (err) {
    res.status(500).send("GitHub Authentication Failed");
  }
});

// --- Facebook Config ---
const facebook = createFacebookAuth({
  clientId: process.env.FACEBOOK_ID!,
  clientSecret: process.env.FACEBOOK_SECRET!,
  redirectURI: process.env.FACEBOOK_REDIRECT!,
});

// Facebook login
app.get("/auth/facebook", (_, res) => {
  res.redirect(facebook.authURL);
});

app.get("/auth/facebook/callback", async (req, res) => {
  const code = req.query.code as string;

  try {
    const token = await facebook.getAccessToken(code);
    const user = await facebook.getUser(token.access_token);

    res.send(`Facebook Login Success → ${user.name} (${user.email})`);
  } catch (err) {
    res.status(500).send("Facebook Authentication Failed");
  }
});

app.listen(PORT, () => {
  console.log(`Server running: http://localhost:${PORT}`);
  console.log("GitHub Login → http://localhost:3000/auth/github");
  console.log("Facebook Login → http://localhost:3000/auth/facebook");
});

🔧 Environment Variables Required

Create a .env manually:

# Google
GOOGLE_ID=
GOOGLE_SECRET=
GOOGLE_REDIRECT=http://localhost:3000/auth/google/callback

# GitHub
GITHUB_ID=
GITHUB_SECRET=
GITHUB_REDIRECT=http://localhost:3000/auth/github/callback

# Facebook
FACEBOOK_ID=
FACEBOOK_SECRET=
FACEBOOK_REDIRECT=http://localhost:3000/auth/facebook/callback

# Firebase (optional)
FIREBASE_API_KEY=
FIREBASE_AUTH_DOMAIN=

🛠 Adding Your Own Providers

  • Duplicate any provider file
  • Update:
    • login URL
    • token URL
    • scopes
    • profile URL
  • Export create<Provider>Auth

Every provider behaves the same, keeping your code clean and maintainable.


🤝 Contributing

  • Add OAuth providers
  • Improve normalization
  • Submit examples
  • Fix bugs

PRs are welcome.


📄 License

MIT — Use it, modify it, break it, fix it.