@frontmcp/testing 1.11.3 → 1.12.0-rc.1

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.
@@ -0,0 +1,85 @@
1
+ import { type EventWebhookReceiver } from '@frontmcp/sdk';
2
+ import type { WebhookSignatureCheck } from '@frontmcp/utils';
3
+ export interface WebhookReceiverOptions {
4
+ /**
5
+ * The secrets deliveries of any subscription are signed with. A request none of them signed is answered 401. Without
6
+ * any, and without a secret an events client registered, nothing is checked.
7
+ */
8
+ secrets?: string[];
9
+ /** The path prefixes the well-known document declares. Without any, the document is a 404 and the challenge is used. */
10
+ receivers?: string[];
11
+ /** The path deliveries are sent to. @default '/hooks/mcp' */
12
+ path?: string;
13
+ /** @default an ephemeral port */
14
+ port?: number;
15
+ }
16
+ export interface WebhookReceiverInfo {
17
+ /** The callback URL to subscribe with. */
18
+ url: string;
19
+ origin: string;
20
+ port: number;
21
+ }
22
+ export type ReceivedWebhookKind = 'verification' | 'gap' | 'terminated' | 'event';
23
+ export interface ReceivedWebhook {
24
+ kind: ReceivedWebhookKind;
25
+ path: string;
26
+ /** The body exactly as it arrived: the bytes the signature covers. */
27
+ body: string;
28
+ /** The body as JSON, or undefined when it is not JSON. */
29
+ json: Record<string, unknown> | undefined;
30
+ webhookId?: string;
31
+ webhookTimestamp?: string;
32
+ webhookSignature?: string;
33
+ subscriptionId?: string;
34
+ /** `unchecked` when the receiver has no secret for the request's subscription. */
35
+ signatureCheck: WebhookSignatureCheck | 'unchecked';
36
+ /** The status the receiver answered with. */
37
+ answeredStatus: number;
38
+ receivedAt: number;
39
+ }
40
+ /** An HTTP server on 127.0.0.1 that stands in for the callback of a webhook subscription. */
41
+ export declare class WebhookReceiver {
42
+ private readonly options;
43
+ private readonly events;
44
+ private readonly received;
45
+ private server;
46
+ private info;
47
+ private failuresLeft;
48
+ private failureStatus;
49
+ private echoesChallenges;
50
+ /** A receiver that is not listening yet. */
51
+ constructor(options?: WebhookReceiverOptions);
52
+ /** The SDK receiver behind it, for `withEvents({ webhook: { url, receiver } })` of an events client. */
53
+ get eventReceiver(): EventWebhookReceiver;
54
+ /** Listen on 127.0.0.1 and answer with the callback URL. */
55
+ start(): Promise<WebhookReceiverInfo>;
56
+ /** Stop listening. */
57
+ stop(): Promise<void>;
58
+ /** The callback URL; the receiver must be started. */
59
+ get url(): string;
60
+ /** Every request received, oldest first. */
61
+ get requests(): readonly ReceivedWebhook[];
62
+ /** The verification challenges received. */
63
+ verifications(): ReceivedWebhook[];
64
+ /** The event deliveries received, retries included. */
65
+ deliveries(): ReceivedWebhook[];
66
+ /** Forget the requests received so far. */
67
+ clear(): void;
68
+ /** Accept deliveries signed with one more secret, as after a rotation. */
69
+ addSecret(secret: string): void;
70
+ /** Answer the next `count` deliveries with `status` instead of 200. Verification challenges are not affected. */
71
+ failNext(count: number, status?: number): void;
72
+ /** Whether a verification challenge is echoed (the default) or answered with an empty object. */
73
+ echoChallenges(echo: boolean): void;
74
+ /** Resolve once `count` event deliveries arrived, retries included; reject after `timeoutMs`. */
75
+ waitForDeliveries(count: number, timeoutMs?: number): Promise<ReceivedWebhook[]>;
76
+ /** Answer one request: the well-known document, or a webhook that is checked, recorded and answered. */
77
+ private handle;
78
+ /** The answer to a webhook: unchecked without secrets, a pending failure for a signed delivery, else the SDK's. */
79
+ private answer;
80
+ /** Serve the well-known document when the receiver declares path prefixes. */
81
+ private answerWellKnown;
82
+ /** The status of the next delivery: a pending failure, else 200. */
83
+ private nextDeliveryStatus;
84
+ }
85
+ //# sourceMappingURL=webhook-receiver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-receiver.d.ts","sourceRoot":"","sources":["../../src/webhook/webhook-receiver.ts"],"names":[],"mappings":"AAiBA,OAAO,EAA8B,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAM7D,MAAM,WAAW,sBAAsB;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