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

@tekvora/auth-sdk

v1.1.0

Published

Auth SDK for Tekvora

Readme

@tekvora/auth-sdk

A production-grade TypeScript SDK for the Tekvora Auth Platform. This SDK handles Multi-Factor Authentication (MFA), Passkeys (WebAuthn), and secure session management with built-in protection against brute-force and replay attacks.

Installation

npm install @tekvora/auth-sdk
# or
pnpm add @tekvora/auth-sdk

Initialization

The SDK is designed to work out-of-the-box with zero configuration beyond your identifiers.

Standard Initialization

const auth = new TekvoraAuth('your_api_key_here', 'https://auth-api.example.com');

The SDK automatically:

  • Detects if it should use Secure cookies based on the connection (HTTPS vs HTTP).
  • Sets SameSite: Lax for optimal security and compatibility.
  • Manages token persistence and refreshing.

Advanced Config (Optional)

Only use this if you need to override cookie behavior or domains.

const auth = new TekvoraAuth({
  apiKey: 'your_api_key_here',
  baseUrl: 'https://auth-api.example.com',
  cookieConfig: {
    domain: '.yourdomain.com', // For cross-subdomain auth
    path: '/auth'
  }
});

1. Authentication Flow

The authentication flow is divided into two phases if Multi-Factor Authentication (MFA) is enabled.

Phase 1: Primary Login

Initializes the session with email and password.

const response = await auth.login('[email protected]', 'password123');

if (response.mfaRequired) {
  // MFA is enabled for this user. 
  // You MUST proceed to Phase 2 using the mfaToken.
  const { mfaToken, email, preferredMethod, enabledMethods } = response;
  // Store mfaToken in your frontend state
} else {
  // Login successful, tokens are automatically saved to cookies.
  console.log('User logged in:', response.user);
}

Phase 2: MFA Verification

Required if mfaRequired was returned in Phase 1. This uses a hardened partial-session approach.

// mfaToken is the token received from the login response
// code is the 6-digit TOTP or Email code
const result = await auth.verifyLogin(
  '[email protected]', 
  mfaCode, 
  mfaToken, 
  'totp' // optional: 'totp' | 'email' | 'passkey'
);

console.log('MFA Verified!', result.accessToken);

2. Passkey Authentication (WebAuthn)

The SDK uses @simplewebauthn/browser for biometrics and hardware keys.

Login with Passkey

This supports discoverable credentials (login without typing an email) if the browser facilitates it.

// Email is optional for discoverable credentials
const response = await auth.loginWithPasskey('[email protected]');

if (response.accessToken) {
  router.push('/dashboard');
}

Registering a Passkey (Logged In)

Users must be authenticated to register a new biometric credential.

const success = await auth.registerPasskey();
if (success) {
  alert('Passkey registered successfully!');
}

3. Account Security Management

MFA Setup (TOTP/App)

// 1. Initialize setup
const { qrCode, secret } = await auth.setupMFA('totp');

// 2. Show QR code to user, then verify the first code to enable
const { recoveryCodes } = await auth.verifyMFA(verificationCode, 'totp');

// IMPORTANT: Display recoveryCodes to the user and ensure they are saved.
// These are only shown once in plain text.

Regeneration of Recovery Codes

const { recoveryCodes } = await auth.regenerateRecoveryCodes();

4. Session & Token Management

The SDK automatically manages tekvora_at (Access Token) and tekvora_rt (Refresh Token) in browser cookies.

  • auth.logout(): Clears tokens from memory and deletes cookies.
  • auth.getMe(): Fetches the current user profile using the active session.
  • auth.refreshTokens(): Manually triggers a refresh flow. This is also handled automatically via Axios interceptors on 401 responses.

5. Security Features

  • Hardened MFA: The mfaToken is short-lived (5m) and cryptographically linked to the specific login attempt.
  • Lockout Protection: After 5 failed MFA attempts, the account is locked for 15 minutes. The SDK will throw a 403 error in this case.
  • Replay Protection: TOTP codes are tracked and cannot be reused within the same 30-second window.
  • Encrypted Secrets: TOTP seeds and recovery codes are never stored or transmitted in plain text on the server (encrypted via AES-256-GCM and hashed via Argon2ID).

Error Handling

The SDK throws errors for non-2xx responses. Always wrap calls in try-catch.

try {
  await auth.login(email, password);
} catch (err: any) {
  const errorMessage = err.response?.data?.error || 'An unexpected error occurred';
  console.error(errorMessage);
}