Fix new account again

This commit is contained in:
Fang-Pen Lin
2025-10-28 19:24:53 -07:00
parent 457c5ea9c8
commit 9c748bf0ee
4 changed files with 6 additions and 7 deletions

View File

@@ -12,6 +12,7 @@ export const PkiAcmeAccountsSchema = z.object({
profileId: z.string().uuid(),
emails: z.string().array(),
publicKey: z.unknown(),
alg: z.string(),
createdAt: z.date(),
updatedAt: z.date()
});

View File

@@ -110,7 +110,7 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
}
},
handler: async (req, res) => {
const { payload, protectedHeader, jwk } = await server.services.pkiAcme.validateJwsPayload(
const { payload, protectedHeader } = await server.services.pkiAcme.validateJwsPayload(
req.body as TRawJwsPayload,
async (protectedHeader) => {
if (!protectedHeader.jwk) {
@@ -120,13 +120,11 @@ export const registerPkiAcmeRouter = async (server: FastifyZodProvider) => {
},
CreateAcmeAccountBodySchema
);
if (!jwk) {
throw new AcmeBadPublicKeyError({ detail: "JWK is required in the protected header" });
}
const { alg, jwk } = protectedHeader;
const { status, body, headers } = await server.services.pkiAcme.createAcmeAccount(
req.params.profileId,
protectedHeader.alg,
jwk,
alg,
jwk!,
payload
);
// TODO: DRY

View File

@@ -156,6 +156,7 @@ export const pkiAcmeServiceFactory = ({
const newAccount = await acmeAccountDAL.create({
profileId: profile.id,
alg,
publicKey: jwk,
emails: contact ?? []
});

View File

@@ -40,7 +40,6 @@ export type TFinalizeAcmeOrderPayload = z.infer<typeof FinalizeAcmeOrderBodySche
export type TJwsPayload<T> = {
protectedHeader: TProtectedHeader;
jwk?: JsonWebKey;
payload: T;
};
export type TAcmeResponse<TPayload> = {