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

@anujyadav070/frontier-sdk

v1.0.11

Published

TypeScript SDK for Frontier authentication system

Readme

Frontier Auth SDK

A lightweight TypeScript SDK for authentication with your Frontier backend application. Currently supports tenant user registration and login functionality.

Installation

npm install @anujyadav070/frontier-sdk

Quick Start

import FrontierAuth from '@anujyadav070/frontier-sdk';

const auth = new FrontierAuth();

auth
  .setEndpoint('https://your-backend.com/api/v1')
  .setProject('your-project-id')
  .setKey('your-api-key');

// Sign up new tenant user
const user = await auth.account.create('username', '[email protected]', 'password');

// Login tenant user
const session = await auth.account.createEmailSession('[email protected]', 'password');

Current Features

  • ✅ Tenant user registration (Sign up)
  • ✅ Tenant user email/password authentication (Login)
  • ✅ Get current authenticated user information
  • ✅ User logout functionality
  • ✅ TypeScript support with full type definitions
  • ✅ HTTP client with automatic error handling
  • ✅ Configurable endpoint, project, and API key settings
  • ✅ JWT token support for authenticated requests
  • ✅ Custom exception handling (FrontierException, AuthException, etc.)
  • ✅ Debug logging for development

API Reference

Client Configuration

const auth = new FrontierAuth();

// Set your backend endpoint (required)
auth.setEndpoint('https://your-backend.com/api/v1');

// Set project ID (required)
auth.setProject('your-project-id');

// Set API key (required for authentication)
auth.setKey('your-api-key');

// Set JWT token (optional, for authenticated requests)
auth.setJWT('your-jwt-token');

Authentication Methods

Tenant User Registration

Create a new tenant user account:

const user = await auth.account.create(
  'username',          // Username (required)
  '[email protected]',  // Email address (required)
  'securePassword'     // Password (required)
);

console.log(user);
// Returns User object with: $id, $createdAt, $updatedAt, name, email, emailVerification, status

Tenant User Login

Authenticate tenant user with email and password:

const session = await auth.account.createEmailSession(
  '[email protected]',  // Email address
  'securePassword'     // Password
);

console.log(session);
// Returns Session object with: $id, userId, expire, provider, ip, device info, etc.

Get Current User

Get the currently authenticated user's information:

const currentUser = await auth.account.getCurrentUser();

console.log(currentUser);
// Returns User object with: $id, $createdAt, $updatedAt, name, email, emailVerification, status

Logout

Log out the current user session:

await auth.account.Logout();
// Logs out the current user and invalidates the session

Error Handling

The SDK includes comprehensive error handling with custom exception types:

import { FrontierException, AuthException, NetworkException, ValidationException } from '@anujyadav070/frontier-sdk';

try {
  await auth.account.createEmailSession('[email protected]', 'wrong-password');
} catch (error) {
  if (error instanceof AuthException) {
    console.log('Authentication failed:', error.message);
    console.log('Error code:', error.code);
    console.log('Error type:', error.type);
  } else if (error instanceof ValidationException) {
    console.log('Validation error:', error.message);
  } else if (error instanceof NetworkException) {
    console.log('Network error:', error.message);
  } else if (error instanceof FrontierException) {
    console.log('Frontier error:', error.message);
  } else {
    console.log('Unknown error:', error.message);
  }
}

Exception Types

  • FrontierException: Base exception class for all SDK errors
  • AuthException: Authentication-related errors (401)
  • NetworkException: Network connectivity issues
  • ValidationException: Input validation errors (400)

Complete Example

import FrontierAuth from '@anujyadav070/frontier-sdk';

async function main() {
  // Initialize SDK
  const auth = new FrontierAuth();
  
  // Configure (all required)
  auth
    .setEndpoint('https://your-backend.com/api/v1')
    .setProject('your-project-id')
    .setKey('your-api-key');

  try {
    // Sign up new tenant user
    console.log('Creating tenant account...');
    const user = await auth.account.create(
      'johndoe',
      '[email protected]',
      'securePassword123'
    );
    console.log('Tenant user created:', user);

    // Login tenant user
    console.log('Logging in...');
    const session = await auth.account.createEmailSession(
      '[email protected]',
      'securePassword123'
    );
    console.log('Login successful:', session);

    // Get current user information
    console.log('Getting current user...');
    const currentUser = await auth.account.getCurrentUser();
    console.log('Current user:', currentUser);

    // Logout
    console.log('Logging out...');
    await auth.account.Logout();
    console.log('Logout successful');

  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();

API Endpoints

The SDK currently supports these Frontier backend endpoints:

  • POST /api/v1/tenantuser/tenantRegister - Tenant user registration
  • POST /api/v1/tenantuser/tenatlogin - Tenant user login
  • GET /api/v1/tenantuser/getTenantSessions - Get current user information
  • DELETE /api/v1/tenantuser/tenantlogout/ - Logout current user

Configuration Requirements

The SDK requires the following configuration before making API calls:

  1. Endpoint: Your Frontier backend URL (e.g., https://your-backend.com/api/v1)
  2. Project ID: Your project identifier
  3. API Key: Your API key for authentication

Missing any of these will result in configuration errors.

Development

# Install dependencies
npm install

# Build the SDK
npm run build

# Watch for changes during development
npm run dev

# Prepare for publishing
npm run prepublishOnly

Package Information

  • Version: 1.0.10
  • Package Name: @anujyadav070/frontier-sdk
  • Repository: GitHub
  • Author: ANUJ YADAV
  • License: ISC

TypeScript Support

The SDK is built with TypeScript and includes full type definitions. All types are exported for use in your applications:

import { User, Session, FrontierException } from '@anujyadav070/frontier-sdk';

Roadmap

Future versions will include:

  • User profile management
  • Password reset functionality
  • Email verification
  • Session management (list, delete sessions)
  • JWT token creation and validation
  • User preferences management
  • Multi-factor authentication support

License

ISC

Contributing

This SDK is currently in active development. More authentication features will be added in future versions. Feel free to contribute by submitting issues or pull requests on GitHub.