@mastra/mcp 2.5.0-alpha.2 → 2.5.0-alpha.3
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/client/actions/events.d.ts +66 -0
- package/dist/client/actions/events.d.ts.map +1 -0
- package/dist/client/client.d.ts +63 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +49 -0
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/client/events/errors.d.ts +13 -0
- package/dist/client/events/errors.d.ts.map +1 -0
- package/dist/client/events/index.d.ts +3 -0
- package/dist/client/events/index.d.ts.map +1 -0
- package/dist/client/events/mode.d.ts +58 -0
- package/dist/client/events/mode.d.ts.map +1 -0
- package/dist/client/events/poll-driver.d.ts +6 -0
- package/dist/client/events/poll-driver.d.ts.map +1 -0
- package/dist/client/events/push-driver.d.ts +7 -0
- package/dist/client/events/push-driver.d.ts.map +1 -0
- package/dist/client/events/stream-router.d.ts +42 -0
- package/dist/client/events/stream-router.d.ts.map +1 -0
- package/dist/client/events/subscription.d.ts +118 -0
- package/dist/client/events/subscription.d.ts.map +1 -0
- package/dist/client/events/types.d.ts +181 -0
- package/dist/client/events/types.d.ts.map +1 -0
- package/dist/client/events/webhook-driver.d.ts +10 -0
- package/dist/client/events/webhook-driver.d.ts.map +1 -0
- package/dist/client/events/webhook-receiver.d.ts +41 -0
- package/dist/client/events/webhook-receiver.d.ts.map +1 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +3 -0
- package/dist/client/types.d.ts.map +1 -1
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-guides-mcp-events.md +306 -0
- package/dist/docs/references/reference-tools-mcp-client.md +236 -0
- package/dist/docs/references/reference-tools-mcp-server.md +170 -0
- package/dist/index.cjs +4094 -197
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4032 -142
- package/dist/index.js.map +1 -1
- package/dist/integrations/events-cursor-store.d.ts +25 -0
- package/dist/integrations/events-cursor-store.d.ts.map +1 -0
- package/dist/integrations/events-signals.d.ts +99 -0
- package/dist/integrations/events-signals.d.ts.map +1 -0
- package/dist/integrations/events-tools.d.ts +24 -0
- package/dist/integrations/events-tools.d.ts.map +1 -0
- package/dist/integrations/events-utils.d.ts +18 -0
- package/dist/integrations/events-utils.d.ts.map +1 -0
- package/dist/integrations/index.d.ts +5 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/server/events/actions.d.ts +35 -0
- package/dist/server/events/actions.d.ts.map +1 -0
- package/dist/server/events/define-event.d.ts +19 -0
- package/dist/server/events/define-event.d.ts.map +1 -0
- package/dist/server/events/handlers.d.ts +49 -0
- package/dist/server/events/handlers.d.ts.map +1 -0
- package/dist/server/events/index.d.ts +7 -0
- package/dist/server/events/index.d.ts.map +1 -0
- package/dist/server/events/inspector.d.ts +14 -0
- package/dist/server/events/inspector.d.ts.map +1 -0
- package/dist/server/events/registry.d.ts +59 -0
- package/dist/server/events/registry.d.ts.map +1 -0
- package/dist/server/events/ring-buffer.d.ts +56 -0
- package/dist/server/events/ring-buffer.d.ts.map +1 -0
- package/dist/server/events/stream.d.ts +56 -0
- package/dist/server/events/stream.d.ts.map +1 -0
- package/dist/server/events/types.d.ts +203 -0
- package/dist/server/events/types.d.ts.map +1 -0
- package/dist/server/events/webhook-dispatcher.d.ts +98 -0
- package/dist/server/events/webhook-dispatcher.d.ts.map +1 -0
- package/dist/server/events/webhook-store.d.ts +60 -0
- package/dist/server/events/webhook-store.d.ts.map +1 -0
- package/dist/server/events/webhook-transport.d.ts +44 -0
- package/dist/server/events/webhook-transport.d.ts.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/server.d.ts +53 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/shared/events/index.d.ts +2 -0
- package/dist/shared/events/index.d.ts.map +1 -1
- package/dist/shared/events/webhook-url.d.ts +59 -0
- package/dist/shared/events/webhook-url.d.ts.map +1 -0
- package/dist/shared/events/webhook.d.ts +60 -0
- package/dist/shared/events/webhook.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { RequestContext } from '@mastra/core/request-context';
|
|
2
|
+
import type { PublicSchema } from '@mastra/core/schema';
|
|
3
|
+
import type { EventDeliveryMode, WebhookUrlPolicyOptions } from '../../shared/events/index.js';
|
|
4
|
+
import type { WebhookSubscriptionStore } from './webhook-store.js';
|
|
5
|
+
import type { WebhookTransport } from './webhook-transport.js';
|
|
6
|
+
/** Subscription arguments of an event type. @experimental SEP-3415 is a draft; this API may change. */
|
|
7
|
+
export type MCPServerEventArgs = Record<string, unknown>;
|
|
8
|
+
/** Payload (`data`) of an event occurrence. @experimental SEP-3415 is a draft; this API may change. */
|
|
9
|
+
export type MCPServerEventData = Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* What a `poll` source receives for one `events/poll` request.
|
|
12
|
+
*
|
|
13
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
14
|
+
*/
|
|
15
|
+
export interface MCPServerEventPollContext<TArgs extends MCPServerEventArgs = MCPServerEventArgs> {
|
|
16
|
+
/** Subscription arguments, validated against `inputSchema` when one is set. */
|
|
17
|
+
arguments: TArgs;
|
|
18
|
+
/** Cursor from the previous poll, or `null` to start from now (no replay). */
|
|
19
|
+
cursor: string | null;
|
|
20
|
+
/** Upper bound on the number of events to return. */
|
|
21
|
+
maxEvents: number;
|
|
22
|
+
/** The client asks not to replay events older than this many milliseconds. */
|
|
23
|
+
maxAgeMs?: number;
|
|
24
|
+
requestContext: RequestContext;
|
|
25
|
+
/** Aborted when the client cancels the request. */
|
|
26
|
+
signal: AbortSignal;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* What `authorize` receives when a client polls or subscribes to an event type.
|
|
30
|
+
*
|
|
31
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
32
|
+
*/
|
|
33
|
+
export interface MCPServerEventAuthorizeContext<TArgs extends MCPServerEventArgs = MCPServerEventArgs> {
|
|
34
|
+
/** Subscription arguments, validated against `inputSchema` when one is set. */
|
|
35
|
+
arguments: TArgs;
|
|
36
|
+
/** The caller's request context, including `user` when the server maps one from the request's auth info. */
|
|
37
|
+
requestContext: RequestContext;
|
|
38
|
+
/** How the caller asked to receive events. */
|
|
39
|
+
delivery: EventDeliveryMode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* An event returned by a `poll` source. The server fills in `eventId` (random UUID) and
|
|
43
|
+
* `timestamp` (now) when they are absent.
|
|
44
|
+
*
|
|
45
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
46
|
+
*/
|
|
47
|
+
export interface MCPServerPolledEvent<TData extends MCPServerEventData = MCPServerEventData> {
|
|
48
|
+
data: TData;
|
|
49
|
+
/**
|
|
50
|
+
* Stable id of the occurrence. Clients dedupe by it across polls and reconnections, so return
|
|
51
|
+
* the same id every time the same occurrence is polled (for example the upstream record id).
|
|
52
|
+
*/
|
|
53
|
+
eventId: string;
|
|
54
|
+
/** When the event occurred. Defaults to the time of the poll. */
|
|
55
|
+
timestamp?: string | Date;
|
|
56
|
+
}
|
|
57
|
+
/** @experimental SEP-3415 is a draft; this API may change. */
|
|
58
|
+
export interface MCPServerEventPollResult<TData extends MCPServerEventData = MCPServerEventData> {
|
|
59
|
+
events: MCPServerPolledEvent<TData>[];
|
|
60
|
+
/** Position after the returned events, or `null` for a non-replayable source. */
|
|
61
|
+
cursor: string | null;
|
|
62
|
+
hasMore?: boolean;
|
|
63
|
+
nextPollMs?: number;
|
|
64
|
+
truncated?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Definition of one event type served by `MCPServer`.
|
|
68
|
+
*
|
|
69
|
+
* Without `poll`, the type is fed by `server.events.emit()` and is served over push
|
|
70
|
+
* (`events/stream`) and poll (`events/poll`, from a per-type ring buffer). With `poll`, the
|
|
71
|
+
* type is served over poll only, by calling `poll` for each request; it can't also be pushed,
|
|
72
|
+
* and `server.events.emit()` rejects it.
|
|
73
|
+
*
|
|
74
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
75
|
+
*/
|
|
76
|
+
export interface MCPServerEventDefinition<TArgs extends MCPServerEventArgs = MCPServerEventArgs, TData extends MCPServerEventData = MCPServerEventData> {
|
|
77
|
+
description?: string;
|
|
78
|
+
/** Schema for subscription `arguments`. Advertised as JSON Schema in `events/list`. */
|
|
79
|
+
inputSchema?: PublicSchema<TArgs>;
|
|
80
|
+
/** Schema for event `data`. Advertised in `events/list` and enforced by `emit()`. */
|
|
81
|
+
payloadSchema?: PublicSchema<TData>;
|
|
82
|
+
/**
|
|
83
|
+
* Decides whether an emitted event reaches a subscription with these arguments. Defaults to all.
|
|
84
|
+
* The client chooses the arguments, so `match` doesn't restrict who can subscribe; use
|
|
85
|
+
* `authorize` for that.
|
|
86
|
+
*/
|
|
87
|
+
match?(args: TArgs, data: TData): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Decides whether the caller may receive this event type with these arguments. Runs on every
|
|
90
|
+
* `events/poll`, every `events/stream` open and every webhook `events/subscribe`, including
|
|
91
|
+
* refreshes; returning `false` rejects the request with -32024 and, for a webhook, removes the
|
|
92
|
+
* existing subscription. An open stream isn't checked again until it reconnects, and a webhook
|
|
93
|
+
* until its next refresh. Defaults to allowing everyone.
|
|
94
|
+
*/
|
|
95
|
+
authorize?(context: MCPServerEventAuthorizeContext<TArgs>): boolean | Promise<boolean>;
|
|
96
|
+
/** Pull source serving `events/poll`. */
|
|
97
|
+
poll?(context: MCPServerEventPollContext<TArgs>): Promise<MCPServerEventPollResult<TData>>;
|
|
98
|
+
/**
|
|
99
|
+
* Restricts the advertised delivery modes to this list. It only narrows: a mode the
|
|
100
|
+
* definition can't serve (for example `'push'` on a type with `poll`) is dropped, and a
|
|
101
|
+
* definition left with none fails at construction.
|
|
102
|
+
*/
|
|
103
|
+
delivery?: EventDeliveryMode[];
|
|
104
|
+
/** Number of emitted events retained for replay and ring-buffer polls. Defaults to 1000. */
|
|
105
|
+
bufferSize?: number;
|
|
106
|
+
/** `nextPollMs` suggested to clients polling the ring buffer. */
|
|
107
|
+
pollIntervalMs?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Server-wide events settings.
|
|
111
|
+
*
|
|
112
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
113
|
+
*/
|
|
114
|
+
export interface MCPServerEventsOptions {
|
|
115
|
+
/** Longest gap between messages on an `events/stream`. Defaults to 30 000 ms. */
|
|
116
|
+
heartbeatIntervalMs?: number;
|
|
117
|
+
/** Descriptors per `events/list` page. Defaults to 100. */
|
|
118
|
+
listPageSize?: number;
|
|
119
|
+
/**
|
|
120
|
+
* Most `events/stream` requests this server keeps open at once, across all clients. Further
|
|
121
|
+
* requests are rejected with -32025 until a stream closes. Defaults to 1024.
|
|
122
|
+
*/
|
|
123
|
+
maxStreams?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Enables webhook delivery (`events/subscribe`, `events/unsubscribe`) for event types fed by
|
|
126
|
+
* `server.events.emit()`. Types with a `poll` source stay poll-only. Webhook subscriptions need an
|
|
127
|
+
* authenticated caller, so serve the server over HTTP with authentication.
|
|
128
|
+
*/
|
|
129
|
+
webhook?: MCPServerWebhookOptions;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Webhook delivery settings.
|
|
133
|
+
*
|
|
134
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
135
|
+
*/
|
|
136
|
+
export interface MCPServerWebhookOptions {
|
|
137
|
+
/** Subscription lifetimes granted for the client's `ttlMs` suggestion. */
|
|
138
|
+
ttl?: {
|
|
139
|
+
/** Granted when the client suggests none. Defaults to 30 minutes. */
|
|
140
|
+
defaultMs?: number;
|
|
141
|
+
/** Shorter suggestions are raised to this. Defaults to 60 seconds. */
|
|
142
|
+
minMs?: number;
|
|
143
|
+
/** Longer suggestions are lowered to this. Defaults to 24 hours. */
|
|
144
|
+
maxMs?: number;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Grant `ttlMs: null` (no expiry) when a client asks for it. Defaults to `false`, which grants
|
|
148
|
+
* `ttl.maxMs` instead. No-expiry subscriptions must survive restarts, so enable this only with a
|
|
149
|
+
* durable `store`.
|
|
150
|
+
*/
|
|
151
|
+
allowNoExpiry?: boolean;
|
|
152
|
+
/** Where subscriptions are kept. Defaults to an in-memory store. */
|
|
153
|
+
store?: WebhookSubscriptionStore;
|
|
154
|
+
/** Callback URL policy. By default only `https` URLs that resolve to public addresses are accepted. */
|
|
155
|
+
url?: WebhookUrlPolicyOptions;
|
|
156
|
+
/** Callback URLs that count as verified without a challenge handshake. */
|
|
157
|
+
allowedUrls?: (url: URL) => boolean;
|
|
158
|
+
/** How long a successful handshake verifies a `(principal, url)` pair. Defaults to 24 hours. */
|
|
159
|
+
verificationTtlMs?: number;
|
|
160
|
+
/** Time allowed for one POST. Defaults to 5 seconds. */
|
|
161
|
+
timeoutMs?: number;
|
|
162
|
+
/** Retries of one delivery after a failure. Exponential backoff with jitter. */
|
|
163
|
+
retry?: {
|
|
164
|
+
/** Attempts per event, including the first. Defaults to 5. */
|
|
165
|
+
maxAttempts?: number;
|
|
166
|
+
/** Defaults to 1 second. */
|
|
167
|
+
initialDelayMs?: number;
|
|
168
|
+
/** Defaults to 5 minutes. */
|
|
169
|
+
maxDelayMs?: number;
|
|
170
|
+
/** Time after the first attempt after which an event is abandoned. Suspended time does not count. Defaults to 15 minutes. */
|
|
171
|
+
maxWindowMs?: number;
|
|
172
|
+
};
|
|
173
|
+
/** When delivery to an endpoint is suspended (`deliveryStatus.active: false`) until the client refreshes. */
|
|
174
|
+
suspend?: {
|
|
175
|
+
/** Rolling window the failure rate is measured over. Defaults to 60 minutes. */
|
|
176
|
+
windowMs?: number;
|
|
177
|
+
/** Attempts in the window needed before suspending. Defaults to 100. */
|
|
178
|
+
minAttempts?: number;
|
|
179
|
+
/** Failure ratio that suspends. Defaults to 0.95. */
|
|
180
|
+
failureRate?: number;
|
|
181
|
+
};
|
|
182
|
+
/** Undelivered events held per subscription before the oldest are dropped and a `gap` is sent. Defaults to 1000. */
|
|
183
|
+
maxPending?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Most webhook subscriptions this process keeps, across all callers. A new subscription past
|
|
186
|
+
* the limit is rejected with -32025; refreshing an existing one is not. Defaults to 1000.
|
|
187
|
+
*/
|
|
188
|
+
maxSubscriptions?: number;
|
|
189
|
+
/** Most webhook subscriptions one authenticated caller can hold. Defaults to 100. */
|
|
190
|
+
maxSubscriptionsPerPrincipal?: number;
|
|
191
|
+
/** How long deliveries are signed with both the old and the new secret after a rotation. Defaults to 5 minutes. */
|
|
192
|
+
secretGraceMs?: number;
|
|
193
|
+
/** Sends one POST. Defaults to `node:http`/`node:https`, connecting to the validated address. */
|
|
194
|
+
transport?: WebhookTransport;
|
|
195
|
+
}
|
|
196
|
+
/** @experimental SEP-3415 is a draft; this API may change. */
|
|
197
|
+
export interface MCPServerEmitOptions {
|
|
198
|
+
/** Unique id clients deduplicate by. Defaults to a random UUID. */
|
|
199
|
+
eventId?: string;
|
|
200
|
+
/** When the event happened. Defaults to now. */
|
|
201
|
+
timestamp?: string | Date;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/events/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK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;IACtC,mHAAmH;IACnH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iGAAiG;IACjG,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAED,8DAA8D;AAC9D,MAAM,WAAW,oBAAoB;IACnC,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
+
import type { SubscribeEventsRequestParams, SubscribeEventsResult } from '../../shared/events/index.js';
|
|
3
|
+
import type { RegisteredEvent, ServerEventRegistry } from './registry.js';
|
|
4
|
+
import type { MCPServerWebhookOptions } from './types.js';
|
|
5
|
+
export interface WebhookDispatcherConfig {
|
|
6
|
+
registry: ServerEventRegistry;
|
|
7
|
+
options: MCPServerWebhookOptions;
|
|
8
|
+
getLogger: () => IMastraLogger;
|
|
9
|
+
/** Source of retry jitter; tests pin it. */
|
|
10
|
+
random?: () => number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Serves webhook delivery for one `MCPServer`: `events/subscribe` upserts, endpoint verification,
|
|
14
|
+
* fan-out of emitted events, signed POSTs with retries, the safe-to-persist watermark, suspension
|
|
15
|
+
* and control envelopes.
|
|
16
|
+
*
|
|
17
|
+
* Subscriptions live in the configured {@link WebhookSubscriptionStore}; delivery state is in
|
|
18
|
+
* memory and only reaches this process's subscriptions.
|
|
19
|
+
*/
|
|
20
|
+
export declare class WebhookDispatcher {
|
|
21
|
+
private readonly config;
|
|
22
|
+
private readonly settings;
|
|
23
|
+
private readonly store;
|
|
24
|
+
private readonly transport;
|
|
25
|
+
private readonly states;
|
|
26
|
+
/** New subscriptions that passed the capacity check and are still being set up, by id → principal. */
|
|
27
|
+
private readonly reserved;
|
|
28
|
+
private readonly verified;
|
|
29
|
+
private readonly fanOutChains;
|
|
30
|
+
private readonly unsubscribers;
|
|
31
|
+
private readonly random;
|
|
32
|
+
private closed;
|
|
33
|
+
constructor(config: WebhookDispatcherConfig);
|
|
34
|
+
/** Subscription id for a key: a truncated SHA-256 over the canonical key. A routing handle, not a capability. */
|
|
35
|
+
static subscriptionId(key: {
|
|
36
|
+
principal: string;
|
|
37
|
+
url: string;
|
|
38
|
+
name: string;
|
|
39
|
+
arguments: Record<string, unknown>;
|
|
40
|
+
}): string;
|
|
41
|
+
/**
|
|
42
|
+
* Creates or refreshes the subscription keyed by `(principal, url, name, args)`.
|
|
43
|
+
* @throws ProtocolError `InvalidParams` for a disallowed callback URL, `CallbackEndpointError` when
|
|
44
|
+
* the endpoint fails verification.
|
|
45
|
+
*/
|
|
46
|
+
subscribe(event: RegisteredEvent, args: Record<string, unknown>, params: SubscribeEventsRequestParams, principal: string): Promise<SubscribeEventsResult>;
|
|
47
|
+
private establish;
|
|
48
|
+
private assertCapacity;
|
|
49
|
+
/** Records a verified `(principal, url)` pair, dropping expired pairs and the oldest past a cap. */
|
|
50
|
+
private rememberVerified;
|
|
51
|
+
private persist;
|
|
52
|
+
/** Removes the subscription with this key, if any. Answers the same either way. */
|
|
53
|
+
unsubscribe(key: {
|
|
54
|
+
principal: string;
|
|
55
|
+
url: string;
|
|
56
|
+
name: string;
|
|
57
|
+
arguments: Record<string, unknown>;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
/** Stops every timer and retry. */
|
|
60
|
+
close(): void;
|
|
61
|
+
private grantTtl;
|
|
62
|
+
private resolveUrl;
|
|
63
|
+
private isVerified;
|
|
64
|
+
/** The challenge handshake: the endpoint must echo a fresh nonce from a `2xx` response. */
|
|
65
|
+
private verify;
|
|
66
|
+
private createState;
|
|
67
|
+
private onEmit;
|
|
68
|
+
private fanOut;
|
|
69
|
+
private matches;
|
|
70
|
+
/** Advances past an event this subscription does not receive. */
|
|
71
|
+
private skip;
|
|
72
|
+
private enqueue;
|
|
73
|
+
/** Drops every undelivered event and tells the endpoint where delivery resumes with a `gap`. */
|
|
74
|
+
private overflow;
|
|
75
|
+
private attempt;
|
|
76
|
+
private scheduleRetry;
|
|
77
|
+
private settle;
|
|
78
|
+
private recordOutcome;
|
|
79
|
+
/** Suspends delivery once the failure rate over the window crosses the threshold. */
|
|
80
|
+
private maybeSuspend;
|
|
81
|
+
/** A refresh is the client's liveness signal: reactivate a suspended subscription and retry what is pending. */
|
|
82
|
+
private resume;
|
|
83
|
+
private terminate;
|
|
84
|
+
/** Sends a control envelope (`gap`, `terminated`), retrying with backoff up to `maxAttempts` attempts. */
|
|
85
|
+
private sendControl;
|
|
86
|
+
/** One signed POST to a subscription's endpoint, re-validating the URL so DNS cannot rebind it. */
|
|
87
|
+
private deliver;
|
|
88
|
+
private post;
|
|
89
|
+
private statusOf;
|
|
90
|
+
private isExpired;
|
|
91
|
+
private expiryTimers;
|
|
92
|
+
private scheduleExpiry;
|
|
93
|
+
private expire;
|
|
94
|
+
private dropState;
|
|
95
|
+
private setTimer;
|
|
96
|
+
private clearTimer;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=webhook-dispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-dispatcher.d.ts","sourceRoot":"","sources":["../../../src/server/events/webhook-dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAUzD,OAAO,KAAK,EAEV,4BAA4B,EAC5B,qBAAqB,EAGtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAuFvD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,OAAO,EAAE,uBAAuB,CAAC;IACjC,SAAS,EAAE,MAAM,aAAa,CAAC;IAC/B,4CAA4C;IAC5C,M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EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,iBAI1G;IAED,mCAAmC;IACnC,KAAK,IAAI,IAAI,CAIZ;IAED,OAAO,CAAC,QAAQ;YAOF,UAAU;IAQxB,OAAO,CAAC,UAAU;IAMlB,2FAA2F;YAC7E,MAAM;IAYpB,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,MAAM;YASA,MAAM;IA0BpB,OAAO,CAAC,OAAO;IAWf,iEAAiE;IACjE,OAAO,CAAC,IAAI;IAMZ,OAAO,CAAC,OAAO;IAcf,gGAAgG;IAChG,OAAO,CAAC,QAAQ;YAWF,OAAO;IAqCrB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,aAAa;IAerB,qFAAqF;IACrF,OAAO,CAAC,YAAY;IAmBpB,gHAAgH;IAChH,OAAO,CAAC,MAAM;YAeA,SAAS;IAiBvB,0GAA0G;YAC5F,WAAW;IAYzB,mGAAmG;YACrF,OAAO;YAiBP,IAAI;IA+BlB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,YAAY,CAAoD;IAExE,OAAO,CAAC,cAAc;YAkBR,MAAM;IAKpB,OAAO,CAAC,SAAS;IAYjB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,UAAU;CAMnB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One webhook subscription as held by the server: the immutable subscription key, the derived
|
|
3
|
+
* `id`, the signing secret and the granted lifetime.
|
|
4
|
+
*
|
|
5
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
6
|
+
*/
|
|
7
|
+
export interface WebhookSubscriptionRecord {
|
|
8
|
+
/** Derived from the key; carried in `X-MCP-Subscription-Id`. */
|
|
9
|
+
id: string;
|
|
10
|
+
/** Canonical identifier of the authenticated subject that subscribed. */
|
|
11
|
+
principal: string;
|
|
12
|
+
/** Callback URL (`delivery.url`). */
|
|
13
|
+
url: string;
|
|
14
|
+
/** Event name. */
|
|
15
|
+
name: string;
|
|
16
|
+
/** Validated subscription arguments. */
|
|
17
|
+
arguments: Record<string, unknown>;
|
|
18
|
+
/** Current `whsec_` signing secret. */
|
|
19
|
+
secret: string;
|
|
20
|
+
/** The secret replaced by the latest rotation, still used to dual-sign until `until` (epoch ms). */
|
|
21
|
+
previousSecret?: {
|
|
22
|
+
secret: string;
|
|
23
|
+
until: number;
|
|
24
|
+
};
|
|
25
|
+
/** Expiry in epoch ms, or `null` for a no-expiry grant. */
|
|
26
|
+
expiresAt: number | null;
|
|
27
|
+
/** Creation time in epoch ms. */
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Where `MCPServer` keeps webhook subscriptions. The default keeps them in memory, which suits short
|
|
32
|
+
* TTL grants: after a restart clients resubscribe on their next refresh. A server that grants
|
|
33
|
+
* no-expiry subscriptions (`allowNoExpiry`) must persist them, so it needs a durable store.
|
|
34
|
+
*
|
|
35
|
+
* In-flight delivery state (retry queue, watermark, delivery status) is not stored here; it stays
|
|
36
|
+
* in memory and is rebuilt by the client's next refresh.
|
|
37
|
+
*
|
|
38
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
39
|
+
*/
|
|
40
|
+
export interface WebhookSubscriptionStore {
|
|
41
|
+
get(id: string): Promise<WebhookSubscriptionRecord | undefined>;
|
|
42
|
+
/** Inserts or replaces the record with this `id`. */
|
|
43
|
+
set(record: WebhookSubscriptionRecord): Promise<void>;
|
|
44
|
+
delete(id: string): Promise<void>;
|
|
45
|
+
/** Every record subscribed to event `name`, including expired ones. */
|
|
46
|
+
list(name: string): Promise<WebhookSubscriptionRecord[]>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Default {@link WebhookSubscriptionStore}: a process-local map.
|
|
50
|
+
*
|
|
51
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
52
|
+
*/
|
|
53
|
+
export declare class InMemoryWebhookSubscriptionStore implements WebhookSubscriptionStore {
|
|
54
|
+
private readonly records;
|
|
55
|
+
get(id: string): Promise<WebhookSubscriptionRecord | undefined>;
|
|
56
|
+
set(record: WebhookSubscriptionRecord): Promise<void>;
|
|
57
|
+
delete(id: string): Promise<void>;
|
|
58
|
+
list(name: string): Promise<WebhookSubscriptionRecord[]>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=webhook-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-store.d.ts","sourceRoot":"","sources":["../../../src/server/events/webhook-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,oGAAoG;IACpG,cAAc,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,2DAA2D;IAC3D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAAC;IAChE,qDAAqD;IACrD,GAAG,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,uEAAuE;IACvE,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;CAC1D;AAED;;;;GAIG;AACH,qBAAa,gCAAiC,YAAW,wBAAwB;IAC/E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgD;IAElE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC,CAEpE;IAEK,GAAG,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IAEK,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtC;IAEK,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAE7D;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { WebhookFailureReason } from '../../shared/events/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* One POST to a callback endpoint.
|
|
4
|
+
*
|
|
5
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
6
|
+
*/
|
|
7
|
+
export interface WebhookTransportRequest {
|
|
8
|
+
url: URL;
|
|
9
|
+
/** Validated IP to connect to. The hostname in `url` is used only for TLS SNI and the `Host` header. */
|
|
10
|
+
address: string;
|
|
11
|
+
family: 4 | 6;
|
|
12
|
+
headers: Record<string, string>;
|
|
13
|
+
body: string;
|
|
14
|
+
timeoutMs: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Outcome of one POST: the response status and (truncated) body, or the failure category when
|
|
18
|
+
* there was no HTTP response.
|
|
19
|
+
*
|
|
20
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
21
|
+
*/
|
|
22
|
+
export type WebhookTransportResult = {
|
|
23
|
+
status: number;
|
|
24
|
+
body: string;
|
|
25
|
+
} | {
|
|
26
|
+
error: WebhookFailureReason;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Sends one webhook POST. Must not follow redirects.
|
|
30
|
+
*
|
|
31
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
32
|
+
*/
|
|
33
|
+
export type WebhookTransport = (request: WebhookTransportRequest) => Promise<WebhookTransportResult>;
|
|
34
|
+
/** Maps a non-2xx status to its failure category. */
|
|
35
|
+
export declare function statusFailure(status: number): WebhookFailureReason;
|
|
36
|
+
/**
|
|
37
|
+
* Default {@link WebhookTransport}: `node:http`/`node:https` connecting to the pinned address, so a
|
|
38
|
+
* DNS answer that changes after validation cannot redirect the request. Redirects are returned as
|
|
39
|
+
* plain 3xx statuses (never followed) and only a bounded prefix of the response body is read.
|
|
40
|
+
*
|
|
41
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
42
|
+
*/
|
|
43
|
+
export declare const nodeWebhookTransport: WebhookTransport;
|
|
44
|
+
//# sourceMappingURL=webhook-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-transport.d.ts","sourceRoot":"","sources":["../../../src/server/events/webhook-transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAKhE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,GAAG,CAAC;IACT,wGAAwG;IACxG,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAExG;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;AAErG,qDAAqD;AACrD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAElE;AAqBD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,gBAkD/B,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC"}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type * as http from 'node:http';
|
|
2
2
|
import type { Agent, ToolsInput } from '@mastra/core/agent';
|
|
3
3
|
import { MCPServerBase } from '@mastra/core/mcp';
|
|
4
|
-
import type { MCPServerConfig as CoreMCPServerConfig, MCPToolExecutionResultV2, ServerDetailInfo, ServerInfo } from '@mastra/core/mcp';
|
|
4
|
+
import type { MCPServerConfig as CoreMCPServerConfig, MCPServerEventInfo, MCPServerEventsInspector, MCPToolExecutionResultV2, ServerDetailInfo, ServerInfo } from '@mastra/core/mcp';
|
|
5
5
|
import { RequestContext } from '@mastra/core/request-context';
|
|
6
6
|
import type { InternalCoreTool, MCPToolType } from '@mastra/core/tools';
|
|
7
7
|
import type { Workflow } from '@mastra/core/workflows';
|
|
8
8
|
import type { Resource, jsonSchemaValidator } from '@modelcontextprotocol/server';
|
|
9
9
|
import { ServerPromptActions, ServerResourceActions, ServerToolActions } from './actions.js';
|
|
10
|
+
import { ServerEventActions } from './events/actions.js';
|
|
11
|
+
import type { MCPServerEventDefinition, MCPServerEventsOptions } from './events/types.js';
|
|
10
12
|
import type { AppResources, MCPServerCacheHints, MCPServerHTTPRequestOptions, MCPServerPrompts, MCPServerRequestStateOptions, MCPServerResources } from './types.js';
|
|
11
13
|
export interface MCPServerConfig extends CoreMCPServerConfig {
|
|
12
14
|
resources?: MCPServerResources;
|
|
@@ -18,6 +20,19 @@ export interface MCPServerConfig extends CoreMCPServerConfig {
|
|
|
18
20
|
cacheHints?: MCPServerCacheHints;
|
|
19
21
|
/** Integrity protection for `input_required` continuation state. */
|
|
20
22
|
requestState?: MCPServerRequestStateOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Event types served over the MCP Events extension (`events/list`, `events/poll`,
|
|
25
|
+
* `events/stream`), keyed by event name. Declare each with `defineEvent()`.
|
|
26
|
+
*
|
|
27
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
28
|
+
*/
|
|
29
|
+
events?: Record<string, MCPServerEventDefinition>;
|
|
30
|
+
/**
|
|
31
|
+
* Server-wide settings for `events`.
|
|
32
|
+
*
|
|
33
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
34
|
+
*/
|
|
35
|
+
eventsOptions?: MCPServerEventsOptions;
|
|
21
36
|
}
|
|
22
37
|
export interface MCPServerHTTPOptions {
|
|
23
38
|
url: URL;
|
|
@@ -69,6 +84,13 @@ export declare class MCPServer extends MCPServerBase {
|
|
|
69
84
|
readonly resources: ServerResourceActions;
|
|
70
85
|
readonly prompts: ServerPromptActions;
|
|
71
86
|
readonly toolActions: ServerToolActions;
|
|
87
|
+
/**
|
|
88
|
+
* Publishes occurrences of the configured `events` to poll, push and (when
|
|
89
|
+
* `eventsOptions.webhook` is set) webhook subscribers.
|
|
90
|
+
*
|
|
91
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
92
|
+
*/
|
|
93
|
+
readonly events: ServerEventActions;
|
|
72
94
|
private readonly resourceOptions?;
|
|
73
95
|
private readonly promptOptions?;
|
|
74
96
|
private readonly appResourceList;
|
|
@@ -78,6 +100,10 @@ export declare class MCPServer extends MCPServerBase {
|
|
|
78
100
|
private readonly mapAuthInfoToUser?;
|
|
79
101
|
private readonly fga?;
|
|
80
102
|
private readonly requestStateCodec;
|
|
103
|
+
private readonly eventRegistry;
|
|
104
|
+
private readonly eventsOptions;
|
|
105
|
+
private eventsInspector;
|
|
106
|
+
private readonly webhooks?;
|
|
81
107
|
private httpHandler?;
|
|
82
108
|
private nodeHandler?;
|
|
83
109
|
private stdioHandle?;
|
|
@@ -120,7 +146,19 @@ export declare class MCPServer extends MCPServerBase {
|
|
|
120
146
|
private toMCPTool;
|
|
121
147
|
private hasUiMetadata;
|
|
122
148
|
private capabilities;
|
|
149
|
+
/**
|
|
150
|
+
* Settings advertised under `extensions["io.modelcontextprotocol/events"]`. `listChanged` is not
|
|
151
|
+
* advertised: the SDK's `subscriptions/listen` drops the `eventsListChanged` filter, so
|
|
152
|
+
* `notifications/events/list_changed` cannot be delivered.
|
|
153
|
+
*/
|
|
154
|
+
private eventsCapability;
|
|
123
155
|
private createServerInstance;
|
|
156
|
+
/**
|
|
157
|
+
* {@link setTracedHandler} for methods outside the spec's request map (the events
|
|
158
|
+
* extension): the request runs under an `MCP_SERVER_REQUEST` span with its resolved
|
|
159
|
+
* request context. A push stream's span lasts as long as the stream.
|
|
160
|
+
*/
|
|
161
|
+
private traceCustomRequest;
|
|
124
162
|
/**
|
|
125
163
|
* Registers `method` under an `MCP_SERVER_REQUEST` span, so every request the
|
|
126
164
|
* server answers is recorded — including the list and read methods that never
|
|
@@ -193,6 +231,20 @@ export declare class MCPServer extends MCPServerBase {
|
|
|
193
231
|
listResources(): Promise<{
|
|
194
232
|
resources: Resource[];
|
|
195
233
|
}>;
|
|
234
|
+
/**
|
|
235
|
+
* The declared event types as Studio shows them, or `undefined` when the server has none.
|
|
236
|
+
* @experimental
|
|
237
|
+
*/
|
|
238
|
+
getEventsInfo(): {
|
|
239
|
+
events: MCPServerEventInfo[];
|
|
240
|
+
} | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Polls, streams and test-emits events in-process through the `events/poll` and
|
|
243
|
+
* `events/stream` code paths, or `undefined` when the server has none. Used by Studio.
|
|
244
|
+
* @experimental
|
|
245
|
+
*/
|
|
246
|
+
getEventsInspector(): MCPServerEventsInspector | undefined;
|
|
247
|
+
private eventsDeps;
|
|
196
248
|
}
|
|
197
249
|
export { ServerPromptActions, ServerResourceActions, ServerToolActions };
|
|
198
250
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EACV,eAAe,IAAI,mBAAmB,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EACV,eAAe,IAAI,mBAAmB,EACtC,kBAAkB,EAClB,wBAAwB,EAExB,wBAAwB,EACxB,gBAAgB,EAChB,UAAU,EACX,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,KAAK,EAAE,gBAAgB,EAA2B,WAAW,EAAc,MAAM,oBAAoB,CAAC;AAE7G,OAAO,KAAK,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AAO,CAAC,CAAA;SAAE,CAAC,CAAC;KACpH,CAAC,CAaD;IAED,qFAAqF;IAC/E,aAAa,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC,CAExD;IAED;;;OAGG;IACH,aAAa,IAAI;QAAE,MAAM,EAAE,kBAAkB,EAAE,CAAA;KAAE,GAAG,SAAS,CAG5D;IAED;;;;OAIG;IACH,kBAAkB,IAAI,wBAAwB,GAAG,SAAS,CAIzD;IAED,OAAO,CAAC,UAAU;CASnB;AAyBD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,mBAAmB,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,mBAAmB,SAAS,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** @experimental SEP-3415 is a draft; this API may change. */
|
|
2
|
+
export type WebhookUrlFailure = 'invalid_url' | 'insecure_scheme' | 'disallowed_address' | 'dns_failure';
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when a callback URL fails the webhook URL policy.
|
|
5
|
+
*
|
|
6
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
7
|
+
*/
|
|
8
|
+
export declare class WebhookUrlError extends Error {
|
|
9
|
+
readonly reason: WebhookUrlFailure;
|
|
10
|
+
readonly url: string;
|
|
11
|
+
constructor(reason: WebhookUrlFailure, url: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
/** @experimental SEP-3415 is a draft; this API may change. */
|
|
14
|
+
export type WebhookLookup = (hostname: string) => Promise<Array<{
|
|
15
|
+
address: string;
|
|
16
|
+
family: 4 | 6;
|
|
17
|
+
}>>;
|
|
18
|
+
/** @experimental SEP-3415 is a draft; this API may change. */
|
|
19
|
+
export interface WebhookUrlPolicyOptions {
|
|
20
|
+
/** Skip address classification, allowing private and loopback targets (tests and private deployments). */
|
|
21
|
+
allowPrivate?: boolean;
|
|
22
|
+
/** Allow `http:` callback URLs. */
|
|
23
|
+
allowInsecure?: boolean;
|
|
24
|
+
/** Resolver used for hostnames. Defaults to `dns.promises.lookup` returning every address. */
|
|
25
|
+
lookup?: WebhookLookup;
|
|
26
|
+
}
|
|
27
|
+
/** @experimental SEP-3415 is a draft; this API may change. */
|
|
28
|
+
export interface ResolvedWebhookUrl {
|
|
29
|
+
url: URL;
|
|
30
|
+
/** The validated IP that delivery must connect to, so a later DNS answer cannot rebind it. */
|
|
31
|
+
address: string;
|
|
32
|
+
family: 4 | 6;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* True when a literal IP address is globally routable. Non-IP input, scoped (zone) addresses, and
|
|
36
|
+
* NAT64 / 6to4 addresses that embed a non-global IPv4 address are all treated as not routable.
|
|
37
|
+
*
|
|
38
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isGloballyRoutableAddress(ip: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Synchronously validate a callback URL: it must parse, use `https:` (unless `allowInsecure`), carry no
|
|
43
|
+
* credentials, and, when its host is an IP literal, that IP must be globally routable (unless `allowPrivate`).
|
|
44
|
+
* Hostnames are not resolved here; use {@link resolveAndValidate} before connecting.
|
|
45
|
+
*
|
|
46
|
+
* @throws {WebhookUrlError}
|
|
47
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateWebhookUrl(url: string, opts?: WebhookUrlPolicyOptions): URL;
|
|
50
|
+
/**
|
|
51
|
+
* Validate a callback URL and resolve it to the IP that delivery must connect to. Every resolved address
|
|
52
|
+
* must be globally routable (a mixed answer is a DNS-rebinding vector); the first is returned as the pinned
|
|
53
|
+
* address. Delivery connects to that address and uses the URL hostname for TLS SNI and the Host header.
|
|
54
|
+
*
|
|
55
|
+
* @throws {WebhookUrlError}
|
|
56
|
+
* @experimental SEP-3415 is a draft; this API may change.
|
|
57
|
+
*/
|
|
58
|
+
export declare function resolveAndValidate(url: string, opts?: WebhookUrlPolicyOptions): Promise<ResolvedWebhookUrl>;
|
|
59
|
+
//# sourceMappingURL=webhook-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-url.d.ts","sourceRoot":"","sources":["../../../src/shared/events/webhook-url.ts"],"names":[],"mappings":"AAQA,8DAA8D;AAC9D,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,aAAa,CAAC;AAEzG;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,YAAY,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAKlE;CACF;AAED,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC,CAAC,CAAC;AAErG,8DAA8D;AAC9D,MAAM,WAAW,uBAAuB;IACtC,0GAA0G;IAC1G,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO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