@tangle-network/agent-integrations 0.26.0 → 0.28.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.
Files changed (46) hide show
  1. package/dist/bin/tangle-catalog-runtime.js +6 -2
  2. package/dist/bin/tangle-catalog-runtime.js.map +1 -1
  3. package/dist/catalog.d.ts +5 -1
  4. package/dist/catalog.js +6 -2
  5. package/dist/chunk-ATYHZXLL.js +457 -0
  6. package/dist/chunk-ATYHZXLL.js.map +1 -0
  7. package/dist/chunk-H4XYLS7T.js +75 -0
  8. package/dist/chunk-H4XYLS7T.js.map +1 -0
  9. package/dist/{chunk-GA4VTE3U.js → chunk-JU25UDN2.js} +5 -58
  10. package/dist/chunk-JU25UDN2.js.map +1 -0
  11. package/dist/chunk-P24T3MLM.js +106 -0
  12. package/dist/chunk-P24T3MLM.js.map +1 -0
  13. package/dist/chunk-SVQ4PHDZ.js +129 -0
  14. package/dist/chunk-SVQ4PHDZ.js.map +1 -0
  15. package/dist/{chunk-ALCIWTIR.js → chunk-UWRYFPJW.js} +41 -83
  16. package/dist/chunk-UWRYFPJW.js.map +1 -0
  17. package/dist/connect/index.d.ts +112 -0
  18. package/dist/connect/index.js +14 -0
  19. package/dist/connect/index.js.map +1 -0
  20. package/dist/connectors/adapters/index.d.ts +593 -1
  21. package/dist/connectors/adapters/index.js +15 -1
  22. package/dist/connectors/index.d.ts +2 -1
  23. package/dist/connectors/index.js +19 -5
  24. package/dist/errors-Bg3_rxnQ.d.ts +32 -0
  25. package/dist/index.d.ts +6 -2
  26. package/dist/index.js +47 -9
  27. package/dist/middleware/index.d.ts +137 -0
  28. package/dist/middleware/index.js +14 -0
  29. package/dist/middleware/index.js.map +1 -0
  30. package/dist/registry.d.ts +29 -33
  31. package/dist/registry.js +6 -2
  32. package/dist/router-BncoovUh.d.ts +149 -0
  33. package/dist/runtime.d.ts +5 -1
  34. package/dist/runtime.js +6 -2
  35. package/dist/specs.d.ts +5 -1
  36. package/dist/stripe/index.d.ts +812 -0
  37. package/dist/stripe/index.js +866 -0
  38. package/dist/stripe/index.js.map +1 -0
  39. package/dist/tangle-catalog-runtime.d.ts +5 -1
  40. package/dist/tangle-catalog-runtime.js +6 -2
  41. package/dist/tangle-id-CTU4kGId.d.ts +553 -0
  42. package/dist/webhooks/index.d.ts +3 -148
  43. package/package.json +16 -1
  44. package/dist/chunk-ALCIWTIR.js.map +0 -1
  45. package/dist/chunk-GA4VTE3U.js.map +0 -1
  46. package/dist/index-D4D4CEKX.d.ts +0 -976
@@ -1,150 +1,5 @@
1
- /**
2
- * @stable Provider-agnostic inbound webhook router.
3
- *
4
- * Consumer hooks a single HTTP handler at `/webhook/:provider/:event`
5
- * (or whatever pathing they prefer) and forwards the request through
6
- * `WebhookRouter.handle()`. The router:
7
- *
8
- * 1. Resolves the registered provider entry.
9
- * 2. Calls the provider's `verifySignature(rawBody, headers, secrets)`.
10
- * Failure → 401 fast, no downstream work.
11
- * 3. Calls the provider's `parse(rawBody, headers)` to extract zero or
12
- * more normalized events.
13
- * 4. Enqueues each event for async processing via the consumer-supplied
14
- * `deliver(event)` callback (best-effort fire-and-forget — the
15
- * router does NOT block the HTTP response on the consumer's work).
16
- * 5. Returns 200 fast with `{received: events.length}`.
17
- *
18
- * Replay protection: providers that sign timestamps (Stripe, Slack)
19
- * already reject stale signatures inside `verifySignature`. For providers
20
- * that don't (DocuSeal, GDrive push), the router exposes a pluggable
21
- * `idempotency` hook: if `idempotency.seen(providerEventId)` returns
22
- * true, the router 200s without invoking `deliver()`. Consumers wire
23
- * this to a durable kv (D1 / Redis / Postgres unique-index).
24
- *
25
- * Why a router and not a per-provider express app: the runtime contract
26
- * a product cares about is "an inbound event came in, here's the
27
- * normalized envelope". Verification, parsing, and idempotency-dedup
28
- * are mechanical and provider-specific — the router owns them. The
29
- * consumer's `deliver()` is the only place product logic runs.
30
- *
31
- * Stability: `@stable` — additions to `WebhookEnvelope` must be
32
- * additive; the router's HTTP contract (paths, status codes) is frozen
33
- * at 200 (ok), 400 (bad request), 401 (bad signature), 404 (unknown
34
- * provider), 405 (provider has no inbound surface).
35
- */
36
- interface WebhookHeaders {
37
- [name: string]: string | string[] | undefined;
38
- }
39
- /** Normalized inbound event the router emits after parsing. */
40
- interface WebhookEnvelope<TPayload = unknown> {
41
- /** Provider id (matches the `:provider` path segment). */
42
- provider: string;
43
- /** Optional event class — e.g., 'customer.subscription.deleted'. The
44
- * provider's parser decides. Used for routing inside `deliver()`. */
45
- eventType: string;
46
- /** Provider-emitted event id, when present. Used for the idempotency
47
- * short-circuit. */
48
- providerEventId?: string;
49
- /** Wall-clock receive time. */
50
- receivedAt: number;
51
- /** Provider payload, normalized to the provider's documented event
52
- * shape. The router does NOT reshape this — `parse()` is the contract. */
53
- payload: TPayload;
54
- /** Headers passed through for downstream handlers that want them
55
- * (e.g., to extract custom routing metadata). Always lowercased keys. */
56
- headers: Record<string, string>;
57
- }
58
- type SignatureVerification = {
59
- valid: true;
60
- } | {
61
- valid: false;
62
- reason: string;
63
- };
64
- /** Per-provider plug-in. Stateless — the router calls `verifySignature`
65
- * then `parse` on every request. The provider's HTTP-shape concerns
66
- * (e.g., raw body required) are documented per provider. */
67
- interface WebhookProvider {
68
- /** Stable provider id (`stripe`, `docuseal`, `gdrive`, ...). */
69
- id: string;
70
- /** Verify the inbound signature. Receives the EXACT raw body string —
71
- * consumers MUST preserve raw bytes through their HTTP server (do not
72
- * parse JSON before forwarding here). */
73
- verifySignature(input: {
74
- rawBody: string;
75
- headers: WebhookHeaders;
76
- secret: string;
77
- }): SignatureVerification;
78
- /** Parse the validated raw body into zero or more normalized events.
79
- * A single push payload may carry multiple events (e.g., Slack bulk
80
- * delivery). Return [] to ack the push as a no-op. */
81
- parse(input: {
82
- rawBody: string;
83
- headers: WebhookHeaders;
84
- now?: number;
85
- }): WebhookEnvelope[] | Promise<WebhookEnvelope[]>;
86
- }
87
- interface WebhookIdempotencyStore {
88
- /** Returns true if this providerEventId has been processed already.
89
- * Implementations should be O(1) (Redis SETNX, D1 UNIQUE constraint). */
90
- seen(providerEventId: string): Promise<boolean> | boolean;
91
- /** Marks a providerEventId as processed. Called AFTER `deliver()` has
92
- * been invoked. */
93
- remember(providerEventId: string, ttlMs: number): Promise<void> | void;
94
- }
95
- interface WebhookRouterOptions {
96
- /** Provider registry. Pass any number of providers; routing is by id. */
97
- providers: WebhookProvider[];
98
- /** Async callback invoked with every accepted event. Fire-and-forget
99
- * from the router's perspective — the HTTP response is sent before
100
- * this resolves. Throws are caught and reported via `onError`. */
101
- deliver(event: WebhookEnvelope): Promise<void> | void;
102
- /** Resolve the signing secret for a provider id at request time. The
103
- * router never holds secrets — the consumer's vault resolves them. */
104
- resolveSecret(providerId: string, headers: WebhookHeaders): Promise<string | null> | string | null;
105
- /** Optional idempotency-dedup hook. Required for providers that don't
106
- * sign timestamps in their signature scheme (DocuSeal, Drive push). */
107
- idempotency?: WebhookIdempotencyStore;
108
- /** TTL on idempotency entries. Default 7 days — long enough that a
109
- * provider's normal retry-window can't re-deliver. */
110
- idempotencyTtlMs?: number;
111
- /** Surface delivery errors. Default: console.error. */
112
- onError?(err: unknown, context: {
113
- provider: string;
114
- eventType?: string;
115
- providerEventId?: string;
116
- }): void;
117
- /** Override `now()` for tests. */
118
- now?(): number;
119
- }
120
- interface WebhookRouterRequest {
121
- providerId: string;
122
- rawBody: string;
123
- headers: WebhookHeaders;
124
- }
125
- interface WebhookRouterResponse {
126
- status: number;
127
- body: unknown;
128
- headers?: Record<string, string>;
129
- }
130
- /**
131
- * Router instance. Stateless aside from the provider registry — safe to
132
- * share across requests; build once per process.
133
- */
134
- declare class WebhookRouter {
135
- private readonly providers;
136
- private readonly deliver;
137
- private readonly resolveSecret;
138
- private readonly idempotency?;
139
- private readonly idempotencyTtlMs;
140
- private readonly onError;
141
- private readonly nowFn;
142
- constructor(opts: WebhookRouterOptions);
143
- /** Process one inbound webhook request. Pure with respect to side-
144
- * effects on the router instance — safe to call concurrently. */
145
- handle(request: WebhookRouterRequest): Promise<WebhookRouterResponse>;
146
- private deliverEach;
147
- }
1
+ import { W as WebhookProvider } from '../router-BncoovUh.js';
2
+ export { S as SignatureVerification, a as WebhookEnvelope, b as WebhookHeaders, c as WebhookIdempotencyStore, d as WebhookRouter, e as WebhookRouterOptions, f as WebhookRouterRequest, g as WebhookRouterResponse } from '../router-BncoovUh.js';
148
3
 
149
4
  /**
150
5
  * Pre-built `WebhookProvider` implementations for the inbound surfaces
@@ -190,4 +45,4 @@ declare function genericHmacWebhookProvider(options: {
190
45
  parse?: WebhookProvider['parse'];
191
46
  }): WebhookProvider;
192
47
 
193
- export { type SignatureVerification, type WebhookEnvelope, type WebhookHeaders, type WebhookIdempotencyStore, type WebhookProvider, WebhookRouter, type WebhookRouterOptions, type WebhookRouterRequest, type WebhookRouterResponse, docusealWebhookProvider, gdriveWebhookProvider, genericHmacWebhookProvider, gmailWebhookProvider, slackWebhookProvider, stripeWebhookProvider };
48
+ export { WebhookProvider, docusealWebhookProvider, gdriveWebhookProvider, genericHmacWebhookProvider, gmailWebhookProvider, slackWebhookProvider, stripeWebhookProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-integrations",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Vendor-neutral integration contracts and runtime helpers for sandbox and agent apps.",
5
5
  "homepage": "https://github.com/tangle-network/agent-integrations#readme",
6
6
  "repository": {
@@ -34,6 +34,16 @@
34
34
  "import": "./dist/connectors/adapters/index.js",
35
35
  "default": "./dist/connectors/adapters/index.js"
36
36
  },
37
+ "./connect": {
38
+ "types": "./dist/connect/index.d.ts",
39
+ "import": "./dist/connect/index.js",
40
+ "default": "./dist/connect/index.js"
41
+ },
42
+ "./middleware": {
43
+ "types": "./dist/middleware/index.d.ts",
44
+ "import": "./dist/middleware/index.js",
45
+ "default": "./dist/middleware/index.js"
46
+ },
37
47
  "./webhooks": {
38
48
  "types": "./dist/webhooks/index.d.ts",
39
49
  "import": "./dist/webhooks/index.js",
@@ -54,6 +64,11 @@
54
64
  "import": "./dist/specs.js",
55
65
  "default": "./dist/specs.js"
56
66
  },
67
+ "./stripe": {
68
+ "types": "./dist/stripe/index.d.ts",
69
+ "import": "./dist/stripe/index.js",
70
+ "default": "./dist/stripe/index.js"
71
+ },
57
72
  "./tangle-catalog-runtime": {
58
73
  "types": "./dist/tangle-catalog-runtime.d.ts",
59
74
  "import": "./dist/tangle-catalog-runtime.js",