Adding Providers
HookLens keeps provider-specific verification behind a small seam.
The contract
Every provider implements Verifier from src/types.ts:
ts
interface Verifier {
readonly provider: string
verify(event: { headers: Record<string, string>; body: string }): VerificationResult
}The server does not know anything about Stripe, GitHub, or future providers. It just calls verify().
What a provider needs
- Verification logic in
src/verify/<provider>.ts - Tests in
tests/verify/<provider>.test.ts - CLI wiring in
buildVerifier()insidesrc/cli/listen.ts
Nothing else should need to change.
Reference shape
Current providers:
src/verify/stripe.tssrc/verify/github.ts
Each exports:
- a provider-specific
verify...Signature(...)primitive - a
create...Verifier(...)factory that returns aVerifier
Result codes
Stick to the existing VerificationResult.code values when you can:
validmissing_headermalformed_headerexpired_timestampsignature_mismatchbody_mutated
If a provider has a genuinely different failure mode, add it to verificationResultSchema in src/types.ts and update terminal output to match.
Test guidance
- Prefer the provider's official SDK or reference implementation as a test oracle when available
- Cover happy path, missing header, malformed header, mismatch, and body mutation when the provider makes that possible
- Keep provider-specific parsing logic in the provider module, not in the server
CLI wiring
hooklens listen --verify <provider> --secret ... goes through buildVerifier().
That is the only place where provider names should be mapped to factories.