@tangle-network/agent-integrations 0.25.7 → 0.26.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/README.md +11 -2
- package/dist/bin/tangle-catalog-runtime.js +3 -2
- package/dist/bin/tangle-catalog-runtime.js.map +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +3 -2
- package/dist/chunk-2TW2QKGZ.js +94 -0
- package/dist/chunk-2TW2QKGZ.js.map +1 -0
- package/dist/{chunk-A5I3EYU5.js → chunk-ALCIWTIR.js} +96 -1
- package/dist/chunk-ALCIWTIR.js.map +1 -0
- package/dist/{chunk-WC63AI4Q.js → chunk-GA4VTE3U.js} +1249 -169
- package/dist/chunk-GA4VTE3U.js.map +1 -0
- package/dist/connectors/adapters/index.d.ts +1 -1
- package/dist/connectors/adapters/index.js +8 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +14 -6
- package/dist/{index-BQY5ry2s.d.ts → index-D4D4CEKX.d.ts} +177 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -7
- package/dist/registry.d.ts +139 -2
- package/dist/registry.js +3 -2
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +3 -2
- package/dist/specs.d.ts +1 -1
- package/dist/tangle-catalog-runtime.d.ts +1 -1
- package/dist/tangle-catalog-runtime.js +3 -2
- package/dist/webhooks/index.d.ts +193 -0
- package/dist/webhooks/index.js +285 -0
- package/dist/webhooks/index.js.map +1 -0
- package/examples/discover-capabilities.ts +46 -0
- package/examples/webhook-router.ts +56 -0
- package/package.json +15 -12
- package/dist/chunk-A5I3EYU5.js.map +0 -1
- package/dist/chunk-WC63AI4Q.js.map +0 -1
package/dist/registry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ConnectorAdapter, R as ResolvedDataSource, a as ConnectorCredentials } from './index-
|
|
1
|
+
import { C as ConnectorAdapter, R as ResolvedDataSource, a as ConnectorCredentials } from './index-D4D4CEKX.js';
|
|
2
2
|
import './connectors/index.js';
|
|
3
3
|
import { Server, IncomingMessage, ServerResponse } from 'node:http';
|
|
4
4
|
|
|
@@ -512,6 +512,143 @@ declare function revokeConnection(input: {
|
|
|
512
512
|
now?: () => Date;
|
|
513
513
|
}): Promise<IntegrationConnection>;
|
|
514
514
|
|
|
515
|
+
/**
|
|
516
|
+
* Workspace capability discovery — answers "what can this workspace do?"
|
|
517
|
+
* with a typed list of MCP-shape tool descriptors that the agent runtime
|
|
518
|
+
* can flatten into a planner's tool registry.
|
|
519
|
+
*
|
|
520
|
+
* The agent runtime's gating question is one level above the existing
|
|
521
|
+
* connector catalog ("which integrations exist?") and one level below
|
|
522
|
+
* the issued capability-token surface ("temporarily delegate scope X
|
|
523
|
+
* via this signed token"). This module bridges the two:
|
|
524
|
+
*
|
|
525
|
+
* discoverWorkspaceCapabilities({ owner, connectors, connections, scopes })
|
|
526
|
+
* → WorkspaceCapability[]
|
|
527
|
+
*
|
|
528
|
+
* A `WorkspaceCapability` is hand-shaped to be cheap to emit alongside a
|
|
529
|
+
* connector manifest and trivial to render into:
|
|
530
|
+
* - an LLM tool-choice JSON array
|
|
531
|
+
* - an MCP `tools/list` response
|
|
532
|
+
* - a UI surface ("Connect Gmail to enable: send_reply, list_messages…")
|
|
533
|
+
*
|
|
534
|
+
* What this is NOT:
|
|
535
|
+
* - A capability-token issuer. That stays in IntegrationHub.issueCapability.
|
|
536
|
+
* - A connector registry. That stays in IntegrationRegistry / catalog.
|
|
537
|
+
*
|
|
538
|
+
* Scopes are the load-bearing input: a connector advertises N actions,
|
|
539
|
+
* but only the subset whose `requiredScopes` are a subset of the
|
|
540
|
+
* connection's `grantedScopes` is reachable. The discovery function
|
|
541
|
+
* filters on that automatically.
|
|
542
|
+
*
|
|
543
|
+
* Stability: `@stable` — additions to WorkspaceCapability must be
|
|
544
|
+
* additive and non-breaking.
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
/** MCP-shape tool descriptor. Mirrors the
|
|
548
|
+
* [Model Context Protocol tool schema](https://modelcontextprotocol.io/specification)
|
|
549
|
+
* closely enough that consumers can pipe a WorkspaceCapability straight
|
|
550
|
+
* into a `tools/list` response. */
|
|
551
|
+
interface WorkspaceToolSchema {
|
|
552
|
+
name: string;
|
|
553
|
+
description?: string;
|
|
554
|
+
/** JSON-schema describing the action's input. */
|
|
555
|
+
inputSchema?: unknown;
|
|
556
|
+
/** Optional JSON-schema describing the action's output. */
|
|
557
|
+
outputSchema?: unknown;
|
|
558
|
+
}
|
|
559
|
+
/** One discoverable capability — an action a connector exposes that the
|
|
560
|
+
* workspace has the connection + scopes to invoke. */
|
|
561
|
+
interface WorkspaceCapability {
|
|
562
|
+
/** Stable, fully-qualified id. Format `<connector-id>.<action-id>`. */
|
|
563
|
+
id: string;
|
|
564
|
+
/** Human label safe for UI. */
|
|
565
|
+
title: string;
|
|
566
|
+
/** Optional one-line description. */
|
|
567
|
+
description?: string;
|
|
568
|
+
/** Connector category for grouping. */
|
|
569
|
+
category: IntegrationConnectorCategory;
|
|
570
|
+
/** Connector that hosts this capability. */
|
|
571
|
+
connectorId: string;
|
|
572
|
+
/** Provider that hosts this connector (first-party, gateway, …). */
|
|
573
|
+
providerId: string;
|
|
574
|
+
/** Underlying action id on the connector. */
|
|
575
|
+
actionId: string;
|
|
576
|
+
/** Scopes required to invoke. The discovery function only returns
|
|
577
|
+
* capabilities whose required scopes are a subset of the connection's
|
|
578
|
+
* grantedScopes. */
|
|
579
|
+
scopes: string[];
|
|
580
|
+
/** Risk class — useful for UI ("write" / "destructive" lights). */
|
|
581
|
+
risk: IntegrationActionRisk;
|
|
582
|
+
/** Data class of the action's output, when known. */
|
|
583
|
+
dataClass: IntegrationDataClass;
|
|
584
|
+
/** MCP-shape tool schema the agent runtime can register directly. */
|
|
585
|
+
toolSchema: WorkspaceToolSchema;
|
|
586
|
+
/** True iff the workspace has an active connection backing this
|
|
587
|
+
* capability. False capabilities (advertised by the connector but
|
|
588
|
+
* not yet connected) are included when `includeUnconnected: true`
|
|
589
|
+
* is passed — useful for "connect to unlock" UI affordances. */
|
|
590
|
+
connected: boolean;
|
|
591
|
+
/** Connection id backing this capability. Undefined when
|
|
592
|
+
* `connected: false`. */
|
|
593
|
+
connectionId?: string;
|
|
594
|
+
/** Whether the action requires explicit approval before invocation. */
|
|
595
|
+
approvalRequired?: boolean;
|
|
596
|
+
}
|
|
597
|
+
/** Optional inbound trigger surface. Same shape as a capability so the
|
|
598
|
+
* consumer can render both with one component. */
|
|
599
|
+
interface WorkspaceTrigger {
|
|
600
|
+
id: string;
|
|
601
|
+
title: string;
|
|
602
|
+
description?: string;
|
|
603
|
+
category: IntegrationConnectorCategory;
|
|
604
|
+
connectorId: string;
|
|
605
|
+
providerId: string;
|
|
606
|
+
triggerId: string;
|
|
607
|
+
scopes: string[];
|
|
608
|
+
dataClass: IntegrationDataClass;
|
|
609
|
+
connected: boolean;
|
|
610
|
+
connectionId?: string;
|
|
611
|
+
}
|
|
612
|
+
interface DiscoverWorkspaceCapabilitiesInput {
|
|
613
|
+
/** Workspace owner. Used to scope the connection lookup when `store`
|
|
614
|
+
* is supplied (the canonical production path). */
|
|
615
|
+
owner: IntegrationActor;
|
|
616
|
+
/** Either an explicit connection list (test/fixture path) or a store
|
|
617
|
+
* the function should query for connections by owner. Exactly one
|
|
618
|
+
* of `connections` / `store` MUST be provided. */
|
|
619
|
+
connections?: IntegrationConnection[];
|
|
620
|
+
store?: IntegrationConnectionStore;
|
|
621
|
+
/** Either an explicit connector list (test/fixture path) or a set of
|
|
622
|
+
* providers the function should query via `listConnectors()`. */
|
|
623
|
+
connectors?: IntegrationConnector[];
|
|
624
|
+
providers?: IntegrationProvider[];
|
|
625
|
+
/** Include capabilities whose connector is in the catalog but the
|
|
626
|
+
* workspace has no active connection for. Useful to render
|
|
627
|
+
* "connect to unlock" affordances. Default: false. */
|
|
628
|
+
includeUnconnected?: boolean;
|
|
629
|
+
/** When true, include capabilities even if some required scopes are
|
|
630
|
+
* missing from the connection grant. The default `false` hides such
|
|
631
|
+
* capabilities — the agent runtime never sees them. */
|
|
632
|
+
includeMissingScopes?: boolean;
|
|
633
|
+
}
|
|
634
|
+
interface WorkspaceCapabilityDiscovery {
|
|
635
|
+
capabilities: WorkspaceCapability[];
|
|
636
|
+
triggers: WorkspaceTrigger[];
|
|
637
|
+
/** Counts grouped by connector for telemetry / UI badges. */
|
|
638
|
+
countsByConnector: Record<string, number>;
|
|
639
|
+
/** Connectors the workspace is connected to but the planner cannot
|
|
640
|
+
* reach any actions on (e.g., zero scopes granted, or all actions
|
|
641
|
+
* require an additional scope). */
|
|
642
|
+
unreachableConnectors: Array<{
|
|
643
|
+
connectorId: string;
|
|
644
|
+
reason: string;
|
|
645
|
+
}>;
|
|
646
|
+
}
|
|
647
|
+
/** Resolve workspace-visible capabilities + triggers. Pure with respect
|
|
648
|
+
* to the inputs — caller decides whether to back `connections` and
|
|
649
|
+
* `connectors` with persistent state or static fixtures. */
|
|
650
|
+
declare function discoverWorkspaceCapabilities(input: DiscoverWorkspaceCapabilitiesInput): Promise<WorkspaceCapabilityDiscovery>;
|
|
651
|
+
|
|
515
652
|
type IntegrationErrorCode = 'missing_connection' | 'missing_grant' | 'approval_required' | 'approval_denied' | 'connection_revoked' | 'connection_expired' | 'scope_missing' | 'action_denied' | 'action_not_found' | 'trigger_not_found' | 'provider_rate_limited' | 'provider_auth_failed' | 'provider_unavailable' | 'provider_error' | 'capability_expired' | 'capability_invalid' | 'manifest_invalid' | 'passthrough_disabled' | 'input_invalid' | 'unknown';
|
|
516
653
|
interface IntegrationUserAction {
|
|
517
654
|
type: 'connect' | 'reconnect' | 'approve' | 'retry' | 'contact_support' | 'change_request';
|
|
@@ -1999,4 +2136,4 @@ declare function createHttpIntegrationProvider(options: HttpIntegrationProviderO
|
|
|
1999
2136
|
declare function signCapability(capability: IntegrationCapability, secret: string): string;
|
|
2000
2137
|
declare function verifyCapabilityToken(token: string, secret: string): IntegrationCapability;
|
|
2001
2138
|
|
|
2002
|
-
export { type HealthcheckSpec as $, type TangleCatalogHttpAuthResolverRequest as A, type TangleCatalogInstalledPackageExecutorOptions as B, type TangleCatalogRuntimeHandlerOptions as C, type ComposeIntegrationRegistryOptions, type TangleCatalogRuntimeHttpRequest as D, type TangleCatalogRuntimeHttpResponse as E, type TangleCatalogRuntimeInvocation as F, type TangleCatalogRuntimeModuleAction as G, type TangleCatalogRuntimePackageCoverageOptions as H, type IntegrationCatalogView as I, type IntegrationCatalogSource, type IntegrationRegistry, type IntegrationRegistryConflict, type IntegrationRegistryEntry, type IntegrationRegistrySourceRef, type IntegrationRegistrySummary, type IntegrationSupportTier, type TangleCatalogRuntimePackageCoverageRow as J, auditTangleCatalogRuntimePackages as K, createTangleCatalogCredentialAuthResolver as L, type McpToolDefinition as M, createTangleCatalogHttpAuthResolver as N, createTangleCatalogInstalledPackageExecutor as O, createTangleCatalogRuntimeHandler as P, signTangleCatalogRuntimeRequest as Q, tangleCatalogAuthValue as R, verifyTangleCatalogRuntimeSignature as S, TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER as T, type ApiKeyAuthSpec as U, type ConsoleStep as V, type CredentialFieldSpec as W, type CredentialValidationInput as X, type CredentialValidationResult as Y, type CustomAuthSpec as Z, type HealthcheckPlan as _, type IntegrationToolDefinition as a, type GatewayCatalogTrigger as a$, type HmacAuthSpec as a0, INTEGRATION_FAMILIES as a1, type IntegrationAuthMode as a2, type IntegrationAuthSpec as a3, type IntegrationFamilyId as a4, type IntegrationFamilySpec as a5, type IntegrationLifecycleSpec as a6, type IntegrationPlannerHints as a7, type IntegrationSetupSpec as a8, type IntegrationSpec as a9, validateIntegrationSpec as aA, ACTIVEPIECES_OVERRIDES as aB, ACTIVEPIECES_PUBLIC_CATALOG_URL as aC, ACTIVEPIECES_RUNTIME_SIGNATURE_HEADER as aD, type ActivepiecesCatalogAuthField as aE, type ActivepiecesCatalogEntry as aF, type ActivepiecesExecutorInvocation as aG, type ActivepiecesExecutorProviderOptions as aH, type ActivepiecesHttpExecutorOptions as aI, type ActivepiecesPieceOverride as aJ, type ActivepiecesRuntimeRequest as aK, ApprovalBackedPolicyEngine as aL, type ApprovalBackedPolicyOptions as aM, CANONICAL_INTEGRATION_ACTIONS as aN, type CanonicalIntegrationActionId as aO, type CanonicalLaunchConnectorOptions as aP, type CatalogExecutorInvocation as aQ, type CatalogExecutorProviderOptions as aR, type CompleteAuthRequest as aS, type ConnectionCredentialResolverOptions as aT, type ConnectorAdapterProviderOptions as aU, type ConsentSummary as aV, DEFAULT_INTEGRATION_BRIDGE_ENV as aW, DefaultIntegrationActionGuard as aX, type GatewayCatalogAction as aY, type GatewayCatalogEntry as aZ, type GatewayCatalogProviderOptions as a_, type IntegrationSpecStatus as aa, type IntegrationSpecValidationIssue as ab, type IntegrationSpecValidationResult as ac, type NoneAuthSpec as ad, type NormalizedPermission as ae, type OAuth2AuthSpec as af, type PermissionDescriptor as ag, type PostSetupCheck as ah, type Quirk as ai, type RenderSpecOptions as aj, type RenderedConsoleStep as ak, type ScopeDescriptor as al, assertValidIntegrationSpec as am, buildHealthcheckPlan as an, consoleStepsToText as ao, getIntegrationFamily as ap, getIntegrationSpec as aq, integrationSpecToConnector as ar, listExecutableIntegrationSpecs as as, listIntegrationSpecs as at, renderAgentToolDescription as au, renderConsoleSteps as av, renderRunbookMarkdown as aw, specAuthToConnectorAuth as ax, validateCredentialFormat as ay, validateCredentialSet as az, type IntegrationToolSearchFilters as b, type IntegrationProviderKind as b$, type GraphqlOperationSpec as b0, type HttpIntegrationProviderOptions as b1, type ImportCatalogOptions as b2, InMemoryConnectionStore as b3, InMemoryIntegrationApprovalStore as b4, InMemoryIntegrationAuditStore as b5, InMemoryIntegrationEventStore as b6, InMemoryIntegrationHealthcheckStore as b7, InMemoryIntegrationIdempotencyStore as b8, InMemoryIntegrationSecretStore as b9, type IntegrationConnectionStore as bA, type IntegrationConnector as bB, type IntegrationConnectorAction as bC, type IntegrationConnectorCategory as bD, type IntegrationConnectorTrigger as bE, type IntegrationCoveragePriority as bF, type IntegrationCoverageSpec as bG, type IntegrationDataClass as bH, IntegrationError as bI, type IntegrationErrorCode as bJ, type IntegrationEventStore as bK, type IntegrationGuardContext as bL, type IntegrationHealthcheckCheck as bM, type IntegrationHealthcheckResult as bN, type IntegrationHealthcheckStatus as bO, type IntegrationHealthcheckStore as bP, IntegrationHub as bQ, type IntegrationHubOptions as bR, type IntegrationIdempotencyRecord as bS, type IntegrationIdempotencyStore as bT, type IntegrationInvocationEnvelope as bU, type IntegrationInvocationEnvelopeValidationOptions as bV, type IntegrationPolicyDecision as bW, type IntegrationPolicyEffect as bX, type IntegrationPolicyEngine as bY, type IntegrationPolicyRule as bZ, type IntegrationProvider as b_, InMemoryIntegrationWorkflowStore as ba, type InferIntegrationRequirementsOptions as bb, type InstalledIntegrationWorkflow as bc, type IntegrationActionGuard as bd, type IntegrationActionPack as be, type IntegrationActionRequest as bf, type IntegrationActionResult as bg, type IntegrationActionRisk as bh, type IntegrationActor as bi, type IntegrationApprovalFilter as bj, type IntegrationApprovalRecord as bk, type IntegrationApprovalRequest as bl, type IntegrationApprovalResolution as bm, type IntegrationApprovalStatus as bn, type IntegrationApprovalStore as bo, type IntegrationAuditEvent as bp, type IntegrationAuditEventType as bq, type IntegrationAuditFilter as br, type IntegrationAuditSink as bs, type IntegrationAuditStore as bt, type IntegrationBridgePayload as bu, buildDefaultIntegrationRegistry, type IntegrationBridgeToolBinding as bv, type IntegrationCapability as bw, type IntegrationCatalogFreshnessOptions as bx, type IntegrationCatalogFreshnessResult as by, type IntegrationConnection as bz, type IntegrationToolSearchResult as c, adapterManifestsToConnectors as c$, type IntegrationRateLimitDecision as c0, type IntegrationRateLimiter as c1, IntegrationRuntimeError as c2, IntegrationSandboxHost as c3, type IntegrationSandboxHostHub as c4, type IntegrationSandboxHostOptions as c5, type IntegrationSecretStore as c6, type IntegrationTriggerEvent as c7, type IntegrationTriggerSubscription as c8, type IntegrationUserAction as c9, type StartedTangleCatalogRuntimeNodeServer as cA, StaticIntegrationPolicyEngine as cB, type StaticIntegrationPolicyOptions as cC, type StoredIntegrationEvent as cD, TANGLE_INTEGRATIONS_CATALOG_PROVIDER_ID as cE, TANGLE_INTEGRATIONS_CATALOG_SOURCE as cF, type TangleCatalogExecutorInvocation as cG, type TangleCatalogExecutorProviderOptions as cH, type TangleCatalogHttpExecutorInvocation as cI, type TangleCatalogHttpExecutorOptions as cJ, type TangleCatalogRuntimeActionRequest as cK, type TangleCatalogRuntimeNodeServerOptions as cL, type TangleCatalogRuntimePackageManifest as cM, type TangleCatalogRuntimePackageManifestOptions as cN, type TangleCatalogRuntimePiece as cO, type TangleCatalogRuntimeRequest as cP, type TangleCatalogTriggerInvocation as cQ, type TangleIntegrationCatalogEntry as cR, type TangleIntegrationCatalogFreshnessOptions as cS, type TangleIntegrationCatalogFreshnessResult as cT, type TangleIntegrationContract as cU, type TangleIntegrationContractStatus as cV, type TangleIntegrationImplementationKind as cW, type TangleIntegrationInvokeInput as cX, type TangleIntegrationInvokeResult as cY, TangleIntegrationsClient as cZ, type TangleIntegrationsClientOptions as c_, type IntegrationWebhookReceiverResult as ca, canonicalConnectorId, type IntegrationWorkflowDefinition as cb, IntegrationWorkflowRuntime as cc, type IntegrationWorkflowRuntimeHub as cd, type IntegrationWorkflowRuntimeOptions as ce, type IntegrationWorkflowStore as cf, type InvokeWithCapabilityRequest as cg, type IssueCapabilityRequest as ch, type IssuedIntegrationCapability as ci, type ManifestValidationIssue as cj, type ManifestValidationResult as ck, type McpCatalog as cl, type McpCatalogTool as cm, type MissingRequirementExplanation as cn, type NormalizedIntegrationError as co, composeIntegrationRegistry, type NormalizedIntegrationResult as cp, type OpenApiDocument as cq, type OpenApiOperation as cr, PROVIDER_PASSTHROUGH_ACTION as cs, type PlatformIntegrationPolicyPresetOptions as ct, type ProviderHttpRequestInput as cu, type ProviderPassthroughPolicy as cv, type RenderConsentOptions as cw, type SecretRef as cx, type StartAuthRequest as cy, type StartAuthResult as cz, buildIntegrationCatalogView as d, redactApprovalRequest as d$, assertValidIntegrationManifest as d0, auditIntegrationCatalogFreshness as d1, auditTangleIntegrationCatalogFreshness as d2, buildActivepiecesConnectors as d3, buildActivepiecesRuntimeRequest as d4, buildApprovalRequest as d5, buildCanonicalLaunchConnectors as d6, buildIntegrationBridgeEnvironment as d7, buildIntegrationBridgePayload as d8, buildIntegrationCoverageConnectors as d9, createTangleCatalogRuntimeNodeRequestListener as dA, createTangleIntegrationsClient as dB, decodeIntegrationBridgePayload as dC, dispatchIntegrationInvocation as dD, encodeIntegrationBridgePayload as dE, explainMissingRequirements as dF, extractActivepiecesPublicPieceCount as dG, extractExternalCatalogPublicCount as dH, getActivepiecesOverride as dI, healthcheckRequest as dJ, importGraphqlConnector as dK, importMcpConnector as dL, importOpenApiConnector as dM, inferIntegrationManifestFromTools as dN, integrationCoverageChecklistMarkdown as dO, invocationRequestFromEnvelope as dP, listActivepiecesCatalogEntries as dQ, listIntegrationCoverageSpecs as dR, listTangleIntegrationCatalogEntries as dS, listTangleIntegrationCatalogRuntimePackages as dT, listTangleIntegrationContracts as dU, manifestToConnector as dV, normalizeGatewayCatalog as dW, normalizeIntegrationError as dX, normalizeIntegrationResult as dY, parseIntegrationBridgeEnvironment as dZ, receiveIntegrationWebhook as d_, buildIntegrationInvocationEnvelope as da, buildTangleCatalogRuntimePackageManifest as db, buildTangleCatalogRuntimeRequest as dc, buildTangleIntegrationCatalogConnectors as dd, calendarExercisePlannerManifest as de, canonicalActionConnectorId as df, createActivepiecesExecutorProvider as dg, createActivepiecesHttpExecutor as dh, createApprovalBackedPolicyEngine as di, createAuditingActionGuard as dj, createCatalogExecutorProvider as dk, createConnectionCredentialResolver as dl, createConnectorAdapterCatalogSource as dm, createConnectorAdapterProvider as dn, createCredentialBackedAdapterProvider as dp, createDefaultIntegrationActionGuard as dq, createDefaultIntegrationPolicyEngine as dr, createGatewayCatalogProvider as ds, createHttpIntegrationProvider as dt, createIntegrationAuditEvent as du, createIntegrationWorkflowRuntime as dv, createMockIntegrationProvider as dw, createPlatformIntegrationPolicyPreset as dx, createTangleCatalogExecutorProvider as dy, createTangleCatalogHttpExecutor as dz, buildIntegrationToolCatalog as e, redactCapability as e0, redactIntegrationBridgePayload as e1, redactInvocationEnvelope as e2, renderApprovalCopy as e3, renderConsentSummary as e4, renderTangleCatalogRuntimePnpmAddCommand as e5, resolveConnectionCredentials as e6, resolveIntegrationApproval as e7, revokeConnection as e8, runIntegrationHealthcheck as e9, runIntegrationHealthchecks as ea, sanitizeAuditConnection as eb, sanitizeConnection as ec, signActivepiecesRuntimeRequest as ed, signCapability as ee, startTangleCatalogRuntimeNodeServer as ef, statusForCode as eg, storedEventToTriggerEvent as eh, validateIntegrationInvocationEnvelope as ei, validateIntegrationManifest as ej, validateProviderPassthroughRequest as ek, verifyActivepiecesRuntimeSignature as el, verifyCapabilityToken as em, InMemoryIntegrationGrantStore as f, type IntegrationCapabilityBinding as g, type IntegrationGrant as h, integrationToolName as i, inferIntegrationSupportTier, type IntegrationGrantStore as j, type IntegrationManifest as k, type IntegrationManifestResolution as l, type IntegrationRequirement as m, type IntegrationRequirementMode as n, type IntegrationRequirementResolution as o, parseIntegrationToolName as p, type IntegrationRequirementStatus as q, IntegrationRuntime as r, searchIntegrationTools as s, summarizeIntegrationRegistry, toMcpTools as t, type IntegrationRuntimeHub as u, type IntegrationRuntimeOptions as v, type IntegrationSandboxBundle as w, createIntegrationRuntime as x, type TangleCatalogAuthResolverOptions as y, type TangleCatalogHttpAuthResolverOptions as z };
|
|
2139
|
+
export { type HealthcheckSpec as $, type TangleCatalogHttpAuthResolverRequest as A, type TangleCatalogInstalledPackageExecutorOptions as B, type TangleCatalogRuntimeHandlerOptions as C, type ComposeIntegrationRegistryOptions, type TangleCatalogRuntimeHttpRequest as D, type TangleCatalogRuntimeHttpResponse as E, type TangleCatalogRuntimeInvocation as F, type TangleCatalogRuntimeModuleAction as G, type TangleCatalogRuntimePackageCoverageOptions as H, type IntegrationCatalogView as I, type IntegrationCatalogSource, type IntegrationRegistry, type IntegrationRegistryConflict, type IntegrationRegistryEntry, type IntegrationRegistrySourceRef, type IntegrationRegistrySummary, type IntegrationSupportTier, type TangleCatalogRuntimePackageCoverageRow as J, auditTangleCatalogRuntimePackages as K, createTangleCatalogCredentialAuthResolver as L, type McpToolDefinition as M, createTangleCatalogHttpAuthResolver as N, createTangleCatalogInstalledPackageExecutor as O, createTangleCatalogRuntimeHandler as P, signTangleCatalogRuntimeRequest as Q, tangleCatalogAuthValue as R, verifyTangleCatalogRuntimeSignature as S, TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER as T, type ApiKeyAuthSpec as U, type ConsoleStep as V, type CredentialFieldSpec as W, type CredentialValidationInput as X, type CredentialValidationResult as Y, type CustomAuthSpec as Z, type HealthcheckPlan as _, type IntegrationToolDefinition as a, type GatewayCatalogProviderOptions as a$, type HmacAuthSpec as a0, INTEGRATION_FAMILIES as a1, type IntegrationAuthMode as a2, type IntegrationAuthSpec as a3, type IntegrationFamilyId as a4, type IntegrationFamilySpec as a5, type IntegrationLifecycleSpec as a6, type IntegrationPlannerHints as a7, type IntegrationSetupSpec as a8, type IntegrationSpec as a9, validateIntegrationSpec as aA, ACTIVEPIECES_OVERRIDES as aB, ACTIVEPIECES_PUBLIC_CATALOG_URL as aC, ACTIVEPIECES_RUNTIME_SIGNATURE_HEADER as aD, type ActivepiecesCatalogAuthField as aE, type ActivepiecesCatalogEntry as aF, type ActivepiecesExecutorInvocation as aG, type ActivepiecesExecutorProviderOptions as aH, type ActivepiecesHttpExecutorOptions as aI, type ActivepiecesPieceOverride as aJ, type ActivepiecesRuntimeRequest as aK, ApprovalBackedPolicyEngine as aL, type ApprovalBackedPolicyOptions as aM, CANONICAL_INTEGRATION_ACTIONS as aN, type CanonicalIntegrationActionId as aO, type CanonicalLaunchConnectorOptions as aP, type CatalogExecutorInvocation as aQ, type CatalogExecutorProviderOptions as aR, type CompleteAuthRequest as aS, type ConnectionCredentialResolverOptions as aT, type ConnectorAdapterProviderOptions as aU, type ConsentSummary as aV, DEFAULT_INTEGRATION_BRIDGE_ENV as aW, DefaultIntegrationActionGuard as aX, type DiscoverWorkspaceCapabilitiesInput as aY, type GatewayCatalogAction as aZ, type GatewayCatalogEntry as a_, type IntegrationSpecStatus as aa, type IntegrationSpecValidationIssue as ab, type IntegrationSpecValidationResult as ac, type NoneAuthSpec as ad, type NormalizedPermission as ae, type OAuth2AuthSpec as af, type PermissionDescriptor as ag, type PostSetupCheck as ah, type Quirk as ai, type RenderSpecOptions as aj, type RenderedConsoleStep as ak, type ScopeDescriptor as al, assertValidIntegrationSpec as am, buildHealthcheckPlan as an, consoleStepsToText as ao, getIntegrationFamily as ap, getIntegrationSpec as aq, integrationSpecToConnector as ar, listExecutableIntegrationSpecs as as, listIntegrationSpecs as at, renderAgentToolDescription as au, renderConsoleSteps as av, renderRunbookMarkdown as aw, specAuthToConnectorAuth as ax, validateCredentialFormat as ay, validateCredentialSet as az, type IntegrationToolSearchFilters as b, type IntegrationProvider as b$, type GatewayCatalogTrigger as b0, type GraphqlOperationSpec as b1, type HttpIntegrationProviderOptions as b2, type ImportCatalogOptions as b3, InMemoryConnectionStore as b4, InMemoryIntegrationApprovalStore as b5, InMemoryIntegrationAuditStore as b6, InMemoryIntegrationEventStore as b7, InMemoryIntegrationHealthcheckStore as b8, InMemoryIntegrationIdempotencyStore as b9, type IntegrationConnection as bA, type IntegrationConnectionStore as bB, type IntegrationConnector as bC, type IntegrationConnectorAction as bD, type IntegrationConnectorCategory as bE, type IntegrationConnectorTrigger as bF, type IntegrationCoveragePriority as bG, type IntegrationCoverageSpec as bH, type IntegrationDataClass as bI, IntegrationError as bJ, type IntegrationErrorCode as bK, type IntegrationEventStore as bL, type IntegrationGuardContext as bM, type IntegrationHealthcheckCheck as bN, type IntegrationHealthcheckResult as bO, type IntegrationHealthcheckStatus as bP, type IntegrationHealthcheckStore as bQ, IntegrationHub as bR, type IntegrationHubOptions as bS, type IntegrationIdempotencyRecord as bT, type IntegrationIdempotencyStore as bU, type IntegrationInvocationEnvelope as bV, type IntegrationInvocationEnvelopeValidationOptions as bW, type IntegrationPolicyDecision as bX, type IntegrationPolicyEffect as bY, type IntegrationPolicyEngine as bZ, type IntegrationPolicyRule as b_, InMemoryIntegrationSecretStore as ba, InMemoryIntegrationWorkflowStore as bb, type InferIntegrationRequirementsOptions as bc, type InstalledIntegrationWorkflow as bd, type IntegrationActionGuard as be, type IntegrationActionPack as bf, type IntegrationActionRequest as bg, type IntegrationActionResult as bh, type IntegrationActionRisk as bi, type IntegrationActor as bj, type IntegrationApprovalFilter as bk, type IntegrationApprovalRecord as bl, type IntegrationApprovalRequest as bm, type IntegrationApprovalResolution as bn, type IntegrationApprovalStatus as bo, type IntegrationApprovalStore as bp, type IntegrationAuditEvent as bq, type IntegrationAuditEventType as br, type IntegrationAuditFilter as bs, type IntegrationAuditSink as bt, type IntegrationAuditStore as bu, buildDefaultIntegrationRegistry, type IntegrationBridgePayload as bv, type IntegrationBridgeToolBinding as bw, type IntegrationCapability as bx, type IntegrationCatalogFreshnessOptions as by, type IntegrationCatalogFreshnessResult as bz, type IntegrationToolSearchResult as c, type TangleIntegrationsClientOptions as c$, type IntegrationProviderKind as c0, type IntegrationRateLimitDecision as c1, type IntegrationRateLimiter as c2, IntegrationRuntimeError as c3, IntegrationSandboxHost as c4, type IntegrationSandboxHostHub as c5, type IntegrationSandboxHostOptions as c6, type IntegrationSecretStore as c7, type IntegrationTriggerEvent as c8, type IntegrationTriggerSubscription as c9, type StartAuthResult as cA, type StartedTangleCatalogRuntimeNodeServer as cB, StaticIntegrationPolicyEngine as cC, type StaticIntegrationPolicyOptions as cD, type StoredIntegrationEvent as cE, TANGLE_INTEGRATIONS_CATALOG_PROVIDER_ID as cF, TANGLE_INTEGRATIONS_CATALOG_SOURCE as cG, type TangleCatalogExecutorInvocation as cH, type TangleCatalogExecutorProviderOptions as cI, type TangleCatalogHttpExecutorInvocation as cJ, type TangleCatalogHttpExecutorOptions as cK, type TangleCatalogRuntimeActionRequest as cL, type TangleCatalogRuntimeNodeServerOptions as cM, type TangleCatalogRuntimePackageManifest as cN, type TangleCatalogRuntimePackageManifestOptions as cO, type TangleCatalogRuntimePiece as cP, type TangleCatalogRuntimeRequest as cQ, type TangleCatalogTriggerInvocation as cR, type TangleIntegrationCatalogEntry as cS, type TangleIntegrationCatalogFreshnessOptions as cT, type TangleIntegrationCatalogFreshnessResult as cU, type TangleIntegrationContract as cV, type TangleIntegrationContractStatus as cW, type TangleIntegrationImplementationKind as cX, type TangleIntegrationInvokeInput as cY, type TangleIntegrationInvokeResult as cZ, TangleIntegrationsClient as c_, type IntegrationUserAction as ca, canonicalConnectorId, type IntegrationWebhookReceiverResult as cb, type IntegrationWorkflowDefinition as cc, IntegrationWorkflowRuntime as cd, type IntegrationWorkflowRuntimeHub as ce, type IntegrationWorkflowRuntimeOptions as cf, type IntegrationWorkflowStore as cg, type InvokeWithCapabilityRequest as ch, type IssueCapabilityRequest as ci, type IssuedIntegrationCapability as cj, type ManifestValidationIssue as ck, type ManifestValidationResult as cl, type McpCatalog as cm, type McpCatalogTool as cn, type MissingRequirementExplanation as co, composeIntegrationRegistry, type NormalizedIntegrationError as cp, type NormalizedIntegrationResult as cq, type OpenApiDocument as cr, type OpenApiOperation as cs, PROVIDER_PASSTHROUGH_ACTION as ct, type PlatformIntegrationPolicyPresetOptions as cu, type ProviderHttpRequestInput as cv, type ProviderPassthroughPolicy as cw, type RenderConsentOptions as cx, type SecretRef as cy, type StartAuthRequest as cz, buildIntegrationCatalogView as d, manifestToConnector as d$, type WorkspaceCapability as d0, type WorkspaceCapabilityDiscovery as d1, type WorkspaceToolSchema as d2, type WorkspaceTrigger as d3, adapterManifestsToConnectors as d4, assertValidIntegrationManifest as d5, auditIntegrationCatalogFreshness as d6, auditTangleIntegrationCatalogFreshness as d7, buildActivepiecesConnectors as d8, buildActivepiecesRuntimeRequest as d9, createIntegrationWorkflowRuntime as dA, createMockIntegrationProvider as dB, createPlatformIntegrationPolicyPreset as dC, createTangleCatalogExecutorProvider as dD, createTangleCatalogHttpExecutor as dE, createTangleCatalogRuntimeNodeRequestListener as dF, createTangleIntegrationsClient as dG, decodeIntegrationBridgePayload as dH, discoverWorkspaceCapabilities as dI, dispatchIntegrationInvocation as dJ, encodeIntegrationBridgePayload as dK, explainMissingRequirements as dL, extractActivepiecesPublicPieceCount as dM, extractExternalCatalogPublicCount as dN, getActivepiecesOverride as dO, healthcheckRequest as dP, importGraphqlConnector as dQ, importMcpConnector as dR, importOpenApiConnector as dS, inferIntegrationManifestFromTools as dT, integrationCoverageChecklistMarkdown as dU, invocationRequestFromEnvelope as dV, listActivepiecesCatalogEntries as dW, listIntegrationCoverageSpecs as dX, listTangleIntegrationCatalogEntries as dY, listTangleIntegrationCatalogRuntimePackages as dZ, listTangleIntegrationContracts as d_, buildApprovalRequest as da, buildCanonicalLaunchConnectors as db, buildIntegrationBridgeEnvironment as dc, buildIntegrationBridgePayload as dd, buildIntegrationCoverageConnectors as de, buildIntegrationInvocationEnvelope as df, buildTangleCatalogRuntimePackageManifest as dg, buildTangleCatalogRuntimeRequest as dh, buildTangleIntegrationCatalogConnectors as di, calendarExercisePlannerManifest as dj, canonicalActionConnectorId as dk, createActivepiecesExecutorProvider as dl, createActivepiecesHttpExecutor as dm, createApprovalBackedPolicyEngine as dn, createAuditingActionGuard as dp, createCatalogExecutorProvider as dq, createConnectionCredentialResolver as dr, createConnectorAdapterCatalogSource as ds, createConnectorAdapterProvider as dt, createCredentialBackedAdapterProvider as du, createDefaultIntegrationActionGuard as dv, createDefaultIntegrationPolicyEngine as dw, createGatewayCatalogProvider as dx, createHttpIntegrationProvider as dy, createIntegrationAuditEvent as dz, buildIntegrationToolCatalog as e, normalizeGatewayCatalog as e0, normalizeIntegrationError as e1, normalizeIntegrationResult as e2, parseIntegrationBridgeEnvironment as e3, receiveIntegrationWebhook as e4, redactApprovalRequest as e5, redactCapability as e6, redactIntegrationBridgePayload as e7, redactInvocationEnvelope as e8, renderApprovalCopy as e9, renderConsentSummary as ea, renderTangleCatalogRuntimePnpmAddCommand as eb, resolveConnectionCredentials as ec, resolveIntegrationApproval as ed, revokeConnection as ee, runIntegrationHealthcheck as ef, runIntegrationHealthchecks as eg, sanitizeAuditConnection as eh, sanitizeConnection as ei, signActivepiecesRuntimeRequest as ej, signCapability as ek, startTangleCatalogRuntimeNodeServer as el, statusForCode as em, storedEventToTriggerEvent as en, validateIntegrationInvocationEnvelope as eo, validateIntegrationManifest as ep, validateProviderPassthroughRequest as eq, verifyActivepiecesRuntimeSignature as er, verifyCapabilityToken as es, InMemoryIntegrationGrantStore as f, type IntegrationCapabilityBinding as g, type IntegrationGrant as h, integrationToolName as i, inferIntegrationSupportTier, type IntegrationGrantStore as j, type IntegrationManifest as k, type IntegrationManifestResolution as l, type IntegrationRequirement as m, type IntegrationRequirementMode as n, type IntegrationRequirementResolution as o, parseIntegrationToolName as p, type IntegrationRequirementStatus as q, IntegrationRuntime as r, searchIntegrationTools as s, summarizeIntegrationRegistry, toMcpTools as t, type IntegrationRuntimeHub as u, type IntegrationRuntimeOptions as v, type IntegrationSandboxBundle as w, createIntegrationRuntime as x, type TangleCatalogAuthResolverOptions as y, type TangleCatalogHttpAuthResolverOptions as z };
|
package/dist/registry.js
CHANGED
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
composeIntegrationRegistry,
|
|
5
5
|
inferIntegrationSupportTier,
|
|
6
6
|
summarizeIntegrationRegistry
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ALCIWTIR.js";
|
|
8
8
|
import "./chunk-4JQ754PA.js";
|
|
9
9
|
import "./chunk-376UBTNB.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-GA4VTE3U.js";
|
|
11
|
+
import "./chunk-2TW2QKGZ.js";
|
|
11
12
|
export {
|
|
12
13
|
buildDefaultIntegrationRegistry,
|
|
13
14
|
canonicalConnectorId,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 './index-
|
|
2
|
+
import './index-D4D4CEKX.js';
|
|
3
3
|
import './connectors/index.js';
|
|
4
4
|
import 'node:http';
|
package/dist/runtime.js
CHANGED
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
InMemoryIntegrationGrantStore,
|
|
3
3
|
IntegrationRuntime,
|
|
4
4
|
createIntegrationRuntime
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ALCIWTIR.js";
|
|
6
6
|
import "./chunk-4JQ754PA.js";
|
|
7
7
|
import "./chunk-376UBTNB.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-GA4VTE3U.js";
|
|
9
|
+
import "./chunk-2TW2QKGZ.js";
|
|
9
10
|
export {
|
|
10
11
|
InMemoryIntegrationGrantStore,
|
|
11
12
|
IntegrationRuntime,
|
package/dist/specs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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 './index-
|
|
2
|
+
import './index-D4D4CEKX.js';
|
|
3
3
|
import './connectors/index.js';
|
|
4
4
|
import 'node:http';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { T as TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER, y as TangleCatalogAuthResolverOptions, z as TangleCatalogHttpAuthResolverOptions, A as TangleCatalogHttpAuthResolverRequest, B as TangleCatalogInstalledPackageExecutorOptions, C as TangleCatalogRuntimeHandlerOptions, D as TangleCatalogRuntimeHttpRequest, E as TangleCatalogRuntimeHttpResponse, F as TangleCatalogRuntimeInvocation, G as TangleCatalogRuntimeModuleAction, H as TangleCatalogRuntimePackageCoverageOptions, J as TangleCatalogRuntimePackageCoverageRow, K as auditTangleCatalogRuntimePackages, L as createTangleCatalogCredentialAuthResolver, N as createTangleCatalogHttpAuthResolver, O as createTangleCatalogInstalledPackageExecutor, P as createTangleCatalogRuntimeHandler, Q as signTangleCatalogRuntimeRequest, R as tangleCatalogAuthValue, S as verifyTangleCatalogRuntimeSignature } from './registry.js';
|
|
2
|
-
import './index-
|
|
2
|
+
import './index-D4D4CEKX.js';
|
|
3
3
|
import './connectors/index.js';
|
|
4
4
|
import 'node:http';
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
signTangleCatalogRuntimeRequest,
|
|
9
9
|
tangleCatalogAuthValue,
|
|
10
10
|
verifyTangleCatalogRuntimeSignature
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ALCIWTIR.js";
|
|
12
12
|
import "./chunk-4JQ754PA.js";
|
|
13
13
|
import "./chunk-376UBTNB.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-GA4VTE3U.js";
|
|
15
|
+
import "./chunk-2TW2QKGZ.js";
|
|
15
16
|
export {
|
|
16
17
|
TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER,
|
|
17
18
|
auditTangleCatalogRuntimePackages,
|
|
@@ -0,0 +1,193 @@
|
|
|
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
|
+
/**
|
|
150
|
+
* Pre-built `WebhookProvider` implementations for the inbound surfaces
|
|
151
|
+
* the substrate ships first-party verifiers for.
|
|
152
|
+
*
|
|
153
|
+
* Each provider implementation is intentionally thin: it delegates
|
|
154
|
+
* signature verification to the corresponding pure function in
|
|
155
|
+
* `connectors/webhooks.ts` and parses the body into one or more
|
|
156
|
+
* normalized `WebhookEnvelope` rows. Anything provider-specific that
|
|
157
|
+
* doesn't fit cleanly (Slack URL-verification handshake, etc.) is
|
|
158
|
+
* surfaced via the envelope `eventType` so the consumer's `deliver()`
|
|
159
|
+
* can branch.
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
/** Stripe webhook provider. Signature header `Stripe-Signature`. */
|
|
163
|
+
declare const stripeWebhookProvider: WebhookProvider;
|
|
164
|
+
/** Slack Events API provider. Handles the `url_verification` handshake
|
|
165
|
+
* by emitting a synthetic event the consumer's `deliver()` can echo. */
|
|
166
|
+
declare const slackWebhookProvider: WebhookProvider;
|
|
167
|
+
/** DocuSeal webhook provider. Signature header `X-Docuseal-Signature`. */
|
|
168
|
+
declare const docusealWebhookProvider: WebhookProvider;
|
|
169
|
+
/** Gmail push provider. Cloud Pub/Sub posts a JWT-signed envelope; the
|
|
170
|
+
* *payload* is base64 JSON describing the changed history range. The
|
|
171
|
+
* signature scheme here is the Pub/Sub JWT auth header — when supplied,
|
|
172
|
+
* consumers SHOULD verify the JWT against Google's well-known
|
|
173
|
+
* certificates. We accept the simpler "Bearer <pubsub-shared-secret>"
|
|
174
|
+
* variant by default (matching `verifyHmacSignature`). */
|
|
175
|
+
declare const gmailWebhookProvider: WebhookProvider;
|
|
176
|
+
/** Google Drive push provider. Drive does NOT sign the body — it uses
|
|
177
|
+
* the per-channel token (`X-Goog-Channel-Token`) as the shared secret.
|
|
178
|
+
* The router compares it constant-time against the resolved secret. */
|
|
179
|
+
declare const gdriveWebhookProvider: WebhookProvider;
|
|
180
|
+
/** Generic HMAC provider — for the long-tail webhook source where the
|
|
181
|
+
* caller has standardised on a single sha256-of-body scheme. Header
|
|
182
|
+
* `X-Signature` by default; override at provider-build time if needed. */
|
|
183
|
+
declare function genericHmacWebhookProvider(options: {
|
|
184
|
+
id: string;
|
|
185
|
+
signatureHeader?: string;
|
|
186
|
+
algorithm?: 'sha256' | 'sha1' | 'sha512';
|
|
187
|
+
signaturePrefix?: string;
|
|
188
|
+
/** Parser to convert the raw body into envelopes. Defaults to
|
|
189
|
+
* "one event with eventType=<provider>.event and payload=JSON". */
|
|
190
|
+
parse?: WebhookProvider['parse'];
|
|
191
|
+
}): WebhookProvider;
|
|
192
|
+
|
|
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 };
|