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

@cemiar/auth-sdk

v1.0.36

Published

Cemiar Auth integration helpers for web apps and APIs.

Readme

@cemiar/auth-sdk

Reusable helpers for integrating Cemiar Auth in web front-ends and Node.js APIs.

This package bundles:

  • A browser-friendly Cemiar Auth client with email codes, Microsoft login support, token storage, refresh and logout helpers
  • Axios utilities to attach automatic Authorization headers and refresh tokens on 401 responses
  • A Hapi JWT strategy helper that fetches Cemiar Auth signing keys from JWKS and validates incoming requests

Installation

npm install @cemiar/auth-sdk

When working inside this monorepo, you can add it via a file reference:

npm install @cemiar/auth-sdk@file:../packages/cemiar-auth-sdk

Make sure the host project also has the required peer dependencies installed (@hapi/hapi, hapi-auth-jwt2).

Usage

Front-end (Vue/React/etc.)

import { createCemiarAuthClient } from "@cemiar/auth-sdk";

const authClient = createCemiarAuthClient({
    baseUrl: import.meta.env.VITE_CEMIAR_AUTH_URL!,
    tenantId: import.meta.env.VITE_CEMIAR_TENANT_ID!,
    auds: (import.meta.env.VITE_CEMIAR_AUDS || "").split(","),
    redirectUrl: `${window.location.origin}/auth/microsoft/callback`,
    logoutRedirectUrl: `${window.location.origin}/login`
});

// Trigger Microsoft login
window.location.href = authClient.getMicrosoftLoginUrl();

// Email code flow
await authClient.sendEmailCode("[email protected]");
const { accessToken } = await authClient.verifyEmailCode("[email protected]", "123456");

// Axios client with automatic Authorization header and refresh-on-401
const api = authClient.createApiClient({ baseURL: import.meta.env.VITE_API_BASE });
const jobs = await api.get("/api/jobs");

// Manual interceptor attachment if you already have an axios instance
authClient.attachInterceptors(existingAxiosInstance);

Handling the Microsoft callback

const params = Object.fromEntries(new URLSearchParams(window.location.search));
const user = authClient.handleRedirectMicrosoftCallback(params);

if (user) {
    history.replaceState(null, "", "/dashboard");
}

handleRedirectMicrosoftCallback stores the returned access token, infers the login method for future logouts, and gives you the signed-in user details. Call it once on your redirect page, then clean up the query string if needed.

Token storage hooks

By default the client stores tokens in localStorage. Override storage to customize behaviour:

import { createCemiarAuthClient, TokenStorage } from "@cemiar/auth-sdk";

const storage: TokenStorage = {
    getToken: () => cookies.get("cemiar-access"),
    setToken: token => {
        token ? cookies.set("cemiar-access", token) : cookies.remove("cemiar-access");
    }
};

const authClient = createCemiarAuthClient({
    baseUrl: import.meta.env.VITE_CEMIAR_AUTH_URL!,
    tenantId: import.meta.env.VITE_CEMIAR_TENANT_ID!,
    auds: ["cemiar-jobs"],
    storage
});

Logging out

await authClient.logout();

Logout automatically detects whether the user signed in with Microsoft or email and routes to the matching Cemiar Auth endpoint. Override behaviour with the optional flags:

  • redirectUrl: override the post-logout redirect (defaults to logoutRedirectUrl from the constructor)
  • performRedirect: set to false to stay on the page and only clear the server session
  • clearToken: set to false to retain the locally cached access token

You can still specify method: "microsoft" | "emailCode" if you need to force a flow.

Backend (Hapi)

import { registerCemiarAuthHapi } from "@cemiar/auth-sdk";

await registerCemiarAuthHapi(server, {
    authUrl: process.env.CEMIAR_AUTH_URL!,
    strategyName: "jwt",
    validate: async decoded => ({
        isValid: true,
        credentials: decoded.payload
    })
});

The helper automatically fetches signing keys from Cemiar Auth JWKS endpoint and keeps them cached.

To customise the cache and algorithms:

await registerCemiarAuthHapi(server, {
    authUrl: process.env.CEMIAR_AUTH_URL!,
    algorithms: ["RS256"],
    cacheMaxAgeMs: 12 * 60 * 60 * 1000
});

Environment Variables

| Variable | Description | | -------------------------- | ------------------------------------------------------------------ | | VITE_CEMIAR_AUTH_URL | Base Cemiar Auth URL (e.g. https://cemiar-auth.example.com/auth) | | VITE_CEMIAR_TENANT_ID | Tenant identifier provided by Cemiar Auth | | VITE_CEMIAR_AUDS | Comma separated list of audiences | | VITE_CEMIAR_REDIRECT_URL | Optional override for Microsoft redirect | | CEMIAR_AUTH_URL | Backend URL for Cemiar Auth (no Vite prefix) |

Building

cd packages/cemiar-auth-sdk
npm install
npm run build

Output will be generated under dist/.