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

@imtbl/auth

v2.19.0

Published

Authentication SDK for Immutable

Readme

@imtbl/auth

Authentication utilities for the Immutable SDK.

Installation

npm install @imtbl/auth

Overview

This package provides two ways to handle Immutable authentication:

  1. Auth Class - Full-featured authentication with session managed on client side.
  2. Standalone Login Functions - Stateless login functions for use with external session managers (e.g., NextAuth)

Standalone Login Functions

For Next.js applications using NextAuth, use the standalone login functions. These handle OAuth flows and return tokens without managing session state.

loginWithPopup

Opens a popup window for authentication and returns tokens when complete.

import { loginWithPopup } from '@imtbl/auth';
import { signIn } from 'next-auth/react';

async function handleLogin() {
  const tokens = await loginWithPopup({
    clientId: process.env.NEXT_PUBLIC_IMMUTABLE_CLIENT_ID!,
    redirectUri: `${window.location.origin}/callback`,
  });
  
  // Sign in to NextAuth with the tokens
  await signIn('immutable', {
    tokens: JSON.stringify(tokens),
    redirect: false,
  });
}

loginWithRedirect

Redirects the page to the authentication provider. Use handleLoginCallback on the callback page.

import { loginWithRedirect } from '@imtbl/auth';

function handleLogin() {
  loginWithRedirect({
    clientId: process.env.NEXT_PUBLIC_IMMUTABLE_CLIENT_ID!,
    redirectUri: `${window.location.origin}/callback`,
  });
}

handleLoginCallback

Handles the OAuth callback and exchanges the authorization code for tokens.

import { handleLoginCallback } from '@imtbl/auth';
import { signIn } from 'next-auth/react';

// In your callback page
async function processCallback() {
  const tokens = await handleLoginCallback({
    clientId: process.env.NEXT_PUBLIC_IMMUTABLE_CLIENT_ID!,
    redirectUri: `${window.location.origin}/callback`,
  });
  
  if (tokens) {
    await signIn('immutable', {
      tokens: JSON.stringify(tokens),
      redirect: false,
    });
    // Redirect to home or dashboard
    window.location.href = '/';
  }
}

LoginConfig

Configuration options for standalone login functions:

interface LoginConfig {
  /** Your Immutable application client ID */
  clientId: string;
  /** The OAuth redirect URI for your application */
  redirectUri: string;
  /** Optional separate redirect URI for popup flows */
  popupRedirectUri?: string;
  /** OAuth audience (default: "platform_api") */
  audience?: string;
  /** OAuth scopes (default: "openid profile email offline_access transact") */
  scope?: string;
  /** Authentication domain (default: "https://auth.immutable.com") */
  authenticationDomain?: string;
}

TokenResponse

The token data returned from successful authentication:

interface TokenResponse {
  /** OAuth access token for API calls */
  accessToken: string;
  /** OAuth refresh token for token renewal */
  refreshToken?: string;
  /** OpenID Connect ID token */
  idToken?: string;
  /** Unix timestamp (ms) when the access token expires */
  accessTokenExpires: number;
  /** User profile information */
  profile: {
    sub: string;
    email?: string;
    nickname?: string;
  };
  /** zkEVM wallet information if available */
  zkEvm?: {
    ethAddress: string;
    userAdminAddress: string;
  };
}

Auth Class

For applications that need full authentication management (like the Passport SDK), use the Auth class:

import { Auth } from '@imtbl/auth';

const auth = new Auth({
  clientId: 'your-client-id',
  redirectUri: 'https://your-app.com/callback',
  scope: 'openid profile email offline_access transact',
});

// Login with popup
const user = await auth.login();

// Get current user
const user = await auth.getUser();

// Logout
await auth.logout();

Integration with NextAuth

For a complete Next.js authentication setup, use this package with:

  • @imtbl/auth-next-server - Server-side NextAuth configuration
  • @imtbl/auth-next-client - Client-side components and hooks

See those packages for full integration documentation.