How hectorm/otpauth works
Main Components
a) Core Components:
• HOTP Module (RFC 4226 implementation)
• TOTP Module (RFC 6238 implementation)
• Secret Management Module
• URI Handler Module
b) Internal Components:
• Crypto Operations Layer
• Encoding Layer
• Global Scope Handler
┌─ Public API Layer ─────────────────────┐
• HOTP │ TOTP │ Secret │ URI │ Version │
• ┬────────────────────┘
• ↓
┌─ Internal Layer ─────────────────────────────────┐
• ┌─ Crypto ─────┐ ┌─ Encoding ─────────┐ │
• HMAC Digest │ │ Base32 │ │
• Random Bytes │ │ Hex │ │
• Timing Safe │ │ Latin1 │ │
• ┘ │ UTF8 │ │
• UINT │ │
• ┘
Key Elements to Highlight
a) Platform Support:
• Compatibility with different environments (Node.js, Deno, Bun, Browsers)
• Distribution formats (ESM, UMD, CJS)
b) Security Components:
• Cryptographic operations
• Secure random generation flow
• Validation mechanisms
Specific Implementation Details
┌─ TOTP Class ──────────┐
• issuer │
• algorithm │
• digits │
• period │
• secret │
• ┘
Data Flow Indicators
• Secret generation flow
• Token generation process
• Validation flow
• URI encoding/decoding paths
URI handling for compatibility with standard authenticator apps
This will provide a comprehensive view of the library's architecture while highlighting its security-focused nature and broad platform support.