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

authsafe-ts

v0.0.5

Published

Framework-agnostic TypeScript/JavaScript SDK for AuthSafe - OAuth 2.1, OIDC, MFA, and user management for browser applications

Downloads

150

Readme

AuthSafe TypeScript SDK

The core TypeScript/JavaScript SDK for AuthSafe — a secure, framework-agnostic browser library for OAuth 2.1 and OpenID Connect (OIDC) authentication.

Overview

authsafe-ts is the foundational library that powers framework-specific SDKs like authsafe-react. Use this package when you need direct OAuth/OIDC integration without framework dependencies, or when building custom integrations for Vue, Angular, Svelte, or vanilla JavaScript applications.

Features

  • Framework Agnostic - Works with any JavaScript/TypeScript application
  • OAuth 2.1 & OIDC Compliant - Full implementation using oidc-client-ts
  • PKCE Support - Automatic Proof Key for Code Exchange
  • Token Management - Access tokens, refresh tokens, and ID tokens
  • TypeScript First - Comprehensive type definitions included
  • API Clients - Ready-to-use clients for MFA, SSO, User, and Branding APIs
  • Secure Storage - sessionStorage for OIDC state, HTTP-only cookies for refresh tokens
  • Tree-Shakeable - Import only what you need

Installation

npm install authsafe-ts

Or with other package managers:

# Yarn
yarn add authsafe-ts

# pnpm
pnpm add authsafe-ts

Quick Start

Basic OAuth Authentication

import { OAuthService } from 'authsafe-ts';

// Initialize OAuth service
const oauth = new OAuthService({
  clientId: 'your-client-id',
  redirectUri: 'http://localhost:3000/callback',
  scope: ['openid', 'email', 'profile', 'offline_access'],
  authority: 'https://your-authsafe-domain.com',
  env: 'development',
});

// Initiate login
await oauth.signinRedirect();

// Handle callback
const user = await oauth.signinRedirectCallback();
console.log('Authenticated user:', user);

// Get current user
const currentUser = await oauth.getUser();

// Logout
await oauth.signoutRedirect();

Using API Clients

import { HttpService, MfaApi, UserApi, BrandingApi, SSOApi } from 'authsafe-ts';

// Create HTTP service with authentication token
const httpService = new HttpService(accessToken);

// MFA Management
const mfaApi = new MfaApi(httpService);
const methods = await mfaApi.listMethods();
const registration = await mfaApi.registerMethod({ type: MfaType.TOTP });
await mfaApi.confirmMethod({ type: MfaType.TOTP, token: '123456' });

// User Management
const userApi = new UserApi(httpService);
await userApi.updateUser(userId, { name: 'John Doe' });

// Branding
const brandingApi = new BrandingApi(httpService);
const branding = await brandingApi.getBranding(clientId);

// SSO
const ssoApi = new SSOApi(httpService);
const providers = await ssoApi.getProviders();

Password Strength Validation

import { calculatePasswordStrength } from 'authsafe-ts';

const result = calculatePasswordStrength('MyP@ssw0rd123');
console.log(result);
// { strength: 80, label: 'Good', color: '#3b82f6' }

Core Exports

Services

  • OAuthService - OAuth 2.1/OIDC authentication service
  • HttpService - HTTP client with authentication support

API Clients

  • MfaApi - Multi-factor authentication management
  • UserApi - User profile and account management
  • BrandingApi - Client branding configuration
  • SSOApi - Single sign-on provider management

Types

All TypeScript types are exported, including:

  • User, AuthConfig, AuthTokens, AuthScope
  • MfaType, MfaMethod, RegisterMfaRequest, ConfirmMfaRequest
  • UpdateUserRequest, Branding, SSO, SSOProvider

Utilities

  • calculatePasswordStrength - Password strength calculator

Usage with Frameworks

While you can use this library directly, we provide framework-specific SDKs for better integration:

React

npm install authsafe-react

See the authsafe-react documentation for React-specific hooks and components.

Vue, Angular, Svelte

Use authsafe-ts directly and build your own framework wrappers using the core services and API clients.

TypeScript Support

This library is written in TypeScript and includes comprehensive type definitions:

import type {
  User,
  AuthConfig,
  AuthTokens,
  MfaType,
  MfaMethod,
  Branding,
  SSO,
} from 'authsafe-ts';

Browser Compatibility

  • Chrome/Edge: Latest 2 versions
  • Firefox: Latest 2 versions
  • Safari: Latest 2 versions
  • Modern browsers with ES2022 support

Dependencies

  • oidc-client-ts - OpenID Connect client
  • axios - HTTP client
  • js-cookie - Cookie management
  • @simplewebauthn/browser - WebAuthn support

License

MIT

Support

For issues, questions, or contributions, please visit:


Made with ❤️ by the AuthSafe team