@xtandard/webhooks — self-hosted, embeddable, Standard Webhooks-compliant
outbound-webhooks control plane.
The root export: the core and its types (also on /core and /schema),
the dispatcher, the panel’s web-standard fetch handler, signing (also on
/signing), portal tokens, the hooks contract, and the auth/authorization
contracts. Storage adapters, auth providers, framework adapters and the
React embeds are separate subpaths with optional peer dependencies.
Perform one signed POST to endpoint.url. Never throws for remote-party failures — network errors, timeouts, and non-2xx responses all come back as a failed AttemptOutcome. (It does throw on programmer error, e.g. an endpoint with no unexpired secret.)
Build the exact signed request an attempt would POST — Standard Webhooks headers, all unexpired secrets signing — without sending it. Shared by attemptDelivery and the panel’s request inspector so what you preview is byte-for-byte what a receiver gets.
Mint a portal token granting access to applicationKey until expiresIn elapses (default 7 days). Call this server-side — anyone holding the portal secret can mint tokens for any application.
Convert a WebhookDuration to milliseconds: a non-negative number of ms, or "<n><unit>" with unit ms, s, m, h, d (or w). Throws on negative, non-finite or malformed values.
Invoke listener safely off the delivery path: synchronous throws are caught and a returned Promise’s rejection is handled, so a broken sink can never fail (or slow, since it is not awaited) a delivery.
A WatchSubscribe source for Postgres LISTEN/NOTIFY: the database owns the trigger that pg_notifys channel with the changed key as payload; client is a dedicated listening connection.
Validate an endpoint destination URL: parseable, https: (or http: for localhost, or anywhere when allowInsecureUrls), no embedded credentials, and passing the host’s optional urlPolicy gate.
Verify a portal token: format, signature (constant time), then expiry. Returns the granted application key on success; throws PortalTokenError otherwise.
Storage that can natively claim due deliveries (sorted-set / SKIP LOCKED class backends). When present, the dispatcher delegates claiming entirely to the adapter instead of scanning the generic due index.
Event delivered to WebhooksHooks.after — the committed mutation. Carries the resulting state in full: for destructive events this is the last chance to offload the payload before it is gone from storage.
A fire-and-forget observer of delivery attempts. Return value (including a Promise) is ignored by the caller; throwing / rejecting never affects the delivery — failures are routed to the configured error reporter.
CORS for the panel: origin (a string, a list, or a predicate; "*" with credentials echoes the caller’s origin), credentials, methods, headers and maxAge.
Lifecycle hooks: before may deny a mutation by throwing (sequential, the first throw aborts); after observes committed changes (concurrent, errors isolated and reported).