Use the right error type

This commit is contained in:
Fang-Pen Lin
2025-11-07 09:20:49 -08:00
parent 708b8f9f65
commit 1adcd721fe
@@ -158,7 +158,7 @@ export const pkiAcmeServiceFactory = ({
if (error instanceof ZodError) { if (error instanceof ZodError) {
throw new AcmeMalformedError({ detail: `Invalid JWS payload: ${error.message}` }); throw new AcmeMalformedError({ detail: `Invalid JWS payload: ${error.message}` });
} }
if (error instanceof errors.JWSInvalid) { if (error instanceof errors.JWSSignatureVerificationFailed) {
throw new AcmeBadPublicKeyError({ detail: "Invalid JWS payload" }); throw new AcmeBadPublicKeyError({ detail: "Invalid JWS payload" });
} }
logger.error(error, "Unexpected error while verifying JWS payload"); logger.error(error, "Unexpected error while verifying JWS payload");
@@ -361,7 +361,7 @@ export const pkiAcmeServiceFactory = ({
); );
return { eabPayload, eabProtectedHeader }; return { eabPayload, eabProtectedHeader };
} catch (error) { } catch (error) {
if (error instanceof errors.JWSInvalid) { if (error instanceof errors.JWSSignatureVerificationFailed) {
throw new AcmeMalformedError({ detail: "Invalid external account binding JWS payload" }); throw new AcmeMalformedError({ detail: "Invalid external account binding JWS payload" });
} }
logger.error(error, "Unexpected error while verifying EAB JWS payload"); logger.error(error, "Unexpected error while verifying EAB JWS payload");