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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vector-institute/aieng-auth-core

v0.1.2

Published

Framework-agnostic Google OAuth authentication core library

Readme

@vector-institute/aieng-auth-core

Framework-agnostic CyberArk OAuth authentication core library with PKCE support.

Features

  • 🔒 Secure OAuth 2.0 Authorization Code + PKCE flow
  • 🎯 Framework-agnostic - works with any JavaScript framework
  • 💾 Pluggable token storage (Memory, SessionStorage, LocalStorage)
  • ⚡ Automatic token refresh management
  • 🛡️ TypeScript strict mode with full type definitions
  • ✅ Comprehensive test coverage (90%+)

Installation

npm install @vector-institute/aieng-auth-core
# or
pnpm add @vector-institute/aieng-auth-core
# or
yarn add @vector-institute/aieng-auth-core

Quick Start

import {
  generatePKCE,
  TokenManager,
  MemoryTokenStorage,
  type AuthConfig,
} from '@vector-institute/aieng-auth-core';

// Configure authentication
const config: AuthConfig = {
  tenantUrl: 'https://your-tenant.cyberark.cloud',
  clientId: 'your-client-id',
  redirectUri: 'http://localhost:3000/callback',
  scopes: ['openid', 'profile', 'email'],
};

// Initialize token manager
const tokenManager = new TokenManager(new MemoryTokenStorage());

// Generate PKCE challenge for login
const pkce = await generatePKCE();
console.log(pkce.challenge); // Send to authorization endpoint

API Reference

PKCE Utilities

// Generate PKCE challenge
const pkce = await generatePKCE();
// { verifier: '...', challenge: '...', method: 'S256' }

// Verify PKCE (for testing)
const isValid = await verifyPKCE(pkce.verifier, pkce.challenge);

Token Storage

import {
  MemoryTokenStorage,
  SessionStorageAdapter,
  LocalStorageAdapter,
} from '@vector-institute/aieng-auth-core';

// Memory storage (most secure, lost on refresh)
const memoryStorage = new MemoryTokenStorage();

// Session storage (survives refresh, XSS vulnerable)
const sessionStorage = new SessionStorageAdapter();

// Local storage (persists across sessions, least secure)
const localStorage = new LocalStorageAdapter();

Token Manager

import { TokenManager } from '@vector-institute/aieng-auth-core';

const manager = new TokenManager(storage);

// Store tokens
await manager.setTokens({
  accessToken: 'access_token',
  refreshToken: 'refresh_token',
  tokenType: 'Bearer',
  expiresIn: 3600,
});

// Get tokens
const tokens = await manager.getTokens();
const accessToken = await manager.getAccessToken();

// Validate tokens
const isValid = await manager.isTokenValid();
const shouldRefresh = await manager.shouldRefresh(300); // 5 min buffer

// Clear tokens
await manager.clearTokens();

Token Validation

import { decodeToken, isTokenExpired, validateToken } from '@vector-institute/aieng-auth-core';

// Decode JWT
const decoded = decodeToken(accessToken);

// Check expiration
const expired = isTokenExpired(accessToken);
const expiringSoon = isTokenExpired(accessToken, 300); // 5 min buffer

// Validate token
const valid = validateToken(accessToken, {
  checkExpiration: true,
  requiredClaims: ['sub', 'email'],
  issuer: 'https://your-tenant.cyberark.cloud',
});

Security

  • Always use PKCE for public clients (SPAs)
  • Prefer MemoryTokenStorage for maximum security
  • Use SessionStorageAdapter only when UX requires persistence
  • Avoid LocalStorageAdapter unless absolutely necessary
  • Never store tokens in URLs or query parameters
  • Implement proper HTTPS in production

License

MIT