Skip to content

Commit 49f693d

Browse files
committed
refactor: widen webhook request guard sdk seam
1 parent d5841f6 commit 49f693d

5 files changed

Lines changed: 25 additions & 22 deletions

File tree

docs/.generated/plugin-sdk-api-baseline.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5273,7 +5273,7 @@
52735273
"exportName": "applyBasicWebhookRequestGuards",
52745274
"kind": "function",
52755275
"source": {
5276-
"line": 148,
5276+
"line": 151,
52775277
"path": "src/plugin-sdk/webhook-request-guards.ts"
52785278
}
52795279
},
@@ -5282,7 +5282,7 @@
52825282
"exportName": "beginWebhookRequestPipelineOrReject",
52835283
"kind": "function",
52845284
"source": {
5285-
"line": 189,
5285+
"line": 192,
52865286
"path": "src/plugin-sdk/webhook-request-guards.ts"
52875287
}
52885288
},
@@ -5318,7 +5318,7 @@
53185318
"exportName": "createWebhookInFlightLimiter",
53195319
"kind": "function",
53205320
"source": {
5321-
"line": 91,
5321+
"line": 94,
53225322
"path": "src/plugin-sdk/webhook-request-guards.ts"
53235323
}
53245324
},
@@ -5327,7 +5327,7 @@
53275327
"exportName": "isJsonContentType",
53285328
"kind": "function",
53295329
"source": {
5330-
"line": 138,
5330+
"line": 141,
53315331
"path": "src/plugin-sdk/webhook-request-guards.ts"
53325332
}
53335333
},
@@ -5363,7 +5363,7 @@
53635363
"exportName": "readJsonWebhookBodyOrReject",
53645364
"kind": "function",
53655365
"source": {
5366-
"line": 275,
5366+
"line": 278,
53675367
"path": "src/plugin-sdk/webhook-request-guards.ts"
53685368
}
53695369
},
@@ -5381,7 +5381,7 @@
53815381
"exportName": "readWebhookBodyOrReject",
53825382
"kind": "function",
53835383
"source": {
5384-
"line": 240,
5384+
"line": 243,
53855385
"path": "src/plugin-sdk/webhook-request-guards.ts"
53865386
}
53875387
},
@@ -5516,7 +5516,7 @@
55165516
"exportName": "WEBHOOK_BODY_READ_DEFAULTS",
55175517
"kind": "const",
55185518
"source": {
5519-
"line": 19,
5519+
"line": 22,
55205520
"path": "src/plugin-sdk/webhook-request-guards.ts"
55215521
}
55225522
},
@@ -5525,7 +5525,7 @@
55255525
"exportName": "WEBHOOK_IN_FLIGHT_DEFAULTS",
55265526
"kind": "const",
55275527
"source": {
5528-
"line": 30,
5528+
"line": 33,
55295529
"path": "src/plugin-sdk/webhook-request-guards.ts"
55305530
}
55315531
},
@@ -5597,7 +5597,7 @@
55975597
"exportName": "WebhookBodyReadProfile",
55985598
"kind": "type",
55995599
"source": {
5600-
"line": 11,
5600+
"line": 12,
56015601
"path": "src/plugin-sdk/webhook-request-guards.ts"
56025602
}
56035603
},
@@ -5606,7 +5606,7 @@
56065606
"exportName": "WebhookInFlightLimiter",
56075607
"kind": "type",
56085608
"source": {
5609-
"line": 35,
5609+
"line": 38,
56105610
"path": "src/plugin-sdk/webhook-request-guards.ts"
56115611
}
56125612
},

docs/.generated/plugin-sdk-api-baseline.jsonl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -580,19 +580,19 @@
580580
{"declaration":"export type PluginRuntime = PluginRuntime;","entrypoint":"testing","exportName":"PluginRuntime","importSpecifier":"openclaw/plugin-sdk/testing","kind":"type","recordType":"export","sourceLine":54,"sourcePath":"src/plugins/runtime/types.ts"}
581581
{"declaration":"export type RuntimeEnv = RuntimeEnv;","entrypoint":"testing","exportName":"RuntimeEnv","importSpecifier":"openclaw/plugin-sdk/testing","kind":"type","recordType":"export","sourceLine":4,"sourcePath":"src/runtime.ts"}
582582
{"category":"channel","entrypoint":"webhook-ingress","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","recordType":"module","sourceLine":1,"sourcePath":"src/plugin-sdk/webhook-ingress.ts"}
583-
{"declaration":"export function applyBasicWebhookRequestGuards(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; allowMethods?: readonly string[] | undefined; rateLimiter?: FixedWindowRateLimiter | undefined; rateLimitKey?: string | undefined; nowMs?: number | undefined; requireJsonContentType?: boolean | undefined; }): boolean;","entrypoint":"webhook-ingress","exportName":"applyBasicWebhookRequestGuards","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":148,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
584-
{"declaration":"export function beginWebhookRequestPipelineOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; allowMethods?: readonly string[] | undefined; rateLimiter?: FixedWindowRateLimiter | undefined; ... 6 more ...; inFlightLimitMessage?: string | undefined; }): { ...; } | { ...; };","entrypoint":"webhook-ingress","exportName":"beginWebhookRequestPipelineOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":189,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
583+
{"declaration":"export function applyBasicWebhookRequestGuards(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; allowMethods?: readonly string[] | undefined; rateLimiter?: FixedWindowRateLimiter | undefined; rateLimitKey?: string | undefined; nowMs?: number | undefined; requireJsonContentType?: boolean | undefined; }): boolean;","entrypoint":"webhook-ingress","exportName":"applyBasicWebhookRequestGuards","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":151,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
584+
{"declaration":"export function beginWebhookRequestPipelineOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; allowMethods?: readonly string[] | undefined; rateLimiter?: FixedWindowRateLimiter | undefined; ... 6 more ...; inFlightLimitMessage?: string | undefined; }): { ...; } | { ...; };","entrypoint":"webhook-ingress","exportName":"beginWebhookRequestPipelineOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":192,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
585585
{"declaration":"export function createBoundedCounter(options: { maxTrackedKeys: number; ttlMs?: number | undefined; pruneIntervalMs?: number | undefined; }): BoundedCounter;","entrypoint":"webhook-ingress","exportName":"createBoundedCounter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":109,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
586586
{"declaration":"export function createFixedWindowRateLimiter(options: { windowMs: number; maxRequests: number; maxTrackedKeys: number; pruneIntervalMs?: number | undefined; }): FixedWindowRateLimiter;","entrypoint":"webhook-ingress","exportName":"createFixedWindowRateLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":52,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
587587
{"declaration":"export function createWebhookAnomalyTracker(options?: { maxTrackedKeys?: number | undefined; ttlMs?: number | undefined; logEvery?: number | undefined; trackedStatusCodes?: readonly number[] | undefined; } | undefined): WebhookAnomalyTracker;","entrypoint":"webhook-ingress","exportName":"createWebhookAnomalyTracker","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":167,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
588-
{"declaration":"export function createWebhookInFlightLimiter(options?: { maxInFlightPerKey?: number | undefined; maxTrackedKeys?: number | undefined; } | undefined): WebhookInFlightLimiter;","entrypoint":"webhook-ingress","exportName":"createWebhookInFlightLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":91,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
589-
{"declaration":"export function isJsonContentType(value: string | string[] | undefined): boolean;","entrypoint":"webhook-ingress","exportName":"isJsonContentType","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":138,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
588+
{"declaration":"export function createWebhookInFlightLimiter(options?: { maxInFlightPerKey?: number | undefined; maxTrackedKeys?: number | undefined; } | undefined): WebhookInFlightLimiter;","entrypoint":"webhook-ingress","exportName":"createWebhookInFlightLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":94,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
589+
{"declaration":"export function isJsonContentType(value: string | string[] | undefined): boolean;","entrypoint":"webhook-ingress","exportName":"isJsonContentType","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":141,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
590590
{"declaration":"export function isRequestBodyLimitError(error: unknown, code?: RequestBodyLimitErrorCode | undefined): error is RequestBodyLimitError;","entrypoint":"webhook-ingress","exportName":"isRequestBodyLimitError","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":47,"sourcePath":"src/infra/http-body.ts"}
591591
{"declaration":"export function normalizePluginHttpPath(path?: string | null | undefined, fallback?: string | null | undefined): string | null;","entrypoint":"webhook-ingress","exportName":"normalizePluginHttpPath","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":1,"sourcePath":"src/plugins/http-path.ts"}
592592
{"declaration":"export function normalizeWebhookPath(raw: string): string;","entrypoint":"webhook-ingress","exportName":"normalizeWebhookPath","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":2,"sourcePath":"src/plugin-sdk/webhook-path.ts"}
593-
{"declaration":"export function readJsonWebhookBodyOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; maxBytes?: number | undefined; timeoutMs?: number | undefined; profile?: WebhookBodyReadProfile | undefined; emptyObjectOnEmpty?: boolean | undefined; invalidJsonMessage?: string | undefined; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"readJsonWebhookBodyOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":275,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
593+
{"declaration":"export function readJsonWebhookBodyOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; maxBytes?: number | undefined; timeoutMs?: number | undefined; profile?: WebhookBodyReadProfile | undefined; emptyObjectOnEmpty?: boolean | undefined; invalidJsonMessage?: string | undefined; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"readJsonWebhookBodyOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":278,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
594594
{"declaration":"export function readRequestBodyWithLimit(req: IncomingMessage, options: ReadRequestBodyOptions): Promise<string>;","entrypoint":"webhook-ingress","exportName":"readRequestBodyWithLimit","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":122,"sourcePath":"src/infra/http-body.ts"}
595-
{"declaration":"export function readWebhookBodyOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; maxBytes?: number | undefined; timeoutMs?: number | undefined; profile?: WebhookBodyReadProfile | undefined; invalidBodyMessage?: string | undefined; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"readWebhookBodyOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":240,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
595+
{"declaration":"export function readWebhookBodyOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; maxBytes?: number | undefined; timeoutMs?: number | undefined; profile?: WebhookBodyReadProfile | undefined; invalidBodyMessage?: string | undefined; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"readWebhookBodyOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":243,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
596596
{"declaration":"export function registerPluginHttpRoute(params: { path?: string | null | undefined; fallbackPath?: string | null | undefined; handler: PluginHttpRouteHandler; auth: OpenClawPluginHttpRouteAuth; ... 6 more ...; registry?: PluginRegistry | undefined; }): () => void;","entrypoint":"webhook-ingress","exportName":"registerPluginHttpRoute","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":12,"sourcePath":"src/plugins/http-registry.ts"}
597597
{"declaration":"export function registerWebhookTarget<T extends { path: string; }>(targetsByPath: Map<string, T[]>, target: T, opts?: RegisterWebhookTargetOptions<T> | undefined): RegisteredWebhookTarget<T>;","entrypoint":"webhook-ingress","exportName":"registerWebhookTarget","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":61,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
598598
{"declaration":"export function registerWebhookTargetWithPluginRoute<T extends { path: string; }>(params: { targetsByPath: Map<string, T[]>; target: T; route: RegisterWebhookPluginRouteOptions; onLastPathTargetRemoved?: ((params: { ...; }) => void) | undefined; }): RegisteredWebhookTarget<...>;","entrypoint":"webhook-ingress","exportName":"registerWebhookTargetWithPluginRoute","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":30,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
@@ -607,15 +607,15 @@
607607
{"declaration":"export function withResolvedWebhookRequestPipeline<T>(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; targetsByPath: Map<string, T[]>; allowMethods?: readonly string[] | undefined; ... 8 more ...; handle: (args: { ...; }) => boolean | ... 1 more ... | Promise<...>; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"withResolvedWebhookRequestPipeline","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":121,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
608608
{"declaration":"export const WEBHOOK_ANOMALY_COUNTER_DEFAULTS: Readonly<{ maxTrackedKeys: 4096; ttlMs: number; logEvery: 25; }>;","entrypoint":"webhook-ingress","exportName":"WEBHOOK_ANOMALY_COUNTER_DEFAULTS","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":31,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
609609
{"declaration":"export const WEBHOOK_ANOMALY_STATUS_CODES: readonly number[];","entrypoint":"webhook-ingress","exportName":"WEBHOOK_ANOMALY_STATUS_CODES","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":37,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
610-
{"declaration":"export const WEBHOOK_BODY_READ_DEFAULTS: Readonly<{ preAuth: { maxBytes: number; timeoutMs: number; }; postAuth: { maxBytes: number; timeoutMs: number; }; }>;","entrypoint":"webhook-ingress","exportName":"WEBHOOK_BODY_READ_DEFAULTS","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":19,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
611-
{"declaration":"export const WEBHOOK_IN_FLIGHT_DEFAULTS: Readonly<{ maxInFlightPerKey: 8; maxTrackedKeys: 4096; }>;","entrypoint":"webhook-ingress","exportName":"WEBHOOK_IN_FLIGHT_DEFAULTS","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":30,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
610+
{"declaration":"export const WEBHOOK_BODY_READ_DEFAULTS: Readonly<{ preAuth: { maxBytes: number; timeoutMs: number; }; postAuth: { maxBytes: number; timeoutMs: number; }; }>;","entrypoint":"webhook-ingress","exportName":"WEBHOOK_BODY_READ_DEFAULTS","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":22,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
611+
{"declaration":"export const WEBHOOK_IN_FLIGHT_DEFAULTS: Readonly<{ maxInFlightPerKey: 8; maxTrackedKeys: 4096; }>;","entrypoint":"webhook-ingress","exportName":"WEBHOOK_IN_FLIGHT_DEFAULTS","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":33,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
612612
{"declaration":"export const WEBHOOK_RATE_LIMIT_DEFAULTS: Readonly<{ windowMs: 60000; maxRequests: 120; maxTrackedKeys: 4096; }>;","entrypoint":"webhook-ingress","exportName":"WEBHOOK_RATE_LIMIT_DEFAULTS","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"const","recordType":"export","sourceLine":25,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
613613
{"declaration":"export type BoundedCounter = BoundedCounter;","entrypoint":"webhook-ingress","exportName":"BoundedCounter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":19,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
614614
{"declaration":"export type FixedWindowRateLimiter = FixedWindowRateLimiter;","entrypoint":"webhook-ingress","exportName":"FixedWindowRateLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":13,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
615615
{"declaration":"export type RegisteredWebhookTarget = RegisteredWebhookTarget<T>;","entrypoint":"webhook-ingress","exportName":"RegisteredWebhookTarget","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":10,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
616616
{"declaration":"export type RegisterWebhookPluginRouteOptions = RegisterWebhookPluginRouteOptions;","entrypoint":"webhook-ingress","exportName":"RegisterWebhookPluginRouteOptions","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":24,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
617617
{"declaration":"export type RegisterWebhookTargetOptions = RegisterWebhookTargetOptions<T>;","entrypoint":"webhook-ingress","exportName":"RegisterWebhookTargetOptions","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":15,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
618618
{"declaration":"export type WebhookAnomalyTracker = WebhookAnomalyTracker;","entrypoint":"webhook-ingress","exportName":"WebhookAnomalyTracker","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":39,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
619-
{"declaration":"export type WebhookBodyReadProfile = WebhookBodyReadProfile;","entrypoint":"webhook-ingress","exportName":"WebhookBodyReadProfile","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":11,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
620-
{"declaration":"export type WebhookInFlightLimiter = WebhookInFlightLimiter;","entrypoint":"webhook-ingress","exportName":"WebhookInFlightLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":35,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
619+
{"declaration":"export type WebhookBodyReadProfile = WebhookBodyReadProfile;","entrypoint":"webhook-ingress","exportName":"WebhookBodyReadProfile","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":12,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
620+
{"declaration":"export type WebhookInFlightLimiter = WebhookInFlightLimiter;","entrypoint":"webhook-ingress","exportName":"WebhookInFlightLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":38,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
621621
{"declaration":"export type WebhookTargetMatchResult = WebhookTargetMatchResult<T>;","entrypoint":"webhook-ingress","exportName":"WebhookTargetMatchResult","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"type","recordType":"export","sourceLine":170,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}

0 commit comments

Comments
 (0)