@codai/cbd
Version:
Codai Better Database - High-Performance Vector Memory System with HPKV-inspired architecture and MCP server
47 lines • 1.52 kB
JavaScript
/**
* ACME Challenge Handler for Let's Encrypt SSL Certificate
* This adds the /.well-known/acme-challenge endpoint to CBD Universal Database
*/
export class ACMEChallengeHandler {
challenges = new Map();
/**
* Add an ACME challenge
*/
addChallenge(token, response) {
this.challenges.set(token, response);
console.log(`🔐 ACME Challenge added: ${token} -> ${response.substring(0, 20)}...`);
}
/**
* Remove an ACME challenge
*/
removeChallenge(token) {
this.challenges.delete(token);
console.log(`🗑️ ACME Challenge removed: ${token}`);
}
/**
* Get challenge response
*/
getChallenge(token) {
return this.challenges.get(token);
}
/**
* Setup Express routes for ACME challenges
*/
setupRoutes(app) {
// Create .well-known directory route
app.get('/.well-known/acme-challenge/:token', (req, res) => {
const token = req.params.token;
const challenge = this.getChallenge(token);
if (challenge) {
console.log(`✅ ACME Challenge served: ${token}`);
res.type('text/plain').send(challenge);
}
else {
console.log(`❌ ACME Challenge not found: ${token}`);
res.status(404).send('Challenge not found');
}
});
console.log('🔐 ACME Challenge handler routes registered');
}
}
//# sourceMappingURL=ACMEChallengeHandler.js.map