Repository navigation
feat(webhooks): declarative provider routing (closes #2254) - #2326
Merged
github-actions[bot] merged 1 commit intoNov 24, 2026
Merged
github-actions[bot] merged 1 commit into
github-actions[bot] merged 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2254
Summary
Implements declarative webhook routing with provider handlers, entirely within the technical scope (
backend/src/webhooks/dispatcher.tsandbackend/src/webhooks/providers/).providers/module (zero dependencies):types.ts—WebhookProvider/ProviderKind,HandlerErrorCode,HandlerError,ProviderHandler,WebhookRoute,RouteRegistry,RouteMatch,NormalizedWebhookEvent, observability hook interfaces. All route declarations are plain, frozen data.matching.ts— purenormalizeProvider,normalizeEventType,routeKey,compileRouteandmatchRoute. Exact provider+event routes beat wildcard (*) routes; ties break onpriority, then registration order.registry.ts—createRouteRegistry(config?, metrics?, logger?)withregister/unregister/match/has/handlers/providers/size/clear. Configurable duplicate policy (error|replace|keepFirst), optional provider allow-list, frozen config and frozen returned snapshots.handlers.ts— first-class, side-effect-free Stripe / PayPal / GitHub handlers that normalize payloads into aNormalizedWebhookEventand forward to an injected sink;createProviderRoutes(sink)builds a complete frozen 10-route table.index.ts— barrel exports,DEFAULT_PROVIDER_ROUTES,createDefaultRouteRegistry.dispatcher.tsextension (preserves the existing JWT flow): the JWT claim gate, signature hook,DispatchErrorcodes and legacy handler map are untouched in behavior. A declarative provider-route lookup is inserted after signature validation and before handler invocation; matched provider routes take precedence, legacy event-type handlers remain as a fallback. Handler contexts now also receiveprovider,eventTypeandmatchedRoutemetadata. AddedcreateDeclarativeDispatcher,registerRouteandrouteRegistryexposure.Observability
Every registration, match, miss, duplicate, removal and clear emits a namespaced metric (
webhook.route.*) and an audit log entry through the same hook shapes already used by the JWT validator, so callers can pass their existing hooks straight through.Verification
.tssources: 52/52 assertions passed, 0 failures (covering normalization, registration, duplicate policies, allow-list, exact/wildcard/priority matching, all three built-in handlers, unregister/clear, metrics/logger hooks, frozen results, and dispatcher integration including JWT rejection).backend/src/webhooks/providers/__tests__/index.test.ts: 39 tests / 107 assertions passed, 0 failures via a describe/it/expect shim runner (no node_modules available in this environment).backend/src/webhooks/__tests__/dispatcher.test.ts18/18 passed andjwt.test.ts42/42 passed — the JWT gate is unchanged.python tools/check_secrets.py):SECRETS_EXIT=0.IVANLI2412/SubTrackrasfix/issue-2254-webhook-routing.Payouts
Base Mainnet (USDC/ETH): 0xC5dD2Ea54FF138bb3f71D3466092eA31eF115868
Solana (USDC/SOL): DN3pfYEvdkoTBP4oaEVvemsr98fZPhDSAbfVfmewRGQ5
PayPal: ivanzenteno3@gmail.com