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

@nublestation/identity

v0.1.1

Published

NubleStation Identity — SSO auth client

Readme

@nublestation/identity

Auth SDK for NubleStation — user sessions, single sign-on, and per-app authorization for browser apps.

npm install @nublestation/identity

How auth works

NubleStation runs one Identity service for the whole organization. Every app shares the same sign-in session through a cookie scoped to *.{org}.local, so a user signs in once and is recognized across every app on the network — that's the SSO.

Because it rides the shared session cookie, this SDK takes no API key (unlike @nublestation/vault). It needs to know only where the Gateway and Identity pages live, plus your app's slug.

Quick start

import { createIdentityClient } from "@nublestation/identity";

const identity = createIdentityClient({
  url:         "http://api.clinic.local",       // Gateway
  identityUrl: "http://identity.clinic.local",  // Identity sign-in pages
  app:         "bucket",                         // your app's slug (from Console)
});

const session = await identity.getSession();
if (session.status === "unauthenticated") {
  identity.login();           // redirect to SSO sign-in
} else if (session.status === "forbidden") {
  // signed in, but no access to this app
} else {
  console.log("Hello", session.user.email);
}

Authorization model

Access is per-app and default-deny: a valid session does not imply access to your app. An admin grants a user a role on the app in the Console (or the user is an org admin, who can access everything). getSession() distinguishes the two cases so you can show the right screen.

API

createIdentityClient(config) returns:

| Method | Returns | Description | |---|---|---| | getUser() | Promise<IdentityUser \| null> | The signed-in user, regardless of app access. | | getSession() | Promise<SessionState> | Full session + app-access state (see below). | | isAuthenticated() | Promise<boolean> | True if a valid session exists (ignores app access). | | hasAccess(role?) | Promise<boolean> | True if signed in and allowed on this app (optionally requiring a role). | | requireUser(opts?) | Promise<IdentityUser> | Route guard — resolves with the user when signed in and allowed; redirects otherwise. | | listAppUsers() | Promise<AppUser[]> | Users you can share with in this app. | | loginUrl(redirectUri?) | string | The SSO sign-in URL for this app. | | login(redirectUri?) | void | Navigate to the SSO sign-in. | | logout(redirectTo?) | Promise<void> | Revoke the session server-side, then navigate. |

Config

interface IdentityConfig {
  url: string;         // Gateway base URL, e.g. http://api.clinic.local
  identityUrl: string; // Identity pages base URL, e.g. http://identity.clinic.local
  app: string;         // this app's slug (from the Console), e.g. "bucket"
}

Types

interface IdentityUser {
  id: string;
  email: string;
  displayName: string | null;
  avatarUrl: string | null;
  role: string | null;
}

type SessionState =
  | { status: "authenticated"; user: IdentityUser }   // signed in + has access
  | { status: "forbidden";     user: IdentityUser }   // signed in, no app access
  | { status: "unauthenticated" };                    // not signed in

interface AppUser {
  id: string;
  email: string;
  displayName: string | null;
  avatarUrl: string | null;
  role: string;
}

React integration

A minimal hook over getSession():

import { useEffect, useState } from "react";
import { createIdentityClient } from "@nublestation/identity";
import type { IdentityUser } from "@nublestation/identity";

export const identity = createIdentityClient({
  url:         import.meta.env.VITE_NUBLESTATION_URL,
  identityUrl: import.meta.env.VITE_NUBLESTATION_IDENTITY_URL,
  app:         import.meta.env.VITE_NUBLESTATION_APP,
});

type Status = "loading" | "authenticated" | "forbidden" | "unauthenticated";

export function useIdentity() {
  const [status, setStatus] = useState<Status>("loading");
  const [user, setUser] = useState<IdentityUser | null>(null);

  useEffect(() => {
    identity.getSession().then((s) => {
      if (s.status === "unauthenticated") setStatus("unauthenticated");
      else { setStatus(s.status); setUser(s.user); }
    });
  }, []);

  return {
    status,
    user,
    login:  () => identity.login(),
    logout: () => void identity.logout(),
  };
}

Render a sign-in prompt when unauthenticated, a "no access" screen when forbidden, and your app when authenticated.

Error handling

import { IdentityError } from "@nublestation/identity";

try {
  await identity.listAppUsers();
} catch (err) {
  if (err instanceof IdentityError) console.error(err.status, err.code);
}

License

MIT