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

@qobo/admin-auth

v1.0.6

Published

Shared admin authentication components and utilities for Qobo-generated projects

Downloads

656

Readme

@qobo/admin-auth

Shared admin authentication components and utilities for all Qobo-generated projects. Protects admin routes with centralized OTP-based authentication.

Installation

npm install @qobo/admin-auth

Usage

1. Install and Initialize in App.jsx

import { useEffect } from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { AdminProtectedRoute, initializeAdminAuthFromUrl } from '@qobo/admin-auth';

export default function App() {
  // Initialize admin auth from URL parameters early (for cross-domain redirects)
  useEffect(() => {
    initializeAdminAuthFromUrl();
  }, []);

  return (
    <BrowserRouter>
      <Routes>
        {/* Public routes */}
        <Route path="/" element={<HomePage />} />
        <Route path="/about" element={<AboutPage />} />

        {/* Protected admin routes */}
        <Route path="/admin/*" element={
          <AdminProtectedRoute>
            <AdminLayout />
          </AdminProtectedRoute>
        } />
      </Routes>
    </BrowserRouter>
  );
}

2. Wrap Admin Routes

All admin routes should be wrapped with AdminProtectedRoute:

import { AdminProtectedRoute } from '@qobo/admin-auth';

// Option 1: Wrap entire admin section
<Route path="/admin/*" element={
  <AdminProtectedRoute>
    <AdminLayout />
  </AdminProtectedRoute>
} />

// Option 2: Wrap individual routes (not recommended, use Option 1)
<Route path="/admin" element={
  <AdminProtectedRoute>
    <AdminDashboard />
  </AdminProtectedRoute>
} />

3. Use Auth Utilities (Optional)

import { 
  isAdminAuthenticated, 
  logoutAdmin, 
  authenticatedApiCall 
} from '@qobo/admin-auth';

// Check authentication status
if (isAdminAuthenticated()) {
  console.log('User is authenticated');
}

// Logout admin
<button onClick={logoutAdmin}>Logout</button>

// Make authenticated API calls
const response = await authenticatedApiCall('/api/v1/admin/data', {
  method: 'GET'
});

Features

  • Automatic Redirect: Unauthenticated users are automatically redirected to https://platform.qobo.dev/login
  • Cross-Domain Support: Handles authentication tokens passed via URL parameters for cross-domain redirects
  • Token Management: Automatically manages JWT tokens in localStorage
  • Token Validation: Validates JWT tokens and checks expiration
  • Loading State: Shows loading indicator during redirect

Authentication Flow

  1. User tries to access /admin/* route without authentication
  2. AdminProtectedRoute checks authentication status
  3. If not authenticated, redirects to https://platform.qobo.dev/login?redirect=[currentUrl]
  4. User logs in using OTP on platform login page
  5. After successful login, user is redirected back to their website with ?admin_token=...&project_id=...
  6. initializeAdminAuthFromUrl() extracts token from URL and stores in localStorage
  7. User can now access admin routes

Environment Variables

No environment variables required. The package uses:

  • localStorage for token storage
  • https://platform.qobo.dev/login for centralized login

License

MIT