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

haaremy-auth

v2.0.0

Published

Haaremy SSO Auth SDK v1.0.1 — apps-Claim, hasApp(), requiredApp-Guard

Readme

@haaremy/auth

Offizielles Auth-SDK für alle Haaremy-Apps. Kapselt Token-Handling, Login/Logout, BroadcastChannel Tab-Sync und Next.js-Integration.

Installation

npm install @haaremy/auth

Entrypoints

| Import | Beschreibung | |--------|-------------| | @haaremy/auth | Vanilla-JS Core (~2KB) — für alle Apps | | @haaremy/auth/react | React useAuth Hook + HmyLoginForm | | @haaremy/auth/next | Next.js Middleware + Server-Side Helpers (Edge-Runtime) |

Vanilla-JS / Astro / SvelteKit

import { init, login, logout, subscribe, getAccessToken, authFetch } from '@haaremy/auth'

// Einmalig beim App-Start initialisieren (prüft bestehenden Session-Cookie)
await init({ ssoUrl: 'https://sso.haaremy.de' })

// Auth-State abonnieren
const unsubscribe = subscribe((state, user) => {
  console.log(state) // 'loading' | 'authenticated' | 'unauthenticated'
  console.log(user)  // HmyUser | null
})

// Einloggen
const user = await login({ username_or_email: '[email protected]', password: 'secret' })

// Authentifizierte API-Anfragen
const res = await authFetch('/api/data')

// Ausloggen
await logout()

React

import { HmyAuthProvider, useAuth, HmyLoginForm } from '@haaremy/auth/react'

// App-Root
function App() {
  return (
    <HmyAuthProvider config={{ ssoUrl: 'https://sso.haaremy.de' }}>
      <MyPage />
    </HmyAuthProvider>
  )
}

// In Komponenten
function MyPage() {
  const { state, user, login, logout } = useAuth()

  if (state === 'loading') return <div>Lade...</div>
  if (state === 'unauthenticated') return <HmyLoginForm onSuccess={console.log} />

  return (
    <div>
      <p>Hallo, {user?.display_name}!</p>
      <button onClick={logout}>Abmelden</button>
    </div>
  )
}

Next.js Middleware

// middleware.ts
import { createHmyMiddleware } from '@haaremy/auth/next'

export default createHmyMiddleware({
  ssoUrl: 'https://sso.haaremy.de',
  publicPaths: ['/login', '/register', '/api/public*'],
  loginPath: '/login',
  jwksCacheTtlSeconds: 3600, // JWKS 1h cachen
})

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon).*)'],
}

Features

  • Zero localStorage — Access Token nur im JS-Memory
  • BroadcastChannel Tab-Sync — Einmal anmelden → alle Tabs eingeloggt (mit 150ms ack-Timeout für Background-Tabs)
  • Proaktiver Refresh — 60s vor Token-Ablauf automatisch erneuern
  • Replay-Detection — Serverseitige Token-Family-Invalidierung bei Diebstahl
  • JWKS-Cache — 1h offline JWT-Validierung in Next.js Middleware (kein SSO-Request pro Page Load)
  • Ed25519 — Schnelle, sichere JWT-Signierung

Architektur

SSO: sso.haaremy.de
├── POST /api/v1/auth/login   → access_token (JWT, 15 Min) + hmy_refresh_token Cookie
├── POST /api/v1/auth/refresh  → neuer access_token (Cookie-Rotation)
├── POST /api/v1/auth/logout   → Session revoken
├── GET  /api/v1/auth/check    → User-Info (Bearer Token)
└── GET  /.well-known/jwks.json → JWKS (Ed25519 Public Keys)