NOTE: this is still a draft, so it's subject to changes. This alert will be removed as soon as final version will be available

πŸ”‘@hsuite/auth-types - Authentication Type Definitions

A comprehensive TypeScript library providing type-safe authentication, authorization, and user management type definitions for Web2 and Web3 applications within the HSuite ecosystem.

Table of Contents


Quick Start

npm install @hsuite/auth-types
import { IAuth, Auth } from '@hsuite/auth-types';

// Use interfaces for type checking
const loginData: IAuth.ICredentials.IWeb2.IDto.ILogin = {
  username: "john_doe",
  email: "[email protected]", 
  password: "securePassword123"
};

// Use models for runtime logic
const loginDto = new Auth.Credentials.Web2.Dto.Login(loginData);

Key Features

Comprehensive TypeScript library for authentication and authorization type definitions

Complete set of TypeScript interfaces, models, and decorators for implementing secure, type-safe authentication across applications within the HSuite ecosystem.


πŸ—οΈ Architecture

Core Namespaces

πŸ”’ IAuth (Interfaces)

  • ITwilio - Twilio service integration interfaces

  • ITwoFactor - Two-factor authentication interfaces

  • IConfiguration - System configuration interfaces

  • IWeb3 - Blockchain authentication interfaces

  • IWeb2 - Traditional authentication interfaces

  • ICredentials - Credential management interfaces

  • IUser - User entity and management interfaces

πŸ›οΈ Auth (Models)

  • Twilio - SMS and voice verification models

  • TwoFactor - TOTP and verification models

  • Configuration - Authentication system settings

  • Web3 - Blockchain wallet authentication models

  • Web2 - Traditional credential models

  • Credentials - Secure credential storage models

πŸ‘₯ User (Models)

  • User.Safe - Safe user entity model with public properties

  • User management type definitions

  • User entity interfaces and implementations

🎯 Decorators

  • @Roles() - Role-based access control

  • @Public() - Public route marker

  • @isTwoFactorAuth() - Two-factor authentication requirement

  • @bypassTokenGate() - Token gate bypass

Module Structure


πŸ”§ API Reference

Decorators

@Roles(roles: string[])

Role-based access control decorator using Reflector pattern.

@Public()

Marks route as publicly accessible without authentication.

@isTwoFactorAuth()

Enforces two-factor authentication requirement.

@bypassTokenGate()

Bypasses token gate verification checks.

Core Interfaces

IAuth.IConfiguration.IAuthentication

IAuth.ICredentials.IWeb2.IDto.ILogin

IAuth.ICredentials.IWeb2.IDto.ISignup

IAuth.ICredentials.IUser.IEntity

Model Classes

Auth.Configuration.Authentication

Auth.Credentials.Web2.Dto.Login

Auth.Credentials.Web3.Entity

Auth.TwoFactor.Auth


πŸ“– Guides

Decorator Usage Guide

Learn how to use authentication decorators for route protection and access control. Implement role-based permissions, public endpoints, and advanced authentication patterns.

Interface Reference Guide

Complete reference for all authentication interfaces and type definitions. Understand the authentication system architecture and type contracts.

Model Implementation Guide

How to use model classes for type-safe authentication data handling. Learn about concrete implementations and runtime logic patterns.


🎯 Examples

Role-Based Access Control

Web2 Authentication Models

Web3 Authentication Models

Two-Factor Authentication

User Types

Configuration Models


πŸ”— Integration

Required Dependencies

TypeScript Configuration

Metadata Keys


πŸ”§ Type Safety: All interfaces and models provide full TypeScript support with strict type checking and validation.

πŸ“ Architecture: Clean separation between interfaces (IAuth namespace) and implementations (Auth namespace) following SOLID principles.

🎯 Best Practice: Use interfaces for type definitions and model classes for runtime validation and data transformation.

Built with ❀️ by the HSuite Team Copyright © 2025 HSuite. All rights reserved.

Last updated