feat(server): add an embedded ACME directory server and certificate authority with challenge, order, and certificate endpoints
This commit is contained in:
27
ts_server/server.classes.account.store.ts
Normal file
27
ts_server/server.classes.account.store.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { IServerAccountStore, IServerAccount } from './server.interfaces.js';
|
||||
|
||||
/**
|
||||
* In-memory account storage for the ACME server.
|
||||
*/
|
||||
export class MemoryAccountStore implements IServerAccountStore {
|
||||
private accounts = new Map<string, IServerAccount>();
|
||||
private byThumbprint = new Map<string, string>();
|
||||
private byUrl = new Map<string, string>();
|
||||
|
||||
async create(account: IServerAccount): Promise<IServerAccount> {
|
||||
this.accounts.set(account.id, account);
|
||||
this.byThumbprint.set(account.thumbprint, account.id);
|
||||
this.byUrl.set(account.url, account.id);
|
||||
return account;
|
||||
}
|
||||
|
||||
async getByThumbprint(thumbprint: string): Promise<IServerAccount | null> {
|
||||
const id = this.byThumbprint.get(thumbprint);
|
||||
return id ? this.accounts.get(id) || null : null;
|
||||
}
|
||||
|
||||
async getByUrl(url: string): Promise<IServerAccount | null> {
|
||||
const id = this.byUrl.get(url);
|
||||
return id ? this.accounts.get(id) || null : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user