@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.
- package/dist/bin/tangle-catalog-runtime.js +6 -2
- package/dist/bin/tangle-catalog-runtime.js.map +1 -1
- package/dist/catalog.d.ts +5 -1
- package/dist/catalog.js +6 -2
- package/dist/chunk-ATYHZXLL.js +457 -0
- package/dist/chunk-ATYHZXLL.js.map +1 -0
- package/dist/chunk-H4XYLS7T.js +75 -0
- package/dist/chunk-H4XYLS7T.js.map +1 -0
- package/dist/{chunk-GA4VTE3U.js → chunk-JU25UDN2.js} +5 -58
- package/dist/chunk-JU25UDN2.js.map +1 -0
- package/dist/chunk-P24T3MLM.js +106 -0
- package/dist/chunk-P24T3MLM.js.map +1 -0
- package/dist/chunk-SVQ4PHDZ.js +129 -0
- package/dist/chunk-SVQ4PHDZ.js.map +1 -0
- package/dist/{chunk-ALCIWTIR.js → chunk-UWRYFPJW.js} +41 -83
- package/dist/chunk-UWRYFPJW.js.map +1 -0
- package/dist/connect/index.d.ts +112 -0
- package/dist/connect/index.js +14 -0
- package/dist/connect/index.js.map +1 -0
- package/dist/connectors/adapters/index.d.ts +593 -1
- package/dist/connectors/adapters/index.js +15 -1
- package/dist/connectors/index.d.ts +2 -1
- package/dist/connectors/index.js +19 -5
- package/dist/errors-Bg3_rxnQ.d.ts +32 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +47 -9
- package/dist/middleware/index.d.ts +137 -0
- package/dist/middleware/index.js +14 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/registry.d.ts +29 -33
- package/dist/registry.js +6 -2
- package/dist/router-BncoovUh.d.ts +149 -0
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.js +6 -2
- package/dist/specs.d.ts +5 -1
- package/dist/stripe/index.d.ts +812 -0
- package/dist/stripe/index.js +866 -0
- package/dist/stripe/index.js.map +1 -0
- package/dist/tangle-catalog-runtime.d.ts +5 -1
- package/dist/tangle-catalog-runtime.js +6 -2
- package/dist/tangle-id-CTU4kGId.d.ts +553 -0
- package/dist/webhooks/index.d.ts +3 -148
- package/package.json +16 -1
- package/dist/chunk-ALCIWTIR.js.map +0 -1
- package/dist/chunk-GA4VTE3U.js.map +0 -1
- package/dist/index-D4D4CEKX.d.ts +0 -976
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
}
|
|
148
|
+
|
|
149
|
+
export { type SignatureVerification as S, type WebhookProvider as W, type WebhookEnvelope as a, type WebhookHeaders as b, type WebhookIdempotencyStore as c, WebhookRouter as d, type WebhookRouterOptions as e, type WebhookRouterRequest as f, type WebhookRouterResponse as g };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { f as InMemoryIntegrationGrantStore, g as IntegrationCapabilityBinding, h as IntegrationGrant, j as IntegrationGrantStore, k as IntegrationManifest, l as IntegrationManifestResolution, m as IntegrationRequirement, n as IntegrationRequirementMode, o as IntegrationRequirementResolution, q as IntegrationRequirementStatus, r as IntegrationRuntime, u as IntegrationRuntimeHub, v as IntegrationRuntimeOptions, w as IntegrationSandboxBundle, x as createIntegrationRuntime } from './registry.js';
|
|
2
|
-
import './
|
|
2
|
+
import './tangle-id-CTU4kGId.js';
|
|
3
|
+
import './errors-Bg3_rxnQ.js';
|
|
4
|
+
import './connect/index.js';
|
|
5
|
+
import './middleware/index.js';
|
|
3
6
|
import './connectors/index.js';
|
|
7
|
+
import './connectors/adapters/index.js';
|
|
4
8
|
import 'node:http';
|
package/dist/runtime.js
CHANGED
|
@@ -2,11 +2,15 @@ import {
|
|
|
2
2
|
InMemoryIntegrationGrantStore,
|
|
3
3
|
IntegrationRuntime,
|
|
4
4
|
createIntegrationRuntime
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UWRYFPJW.js";
|
|
6
|
+
import "./chunk-SVQ4PHDZ.js";
|
|
7
|
+
import "./chunk-H4XYLS7T.js";
|
|
6
8
|
import "./chunk-4JQ754PA.js";
|
|
7
9
|
import "./chunk-376UBTNB.js";
|
|
8
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-JU25UDN2.js";
|
|
9
11
|
import "./chunk-2TW2QKGZ.js";
|
|
12
|
+
import "./chunk-P24T3MLM.js";
|
|
13
|
+
import "./chunk-ATYHZXLL.js";
|
|
10
14
|
export {
|
|
11
15
|
InMemoryIntegrationGrantStore,
|
|
12
16
|
IntegrationRuntime,
|
package/dist/specs.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { U as ApiKeyAuthSpec, V as ConsoleStep, W as CredentialFieldSpec, X as CredentialValidationInput, Y as CredentialValidationResult, Z as CustomAuthSpec, _ as HealthcheckPlan, $ as HealthcheckSpec, a0 as HmacAuthSpec, a1 as INTEGRATION_FAMILIES, a2 as IntegrationAuthMode, a3 as IntegrationAuthSpec, a4 as IntegrationFamilyId, a5 as IntegrationFamilySpec, a6 as IntegrationLifecycleSpec, a7 as IntegrationPlannerHints, a8 as IntegrationSetupSpec, a9 as IntegrationSpec, aa as IntegrationSpecStatus, ab as IntegrationSpecValidationIssue, ac as IntegrationSpecValidationResult, ad as NoneAuthSpec, ae as NormalizedPermission, af as OAuth2AuthSpec, ag as PermissionDescriptor, ah as PostSetupCheck, ai as Quirk, aj as RenderSpecOptions, ak as RenderedConsoleStep, al as ScopeDescriptor, am as assertValidIntegrationSpec, an as buildHealthcheckPlan, ao as consoleStepsToText, ap as getIntegrationFamily, aq as getIntegrationSpec, ar as integrationSpecToConnector, as as listExecutableIntegrationSpecs, at as listIntegrationSpecs, au as renderAgentToolDescription, av as renderConsoleSteps, aw as renderRunbookMarkdown, ax as specAuthToConnectorAuth, ay as validateCredentialFormat, az as validateCredentialSet, aA as validateIntegrationSpec } from './registry.js';
|
|
2
|
-
import './
|
|
2
|
+
import './tangle-id-CTU4kGId.js';
|
|
3
|
+
import './errors-Bg3_rxnQ.js';
|
|
4
|
+
import './connect/index.js';
|
|
5
|
+
import './middleware/index.js';
|
|
3
6
|
import './connectors/index.js';
|
|
7
|
+
import './connectors/adapters/index.js';
|
|
4
8
|
import 'node:http';
|