Hessra SDK
The primary interface for interacting with Hessra authentication services.
API Reference
This crate integrates functionality from these component crates:
hessra-token: Token verification and attestationhessra-config: Configuration managementhessra-api: HTTP client for the Hessra service
Detailed Usage
Creating a Client
use ;
// Basic client setup
let client = builder
.base_url
.protocol
.build?;
// More complete setup with mTLS certificates
let secure_client = builder
.base_url
.protocol
.mtls_cert
.mtls_key
.server_ca
.build?;
// Loading from environment variables
let env_client = from_env?;
// Loading from a configuration file
let file_client = from_file?;
Working with Tokens
// Request a token
let token = client.request_token.await?;
println!;
// Simple token verification
let verification = client.verify_token.await?;
println!;
// Local token verification (using cached public keys)
let local_verification = client.verify_token_local?;
println!;
// Update public keys cache for local verification
client.update_public_keys.await?;
Advanced: Service Chain Attestation
For services that need to verify tokens passed through multiple services:
use ;
// Define the service chain (order matters!)
let service_chain = builder
.add_node
.add_node
.build;
// Verify a token with the service chain
client.verify_service_chain_token.await?;
// Local verification of service chain token
client.verify_service_chain_token_local?;
Error Handling
The SDK provides a comprehensive error handling system:
use HessraError;
Feature Flags
http3: Enables HTTP/3 protocol support via thehessra-apicratetoml: Enables TOML configuration file support via thehessra-configcratewasm: Enables WebAssembly support for token verification via thehessra-tokencrate
Advanced Configuration
Customizing HTTP Clients
use ;
use Duration;
let client = builder
.base_url
.protocol
.timeout
.retry_attempts
.retry_backoff
.build?;
Using HTTP/3
When the http3 feature is enabled:
use ;
let client = builder
.base_url
.protocol
.build?;
License
Licensed under the Apache License, Version 2.0.