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

@metaloot/auth

v0.1.1

Published

Drop-in Metaloot auth adapters for browser games.

Readme

Metaloot Auth

Drop-in Metaloot auth adapters for browser games.

The package owns the OAuth callback and game session so a game does not need to hand-roll code exchange, signed cookies, session JSON, or sign-in UI state.

On HTTPS, auth cookies default to SameSite=None; Secure so games embedded in the Metaloot portal can establish and read their game session inside an iframe. Local HTTP development keeps SameSite=Lax. Override with cookieSameSite or cookieSecure only when your host requires a custom policy.

Install

npm install @metaloot/auth

Environment

METALOOT_CLIENT_ID=mtl_client_...
METALOOT_CLIENT_SECRET=mtl_secret_...
METALOOT_SESSION_SECRET=replace-with-a-long-random-secret

Register this callback URL in Metaloot:

https://your-game.com/auth/metaloot/callback

Static Node or Express Game

import express from "express";
import { metalootAuth } from "@metaloot/auth/node";

const app = express();

app.use(
  metalootAuth({
    clientId: process.env.METALOOT_CLIENT_ID,
    clientSecret: process.env.METALOOT_CLIENT_SECRET,
    sessionSecret: process.env.METALOOT_SESSION_SECRET,
    redirectUri: "https://your-game.com/auth/metaloot/callback",
  })
);

app.use(
  "/vendor/@metaloot/auth",
  express.static("node_modules/@metaloot/auth/dist")
);
app.use(express.static("public"));
app.listen(process.env.PORT || 3000);

Add the button to the game:

<div id="metaloot-auth"></div>
<script type="module">
  import { mountMetalootAuth } from "/vendor/@metaloot/auth/browser.js";

  mountMetalootAuth("#metaloot-auth", {
    gameName: "Your Game"
  });
</script>

The middleware provides:

GET /auth/metaloot/start
GET /auth/metaloot/callback
GET /auth/metaloot/session
GET /auth/metaloot/logout
POST /auth/metaloot/logout

Next.js App Router

Create app/api/auth/metaloot/[...metaloot]/route.ts:

import { createMetalootRouteHandlers } from "@metaloot/auth/next";

export const { GET, POST } = createMetalootRouteHandlers({
  clientId: process.env.METALOOT_CLIENT_ID!,
  clientSecret: process.env.METALOOT_CLIENT_SECRET!,
  sessionSecret: process.env.METALOOT_SESSION_SECRET!,
  redirectUri: "https://your-game.com/auth/metaloot/callback",
  startPath: "/api/auth/metaloot/start",
  callbackPath: "/api/auth/metaloot/callback",
  sessionPath: "/api/auth/metaloot/session",
  logoutPath: "/api/auth/metaloot/logout",
});

Register the matching callback URL for this example:

https://your-game.com/api/auth/metaloot/callback

Mount the browser button from a client component:

"use client";

import { useEffect, useRef } from "react";
import { mountMetalootAuth } from "@metaloot/auth/browser";

export function MetalootSignIn() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (!ref.current) return;
    mountMetalootAuth(ref.current, {
      gameName: "Your Game",
      startUrl: "/api/auth/metaloot/start",
      sessionUrl: "/api/auth/metaloot/session",
      logoutUrl: "/api/auth/metaloot/logout",
    });
  }, []);

  return <div ref={ref} />;
}

Read the Session

Browser code can check the current player:

const session = await fetch("/auth/metaloot/session").then((res) => res.json());

if (session.signedIn) {
  console.log(session.user.id, session.user.name);
}

Server code can read a signed session from cookies:

import { getMetalootSessionFromCookieHeader } from "@metaloot/auth/server";

const session = getMetalootSessionFromCookieHeader(request.headers.get("cookie"), {
  clientId: process.env.METALOOT_CLIENT_ID!,
  clientSecret: process.env.METALOOT_CLIENT_SECRET!,
  sessionSecret: process.env.METALOOT_SESSION_SECRET!,
  redirectUri: "https://your-game.com/auth/metaloot/callback",
});

Agent Prompt

Use this when asking an implementation agent to add Metaloot auth:

Install @metaloot/auth and wire Metaloot sign-in.

Do not implement OAuth by hand.

Requirements:
1. Add the Metaloot server adapter for this stack.
2. Configure METALOOT_CLIENT_ID, METALOOT_CLIENT_SECRET, and METALOOT_SESSION_SECRET on the server only.
3. Use /auth/metaloot/start, /auth/metaloot/callback, /auth/metaloot/session, and /auth/metaloot/logout.
4. Mount the browser sign-in button with mountMetalootAuth.
5. On game boot, call the session endpoint and treat signedIn:true as the player being authenticated.
6. Hide or replace any old guest-login, #mlt token, or vendored Metaloot SDK logic.
7. Verify locally and in production that /auth/metaloot/session returns signedIn:true after login.

Publishing

npm login
npm publish --access public

If the @metaloot npm scope is not available on your account, change the package name in package.json before publishing.