feat-certificate-zip
✨ New Features
Certificate ZIP Generation
Goal: Provide a downloadable ZIP archive containing blockchain proof certificates and receipts for a document, replacing the legacy backend route with Hotep-powered PDF generation.
Solution: New GET /api/v2/documents/:id/zip endpoint that fetches document data + proofs from MongoDB, projects raw data (with field mask) to Hotep, which handles all certificate mapping logic, and assembles everything into a streaming ZIP archive.
Features:
- ZIP archive with proof certificates (PDF via Hotep) and receipts (.json/.ots)
- Optional inclusion of the source document file
- Query params
exclude=file,required=<types>,only=<types>for filtering - Support for chainpoint, ots, polygon and external proof types
- External proof certificates served directly from storage (no Hotep generation)
- Raw payload with field mask: neo sends projected MongoDB data, Hotep does all mapping (owner resolution, coauthors, represented client, ownerShare)
- Automatic specimen watermark in non-production via
HOTEP_MODEenv var
Implementation Details:
- Custom OpenStack Swift client using raw HTTP + Keystone v3 auth (no unmaintained third-party dependency)
- Token caching with auto-refresh for Swift authentication
- Two separate Swift credential sets (files vs proofs) matching legacy architecture
- Neo is a dumb pipe:
projectPayload()only picks fields, no transformation - Hotep owns all certificate logic: owner type resolution, address formatting, coauthor name concatenation, represented client lookup, ownerShare calculation
- Representative case:
document.owner(ObjectId) matched againstcompany.clients[]._idby Hotep
Files Modified:
src/core/config/storage.config.ts- OVH Swift storage configuration (Joi validated)src/core/config/hotep.config.ts- Hotep service configuration with mode (Joi validated)src/core/config/config.module.ts- Register new config loaders +ENV_FILEsupportsrc/core/storage/swift-auth.service.ts- Keystone v3 authentication with token cachingsrc/core/storage/storage.service.ts- File/proof download service (Swift HTTP client)src/core/storage/storage.module.ts- Storage NestJS modulesrc/core/hotep/hotep.types.ts- Raw projection types (HotepPayload,HotepDocumentData, etc.)src/core/hotep/hotep.service.ts- HTTP client for Hotep certificate generationsrc/core/hotep/hotep.module.ts- Hotep NestJS modulesrc/domains/document/zip.service.ts- ZIP assembly +projectPayload()field masksrc/domains/document/document.controller.ts- NewGET :id/zipendpointsrc/domains/document/document.module.ts- Import StorageModule + HotepModule
🐛 Bug Fixes
Auth middleware null user crash
Goal: Fix crash when getApiTokenUser returns null instead of throwing.
Solution: getApiTokenUser now throws Error('Api token not found') instead of returning null. The middleware .catch handles it properly with a 401.
Files Modified:
src/core/auth/auth.service.ts- Throw instead of return nullsrc/core/auth/middleware/authorization.middleware.ts- Simplified catch flow