@xtandard/webhooks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +315 -0
- package/bin/xtandard-webhooks.mjs +3 -0
- package/dist/basic-BIW3Rvuz.cjs +199 -0
- package/dist/basic-BIW3Rvuz.cjs.map +1 -0
- package/dist/basic-DKk0Xfuu.mjs +176 -0
- package/dist/basic-DKk0Xfuu.mjs.map +1 -0
- package/dist/chunk-D7D4PA-g.mjs +13 -0
- package/dist/cli.cjs +655 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +42 -0
- package/dist/cli.d.mts +42 -0
- package/dist/cli.mjs +653 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/contract-8h-Azxa5.d.cts +71 -0
- package/dist/contract-9XpcwcCn.mjs +22 -0
- package/dist/contract-9XpcwcCn.mjs.map +1 -0
- package/dist/contract-B2d5dNU3.cjs +33 -0
- package/dist/contract-B2d5dNU3.cjs.map +1 -0
- package/dist/contract-BEhDcd_5.mjs +28 -0
- package/dist/contract-BEhDcd_5.mjs.map +1 -0
- package/dist/contract-Bf1qguwt.cjs +57 -0
- package/dist/contract-Bf1qguwt.cjs.map +1 -0
- package/dist/contract-Bnb3fgRJ.d.cts +177 -0
- package/dist/contract-C2r2Xzwp.d.mts +46 -0
- package/dist/contract-CiPskNvS.d.cts +46 -0
- package/dist/contract-DhQ4JjGG.d.mts +71 -0
- package/dist/contract-T1kcZNdG.d.mts +177 -0
- package/dist/contract-lETlIuXo.d.cts +30 -0
- package/dist/contract-lETlIuXo.d.mts +30 -0
- package/dist/core-CMpnmI5Q.mjs +1605 -0
- package/dist/core-CMpnmI5Q.mjs.map +1 -0
- package/dist/core-DT4ppWh8.d.mts +502 -0
- package/dist/core-KJawHjFF.d.cts +502 -0
- package/dist/core-ZGhH6Vs2.cjs +1790 -0
- package/dist/core-ZGhH6Vs2.cjs.map +1 -0
- package/dist/core.cjs +8 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/create-fetch-handler-BIdk9P30.mjs +1724 -0
- package/dist/create-fetch-handler-BIdk9P30.mjs.map +1 -0
- package/dist/create-fetch-handler-CmooujQo.cjs +1771 -0
- package/dist/create-fetch-handler-CmooujQo.cjs.map +1 -0
- package/dist/create-fetch-handler-Dlkhustu.d.cts +162 -0
- package/dist/create-fetch-handler-jy3hy5nZ.d.mts +162 -0
- package/dist/dispatcher-B0xTEHt1.cjs +212 -0
- package/dist/dispatcher-B0xTEHt1.cjs.map +1 -0
- package/dist/dispatcher-Coubwrka.mjs +196 -0
- package/dist/dispatcher-Coubwrka.mjs.map +1 -0
- package/dist/entry-auth-basic.cjs +5 -0
- package/dist/entry-auth-basic.d.cts +83 -0
- package/dist/entry-auth-basic.d.mts +83 -0
- package/dist/entry-auth-basic.mjs +2 -0
- package/dist/entry-auth-delegated.cjs +28 -0
- package/dist/entry-auth-delegated.cjs.map +1 -0
- package/dist/entry-auth-delegated.d.cts +36 -0
- package/dist/entry-auth-delegated.d.mts +36 -0
- package/dist/entry-auth-delegated.mjs +27 -0
- package/dist/entry-auth-delegated.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +4 -0
- package/dist/entry-auth-none.d.cts +25 -0
- package/dist/entry-auth-none.d.mts +25 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-authorization-delegated.cjs +27 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +31 -0
- package/dist/entry-authorization-delegated.d.mts +31 -0
- package/dist/entry-authorization-delegated.mjs +26 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +3 -0
- package/dist/entry-authorization-none.d.cts +18 -0
- package/dist/entry-authorization-none.d.mts +18 -0
- package/dist/entry-authorization-none.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +6 -0
- package/dist/entry-authorization-roles.d.cts +65 -0
- package/dist/entry-authorization-roles.d.mts +65 -0
- package/dist/entry-authorization-roles.mjs +2 -0
- package/dist/entry-bun.cjs +24 -0
- package/dist/entry-bun.cjs.map +1 -0
- package/dist/entry-bun.d.cts +8 -0
- package/dist/entry-bun.d.mts +8 -0
- package/dist/entry-bun.mjs +23 -0
- package/dist/entry-bun.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +20 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +27 -0
- package/dist/entry-drizzle-mysql.d.mts +27 -0
- package/dist/entry-drizzle-mysql.mjs +19 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +21 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +26 -0
- package/dist/entry-drizzle-pg.d.mts +26 -0
- package/dist/entry-drizzle-pg.mjs +20 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +21 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +23 -0
- package/dist/entry-drizzle-sqlite.d.mts +23 -0
- package/dist/entry-drizzle-sqlite.mjs +20 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-elysia.cjs +125 -0
- package/dist/entry-elysia.cjs.map +1 -0
- package/dist/entry-elysia.d.cts +1017 -0
- package/dist/entry-elysia.d.mts +1017 -0
- package/dist/entry-elysia.mjs +123 -0
- package/dist/entry-elysia.mjs.map +1 -0
- package/dist/entry-express.cjs +57 -0
- package/dist/entry-express.cjs.map +1 -0
- package/dist/entry-express.d.cts +15 -0
- package/dist/entry-express.d.mts +15 -0
- package/dist/entry-express.mjs +56 -0
- package/dist/entry-express.mjs.map +1 -0
- package/dist/entry-hono.cjs +35 -0
- package/dist/entry-hono.cjs.map +1 -0
- package/dist/entry-hono.d.cts +16 -0
- package/dist/entry-hono.d.mts +16 -0
- package/dist/entry-hono.mjs +34 -0
- package/dist/entry-hono.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +22 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +23 -0
- package/dist/entry-hooks-log.d.mts +23 -0
- package/dist/entry-hooks-log.mjs +21 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +47 -0
- package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +42 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +42 -0
- package/dist/entry-storage-cloudflare-kv.mjs +46 -0
- package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
- package/dist/entry-storage-drizzle.cjs +78 -0
- package/dist/entry-storage-drizzle.cjs.map +1 -0
- package/dist/entry-storage-drizzle.d.cts +30 -0
- package/dist/entry-storage-drizzle.d.mts +30 -0
- package/dist/entry-storage-drizzle.mjs +77 -0
- package/dist/entry-storage-drizzle.mjs.map +1 -0
- package/dist/entry-storage-file.cjs +4 -0
- package/dist/entry-storage-file.d.cts +30 -0
- package/dist/entry-storage-file.d.mts +30 -0
- package/dist/entry-storage-file.mjs +2 -0
- package/dist/entry-storage-libsql.cjs +3 -0
- package/dist/entry-storage-libsql.d.cts +48 -0
- package/dist/entry-storage-libsql.d.mts +48 -0
- package/dist/entry-storage-libsql.mjs +2 -0
- package/dist/entry-storage-memory.cjs +3 -0
- package/dist/entry-storage-memory.d.cts +2 -0
- package/dist/entry-storage-memory.d.mts +2 -0
- package/dist/entry-storage-memory.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +3 -0
- package/dist/entry-storage-mongodb.d.cts +55 -0
- package/dist/entry-storage-mongodb.d.mts +55 -0
- package/dist/entry-storage-mongodb.mjs +2 -0
- package/dist/entry-storage-postgres.cjs +3 -0
- package/dist/entry-storage-postgres.d.cts +62 -0
- package/dist/entry-storage-postgres.d.mts +62 -0
- package/dist/entry-storage-postgres.mjs +2 -0
- package/dist/entry-storage-redis.cjs +4 -0
- package/dist/entry-storage-redis.d.cts +77 -0
- package/dist/entry-storage-redis.d.mts +77 -0
- package/dist/entry-storage-redis.mjs +2 -0
- package/dist/entry-storage-sqlite.cjs +3 -0
- package/dist/entry-storage-sqlite.d.cts +36 -0
- package/dist/entry-storage-sqlite.d.mts +36 -0
- package/dist/entry-storage-sqlite.mjs +2 -0
- package/dist/entry-storage-unstorage.cjs +42 -0
- package/dist/entry-storage-unstorage.cjs.map +1 -0
- package/dist/entry-storage-unstorage.d.cts +29 -0
- package/dist/entry-storage-unstorage.d.mts +29 -0
- package/dist/entry-storage-unstorage.mjs +41 -0
- package/dist/entry-storage-unstorage.mjs.map +1 -0
- package/dist/file-COBYZA4Q.cjs +148 -0
- package/dist/file-COBYZA4Q.cjs.map +1 -0
- package/dist/file-fi02eFHk.mjs +131 -0
- package/dist/file-fi02eFHk.mjs.map +1 -0
- package/dist/index.cjs +123 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +368 -0
- package/dist/index.d.mts +366 -0
- package/dist/index.mjs +61 -0
- package/dist/index.mjs.map +1 -0
- package/dist/keys-Byyj4quQ.mjs +111 -0
- package/dist/keys-Byyj4quQ.mjs.map +1 -0
- package/dist/keys-FiKpaVHX.cjs +302 -0
- package/dist/keys-FiKpaVHX.cjs.map +1 -0
- package/dist/libsql-bpVi0bXN.mjs +113 -0
- package/dist/libsql-bpVi0bXN.mjs.map +1 -0
- package/dist/libsql-pPJEo1e4.cjs +124 -0
- package/dist/libsql-pPJEo1e4.cjs.map +1 -0
- package/dist/memory-8Ef-PL5a.cjs +137 -0
- package/dist/memory-8Ef-PL5a.cjs.map +1 -0
- package/dist/memory-BMsSSwqn.mjs +127 -0
- package/dist/memory-BMsSSwqn.mjs.map +1 -0
- package/dist/memory-FnMJWCmB.d.cts +28 -0
- package/dist/memory-qIvANEs_.d.mts +28 -0
- package/dist/mongodb-Cy8yo0uk.cjs +108 -0
- package/dist/mongodb-Cy8yo0uk.cjs.map +1 -0
- package/dist/mongodb-Ddaq9mml.mjs +97 -0
- package/dist/mongodb-Ddaq9mml.mjs.map +1 -0
- package/dist/none-BnZtaGNJ.mjs +23 -0
- package/dist/none-BnZtaGNJ.mjs.map +1 -0
- package/dist/none-CAsxCOWN.cjs +49 -0
- package/dist/none-CAsxCOWN.cjs.map +1 -0
- package/dist/none-CZVrfnmF.cjs +33 -0
- package/dist/none-CZVrfnmF.cjs.map +1 -0
- package/dist/none-GhVIoh_s.mjs +33 -0
- package/dist/none-GhVIoh_s.mjs.map +1 -0
- package/dist/postgres-C8WbchFa.cjs +134 -0
- package/dist/postgres-C8WbchFa.cjs.map +1 -0
- package/dist/postgres-c3pAhmhr.mjs +123 -0
- package/dist/postgres-c3pAhmhr.mjs.map +1 -0
- package/dist/react.css +1 -0
- package/dist/react.js +31465 -0
- package/dist/receiver.cjs +43 -0
- package/dist/receiver.cjs.map +1 -0
- package/dist/receiver.d.cts +36 -0
- package/dist/receiver.d.mts +36 -0
- package/dist/receiver.mjs +40 -0
- package/dist/receiver.mjs.map +1 -0
- package/dist/redis-CFJkuSgB.cjs +270 -0
- package/dist/redis-CFJkuSgB.cjs.map +1 -0
- package/dist/redis-CvLi0KF7.mjs +254 -0
- package/dist/redis-CvLi0KF7.mjs.map +1 -0
- package/dist/roles-D0G9XqBq.cjs +128 -0
- package/dist/roles-D0G9XqBq.cjs.map +1 -0
- package/dist/roles-vp361lTk.mjs +99 -0
- package/dist/roles-vp361lTk.mjs.map +1 -0
- package/dist/schema-mo__wv4P.d.cts +233 -0
- package/dist/schema-mo__wv4P.d.mts +233 -0
- package/dist/schema.cjs +13 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +2 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +11 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/signing.cjs +162 -0
- package/dist/signing.cjs.map +1 -0
- package/dist/signing.d.cts +73 -0
- package/dist/signing.d.mts +73 -0
- package/dist/signing.mjs +156 -0
- package/dist/signing.mjs.map +1 -0
- package/dist/sqlite-Cmqnrjes.mjs +67 -0
- package/dist/sqlite-Cmqnrjes.mjs.map +1 -0
- package/dist/sqlite-Dcufk0x3.cjs +78 -0
- package/dist/sqlite-Dcufk0x3.cjs.map +1 -0
- package/dist/table-Ce3Tzwqs.d.cts +11 -0
- package/dist/table-Ce3Tzwqs.d.mts +11 -0
- package/dist/testing.cjs +134 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +80 -0
- package/dist/testing.d.mts +80 -0
- package/dist/testing.mjs +131 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-react/react.d.ts +98 -0
- package/dist/types-react/schema.d.ts +229 -0
- package/dist/types-react/ui/App.d.ts +22 -0
- package/dist/types-react/ui/api.d.ts +97 -0
- package/dist/types-react/ui/components/JsonCodeEditor.d.ts +12 -0
- package/dist/types-react/ui/components/ThemeToggle.d.ts +2 -0
- package/dist/types-react/ui/components/Toast.d.ts +16 -0
- package/dist/types-react/ui/components/primitives.d.ts +50 -0
- package/dist/types-react/ui/components/ui-bits.d.ts +22 -0
- package/dist/types-react/ui/components/webhook-bits.d.ts +51 -0
- package/dist/types-react/ui/lib/format.d.ts +39 -0
- package/dist/types-react/ui/lib/nav-guard.d.ts +20 -0
- package/dist/types-react/ui/lib/utils.d.ts +3 -0
- package/dist/types-react/ui/theme.d.ts +12 -0
- package/dist/types-react/ui/types.d.ts +80 -0
- package/dist/types-react/ui/views/AuditView.d.ts +6 -0
- package/dist/types-react/ui/views/DeliveriesView.d.ts +12 -0
- package/dist/types-react/ui/views/EndpointsView.d.ts +11 -0
- package/dist/types-react/ui/views/EventTypesView.d.ts +11 -0
- package/dist/types-react/ui/views/MessagesView.d.ts +10 -0
- package/dist/types-react/ui/views/OverviewView.d.ts +12 -0
- package/dist/ui/assets/index-B0eoQX2U.css +1 -0
- package/dist/ui/assets/index-S5t_CLOe.js +209 -0
- package/dist/ui/index.html +14 -0
- package/package.json +487 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { _ as WebhookEnvelope, a as AuditEntry, c as DeliveryStatus, d as EndpointSecret, f as EventType, g as WebhookDuration, h as SCHEMA_VERSION, i as AuditAction, l as Endpoint, m as Message, n as Application, o as Delivery, p as JsonValue, r as AttemptTrigger, s as DeliveryAttempt, t as Actor, u as EndpointDisabledReason, v as isTerminalDeliveryStatus } from "./schema-mo__wv4P.cjs";
|
|
2
|
+
import { A as BuildSignedRequestInput, C as createDispatcher, D as emitDelivery, E as DeliveryListener, F as attemptDelivery, I as buildSignedRequest, M as DEFAULT_RESPONSE_BODY_LIMIT, N as SignedRequest, O as AttemptDeliveryInput, P as activeSecrets, S as DispatcherOptions, T as DeliveryEvent, _ as WebhooksCore, a as ListDeliveriesOptions, b as DEFAULT_RETRY_SCHEDULE, c as PayloadTooLargeError, d as ReadonlyError, f as RecordAttemptInput, g as SendExampleResult, h as RetentionRule, i as IdempotencyConflictError, j as DEFAULT_ATTEMPT_TIMEOUT_MS, k as AttemptOutcome, l as PublishInput, m as RetentionOptions, n as ClaimInput, o as ListMessagesOptions, p as RecoverResult, r as ConflictError, s as NotFoundError, t as ActorOptions, u as PublishResult, v as WebhooksCoreOptions, w as DeliveryErrorReporter, x as Dispatcher, y as createWebhooksCore } from "./core-KJawHjFF.cjs";
|
|
3
|
+
import { a as WatchableWebhooksStorage, c as isCompareAndSwap, d as requirePeer, i as TransactionalWebhooksStorage, l as isTransactional, n as DeliveryQueueStorage, o as WebhooksStorage, r as StorageChangeEvent, s as hasDeliveryQueue, t as CompareAndSwapWebhooksStorage, u as isWatchable } from "./contract-8h-Azxa5.cjs";
|
|
4
|
+
import { a as HookDeniedError, c as WebhooksHooksInput, d as runAfter, f as runBefore, i as BeforeEventType, l as defaultHookErrorReporter, n as AfterEventType, o as HookErrorReporter, r as BeforeEvent, s as WebhooksHooks, t as AfterEvent, u as normalizeHooks } from "./contract-Bnb3fgRJ.cjs";
|
|
5
|
+
import { n as Principal, t as AuthProvider } from "./contract-lETlIuXo.cjs";
|
|
6
|
+
import { a as WebhooksResource, i as WebhooksAction, n as AuthorizeInput, o as isMutatingAction, r as MUTATING_ACTIONS, t as AuthorizationProvider } from "./contract-CiPskNvS.cjs";
|
|
7
|
+
import { a as WebhooksPortalOptions, i as DEFAULT_PORTAL_ACTIONS, n as WebhooksPanelOptions, o as WebhooksCorsOptions, r as createFetchHandler, t as CreateFetchHandlerResult } from "./create-fetch-handler-Dlkhustu.cjs";
|
|
8
|
+
import { SECRET_PREFIX, VerifyInput, WebhookVerificationError, generateSecret, sign, signatureHeader, verify } from "./signing.cjs";
|
|
9
|
+
|
|
10
|
+
//#region \0rolldown/runtime.js
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/version.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* Package version, used for the default dispatcher `user-agent`. Bumped by the
|
|
15
|
+
* release flow alongside `package.json`.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/** The published package version. */
|
|
20
|
+
declare const VERSION = "0.1.0";
|
|
21
|
+
declare namespace keys_d_exports {
|
|
22
|
+
export { DueEntry, RESERVED_APPLICATION_KEYS, ROOT, applicationMetaKey, applicationPrefix, applicationsKey, attemptKey, attemptsPrefix, auditLogKey, byEndpointKey, byEndpointPrefix, byMessageKey, byMessagePrefix, deliveriesPrefix, deliveryKey, dueKey, duePrefix, endpointKey, endpointsKey, eventTypeKey, eventTypesKey, globalAuditLogKey, idempotencyKey, lastSegment, messageKey, messagesPrefix, parseDueKey };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Storage key layout for `@xtandard/webhooks`.
|
|
26
|
+
*
|
|
27
|
+
* Keys are namespaced by application so a single storage backend can host the
|
|
28
|
+
* whole control plane. Pure string helpers — no dependencies.
|
|
29
|
+
*
|
|
30
|
+
* ```txt
|
|
31
|
+
* whk/applications -> string[] index
|
|
32
|
+
* whk/{app}/metadata -> Application
|
|
33
|
+
* whk/event-types -> string[] index (global)
|
|
34
|
+
* whk/event-types/{name} -> EventType
|
|
35
|
+
* whk/{app}/endpoints -> string[] index
|
|
36
|
+
* whk/{app}/endpoints/{id} -> Endpoint
|
|
37
|
+
* whk/{app}/messages/{id} -> Message
|
|
38
|
+
* whk/{app}/idempotency/{key} -> message id
|
|
39
|
+
* whk/{app}/deliveries/{id} -> Delivery
|
|
40
|
+
* whk/{app}/attempts/{deliveryId}/{n} -> DeliveryAttempt (n zero-padded)
|
|
41
|
+
* whk/{app}/due/{dueAtMillis}~{deliveryId} -> DueEntry (13-digit zero-padded millis)
|
|
42
|
+
* whk/{app}/by-message/{messageId}/{deliveryId} -> 1 (reverse index)
|
|
43
|
+
* whk/{app}/by-endpoint/{endpointId}/{deliveryId} -> 1 (reverse index)
|
|
44
|
+
* whk/{app}/audit-log -> AuditEntry[] (single ordered array)
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* The due index is the dispatcher's generic work queue: 13-digit zero-padded
|
|
48
|
+
* milliseconds make lexicographic key order chronological, so a sorted
|
|
49
|
+
* `getKeys(duePrefix(app))` scan yields deliveries in due order.
|
|
50
|
+
*
|
|
51
|
+
* @module
|
|
52
|
+
*/
|
|
53
|
+
/** Root namespace segment for all keys. */
|
|
54
|
+
declare const ROOT = "whk";
|
|
55
|
+
/**
|
|
56
|
+
* Application keys that would collide with global index keys under the shared
|
|
57
|
+
* root. Rejected by validation.
|
|
58
|
+
*/
|
|
59
|
+
declare const RESERVED_APPLICATION_KEYS: readonly ["applications", "event-types", "audit-log"];
|
|
60
|
+
/** Global audit log (event-type actions, which are not application-scoped). */
|
|
61
|
+
declare const globalAuditLogKey: () => string;
|
|
62
|
+
/** Index key listing all known application keys. */
|
|
63
|
+
declare const applicationsKey: () => string;
|
|
64
|
+
/** Metadata for a single application. */
|
|
65
|
+
declare const applicationMetaKey: (applicationKey: string) => string;
|
|
66
|
+
/** Index key listing all event type names (global catalog). */
|
|
67
|
+
declare const eventTypesKey: () => string;
|
|
68
|
+
/** A single event type record. */
|
|
69
|
+
declare const eventTypeKey: (name: string) => string;
|
|
70
|
+
/** Index key listing an application's endpoint ids. */
|
|
71
|
+
declare const endpointsKey: (applicationKey: string) => string;
|
|
72
|
+
/** A single endpoint record. */
|
|
73
|
+
declare const endpointKey: (applicationKey: string, endpointId: string) => string;
|
|
74
|
+
/** Prefix under which an application's messages live. */
|
|
75
|
+
declare const messagesPrefix: (applicationKey: string) => string;
|
|
76
|
+
/** A single message record. */
|
|
77
|
+
declare const messageKey: (applicationKey: string, messageId: string) => string;
|
|
78
|
+
/** Maps a caller-supplied idempotency key to the message id it produced. */
|
|
79
|
+
declare const idempotencyKey: (applicationKey: string, key: string) => string;
|
|
80
|
+
/** Prefix under which an application's deliveries live. */
|
|
81
|
+
declare const deliveriesPrefix: (applicationKey: string) => string;
|
|
82
|
+
/** A single delivery record. */
|
|
83
|
+
declare const deliveryKey: (applicationKey: string, deliveryId: string) => string;
|
|
84
|
+
/** Prefix under which one delivery's attempts live. */
|
|
85
|
+
declare const attemptsPrefix: (applicationKey: string, deliveryId: string) => string;
|
|
86
|
+
/**
|
|
87
|
+
* A single attempt record. The attempt number is zero-padded to four digits so
|
|
88
|
+
* lexicographic key order equals attempt order.
|
|
89
|
+
*/
|
|
90
|
+
declare const attemptKey: (applicationKey: string, deliveryId: string, attemptNumber: number) => string;
|
|
91
|
+
/** Prefix of an application's due index (the dispatcher's work queue). */
|
|
92
|
+
declare const duePrefix: (applicationKey: string) => string;
|
|
93
|
+
/** Value stored at a due-index key. */
|
|
94
|
+
interface DueEntry {
|
|
95
|
+
app: string;
|
|
96
|
+
deliveryId: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A due-index entry: 13-digit zero-padded epoch milliseconds, then the delivery
|
|
100
|
+
* id, `~`-separated. Sorting keys lexicographically sorts entries chronologically.
|
|
101
|
+
*/
|
|
102
|
+
declare const dueKey: (applicationKey: string, dueAtMillis: number, deliveryId: string) => string;
|
|
103
|
+
/** Parse a due-index key back into its due-time and delivery id. */
|
|
104
|
+
declare const parseDueKey: (key: string) => {
|
|
105
|
+
dueAtMillis: number;
|
|
106
|
+
deliveryId: string;
|
|
107
|
+
} | null;
|
|
108
|
+
/** Prefix of the message → deliveries reverse index. */
|
|
109
|
+
declare const byMessagePrefix: (applicationKey: string, messageId: string) => string;
|
|
110
|
+
/** One entry in the message → deliveries reverse index. */
|
|
111
|
+
declare const byMessageKey: (applicationKey: string, messageId: string, deliveryId: string) => string;
|
|
112
|
+
/** Prefix of the endpoint → deliveries reverse index. */
|
|
113
|
+
declare const byEndpointPrefix: (applicationKey: string, endpointId: string) => string;
|
|
114
|
+
/** One entry in the endpoint → deliveries reverse index. */
|
|
115
|
+
declare const byEndpointKey: (applicationKey: string, endpointId: string, deliveryId: string) => string;
|
|
116
|
+
/** Append-only audit log for an application, stored as an ordered `AuditEntry[]`. */
|
|
117
|
+
declare const auditLogKey: (applicationKey: string) => string;
|
|
118
|
+
/** Prefix under which everything belonging to one application lives. */
|
|
119
|
+
declare const applicationPrefix: (applicationKey: string) => string;
|
|
120
|
+
/** Extract the trailing segment (endpoint id / message id / …) from a key. */
|
|
121
|
+
declare const lastSegment: (key: string) => string;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/id.d.ts
|
|
124
|
+
/**
|
|
125
|
+
* Entity id generation: `{prefix}_{22-char base62}`. Zero dependencies — base62
|
|
126
|
+
* over `crypto.getRandomValues`, no ULID. 22 base62 characters encode ~131 bits;
|
|
127
|
+
* ids are generated from 16 random bytes (128 bits) and left-padded to a fixed
|
|
128
|
+
* length so ids are uniform and lexicographically well-behaved.
|
|
129
|
+
*
|
|
130
|
+
* @module
|
|
131
|
+
*/
|
|
132
|
+
/** Prefixes for the four generated entity id kinds. */
|
|
133
|
+
type IdPrefix = "msg" | "ep" | "dlv" | "atp";
|
|
134
|
+
/**
|
|
135
|
+
* Generate a new entity id, e.g. `newId("msg")` → `"msg_0uK9…"` (22-char base62
|
|
136
|
+
* suffix).
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* import { newId } from "@xtandard/webhooks";
|
|
141
|
+
*
|
|
142
|
+
* const id = newId("ep"); // "ep_…"
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
declare function newId(prefix: IdPrefix): string;
|
|
146
|
+
/** Regex an id of the given prefix must match. */
|
|
147
|
+
declare function idPattern(prefix: IdPrefix): RegExp;
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/duration.d.ts
|
|
150
|
+
/**
|
|
151
|
+
* Convert a {@link WebhookDuration} (`5000`, `"5s"`, `"30m"`, `"2h"`, `"5d"`)
|
|
152
|
+
* to milliseconds. Throws on malformed strings or negative numbers.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* import { durationToMs } from "@xtandard/webhooks";
|
|
157
|
+
*
|
|
158
|
+
* durationToMs("5m"); // 300000
|
|
159
|
+
* durationToMs(250); // 250
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
declare function durationToMs(duration: WebhookDuration): number;
|
|
163
|
+
/**
|
|
164
|
+
* Parse a comma-separated duration list (the `RETRY_SCHEDULE` env var format,
|
|
165
|
+
* e.g. `"0s,5s,5m,30m,2h,5h,10h"`) into a {@link WebhookDuration} array.
|
|
166
|
+
*/
|
|
167
|
+
declare function parseDurationList(input: string): WebhookDuration[];
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/storage/watch.d.ts
|
|
170
|
+
/**
|
|
171
|
+
* A change source. Called with a `notify` callback — wire your source to invoke
|
|
172
|
+
* it (optionally with the changed key) on every change — and return an
|
|
173
|
+
* unsubscribe function (sync or async).
|
|
174
|
+
*/
|
|
175
|
+
type WatchSubscribe = (notify: (key?: string) => void) => (() => void | Promise<void>) | Promise<() => void | Promise<void>>;
|
|
176
|
+
/**
|
|
177
|
+
* Wrap a storage so it implements {@link WatchableWebhooksStorage} using
|
|
178
|
+
* `subscribe` as the change source. The wrapper delegates all reads/writes to
|
|
179
|
+
* `storage` and only adds `watch`; keys not under the watched `prefix` are
|
|
180
|
+
* filtered out. A notification without a key is delivered as a change to the
|
|
181
|
+
* prefix itself (enough to trigger a refresh).
|
|
182
|
+
*/
|
|
183
|
+
declare function withWatch<S extends WebhooksStorage>(storage: S, subscribe: WatchSubscribe): S & WatchableWebhooksStorage;
|
|
184
|
+
/**
|
|
185
|
+
* A dedicated notification client for {@link pgListenNotify} — satisfied by a
|
|
186
|
+
* `pg` `Client`. `Pool` won't do (it rotates connections); use a `Client` you
|
|
187
|
+
* `connect()`.
|
|
188
|
+
*/
|
|
189
|
+
interface PgNotificationClient {
|
|
190
|
+
query(sql: string): Promise<unknown>;
|
|
191
|
+
on(event: "notification", listener: (msg: {
|
|
192
|
+
channel: string;
|
|
193
|
+
payload?: string;
|
|
194
|
+
}) => void): void;
|
|
195
|
+
removeListener(event: "notification", listener: (msg: {
|
|
196
|
+
channel: string;
|
|
197
|
+
payload?: string;
|
|
198
|
+
}) => void): void;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A {@link WatchSubscribe} backed by Postgres `LISTEN`/`NOTIFY`. Pair with
|
|
202
|
+
* {@link withWatch} for the postgres or drizzle-over-pg adapters. Your migration
|
|
203
|
+
* owns the trigger that `pg_notify`s `channel` with the changed key as payload;
|
|
204
|
+
* this only `LISTEN`s.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* import { Client } from "pg";
|
|
209
|
+
* const listener = new Client({ connectionString: process.env.DATABASE_URL });
|
|
210
|
+
* await listener.connect();
|
|
211
|
+
* const storage = withWatch(base, pgListenNotify(listener, "xtandard_webhooks"));
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
declare function pgListenNotify(client: PgNotificationClient, channel?: string): WatchSubscribe;
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/validation.d.ts
|
|
217
|
+
/**
|
|
218
|
+
* Runtime validation for control-plane inputs, built on `valibot`.
|
|
219
|
+
*
|
|
220
|
+
* This is the **admin path** only — `publish()` performs its own minimal
|
|
221
|
+
* checks and the wire/receiver path never imports this module, so `valibot`
|
|
222
|
+
* stays off the hot paths. Validation combines structural parsing (valibot)
|
|
223
|
+
* with semantic checks (URL policy, reserved header names, reserved keys).
|
|
224
|
+
*
|
|
225
|
+
* @module
|
|
226
|
+
*/
|
|
227
|
+
/** Allowed characters for application keys and event type names. */
|
|
228
|
+
declare const KEY_REGEX: RegExp;
|
|
229
|
+
/**
|
|
230
|
+
* Header names owned by the Standard Webhooks wire contract. Endpoints may not
|
|
231
|
+
* override them via static headers.
|
|
232
|
+
*/
|
|
233
|
+
declare const RESERVED_HEADERS: readonly ["webhook-id", "webhook-timestamp", "webhook-signature"];
|
|
234
|
+
/** A single validation problem with a dotted path into the offending data. */
|
|
235
|
+
interface ValidationIssue {
|
|
236
|
+
path: string;
|
|
237
|
+
message: string;
|
|
238
|
+
}
|
|
239
|
+
/** Result of the `validate*` functions. */
|
|
240
|
+
interface ValidationResult {
|
|
241
|
+
valid: boolean;
|
|
242
|
+
errors: ValidationIssue[];
|
|
243
|
+
}
|
|
244
|
+
/** Raised by {@link assertValid} when an input fails validation. Maps to HTTP 422. */
|
|
245
|
+
declare class ValidationError extends Error {
|
|
246
|
+
readonly errors: ValidationIssue[];
|
|
247
|
+
constructor(errors: ValidationIssue[]);
|
|
248
|
+
}
|
|
249
|
+
/** Throw a {@link ValidationError} when `result` is invalid. */
|
|
250
|
+
declare function assertValid(result: ValidationResult): void;
|
|
251
|
+
/**
|
|
252
|
+
* Validate an {@link Application}: structure + reserved-key check.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import { validateApplication } from "@xtandard/webhooks";
|
|
257
|
+
*
|
|
258
|
+
* const result = validateApplication({ key: "acme" });
|
|
259
|
+
* // result.valid === true
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
declare function validateApplication(input: unknown, basePath?: string): ValidationResult;
|
|
263
|
+
/** Validate an {@link EventType}: structural only (the name regex carries the semantics). */
|
|
264
|
+
declare function validateEventType(input: unknown, basePath?: string): ValidationResult;
|
|
265
|
+
/** Options that relax/extend the endpoint URL policy. */
|
|
266
|
+
interface UrlPolicyOptions {
|
|
267
|
+
/** Allow `http:` for non-localhost hosts (dev only; default `false`). */
|
|
268
|
+
allowInsecureUrls?: boolean;
|
|
269
|
+
/** Extra host-supplied gate; return `false` to reject (e.g. an SSRF denylist). */
|
|
270
|
+
urlPolicy?: (url: string) => boolean;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Validate an endpoint destination URL: parseable, `https:` (or `http:` for
|
|
274
|
+
* localhost, or anywhere when `allowInsecureUrls`), no embedded credentials,
|
|
275
|
+
* and passing the host's optional `urlPolicy` gate.
|
|
276
|
+
*/
|
|
277
|
+
declare function validateEndpointUrl(url: string, options?: UrlPolicyOptions, basePath?: string): ValidationResult;
|
|
278
|
+
/**
|
|
279
|
+
* Validate an {@link Endpoint} input: structure, URL policy, and static-header
|
|
280
|
+
* restrictions (the Standard Webhooks headers are reserved).
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* import { validateEndpoint } from "@xtandard/webhooks";
|
|
285
|
+
*
|
|
286
|
+
* const result = validateEndpoint({ url: "https://api.example.com/hooks" });
|
|
287
|
+
* // result.valid === true
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
declare function validateEndpoint(input: unknown, options?: UrlPolicyOptions, basePath?: string): ValidationResult;
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/portal.d.ts
|
|
293
|
+
/** Prefix of every portal token. */
|
|
294
|
+
declare const PORTAL_TOKEN_PREFIX = "whpt_";
|
|
295
|
+
/**
|
|
296
|
+
* Thrown by {@link verifyPortalToken} for any invalid token — malformed,
|
|
297
|
+
* bad signature, or expired. Maps to HTTP 401 at the API layer.
|
|
298
|
+
*/
|
|
299
|
+
declare class PortalTokenError extends Error {
|
|
300
|
+
constructor(message: string);
|
|
301
|
+
}
|
|
302
|
+
/** Options for {@link createPortalToken}. */
|
|
303
|
+
interface PortalTokenOptions {
|
|
304
|
+
/** Token lifetime. Default `"7d"`. */
|
|
305
|
+
expiresIn?: WebhookDuration;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Mint a portal token granting access to `applicationKey` until `expiresIn`
|
|
309
|
+
* elapses (default 7 days). Call this **server-side** — anyone holding the
|
|
310
|
+
* portal secret can mint tokens for any application.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```ts
|
|
314
|
+
* import { createPortalToken } from "@xtandard/webhooks";
|
|
315
|
+
*
|
|
316
|
+
* // In the host app's session-guarded route:
|
|
317
|
+
* const token = await createPortalToken(process.env.PORTAL_SECRET!, "acme", {
|
|
318
|
+
* expiresIn: "1h",
|
|
319
|
+
* });
|
|
320
|
+
* // Hand `token` to the frontend for <WebhooksPortal token={token} />.
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
declare function createPortalToken(secret: string, applicationKey: string, options?: PortalTokenOptions): Promise<string>;
|
|
324
|
+
/**
|
|
325
|
+
* Verify a portal token: format, signature (constant time), then expiry.
|
|
326
|
+
* Returns the granted application key on success; throws
|
|
327
|
+
* {@link PortalTokenError} otherwise.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* import { verifyPortalToken } from "@xtandard/webhooks";
|
|
332
|
+
*
|
|
333
|
+
* const { applicationKey } = await verifyPortalToken(secret, token);
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
declare function verifyPortalToken(secret: string, token: string): Promise<{
|
|
337
|
+
applicationKey: string;
|
|
338
|
+
}>;
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/server/openapi.d.ts
|
|
341
|
+
/**
|
|
342
|
+
* OpenAPI 3.1 description of the admin JSON API.
|
|
343
|
+
*
|
|
344
|
+
* Exposed two ways, mirroring the flags panel:
|
|
345
|
+
* - served at `GET {basePath}/api/openapi.json` for standalone tools (Scalar,
|
|
346
|
+
* Swagger UI, Postman, codegen);
|
|
347
|
+
* - returned by `createFetchHandler(...).openapi()` so you can MERGE it into
|
|
348
|
+
* your host app's OpenAPI document (e.g. Elysia `@elysiajs/openapi`
|
|
349
|
+
* `references`, or Hono's OpenAPI).
|
|
350
|
+
*
|
|
351
|
+
* Hand-authored — no generation dependency (flags precedent).
|
|
352
|
+
*
|
|
353
|
+
* @module
|
|
354
|
+
*/
|
|
355
|
+
/** Options for {@link buildOpenApiDocument}. */
|
|
356
|
+
interface OpenApiOptions {
|
|
357
|
+
/** Mount prefix used in the `servers` url (e.g. `"/webhooks"`). */
|
|
358
|
+
basePath?: string;
|
|
359
|
+
/** Document title. */
|
|
360
|
+
title?: string;
|
|
361
|
+
/** Document version (defaults to the package's API version). */
|
|
362
|
+
version?: string;
|
|
363
|
+
}
|
|
364
|
+
/** Build the OpenAPI 3.1 document for the admin API. Pure — safe to call anywhere. */
|
|
365
|
+
declare function buildOpenApiDocument(options?: OpenApiOptions): Record<string, unknown>;
|
|
366
|
+
//#endregion
|
|
367
|
+
export { Actor, ActorOptions, type AfterEvent, type AfterEventType, Application, type AttemptDeliveryInput, type AttemptOutcome, AttemptTrigger, AuditAction, AuditEntry, type AuthProvider, type AuthorizationProvider, type AuthorizeInput, type BeforeEvent, type BeforeEventType, type BuildSignedRequestInput, ClaimInput, type CompareAndSwapWebhooksStorage, ConflictError, type CreateFetchHandlerResult, DEFAULT_ATTEMPT_TIMEOUT_MS, DEFAULT_PORTAL_ACTIONS, DEFAULT_RESPONSE_BODY_LIMIT, DEFAULT_RETRY_SCHEDULE, Delivery, DeliveryAttempt, type DeliveryErrorReporter, type DeliveryEvent, type DeliveryListener, type DeliveryQueueStorage, DeliveryStatus, type Dispatcher, type DispatcherOptions, Endpoint, EndpointDisabledReason, EndpointSecret, EventType, HookDeniedError, type HookErrorReporter, type IdPrefix, IdempotencyConflictError, JsonValue, KEY_REGEX, ListDeliveriesOptions, ListMessagesOptions, MUTATING_ACTIONS, Message, NotFoundError, type OpenApiOptions, PORTAL_TOKEN_PREFIX, PayloadTooLargeError, type PgNotificationClient, PortalTokenError, type PortalTokenOptions, type Principal, PublishInput, PublishResult, RESERVED_HEADERS, ReadonlyError, RecordAttemptInput, RecoverResult, RetentionOptions, RetentionRule, SCHEMA_VERSION, SECRET_PREFIX, SendExampleResult, type SignedRequest, type StorageChangeEvent, type TransactionalWebhooksStorage, type UrlPolicyOptions, VERSION, ValidationError, type ValidationIssue, type ValidationResult, type VerifyInput, type WatchSubscribe, type WatchableWebhooksStorage, WebhookDuration, WebhookEnvelope, WebhookVerificationError, type WebhooksAction, WebhooksCore, WebhooksCoreOptions, type WebhooksCorsOptions, type WebhooksHooks, type WebhooksHooksInput, type WebhooksPanelOptions, type WebhooksPortalOptions, type WebhooksResource, type WebhooksStorage, activeSecrets, assertValid, attemptDelivery, buildOpenApiDocument, buildSignedRequest, createDispatcher, createFetchHandler, createPortalToken, createWebhooksCore, defaultHookErrorReporter, durationToMs, emitDelivery, generateSecret, hasDeliveryQueue, idPattern, isCompareAndSwap, isMutatingAction, isTerminalDeliveryStatus, isTransactional, isWatchable, keys_d_exports as keys, newId, normalizeHooks, parseDurationList, pgListenNotify, requirePeer, runAfter, runBefore, sign, signatureHeader, validateApplication, validateEndpoint, validateEndpointUrl, validateEventType, verify, verifyPortalToken, withWatch };
|
|
368
|
+
//# sourceMappingURL=index.d.cts.map
|