@crvouga/mockingbird-notifications 0.3.0 → 0.4.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 +2 -2
- package/dist/{chunk-ZRI5NLWC.js → chunk-5DUELOZW.js} +29 -4
- package/dist/{chunk-ZRI5NLWC.js.map → chunk-5DUELOZW.js.map} +2 -2
- package/dist/{chunk-TN2LRJAM.js → chunk-5KZ24SHQ.js} +11 -385
- package/dist/chunk-5KZ24SHQ.js.map +7 -0
- package/dist/chunk-JECNH6UB.js +393 -0
- package/dist/chunk-JECNH6UB.js.map +7 -0
- package/dist/{chunk-4BPQC52H.js → chunk-QQK27AFM.js} +5 -3
- package/dist/chunk-QQK27AFM.js.map +7 -0
- package/dist/cli.js +4 -3
- package/dist/cli.js.map +1 -1
- package/dist/document-OSYEGZSQ.js +11 -0
- package/dist/document-OSYEGZSQ.js.map +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/server.js +4 -3
- package/dist/{types-CU0LKNyA.d.ts → types-BBDh1R-w.d.ts} +2 -2
- package/dist/ui.js +5 -4
- package/dist/ui.js.map +2 -2
- package/package.json +3 -2
- package/dist/chunk-4BPQC52H.js.map +0 -7
- package/dist/chunk-TN2LRJAM.js.map +0 -7
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNotificationHarness
|
|
3
|
+
} from "./chunk-5DUELOZW.js";
|
|
4
|
+
import {
|
|
5
|
+
adminClientScript,
|
|
6
|
+
adminClientSource
|
|
7
|
+
} from "./chunk-5KZ24SHQ.js";
|
|
8
|
+
|
|
9
|
+
// src/server.ts
|
|
10
|
+
import { readFile } from "node:fs/promises";
|
|
11
|
+
|
|
12
|
+
// ../adapters/node/dist/serve.js
|
|
13
|
+
import { createServer } from "node:http";
|
|
14
|
+
import { Readable } from "node:stream";
|
|
15
|
+
var serve = async (api, options = {}) => {
|
|
16
|
+
const maxBytes = options.maxBodyBytes ?? 16 * 1024 * 1024;
|
|
17
|
+
const timeoutMs = options.requestTimeoutMs ?? 3e4;
|
|
18
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0 || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1)
|
|
19
|
+
throw new Error("invalid request limits");
|
|
20
|
+
const server = createServer(async (req, res) => {
|
|
21
|
+
const aborted = new AbortController();
|
|
22
|
+
let reader;
|
|
23
|
+
let timer;
|
|
24
|
+
const abort = () => {
|
|
25
|
+
aborted.abort();
|
|
26
|
+
void reader?.cancel().catch(() => {
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const fail = (status, message) => {
|
|
30
|
+
if (!res.headersSent && !res.destroyed) {
|
|
31
|
+
res.writeHead(status, { "content-type": "application/json", connection: "close" });
|
|
32
|
+
res.end(JSON.stringify({ error: { type: "mockingbird_transport", message } }));
|
|
33
|
+
}
|
|
34
|
+
abort();
|
|
35
|
+
};
|
|
36
|
+
req.once("aborted", abort);
|
|
37
|
+
res.once("close", abort);
|
|
38
|
+
res.once("error", abort);
|
|
39
|
+
try {
|
|
40
|
+
const address = server.address();
|
|
41
|
+
const port = typeof address === "object" && address !== null ? address.port : 80;
|
|
42
|
+
const url = new URL((req.url ?? "/").replace(/^\/+/, "/"), `http://${req.headers.host ?? `localhost:${port}`}`);
|
|
43
|
+
const headers = new Headers();
|
|
44
|
+
for (const [name, value] of Object.entries(req.headers)) {
|
|
45
|
+
if (Array.isArray(value))
|
|
46
|
+
for (const item of value)
|
|
47
|
+
headers.append(name, item);
|
|
48
|
+
else if (value !== void 0)
|
|
49
|
+
headers.set(name, value);
|
|
50
|
+
}
|
|
51
|
+
const init = {
|
|
52
|
+
method: req.method ?? "GET",
|
|
53
|
+
headers,
|
|
54
|
+
signal: aborted.signal
|
|
55
|
+
};
|
|
56
|
+
if (init.method !== "GET" && init.method !== "HEAD") {
|
|
57
|
+
if (Number(req.headers["content-length"]) > maxBytes) {
|
|
58
|
+
fail(413, "request body exceeds byte limit");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let bytes = 0;
|
|
62
|
+
const source = Readable.toWeb(req);
|
|
63
|
+
init.body = source.pipeThrough(new TransformStream({
|
|
64
|
+
transform(chunk, controller) {
|
|
65
|
+
bytes += chunk.byteLength;
|
|
66
|
+
if (bytes > maxBytes) {
|
|
67
|
+
fail(413, "request body exceeds byte limit");
|
|
68
|
+
controller.error(new Error("request body exceeds byte limit"));
|
|
69
|
+
} else
|
|
70
|
+
controller.enqueue(chunk);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
init.duplex = "half";
|
|
74
|
+
timer = setTimeout(() => fail(408, "request body timed out"), timeoutMs);
|
|
75
|
+
req.once("end", () => clearTimeout(timer));
|
|
76
|
+
}
|
|
77
|
+
const response = await api.fetch(new Request(url, init));
|
|
78
|
+
if (aborted.signal.aborted || res.destroyed) {
|
|
79
|
+
await response.body?.cancel();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const output = Object.fromEntries(response.headers);
|
|
83
|
+
const cookies = response.headers.getSetCookie();
|
|
84
|
+
if (cookies.length)
|
|
85
|
+
output["set-cookie"] = cookies;
|
|
86
|
+
res.writeHead(response.status, output);
|
|
87
|
+
if (!response.body) {
|
|
88
|
+
res.end();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
res.flushHeaders();
|
|
92
|
+
reader = response.body.getReader();
|
|
93
|
+
for (; ; ) {
|
|
94
|
+
const { done, value } = await reader.read();
|
|
95
|
+
if (done || aborted.signal.aborted)
|
|
96
|
+
break;
|
|
97
|
+
if (!res.write(value)) {
|
|
98
|
+
await new Promise((resolve) => {
|
|
99
|
+
const finish = () => {
|
|
100
|
+
res.off("drain", finish);
|
|
101
|
+
res.off("close", finish);
|
|
102
|
+
res.off("error", finish);
|
|
103
|
+
resolve();
|
|
104
|
+
};
|
|
105
|
+
res.once("drain", finish);
|
|
106
|
+
res.once("close", finish);
|
|
107
|
+
res.once("error", finish);
|
|
108
|
+
if (res.destroyed || aborted.signal.aborted)
|
|
109
|
+
finish();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!aborted.signal.aborted)
|
|
114
|
+
res.end();
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (error.code === "MOCKINGBIRD_DROP")
|
|
117
|
+
req.socket.destroy();
|
|
118
|
+
else if (!aborted.signal.aborted && !res.destroyed) {
|
|
119
|
+
if (res.headersSent)
|
|
120
|
+
res.destroy();
|
|
121
|
+
else {
|
|
122
|
+
res.writeHead(500, { "content-type": "application/json" });
|
|
123
|
+
res.end(JSON.stringify({
|
|
124
|
+
error: {
|
|
125
|
+
type: "mockingbird_internal",
|
|
126
|
+
message: error instanceof Error ? error.message : String(error)
|
|
127
|
+
}
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} finally {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
reader?.releaseLock();
|
|
134
|
+
req.off("aborted", abort);
|
|
135
|
+
res.off("close", abort);
|
|
136
|
+
res.off("error", abort);
|
|
137
|
+
if (!req.complete)
|
|
138
|
+
req.resume();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
server.requestTimeout = timeoutMs;
|
|
142
|
+
await new Promise((resolve, reject) => {
|
|
143
|
+
server.once("error", reject);
|
|
144
|
+
server.listen(options.port ?? 0, options.host, resolve);
|
|
145
|
+
});
|
|
146
|
+
return server;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// ../adapters/node/dist/listen.js
|
|
150
|
+
var listen = async (api, options = {}) => {
|
|
151
|
+
const host = options.host ?? "127.0.0.1";
|
|
152
|
+
const server = await serve(api, {
|
|
153
|
+
port: options.port ?? 0,
|
|
154
|
+
host,
|
|
155
|
+
...options.maxBodyBytes !== void 0 ? { maxBodyBytes: options.maxBodyBytes } : {}
|
|
156
|
+
});
|
|
157
|
+
const address = server.address();
|
|
158
|
+
const port = typeof address === "object" && address !== null ? address.port : options.port ?? 0;
|
|
159
|
+
const shown = host.includes(":") ? `[${host}]` : host;
|
|
160
|
+
return {
|
|
161
|
+
url: `http://${shown}:${port}`,
|
|
162
|
+
port,
|
|
163
|
+
host,
|
|
164
|
+
server,
|
|
165
|
+
close: () => new Promise((resolve, reject) => {
|
|
166
|
+
server.close((error) => {
|
|
167
|
+
if (error && error.code !== "ERR_SERVER_NOT_RUNNING")
|
|
168
|
+
reject(error);
|
|
169
|
+
else
|
|
170
|
+
resolve();
|
|
171
|
+
});
|
|
172
|
+
server.closeAllConnections?.();
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// ../admin-ui/dist/compose.js
|
|
178
|
+
var composeAdminRoutes = (apis, options) => {
|
|
179
|
+
if (apis.length === 0)
|
|
180
|
+
throw new RangeError("composeAdminApis needs at least one admin API");
|
|
181
|
+
const ids = /* @__PURE__ */ new Set();
|
|
182
|
+
for (const api of apis) {
|
|
183
|
+
if (!/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(api.id))
|
|
184
|
+
throw new RangeError(`invalid admin API id ${JSON.stringify(api.id)}`);
|
|
185
|
+
if (ids.has(api.id))
|
|
186
|
+
throw new RangeError(`duplicate admin API id ${api.id}`);
|
|
187
|
+
ids.add(api.id);
|
|
188
|
+
}
|
|
189
|
+
const prefix = `/${(options.prefix ?? "/__admin").replace(/^\/+|\/+$/g, "")}`;
|
|
190
|
+
const first = apis[0];
|
|
191
|
+
const config = {
|
|
192
|
+
service: first.service,
|
|
193
|
+
adminPrefix: `${prefix}/apis/${first.id}`,
|
|
194
|
+
adminKeyHeader: first.adminKeyHeader,
|
|
195
|
+
standardRoutes: first.standardRoutes,
|
|
196
|
+
brandsUrl: options.brandsUrl,
|
|
197
|
+
apis: apis.map(({ fetch: _fetch, ...api }) => ({
|
|
198
|
+
...api,
|
|
199
|
+
adminPrefix: `${prefix}/apis/${api.id}`
|
|
200
|
+
}))
|
|
201
|
+
};
|
|
202
|
+
return {
|
|
203
|
+
config,
|
|
204
|
+
prefix,
|
|
205
|
+
async fetch(request) {
|
|
206
|
+
const url = new URL(request.url);
|
|
207
|
+
const root = `${prefix}/apis/`;
|
|
208
|
+
if (!url.pathname.startsWith(root))
|
|
209
|
+
return new Response("Not found", { status: 404 });
|
|
210
|
+
const rest = url.pathname.slice(root.length);
|
|
211
|
+
const slash = rest.indexOf("/");
|
|
212
|
+
const id = slash < 0 ? rest : rest.slice(0, slash);
|
|
213
|
+
const api = apis.find((candidate) => candidate.id === id);
|
|
214
|
+
if (!api)
|
|
215
|
+
return new Response("Not found", { status: 404 });
|
|
216
|
+
url.pathname = `${api.adminPrefix.replace(/\/$/, "")}${slash < 0 ? "" : rest.slice(slash)}`;
|
|
217
|
+
return api.fetch(new Request(url, request));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// ../admin-ui/dist/index.js
|
|
223
|
+
var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[char] ?? char);
|
|
224
|
+
var composeAdminApis = (apis, options) => {
|
|
225
|
+
const { config, prefix, fetch: forward } = composeAdminRoutes(apis, options);
|
|
226
|
+
const title = escapeHtml(options.title ?? "Mockingbird");
|
|
227
|
+
const document = `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light dark"><title>${title} admin</title><style>html,body{margin:0;min-height:100%}#admin-root{min-height:100%}</style></head><body><main id="admin-root" data-mockingbird-admin data-admin-ui-library="antd" data-service="${title}"><noscript>Enable JavaScript to use administration.</noscript></main>${adminClientSource(config)}</body></html>`;
|
|
228
|
+
return {
|
|
229
|
+
config,
|
|
230
|
+
async fetch(request) {
|
|
231
|
+
const url = new URL(request.url);
|
|
232
|
+
if (request.method === "GET" && (url.pathname === `${prefix}/ui` || url.pathname === `${prefix}/ui/`))
|
|
233
|
+
return new Response(document, {
|
|
234
|
+
headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" }
|
|
235
|
+
});
|
|
236
|
+
return forward(request);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// src/admin-gateway.ts
|
|
242
|
+
var ADMIN_BRANDS_URL = "https://mockingbird.chrisvouga.dev/brands.json";
|
|
243
|
+
var PREFIX = "/admin";
|
|
244
|
+
var KEY_HEADER = "x-mockingbird-admin-key";
|
|
245
|
+
var HOP_HEADERS = [
|
|
246
|
+
"connection",
|
|
247
|
+
"content-encoding",
|
|
248
|
+
"content-length",
|
|
249
|
+
"host",
|
|
250
|
+
"keep-alive",
|
|
251
|
+
"transfer-encoding"
|
|
252
|
+
];
|
|
253
|
+
var script;
|
|
254
|
+
var adminScript = () => {
|
|
255
|
+
script ??= adminClientScript();
|
|
256
|
+
return script;
|
|
257
|
+
};
|
|
258
|
+
var idFor = (name, taken) => {
|
|
259
|
+
const base = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56) || "emulator";
|
|
260
|
+
let id = base;
|
|
261
|
+
for (let n = 2; taken.has(id); n++) id = `${base}-${n}`;
|
|
262
|
+
taken.add(id);
|
|
263
|
+
return id;
|
|
264
|
+
};
|
|
265
|
+
var failure = (status, message) => new Response(JSON.stringify({ error: { type: "mockingbird_notifications", message } }), {
|
|
266
|
+
status,
|
|
267
|
+
headers: { "content-type": "application/json; charset=utf-8" }
|
|
268
|
+
});
|
|
269
|
+
var adminGateway = (options = {}) => (context) => {
|
|
270
|
+
const brandsUrl = options.brandsUrl ?? ADMIN_BRANDS_URL;
|
|
271
|
+
const forward = (target) => async (request) => {
|
|
272
|
+
const from = new URL(request.url);
|
|
273
|
+
const headers = new Headers(request.headers);
|
|
274
|
+
for (const name of HOP_HEADERS) headers.delete(name);
|
|
275
|
+
headers.delete("accept-encoding");
|
|
276
|
+
if (!headers.has(KEY_HEADER))
|
|
277
|
+
for (const [name, value] of Object.entries(context.headers(target.name)))
|
|
278
|
+
headers.set(name, value);
|
|
279
|
+
const hasBody = request.method !== "GET" && request.method !== "HEAD";
|
|
280
|
+
try {
|
|
281
|
+
const response = await target.fetch(
|
|
282
|
+
new Request(new URL(`${from.pathname}${from.search}`, target.adminUrl), {
|
|
283
|
+
method: request.method,
|
|
284
|
+
headers,
|
|
285
|
+
...hasBody ? { body: await request.arrayBuffer() } : {},
|
|
286
|
+
signal: request.signal
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
const out = new Headers(response.headers);
|
|
290
|
+
for (const name of HOP_HEADERS) out.delete(name);
|
|
291
|
+
return new Response(response.body, {
|
|
292
|
+
status: response.status,
|
|
293
|
+
statusText: response.statusText,
|
|
294
|
+
headers: out
|
|
295
|
+
});
|
|
296
|
+
} catch (error) {
|
|
297
|
+
return failure(
|
|
298
|
+
502,
|
|
299
|
+
`${target.name} is unreachable at ${target.adminUrl}: ${error instanceof Error ? error.message : String(error)}`
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
let composed = null;
|
|
304
|
+
const compose = async () => {
|
|
305
|
+
const targets = await context.targets();
|
|
306
|
+
if (targets.length === 0) return null;
|
|
307
|
+
const key = targets.map((t) => `${t.name}\0${t.target}\0${t.adminUrl}`).join("\n");
|
|
308
|
+
if (composed?.key === key) return composed;
|
|
309
|
+
const taken = /* @__PURE__ */ new Set();
|
|
310
|
+
const apis = targets.map(
|
|
311
|
+
(target) => ({
|
|
312
|
+
id: idFor(target.name, taken),
|
|
313
|
+
label: target.name === target.target ? target.name : `${target.name} (${target.target})`,
|
|
314
|
+
service: target.target,
|
|
315
|
+
adminPrefix: new URL(target.adminUrl).pathname.replace(/\/+$/, ""),
|
|
316
|
+
adminKeyHeader: KEY_HEADER,
|
|
317
|
+
standardRoutes: [],
|
|
318
|
+
fetch: forward(target)
|
|
319
|
+
})
|
|
320
|
+
);
|
|
321
|
+
const first = apis[0];
|
|
322
|
+
const routes = composeAdminApis(apis, { brandsUrl, prefix: PREFIX, title: context.title });
|
|
323
|
+
composed = {
|
|
324
|
+
key,
|
|
325
|
+
config: {
|
|
326
|
+
service: first.service,
|
|
327
|
+
adminPrefix: `${PREFIX}/apis/${first.id}`,
|
|
328
|
+
adminKeyHeader: KEY_HEADER,
|
|
329
|
+
standardRoutes: [],
|
|
330
|
+
brandsUrl,
|
|
331
|
+
apis: apis.map(({ fetch: _fetch, ...api }) => ({
|
|
332
|
+
...api,
|
|
333
|
+
adminPrefix: `${PREFIX}/apis/${api.id}`
|
|
334
|
+
}))
|
|
335
|
+
},
|
|
336
|
+
fetch: (request) => routes.fetch(request)
|
|
337
|
+
};
|
|
338
|
+
return composed;
|
|
339
|
+
};
|
|
340
|
+
return {
|
|
341
|
+
config: async () => (await compose())?.config ?? null,
|
|
342
|
+
async fetch(request) {
|
|
343
|
+
const path = new URL(request.url).pathname;
|
|
344
|
+
if (path === `${PREFIX}/ui.js`) {
|
|
345
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
346
|
+
return failure(405, "method not allowed");
|
|
347
|
+
return new Response(adminScript(), {
|
|
348
|
+
headers: {
|
|
349
|
+
"content-type": "text/javascript; charset=utf-8",
|
|
350
|
+
"cache-control": "no-store"
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
const current = await compose();
|
|
355
|
+
if (!current) return failure(404, "the harness knows no emulators");
|
|
356
|
+
return current.fetch(request);
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
// src/server.ts
|
|
362
|
+
var DEFAULT_PORT = 8790;
|
|
363
|
+
var manifestFile = (path) => async () => JSON.parse(await readFile(path, "utf8"));
|
|
364
|
+
var createServer2 = async (options = {}) => {
|
|
365
|
+
const { port, host, manifest, ...rest } = options;
|
|
366
|
+
const harness = createNotificationHarness({
|
|
367
|
+
admin: adminGateway(),
|
|
368
|
+
...rest,
|
|
369
|
+
...manifest === void 0 ? {} : { manifest: typeof manifest === "string" ? manifestFile(manifest) : manifest }
|
|
370
|
+
});
|
|
371
|
+
const listening = await listen(harness, {
|
|
372
|
+
port: port ?? 0,
|
|
373
|
+
...host !== void 0 ? { host } : {}
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
url: listening.url,
|
|
377
|
+
port: listening.port,
|
|
378
|
+
harness,
|
|
379
|
+
close: async () => {
|
|
380
|
+
harness.close();
|
|
381
|
+
await listening.close();
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
export {
|
|
387
|
+
ADMIN_BRANDS_URL,
|
|
388
|
+
adminGateway,
|
|
389
|
+
DEFAULT_PORT,
|
|
390
|
+
manifestFile,
|
|
391
|
+
createServer2 as createServer
|
|
392
|
+
};
|
|
393
|
+
//# sourceMappingURL=chunk-JECNH6UB.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/server.ts", "../../adapters/node/src/serve.ts", "../../adapters/node/src/listen.ts", "../../admin-ui/src/compose.ts", "../../admin-ui/src/index.ts", "../src/admin-gateway.ts"],
|
|
4
|
+
"sourcesContent": ["/// <reference types=\"node\" />\nimport { readFile } from \"node:fs/promises\"\nimport { listen } from \"@crvouga/mockingbird-adapter-node\"\nimport { adminGateway } from \"./admin-gateway.js\"\nimport type { FleetManifest } from \"./discovery.js\"\nimport {\n createNotificationHarness,\n type HarnessOptions,\n type NotificationHarness,\n} from \"./harness.js\"\n\nexport { ADMIN_BRANDS_URL, type AdminGatewayOptions, adminGateway } from \"./admin-gateway.js\"\n\n/** Port `mockingbird-notifications serve` listens on when none is given. */\nexport const DEFAULT_PORT = 8790\n\n/**\n * `admin` defaults to `adminGateway()` here: the page gets an Emulators tab with every emulator's\n * admin dashboard. Pass `admin: false` for the notifications UI alone.\n */\nexport type NotificationServerOptions = Omit<HarnessOptions, \"manifest\"> & {\n /** A fleet ready manifest object, or the path of the fleet's `--ready-file` (re-read every sync). */\n manifest?: HarnessOptions[\"manifest\"] | string\n /** Default `0`: the OS picks a free port. */\n port?: number\n /** Default `127.0.0.1`. */\n host?: string\n}\n\nexport type NotificationServer = {\n url: string\n port: number\n harness: NotificationHarness\n close(): Promise<void>\n}\n\n/** A manifest loader that re-reads the fleet's ready file, so a restarted fleet is picked up. */\nexport const manifestFile = (path: string) => async (): Promise<FleetManifest> =>\n JSON.parse(await readFile(path, \"utf8\")) as FleetManifest\n\nexport const createServer = async (\n options: NotificationServerOptions = {},\n): Promise<NotificationServer> => {\n const { port, host, manifest, ...rest } = options\n const harness = createNotificationHarness({\n admin: adminGateway(),\n ...rest,\n ...(manifest === undefined\n ? {}\n : { manifest: typeof manifest === \"string\" ? manifestFile(manifest) : manifest }),\n })\n const listening = await listen(harness, {\n port: port ?? 0,\n ...(host !== undefined ? { host } : {}),\n })\n return {\n url: listening.url,\n port: listening.port,\n harness,\n close: async () => {\n harness.close()\n await listening.close()\n },\n }\n}\n", "import { createServer, type Server } from \"node:http\"\nimport { Readable } from \"node:stream\"\nimport type { FetchAPI } from \"@crvouga/mockingbird-core\"\n\n/** Limits apply incrementally, including chunked uploads. Bodies reach fetch as a stream. */\nexport type NodeServeOptions = {\n port?: number\n host?: string\n maxBodyBytes?: number\n requestTimeoutMs?: number\n}\n\n/** Serve a FetchAPI with bounded streaming uploads and disconnect-aware response backpressure. */\nexport const serve = async (api: FetchAPI, options: NodeServeOptions = {}): Promise<Server> => {\n const maxBytes = options.maxBodyBytes ?? 16 * 1024 * 1024\n const timeoutMs = options.requestTimeoutMs ?? 30_000\n if (\n !Number.isSafeInteger(maxBytes) ||\n maxBytes < 0 ||\n !Number.isSafeInteger(timeoutMs) ||\n timeoutMs < 1\n )\n throw new Error(\"invalid request limits\")\n const server = createServer(async (req, res) => {\n const aborted = new AbortController()\n let reader: ReadableStreamDefaultReader<Uint8Array> | undefined\n let timer: ReturnType<typeof setTimeout> | undefined\n const abort = () => {\n aborted.abort()\n void reader?.cancel().catch(() => {})\n }\n const fail = (status: number, message: string) => {\n if (!res.headersSent && !res.destroyed) {\n res.writeHead(status, { \"content-type\": \"application/json\", connection: \"close\" })\n res.end(JSON.stringify({ error: { type: \"mockingbird_transport\", message } }))\n }\n abort()\n }\n req.once(\"aborted\", abort)\n res.once(\"close\", abort)\n res.once(\"error\", abort)\n try {\n const address = server.address()\n const port = typeof address === \"object\" && address !== null ? address.port : 80\n const url = new URL(\n (req.url ?? \"/\").replace(/^\\/+/, \"/\"),\n `http://${req.headers.host ?? `localhost:${port}`}`,\n )\n const headers = new Headers()\n for (const [name, value] of Object.entries(req.headers)) {\n if (Array.isArray(value)) for (const item of value) headers.append(name, item)\n else if (value !== undefined) headers.set(name, value)\n }\n const init: RequestInit & { duplex?: \"half\" } = {\n method: req.method ?? \"GET\",\n headers,\n signal: aborted.signal,\n }\n if (init.method !== \"GET\" && init.method !== \"HEAD\") {\n if (Number(req.headers[\"content-length\"]) > maxBytes) {\n fail(413, \"request body exceeds byte limit\")\n return\n }\n let bytes = 0\n const source = Readable.toWeb(req) as unknown as ReadableStream<Uint8Array>\n init.body = source.pipeThrough(\n new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n bytes += chunk.byteLength\n if (bytes > maxBytes) {\n fail(413, \"request body exceeds byte limit\")\n controller.error(new Error(\"request body exceeds byte limit\"))\n } else controller.enqueue(chunk)\n },\n }),\n )\n init.duplex = \"half\"\n timer = setTimeout(() => fail(408, \"request body timed out\"), timeoutMs)\n req.once(\"end\", () => clearTimeout(timer))\n }\n const response = await api.fetch(new Request(url, init))\n if (aborted.signal.aborted || res.destroyed) {\n await response.body?.cancel()\n return\n }\n const output: Record<string, string | string[]> = Object.fromEntries(response.headers)\n const cookies = response.headers.getSetCookie()\n if (cookies.length) output[\"set-cookie\"] = cookies\n res.writeHead(response.status, output)\n if (!response.body) {\n res.end()\n return\n }\n res.flushHeaders()\n reader = response.body.getReader()\n for (;;) {\n const { done, value } = await reader.read()\n if (done || aborted.signal.aborted) break\n if (!res.write(value)) {\n await new Promise<void>((resolve) => {\n const finish = () => {\n res.off(\"drain\", finish)\n res.off(\"close\", finish)\n res.off(\"error\", finish)\n resolve()\n }\n res.once(\"drain\", finish)\n res.once(\"close\", finish)\n res.once(\"error\", finish)\n if (res.destroyed || aborted.signal.aborted) finish()\n })\n }\n }\n if (!aborted.signal.aborted) res.end()\n } catch (error) {\n if ((error as { code?: string }).code === \"MOCKINGBIRD_DROP\") req.socket.destroy()\n else if (!aborted.signal.aborted && !res.destroyed) {\n if (res.headersSent) res.destroy()\n else {\n res.writeHead(500, { \"content-type\": \"application/json\" })\n res.end(\n JSON.stringify({\n error: {\n type: \"mockingbird_internal\",\n message: error instanceof Error ? error.message : String(error),\n },\n }),\n )\n }\n }\n } finally {\n clearTimeout(timer)\n reader?.releaseLock()\n req.off(\"aborted\", abort)\n res.off(\"close\", abort)\n res.off(\"error\", abort)\n if (!req.complete) req.resume()\n }\n })\n server.requestTimeout = timeoutMs\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject)\n server.listen(options.port ?? 0, options.host, resolve)\n })\n return server\n}\n", "import type { Server } from \"node:http\"\nimport type { FetchAPI } from \"@crvouga/mockingbird-core\"\nimport { serve } from \"./serve.js\"\n\nexport type ListenOptions = {\n /** Default `0`: the OS picks a free port. */\n port?: number\n /** Default `127.0.0.1`: a mock should not be reachable off the machine by accident. */\n host?: string\n /** Largest request body accepted. Default 16 MiB. */\n maxBodyBytes?: number\n}\n\n/** A running server, with the address it actually bound. */\nexport type Listening = {\n url: string\n port: number\n host: string\n server: Server\n close(): Promise<void>\n}\n\nexport const listen = async (api: FetchAPI, options: ListenOptions = {}): Promise<Listening> => {\n const host = options.host ?? \"127.0.0.1\"\n const server = await serve(api, {\n port: options.port ?? 0,\n host,\n ...(options.maxBodyBytes !== undefined ? { maxBodyBytes: options.maxBodyBytes } : {}),\n })\n const address = server.address()\n const port = typeof address === \"object\" && address !== null ? address.port : (options.port ?? 0)\n const shown = host.includes(\":\") ? `[${host}]` : host\n return {\n url: `http://${shown}:${port}`,\n port,\n host,\n server,\n close: () =>\n new Promise<void>((resolve, reject) => {\n // Stop accepting first, then drop keep-alive sockets so close() can finish.\n server.close((error) => {\n if (error && (error as { code?: string }).code !== \"ERR_SERVER_NOT_RUNNING\") reject(error)\n else resolve()\n })\n server.closeAllConnections?.()\n }),\n }\n}\n", "import type { AdminApiConfig, AdminConfig } from \"./model.js\"\n\nexport type ComposableAdminApi = AdminApiConfig & {\n fetch(request: Request): Promise<Response>\n}\n\nexport type ComposedAdminRoutes = {\n /** What the shared UI mounts with: one entry per API, each behind `<prefix>/apis/<id>`. */\n config: AdminConfig\n /** The normalised mount prefix, `/__admin` by default. */\n prefix: string\n /** Forwards `<prefix>/apis/<id>/\u2026` to that API unchanged. Everything else is a 404. */\n fetch(request: Request): Promise<Response>\n}\n\n/**\n * The routing half of `composeAdminApis`: the UI config and the forwarding fetch, without the\n * HTML document. This module never imports the prebuilt browser bundle, so a page that mounts\n * the UI from `@crvouga/mockingbird-admin-ui/browser` does not also carry it as a string.\n */\nexport const composeAdminRoutes = (\n apis: readonly ComposableAdminApi[],\n options: { brandsUrl: string; prefix?: string },\n): ComposedAdminRoutes => {\n if (apis.length === 0) throw new RangeError(\"composeAdminApis needs at least one admin API\")\n const ids = new Set<string>()\n for (const api of apis) {\n if (!/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(api.id))\n throw new RangeError(`invalid admin API id ${JSON.stringify(api.id)}`)\n if (ids.has(api.id)) throw new RangeError(`duplicate admin API id ${api.id}`)\n ids.add(api.id)\n }\n const prefix = `/${(options.prefix ?? \"/__admin\").replace(/^\\/+|\\/+$/g, \"\")}`\n const first = apis[0] as ComposableAdminApi\n const config: AdminConfig = {\n service: first.service,\n adminPrefix: `${prefix}/apis/${first.id}`,\n adminKeyHeader: first.adminKeyHeader,\n standardRoutes: first.standardRoutes,\n brandsUrl: options.brandsUrl,\n apis: apis.map(({ fetch: _fetch, ...api }) => ({\n ...api,\n adminPrefix: `${prefix}/apis/${api.id}`,\n })),\n }\n return {\n config,\n prefix,\n async fetch(request) {\n const url = new URL(request.url)\n const root = `${prefix}/apis/`\n if (!url.pathname.startsWith(root)) return new Response(\"Not found\", { status: 404 })\n const rest = url.pathname.slice(root.length)\n const slash = rest.indexOf(\"/\")\n const id = slash < 0 ? rest : rest.slice(0, slash)\n const api = apis.find((candidate) => candidate.id === id)\n if (!api) return new Response(\"Not found\", { status: 404 })\n url.pathname = `${api.adminPrefix.replace(/\\/$/, \"\")}${slash < 0 ? \"\" : rest.slice(slash)}`\n return api.fetch(new Request(url, request))\n },\n }\n}\n", "import { type ComposableAdminApi, composeAdminRoutes } from \"./compose.js\"\nimport { adminClientSource } from \"./document.js\"\nimport type { AdminConfig } from \"./model.js\"\n\nexport type { ComposableAdminApi, ComposedAdminRoutes } from \"./compose.js\"\nexport { composeAdminRoutes } from \"./compose.js\"\nexport { adminClientScript, adminClientSource, membersClientSource } from \"./document.js\"\nexport type { AdminApiConfig, AdminConfig, MembersConfig } from \"./model.js\"\n\nconst escapeHtml = (value: string): string =>\n value.replace(\n /[&<>\"']/g,\n (char) =>\n ({ \"&\": \"&\", \"<\": \"<\", \">\": \">\", '\"': \""\", \"'\": \"'\" })[char] ?? char,\n )\n\n/**\n * Compose independent admin APIs behind one fetch handler and one UI. The shell is only a\n * facade: every data/control request is forwarded unchanged to the selected API.\n */\nexport const composeAdminApis = (\n apis: readonly ComposableAdminApi[],\n options: { brandsUrl: string; prefix?: string; title?: string },\n): { config: AdminConfig; fetch(request: Request): Promise<Response> } => {\n const { config, prefix, fetch: forward } = composeAdminRoutes(apis, options)\n const title = escapeHtml(options.title ?? \"Mockingbird\")\n const document = `<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta name=\"color-scheme\" content=\"light dark\"><title>${title} admin</title><style>html,body{margin:0;min-height:100%}#admin-root{min-height:100%}</style></head><body><main id=\"admin-root\" data-mockingbird-admin data-admin-ui-library=\"antd\" data-service=\"${title}\"><noscript>Enable JavaScript to use administration.</noscript></main>${adminClientSource(config)}</body></html>`\n return {\n config,\n async fetch(request) {\n const url = new URL(request.url)\n if (\n request.method === \"GET\" &&\n (url.pathname === `${prefix}/ui` || url.pathname === `${prefix}/ui/`)\n )\n return new Response(document, {\n headers: { \"content-type\": \"text/html; charset=utf-8\", \"cache-control\": \"no-store\" },\n })\n return forward(request)\n },\n }\n}\n", "/**\n * The admin gateway: every emulator's admin API and the shared admin UI, on the harness's own\n * origin. The browser then needs one port and no CORS, however many emulators the fleet runs.\n *\n * /admin/ui.js the admin UI (defines `MockingbirdAdmin.mount(host, config)`)\n * /admin/ui the admin UI as a page of its own\n * /admin/apis/<name>/\u2026 that emulator's admin API, forwarded unchanged\n *\n * This module carries the prebuilt admin UI (about 1.3 MB), which is why the harness takes it as an\n * option instead of importing it: an app that embeds the harness in a browser does not pay for it.\n */\nimport {\n type AdminConfig,\n adminClientScript,\n type ComposableAdminApi,\n composeAdminApis,\n} from \"@crvouga/mockingbird-admin-ui\"\nimport type { AdminTarget } from \"./discovery.js\"\nimport type { AdminGatewayFactory } from \"./harness.js\"\n\n/** Where the admin UI reads each vendor's logo and links from, as every emulator's own admin does. */\nexport const ADMIN_BRANDS_URL = \"https://mockingbird.chrisvouga.dev/brands.json\"\n\nconst PREFIX = \"/admin\"\nconst KEY_HEADER = \"x-mockingbird-admin-key\"\n/** Describe one hop, not the resource: never forwarded in either direction. */\nconst HOP_HEADERS = [\n \"connection\",\n \"content-encoding\",\n \"content-length\",\n \"host\",\n \"keep-alive\",\n \"transfer-encoding\",\n]\n\nlet script: string | undefined\n/** The admin UI bundle as a script file: it defines `MockingbirdAdmin` and mounts nothing. */\nconst adminScript = (): string => {\n script ??= adminClientScript()\n return script\n}\n\n/** Admin API ids are DNS-label shaped; emulator names from `services` can be anything. */\nconst idFor = (name: string, taken: Set<string>): string => {\n const base =\n name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 56) || \"emulator\"\n let id = base\n for (let n = 2; taken.has(id); n++) id = `${base}-${n}`\n taken.add(id)\n return id\n}\n\nconst failure = (status: number, message: string) =>\n new Response(JSON.stringify({ error: { type: \"mockingbird_notifications\", message } }), {\n status,\n headers: { \"content-type\": \"application/json; charset=utf-8\" },\n })\n\nexport type AdminGatewayOptions = {\n /** Default {@link ADMIN_BRANDS_URL}. */\n brandsUrl?: string\n}\n\n/**\n * Pass the result as the harness's `admin` option. `createServer` does so by default.\n *\n * A request that carries no admin key gets the harness's own (`adminKey` / `adminKeys`), so the\n * page works against a locked fleet without the viewer typing the key. Anyone who can reach the\n * harness can then change emulator state: keep it on a loopback or otherwise private address.\n */\nexport const adminGateway =\n (options: AdminGatewayOptions = {}): AdminGatewayFactory =>\n (context) => {\n const brandsUrl = options.brandsUrl ?? ADMIN_BRANDS_URL\n\n const forward =\n (target: AdminTarget) =>\n async (request: Request): Promise<Response> => {\n const from = new URL(request.url)\n const headers = new Headers(request.headers)\n for (const name of HOP_HEADERS) headers.delete(name)\n headers.delete(\"accept-encoding\")\n if (!headers.has(KEY_HEADER))\n for (const [name, value] of Object.entries(context.headers(target.name)))\n headers.set(name, value)\n const hasBody = request.method !== \"GET\" && request.method !== \"HEAD\"\n try {\n const response = await target.fetch(\n new Request(new URL(`${from.pathname}${from.search}`, target.adminUrl), {\n method: request.method,\n headers,\n ...(hasBody ? { body: await request.arrayBuffer() } : {}),\n signal: request.signal,\n }),\n )\n const out = new Headers(response.headers)\n for (const name of HOP_HEADERS) out.delete(name)\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: out,\n })\n } catch (error) {\n return failure(\n 502,\n `${target.name} is unreachable at ${target.adminUrl}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n type Composed = {\n key: string\n config: AdminConfig\n fetch(request: Request): Promise<Response>\n }\n let composed: Composed | null = null\n const compose = async (): Promise<Composed | null> => {\n const targets = await context.targets()\n if (targets.length === 0) return null\n const key = targets.map((t) => `${t.name}\\u0000${t.target}\\u0000${t.adminUrl}`).join(\"\\n\")\n if (composed?.key === key) return composed\n const taken = new Set<string>()\n const apis = targets.map(\n (target): ComposableAdminApi => ({\n id: idFor(target.name, taken),\n label: target.name === target.target ? target.name : `${target.name} (${target.target})`,\n service: target.target,\n adminPrefix: new URL(target.adminUrl).pathname.replace(/\\/+$/, \"\"),\n adminKeyHeader: KEY_HEADER,\n standardRoutes: [],\n fetch: forward(target),\n }),\n )\n const first = apis[0] as ComposableAdminApi\n const routes = composeAdminApis(apis, { brandsUrl, prefix: PREFIX, title: context.title })\n composed = {\n key,\n config: {\n service: first.service,\n adminPrefix: `${PREFIX}/apis/${first.id}`,\n adminKeyHeader: KEY_HEADER,\n standardRoutes: [],\n brandsUrl,\n apis: apis.map(({ fetch: _fetch, ...api }) => ({\n ...api,\n adminPrefix: `${PREFIX}/apis/${api.id}`,\n })),\n },\n fetch: (request) => routes.fetch(request),\n }\n return composed\n }\n\n return {\n config: async () => (await compose())?.config ?? null,\n async fetch(request) {\n const path = new URL(request.url).pathname\n if (path === `${PREFIX}/ui.js`) {\n if (request.method !== \"GET\" && request.method !== \"HEAD\")\n return failure(405, \"method not allowed\")\n return new Response(adminScript(), {\n headers: {\n \"content-type\": \"text/javascript; charset=utf-8\",\n \"cache-control\": \"no-store\",\n },\n })\n }\n const current = await compose()\n if (!current) return failure(404, \"the harness knows no emulators\")\n return current.fetch(request)\n },\n }\n }\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AACA,SAAS,gBAAgB;;;ACDzB,SAAS,oBAAiC;AAC1C,SAAS,gBAAgB;AAYlB,IAAM,QAAQ,OAAO,KAAe,UAA4B,CAAA,MAAuB;AAC5F,QAAM,WAAW,QAAQ,gBAAgB,KA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C,QAAS,QAAO,QAAQ,KAAK,gCAAgC;AAClE,aAAO,QAAQ,MAAM,OAAO;AAAA,IAC9B;AAAA,EACF;AACF;;;ALlKK,IAAM,eAAe;AAuBrB,IAAM,eAAe,CAAC,SAAiB,YAC5C,KAAK,MAAM,MAAM,SAAS,MAAM,MAAM,CAAC;AAElC,IAAMA,gBAAe,OAC1B,UAAqC,CAAC,MACN;AAChC,QAAM,EAAE,MAAM,MAAM,UAAU,GAAG,KAAK,IAAI;AAC1C,QAAM,UAAU,0BAA0B;AAAA,IACxC,OAAO,aAAa;AAAA,IACpB,GAAG;AAAA,IACH,GAAI,aAAa,SACb,CAAC,IACD,EAAE,UAAU,OAAO,aAAa,WAAW,aAAa,QAAQ,IAAI,SAAS;AAAA,EACnF,CAAC;AACD,QAAM,YAAY,MAAM,OAAO,SAAS;AAAA,IACtC,MAAM,QAAQ;AAAA,IACd,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC;AAAA,EACvC,CAAC;AACD,SAAO;AAAA,IACL,KAAK,UAAU;AAAA,IACf,MAAM,UAAU;AAAA,IAChB;AAAA,IACA,OAAO,YAAY;AACjB,cAAQ,MAAM;AACd,YAAM,UAAU,MAAM;AAAA,IACxB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["createServer"]
|
|
7
|
+
}
|
|
@@ -8,7 +8,8 @@ var SERVICE_KINDS = [
|
|
|
8
8
|
"sns",
|
|
9
9
|
"customerio",
|
|
10
10
|
"mailosaur",
|
|
11
|
-
"slack"
|
|
11
|
+
"slack",
|
|
12
|
+
"cognito"
|
|
12
13
|
];
|
|
13
14
|
var SERVICE_LABELS = {
|
|
14
15
|
twilio: "Twilio",
|
|
@@ -18,7 +19,8 @@ var SERVICE_LABELS = {
|
|
|
18
19
|
sns: "Amazon SNS",
|
|
19
20
|
customerio: "Customer.io",
|
|
20
21
|
mailosaur: "Mailosaur",
|
|
21
|
-
slack: "Slack"
|
|
22
|
+
slack: "Slack",
|
|
23
|
+
cognito: "Amazon Cognito"
|
|
22
24
|
};
|
|
23
25
|
var toMs = (value) => typeof value === "number" ? value : /^\d+$/.test(value) ? Number(value) : Date.parse(value);
|
|
24
26
|
var searchable = (n) => [
|
|
@@ -778,4 +780,4 @@ export {
|
|
|
778
780
|
STYLES,
|
|
779
781
|
PAGE_STYLES
|
|
780
782
|
};
|
|
781
|
-
//# sourceMappingURL=chunk-
|
|
783
|
+
//# sourceMappingURL=chunk-QQK27AFM.js.map
|