feat(server): add an embedded ACME directory server and certificate authority with challenge, order, and certificate endpoints
This commit is contained in:
72
ts_server/server.classes.order.store.ts
Normal file
72
ts_server/server.classes.order.store.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import type {
|
||||
IServerOrderStore,
|
||||
IServerOrder,
|
||||
IServerAuthorization,
|
||||
IServerChallenge,
|
||||
} from './server.interfaces.js';
|
||||
|
||||
/**
|
||||
* In-memory order/authorization/challenge/certificate storage for the ACME server.
|
||||
*/
|
||||
export class MemoryOrderStore implements IServerOrderStore {
|
||||
private orders = new Map<string, IServerOrder>();
|
||||
private authorizations = new Map<string, IServerAuthorization>();
|
||||
private challenges = new Map<string, IServerChallenge>();
|
||||
private certPems = new Map<string, string>();
|
||||
|
||||
async createOrder(order: IServerOrder): Promise<IServerOrder> {
|
||||
this.orders.set(order.id, order);
|
||||
return order;
|
||||
}
|
||||
|
||||
async getOrder(id: string): Promise<IServerOrder | null> {
|
||||
return this.orders.get(id) || null;
|
||||
}
|
||||
|
||||
async updateOrder(id: string, updates: Partial<IServerOrder>): Promise<void> {
|
||||
const order = this.orders.get(id);
|
||||
if (order) {
|
||||
Object.assign(order, updates);
|
||||
}
|
||||
}
|
||||
|
||||
async createAuthorization(authz: IServerAuthorization): Promise<IServerAuthorization> {
|
||||
this.authorizations.set(authz.id, authz);
|
||||
return authz;
|
||||
}
|
||||
|
||||
async getAuthorization(id: string): Promise<IServerAuthorization | null> {
|
||||
return this.authorizations.get(id) || null;
|
||||
}
|
||||
|
||||
async updateAuthorization(id: string, updates: Partial<IServerAuthorization>): Promise<void> {
|
||||
const authz = this.authorizations.get(id);
|
||||
if (authz) {
|
||||
Object.assign(authz, updates);
|
||||
}
|
||||
}
|
||||
|
||||
async createChallenge(challenge: IServerChallenge): Promise<IServerChallenge> {
|
||||
this.challenges.set(challenge.id, challenge);
|
||||
return challenge;
|
||||
}
|
||||
|
||||
async getChallenge(id: string): Promise<IServerChallenge | null> {
|
||||
return this.challenges.get(id) || null;
|
||||
}
|
||||
|
||||
async updateChallenge(id: string, updates: Partial<IServerChallenge>): Promise<void> {
|
||||
const challenge = this.challenges.get(id);
|
||||
if (challenge) {
|
||||
Object.assign(challenge, updates);
|
||||
}
|
||||
}
|
||||
|
||||
async storeCertPem(orderId: string, pem: string): Promise<void> {
|
||||
this.certPems.set(orderId, pem);
|
||||
}
|
||||
|
||||
async getCertPem(orderId: string): Promise<string | null> {
|
||||
return this.certPems.get(orderId) || null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user