feat(server): add an embedded ACME directory server and certificate authority with challenge, order, and certificate endpoints
This commit is contained in:
30
ts_server/server.handlers.directory.ts
Normal file
30
ts_server/server.handlers.directory.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type * as http from 'node:http';
|
||||
import type { IAcmeDirectory } from '../ts/acme/acme.interfaces.js';
|
||||
|
||||
/**
|
||||
* GET /directory — Returns the ACME directory object with all endpoint URLs.
|
||||
*/
|
||||
export function createDirectoryHandler(baseUrl: string) {
|
||||
return async (
|
||||
_req: http.IncomingMessage,
|
||||
res: http.ServerResponse,
|
||||
_params: Record<string, string>,
|
||||
_body: any,
|
||||
): Promise<void> => {
|
||||
const directory: IAcmeDirectory = {
|
||||
newNonce: `${baseUrl}/new-nonce`,
|
||||
newAccount: `${baseUrl}/new-account`,
|
||||
newOrder: `${baseUrl}/new-order`,
|
||||
revokeCert: `${baseUrl}/revoke-cert`,
|
||||
keyChange: `${baseUrl}/key-change`,
|
||||
meta: {
|
||||
termsOfService: `${baseUrl}/terms`,
|
||||
website: `${baseUrl}`,
|
||||
caaIdentities: [],
|
||||
externalAccountRequired: false,
|
||||
},
|
||||
};
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify(directory));
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user