Auth
Password hashing and JWT token primitives for the API auth endpoints.
Auth (packages/auth)
The auth package provides low-level authentication primitives: password hashing and JWT token operations. It is consumed by the API server's auth routes and the core domain's auth service.
Capabilities
Password Hashing
Secure password hashing using industry-standard algorithms. Provides hash and verify functions:
import { hashPassword, verifyPassword } from '@tx-agent-kit/auth'
const hashed = await hashPassword(plaintext)
const isValid = await verifyPassword(plaintext, hashed)JWT Tokens
Token generation and verification for session management:
import { signToken, verifyToken } from '@tx-agent-kit/auth'
const token = await signToken({ userId: user.id })
const payload = await verifyToken(token)Environment
Auth-specific configuration (e.g., JWT secret, token expiry) is read from packages/auth/src/env.ts. Direct process.env access is forbidden in other source modules within this package.
Usage in the Stack
The auth package sits between the API layer and the core domain:
API Route (apps/api/src/routes/auth.ts)
-> AuthService (packages/core/src/domains/auth/application/)
-> Auth Primitives (packages/auth)
-> User Repository (packages/db/src/repositories/)The API route handles HTTP concerns, the domain service orchestrates the auth flow, and this package provides the cryptographic primitives.