@hsuite/client
A comprehensive NestJS module providing client functionality for HSUITE applications, with built-in support for Web3 authentication, node communication, and network resilience.
Features
🔐 Web3-based authentication flow
🌐 Dynamic node connection management
🔄 Automatic network resilience and failover
🍪 Session management with cookie support
⚡ HTTP client with axios integration
🛡️ Secure cryptographic signing
📡 Periodic health monitoring
🔌 Flexible module configuration
🎯 Global module scope support
Installation
Peer Dependencies
This module requires the following peer dependencies:
Quick Start
Import the module in your
app.module.ts
:
Inject and use the ClientService in your components:
API Reference
ClientModule
The main module that provides client functionality.
Methods
forRootAsync(options: ClientModuleAsyncOptions)
: Configures the module asynchronously with dependency injection support.
ClientService
Core service for managing client operations and authentication.
Properties
login
: Get current Web3 login credentialsoperator
: Get current operator informationaxios
: Get configured axios instance for making HTTP requests
Methods
onModuleInit()
: Initializes client connection and authenticationPrivate methods handle node connection, network resilience, and data signing
Configuration Options
The module supports three configuration patterns:
Factory Function Pattern:
Existing Provider Pattern:
Class Provider Pattern:
Features in Detail
Web3 Authentication Flow
The module implements a complete Web3 authentication flow:
Requests authentication challenge
Signs challenge with operator credentials
Submits signed proof for verification
Establishes authenticated session
Sets up periodic health monitoring
Network Resilience
Built-in support for handling network issues:
Automatic failover to alternative nodes
Connection error handling (ECONNREFUSED, ECONNABORTED, ECONNRESET)
Dynamic node selection
Session maintenance during node failures
Security Features
Cryptographic signing of requests
Secure cookie handling
Private key management
Session-based authentication
Documentation
Detailed documentation can be generated using Compodoc:
To check documentation coverage:
Dependencies
Core dependencies:
@hsuite/smart-network-types
: "2.0.0"@hsuite/auth-types
: "2.0.0"@hsuite/nestjs-swagger
: "2.0.0"@hsuite/smart-config
: "2.0.0"
Development dependencies:
@compodoc/compodoc
: "^1.1.23"
Version
Current version: 2.0.0
License
This package is part of the HSuite Enterprise solution.
Built with ❤️ by the HbarSuite Team Copyright © 2024 HbarSuite. All rights reserved.
Last updated