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

@the-beus/sso-client

v1.0.4

Published

SSO Client SDK for The BEUS - Easy OAuth 2.0 integration

Readme

@the-beus/sso-client

🔐 Official SSO Client SDK for The BEUS - OAuth 2.0 + PKCE authentication made simple

npm version TypeScript

✨ Features

  • 🔒 OAuth 2.0 + PKCE - Secure authentication without exposing secrets
  • 🌐 Universal - Works in Browser & Node.js
  • 📦 Lightweight - Zero dependencies, < 5KB gzipped
  • 🎣 React Ready - Built-in hook factory
  • 💪 TypeScript - Full type definitions included

📦 Installation

npm install @the-beus/sso-client
# or
yarn add @the-beus/sso-client
# or
pnpm add @the-beus/sso-client

🚀 Quick Start

Basic Usage

import { TheBeusSSOClient } from '@the-beus/sso-client'

const sso = new TheBeusSSOClient({
  clientId: 'your-client-id',
  redirectUri: 'https://your-site.com/auth/callback',
})

// Redirect to login
await sso.login()

Handle Callback

// In your callback page
const { tokens, user } = await sso.handleCallback()

console.log(user.name)    // "John Doe"
console.log(user.email)   // "[email protected]"
console.log(tokens.access_token)  // "eyJ..."

📖 Documentation

Configuration

interface SSOClientConfig {
  clientId: string        // Required - Your client ID
  clientSecret?: string   // Optional - For server-side only!
  redirectUri: string     // Required - Your callback URL
  providerUrl?: string    // Optional - Default: 'https://thebeus.com'
  scopes?: SSOScope[]     // Optional - Default: ['openid', 'profile', 'email']
}

Available Scopes

| Scope | Description | |-------|-------------| | openid | OpenID Connect (required) | | profile | User's profile (name, picture) | | email | User's email address | | offline_access | Get refresh token |

API Reference

login(options?)

Redirect user to The BEUS login page.

await sso.login()

// With custom callback
await sso.login({ callbackUrl: 'https://custom.com/callback' })

handleCallback(params?)

Handle OAuth callback and exchange code for tokens.

const { tokens, user } = await sso.handleCallback()

refreshToken(token)

Refresh access token using refresh token.

const newTokens = await sso.refreshToken(savedRefreshToken)

getUserInfo(accessToken)

Get user info using access token.

const user = await sso.getUserInfo(accessToken)

logout(tokens?)

Revoke tokens and logout.

await sso.logout({
  accessToken: savedAccessToken,
  refreshToken: savedRefreshToken,
})

⚛️ React Integration

Create a Custom Hook

// lib/sso.ts
import { createSSOAuthHook } from '@the-beus/sso-client'

export const useSSOAuth = createSSOAuthHook({
  clientId: process.env.NEXT_PUBLIC_SSO_CLIENT_ID!,
  redirectUri: `${process.env.NEXT_PUBLIC_SITE_URL}/auth/callback`,
})

Login Button Component

// components/LoginButton.tsx
import { useSSOAuth } from '@/lib/sso'

export function LoginButton() {
  const { login } = useSSOAuth()
  
  return (
    <button onClick={() => login()}>
      Login with The BEUS
    </button>
  )
}

Callback Page

// pages/auth/callback.tsx
import { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import { useSSOAuth } from '@/lib/sso'

export default function CallbackPage() {
  const router = useRouter()
  const { handleCallback } = useSSOAuth()
  const [error, setError] = useState<string | null>(null)
  
  useEffect(() => {
    handleCallback()
      .then(({ tokens, user }) => {
        // Save to your auth state
        localStorage.setItem('accessToken', tokens.access_token)
        localStorage.setItem('user', JSON.stringify(user))
        router.push('/dashboard')
      })
      .catch(err => {
        setError(err.message)
      })
  }, [])
  
  if (error) return <div>Error: {error}</div>
  return <div>Logging in...</div>
}

🔧 Next.js API Route (Server-Side)

// pages/api/auth/refresh.ts
import { TheBeusSSOClient } from '@the-beus/sso-client'
import type { NextApiRequest, NextApiResponse } from 'next'

const sso = new TheBeusSSOClient({
  clientId: process.env.SSO_CLIENT_ID!,
  clientSecret: process.env.SSO_CLIENT_SECRET!, // Safe on server
  redirectUri: process.env.SITE_URL + '/auth/callback',
})

export default async function handler(
  req: NextApiRequest, 
  res: NextApiResponse
) {
  const { refreshToken } = req.body
  
  try {
    const tokens = await sso.refreshToken(refreshToken)
    res.json(tokens)
  } catch (error) {
    res.status(401).json({ error: 'Token refresh failed' })
  }
}

🛡️ Security Best Practices

  1. Never expose clientSecret in frontend code
  2. Use HTTPS in production
  3. Validate tokens on your backend
  4. Store tokens securely (httpOnly cookies preferred)
  5. Implement token refresh before expiration

📄 License

MIT © The BEUS