miniflare 0.0.0-e51304ca0 → 0.0.0-e55f489db
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/src/index.d.ts +1314 -261
- package/dist/src/index.js +1829 -885
- package/dist/src/index.js.map +3 -3
- package/dist/src/workers/analytics-engine/analytics-engine.worker.js +10 -0
- package/dist/src/workers/analytics-engine/analytics-engine.worker.js.map +6 -0
- package/dist/src/workers/assets/assets.worker.js +392 -193
- package/dist/src/workers/assets/assets.worker.js.map +2 -2
- package/dist/src/workers/assets/router.worker.js +2 -1
- package/dist/src/workers/assets/router.worker.js.map +1 -1
- package/dist/src/workers/assets/rpc-proxy.worker.js +7 -0
- package/dist/src/workers/assets/rpc-proxy.worker.js.map +1 -1
- package/dist/src/workers/cache/cache.worker.js +2 -1
- package/dist/src/workers/cache/cache.worker.js.map +1 -1
- package/dist/src/workers/core/entry.worker.js +3371 -50
- package/dist/src/workers/core/entry.worker.js.map +3 -3
- package/dist/src/workers/d1/database.worker.js +6 -2
- package/dist/src/workers/d1/database.worker.js.map +1 -1
- package/dist/src/workers/email/email.worker.js +23 -0
- package/dist/src/workers/email/email.worker.js.map +6 -0
- package/dist/src/workers/email/send_email.worker.js +3180 -0
- package/dist/src/workers/email/send_email.worker.js.map +6 -0
- package/dist/src/workers/kv/namespace.worker.js +67 -2
- package/dist/src/workers/kv/namespace.worker.js.map +2 -2
- package/dist/src/workers/kv/sites.worker.js +2 -1
- package/dist/src/workers/kv/sites.worker.js.map +1 -1
- package/dist/src/workers/secrets-store/secret.worker.js +65 -0
- package/dist/src/workers/secrets-store/secret.worker.js.map +6 -0
- package/dist/src/workers/workflows/binding.worker.js +162 -5
- package/dist/src/workers/workflows/binding.worker.js.map +1 -1
- package/package.json +14 -11
package/dist/src/index.js
CHANGED
|
@@ -254,17 +254,17 @@ var require_ignore = __commonJS({
|
|
|
254
254
|
var throwError = (message, Ctor) => {
|
|
255
255
|
throw new Ctor(message);
|
|
256
256
|
};
|
|
257
|
-
var checkPath = (
|
|
258
|
-
if (!isString(
|
|
257
|
+
var checkPath = (path34, originalPath, doThrow) => {
|
|
258
|
+
if (!isString(path34)) {
|
|
259
259
|
return doThrow(
|
|
260
260
|
`path must be a string, but got \`${originalPath}\``,
|
|
261
261
|
TypeError
|
|
262
262
|
);
|
|
263
263
|
}
|
|
264
|
-
if (!
|
|
264
|
+
if (!path34) {
|
|
265
265
|
return doThrow(`path must not be empty`, TypeError);
|
|
266
266
|
}
|
|
267
|
-
if (checkPath.isNotRelative(
|
|
267
|
+
if (checkPath.isNotRelative(path34)) {
|
|
268
268
|
const r = "`path.relative()`d";
|
|
269
269
|
return doThrow(
|
|
270
270
|
`path should be a ${r} string, but got "${originalPath}"`,
|
|
@@ -273,7 +273,7 @@ var require_ignore = __commonJS({
|
|
|
273
273
|
}
|
|
274
274
|
return true;
|
|
275
275
|
};
|
|
276
|
-
var isNotRelative = (
|
|
276
|
+
var isNotRelative = (path34) => REGEX_TEST_INVALID_PATH.test(path34);
|
|
277
277
|
checkPath.isNotRelative = isNotRelative;
|
|
278
278
|
checkPath.convert = (p) => p;
|
|
279
279
|
var Ignore = class {
|
|
@@ -332,7 +332,7 @@ var require_ignore = __commonJS({
|
|
|
332
332
|
// setting `checkUnignored` to `false` could reduce additional
|
|
333
333
|
// path matching.
|
|
334
334
|
// @returns {TestResult} true if a file is ignored
|
|
335
|
-
_testOne(
|
|
335
|
+
_testOne(path34, checkUnignored) {
|
|
336
336
|
let ignored2 = false;
|
|
337
337
|
let unignored = false;
|
|
338
338
|
this._rules.forEach((rule) => {
|
|
@@ -340,7 +340,7 @@ var require_ignore = __commonJS({
|
|
|
340
340
|
if (unignored === negative && ignored2 !== unignored || negative && !ignored2 && !unignored && !checkUnignored) {
|
|
341
341
|
return;
|
|
342
342
|
}
|
|
343
|
-
const matched = rule.regex.test(
|
|
343
|
+
const matched = rule.regex.test(path34);
|
|
344
344
|
if (matched) {
|
|
345
345
|
ignored2 = !negative;
|
|
346
346
|
unignored = negative;
|
|
@@ -353,24 +353,24 @@ var require_ignore = __commonJS({
|
|
|
353
353
|
}
|
|
354
354
|
// @returns {TestResult}
|
|
355
355
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
356
|
-
const
|
|
356
|
+
const path34 = originalPath && checkPath.convert(originalPath);
|
|
357
357
|
checkPath(
|
|
358
|
-
|
|
358
|
+
path34,
|
|
359
359
|
originalPath,
|
|
360
360
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
361
361
|
);
|
|
362
|
-
return this._t(
|
|
362
|
+
return this._t(path34, cache, checkUnignored, slices);
|
|
363
363
|
}
|
|
364
|
-
_t(
|
|
365
|
-
if (
|
|
366
|
-
return cache[
|
|
364
|
+
_t(path34, cache, checkUnignored, slices) {
|
|
365
|
+
if (path34 in cache) {
|
|
366
|
+
return cache[path34];
|
|
367
367
|
}
|
|
368
368
|
if (!slices) {
|
|
369
|
-
slices =
|
|
369
|
+
slices = path34.split(SLASH);
|
|
370
370
|
}
|
|
371
371
|
slices.pop();
|
|
372
372
|
if (!slices.length) {
|
|
373
|
-
return cache[
|
|
373
|
+
return cache[path34] = this._testOne(path34, checkUnignored);
|
|
374
374
|
}
|
|
375
375
|
const parent = this._t(
|
|
376
376
|
slices.join(SLASH) + SLASH,
|
|
@@ -378,24 +378,24 @@ var require_ignore = __commonJS({
|
|
|
378
378
|
checkUnignored,
|
|
379
379
|
slices
|
|
380
380
|
);
|
|
381
|
-
return cache[
|
|
381
|
+
return cache[path34] = parent.ignored ? parent : this._testOne(path34, checkUnignored);
|
|
382
382
|
}
|
|
383
|
-
ignores(
|
|
384
|
-
return this._test(
|
|
383
|
+
ignores(path34) {
|
|
384
|
+
return this._test(path34, this._ignoreCache, false).ignored;
|
|
385
385
|
}
|
|
386
386
|
createFilter() {
|
|
387
|
-
return (
|
|
387
|
+
return (path34) => !this.ignores(path34);
|
|
388
388
|
}
|
|
389
389
|
filter(paths) {
|
|
390
390
|
return makeArray(paths).filter(this.createFilter());
|
|
391
391
|
}
|
|
392
392
|
// @returns {TestResult}
|
|
393
|
-
test(
|
|
394
|
-
return this._test(
|
|
393
|
+
test(path34) {
|
|
394
|
+
return this._test(path34, this._testCache, true);
|
|
395
395
|
}
|
|
396
396
|
};
|
|
397
397
|
var factory = (options) => new Ignore(options);
|
|
398
|
-
var isPathValid = (
|
|
398
|
+
var isPathValid = (path34) => checkPath(path34 && checkPath.convert(path34), path34, RETURN_FALSE);
|
|
399
399
|
factory.isPathValid = isPathValid;
|
|
400
400
|
factory.default = factory;
|
|
401
401
|
module2.exports = factory;
|
|
@@ -406,7 +406,7 @@ var require_ignore = __commonJS({
|
|
|
406
406
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
407
407
|
checkPath.convert = makePosix;
|
|
408
408
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
409
|
-
checkPath.isNotRelative = (
|
|
409
|
+
checkPath.isNotRelative = (path34) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path34) || isNotRelative(path34);
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
});
|
|
@@ -449,11 +449,11 @@ var require_Mime = __commonJS({
|
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
};
|
|
452
|
-
Mime.prototype.getType = function(
|
|
453
|
-
|
|
454
|
-
let last =
|
|
452
|
+
Mime.prototype.getType = function(path34) {
|
|
453
|
+
path34 = String(path34);
|
|
454
|
+
let last = path34.replace(/^.*[/\\]/, "").toLowerCase();
|
|
455
455
|
let ext = last.replace(/^.*\./, "").toLowerCase();
|
|
456
|
-
let hasPath = last.length <
|
|
456
|
+
let hasPath = last.length < path34.length;
|
|
457
457
|
let hasDot = ext.length < last.length - 1;
|
|
458
458
|
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
459
459
|
};
|
|
@@ -493,7 +493,11 @@ var require_mime = __commonJS({
|
|
|
493
493
|
// src/index.ts
|
|
494
494
|
var src_exports = {};
|
|
495
495
|
__export(src_exports, {
|
|
496
|
+
ANALYTICS_ENGINE_PLUGIN: () => ANALYTICS_ENGINE_PLUGIN,
|
|
497
|
+
ANALYTICS_ENGINE_PLUGIN_NAME: () => ANALYTICS_ENGINE_PLUGIN_NAME,
|
|
496
498
|
ASSETS_PLUGIN: () => ASSETS_PLUGIN,
|
|
499
|
+
AnalyticsEngineSchemaOptionsSchema: () => AnalyticsEngineSchemaOptionsSchema,
|
|
500
|
+
AnalyticsEngineSchemaSharedOptionsSchema: () => AnalyticsEngineSchemaSharedOptionsSchema,
|
|
497
501
|
AssetsOptionsSchema: () => AssetsOptionsSchema,
|
|
498
502
|
CACHE_PLUGIN: () => CACHE_PLUGIN,
|
|
499
503
|
CACHE_PLUGIN_NAME: () => CACHE_PLUGIN_NAME,
|
|
@@ -520,6 +524,9 @@ __export(src_exports, {
|
|
|
520
524
|
DispatchFetchDispatcher: () => DispatchFetchDispatcher,
|
|
521
525
|
DurableObjectsOptionsSchema: () => DurableObjectsOptionsSchema,
|
|
522
526
|
DurableObjectsSharedOptionsSchema: () => DurableObjectsSharedOptionsSchema,
|
|
527
|
+
EMAIL_PLUGIN: () => EMAIL_PLUGIN,
|
|
528
|
+
EMAIL_PLUGIN_NAME: () => EMAIL_PLUGIN_NAME,
|
|
529
|
+
EmailOptionsSchema: () => EmailOptionsSchema,
|
|
523
530
|
ErrorEvent: () => ErrorEvent,
|
|
524
531
|
File: () => import_undici4.File,
|
|
525
532
|
FormData: () => import_undici4.FormData,
|
|
@@ -541,6 +548,7 @@ __export(src_exports, {
|
|
|
541
548
|
LiteralSchema: () => LiteralSchema,
|
|
542
549
|
Log: () => Log,
|
|
543
550
|
LogLevel: () => LogLevel,
|
|
551
|
+
MAX_BULK_GET_KEYS: () => MAX_BULK_GET_KEYS,
|
|
544
552
|
MessageEvent: () => MessageEvent,
|
|
545
553
|
Miniflare: () => Miniflare2,
|
|
546
554
|
MiniflareCoreError: () => MiniflareCoreError,
|
|
@@ -589,11 +597,15 @@ __export(src_exports, {
|
|
|
589
597
|
Response: () => Response,
|
|
590
598
|
RouterError: () => RouterError,
|
|
591
599
|
Runtime: () => Runtime,
|
|
600
|
+
SECRET_STORE_PLUGIN: () => SECRET_STORE_PLUGIN,
|
|
601
|
+
SECRET_STORE_PLUGIN_NAME: () => SECRET_STORE_PLUGIN_NAME,
|
|
592
602
|
SERVICE_ENTRY: () => SERVICE_ENTRY,
|
|
593
603
|
SERVICE_LOOPBACK: () => SERVICE_LOOPBACK,
|
|
594
604
|
SITES_NO_CACHE_PREFIX: () => SITES_NO_CACHE_PREFIX,
|
|
595
605
|
SOCKET_ENTRY: () => SOCKET_ENTRY,
|
|
596
606
|
SOCKET_ENTRY_LOCAL: () => SOCKET_ENTRY_LOCAL,
|
|
607
|
+
SecretsStoreSecretsOptionsSchema: () => SecretsStoreSecretsOptionsSchema,
|
|
608
|
+
SecretsStoreSecretsSharedOptionsSchema: () => SecretsStoreSecretsSharedOptionsSchema,
|
|
597
609
|
SharedBindings: () => SharedBindings,
|
|
598
610
|
SharedHeaders: () => SharedHeaders,
|
|
599
611
|
SiteBindings: () => SiteBindings,
|
|
@@ -628,7 +640,7 @@ __export(src_exports, {
|
|
|
628
640
|
deserialiseRegExps: () => deserialiseRegExps,
|
|
629
641
|
deserialiseSiteRegExps: () => deserialiseSiteRegExps,
|
|
630
642
|
encodeSitesKey: () => encodeSitesKey,
|
|
631
|
-
fetch: () =>
|
|
643
|
+
fetch: () => fetch4,
|
|
632
644
|
formatZodError: () => formatZodError,
|
|
633
645
|
getAccessibleHosts: () => getAccessibleHosts,
|
|
634
646
|
getAssetsBindingsNames: () => getAssetsBindingsNames,
|
|
@@ -683,11 +695,12 @@ __export(src_exports, {
|
|
|
683
695
|
module.exports = __toCommonJS(src_exports);
|
|
684
696
|
var import_assert12 = __toESM(require("assert"));
|
|
685
697
|
var import_crypto3 = __toESM(require("crypto"));
|
|
686
|
-
var
|
|
698
|
+
var import_fs28 = __toESM(require("fs"));
|
|
699
|
+
var import_promises13 = require("fs/promises");
|
|
687
700
|
var import_http6 = __toESM(require("http"));
|
|
688
701
|
var import_net = __toESM(require("net"));
|
|
689
702
|
var import_os2 = __toESM(require("os"));
|
|
690
|
-
var
|
|
703
|
+
var import_path32 = __toESM(require("path"));
|
|
691
704
|
var import_web5 = require("stream/web");
|
|
692
705
|
var import_util5 = __toESM(require("util"));
|
|
693
706
|
var import_zlib = __toESM(require("zlib"));
|
|
@@ -770,8 +783,8 @@ function zod_worker_default() {
|
|
|
770
783
|
}
|
|
771
784
|
|
|
772
785
|
// src/index.ts
|
|
773
|
-
var
|
|
774
|
-
var
|
|
786
|
+
var import_ws5 = require("ws");
|
|
787
|
+
var import_zod26 = require("zod");
|
|
775
788
|
|
|
776
789
|
// src/cf.ts
|
|
777
790
|
var import_assert = __toESM(require("assert"));
|
|
@@ -909,7 +922,9 @@ var CoreBindings = {
|
|
|
909
922
|
DATA_LIVE_RELOAD_SCRIPT: "MINIFLARE_LIVE_RELOAD_SCRIPT",
|
|
910
923
|
DURABLE_OBJECT_NAMESPACE_PROXY: "MINIFLARE_PROXY",
|
|
911
924
|
DATA_PROXY_SECRET: "MINIFLARE_PROXY_SECRET",
|
|
912
|
-
DATA_PROXY_SHARED_SECRET: "MINIFLARE_PROXY_SHARED_SECRET"
|
|
925
|
+
DATA_PROXY_SHARED_SECRET: "MINIFLARE_PROXY_SHARED_SECRET",
|
|
926
|
+
TRIGGER_HANDLERS: "TRIGGER_HANDLERS",
|
|
927
|
+
LOG_REQUESTS: "LOG_REQUESTS"
|
|
913
928
|
};
|
|
914
929
|
var ProxyOps = {
|
|
915
930
|
// Get the target or a property of the target
|
|
@@ -1354,12 +1369,12 @@ function createHTTPRevivers(impl) {
|
|
|
1354
1369
|
},
|
|
1355
1370
|
Request(value) {
|
|
1356
1371
|
(0, import_node_assert.default)(Array.isArray(value));
|
|
1357
|
-
const [method,
|
|
1372
|
+
const [method, url24, headers, cf, body] = value;
|
|
1358
1373
|
(0, import_node_assert.default)(typeof method === "string");
|
|
1359
|
-
(0, import_node_assert.default)(typeof
|
|
1374
|
+
(0, import_node_assert.default)(typeof url24 === "string");
|
|
1360
1375
|
(0, import_node_assert.default)(headers instanceof impl.Headers);
|
|
1361
1376
|
(0, import_node_assert.default)(body === null || impl.isReadableStream(body));
|
|
1362
|
-
return new impl.Request(
|
|
1377
|
+
return new impl.Request(url24, {
|
|
1363
1378
|
method,
|
|
1364
1379
|
headers,
|
|
1365
1380
|
cf,
|
|
@@ -1485,19 +1500,19 @@ function parseWithReadableStreams(impl, stringified, revivers2) {
|
|
|
1485
1500
|
}
|
|
1486
1501
|
|
|
1487
1502
|
// src/workers/core/routing.ts
|
|
1488
|
-
function matchRoutes(routes,
|
|
1503
|
+
function matchRoutes(routes, url24) {
|
|
1489
1504
|
for (const route of routes) {
|
|
1490
|
-
if (route.protocol && route.protocol !==
|
|
1505
|
+
if (route.protocol && route.protocol !== url24.protocol) continue;
|
|
1491
1506
|
if (route.allowHostnamePrefix) {
|
|
1492
|
-
if (!
|
|
1507
|
+
if (!url24.hostname.endsWith(route.hostname)) continue;
|
|
1493
1508
|
} else {
|
|
1494
|
-
if (
|
|
1509
|
+
if (url24.hostname !== route.hostname) continue;
|
|
1495
1510
|
}
|
|
1496
|
-
const
|
|
1511
|
+
const path34 = url24.pathname + url24.search;
|
|
1497
1512
|
if (route.allowPathSuffix) {
|
|
1498
|
-
if (!
|
|
1513
|
+
if (!path34.startsWith(route.path)) continue;
|
|
1499
1514
|
} else {
|
|
1500
|
-
if (
|
|
1515
|
+
if (path34 !== route.path) continue;
|
|
1501
1516
|
}
|
|
1502
1517
|
return route.target;
|
|
1503
1518
|
}
|
|
@@ -1697,7 +1712,8 @@ var KVLimits = {
|
|
|
1697
1712
|
MAX_KEY_SIZE: 512,
|
|
1698
1713
|
MAX_VALUE_SIZE: 25 * 1024 * 1024,
|
|
1699
1714
|
MAX_VALUE_SIZE_TEST: 1024,
|
|
1700
|
-
MAX_METADATA_SIZE: 1024
|
|
1715
|
+
MAX_METADATA_SIZE: 1024,
|
|
1716
|
+
MAX_BULK_SIZE: 25 * 1024 * 1024
|
|
1701
1717
|
};
|
|
1702
1718
|
var KVParams = {
|
|
1703
1719
|
URL_ENCODED: "urlencoded",
|
|
@@ -1718,6 +1734,7 @@ var SiteBindings = {
|
|
|
1718
1734
|
JSON_SITE_FILTER: "MINIFLARE_SITE_FILTER"
|
|
1719
1735
|
};
|
|
1720
1736
|
var SITES_NO_CACHE_PREFIX = "$__MINIFLARE_SITES__$/";
|
|
1737
|
+
var MAX_BULK_GET_KEYS = 100;
|
|
1721
1738
|
function encodeSitesKey(key) {
|
|
1722
1739
|
return SITES_NO_CACHE_PREFIX + encodeURIComponent(key);
|
|
1723
1740
|
}
|
|
@@ -1725,8 +1742,8 @@ function decodeSitesKey(key) {
|
|
|
1725
1742
|
return key.startsWith(SITES_NO_CACHE_PREFIX) ? decodeURIComponent(key.substring(SITES_NO_CACHE_PREFIX.length)) : key;
|
|
1726
1743
|
}
|
|
1727
1744
|
function isSitesRequest(request) {
|
|
1728
|
-
const
|
|
1729
|
-
return
|
|
1745
|
+
const url24 = new URL(request.url);
|
|
1746
|
+
return url24.pathname.startsWith(`/${SITES_NO_CACHE_PREFIX}`);
|
|
1730
1747
|
}
|
|
1731
1748
|
function serialiseRegExp(regExp) {
|
|
1732
1749
|
const str = regExp.toString();
|
|
@@ -1877,8 +1894,8 @@ var Response = class _Response extends import_undici3.Response {
|
|
|
1877
1894
|
Object.setPrototypeOf(response, _Response.prototype);
|
|
1878
1895
|
return response;
|
|
1879
1896
|
}
|
|
1880
|
-
static redirect(
|
|
1881
|
-
const response = import_undici3.Response.redirect(
|
|
1897
|
+
static redirect(url24, status) {
|
|
1898
|
+
const response = import_undici3.Response.redirect(url24, status);
|
|
1882
1899
|
Object.setPrototypeOf(response, _Response.prototype);
|
|
1883
1900
|
return response;
|
|
1884
1901
|
}
|
|
@@ -2359,18 +2376,18 @@ function headersFromIncomingRequest(req) {
|
|
|
2359
2376
|
);
|
|
2360
2377
|
return new undici.Headers(Object.fromEntries(entries));
|
|
2361
2378
|
}
|
|
2362
|
-
async function
|
|
2379
|
+
async function fetch4(input, init2) {
|
|
2363
2380
|
const requestInit = init2;
|
|
2364
2381
|
const request = new Request(input, requestInit);
|
|
2365
2382
|
if (request.method === "GET" && request.headers.get("upgrade") === "websocket") {
|
|
2366
|
-
const
|
|
2367
|
-
if (
|
|
2383
|
+
const url24 = new URL(request.url);
|
|
2384
|
+
if (url24.protocol !== "http:" && url24.protocol !== "https:") {
|
|
2368
2385
|
throw new TypeError(
|
|
2369
|
-
`Fetch API cannot load: ${
|
|
2386
|
+
`Fetch API cannot load: ${url24.toString()}.
|
|
2370
2387
|
Make sure you're using http(s):// URLs for WebSocket requests via fetch.`
|
|
2371
2388
|
);
|
|
2372
2389
|
}
|
|
2373
|
-
|
|
2390
|
+
url24.protocol = url24.protocol.replace("http", "ws");
|
|
2374
2391
|
const headers = {};
|
|
2375
2392
|
let protocols;
|
|
2376
2393
|
for (const [key, value] of request.headers.entries()) {
|
|
@@ -2382,10 +2399,10 @@ Make sure you're using http(s):// URLs for WebSocket requests via fetch.`
|
|
|
2382
2399
|
}
|
|
2383
2400
|
let rejectUnauthorized;
|
|
2384
2401
|
if (requestInit.dispatcher instanceof DispatchFetchDispatcher) {
|
|
2385
|
-
requestInit.dispatcher.addHeaders(headers,
|
|
2402
|
+
requestInit.dispatcher.addHeaders(headers, url24.pathname + url24.search);
|
|
2386
2403
|
rejectUnauthorized = { rejectUnauthorized: false };
|
|
2387
2404
|
}
|
|
2388
|
-
const ws = new import_ws2.default(
|
|
2405
|
+
const ws = new import_ws2.default(url24, protocols, {
|
|
2389
2406
|
followRedirects: request.redirect === "follow",
|
|
2390
2407
|
headers,
|
|
2391
2408
|
...rejectUnauthorized
|
|
@@ -2441,8 +2458,8 @@ var DispatchFetchDispatcher = class extends undici.Dispatcher {
|
|
|
2441
2458
|
if (cfBlob !== void 0) this.cfBlobJson = JSON.stringify(cfBlob);
|
|
2442
2459
|
}
|
|
2443
2460
|
cfBlobJson;
|
|
2444
|
-
addHeaders(headers,
|
|
2445
|
-
const originalURL = this.userRuntimeOrigin +
|
|
2461
|
+
addHeaders(headers, path34) {
|
|
2462
|
+
const originalURL = this.userRuntimeOrigin + path34;
|
|
2446
2463
|
addHeader(headers, CoreHeaders.ORIGINAL_URL, originalURL);
|
|
2447
2464
|
addHeader(headers, CoreHeaders.DISABLE_PRETTY_ERROR, "true");
|
|
2448
2465
|
if (this.cfBlobJson !== void 0) {
|
|
@@ -2454,16 +2471,16 @@ var DispatchFetchDispatcher = class extends undici.Dispatcher {
|
|
|
2454
2471
|
if (origin === this.userRuntimeOrigin) origin = this.actualRuntimeOrigin;
|
|
2455
2472
|
if (origin === this.actualRuntimeOrigin) {
|
|
2456
2473
|
options.origin = origin;
|
|
2457
|
-
let
|
|
2474
|
+
let path34 = options.path;
|
|
2458
2475
|
if (options.query !== void 0) {
|
|
2459
|
-
const
|
|
2476
|
+
const url24 = new URL(path34, "http://placeholder/");
|
|
2460
2477
|
for (const [key, value] of Object.entries(options.query)) {
|
|
2461
|
-
|
|
2478
|
+
url24.searchParams.append(key, value);
|
|
2462
2479
|
}
|
|
2463
|
-
|
|
2480
|
+
path34 = url24.pathname + url24.search;
|
|
2464
2481
|
}
|
|
2465
2482
|
options.headers ??= {};
|
|
2466
|
-
this.addHeaders(options.headers,
|
|
2483
|
+
this.addHeaders(options.headers, path34);
|
|
2467
2484
|
return this.runtimeDispatcher.dispatch(options, handler);
|
|
2468
2485
|
} else {
|
|
2469
2486
|
return this.globalDispatcher.dispatch(options, handler);
|
|
@@ -2558,8 +2575,8 @@ function valueOrFile(value, filePath) {
|
|
|
2558
2575
|
var import_os = require("os");
|
|
2559
2576
|
function getAccessibleHosts(ipv4Only = false) {
|
|
2560
2577
|
const hosts = [];
|
|
2561
|
-
Object.values((0, import_os.networkInterfaces)()).forEach((
|
|
2562
|
-
|
|
2578
|
+
Object.values((0, import_os.networkInterfaces)()).forEach((net3) => {
|
|
2579
|
+
net3?.forEach(({ family, address }) => {
|
|
2563
2580
|
if (family === "IPv4" || family === 4) {
|
|
2564
2581
|
hosts.push(address);
|
|
2565
2582
|
} else if (!ipv4Only) {
|
|
@@ -2573,6 +2590,329 @@ function getAccessibleHosts(ipv4Only = false) {
|
|
|
2573
2590
|
// src/http/index.ts
|
|
2574
2591
|
var import_undici4 = require("undici");
|
|
2575
2592
|
|
|
2593
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/analytics-engine/analytics-engine.worker.ts
|
|
2594
|
+
var import_fs3 = __toESM(require("fs"));
|
|
2595
|
+
var import_path6 = __toESM(require("path"));
|
|
2596
|
+
var import_url3 = __toESM(require("url"));
|
|
2597
|
+
var contents3;
|
|
2598
|
+
function analytics_engine_worker_default() {
|
|
2599
|
+
if (contents3 !== void 0) return contents3;
|
|
2600
|
+
const filePath = import_path6.default.join(__dirname, "workers", "analytics-engine/analytics-engine.worker.js");
|
|
2601
|
+
contents3 = import_fs3.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url3.default.pathToFileURL(filePath);
|
|
2602
|
+
return contents3;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
// src/plugins/analytics-engine/index.ts
|
|
2606
|
+
var import_zod5 = require("zod");
|
|
2607
|
+
|
|
2608
|
+
// src/plugins/shared/index.ts
|
|
2609
|
+
var import_crypto = __toESM(require("crypto"));
|
|
2610
|
+
var import_fs5 = require("fs");
|
|
2611
|
+
var import_promises3 = __toESM(require("fs/promises"));
|
|
2612
|
+
var import_path8 = __toESM(require("path"));
|
|
2613
|
+
var import_url6 = require("url");
|
|
2614
|
+
var import_zod4 = require("zod");
|
|
2615
|
+
|
|
2616
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/object-entry.worker.ts
|
|
2617
|
+
var import_fs4 = __toESM(require("fs"));
|
|
2618
|
+
var import_path7 = __toESM(require("path"));
|
|
2619
|
+
var import_url4 = __toESM(require("url"));
|
|
2620
|
+
var contents4;
|
|
2621
|
+
function object_entry_worker_default() {
|
|
2622
|
+
if (contents4 !== void 0) return contents4;
|
|
2623
|
+
const filePath = import_path7.default.join(__dirname, "workers", "shared/object-entry.worker.js");
|
|
2624
|
+
contents4 = import_fs4.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url4.default.pathToFileURL(filePath);
|
|
2625
|
+
return contents4;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
// src/plugins/shared/constants.ts
|
|
2629
|
+
var SOCKET_ENTRY = "entry";
|
|
2630
|
+
var SOCKET_ENTRY_LOCAL = "entry:local";
|
|
2631
|
+
var SOCKET_DIRECT_PREFIX = "direct";
|
|
2632
|
+
function getDirectSocketName(workerIndex, entrypoint) {
|
|
2633
|
+
return `${SOCKET_DIRECT_PREFIX}:${workerIndex}:${entrypoint}`;
|
|
2634
|
+
}
|
|
2635
|
+
var SERVICE_LOOPBACK = "loopback";
|
|
2636
|
+
var HOST_CAPNP_CONNECT = "miniflare-unsafe-internal-capnp-connect";
|
|
2637
|
+
var WORKER_BINDING_SERVICE_LOOPBACK = {
|
|
2638
|
+
name: CoreBindings.SERVICE_LOOPBACK,
|
|
2639
|
+
service: { name: SERVICE_LOOPBACK }
|
|
2640
|
+
};
|
|
2641
|
+
var WORKER_BINDING_ENABLE_CONTROL_ENDPOINTS = {
|
|
2642
|
+
name: SharedBindings.MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS,
|
|
2643
|
+
json: "true"
|
|
2644
|
+
};
|
|
2645
|
+
var WORKER_BINDING_ENABLE_STICKY_BLOBS = {
|
|
2646
|
+
name: SharedBindings.MAYBE_JSON_ENABLE_STICKY_BLOBS,
|
|
2647
|
+
json: "true"
|
|
2648
|
+
};
|
|
2649
|
+
var enableControlEndpoints = false;
|
|
2650
|
+
function getMiniflareObjectBindings(unsafeStickyBlobs) {
|
|
2651
|
+
const result = [];
|
|
2652
|
+
if (enableControlEndpoints) {
|
|
2653
|
+
result.push(WORKER_BINDING_ENABLE_CONTROL_ENDPOINTS);
|
|
2654
|
+
}
|
|
2655
|
+
if (unsafeStickyBlobs) {
|
|
2656
|
+
result.push(WORKER_BINDING_ENABLE_STICKY_BLOBS);
|
|
2657
|
+
}
|
|
2658
|
+
return result;
|
|
2659
|
+
}
|
|
2660
|
+
function _enableControlEndpoints() {
|
|
2661
|
+
enableControlEndpoints = true;
|
|
2662
|
+
}
|
|
2663
|
+
function objectEntryWorker(durableObjectNamespace, namespace) {
|
|
2664
|
+
return {
|
|
2665
|
+
compatibilityDate: "2023-07-24",
|
|
2666
|
+
modules: [
|
|
2667
|
+
{ name: "object-entry.worker.js", esModule: object_entry_worker_default() }
|
|
2668
|
+
],
|
|
2669
|
+
bindings: [
|
|
2670
|
+
{ name: SharedBindings.TEXT_NAMESPACE, text: namespace },
|
|
2671
|
+
{
|
|
2672
|
+
name: SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT,
|
|
2673
|
+
durableObjectNamespace
|
|
2674
|
+
}
|
|
2675
|
+
]
|
|
2676
|
+
};
|
|
2677
|
+
}
|
|
2678
|
+
var kUnsafeEphemeralUniqueKey = Symbol.for(
|
|
2679
|
+
"miniflare.kUnsafeEphemeralUniqueKey"
|
|
2680
|
+
);
|
|
2681
|
+
|
|
2682
|
+
// src/plugins/shared/routing.ts
|
|
2683
|
+
var import_url5 = require("url");
|
|
2684
|
+
var RouterError = class extends MiniflareError {
|
|
2685
|
+
};
|
|
2686
|
+
function routeSpecificity(url24) {
|
|
2687
|
+
const hostParts = url24.host.split(".");
|
|
2688
|
+
let hostScore = hostParts.length;
|
|
2689
|
+
if (hostParts[0] === "*") hostScore -= 2;
|
|
2690
|
+
const pathParts = url24.pathname.split("/");
|
|
2691
|
+
let pathScore = pathParts.length;
|
|
2692
|
+
if (pathParts[pathParts.length - 1] === "*") pathScore -= 2;
|
|
2693
|
+
return hostScore * 26 + pathScore;
|
|
2694
|
+
}
|
|
2695
|
+
function parseRoutes(allRoutes) {
|
|
2696
|
+
const routes = [];
|
|
2697
|
+
for (const [target, targetRoutes] of allRoutes) {
|
|
2698
|
+
for (const route of targetRoutes) {
|
|
2699
|
+
const hasProtocol = /^[a-z0-9+\-.]+:\/\//i.test(route);
|
|
2700
|
+
let urlInput = route;
|
|
2701
|
+
if (!hasProtocol) urlInput = `https://${urlInput}`;
|
|
2702
|
+
const url24 = new import_url5.URL(urlInput);
|
|
2703
|
+
const specificity = routeSpecificity(url24);
|
|
2704
|
+
const protocol = hasProtocol ? url24.protocol : void 0;
|
|
2705
|
+
const internationalisedAllowHostnamePrefix = url24.hostname.startsWith("xn--*");
|
|
2706
|
+
const allowHostnamePrefix = url24.hostname.startsWith("*") || internationalisedAllowHostnamePrefix;
|
|
2707
|
+
const anyHostname = url24.hostname === "*";
|
|
2708
|
+
if (allowHostnamePrefix && !anyHostname) {
|
|
2709
|
+
let hostname = url24.hostname;
|
|
2710
|
+
if (internationalisedAllowHostnamePrefix) {
|
|
2711
|
+
hostname = (0, import_url5.domainToUnicode)(hostname);
|
|
2712
|
+
}
|
|
2713
|
+
url24.hostname = hostname.substring(1);
|
|
2714
|
+
}
|
|
2715
|
+
const allowPathSuffix = url24.pathname.endsWith("*");
|
|
2716
|
+
if (allowPathSuffix) {
|
|
2717
|
+
url24.pathname = url24.pathname.substring(0, url24.pathname.length - 1);
|
|
2718
|
+
}
|
|
2719
|
+
if (url24.search) {
|
|
2720
|
+
throw new RouterError(
|
|
2721
|
+
"ERR_QUERY_STRING",
|
|
2722
|
+
`Route "${route}" for "${target}" contains a query string. This is not allowed.`
|
|
2723
|
+
);
|
|
2724
|
+
}
|
|
2725
|
+
if (url24.toString().includes("*") && !anyHostname) {
|
|
2726
|
+
throw new RouterError(
|
|
2727
|
+
"ERR_INFIX_WILDCARD",
|
|
2728
|
+
`Route "${route}" for "${target}" contains an infix wildcard. This is not allowed.`
|
|
2729
|
+
);
|
|
2730
|
+
}
|
|
2731
|
+
routes.push({
|
|
2732
|
+
target,
|
|
2733
|
+
route,
|
|
2734
|
+
specificity,
|
|
2735
|
+
protocol,
|
|
2736
|
+
allowHostnamePrefix,
|
|
2737
|
+
hostname: anyHostname ? "" : url24.hostname,
|
|
2738
|
+
path: url24.pathname,
|
|
2739
|
+
allowPathSuffix
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
routes.sort((a, b) => {
|
|
2744
|
+
if (a.specificity === b.specificity) {
|
|
2745
|
+
return b.route.length - a.route.length;
|
|
2746
|
+
} else {
|
|
2747
|
+
return b.specificity - a.specificity;
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2750
|
+
return routes;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
// src/plugins/shared/index.ts
|
|
2754
|
+
var DEFAULT_PERSIST_ROOT = ".mf";
|
|
2755
|
+
var PersistenceSchema = import_zod4.z.union([import_zod4.z.boolean(), import_zod4.z.string().url(), PathSchema]).optional();
|
|
2756
|
+
var ProxyNodeBinding = class {
|
|
2757
|
+
constructor(proxyOverrideHandler) {
|
|
2758
|
+
this.proxyOverrideHandler = proxyOverrideHandler;
|
|
2759
|
+
}
|
|
2760
|
+
};
|
|
2761
|
+
function namespaceKeys(namespaces) {
|
|
2762
|
+
if (Array.isArray(namespaces)) {
|
|
2763
|
+
return namespaces;
|
|
2764
|
+
} else if (namespaces !== void 0) {
|
|
2765
|
+
return Object.keys(namespaces);
|
|
2766
|
+
} else {
|
|
2767
|
+
return [];
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
function namespaceEntries(namespaces) {
|
|
2771
|
+
if (Array.isArray(namespaces)) {
|
|
2772
|
+
return namespaces.map((bindingName) => [bindingName, bindingName]);
|
|
2773
|
+
} else if (namespaces !== void 0) {
|
|
2774
|
+
return Object.entries(namespaces);
|
|
2775
|
+
} else {
|
|
2776
|
+
return [];
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
function maybeParseURL(url24) {
|
|
2780
|
+
if (typeof url24 !== "string" || import_path8.default.isAbsolute(url24)) return;
|
|
2781
|
+
try {
|
|
2782
|
+
return new URL(url24);
|
|
2783
|
+
} catch {
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
function getPersistPath(pluginName, tmpPath, persist) {
|
|
2787
|
+
const memoryishPath = import_path8.default.join(tmpPath, pluginName);
|
|
2788
|
+
if (persist === void 0 || persist === false) {
|
|
2789
|
+
return memoryishPath;
|
|
2790
|
+
}
|
|
2791
|
+
const url24 = maybeParseURL(persist);
|
|
2792
|
+
if (url24 !== void 0) {
|
|
2793
|
+
if (url24.protocol === "memory:") {
|
|
2794
|
+
return memoryishPath;
|
|
2795
|
+
} else if (url24.protocol === "file:") {
|
|
2796
|
+
return (0, import_url6.fileURLToPath)(url24);
|
|
2797
|
+
}
|
|
2798
|
+
throw new MiniflareCoreError(
|
|
2799
|
+
"ERR_PERSIST_UNSUPPORTED",
|
|
2800
|
+
`Unsupported "${url24.protocol}" persistence protocol for storage: ${url24.href}`
|
|
2801
|
+
);
|
|
2802
|
+
}
|
|
2803
|
+
return persist === true ? import_path8.default.join(DEFAULT_PERSIST_ROOT, pluginName) : persist;
|
|
2804
|
+
}
|
|
2805
|
+
function durableObjectNamespaceIdFromName(uniqueKey, name) {
|
|
2806
|
+
const key = import_crypto.default.createHash("sha256").update(uniqueKey).digest();
|
|
2807
|
+
const nameHmac = import_crypto.default.createHmac("sha256", key).update(name).digest().subarray(0, 16);
|
|
2808
|
+
const hmac = import_crypto.default.createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16);
|
|
2809
|
+
return Buffer.concat([nameHmac, hmac]).toString("hex");
|
|
2810
|
+
}
|
|
2811
|
+
async function migrateDatabase(log, uniqueKey, persistPath, namespace) {
|
|
2812
|
+
const sanitisedNamespace = sanitisePath(namespace);
|
|
2813
|
+
const previousDir = import_path8.default.join(persistPath, sanitisedNamespace);
|
|
2814
|
+
const previousPath = import_path8.default.join(previousDir, "db.sqlite");
|
|
2815
|
+
const previousWalPath = import_path8.default.join(previousDir, "db.sqlite-wal");
|
|
2816
|
+
if (!(0, import_fs5.existsSync)(previousPath)) return;
|
|
2817
|
+
const id = durableObjectNamespaceIdFromName(uniqueKey, namespace);
|
|
2818
|
+
const newDir = import_path8.default.join(persistPath, uniqueKey);
|
|
2819
|
+
const newPath = import_path8.default.join(newDir, `${id}.sqlite`);
|
|
2820
|
+
const newWalPath = import_path8.default.join(newDir, `${id}.sqlite-wal`);
|
|
2821
|
+
if ((0, import_fs5.existsSync)(newPath)) {
|
|
2822
|
+
log.debug(
|
|
2823
|
+
`Not migrating ${previousPath} to ${newPath} as it already exists`
|
|
2824
|
+
);
|
|
2825
|
+
return;
|
|
2826
|
+
}
|
|
2827
|
+
log.debug(`Migrating ${previousPath} to ${newPath}...`);
|
|
2828
|
+
await import_promises3.default.mkdir(newDir, { recursive: true });
|
|
2829
|
+
try {
|
|
2830
|
+
await import_promises3.default.copyFile(previousPath, newPath);
|
|
2831
|
+
if ((0, import_fs5.existsSync)(previousWalPath)) {
|
|
2832
|
+
await import_promises3.default.copyFile(previousWalPath, newWalPath);
|
|
2833
|
+
}
|
|
2834
|
+
await import_promises3.default.unlink(previousPath);
|
|
2835
|
+
await import_promises3.default.unlink(previousWalPath);
|
|
2836
|
+
} catch (e) {
|
|
2837
|
+
log.warn(`Error migrating ${previousPath} to ${newPath}: ${e}`);
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
// src/plugins/analytics-engine/index.ts
|
|
2842
|
+
var AnalyticsEngineSchema = import_zod5.z.record(
|
|
2843
|
+
import_zod5.z.object({
|
|
2844
|
+
dataset: import_zod5.z.string()
|
|
2845
|
+
})
|
|
2846
|
+
);
|
|
2847
|
+
var AnalyticsEngineSchemaOptionsSchema = import_zod5.z.object({
|
|
2848
|
+
analyticsEngineDatasets: AnalyticsEngineSchema.optional()
|
|
2849
|
+
});
|
|
2850
|
+
var AnalyticsEngineSchemaSharedOptionsSchema = import_zod5.z.object({
|
|
2851
|
+
analyticsEngineDatasetsPersist: PersistenceSchema
|
|
2852
|
+
});
|
|
2853
|
+
var ANALYTICS_ENGINE_PLUGIN_NAME = "analytics-engine";
|
|
2854
|
+
var ANALYTICS_ENGINE_PLUGIN = {
|
|
2855
|
+
options: AnalyticsEngineSchemaOptionsSchema,
|
|
2856
|
+
sharedOptions: AnalyticsEngineSchemaSharedOptionsSchema,
|
|
2857
|
+
async getBindings(options) {
|
|
2858
|
+
if (!options.analyticsEngineDatasets) {
|
|
2859
|
+
return [];
|
|
2860
|
+
}
|
|
2861
|
+
const bindings = Object.entries(
|
|
2862
|
+
options.analyticsEngineDatasets
|
|
2863
|
+
).map(([name, config]) => {
|
|
2864
|
+
return {
|
|
2865
|
+
name,
|
|
2866
|
+
service: {
|
|
2867
|
+
name: `${ANALYTICS_ENGINE_PLUGIN_NAME}:${config.dataset}`,
|
|
2868
|
+
entrypoint: "LocalAnalyticsEngineDataset"
|
|
2869
|
+
}
|
|
2870
|
+
};
|
|
2871
|
+
});
|
|
2872
|
+
return bindings;
|
|
2873
|
+
},
|
|
2874
|
+
getNodeBindings(options) {
|
|
2875
|
+
if (!options.analyticsEngineDatasets) {
|
|
2876
|
+
return {};
|
|
2877
|
+
}
|
|
2878
|
+
return Object.fromEntries(
|
|
2879
|
+
Object.keys(options.analyticsEngineDatasets).map((name) => [
|
|
2880
|
+
name,
|
|
2881
|
+
new ProxyNodeBinding()
|
|
2882
|
+
])
|
|
2883
|
+
);
|
|
2884
|
+
},
|
|
2885
|
+
async getServices({ options }) {
|
|
2886
|
+
if (!options.analyticsEngineDatasets) {
|
|
2887
|
+
return [];
|
|
2888
|
+
}
|
|
2889
|
+
return [
|
|
2890
|
+
...Object.entries(options.analyticsEngineDatasets).map(
|
|
2891
|
+
([_, config]) => {
|
|
2892
|
+
return {
|
|
2893
|
+
name: `${ANALYTICS_ENGINE_PLUGIN_NAME}:${config.dataset}`,
|
|
2894
|
+
worker: {
|
|
2895
|
+
compatibilityDate: "2025-01-01",
|
|
2896
|
+
modules: [
|
|
2897
|
+
{
|
|
2898
|
+
name: "analytics-engine.worker.js",
|
|
2899
|
+
esModule: analytics_engine_worker_default()
|
|
2900
|
+
}
|
|
2901
|
+
],
|
|
2902
|
+
bindings: [
|
|
2903
|
+
{
|
|
2904
|
+
name: "dataset",
|
|
2905
|
+
json: JSON.stringify(config.dataset)
|
|
2906
|
+
}
|
|
2907
|
+
]
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2911
|
+
)
|
|
2912
|
+
];
|
|
2913
|
+
}
|
|
2914
|
+
};
|
|
2915
|
+
|
|
2576
2916
|
// src/plugins/assets/index.ts
|
|
2577
2917
|
var import_node_crypto = __toESM(require("node:crypto"));
|
|
2578
2918
|
var import_promises7 = __toESM(require("node:fs/promises"));
|
|
@@ -2593,51 +2933,52 @@ var REDIRECTS_FILENAME = "_redirects";
|
|
|
2593
2933
|
var HEADERS_FILENAME = "_headers";
|
|
2594
2934
|
|
|
2595
2935
|
// ../workers-shared/utils/types.ts
|
|
2596
|
-
var
|
|
2597
|
-
var InternalConfigSchema =
|
|
2598
|
-
account_id:
|
|
2599
|
-
script_id:
|
|
2936
|
+
var import_zod6 = require("zod");
|
|
2937
|
+
var InternalConfigSchema = import_zod6.z.object({
|
|
2938
|
+
account_id: import_zod6.z.number().optional(),
|
|
2939
|
+
script_id: import_zod6.z.number().optional(),
|
|
2940
|
+
debug: import_zod6.z.boolean().optional()
|
|
2600
2941
|
});
|
|
2601
|
-
var RouterConfigSchema =
|
|
2602
|
-
invoke_user_worker_ahead_of_assets:
|
|
2603
|
-
has_user_worker:
|
|
2942
|
+
var RouterConfigSchema = import_zod6.z.object({
|
|
2943
|
+
invoke_user_worker_ahead_of_assets: import_zod6.z.boolean().optional(),
|
|
2944
|
+
has_user_worker: import_zod6.z.boolean().optional(),
|
|
2604
2945
|
...InternalConfigSchema.shape
|
|
2605
2946
|
});
|
|
2606
|
-
var MetadataStaticRedirectEntry =
|
|
2607
|
-
status:
|
|
2608
|
-
to:
|
|
2609
|
-
lineNumber:
|
|
2947
|
+
var MetadataStaticRedirectEntry = import_zod6.z.object({
|
|
2948
|
+
status: import_zod6.z.number(),
|
|
2949
|
+
to: import_zod6.z.string(),
|
|
2950
|
+
lineNumber: import_zod6.z.number()
|
|
2610
2951
|
});
|
|
2611
|
-
var MetadataRedirectEntry =
|
|
2612
|
-
status:
|
|
2613
|
-
to:
|
|
2952
|
+
var MetadataRedirectEntry = import_zod6.z.object({
|
|
2953
|
+
status: import_zod6.z.number(),
|
|
2954
|
+
to: import_zod6.z.string()
|
|
2614
2955
|
});
|
|
2615
|
-
var MetadataStaticRedirects =
|
|
2616
|
-
var MetadataRedirects =
|
|
2617
|
-
var MetadataHeaderEntry =
|
|
2618
|
-
set:
|
|
2619
|
-
unset:
|
|
2956
|
+
var MetadataStaticRedirects = import_zod6.z.record(MetadataStaticRedirectEntry);
|
|
2957
|
+
var MetadataRedirects = import_zod6.z.record(MetadataRedirectEntry);
|
|
2958
|
+
var MetadataHeaderEntry = import_zod6.z.object({
|
|
2959
|
+
set: import_zod6.z.record(import_zod6.z.string()).optional(),
|
|
2960
|
+
unset: import_zod6.z.array(import_zod6.z.string()).optional()
|
|
2620
2961
|
});
|
|
2621
|
-
var MetadataHeaders =
|
|
2622
|
-
var RedirectsSchema =
|
|
2623
|
-
version:
|
|
2962
|
+
var MetadataHeaders = import_zod6.z.record(MetadataHeaderEntry);
|
|
2963
|
+
var RedirectsSchema = import_zod6.z.object({
|
|
2964
|
+
version: import_zod6.z.literal(1),
|
|
2624
2965
|
staticRules: MetadataStaticRedirects,
|
|
2625
2966
|
rules: MetadataRedirects
|
|
2626
2967
|
}).optional();
|
|
2627
|
-
var HeadersSchema =
|
|
2628
|
-
version:
|
|
2968
|
+
var HeadersSchema = import_zod6.z.object({
|
|
2969
|
+
version: import_zod6.z.literal(2),
|
|
2629
2970
|
rules: MetadataHeaders
|
|
2630
2971
|
}).optional();
|
|
2631
|
-
var AssetConfigSchema =
|
|
2632
|
-
compatibility_date:
|
|
2633
|
-
compatibility_flags:
|
|
2634
|
-
html_handling:
|
|
2972
|
+
var AssetConfigSchema = import_zod6.z.object({
|
|
2973
|
+
compatibility_date: import_zod6.z.string().optional(),
|
|
2974
|
+
compatibility_flags: import_zod6.z.array(import_zod6.z.string()).optional(),
|
|
2975
|
+
html_handling: import_zod6.z.enum([
|
|
2635
2976
|
"auto-trailing-slash",
|
|
2636
2977
|
"force-trailing-slash",
|
|
2637
2978
|
"drop-trailing-slash",
|
|
2638
2979
|
"none"
|
|
2639
2980
|
]).optional(),
|
|
2640
|
-
not_found_handling:
|
|
2981
|
+
not_found_handling: import_zod6.z.enum(["single-page-application", "404-page", "none"]).optional(),
|
|
2641
2982
|
redirects: RedirectsSchema,
|
|
2642
2983
|
headers: HeadersSchema,
|
|
2643
2984
|
...InternalConfigSchema.shape
|
|
@@ -2816,13 +3157,14 @@ ${invalidHeaderRulesList}`
|
|
|
2816
3157
|
}
|
|
2817
3158
|
const rules = {};
|
|
2818
3159
|
for (const rule of headers.rules) {
|
|
2819
|
-
|
|
3160
|
+
const configuredRule = {};
|
|
2820
3161
|
if (Object.keys(rule.headers).length) {
|
|
2821
|
-
|
|
3162
|
+
configuredRule.set = rule.headers;
|
|
2822
3163
|
}
|
|
2823
3164
|
if (rule.unsetHeaders.length) {
|
|
2824
|
-
|
|
3165
|
+
configuredRule.unset = rule.unsetHeaders;
|
|
2825
3166
|
}
|
|
3167
|
+
rules[rule.path] = configuredRule;
|
|
2826
3168
|
}
|
|
2827
3169
|
return {
|
|
2828
3170
|
headers: {
|
|
@@ -2833,12 +3175,12 @@ ${invalidHeaderRulesList}`
|
|
|
2833
3175
|
}
|
|
2834
3176
|
|
|
2835
3177
|
// ../workers-shared/utils/configuration/validateURL.ts
|
|
2836
|
-
var extractPathname = (
|
|
2837
|
-
if (!
|
|
2838
|
-
|
|
3178
|
+
var extractPathname = (path34 = "/", includeSearch, includeHash) => {
|
|
3179
|
+
if (!path34.startsWith("/")) {
|
|
3180
|
+
path34 = `/${path34}`;
|
|
2839
3181
|
}
|
|
2840
|
-
const
|
|
2841
|
-
return `${
|
|
3182
|
+
const url24 = new URL(`//${path34}`, "relative://");
|
|
3183
|
+
return `${url24.pathname}${includeSearch ? url24.search : ""}${includeHash ? url24.hash : ""}`;
|
|
2842
3184
|
};
|
|
2843
3185
|
var URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
2844
3186
|
var HOST_WITH_PORT_REGEX = /.*:\d+$/;
|
|
@@ -2870,8 +3212,8 @@ var validateUrl = (token, onlyRelative = false, disallowPorts = false, includeSe
|
|
|
2870
3212
|
if (!token.startsWith("/") && onlyRelative) {
|
|
2871
3213
|
token = `/${token}`;
|
|
2872
3214
|
}
|
|
2873
|
-
const
|
|
2874
|
-
if (
|
|
3215
|
+
const path34 = PATH_REGEX.exec(token);
|
|
3216
|
+
if (path34) {
|
|
2875
3217
|
try {
|
|
2876
3218
|
return [extractPathname(token, includeSearch, includeHash), void 0];
|
|
2877
3219
|
} catch {
|
|
@@ -2891,26 +3233,29 @@ function urlHasHost(token) {
|
|
|
2891
3233
|
|
|
2892
3234
|
// ../workers-shared/utils/configuration/parseHeaders.ts
|
|
2893
3235
|
var LINE_IS_PROBABLY_A_PATH = new RegExp(/^([^\s]+:\/\/|^\/)/);
|
|
2894
|
-
function parseHeaders(input
|
|
3236
|
+
function parseHeaders(input, {
|
|
3237
|
+
maxRules = MAX_HEADER_RULES,
|
|
3238
|
+
maxLineLength = MAX_LINE_LENGTH
|
|
3239
|
+
} = {}) {
|
|
2895
3240
|
const lines = input.split("\n");
|
|
2896
3241
|
const rules = [];
|
|
2897
3242
|
const invalid = [];
|
|
2898
3243
|
let rule = void 0;
|
|
2899
3244
|
for (let i = 0; i < lines.length; i++) {
|
|
2900
|
-
const line = lines[i].trim();
|
|
3245
|
+
const line = (lines[i] || "").trim();
|
|
2901
3246
|
if (line.length === 0 || line.startsWith("#")) {
|
|
2902
3247
|
continue;
|
|
2903
3248
|
}
|
|
2904
|
-
if (line.length >
|
|
3249
|
+
if (line.length > maxLineLength) {
|
|
2905
3250
|
invalid.push({
|
|
2906
|
-
message: `Ignoring line ${i + 1} as it exceeds the maximum allowed length of ${
|
|
3251
|
+
message: `Ignoring line ${i + 1} as it exceeds the maximum allowed length of ${maxLineLength}.`
|
|
2907
3252
|
});
|
|
2908
3253
|
continue;
|
|
2909
3254
|
}
|
|
2910
3255
|
if (LINE_IS_PROBABLY_A_PATH.test(line)) {
|
|
2911
|
-
if (rules.length >=
|
|
3256
|
+
if (rules.length >= maxRules) {
|
|
2912
3257
|
invalid.push({
|
|
2913
|
-
message: `Maximum number of rules supported is ${
|
|
3258
|
+
message: `Maximum number of rules supported is ${maxRules}. Skipping remaining ${lines.length - i} lines of file.`
|
|
2914
3259
|
});
|
|
2915
3260
|
break;
|
|
2916
3261
|
}
|
|
@@ -2929,7 +3274,7 @@ function parseHeaders(input) {
|
|
|
2929
3274
|
});
|
|
2930
3275
|
}
|
|
2931
3276
|
}
|
|
2932
|
-
const [
|
|
3277
|
+
const [path34, pathError] = validateUrl(line, false, true);
|
|
2933
3278
|
if (pathError) {
|
|
2934
3279
|
invalid.push({
|
|
2935
3280
|
line,
|
|
@@ -2940,7 +3285,7 @@ function parseHeaders(input) {
|
|
|
2940
3285
|
continue;
|
|
2941
3286
|
}
|
|
2942
3287
|
rule = {
|
|
2943
|
-
path:
|
|
3288
|
+
path: path34,
|
|
2944
3289
|
line,
|
|
2945
3290
|
headers: {},
|
|
2946
3291
|
unsetHeaders: []
|
|
@@ -2968,7 +3313,7 @@ function parseHeaders(input) {
|
|
|
2968
3313
|
continue;
|
|
2969
3314
|
}
|
|
2970
3315
|
const [rawName, ...rawValue] = line.split(HEADER_SEPARATOR);
|
|
2971
|
-
const name = rawName.trim().toLowerCase();
|
|
3316
|
+
const name = (rawName || "").trim().toLowerCase();
|
|
2972
3317
|
if (name.includes(" ")) {
|
|
2973
3318
|
invalid.push({
|
|
2974
3319
|
line,
|
|
@@ -3026,7 +3371,11 @@ function isValidRule(rule) {
|
|
|
3026
3371
|
}
|
|
3027
3372
|
|
|
3028
3373
|
// ../workers-shared/utils/configuration/parseRedirects.ts
|
|
3029
|
-
function parseRedirects(input
|
|
3374
|
+
function parseRedirects(input, {
|
|
3375
|
+
maxStaticRules = MAX_STATIC_REDIRECT_RULES,
|
|
3376
|
+
maxDynamicRules = MAX_DYNAMIC_REDIRECT_RULES,
|
|
3377
|
+
maxLineLength = MAX_LINE_LENGTH
|
|
3378
|
+
} = {}) {
|
|
3030
3379
|
const lines = input.split("\n");
|
|
3031
3380
|
const rules = [];
|
|
3032
3381
|
const seen_paths = /* @__PURE__ */ new Set();
|
|
@@ -3035,13 +3384,13 @@ function parseRedirects(input) {
|
|
|
3035
3384
|
let dynamicRules = 0;
|
|
3036
3385
|
let canCreateStaticRule = true;
|
|
3037
3386
|
for (let i = 0; i < lines.length; i++) {
|
|
3038
|
-
const line = lines[i].trim();
|
|
3387
|
+
const line = (lines[i] || "").trim();
|
|
3039
3388
|
if (line.length === 0 || line.startsWith("#")) {
|
|
3040
3389
|
continue;
|
|
3041
3390
|
}
|
|
3042
|
-
if (line.length >
|
|
3391
|
+
if (line.length > maxLineLength) {
|
|
3043
3392
|
invalid.push({
|
|
3044
|
-
message: `Ignoring line ${i + 1} as it exceeds the maximum allowed length of ${
|
|
3393
|
+
message: `Ignoring line ${i + 1} as it exceeds the maximum allowed length of ${maxLineLength}.`
|
|
3045
3394
|
});
|
|
3046
3395
|
continue;
|
|
3047
3396
|
}
|
|
@@ -3067,18 +3416,18 @@ function parseRedirects(input) {
|
|
|
3067
3416
|
const from = fromResult[0];
|
|
3068
3417
|
if (canCreateStaticRule && !from.match(SPLAT_REGEX) && !from.match(PLACEHOLDER_REGEX)) {
|
|
3069
3418
|
staticRules += 1;
|
|
3070
|
-
if (staticRules >
|
|
3419
|
+
if (staticRules > maxStaticRules) {
|
|
3071
3420
|
invalid.push({
|
|
3072
|
-
message: `Maximum number of static rules supported is ${
|
|
3421
|
+
message: `Maximum number of static rules supported is ${maxStaticRules}. Skipping line.`
|
|
3073
3422
|
});
|
|
3074
3423
|
continue;
|
|
3075
3424
|
}
|
|
3076
3425
|
} else {
|
|
3077
3426
|
dynamicRules += 1;
|
|
3078
3427
|
canCreateStaticRule = false;
|
|
3079
|
-
if (dynamicRules >
|
|
3428
|
+
if (dynamicRules > maxDynamicRules) {
|
|
3080
3429
|
invalid.push({
|
|
3081
|
-
message: `Maximum number of dynamic rules supported is ${
|
|
3430
|
+
message: `Maximum number of dynamic rules supported is ${maxDynamicRules}. Skipping remaining ${lines.length - i} lines of file.`
|
|
3082
3431
|
});
|
|
3083
3432
|
break;
|
|
3084
3433
|
}
|
|
@@ -3233,77 +3582,77 @@ function prettyBytes(number, options) {
|
|
|
3233
3582
|
}
|
|
3234
3583
|
|
|
3235
3584
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/assets.worker.ts
|
|
3236
|
-
var
|
|
3237
|
-
var
|
|
3238
|
-
var
|
|
3239
|
-
var
|
|
3585
|
+
var import_fs6 = __toESM(require("fs"));
|
|
3586
|
+
var import_path9 = __toESM(require("path"));
|
|
3587
|
+
var import_url7 = __toESM(require("url"));
|
|
3588
|
+
var contents5;
|
|
3240
3589
|
function assets_worker_default() {
|
|
3241
|
-
if (
|
|
3242
|
-
const filePath =
|
|
3243
|
-
|
|
3244
|
-
return
|
|
3590
|
+
if (contents5 !== void 0) return contents5;
|
|
3591
|
+
const filePath = import_path9.default.join(__dirname, "workers", "assets/assets.worker.js");
|
|
3592
|
+
contents5 = import_fs6.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url7.default.pathToFileURL(filePath);
|
|
3593
|
+
return contents5;
|
|
3245
3594
|
}
|
|
3246
3595
|
|
|
3247
3596
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/assets-kv.worker.ts
|
|
3248
|
-
var
|
|
3249
|
-
var
|
|
3250
|
-
var
|
|
3251
|
-
var
|
|
3597
|
+
var import_fs7 = __toESM(require("fs"));
|
|
3598
|
+
var import_path10 = __toESM(require("path"));
|
|
3599
|
+
var import_url8 = __toESM(require("url"));
|
|
3600
|
+
var contents6;
|
|
3252
3601
|
function assets_kv_worker_default() {
|
|
3253
|
-
if (
|
|
3254
|
-
const filePath =
|
|
3255
|
-
|
|
3256
|
-
return
|
|
3602
|
+
if (contents6 !== void 0) return contents6;
|
|
3603
|
+
const filePath = import_path10.default.join(__dirname, "workers", "assets/assets-kv.worker.js");
|
|
3604
|
+
contents6 = import_fs7.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url8.default.pathToFileURL(filePath);
|
|
3605
|
+
return contents6;
|
|
3257
3606
|
}
|
|
3258
3607
|
|
|
3259
3608
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/router.worker.ts
|
|
3260
|
-
var
|
|
3261
|
-
var
|
|
3262
|
-
var
|
|
3263
|
-
var
|
|
3609
|
+
var import_fs8 = __toESM(require("fs"));
|
|
3610
|
+
var import_path11 = __toESM(require("path"));
|
|
3611
|
+
var import_url9 = __toESM(require("url"));
|
|
3612
|
+
var contents7;
|
|
3264
3613
|
function router_worker_default() {
|
|
3265
|
-
if (
|
|
3266
|
-
const filePath =
|
|
3267
|
-
|
|
3268
|
-
return
|
|
3614
|
+
if (contents7 !== void 0) return contents7;
|
|
3615
|
+
const filePath = import_path11.default.join(__dirname, "workers", "assets/router.worker.js");
|
|
3616
|
+
contents7 = import_fs8.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url9.default.pathToFileURL(filePath);
|
|
3617
|
+
return contents7;
|
|
3269
3618
|
}
|
|
3270
3619
|
|
|
3271
3620
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/assets/rpc-proxy.worker.ts
|
|
3272
|
-
var
|
|
3273
|
-
var
|
|
3274
|
-
var
|
|
3275
|
-
var
|
|
3621
|
+
var import_fs9 = __toESM(require("fs"));
|
|
3622
|
+
var import_path12 = __toESM(require("path"));
|
|
3623
|
+
var import_url10 = __toESM(require("url"));
|
|
3624
|
+
var contents8;
|
|
3276
3625
|
function rpc_proxy_worker_default() {
|
|
3277
|
-
if (
|
|
3278
|
-
const filePath =
|
|
3279
|
-
|
|
3280
|
-
return
|
|
3626
|
+
if (contents8 !== void 0) return contents8;
|
|
3627
|
+
const filePath = import_path12.default.join(__dirname, "workers", "assets/rpc-proxy.worker.js");
|
|
3628
|
+
contents8 = import_fs9.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url10.default.pathToFileURL(filePath);
|
|
3629
|
+
return contents8;
|
|
3281
3630
|
}
|
|
3282
3631
|
|
|
3283
3632
|
// src/plugins/core/index.ts
|
|
3284
3633
|
var import_assert9 = __toESM(require("assert"));
|
|
3285
|
-
var
|
|
3634
|
+
var import_fs16 = require("fs");
|
|
3286
3635
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
3287
|
-
var
|
|
3636
|
+
var import_path19 = __toESM(require("path"));
|
|
3288
3637
|
var import_stream2 = require("stream");
|
|
3289
3638
|
var import_tls = __toESM(require("tls"));
|
|
3290
3639
|
var import_util3 = require("util");
|
|
3291
3640
|
var import_undici7 = require("undici");
|
|
3292
3641
|
|
|
3293
3642
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/core/entry.worker.ts
|
|
3294
|
-
var
|
|
3295
|
-
var
|
|
3296
|
-
var
|
|
3297
|
-
var
|
|
3643
|
+
var import_fs10 = __toESM(require("fs"));
|
|
3644
|
+
var import_path13 = __toESM(require("path"));
|
|
3645
|
+
var import_url11 = __toESM(require("url"));
|
|
3646
|
+
var contents9;
|
|
3298
3647
|
function entry_worker_default() {
|
|
3299
|
-
if (
|
|
3300
|
-
const filePath =
|
|
3301
|
-
|
|
3302
|
-
return
|
|
3648
|
+
if (contents9 !== void 0) return contents9;
|
|
3649
|
+
const filePath = import_path13.default.join(__dirname, "workers", "core/entry.worker.js");
|
|
3650
|
+
contents9 = import_fs10.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url11.default.pathToFileURL(filePath);
|
|
3651
|
+
return contents9;
|
|
3303
3652
|
}
|
|
3304
3653
|
|
|
3305
3654
|
// src/plugins/core/index.ts
|
|
3306
|
-
var
|
|
3655
|
+
var import_zod13 = require("zod");
|
|
3307
3656
|
|
|
3308
3657
|
// src/runtime/index.ts
|
|
3309
3658
|
var import_assert4 = __toESM(require("assert"));
|
|
@@ -3312,7 +3661,7 @@ var import_events2 = require("events");
|
|
|
3312
3661
|
var import_readline = __toESM(require("readline"));
|
|
3313
3662
|
var import_stream = require("stream");
|
|
3314
3663
|
var import_workerd2 = __toESM(require("workerd"));
|
|
3315
|
-
var
|
|
3664
|
+
var import_zod7 = require("zod");
|
|
3316
3665
|
|
|
3317
3666
|
// ../../node_modules/.pnpm/capnp-es@0.0.7_typescript@5.7.3/node_modules/capnp-es/dist/shared/capnp-es.DAoyiaGr.mjs
|
|
3318
3667
|
var ListElementSize = /* @__PURE__ */ ((ListElementSize2) => {
|
|
@@ -9867,15 +10216,15 @@ function serializeConfig(config) {
|
|
|
9867
10216
|
}
|
|
9868
10217
|
|
|
9869
10218
|
// src/runtime/index.ts
|
|
9870
|
-
var ControlMessageSchema =
|
|
9871
|
-
|
|
9872
|
-
event:
|
|
9873
|
-
socket:
|
|
9874
|
-
port:
|
|
10219
|
+
var ControlMessageSchema = import_zod7.z.discriminatedUnion("event", [
|
|
10220
|
+
import_zod7.z.object({
|
|
10221
|
+
event: import_zod7.z.literal("listen"),
|
|
10222
|
+
socket: import_zod7.z.string(),
|
|
10223
|
+
port: import_zod7.z.number()
|
|
9875
10224
|
}),
|
|
9876
|
-
|
|
9877
|
-
event:
|
|
9878
|
-
port:
|
|
10225
|
+
import_zod7.z.object({
|
|
10226
|
+
event: import_zod7.z.literal("listen-inspector"),
|
|
10227
|
+
port: import_zod7.z.number()
|
|
9879
10228
|
})
|
|
9880
10229
|
]);
|
|
9881
10230
|
var kInspectorSocket = Symbol("kInspectorSocket");
|
|
@@ -9977,300 +10326,65 @@ var ASSETS_KV_SERVICE_NAME = `${ASSETS_PLUGIN_NAME}:kv`;
|
|
|
9977
10326
|
var import_promises4 = __toESM(require("fs/promises"));
|
|
9978
10327
|
|
|
9979
10328
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache.worker.ts
|
|
9980
|
-
var
|
|
9981
|
-
var
|
|
9982
|
-
var
|
|
9983
|
-
var contents8;
|
|
9984
|
-
function cache_worker_default() {
|
|
9985
|
-
if (contents8 !== void 0) return contents8;
|
|
9986
|
-
const filePath = import_path11.default.join(__dirname, "workers", "cache/cache.worker.js");
|
|
9987
|
-
contents8 = import_fs8.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url8.default.pathToFileURL(filePath);
|
|
9988
|
-
return contents8;
|
|
9989
|
-
}
|
|
9990
|
-
|
|
9991
|
-
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry.worker.ts
|
|
9992
|
-
var import_fs9 = __toESM(require("fs"));
|
|
9993
|
-
var import_path12 = __toESM(require("path"));
|
|
9994
|
-
var import_url9 = __toESM(require("url"));
|
|
9995
|
-
var contents9;
|
|
9996
|
-
function cache_entry_worker_default() {
|
|
9997
|
-
if (contents9 !== void 0) return contents9;
|
|
9998
|
-
const filePath = import_path12.default.join(__dirname, "workers", "cache/cache-entry.worker.js");
|
|
9999
|
-
contents9 = import_fs9.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url9.default.pathToFileURL(filePath);
|
|
10000
|
-
return contents9;
|
|
10001
|
-
}
|
|
10002
|
-
|
|
10003
|
-
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry-noop.worker.ts
|
|
10004
|
-
var import_fs10 = __toESM(require("fs"));
|
|
10005
|
-
var import_path13 = __toESM(require("path"));
|
|
10006
|
-
var import_url10 = __toESM(require("url"));
|
|
10329
|
+
var import_fs11 = __toESM(require("fs"));
|
|
10330
|
+
var import_path14 = __toESM(require("path"));
|
|
10331
|
+
var import_url12 = __toESM(require("url"));
|
|
10007
10332
|
var contents10;
|
|
10008
|
-
function
|
|
10333
|
+
function cache_worker_default() {
|
|
10009
10334
|
if (contents10 !== void 0) return contents10;
|
|
10010
|
-
const filePath =
|
|
10011
|
-
contents10 =
|
|
10335
|
+
const filePath = import_path14.default.join(__dirname, "workers", "cache/cache.worker.js");
|
|
10336
|
+
contents10 = import_fs11.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url12.default.pathToFileURL(filePath);
|
|
10012
10337
|
return contents10;
|
|
10013
10338
|
}
|
|
10014
10339
|
|
|
10015
|
-
// src/
|
|
10016
|
-
var
|
|
10017
|
-
|
|
10018
|
-
// src/plugins/shared/index.ts
|
|
10019
|
-
var import_crypto = __toESM(require("crypto"));
|
|
10020
|
-
var import_fs12 = require("fs");
|
|
10021
|
-
var import_promises3 = __toESM(require("fs/promises"));
|
|
10340
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry.worker.ts
|
|
10341
|
+
var import_fs12 = __toESM(require("fs"));
|
|
10022
10342
|
var import_path15 = __toESM(require("path"));
|
|
10023
|
-
var import_url13 = require("url");
|
|
10024
|
-
var import_zod6 = require("zod");
|
|
10025
|
-
|
|
10026
|
-
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/shared/object-entry.worker.ts
|
|
10027
|
-
var import_fs11 = __toESM(require("fs"));
|
|
10028
|
-
var import_path14 = __toESM(require("path"));
|
|
10029
|
-
var import_url11 = __toESM(require("url"));
|
|
10343
|
+
var import_url13 = __toESM(require("url"));
|
|
10030
10344
|
var contents11;
|
|
10031
|
-
function
|
|
10345
|
+
function cache_entry_worker_default() {
|
|
10032
10346
|
if (contents11 !== void 0) return contents11;
|
|
10033
|
-
const filePath =
|
|
10034
|
-
contents11 =
|
|
10347
|
+
const filePath = import_path15.default.join(__dirname, "workers", "cache/cache-entry.worker.js");
|
|
10348
|
+
contents11 = import_fs12.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url13.default.pathToFileURL(filePath);
|
|
10035
10349
|
return contents11;
|
|
10036
10350
|
}
|
|
10037
10351
|
|
|
10038
|
-
// src/
|
|
10039
|
-
var
|
|
10040
|
-
var
|
|
10041
|
-
var
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
name: CoreBindings.SERVICE_LOOPBACK,
|
|
10049
|
-
service: { name: SERVICE_LOOPBACK }
|
|
10050
|
-
};
|
|
10051
|
-
var WORKER_BINDING_ENABLE_CONTROL_ENDPOINTS = {
|
|
10052
|
-
name: SharedBindings.MAYBE_JSON_ENABLE_CONTROL_ENDPOINTS,
|
|
10053
|
-
json: "true"
|
|
10054
|
-
};
|
|
10055
|
-
var WORKER_BINDING_ENABLE_STICKY_BLOBS = {
|
|
10056
|
-
name: SharedBindings.MAYBE_JSON_ENABLE_STICKY_BLOBS,
|
|
10057
|
-
json: "true"
|
|
10058
|
-
};
|
|
10059
|
-
var enableControlEndpoints = false;
|
|
10060
|
-
function getMiniflareObjectBindings(unsafeStickyBlobs) {
|
|
10061
|
-
const result = [];
|
|
10062
|
-
if (enableControlEndpoints) {
|
|
10063
|
-
result.push(WORKER_BINDING_ENABLE_CONTROL_ENDPOINTS);
|
|
10064
|
-
}
|
|
10065
|
-
if (unsafeStickyBlobs) {
|
|
10066
|
-
result.push(WORKER_BINDING_ENABLE_STICKY_BLOBS);
|
|
10067
|
-
}
|
|
10068
|
-
return result;
|
|
10069
|
-
}
|
|
10070
|
-
function _enableControlEndpoints() {
|
|
10071
|
-
enableControlEndpoints = true;
|
|
10072
|
-
}
|
|
10073
|
-
function objectEntryWorker(durableObjectNamespace, namespace) {
|
|
10074
|
-
return {
|
|
10075
|
-
compatibilityDate: "2023-07-24",
|
|
10076
|
-
modules: [
|
|
10077
|
-
{ name: "object-entry.worker.js", esModule: object_entry_worker_default() }
|
|
10078
|
-
],
|
|
10079
|
-
bindings: [
|
|
10080
|
-
{ name: SharedBindings.TEXT_NAMESPACE, text: namespace },
|
|
10081
|
-
{
|
|
10082
|
-
name: SharedBindings.DURABLE_OBJECT_NAMESPACE_OBJECT,
|
|
10083
|
-
durableObjectNamespace
|
|
10084
|
-
}
|
|
10085
|
-
]
|
|
10086
|
-
};
|
|
10087
|
-
}
|
|
10088
|
-
var kUnsafeEphemeralUniqueKey = Symbol.for(
|
|
10089
|
-
"miniflare.kUnsafeEphemeralUniqueKey"
|
|
10090
|
-
);
|
|
10091
|
-
|
|
10092
|
-
// src/plugins/shared/routing.ts
|
|
10093
|
-
var import_url12 = require("url");
|
|
10094
|
-
var RouterError = class extends MiniflareError {
|
|
10095
|
-
};
|
|
10096
|
-
function routeSpecificity(url20) {
|
|
10097
|
-
const hostParts = url20.host.split(".");
|
|
10098
|
-
let hostScore = hostParts.length;
|
|
10099
|
-
if (hostParts[0] === "*") hostScore -= 2;
|
|
10100
|
-
const pathParts = url20.pathname.split("/");
|
|
10101
|
-
let pathScore = pathParts.length;
|
|
10102
|
-
if (pathParts[pathParts.length - 1] === "*") pathScore -= 2;
|
|
10103
|
-
return hostScore * 26 + pathScore;
|
|
10104
|
-
}
|
|
10105
|
-
function parseRoutes(allRoutes) {
|
|
10106
|
-
const routes = [];
|
|
10107
|
-
for (const [target, targetRoutes] of allRoutes) {
|
|
10108
|
-
for (const route of targetRoutes) {
|
|
10109
|
-
const hasProtocol = /^[a-z0-9+\-.]+:\/\//i.test(route);
|
|
10110
|
-
let urlInput = route;
|
|
10111
|
-
if (!hasProtocol) urlInput = `https://${urlInput}`;
|
|
10112
|
-
const url20 = new import_url12.URL(urlInput);
|
|
10113
|
-
const specificity = routeSpecificity(url20);
|
|
10114
|
-
const protocol = hasProtocol ? url20.protocol : void 0;
|
|
10115
|
-
const internationalisedAllowHostnamePrefix = url20.hostname.startsWith("xn--*");
|
|
10116
|
-
const allowHostnamePrefix = url20.hostname.startsWith("*") || internationalisedAllowHostnamePrefix;
|
|
10117
|
-
const anyHostname = url20.hostname === "*";
|
|
10118
|
-
if (allowHostnamePrefix && !anyHostname) {
|
|
10119
|
-
let hostname = url20.hostname;
|
|
10120
|
-
if (internationalisedAllowHostnamePrefix) {
|
|
10121
|
-
hostname = (0, import_url12.domainToUnicode)(hostname);
|
|
10122
|
-
}
|
|
10123
|
-
url20.hostname = hostname.substring(1);
|
|
10124
|
-
}
|
|
10125
|
-
const allowPathSuffix = url20.pathname.endsWith("*");
|
|
10126
|
-
if (allowPathSuffix) {
|
|
10127
|
-
url20.pathname = url20.pathname.substring(0, url20.pathname.length - 1);
|
|
10128
|
-
}
|
|
10129
|
-
if (url20.search) {
|
|
10130
|
-
throw new RouterError(
|
|
10131
|
-
"ERR_QUERY_STRING",
|
|
10132
|
-
`Route "${route}" for "${target}" contains a query string. This is not allowed.`
|
|
10133
|
-
);
|
|
10134
|
-
}
|
|
10135
|
-
if (url20.toString().includes("*") && !anyHostname) {
|
|
10136
|
-
throw new RouterError(
|
|
10137
|
-
"ERR_INFIX_WILDCARD",
|
|
10138
|
-
`Route "${route}" for "${target}" contains an infix wildcard. This is not allowed.`
|
|
10139
|
-
);
|
|
10140
|
-
}
|
|
10141
|
-
routes.push({
|
|
10142
|
-
target,
|
|
10143
|
-
route,
|
|
10144
|
-
specificity,
|
|
10145
|
-
protocol,
|
|
10146
|
-
allowHostnamePrefix,
|
|
10147
|
-
hostname: anyHostname ? "" : url20.hostname,
|
|
10148
|
-
path: url20.pathname,
|
|
10149
|
-
allowPathSuffix
|
|
10150
|
-
});
|
|
10151
|
-
}
|
|
10152
|
-
}
|
|
10153
|
-
routes.sort((a, b) => {
|
|
10154
|
-
if (a.specificity === b.specificity) {
|
|
10155
|
-
return b.route.length - a.route.length;
|
|
10156
|
-
} else {
|
|
10157
|
-
return b.specificity - a.specificity;
|
|
10158
|
-
}
|
|
10159
|
-
});
|
|
10160
|
-
return routes;
|
|
10352
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/cache/cache-entry-noop.worker.ts
|
|
10353
|
+
var import_fs13 = __toESM(require("fs"));
|
|
10354
|
+
var import_path16 = __toESM(require("path"));
|
|
10355
|
+
var import_url14 = __toESM(require("url"));
|
|
10356
|
+
var contents12;
|
|
10357
|
+
function cache_entry_noop_worker_default() {
|
|
10358
|
+
if (contents12 !== void 0) return contents12;
|
|
10359
|
+
const filePath = import_path16.default.join(__dirname, "workers", "cache/cache-entry-noop.worker.js");
|
|
10360
|
+
contents12 = import_fs13.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url14.default.pathToFileURL(filePath);
|
|
10361
|
+
return contents12;
|
|
10161
10362
|
}
|
|
10162
10363
|
|
|
10163
|
-
// src/plugins/
|
|
10164
|
-
var
|
|
10165
|
-
var
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10364
|
+
// src/plugins/cache/index.ts
|
|
10365
|
+
var import_zod8 = require("zod");
|
|
10366
|
+
var CacheOptionsSchema = import_zod8.z.object({
|
|
10367
|
+
cache: import_zod8.z.boolean().optional(),
|
|
10368
|
+
cacheWarnUsage: import_zod8.z.boolean().optional()
|
|
10369
|
+
});
|
|
10370
|
+
var CacheSharedOptionsSchema = import_zod8.z.object({
|
|
10371
|
+
cachePersist: PersistenceSchema
|
|
10372
|
+
});
|
|
10373
|
+
var CACHE_PLUGIN_NAME = "cache";
|
|
10374
|
+
var CACHE_STORAGE_SERVICE_NAME = `${CACHE_PLUGIN_NAME}:storage`;
|
|
10375
|
+
var CACHE_SERVICE_PREFIX = `${CACHE_PLUGIN_NAME}:cache`;
|
|
10376
|
+
var CACHE_OBJECT_CLASS_NAME = "CacheObject";
|
|
10377
|
+
var CACHE_OBJECT = {
|
|
10378
|
+
serviceName: CACHE_SERVICE_PREFIX,
|
|
10379
|
+
className: CACHE_OBJECT_CLASS_NAME
|
|
10170
10380
|
};
|
|
10171
|
-
function
|
|
10172
|
-
|
|
10173
|
-
return namespaces;
|
|
10174
|
-
} else if (namespaces !== void 0) {
|
|
10175
|
-
return Object.keys(namespaces);
|
|
10176
|
-
} else {
|
|
10177
|
-
return [];
|
|
10178
|
-
}
|
|
10381
|
+
function getCacheServiceName(workerIndex) {
|
|
10382
|
+
return `${CACHE_PLUGIN_NAME}:${workerIndex}`;
|
|
10179
10383
|
}
|
|
10180
|
-
|
|
10181
|
-
|
|
10182
|
-
|
|
10183
|
-
|
|
10184
|
-
return Object.entries(namespaces);
|
|
10185
|
-
} else {
|
|
10186
|
-
return [];
|
|
10187
|
-
}
|
|
10188
|
-
}
|
|
10189
|
-
function maybeParseURL(url20) {
|
|
10190
|
-
if (typeof url20 !== "string" || import_path15.default.isAbsolute(url20)) return;
|
|
10191
|
-
try {
|
|
10192
|
-
return new URL(url20);
|
|
10193
|
-
} catch {
|
|
10194
|
-
}
|
|
10195
|
-
}
|
|
10196
|
-
function getPersistPath(pluginName, tmpPath, persist) {
|
|
10197
|
-
const memoryishPath = import_path15.default.join(tmpPath, pluginName);
|
|
10198
|
-
if (persist === void 0 || persist === false) {
|
|
10199
|
-
return memoryishPath;
|
|
10200
|
-
}
|
|
10201
|
-
const url20 = maybeParseURL(persist);
|
|
10202
|
-
if (url20 !== void 0) {
|
|
10203
|
-
if (url20.protocol === "memory:") {
|
|
10204
|
-
return memoryishPath;
|
|
10205
|
-
} else if (url20.protocol === "file:") {
|
|
10206
|
-
return (0, import_url13.fileURLToPath)(url20);
|
|
10207
|
-
}
|
|
10208
|
-
throw new MiniflareCoreError(
|
|
10209
|
-
"ERR_PERSIST_UNSUPPORTED",
|
|
10210
|
-
`Unsupported "${url20.protocol}" persistence protocol for storage: ${url20.href}`
|
|
10211
|
-
);
|
|
10212
|
-
}
|
|
10213
|
-
return persist === true ? import_path15.default.join(DEFAULT_PERSIST_ROOT, pluginName) : persist;
|
|
10214
|
-
}
|
|
10215
|
-
function durableObjectNamespaceIdFromName(uniqueKey, name) {
|
|
10216
|
-
const key = import_crypto.default.createHash("sha256").update(uniqueKey).digest();
|
|
10217
|
-
const nameHmac = import_crypto.default.createHmac("sha256", key).update(name).digest().subarray(0, 16);
|
|
10218
|
-
const hmac = import_crypto.default.createHmac("sha256", key).update(nameHmac).digest().subarray(0, 16);
|
|
10219
|
-
return Buffer.concat([nameHmac, hmac]).toString("hex");
|
|
10220
|
-
}
|
|
10221
|
-
async function migrateDatabase(log, uniqueKey, persistPath, namespace) {
|
|
10222
|
-
const sanitisedNamespace = sanitisePath(namespace);
|
|
10223
|
-
const previousDir = import_path15.default.join(persistPath, sanitisedNamespace);
|
|
10224
|
-
const previousPath = import_path15.default.join(previousDir, "db.sqlite");
|
|
10225
|
-
const previousWalPath = import_path15.default.join(previousDir, "db.sqlite-wal");
|
|
10226
|
-
if (!(0, import_fs12.existsSync)(previousPath)) return;
|
|
10227
|
-
const id = durableObjectNamespaceIdFromName(uniqueKey, namespace);
|
|
10228
|
-
const newDir = import_path15.default.join(persistPath, uniqueKey);
|
|
10229
|
-
const newPath = import_path15.default.join(newDir, `${id}.sqlite`);
|
|
10230
|
-
const newWalPath = import_path15.default.join(newDir, `${id}.sqlite-wal`);
|
|
10231
|
-
if ((0, import_fs12.existsSync)(newPath)) {
|
|
10232
|
-
log.debug(
|
|
10233
|
-
`Not migrating ${previousPath} to ${newPath} as it already exists`
|
|
10234
|
-
);
|
|
10235
|
-
return;
|
|
10236
|
-
}
|
|
10237
|
-
log.debug(`Migrating ${previousPath} to ${newPath}...`);
|
|
10238
|
-
await import_promises3.default.mkdir(newDir, { recursive: true });
|
|
10239
|
-
try {
|
|
10240
|
-
await import_promises3.default.copyFile(previousPath, newPath);
|
|
10241
|
-
if ((0, import_fs12.existsSync)(previousWalPath)) {
|
|
10242
|
-
await import_promises3.default.copyFile(previousWalPath, newWalPath);
|
|
10243
|
-
}
|
|
10244
|
-
await import_promises3.default.unlink(previousPath);
|
|
10245
|
-
await import_promises3.default.unlink(previousWalPath);
|
|
10246
|
-
} catch (e) {
|
|
10247
|
-
log.warn(`Error migrating ${previousPath} to ${newPath}: ${e}`);
|
|
10248
|
-
}
|
|
10249
|
-
}
|
|
10250
|
-
|
|
10251
|
-
// src/plugins/cache/index.ts
|
|
10252
|
-
var CacheOptionsSchema = import_zod7.z.object({
|
|
10253
|
-
cache: import_zod7.z.boolean().optional(),
|
|
10254
|
-
cacheWarnUsage: import_zod7.z.boolean().optional()
|
|
10255
|
-
});
|
|
10256
|
-
var CacheSharedOptionsSchema = import_zod7.z.object({
|
|
10257
|
-
cachePersist: PersistenceSchema
|
|
10258
|
-
});
|
|
10259
|
-
var CACHE_PLUGIN_NAME = "cache";
|
|
10260
|
-
var CACHE_STORAGE_SERVICE_NAME = `${CACHE_PLUGIN_NAME}:storage`;
|
|
10261
|
-
var CACHE_SERVICE_PREFIX = `${CACHE_PLUGIN_NAME}:cache`;
|
|
10262
|
-
var CACHE_OBJECT_CLASS_NAME = "CacheObject";
|
|
10263
|
-
var CACHE_OBJECT = {
|
|
10264
|
-
serviceName: CACHE_SERVICE_PREFIX,
|
|
10265
|
-
className: CACHE_OBJECT_CLASS_NAME
|
|
10266
|
-
};
|
|
10267
|
-
function getCacheServiceName(workerIndex) {
|
|
10268
|
-
return `${CACHE_PLUGIN_NAME}:${workerIndex}`;
|
|
10269
|
-
}
|
|
10270
|
-
var CACHE_PLUGIN = {
|
|
10271
|
-
options: CacheOptionsSchema,
|
|
10272
|
-
sharedOptions: CacheSharedOptionsSchema,
|
|
10273
|
-
getBindings() {
|
|
10384
|
+
var CACHE_PLUGIN = {
|
|
10385
|
+
options: CacheOptionsSchema,
|
|
10386
|
+
sharedOptions: CacheSharedOptionsSchema,
|
|
10387
|
+
getBindings() {
|
|
10274
10388
|
return [];
|
|
10275
10389
|
},
|
|
10276
10390
|
getNodeBindings() {
|
|
@@ -10372,27 +10486,27 @@ var CACHE_PLUGIN = {
|
|
|
10372
10486
|
|
|
10373
10487
|
// src/plugins/do/index.ts
|
|
10374
10488
|
var import_promises5 = __toESM(require("fs/promises"));
|
|
10375
|
-
var
|
|
10376
|
-
var DurableObjectsOptionsSchema =
|
|
10377
|
-
durableObjects:
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
className:
|
|
10382
|
-
scriptName:
|
|
10383
|
-
useSQLite:
|
|
10489
|
+
var import_zod9 = require("zod");
|
|
10490
|
+
var DurableObjectsOptionsSchema = import_zod9.z.object({
|
|
10491
|
+
durableObjects: import_zod9.z.record(
|
|
10492
|
+
import_zod9.z.union([
|
|
10493
|
+
import_zod9.z.string(),
|
|
10494
|
+
import_zod9.z.object({
|
|
10495
|
+
className: import_zod9.z.string(),
|
|
10496
|
+
scriptName: import_zod9.z.string().optional(),
|
|
10497
|
+
useSQLite: import_zod9.z.boolean().optional(),
|
|
10384
10498
|
// Allow `uniqueKey` to be customised. We use in Wrangler when setting
|
|
10385
10499
|
// up stub Durable Objects that proxy requests to Durable Objects in
|
|
10386
10500
|
// another `workerd` process, to ensure the IDs created by the stub
|
|
10387
10501
|
// object can be used by the real object too.
|
|
10388
|
-
unsafeUniqueKey:
|
|
10502
|
+
unsafeUniqueKey: import_zod9.z.union([import_zod9.z.string(), import_zod9.z.literal(kUnsafeEphemeralUniqueKey)]).optional(),
|
|
10389
10503
|
// Prevents the Durable Object being evicted.
|
|
10390
|
-
unsafePreventEviction:
|
|
10504
|
+
unsafePreventEviction: import_zod9.z.boolean().optional()
|
|
10391
10505
|
})
|
|
10392
10506
|
])
|
|
10393
10507
|
).optional()
|
|
10394
10508
|
});
|
|
10395
|
-
var DurableObjectsSharedOptionsSchema =
|
|
10509
|
+
var DurableObjectsSharedOptionsSchema = import_zod9.z.object({
|
|
10396
10510
|
durableObjectsPersist: PersistenceSchema
|
|
10397
10511
|
});
|
|
10398
10512
|
function normaliseDurableObject(designator) {
|
|
@@ -10491,14 +10605,14 @@ function getCustomServiceName(workerIndex, kind, bindingName) {
|
|
|
10491
10605
|
|
|
10492
10606
|
// src/plugins/core/modules.ts
|
|
10493
10607
|
var import_assert5 = __toESM(require("assert"));
|
|
10494
|
-
var
|
|
10608
|
+
var import_fs14 = require("fs");
|
|
10495
10609
|
var import_module = require("module");
|
|
10496
|
-
var
|
|
10497
|
-
var
|
|
10610
|
+
var import_path17 = __toESM(require("path"));
|
|
10611
|
+
var import_url15 = require("url");
|
|
10498
10612
|
var import_util = require("util");
|
|
10499
10613
|
var import_acorn = require("acorn");
|
|
10500
10614
|
var import_acorn_walk = require("acorn-walk");
|
|
10501
|
-
var
|
|
10615
|
+
var import_zod10 = require("zod");
|
|
10502
10616
|
|
|
10503
10617
|
// src/plugins/core/node-compat.ts
|
|
10504
10618
|
function getNodeCompat(compatibilityDate = "2000-01-01", compatibilityFlags) {
|
|
@@ -10541,7 +10655,7 @@ function parseNodeCompatibilityFlags(compatibilityFlags) {
|
|
|
10541
10655
|
|
|
10542
10656
|
// src/plugins/core/modules.ts
|
|
10543
10657
|
var SUGGEST_BUNDLE = "If you're trying to import an npm package, you'll need to bundle your Worker first.";
|
|
10544
|
-
var SUGGEST_NODE = "If you're trying to import a Node.js built-in module, or an npm package that uses Node.js built-ins, you'll either need to:\n- Bundle your Worker, configuring your bundler to polyfill Node.js built-ins\n- Configure your bundler to load Workers-compatible builds by changing the main fields/conditions\n- Enable the `nodejs_compat` compatibility flag
|
|
10658
|
+
var SUGGEST_NODE = "If you're trying to import a Node.js built-in module, or an npm package that uses Node.js built-ins, you'll either need to:\n- Bundle your Worker, configuring your bundler to polyfill Node.js built-ins\n- Configure your bundler to load Workers-compatible builds by changing the main fields/conditions\n- Enable the `nodejs_compat` compatibility flag\n- Find an alternative package that doesn't require Node.js built-ins";
|
|
10545
10659
|
var builtinModulesWithPrefix = import_module.builtinModules.concat(
|
|
10546
10660
|
import_module.builtinModules.map((module2) => `node:${module2}`)
|
|
10547
10661
|
);
|
|
@@ -10553,55 +10667,54 @@ function maybeGetStringScriptPathIndex(scriptPath) {
|
|
|
10553
10667
|
const match = stringScriptRegexp.exec(scriptPath);
|
|
10554
10668
|
return match === null ? void 0 : parseInt(match[1]);
|
|
10555
10669
|
}
|
|
10556
|
-
var ModuleRuleTypeSchema =
|
|
10670
|
+
var ModuleRuleTypeSchema = import_zod10.z.enum([
|
|
10557
10671
|
"ESModule",
|
|
10558
10672
|
"CommonJS",
|
|
10559
|
-
"NodeJsCompatModule",
|
|
10560
10673
|
"Text",
|
|
10561
10674
|
"Data",
|
|
10562
10675
|
"CompiledWasm",
|
|
10563
10676
|
"PythonModule",
|
|
10564
10677
|
"PythonRequirement"
|
|
10565
10678
|
]);
|
|
10566
|
-
var ModuleRuleSchema =
|
|
10679
|
+
var ModuleRuleSchema = import_zod10.z.object({
|
|
10567
10680
|
type: ModuleRuleTypeSchema,
|
|
10568
|
-
include:
|
|
10569
|
-
fallthrough:
|
|
10681
|
+
include: import_zod10.z.string().array(),
|
|
10682
|
+
fallthrough: import_zod10.z.boolean().optional()
|
|
10570
10683
|
});
|
|
10571
|
-
var ModuleDefinitionSchema =
|
|
10684
|
+
var ModuleDefinitionSchema = import_zod10.z.object({
|
|
10572
10685
|
type: ModuleRuleTypeSchema,
|
|
10573
10686
|
path: PathSchema,
|
|
10574
|
-
contents:
|
|
10687
|
+
contents: import_zod10.z.string().or(import_zod10.z.instanceof(Uint8Array)).optional()
|
|
10575
10688
|
});
|
|
10576
|
-
var SourceOptionsSchema =
|
|
10577
|
-
|
|
10689
|
+
var SourceOptionsSchema = import_zod10.z.union([
|
|
10690
|
+
import_zod10.z.object({
|
|
10578
10691
|
// Manually defined modules
|
|
10579
10692
|
// (used by Wrangler which has its own module collection code)
|
|
10580
|
-
modules:
|
|
10693
|
+
modules: import_zod10.z.array(ModuleDefinitionSchema),
|
|
10581
10694
|
// `modules` "name"s will be their paths relative to this value.
|
|
10582
10695
|
// This ensures file paths in stack traces are correct.
|
|
10583
10696
|
modulesRoot: PathSchema.optional()
|
|
10584
10697
|
}),
|
|
10585
|
-
|
|
10586
|
-
script:
|
|
10698
|
+
import_zod10.z.object({
|
|
10699
|
+
script: import_zod10.z.string(),
|
|
10587
10700
|
// Optional script path for resolving modules, and stack traces file names
|
|
10588
10701
|
scriptPath: PathSchema.optional(),
|
|
10589
10702
|
// Automatically collect modules by parsing `script` if `true`, or treat as
|
|
10590
10703
|
// service-worker if `false`
|
|
10591
|
-
modules:
|
|
10704
|
+
modules: import_zod10.z.boolean().optional(),
|
|
10592
10705
|
// How to interpret automatically collected modules
|
|
10593
|
-
modulesRules:
|
|
10706
|
+
modulesRules: import_zod10.z.array(ModuleRuleSchema).optional(),
|
|
10594
10707
|
// `modules` "name"s will be their paths relative to this value.
|
|
10595
10708
|
// This ensures file paths in stack traces are correct.
|
|
10596
10709
|
modulesRoot: PathSchema.optional()
|
|
10597
10710
|
}),
|
|
10598
|
-
|
|
10711
|
+
import_zod10.z.object({
|
|
10599
10712
|
scriptPath: PathSchema,
|
|
10600
10713
|
// Automatically collect modules by parsing `scriptPath` if `true`, or treat
|
|
10601
10714
|
// as service-worker if `false`
|
|
10602
|
-
modules:
|
|
10715
|
+
modules: import_zod10.z.boolean().optional(),
|
|
10603
10716
|
// How to interpret automatically collected modules
|
|
10604
|
-
modulesRules:
|
|
10717
|
+
modulesRules: import_zod10.z.array(ModuleRuleSchema).optional(),
|
|
10605
10718
|
// `modules` "name"s will be their paths relative to this value.
|
|
10606
10719
|
// This ensures file paths in stack traces are correct.
|
|
10607
10720
|
modulesRoot: PathSchema.optional()
|
|
@@ -10625,14 +10738,14 @@ function compileModuleRules(rules) {
|
|
|
10625
10738
|
return compiledRules;
|
|
10626
10739
|
}
|
|
10627
10740
|
function moduleName(modulesRoot, modulePath) {
|
|
10628
|
-
const name =
|
|
10629
|
-
return
|
|
10741
|
+
const name = import_path17.default.relative(modulesRoot, modulePath);
|
|
10742
|
+
return import_path17.default.sep === "\\" ? name.replaceAll("\\", "/") : name;
|
|
10630
10743
|
}
|
|
10631
10744
|
function withSourceURL(script, scriptPath) {
|
|
10632
10745
|
if (script.lastIndexOf("//# sourceURL=") !== -1) return script;
|
|
10633
10746
|
let scriptURL = scriptPath;
|
|
10634
10747
|
if (maybeGetStringScriptPathIndex(scriptPath) === void 0) {
|
|
10635
|
-
scriptURL = (0,
|
|
10748
|
+
scriptURL = (0, import_url15.pathToFileURL)(scriptPath);
|
|
10636
10749
|
}
|
|
10637
10750
|
const sourceURL = `
|
|
10638
10751
|
//# sourceURL=${scriptURL}
|
|
@@ -10640,7 +10753,7 @@ function withSourceURL(script, scriptPath) {
|
|
|
10640
10753
|
return script + sourceURL;
|
|
10641
10754
|
}
|
|
10642
10755
|
function getResolveErrorPrefix(referencingPath) {
|
|
10643
|
-
const relative2 =
|
|
10756
|
+
const relative2 = import_path17.default.relative("", referencingPath);
|
|
10644
10757
|
return `Unable to resolve "${relative2}" dependency`;
|
|
10645
10758
|
}
|
|
10646
10759
|
var ModuleLocator = class {
|
|
@@ -10736,12 +10849,11 @@ ${dim(modulesConfig)}`;
|
|
|
10736
10849
|
throw new MiniflareCoreError("ERR_MODULE_DYNAMIC_SPEC", message);
|
|
10737
10850
|
}
|
|
10738
10851
|
const spec = specExpression.value;
|
|
10739
|
-
const isNodeJsCompatModule = referencingType === "NodeJsCompatModule";
|
|
10740
10852
|
if (
|
|
10741
10853
|
// `cloudflare:` and `workerd:` imports don't need to be included explicitly
|
|
10742
10854
|
spec.startsWith("cloudflare:") || spec.startsWith("workerd:") || // Node.js compat v1 requires imports to be prefixed with `node:`
|
|
10743
10855
|
this.#nodejsCompatMode === "v1" && spec.startsWith("node:") || // Node.js compat modules and v2 can also handle non-prefixed imports
|
|
10744
|
-
|
|
10856
|
+
this.#nodejsCompatMode === "v2" && builtinModulesWithPrefix.includes(spec) || // Async Local Storage mode (node_als) only deals with `node:async_hooks` imports
|
|
10745
10857
|
this.#nodejsCompatMode === "als" && spec === "node:async_hooks" || // Any "additional" external modules can be ignored
|
|
10746
10858
|
this.additionalModuleNames.includes(spec)
|
|
10747
10859
|
) {
|
|
@@ -10754,7 +10866,7 @@ ${dim(modulesConfig)}`;
|
|
|
10754
10866
|
`${prefix}: imports are unsupported in string \`script\` without defined \`scriptPath\``
|
|
10755
10867
|
);
|
|
10756
10868
|
}
|
|
10757
|
-
const identifier =
|
|
10869
|
+
const identifier = import_path17.default.resolve(import_path17.default.dirname(referencingPath), spec);
|
|
10758
10870
|
const name = moduleName(this.modulesRoot, identifier);
|
|
10759
10871
|
if (this.#visitedPaths.has(identifier)) return;
|
|
10760
10872
|
this.#visitedPaths.add(identifier);
|
|
@@ -10771,11 +10883,10 @@ ${dim(modulesConfig)}`;
|
|
|
10771
10883
|
${suggestion}`
|
|
10772
10884
|
);
|
|
10773
10885
|
}
|
|
10774
|
-
const data = (0,
|
|
10886
|
+
const data = (0, import_fs14.readFileSync)(identifier);
|
|
10775
10887
|
switch (rule.type) {
|
|
10776
10888
|
case "ESModule":
|
|
10777
10889
|
case "CommonJS":
|
|
10778
|
-
case "NodeJsCompatModule":
|
|
10779
10890
|
const code = data.toString("utf8");
|
|
10780
10891
|
this.#visitJavaScriptModule(code, identifier, rule.type);
|
|
10781
10892
|
break;
|
|
@@ -10806,61 +10917,56 @@ function createJavaScriptModule(code, name, modulePath, type) {
|
|
|
10806
10917
|
return { name, esModule: code };
|
|
10807
10918
|
} else if (type === "CommonJS") {
|
|
10808
10919
|
return { name, commonJsModule: code };
|
|
10809
|
-
} else if (type === "NodeJsCompatModule") {
|
|
10810
|
-
return { name, nodeJsCompatModule: code };
|
|
10811
10920
|
}
|
|
10812
10921
|
const exhaustive = type;
|
|
10813
10922
|
import_assert5.default.fail(`Unreachable: ${exhaustive} JavaScript modules are unsupported`);
|
|
10814
10923
|
}
|
|
10815
10924
|
var encoder = new import_util.TextEncoder();
|
|
10816
10925
|
var decoder = new import_util.TextDecoder();
|
|
10817
|
-
function contentsToString(
|
|
10818
|
-
return typeof
|
|
10926
|
+
function contentsToString(contents24) {
|
|
10927
|
+
return typeof contents24 === "string" ? contents24 : decoder.decode(contents24);
|
|
10819
10928
|
}
|
|
10820
|
-
function contentsToArray(
|
|
10821
|
-
return typeof
|
|
10929
|
+
function contentsToArray(contents24) {
|
|
10930
|
+
return typeof contents24 === "string" ? encoder.encode(contents24) : contents24;
|
|
10822
10931
|
}
|
|
10823
10932
|
function convertModuleDefinition(modulesRoot, def) {
|
|
10824
10933
|
const name = moduleName(modulesRoot, def.path);
|
|
10825
|
-
const
|
|
10934
|
+
const contents24 = def.contents ?? (0, import_fs14.readFileSync)(def.path);
|
|
10826
10935
|
switch (def.type) {
|
|
10827
10936
|
case "ESModule":
|
|
10828
10937
|
case "CommonJS":
|
|
10829
|
-
case "NodeJsCompatModule":
|
|
10830
10938
|
return createJavaScriptModule(
|
|
10831
|
-
contentsToString(
|
|
10939
|
+
contentsToString(contents24),
|
|
10832
10940
|
name,
|
|
10833
|
-
|
|
10941
|
+
import_path17.default.resolve(modulesRoot, def.path),
|
|
10834
10942
|
def.type
|
|
10835
10943
|
);
|
|
10836
10944
|
case "Text":
|
|
10837
|
-
return { name, text: contentsToString(
|
|
10945
|
+
return { name, text: contentsToString(contents24) };
|
|
10838
10946
|
case "Data":
|
|
10839
|
-
return { name, data: contentsToArray(
|
|
10947
|
+
return { name, data: contentsToArray(contents24) };
|
|
10840
10948
|
case "CompiledWasm":
|
|
10841
|
-
return { name, wasm: contentsToArray(
|
|
10949
|
+
return { name, wasm: contentsToArray(contents24) };
|
|
10842
10950
|
case "PythonModule":
|
|
10843
|
-
return { name, pythonModule: contentsToString(
|
|
10951
|
+
return { name, pythonModule: contentsToString(contents24) };
|
|
10844
10952
|
case "PythonRequirement":
|
|
10845
|
-
return { name, pythonRequirement: contentsToString(
|
|
10953
|
+
return { name, pythonRequirement: contentsToString(contents24) };
|
|
10846
10954
|
default:
|
|
10847
10955
|
const exhaustive = def.type;
|
|
10848
10956
|
import_assert5.default.fail(`Unreachable: ${exhaustive} modules are unsupported`);
|
|
10849
10957
|
}
|
|
10850
10958
|
}
|
|
10851
10959
|
function convertWorkerModule(mod) {
|
|
10852
|
-
const
|
|
10853
|
-
(0, import_assert5.default)(
|
|
10960
|
+
const path34 = mod.name;
|
|
10961
|
+
(0, import_assert5.default)(path34 !== void 0);
|
|
10854
10962
|
const m = mod;
|
|
10855
|
-
if ("esModule" in m) return { path:
|
|
10856
|
-
else if ("commonJsModule" in m) return { path:
|
|
10857
|
-
else if ("
|
|
10858
|
-
|
|
10859
|
-
else if ("
|
|
10860
|
-
else if ("
|
|
10861
|
-
else if ("
|
|
10862
|
-
else if ("pythonModule" in m) return { path: path30, type: "PythonModule" };
|
|
10863
|
-
else if ("pythonRequirement" in m) return { path: path30, type: "PythonRequirement" };
|
|
10963
|
+
if ("esModule" in m) return { path: path34, type: "ESModule" };
|
|
10964
|
+
else if ("commonJsModule" in m) return { path: path34, type: "CommonJS" };
|
|
10965
|
+
else if ("text" in m) return { path: path34, type: "Text" };
|
|
10966
|
+
else if ("data" in m) return { path: path34, type: "Data" };
|
|
10967
|
+
else if ("wasm" in m) return { path: path34, type: "CompiledWasm" };
|
|
10968
|
+
else if ("pythonModule" in m) return { path: path34, type: "PythonModule" };
|
|
10969
|
+
else if ("pythonRequirement" in m) return { path: path34, type: "PythonRequirement" };
|
|
10864
10970
|
(0, import_assert5.default)(
|
|
10865
10971
|
!("json" in m || "fallbackService" in m),
|
|
10866
10972
|
"Unreachable: json or fallbackService modules aren't generated"
|
|
@@ -10886,10 +10992,10 @@ var import_web2 = require("stream/web");
|
|
|
10886
10992
|
var import_worker_threads = require("worker_threads");
|
|
10887
10993
|
|
|
10888
10994
|
// src/plugins/core/errors/index.ts
|
|
10889
|
-
var
|
|
10890
|
-
var
|
|
10891
|
-
var
|
|
10892
|
-
var
|
|
10995
|
+
var import_fs15 = __toESM(require("fs"));
|
|
10996
|
+
var import_path18 = __toESM(require("path"));
|
|
10997
|
+
var import_url16 = require("url");
|
|
10998
|
+
var import_zod11 = require("zod");
|
|
10893
10999
|
|
|
10894
11000
|
// src/plugins/core/errors/sourcemap.ts
|
|
10895
11001
|
var import_assert6 = __toESM(require("assert"));
|
|
@@ -10937,7 +11043,7 @@ function parseCallSite(line) {
|
|
|
10937
11043
|
typeName,
|
|
10938
11044
|
functionName,
|
|
10939
11045
|
methodName,
|
|
10940
|
-
fileName: lineMatch[2]
|
|
11046
|
+
fileName: lineMatch[2],
|
|
10941
11047
|
lineNumber: parseInt(lineMatch[3]) || null,
|
|
10942
11048
|
columnNumber: parseInt(lineMatch[4]) || null,
|
|
10943
11049
|
native: isNative
|
|
@@ -10947,6 +11053,21 @@ var CallSite = class {
|
|
|
10947
11053
|
constructor(opts) {
|
|
10948
11054
|
this.opts = opts;
|
|
10949
11055
|
}
|
|
11056
|
+
getScriptHash() {
|
|
11057
|
+
throw new Error("Method not implemented.");
|
|
11058
|
+
}
|
|
11059
|
+
getEnclosingColumnNumber() {
|
|
11060
|
+
throw new Error("Method not implemented.");
|
|
11061
|
+
}
|
|
11062
|
+
getEnclosingLineNumber() {
|
|
11063
|
+
throw new Error("Method not implemented.");
|
|
11064
|
+
}
|
|
11065
|
+
getPosition() {
|
|
11066
|
+
throw new Error("Method not implemented.");
|
|
11067
|
+
}
|
|
11068
|
+
toString() {
|
|
11069
|
+
throw new Error("Method not implemented.");
|
|
11070
|
+
}
|
|
10950
11071
|
getThis() {
|
|
10951
11072
|
return null;
|
|
10952
11073
|
}
|
|
@@ -11061,8 +11182,8 @@ function getSourceMapper() {
|
|
|
11061
11182
|
// src/plugins/core/errors/index.ts
|
|
11062
11183
|
function maybeGetDiskFile(filePath) {
|
|
11063
11184
|
try {
|
|
11064
|
-
const
|
|
11065
|
-
return { path: filePath, contents:
|
|
11185
|
+
const contents24 = import_fs15.default.readFileSync(filePath, "utf8");
|
|
11186
|
+
return { path: filePath, contents: contents24 };
|
|
11066
11187
|
} catch (e) {
|
|
11067
11188
|
if (e.code !== "ENOENT") throw e;
|
|
11068
11189
|
}
|
|
@@ -11070,19 +11191,19 @@ function maybeGetDiskFile(filePath) {
|
|
|
11070
11191
|
function maybeGetFile2(workerSrcOpts, fileSpecifier) {
|
|
11071
11192
|
const maybeUrl = maybeParseURL(fileSpecifier);
|
|
11072
11193
|
if (maybeUrl !== void 0 && maybeUrl.protocol === "file:") {
|
|
11073
|
-
const filePath = (0,
|
|
11194
|
+
const filePath = (0, import_url16.fileURLToPath)(maybeUrl);
|
|
11074
11195
|
for (const srcOpts of workerSrcOpts) {
|
|
11075
11196
|
if (Array.isArray(srcOpts.modules)) {
|
|
11076
11197
|
const modulesRoot = srcOpts.modulesRoot ?? "";
|
|
11077
11198
|
for (const module2 of srcOpts.modules) {
|
|
11078
|
-
if (module2.contents !== void 0 &&
|
|
11079
|
-
const
|
|
11080
|
-
return { path: filePath, contents:
|
|
11199
|
+
if (module2.contents !== void 0 && import_path18.default.resolve(modulesRoot, module2.path) === filePath) {
|
|
11200
|
+
const contents24 = contentsToString(module2.contents);
|
|
11201
|
+
return { path: filePath, contents: contents24 };
|
|
11081
11202
|
}
|
|
11082
11203
|
}
|
|
11083
11204
|
} else if ("script" in srcOpts && "scriptPath" in srcOpts && srcOpts.script !== void 0 && srcOpts.scriptPath !== void 0) {
|
|
11084
11205
|
const modulesRoot = srcOpts.modules && srcOpts.modulesRoot || "";
|
|
11085
|
-
if (
|
|
11206
|
+
if (import_path18.default.resolve(modulesRoot, srcOpts.scriptPath) === filePath) {
|
|
11086
11207
|
return { path: filePath, contents: srcOpts.script };
|
|
11087
11208
|
}
|
|
11088
11209
|
}
|
|
@@ -11105,19 +11226,19 @@ function getSourceMappedStack(workerSrcOpts, error) {
|
|
|
11105
11226
|
const matches = [...sourceFile.contents.matchAll(sourceMapRegexp)];
|
|
11106
11227
|
if (matches.length === 0) return null;
|
|
11107
11228
|
const sourceMapMatch = matches[matches.length - 1];
|
|
11108
|
-
const root =
|
|
11109
|
-
const sourceMapPath =
|
|
11229
|
+
const root = import_path18.default.dirname(sourceFile.path);
|
|
11230
|
+
const sourceMapPath = import_path18.default.resolve(root, sourceMapMatch[1]);
|
|
11110
11231
|
const sourceMapFile = maybeGetDiskFile(sourceMapPath);
|
|
11111
11232
|
if (sourceMapFile === void 0) return null;
|
|
11112
11233
|
return { map: sourceMapFile.contents, url: sourceMapFile.path };
|
|
11113
11234
|
}
|
|
11114
11235
|
return getSourceMapper()(retrieveSourceMap, error);
|
|
11115
11236
|
}
|
|
11116
|
-
var JsonErrorSchema =
|
|
11117
|
-
() =>
|
|
11118
|
-
message:
|
|
11119
|
-
name:
|
|
11120
|
-
stack:
|
|
11237
|
+
var JsonErrorSchema = import_zod11.z.lazy(
|
|
11238
|
+
() => import_zod11.z.object({
|
|
11239
|
+
message: import_zod11.z.string().optional(),
|
|
11240
|
+
name: import_zod11.z.string().optional(),
|
|
11241
|
+
stack: import_zod11.z.string().optional(),
|
|
11121
11242
|
cause: JsonErrorSchema.optional()
|
|
11122
11243
|
})
|
|
11123
11244
|
);
|
|
@@ -11256,7 +11377,7 @@ var SynchronousFetcher = class {
|
|
|
11256
11377
|
transferList: [this.#channel.port2]
|
|
11257
11378
|
});
|
|
11258
11379
|
}
|
|
11259
|
-
fetch(
|
|
11380
|
+
fetch(url24, init2) {
|
|
11260
11381
|
this.#ensureWorker();
|
|
11261
11382
|
Atomics.store(
|
|
11262
11383
|
this.#notifyHandle,
|
|
@@ -11269,7 +11390,7 @@ var SynchronousFetcher = class {
|
|
|
11269
11390
|
this.#channel.port1.postMessage({
|
|
11270
11391
|
id,
|
|
11271
11392
|
method: init2.method,
|
|
11272
|
-
url:
|
|
11393
|
+
url: url24.toString(),
|
|
11273
11394
|
headers: init2.headers,
|
|
11274
11395
|
body: init2.body
|
|
11275
11396
|
});
|
|
@@ -11389,8 +11510,8 @@ var ProxyClient = class {
|
|
|
11389
11510
|
}
|
|
11390
11511
|
};
|
|
11391
11512
|
var ProxyClientBridge = class {
|
|
11392
|
-
constructor(
|
|
11393
|
-
this.url =
|
|
11513
|
+
constructor(url24, dispatchFetch) {
|
|
11514
|
+
this.url = url24;
|
|
11394
11515
|
this.dispatchFetch = dispatchFetch;
|
|
11395
11516
|
this.#finalizationRegistry = new FinalizationRegistry(this.#finalizeProxy);
|
|
11396
11517
|
}
|
|
@@ -11778,73 +11899,74 @@ var ProxyStubHandler = class extends Function {
|
|
|
11778
11899
|
};
|
|
11779
11900
|
|
|
11780
11901
|
// src/plugins/core/services.ts
|
|
11781
|
-
var
|
|
11902
|
+
var import_zod12 = require("zod");
|
|
11782
11903
|
var kCurrentWorker = Symbol.for("miniflare.kCurrentWorker");
|
|
11783
|
-
var HttpOptionsHeaderSchema =
|
|
11784
|
-
name:
|
|
11904
|
+
var HttpOptionsHeaderSchema = import_zod12.z.object({
|
|
11905
|
+
name: import_zod12.z.string(),
|
|
11785
11906
|
// name should be required
|
|
11786
|
-
value:
|
|
11907
|
+
value: import_zod12.z.ostring()
|
|
11787
11908
|
// If omitted, the header will be removed
|
|
11788
11909
|
});
|
|
11789
|
-
var HttpOptionsSchema =
|
|
11790
|
-
style:
|
|
11791
|
-
forwardedProtoHeader:
|
|
11792
|
-
cfBlobHeader:
|
|
11910
|
+
var HttpOptionsSchema = import_zod12.z.object({
|
|
11911
|
+
style: import_zod12.z.nativeEnum(HttpOptions_Style).optional(),
|
|
11912
|
+
forwardedProtoHeader: import_zod12.z.ostring(),
|
|
11913
|
+
cfBlobHeader: import_zod12.z.ostring(),
|
|
11793
11914
|
injectRequestHeaders: HttpOptionsHeaderSchema.array().optional(),
|
|
11794
11915
|
injectResponseHeaders: HttpOptionsHeaderSchema.array().optional()
|
|
11795
11916
|
}).transform((options) => ({
|
|
11796
11917
|
...options,
|
|
11797
11918
|
capnpConnectHost: HOST_CAPNP_CONNECT
|
|
11798
11919
|
}));
|
|
11799
|
-
var TlsOptionsKeypairSchema =
|
|
11800
|
-
privateKey:
|
|
11801
|
-
certificateChain:
|
|
11920
|
+
var TlsOptionsKeypairSchema = import_zod12.z.object({
|
|
11921
|
+
privateKey: import_zod12.z.ostring(),
|
|
11922
|
+
certificateChain: import_zod12.z.ostring()
|
|
11802
11923
|
});
|
|
11803
|
-
var TlsOptionsSchema =
|
|
11924
|
+
var TlsOptionsSchema = import_zod12.z.object({
|
|
11804
11925
|
keypair: TlsOptionsKeypairSchema.optional(),
|
|
11805
|
-
requireClientCerts:
|
|
11806
|
-
trustBrowserCas:
|
|
11807
|
-
trustedCertificates:
|
|
11808
|
-
minVersion:
|
|
11809
|
-
cipherList:
|
|
11926
|
+
requireClientCerts: import_zod12.z.oboolean(),
|
|
11927
|
+
trustBrowserCas: import_zod12.z.oboolean(),
|
|
11928
|
+
trustedCertificates: import_zod12.z.string().array().optional(),
|
|
11929
|
+
minVersion: import_zod12.z.nativeEnum(TlsOptions_Version).optional(),
|
|
11930
|
+
cipherList: import_zod12.z.ostring()
|
|
11810
11931
|
});
|
|
11811
|
-
var NetworkSchema =
|
|
11812
|
-
allow:
|
|
11813
|
-
deny:
|
|
11932
|
+
var NetworkSchema = import_zod12.z.object({
|
|
11933
|
+
allow: import_zod12.z.string().array().optional(),
|
|
11934
|
+
deny: import_zod12.z.string().array().optional(),
|
|
11814
11935
|
tlsOptions: TlsOptionsSchema.optional()
|
|
11815
11936
|
});
|
|
11816
|
-
var ExternalServerSchema =
|
|
11817
|
-
|
|
11937
|
+
var ExternalServerSchema = import_zod12.z.intersection(
|
|
11938
|
+
import_zod12.z.object({ address: import_zod12.z.string() }),
|
|
11818
11939
|
// address should be required
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
https:
|
|
11823
|
-
|
|
11940
|
+
import_zod12.z.union([
|
|
11941
|
+
import_zod12.z.object({ http: import_zod12.z.optional(HttpOptionsSchema) }),
|
|
11942
|
+
import_zod12.z.object({
|
|
11943
|
+
https: import_zod12.z.optional(
|
|
11944
|
+
import_zod12.z.object({
|
|
11824
11945
|
options: HttpOptionsSchema.optional(),
|
|
11825
11946
|
tlsOptions: TlsOptionsSchema.optional(),
|
|
11826
|
-
certificateHost:
|
|
11947
|
+
certificateHost: import_zod12.z.ostring()
|
|
11827
11948
|
})
|
|
11828
11949
|
)
|
|
11829
11950
|
})
|
|
11830
11951
|
])
|
|
11831
11952
|
);
|
|
11832
|
-
var DiskDirectorySchema =
|
|
11833
|
-
path:
|
|
11953
|
+
var DiskDirectorySchema = import_zod12.z.object({
|
|
11954
|
+
path: import_zod12.z.string(),
|
|
11834
11955
|
// path should be required
|
|
11835
|
-
writable:
|
|
11956
|
+
writable: import_zod12.z.oboolean()
|
|
11836
11957
|
});
|
|
11837
|
-
var ServiceFetchSchema =
|
|
11838
|
-
var ServiceDesignatorSchema =
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
name:
|
|
11843
|
-
entrypoint:
|
|
11958
|
+
var ServiceFetchSchema = import_zod12.z.custom((v) => typeof v === "function");
|
|
11959
|
+
var ServiceDesignatorSchema = import_zod12.z.union([
|
|
11960
|
+
import_zod12.z.string(),
|
|
11961
|
+
import_zod12.z.literal(kCurrentWorker),
|
|
11962
|
+
import_zod12.z.object({
|
|
11963
|
+
name: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.literal(kCurrentWorker)]),
|
|
11964
|
+
entrypoint: import_zod12.z.ostring(),
|
|
11965
|
+
props: import_zod12.z.record(import_zod12.z.unknown()).optional()
|
|
11844
11966
|
}),
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11967
|
+
import_zod12.z.object({ network: NetworkSchema }),
|
|
11968
|
+
import_zod12.z.object({ external: ExternalServerSchema }),
|
|
11969
|
+
import_zod12.z.object({ disk: DiskDirectorySchema }),
|
|
11848
11970
|
ServiceFetchSchema
|
|
11849
11971
|
]);
|
|
11850
11972
|
|
|
@@ -11852,10 +11974,12 @@ var ServiceDesignatorSchema = import_zod11.z.union([
|
|
|
11852
11974
|
var trustedCertificates = process.platform === "win32" ? Array.from(import_tls.default.rootCertificates) : [];
|
|
11853
11975
|
if (process.env.NODE_EXTRA_CA_CERTS !== void 0) {
|
|
11854
11976
|
try {
|
|
11855
|
-
const extra = (0,
|
|
11856
|
-
const
|
|
11857
|
-
|
|
11858
|
-
|
|
11977
|
+
const extra = (0, import_fs16.readFileSync)(process.env.NODE_EXTRA_CA_CERTS, "utf8");
|
|
11978
|
+
const certs = extra.match(
|
|
11979
|
+
/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g
|
|
11980
|
+
);
|
|
11981
|
+
if (certs !== null) {
|
|
11982
|
+
trustedCertificates.push(...certs);
|
|
11859
11983
|
}
|
|
11860
11984
|
} catch {
|
|
11861
11985
|
}
|
|
@@ -11865,45 +11989,46 @@ var numericCompare = new Intl.Collator(void 0, { numeric: true }).compare;
|
|
|
11865
11989
|
function createFetchMock() {
|
|
11866
11990
|
return new import_undici7.MockAgent();
|
|
11867
11991
|
}
|
|
11868
|
-
var WrappedBindingSchema =
|
|
11869
|
-
scriptName:
|
|
11870
|
-
entrypoint:
|
|
11871
|
-
bindings:
|
|
11992
|
+
var WrappedBindingSchema = import_zod13.z.object({
|
|
11993
|
+
scriptName: import_zod13.z.string(),
|
|
11994
|
+
entrypoint: import_zod13.z.string().optional(),
|
|
11995
|
+
bindings: import_zod13.z.record(JsonSchema).optional()
|
|
11872
11996
|
});
|
|
11873
|
-
var UnusableStringSchema =
|
|
11874
|
-
var UnsafeDirectSocketSchema =
|
|
11875
|
-
host:
|
|
11876
|
-
port:
|
|
11877
|
-
entrypoint:
|
|
11878
|
-
proxy:
|
|
11997
|
+
var UnusableStringSchema = import_zod13.z.string().transform(() => void 0);
|
|
11998
|
+
var UnsafeDirectSocketSchema = import_zod13.z.object({
|
|
11999
|
+
host: import_zod13.z.ostring(),
|
|
12000
|
+
port: import_zod13.z.onumber(),
|
|
12001
|
+
entrypoint: import_zod13.z.ostring(),
|
|
12002
|
+
proxy: import_zod13.z.oboolean()
|
|
11879
12003
|
});
|
|
11880
|
-
var CoreOptionsSchemaInput =
|
|
12004
|
+
var CoreOptionsSchemaInput = import_zod13.z.intersection(
|
|
11881
12005
|
SourceOptionsSchema,
|
|
11882
|
-
|
|
11883
|
-
name:
|
|
12006
|
+
import_zod13.z.object({
|
|
12007
|
+
name: import_zod13.z.string().optional(),
|
|
11884
12008
|
rootPath: UnusableStringSchema.optional(),
|
|
11885
|
-
compatibilityDate:
|
|
11886
|
-
compatibilityFlags:
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
12009
|
+
compatibilityDate: import_zod13.z.string().optional(),
|
|
12010
|
+
compatibilityFlags: import_zod13.z.string().array().optional(),
|
|
12011
|
+
unsafeInspectorProxy: import_zod13.z.boolean().optional(),
|
|
12012
|
+
routes: import_zod13.z.string().array().optional(),
|
|
12013
|
+
bindings: import_zod13.z.record(JsonSchema).optional(),
|
|
12014
|
+
wasmBindings: import_zod13.z.record(import_zod13.z.union([PathSchema, import_zod13.z.instanceof(Uint8Array)])).optional(),
|
|
12015
|
+
textBlobBindings: import_zod13.z.record(PathSchema).optional(),
|
|
12016
|
+
dataBlobBindings: import_zod13.z.record(import_zod13.z.union([PathSchema, import_zod13.z.instanceof(Uint8Array)])).optional(),
|
|
12017
|
+
serviceBindings: import_zod13.z.record(ServiceDesignatorSchema).optional(),
|
|
12018
|
+
wrappedBindings: import_zod13.z.record(import_zod13.z.union([import_zod13.z.string(), WrappedBindingSchema])).optional(),
|
|
11894
12019
|
outboundService: ServiceDesignatorSchema.optional(),
|
|
11895
|
-
fetchMock:
|
|
12020
|
+
fetchMock: import_zod13.z.instanceof(import_undici7.MockAgent).optional(),
|
|
11896
12021
|
// TODO(soon): remove this in favour of per-object `unsafeUniqueKey: kEphemeralUniqueKey`
|
|
11897
|
-
unsafeEphemeralDurableObjects:
|
|
12022
|
+
unsafeEphemeralDurableObjects: import_zod13.z.boolean().optional(),
|
|
11898
12023
|
unsafeDirectSockets: UnsafeDirectSocketSchema.array().optional(),
|
|
11899
|
-
unsafeEvalBinding:
|
|
11900
|
-
unsafeUseModuleFallbackService:
|
|
12024
|
+
unsafeEvalBinding: import_zod13.z.string().optional(),
|
|
12025
|
+
unsafeUseModuleFallbackService: import_zod13.z.boolean().optional(),
|
|
11901
12026
|
/** Used to set the vitest pool worker SELF binding to point to the Router Worker if there are assets.
|
|
11902
12027
|
(If there are assets but we're not using vitest, the miniflare entry worker can point directly to
|
|
11903
12028
|
Router Worker)
|
|
11904
12029
|
*/
|
|
11905
|
-
hasAssetsAndIsVitest:
|
|
11906
|
-
|
|
12030
|
+
hasAssetsAndIsVitest: import_zod13.z.boolean().optional(),
|
|
12031
|
+
tails: import_zod13.z.array(ServiceDesignatorSchema).optional()
|
|
11907
12032
|
})
|
|
11908
12033
|
);
|
|
11909
12034
|
var CoreOptionsSchema = CoreOptionsSchemaInput.transform((value) => {
|
|
@@ -11916,35 +12041,38 @@ var CoreOptionsSchema = CoreOptionsSchemaInput.transform((value) => {
|
|
|
11916
12041
|
);
|
|
11917
12042
|
}
|
|
11918
12043
|
value.fetchMock = void 0;
|
|
11919
|
-
value.outboundService = (req) =>
|
|
12044
|
+
value.outboundService = (req) => fetch4(req, { dispatcher: fetchMock });
|
|
11920
12045
|
}
|
|
11921
12046
|
return value;
|
|
11922
12047
|
});
|
|
11923
|
-
var CoreSharedOptionsSchema =
|
|
12048
|
+
var CoreSharedOptionsSchema = import_zod13.z.object({
|
|
11924
12049
|
rootPath: UnusableStringSchema.optional(),
|
|
11925
|
-
host:
|
|
11926
|
-
port:
|
|
11927
|
-
https:
|
|
11928
|
-
httpsKey:
|
|
11929
|
-
httpsKeyPath:
|
|
11930
|
-
httpsCert:
|
|
11931
|
-
httpsCertPath:
|
|
11932
|
-
inspectorPort:
|
|
11933
|
-
verbose:
|
|
11934
|
-
log:
|
|
11935
|
-
handleRuntimeStdio:
|
|
11936
|
-
upstream:
|
|
12050
|
+
host: import_zod13.z.string().optional(),
|
|
12051
|
+
port: import_zod13.z.number().optional(),
|
|
12052
|
+
https: import_zod13.z.boolean().optional(),
|
|
12053
|
+
httpsKey: import_zod13.z.string().optional(),
|
|
12054
|
+
httpsKeyPath: import_zod13.z.string().optional(),
|
|
12055
|
+
httpsCert: import_zod13.z.string().optional(),
|
|
12056
|
+
httpsCertPath: import_zod13.z.string().optional(),
|
|
12057
|
+
inspectorPort: import_zod13.z.number().optional(),
|
|
12058
|
+
verbose: import_zod13.z.boolean().optional(),
|
|
12059
|
+
log: import_zod13.z.instanceof(Log).optional(),
|
|
12060
|
+
handleRuntimeStdio: import_zod13.z.function(import_zod13.z.tuple([import_zod13.z.instanceof(import_stream2.Readable), import_zod13.z.instanceof(import_stream2.Readable)])).optional(),
|
|
12061
|
+
upstream: import_zod13.z.string().optional(),
|
|
11937
12062
|
// TODO: add back validation of cf object
|
|
11938
|
-
cf:
|
|
11939
|
-
liveReload:
|
|
12063
|
+
cf: import_zod13.z.union([import_zod13.z.boolean(), import_zod13.z.string(), import_zod13.z.record(import_zod13.z.any())]).optional(),
|
|
12064
|
+
liveReload: import_zod13.z.boolean().optional(),
|
|
11940
12065
|
// This is a shared secret between a proxy server and miniflare that can be
|
|
11941
12066
|
// passed in a header to prove that the request came from the proxy and not
|
|
11942
12067
|
// some malicious attacker.
|
|
11943
|
-
unsafeProxySharedSecret:
|
|
12068
|
+
unsafeProxySharedSecret: import_zod13.z.string().optional(),
|
|
11944
12069
|
unsafeModuleFallbackService: ServiceFetchSchema.optional(),
|
|
11945
12070
|
// Keep blobs when deleting/overwriting keys, required for stacked storage
|
|
11946
|
-
unsafeStickyBlobs:
|
|
11947
|
-
|
|
12071
|
+
unsafeStickyBlobs: import_zod13.z.boolean().optional(),
|
|
12072
|
+
// Enable directly triggering user Worker handlers with paths like `/cdn-cgi/handler/scheduled`
|
|
12073
|
+
unsafeTriggerHandlers: import_zod13.z.boolean().optional(),
|
|
12074
|
+
// Enable logging requests
|
|
12075
|
+
logRequests: import_zod13.z.boolean().default(true)
|
|
11948
12076
|
});
|
|
11949
12077
|
var CORE_PLUGIN_NAME2 = "core";
|
|
11950
12078
|
var LIVE_RELOAD_SCRIPT_TEMPLATE = (port) => `<script defer type="application/javascript">
|
|
@@ -11970,9 +12098,10 @@ var SCRIPT_CUSTOM_SERVICE = `addEventListener("fetch", (event) => {
|
|
|
11970
12098
|
request.headers.set("${CoreHeaders.ORIGINAL_URL}", request.url);
|
|
11971
12099
|
event.respondWith(${CoreBindings.SERVICE_LOOPBACK}.fetch(request));
|
|
11972
12100
|
})`;
|
|
11973
|
-
function getCustomServiceDesignator(refererName, workerIndex, kind, name, service, hasAssetsAndIsVitest = false
|
|
12101
|
+
function getCustomServiceDesignator(refererName, workerIndex, kind, name, service, hasAssetsAndIsVitest = false) {
|
|
11974
12102
|
let serviceName;
|
|
11975
12103
|
let entrypoint;
|
|
12104
|
+
let props;
|
|
11976
12105
|
if (typeof service === "function") {
|
|
11977
12106
|
serviceName = getCustomServiceName(workerIndex, kind, name);
|
|
11978
12107
|
} else if (typeof service === "object") {
|
|
@@ -11983,15 +12112,18 @@ function getCustomServiceDesignator(refererName, workerIndex, kind, name, servic
|
|
|
11983
12112
|
serviceName = getUserServiceName(service.name);
|
|
11984
12113
|
}
|
|
11985
12114
|
entrypoint = service.entrypoint;
|
|
12115
|
+
if (service.props) {
|
|
12116
|
+
props = { json: JSON.stringify(service.props) };
|
|
12117
|
+
}
|
|
11986
12118
|
} else {
|
|
11987
12119
|
serviceName = getBuiltinServiceName(workerIndex, kind, name);
|
|
11988
12120
|
}
|
|
11989
12121
|
} else if (service === kCurrentWorker) {
|
|
11990
|
-
serviceName = hasAssetsAndIsVitest ?
|
|
12122
|
+
serviceName = hasAssetsAndIsVitest ? `${RPC_PROXY_SERVICE_NAME}:${refererName}` : getUserServiceName(refererName);
|
|
11991
12123
|
} else {
|
|
11992
12124
|
serviceName = getUserServiceName(service);
|
|
11993
12125
|
}
|
|
11994
|
-
return { name: serviceName, entrypoint };
|
|
12126
|
+
return { name: serviceName, entrypoint, props };
|
|
11995
12127
|
}
|
|
11996
12128
|
function maybeGetCustomServiceService(workerIndex, kind, name, service) {
|
|
11997
12129
|
if (typeof service === "function") {
|
|
@@ -12085,7 +12217,7 @@ var CORE_PLUGIN = {
|
|
|
12085
12217
|
if (options.textBlobBindings !== void 0) {
|
|
12086
12218
|
bindings.push(
|
|
12087
12219
|
...Object.entries(options.textBlobBindings).map(
|
|
12088
|
-
([name,
|
|
12220
|
+
([name, path34]) => import_promises6.default.readFile(path34, "utf8").then((text) => ({ name, text }))
|
|
12089
12221
|
)
|
|
12090
12222
|
);
|
|
12091
12223
|
}
|
|
@@ -12108,8 +12240,7 @@ var CORE_PLUGIN = {
|
|
|
12108
12240
|
"#" /* UNKNOWN */,
|
|
12109
12241
|
name,
|
|
12110
12242
|
service,
|
|
12111
|
-
options.hasAssetsAndIsVitest
|
|
12112
|
-
options.unsafeEnableAssetsRpc
|
|
12243
|
+
options.hasAssetsAndIsVitest
|
|
12113
12244
|
)
|
|
12114
12245
|
};
|
|
12115
12246
|
})
|
|
@@ -12159,7 +12290,7 @@ var CORE_PLUGIN = {
|
|
|
12159
12290
|
if (options.textBlobBindings !== void 0) {
|
|
12160
12291
|
bindingEntries3.push(
|
|
12161
12292
|
...Object.entries(options.textBlobBindings).map(
|
|
12162
|
-
([name,
|
|
12293
|
+
([name, path34]) => import_promises6.default.readFile(path34, "utf8").then((text) => [name, text])
|
|
12163
12294
|
)
|
|
12164
12295
|
);
|
|
12165
12296
|
}
|
|
@@ -12207,16 +12338,16 @@ var CORE_PLUGIN = {
|
|
|
12207
12338
|
);
|
|
12208
12339
|
if ("modules" in workerScript) {
|
|
12209
12340
|
const subDirs = new Set(
|
|
12210
|
-
workerScript.modules.map(({ name: name2 }) =>
|
|
12341
|
+
workerScript.modules.map(({ name: name2 }) => import_path19.default.posix.dirname(name2))
|
|
12211
12342
|
);
|
|
12212
12343
|
subDirs.delete(".");
|
|
12213
12344
|
for (const module2 of additionalModules) {
|
|
12214
12345
|
workerScript.modules.push(module2);
|
|
12215
12346
|
for (const subDir of subDirs) {
|
|
12216
|
-
const relativePath =
|
|
12347
|
+
const relativePath = import_path19.default.posix.relative(subDir, module2.name);
|
|
12217
12348
|
const relativePathString = JSON.stringify(relativePath);
|
|
12218
12349
|
workerScript.modules.push({
|
|
12219
|
-
name:
|
|
12350
|
+
name: import_path19.default.posix.join(subDir, module2.name),
|
|
12220
12351
|
// TODO(someday): if we ever have additional modules without
|
|
12221
12352
|
// default exports, this may be a problem. For now, our only
|
|
12222
12353
|
// additional module is `__STATIC_CONTENT_MANIFEST` so it's fine.
|
|
@@ -12332,11 +12463,21 @@ Ensure ${stringName} doesn't include unbundled \`import\`s.`
|
|
|
12332
12463
|
"$" /* KNOWN */,
|
|
12333
12464
|
CUSTOM_SERVICE_KNOWN_OUTBOUND,
|
|
12334
12465
|
options.outboundService,
|
|
12335
|
-
options.hasAssetsAndIsVitest
|
|
12336
|
-
options.unsafeEnableAssetsRpc
|
|
12466
|
+
options.hasAssetsAndIsVitest
|
|
12337
12467
|
),
|
|
12338
12468
|
cacheApiOutbound: { name: getCacheServiceName(workerIndex) },
|
|
12339
|
-
moduleFallback: options.unsafeUseModuleFallbackService && sharedOptions.unsafeModuleFallbackService !== void 0 ? `localhost:${loopbackPort}` : void 0
|
|
12469
|
+
moduleFallback: options.unsafeUseModuleFallbackService && sharedOptions.unsafeModuleFallbackService !== void 0 ? `localhost:${loopbackPort}` : void 0,
|
|
12470
|
+
tails: options.tails === void 0 ? void 0 : options.tails.map((service) => {
|
|
12471
|
+
return getCustomServiceDesignator(
|
|
12472
|
+
/* referrer */
|
|
12473
|
+
options.name,
|
|
12474
|
+
workerIndex,
|
|
12475
|
+
"#" /* UNKNOWN */,
|
|
12476
|
+
name,
|
|
12477
|
+
service,
|
|
12478
|
+
options.hasAssetsAndIsVitest
|
|
12479
|
+
);
|
|
12480
|
+
})
|
|
12340
12481
|
}
|
|
12341
12482
|
});
|
|
12342
12483
|
}
|
|
@@ -12351,6 +12492,17 @@ Ensure ${stringName} doesn't include unbundled \`import\`s.`
|
|
|
12351
12492
|
if (maybeService !== void 0) services.push(maybeService);
|
|
12352
12493
|
}
|
|
12353
12494
|
}
|
|
12495
|
+
if (options.tails !== void 0) {
|
|
12496
|
+
for (const service of options.tails) {
|
|
12497
|
+
const maybeService = maybeGetCustomServiceService(
|
|
12498
|
+
workerIndex,
|
|
12499
|
+
"#" /* UNKNOWN */,
|
|
12500
|
+
name,
|
|
12501
|
+
service
|
|
12502
|
+
);
|
|
12503
|
+
if (maybeService !== void 0) services.push(maybeService);
|
|
12504
|
+
}
|
|
12505
|
+
}
|
|
12354
12506
|
if (options.outboundService !== void 0) {
|
|
12355
12507
|
const maybeService = maybeGetCustomServiceService(
|
|
12356
12508
|
workerIndex,
|
|
@@ -12377,6 +12529,14 @@ function getGlobalServices({
|
|
|
12377
12529
|
WORKER_BINDING_SERVICE_LOOPBACK,
|
|
12378
12530
|
// For converting stack-traces to pretty-error pages
|
|
12379
12531
|
{ name: CoreBindings.JSON_ROUTES, json: JSON.stringify(routes) },
|
|
12532
|
+
{
|
|
12533
|
+
name: CoreBindings.TRIGGER_HANDLERS,
|
|
12534
|
+
json: JSON.stringify(!!sharedOptions.unsafeTriggerHandlers)
|
|
12535
|
+
},
|
|
12536
|
+
{
|
|
12537
|
+
name: CoreBindings.LOG_REQUESTS,
|
|
12538
|
+
json: JSON.stringify(!!sharedOptions.logRequests)
|
|
12539
|
+
},
|
|
12380
12540
|
{ name: CoreBindings.JSON_CF_BLOB, json: JSON.stringify(sharedOptions.cf) },
|
|
12381
12541
|
{ name: CoreBindings.JSON_LOG_LEVEL, json: JSON.stringify(log.level) },
|
|
12382
12542
|
{
|
|
@@ -12426,13 +12586,8 @@ function getGlobalServices({
|
|
|
12426
12586
|
name: SERVICE_ENTRY,
|
|
12427
12587
|
worker: {
|
|
12428
12588
|
modules: [{ name: "entry.worker.js", esModule: entry_worker_default() }],
|
|
12429
|
-
compatibilityDate: "
|
|
12430
|
-
compatibilityFlags: [
|
|
12431
|
-
"nodejs_compat",
|
|
12432
|
-
"service_binding_extra_handlers",
|
|
12433
|
-
"brotli_content_encoding",
|
|
12434
|
-
"rpc"
|
|
12435
|
-
],
|
|
12589
|
+
compatibilityDate: "2025-03-17",
|
|
12590
|
+
compatibilityFlags: ["nodejs_compat", "service_binding_extra_handlers"],
|
|
12436
12591
|
bindings: serviceEntryBindings,
|
|
12437
12592
|
durableObjectNamespaces: [
|
|
12438
12593
|
{
|
|
@@ -12470,7 +12625,7 @@ function getGlobalServices({
|
|
|
12470
12625
|
];
|
|
12471
12626
|
}
|
|
12472
12627
|
function getWorkerScript(options, workerIndex, additionalModuleNames) {
|
|
12473
|
-
const modulesRoot =
|
|
12628
|
+
const modulesRoot = import_path19.default.resolve(
|
|
12474
12629
|
("modulesRoot" in options ? options.modulesRoot : void 0) ?? ""
|
|
12475
12630
|
);
|
|
12476
12631
|
if (Array.isArray(options.modules)) {
|
|
@@ -12484,7 +12639,7 @@ function getWorkerScript(options, workerIndex, additionalModuleNames) {
|
|
|
12484
12639
|
if ("script" in options && options.script !== void 0) {
|
|
12485
12640
|
code = options.script;
|
|
12486
12641
|
} else if ("scriptPath" in options && options.scriptPath !== void 0) {
|
|
12487
|
-
code = (0,
|
|
12642
|
+
code = (0, import_fs16.readFileSync)(options.scriptPath, "utf8");
|
|
12488
12643
|
} else {
|
|
12489
12644
|
import_assert9.default.fail("Unreachable: Workers must have code");
|
|
12490
12645
|
}
|
|
@@ -12506,17 +12661,22 @@ function getWorkerScript(options, workerIndex, additionalModuleNames) {
|
|
|
12506
12661
|
}
|
|
12507
12662
|
|
|
12508
12663
|
// src/plugins/assets/schema.ts
|
|
12509
|
-
var
|
|
12510
|
-
var AssetsOptionsSchema =
|
|
12511
|
-
assets:
|
|
12664
|
+
var import_zod14 = require("zod");
|
|
12665
|
+
var AssetsOptionsSchema = import_zod14.z.object({
|
|
12666
|
+
assets: import_zod14.z.object({
|
|
12512
12667
|
// User Worker name or vitest runner - this is only ever set inside miniflare
|
|
12513
12668
|
// The assets plugin needs access to the worker name to create the router worker - user worker binding
|
|
12514
|
-
workerName:
|
|
12669
|
+
workerName: import_zod14.z.string().optional(),
|
|
12515
12670
|
directory: PathSchema,
|
|
12516
|
-
binding:
|
|
12671
|
+
binding: import_zod14.z.string().optional(),
|
|
12517
12672
|
routerConfig: RouterConfigSchema.optional(),
|
|
12518
|
-
assetConfig: AssetConfigSchema.
|
|
12519
|
-
|
|
12673
|
+
assetConfig: AssetConfigSchema.omit({
|
|
12674
|
+
compatibility_date: true,
|
|
12675
|
+
compatibility_flags: true
|
|
12676
|
+
}).optional()
|
|
12677
|
+
}).optional(),
|
|
12678
|
+
compatibilityDate: import_zod14.z.string().optional(),
|
|
12679
|
+
compatibilityFlags: import_zod14.z.string().array().optional()
|
|
12520
12680
|
});
|
|
12521
12681
|
|
|
12522
12682
|
// src/plugins/assets/index.ts
|
|
@@ -12544,14 +12704,18 @@ var ASSETS_PLUGIN = {
|
|
|
12544
12704
|
[options.assets.binding]: new ProxyNodeBinding()
|
|
12545
12705
|
};
|
|
12546
12706
|
},
|
|
12547
|
-
async getServices({ options
|
|
12707
|
+
async getServices({ options }) {
|
|
12548
12708
|
if (!options.assets) {
|
|
12549
12709
|
return [];
|
|
12550
12710
|
}
|
|
12551
12711
|
const storageServiceName = `${ASSETS_PLUGIN_NAME}:storage`;
|
|
12552
12712
|
const storageService = {
|
|
12553
12713
|
name: storageServiceName,
|
|
12554
|
-
disk: {
|
|
12714
|
+
disk: {
|
|
12715
|
+
path: options.assets.directory,
|
|
12716
|
+
writable: true,
|
|
12717
|
+
allowDotfiles: true
|
|
12718
|
+
}
|
|
12555
12719
|
};
|
|
12556
12720
|
const { encodedAssetManifest, assetsReverseMap } = await buildAssetManifest(
|
|
12557
12721
|
options.assets.directory
|
|
@@ -12591,9 +12755,12 @@ var ASSETS_PLUGIN = {
|
|
|
12591
12755
|
);
|
|
12592
12756
|
}
|
|
12593
12757
|
const assetConfig = {
|
|
12758
|
+
compatibility_date: options.compatibilityDate,
|
|
12759
|
+
compatibility_flags: options.compatibilityFlags,
|
|
12594
12760
|
...options.assets.assetConfig,
|
|
12595
12761
|
redirects: parsedRedirects,
|
|
12596
|
-
headers: parsedHeaders
|
|
12762
|
+
headers: parsedHeaders,
|
|
12763
|
+
debug: true
|
|
12597
12764
|
};
|
|
12598
12765
|
const id = options.assets.workerName;
|
|
12599
12766
|
const namespaceService = {
|
|
@@ -12679,36 +12846,39 @@ var ASSETS_PLUGIN = {
|
|
|
12679
12846
|
]
|
|
12680
12847
|
}
|
|
12681
12848
|
};
|
|
12682
|
-
const
|
|
12849
|
+
const assetsProxyService = {
|
|
12850
|
+
name: `${RPC_PROXY_SERVICE_NAME}:${id}`,
|
|
12851
|
+
worker: {
|
|
12852
|
+
compatibilityDate: "2024-08-01",
|
|
12853
|
+
modules: [
|
|
12854
|
+
{
|
|
12855
|
+
name: "assets-proxy-worker.mjs",
|
|
12856
|
+
esModule: rpc_proxy_worker_default()
|
|
12857
|
+
}
|
|
12858
|
+
],
|
|
12859
|
+
bindings: [
|
|
12860
|
+
{
|
|
12861
|
+
name: "ROUTER_WORKER",
|
|
12862
|
+
service: {
|
|
12863
|
+
name: `${ROUTER_SERVICE_NAME}:${id}`
|
|
12864
|
+
}
|
|
12865
|
+
},
|
|
12866
|
+
{
|
|
12867
|
+
name: "USER_WORKER",
|
|
12868
|
+
service: {
|
|
12869
|
+
name: getUserServiceName(id)
|
|
12870
|
+
}
|
|
12871
|
+
}
|
|
12872
|
+
]
|
|
12873
|
+
}
|
|
12874
|
+
};
|
|
12875
|
+
return [
|
|
12683
12876
|
storageService,
|
|
12684
12877
|
namespaceService,
|
|
12685
12878
|
assetService,
|
|
12686
|
-
routerService
|
|
12879
|
+
routerService,
|
|
12880
|
+
assetsProxyService
|
|
12687
12881
|
];
|
|
12688
|
-
if (unsafeEnableAssetsRpc) {
|
|
12689
|
-
const assetsProxyService = {
|
|
12690
|
-
name: `${RPC_PROXY_SERVICE_NAME}:${id}`,
|
|
12691
|
-
worker: {
|
|
12692
|
-
compatibilityDate: "2024-08-01",
|
|
12693
|
-
modules: [
|
|
12694
|
-
{
|
|
12695
|
-
name: "assets-proxy-worker.mjs",
|
|
12696
|
-
esModule: rpc_proxy_worker_default()
|
|
12697
|
-
}
|
|
12698
|
-
],
|
|
12699
|
-
bindings: [
|
|
12700
|
-
{
|
|
12701
|
-
name: "ROUTER_WORKER",
|
|
12702
|
-
service: {
|
|
12703
|
-
name: `${ROUTER_SERVICE_NAME}:${id}`
|
|
12704
|
-
}
|
|
12705
|
-
}
|
|
12706
|
-
]
|
|
12707
|
-
}
|
|
12708
|
-
};
|
|
12709
|
-
services.push(assetsProxyService);
|
|
12710
|
-
}
|
|
12711
|
-
return services;
|
|
12712
12882
|
}
|
|
12713
12883
|
};
|
|
12714
12884
|
var buildAssetManifest = async (dir) => {
|
|
@@ -12814,9 +12984,9 @@ var encodeManifest = (manifest) => {
|
|
|
12814
12984
|
var bytesToHex = (buffer) => {
|
|
12815
12985
|
return [...new Uint8Array(buffer)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
12816
12986
|
};
|
|
12817
|
-
var hashPath = async (
|
|
12987
|
+
var hashPath = async (path34) => {
|
|
12818
12988
|
const encoder3 = new TextEncoder();
|
|
12819
|
-
const data = encoder3.encode(
|
|
12989
|
+
const data = encoder3.encode(path34);
|
|
12820
12990
|
const hashBuffer = await import_node_crypto.default.subtle.digest(
|
|
12821
12991
|
"SHA-256",
|
|
12822
12992
|
data.buffer
|
|
@@ -12828,23 +12998,23 @@ var hashPath = async (path30) => {
|
|
|
12828
12998
|
var import_promises8 = __toESM(require("fs/promises"));
|
|
12829
12999
|
|
|
12830
13000
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/d1/database.worker.ts
|
|
12831
|
-
var
|
|
12832
|
-
var
|
|
12833
|
-
var
|
|
12834
|
-
var
|
|
13001
|
+
var import_fs17 = __toESM(require("fs"));
|
|
13002
|
+
var import_path20 = __toESM(require("path"));
|
|
13003
|
+
var import_url17 = __toESM(require("url"));
|
|
13004
|
+
var contents13;
|
|
12835
13005
|
function database_worker_default() {
|
|
12836
|
-
if (
|
|
12837
|
-
const filePath =
|
|
12838
|
-
|
|
12839
|
-
return
|
|
13006
|
+
if (contents13 !== void 0) return contents13;
|
|
13007
|
+
const filePath = import_path20.default.join(__dirname, "workers", "d1/database.worker.js");
|
|
13008
|
+
contents13 = import_fs17.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url17.default.pathToFileURL(filePath);
|
|
13009
|
+
return contents13;
|
|
12840
13010
|
}
|
|
12841
13011
|
|
|
12842
13012
|
// src/plugins/d1/index.ts
|
|
12843
|
-
var
|
|
12844
|
-
var D1OptionsSchema =
|
|
12845
|
-
d1Databases:
|
|
13013
|
+
var import_zod15 = require("zod");
|
|
13014
|
+
var D1OptionsSchema = import_zod15.z.object({
|
|
13015
|
+
d1Databases: import_zod15.z.union([import_zod15.z.record(import_zod15.z.string()), import_zod15.z.string().array()]).optional()
|
|
12846
13016
|
});
|
|
12847
|
-
var D1SharedOptionsSchema =
|
|
13017
|
+
var D1SharedOptionsSchema = import_zod15.z.object({
|
|
12848
13018
|
d1Persist: PersistenceSchema
|
|
12849
13019
|
});
|
|
12850
13020
|
var D1_PLUGIN_NAME = "d1";
|
|
@@ -12955,67 +13125,181 @@ var D1_PLUGIN = {
|
|
|
12955
13125
|
}
|
|
12956
13126
|
};
|
|
12957
13127
|
|
|
13128
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/email/email.worker.ts
|
|
13129
|
+
var import_fs18 = __toESM(require("fs"));
|
|
13130
|
+
var import_path21 = __toESM(require("path"));
|
|
13131
|
+
var import_url18 = __toESM(require("url"));
|
|
13132
|
+
var contents14;
|
|
13133
|
+
function email_worker_default() {
|
|
13134
|
+
if (contents14 !== void 0) return contents14;
|
|
13135
|
+
const filePath = import_path21.default.join(__dirname, "workers", "email/email.worker.js");
|
|
13136
|
+
contents14 = import_fs18.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url18.default.pathToFileURL(filePath);
|
|
13137
|
+
return contents14;
|
|
13138
|
+
}
|
|
13139
|
+
|
|
13140
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/email/send_email.worker.ts
|
|
13141
|
+
var import_fs19 = __toESM(require("fs"));
|
|
13142
|
+
var import_path22 = __toESM(require("path"));
|
|
13143
|
+
var import_url19 = __toESM(require("url"));
|
|
13144
|
+
var contents15;
|
|
13145
|
+
function send_email_worker_default() {
|
|
13146
|
+
if (contents15 !== void 0) return contents15;
|
|
13147
|
+
const filePath = import_path22.default.join(__dirname, "workers", "email/send_email.worker.js");
|
|
13148
|
+
contents15 = import_fs19.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url19.default.pathToFileURL(filePath);
|
|
13149
|
+
return contents15;
|
|
13150
|
+
}
|
|
13151
|
+
|
|
13152
|
+
// src/plugins/email/index.ts
|
|
13153
|
+
var import_zod16 = require("zod");
|
|
13154
|
+
var EmailBindingOptionsSchema = import_zod16.z.object({
|
|
13155
|
+
name: import_zod16.z.string()
|
|
13156
|
+
}).and(
|
|
13157
|
+
import_zod16.z.union([
|
|
13158
|
+
import_zod16.z.object({
|
|
13159
|
+
destination_address: import_zod16.z.string().optional(),
|
|
13160
|
+
allowed_destination_addresses: import_zod16.z.never().optional()
|
|
13161
|
+
}),
|
|
13162
|
+
import_zod16.z.object({
|
|
13163
|
+
allowed_destination_addresses: import_zod16.z.array(import_zod16.z.string()).optional(),
|
|
13164
|
+
destination_address: import_zod16.z.never().optional()
|
|
13165
|
+
})
|
|
13166
|
+
])
|
|
13167
|
+
);
|
|
13168
|
+
var EmailOptionsSchema = import_zod16.z.object({
|
|
13169
|
+
email: import_zod16.z.object({
|
|
13170
|
+
send_email: import_zod16.z.array(EmailBindingOptionsSchema).optional()
|
|
13171
|
+
}).optional()
|
|
13172
|
+
});
|
|
13173
|
+
var EMAIL_PLUGIN_NAME = "email";
|
|
13174
|
+
var SERVICE_SEND_EMAIL_WORKER_PREFIX = `SEND-EMAIL-WORKER`;
|
|
13175
|
+
function buildJsonBindings(bindings) {
|
|
13176
|
+
return Object.entries(bindings).map(([name, value]) => ({
|
|
13177
|
+
name,
|
|
13178
|
+
json: JSON.stringify(value)
|
|
13179
|
+
}));
|
|
13180
|
+
}
|
|
13181
|
+
var EMAIL_PLUGIN = {
|
|
13182
|
+
options: EmailOptionsSchema,
|
|
13183
|
+
getBindings(options) {
|
|
13184
|
+
if (!options.email?.send_email) {
|
|
13185
|
+
return [];
|
|
13186
|
+
}
|
|
13187
|
+
const sendEmailBindings = options.email.send_email;
|
|
13188
|
+
return sendEmailBindings.map(({ name }) => ({
|
|
13189
|
+
name,
|
|
13190
|
+
service: {
|
|
13191
|
+
entrypoint: "SendEmailBinding",
|
|
13192
|
+
name: `${SERVICE_SEND_EMAIL_WORKER_PREFIX}:${name}`
|
|
13193
|
+
}
|
|
13194
|
+
}));
|
|
13195
|
+
},
|
|
13196
|
+
getNodeBindings(_options) {
|
|
13197
|
+
return {};
|
|
13198
|
+
},
|
|
13199
|
+
async getServices(args) {
|
|
13200
|
+
const extensions = [];
|
|
13201
|
+
const services = [];
|
|
13202
|
+
if (args.workerIndex === 0) {
|
|
13203
|
+
extensions.push({
|
|
13204
|
+
modules: [
|
|
13205
|
+
{
|
|
13206
|
+
name: "cloudflare-internal:email",
|
|
13207
|
+
esModule: email_worker_default(),
|
|
13208
|
+
internal: true
|
|
13209
|
+
}
|
|
13210
|
+
]
|
|
13211
|
+
});
|
|
13212
|
+
}
|
|
13213
|
+
for (const { name, ...config } of args.options.email?.send_email ?? []) {
|
|
13214
|
+
services.push({
|
|
13215
|
+
name: `${SERVICE_SEND_EMAIL_WORKER_PREFIX}:${name}`,
|
|
13216
|
+
worker: {
|
|
13217
|
+
compatibilityDate: "2025-03-17",
|
|
13218
|
+
modules: [
|
|
13219
|
+
{
|
|
13220
|
+
name: "send_email.mjs",
|
|
13221
|
+
esModule: send_email_worker_default()
|
|
13222
|
+
}
|
|
13223
|
+
],
|
|
13224
|
+
bindings: [
|
|
13225
|
+
...buildJsonBindings(config),
|
|
13226
|
+
WORKER_BINDING_SERVICE_LOOPBACK
|
|
13227
|
+
]
|
|
13228
|
+
}
|
|
13229
|
+
});
|
|
13230
|
+
}
|
|
13231
|
+
return {
|
|
13232
|
+
services,
|
|
13233
|
+
extensions
|
|
13234
|
+
};
|
|
13235
|
+
}
|
|
13236
|
+
};
|
|
13237
|
+
|
|
12958
13238
|
// src/plugins/hyperdrive/index.ts
|
|
12959
13239
|
var import_node_assert3 = __toESM(require("node:assert"));
|
|
12960
|
-
var
|
|
13240
|
+
var import_zod17 = require("zod");
|
|
12961
13241
|
var HYPERDRIVE_PLUGIN_NAME = "hyperdrive";
|
|
12962
|
-
function hasPostgresProtocol(
|
|
12963
|
-
return
|
|
13242
|
+
function hasPostgresProtocol(url24) {
|
|
13243
|
+
return url24.protocol === "postgresql:" || url24.protocol === "postgres:";
|
|
12964
13244
|
}
|
|
12965
|
-
function
|
|
12966
|
-
|
|
12967
|
-
if (hasPostgresProtocol(url20)) return "5432";
|
|
12968
|
-
import_node_assert3.default.fail(`Expected known protocol, got ${url20.protocol}`);
|
|
13245
|
+
function hasMysqlProtocol(url24) {
|
|
13246
|
+
return url24.protocol === "mysql:";
|
|
12969
13247
|
}
|
|
12970
|
-
|
|
12971
|
-
if (
|
|
12972
|
-
if (
|
|
13248
|
+
function getPort(url24) {
|
|
13249
|
+
if (url24.port !== "") return url24.port;
|
|
13250
|
+
if (hasPostgresProtocol(url24)) return "5432";
|
|
13251
|
+
if (hasMysqlProtocol(url24)) return "3306";
|
|
13252
|
+
import_node_assert3.default.fail(`Expected known protocol, got ${url24.protocol}`);
|
|
13253
|
+
}
|
|
13254
|
+
var HyperdriveSchema = import_zod17.z.union([import_zod17.z.string().url(), import_zod17.z.instanceof(URL)]).transform((url24, ctx) => {
|
|
13255
|
+
if (typeof url24 === "string") url24 = new URL(url24);
|
|
13256
|
+
if (url24.protocol === "") {
|
|
12973
13257
|
ctx.addIssue({
|
|
12974
|
-
code:
|
|
12975
|
-
message: "You must specify the database protocol - e.g. 'postgresql'."
|
|
13258
|
+
code: import_zod17.z.ZodIssueCode.custom,
|
|
13259
|
+
message: "You must specify the database protocol - e.g. 'postgresql'/'mysql'."
|
|
12976
13260
|
});
|
|
12977
|
-
} else if (!hasPostgresProtocol(
|
|
13261
|
+
} else if (!hasPostgresProtocol(url24) && !hasMysqlProtocol(url24)) {
|
|
12978
13262
|
ctx.addIssue({
|
|
12979
|
-
code:
|
|
12980
|
-
message: "Only PostgreSQL or
|
|
13263
|
+
code: import_zod17.z.ZodIssueCode.custom,
|
|
13264
|
+
message: "Only PostgreSQL-compatible or MySQL-compatible databases are currently supported."
|
|
12981
13265
|
});
|
|
12982
13266
|
}
|
|
12983
|
-
if (
|
|
13267
|
+
if (url24.host === "") {
|
|
12984
13268
|
ctx.addIssue({
|
|
12985
|
-
code:
|
|
13269
|
+
code: import_zod17.z.ZodIssueCode.custom,
|
|
12986
13270
|
message: "You must provide a hostname or IP address in your connection string - e.g. 'user:password@database-hostname.example.com:5432/databasename"
|
|
12987
13271
|
});
|
|
12988
13272
|
}
|
|
12989
|
-
if (
|
|
13273
|
+
if (url24.pathname === "") {
|
|
12990
13274
|
ctx.addIssue({
|
|
12991
|
-
code:
|
|
13275
|
+
code: import_zod17.z.ZodIssueCode.custom,
|
|
12992
13276
|
message: "You must provide a database name as the path component - e.g. /postgres"
|
|
12993
13277
|
});
|
|
12994
13278
|
}
|
|
12995
|
-
if (
|
|
13279
|
+
if (url24.username === "") {
|
|
12996
13280
|
ctx.addIssue({
|
|
12997
|
-
code:
|
|
13281
|
+
code: import_zod17.z.ZodIssueCode.custom,
|
|
12998
13282
|
message: "You must provide a username - e.g. 'user:password@database.example.com:port/databasename'"
|
|
12999
13283
|
});
|
|
13000
13284
|
}
|
|
13001
|
-
if (
|
|
13285
|
+
if (url24.password === "") {
|
|
13002
13286
|
ctx.addIssue({
|
|
13003
|
-
code:
|
|
13287
|
+
code: import_zod17.z.ZodIssueCode.custom,
|
|
13004
13288
|
message: "You must provide a password - e.g. 'user:password@database.example.com:port/databasename' "
|
|
13005
13289
|
});
|
|
13006
13290
|
}
|
|
13007
|
-
return
|
|
13291
|
+
return url24;
|
|
13008
13292
|
});
|
|
13009
|
-
var HyperdriveInputOptionsSchema =
|
|
13010
|
-
hyperdrives:
|
|
13293
|
+
var HyperdriveInputOptionsSchema = import_zod17.z.object({
|
|
13294
|
+
hyperdrives: import_zod17.z.record(import_zod17.z.string(), HyperdriveSchema).optional()
|
|
13011
13295
|
});
|
|
13012
13296
|
var HYPERDRIVE_PLUGIN = {
|
|
13013
13297
|
options: HyperdriveInputOptionsSchema,
|
|
13014
13298
|
getBindings(options) {
|
|
13015
13299
|
return Object.entries(options.hyperdrives ?? {}).map(
|
|
13016
|
-
([name,
|
|
13017
|
-
const database =
|
|
13018
|
-
const scheme =
|
|
13300
|
+
([name, url24]) => {
|
|
13301
|
+
const database = url24.pathname.replace("/", "");
|
|
13302
|
+
const scheme = url24.protocol.replace(":", "");
|
|
13019
13303
|
return {
|
|
13020
13304
|
name,
|
|
13021
13305
|
hyperdrive: {
|
|
@@ -13023,8 +13307,8 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
13023
13307
|
name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`
|
|
13024
13308
|
},
|
|
13025
13309
|
database: decodeURIComponent(database),
|
|
13026
|
-
user: decodeURIComponent(
|
|
13027
|
-
password: decodeURIComponent(
|
|
13310
|
+
user: decodeURIComponent(url24.username),
|
|
13311
|
+
password: decodeURIComponent(url24.password),
|
|
13028
13312
|
scheme
|
|
13029
13313
|
}
|
|
13030
13314
|
};
|
|
@@ -13033,11 +13317,11 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
13033
13317
|
},
|
|
13034
13318
|
getNodeBindings(options) {
|
|
13035
13319
|
return Object.fromEntries(
|
|
13036
|
-
Object.entries(options.hyperdrives ?? {}).map(([name,
|
|
13320
|
+
Object.entries(options.hyperdrives ?? {}).map(([name, url24]) => {
|
|
13037
13321
|
const connectionOverrides = {
|
|
13038
|
-
connectionString: `${
|
|
13039
|
-
port: Number.parseInt(
|
|
13040
|
-
host:
|
|
13322
|
+
connectionString: `${url24}`,
|
|
13323
|
+
port: Number.parseInt(url24.port),
|
|
13324
|
+
host: url24.hostname
|
|
13041
13325
|
};
|
|
13042
13326
|
const proxyNodeBinding = new ProxyNodeBinding({
|
|
13043
13327
|
get(target, prop) {
|
|
@@ -13050,10 +13334,10 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
13050
13334
|
},
|
|
13051
13335
|
async getServices({ options }) {
|
|
13052
13336
|
return Object.entries(options.hyperdrives ?? {}).map(
|
|
13053
|
-
([name,
|
|
13337
|
+
([name, url24]) => ({
|
|
13054
13338
|
name: `${HYPERDRIVE_PLUGIN_NAME}:${name}`,
|
|
13055
13339
|
external: {
|
|
13056
|
-
address: `${
|
|
13340
|
+
address: `${url24.hostname}:${getPort(url24)}`,
|
|
13057
13341
|
tcp: {}
|
|
13058
13342
|
}
|
|
13059
13343
|
})
|
|
@@ -13065,19 +13349,19 @@ var HYPERDRIVE_PLUGIN = {
|
|
|
13065
13349
|
var import_promises10 = __toESM(require("fs/promises"));
|
|
13066
13350
|
|
|
13067
13351
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/kv/namespace.worker.ts
|
|
13068
|
-
var
|
|
13069
|
-
var
|
|
13070
|
-
var
|
|
13071
|
-
var
|
|
13352
|
+
var import_fs20 = __toESM(require("fs"));
|
|
13353
|
+
var import_path23 = __toESM(require("path"));
|
|
13354
|
+
var import_url20 = __toESM(require("url"));
|
|
13355
|
+
var contents16;
|
|
13072
13356
|
function namespace_worker_default() {
|
|
13073
|
-
if (
|
|
13074
|
-
const filePath =
|
|
13075
|
-
|
|
13076
|
-
return
|
|
13357
|
+
if (contents16 !== void 0) return contents16;
|
|
13358
|
+
const filePath = import_path23.default.join(__dirname, "workers", "kv/namespace.worker.js");
|
|
13359
|
+
contents16 = import_fs20.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url20.default.pathToFileURL(filePath);
|
|
13360
|
+
return contents16;
|
|
13077
13361
|
}
|
|
13078
13362
|
|
|
13079
13363
|
// src/plugins/kv/index.ts
|
|
13080
|
-
var
|
|
13364
|
+
var import_zod18 = require("zod");
|
|
13081
13365
|
|
|
13082
13366
|
// src/plugins/kv/constants.ts
|
|
13083
13367
|
var KV_PLUGIN_NAME = "kv";
|
|
@@ -13085,25 +13369,25 @@ var KV_PLUGIN_NAME = "kv";
|
|
|
13085
13369
|
// src/plugins/kv/sites.ts
|
|
13086
13370
|
var import_assert10 = __toESM(require("assert"));
|
|
13087
13371
|
var import_promises9 = __toESM(require("fs/promises"));
|
|
13088
|
-
var
|
|
13372
|
+
var import_path25 = __toESM(require("path"));
|
|
13089
13373
|
|
|
13090
13374
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/kv/sites.worker.ts
|
|
13091
|
-
var
|
|
13092
|
-
var
|
|
13093
|
-
var
|
|
13094
|
-
var
|
|
13375
|
+
var import_fs21 = __toESM(require("fs"));
|
|
13376
|
+
var import_path24 = __toESM(require("path"));
|
|
13377
|
+
var import_url21 = __toESM(require("url"));
|
|
13378
|
+
var contents17;
|
|
13095
13379
|
function sites_worker_default() {
|
|
13096
|
-
if (
|
|
13097
|
-
const filePath =
|
|
13098
|
-
|
|
13099
|
-
return
|
|
13380
|
+
if (contents17 !== void 0) return contents17;
|
|
13381
|
+
const filePath = import_path24.default.join(__dirname, "workers", "kv/sites.worker.js");
|
|
13382
|
+
contents17 = import_fs21.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url21.default.pathToFileURL(filePath);
|
|
13383
|
+
return contents17;
|
|
13100
13384
|
}
|
|
13101
13385
|
|
|
13102
13386
|
// src/plugins/kv/sites.ts
|
|
13103
13387
|
async function* listKeysInDirectoryInner(rootPath2, currentPath) {
|
|
13104
13388
|
const fileEntries = await import_promises9.default.readdir(currentPath, { withFileTypes: true });
|
|
13105
13389
|
for (const fileEntry of fileEntries) {
|
|
13106
|
-
const filePath =
|
|
13390
|
+
const filePath = import_path25.default.posix.join(currentPath, fileEntry.name);
|
|
13107
13391
|
if (fileEntry.isDirectory()) {
|
|
13108
13392
|
yield* listKeysInDirectoryInner(rootPath2, filePath);
|
|
13109
13393
|
} else {
|
|
@@ -13112,7 +13396,7 @@ async function* listKeysInDirectoryInner(rootPath2, currentPath) {
|
|
|
13112
13396
|
}
|
|
13113
13397
|
}
|
|
13114
13398
|
function listKeysInDirectory(rootPath2) {
|
|
13115
|
-
rootPath2 =
|
|
13399
|
+
rootPath2 = import_path25.default.resolve(rootPath2);
|
|
13116
13400
|
return listKeysInDirectoryInner(rootPath2, rootPath2);
|
|
13117
13401
|
}
|
|
13118
13402
|
var sitesRegExpsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -13163,7 +13447,7 @@ function getSitesServices(options) {
|
|
|
13163
13447
|
const siteRegExps = sitesRegExpsCache.get(options);
|
|
13164
13448
|
(0, import_assert10.default)(siteRegExps !== void 0);
|
|
13165
13449
|
const serialisedSiteRegExps = serialiseSiteRegExps(siteRegExps);
|
|
13166
|
-
const persist =
|
|
13450
|
+
const persist = import_path25.default.resolve(options.sitePath);
|
|
13167
13451
|
const storageServiceName = `${SERVICE_NAMESPACE_SITE}:storage`;
|
|
13168
13452
|
const storageService = {
|
|
13169
13453
|
name: storageServiceName,
|
|
@@ -13196,14 +13480,14 @@ function getSitesServices(options) {
|
|
|
13196
13480
|
}
|
|
13197
13481
|
|
|
13198
13482
|
// src/plugins/kv/index.ts
|
|
13199
|
-
var KVOptionsSchema =
|
|
13200
|
-
kvNamespaces:
|
|
13483
|
+
var KVOptionsSchema = import_zod18.z.object({
|
|
13484
|
+
kvNamespaces: import_zod18.z.union([import_zod18.z.record(import_zod18.z.string()), import_zod18.z.string().array()]).optional(),
|
|
13201
13485
|
// Workers Sites
|
|
13202
13486
|
sitePath: PathSchema.optional(),
|
|
13203
|
-
siteInclude:
|
|
13204
|
-
siteExclude:
|
|
13487
|
+
siteInclude: import_zod18.z.string().array().optional(),
|
|
13488
|
+
siteExclude: import_zod18.z.string().array().optional()
|
|
13205
13489
|
});
|
|
13206
|
-
var KVSharedOptionsSchema =
|
|
13490
|
+
var KVSharedOptionsSchema = import_zod18.z.object({
|
|
13207
13491
|
kvPersist: PersistenceSchema
|
|
13208
13492
|
});
|
|
13209
13493
|
var SERVICE_NAMESPACE_PREFIX = `${KV_PLUGIN_NAME}:ns`;
|
|
@@ -13307,21 +13591,21 @@ var KV_PLUGIN = {
|
|
|
13307
13591
|
};
|
|
13308
13592
|
|
|
13309
13593
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/pipelines/pipeline.worker.ts
|
|
13310
|
-
var
|
|
13311
|
-
var
|
|
13312
|
-
var
|
|
13313
|
-
var
|
|
13594
|
+
var import_fs22 = __toESM(require("fs"));
|
|
13595
|
+
var import_path26 = __toESM(require("path"));
|
|
13596
|
+
var import_url22 = __toESM(require("url"));
|
|
13597
|
+
var contents18;
|
|
13314
13598
|
function pipeline_worker_default() {
|
|
13315
|
-
if (
|
|
13316
|
-
const filePath =
|
|
13317
|
-
|
|
13318
|
-
return
|
|
13599
|
+
if (contents18 !== void 0) return contents18;
|
|
13600
|
+
const filePath = import_path26.default.join(__dirname, "workers", "pipelines/pipeline.worker.js");
|
|
13601
|
+
contents18 = import_fs22.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url22.default.pathToFileURL(filePath);
|
|
13602
|
+
return contents18;
|
|
13319
13603
|
}
|
|
13320
13604
|
|
|
13321
13605
|
// src/plugins/pipelines/index.ts
|
|
13322
|
-
var
|
|
13323
|
-
var PipelineOptionsSchema =
|
|
13324
|
-
pipelines:
|
|
13606
|
+
var import_zod19 = require("zod");
|
|
13607
|
+
var PipelineOptionsSchema = import_zod19.z.object({
|
|
13608
|
+
pipelines: import_zod19.z.union([import_zod19.z.record(import_zod19.z.string()), import_zod19.z.string().array()]).optional()
|
|
13325
13609
|
});
|
|
13326
13610
|
var PIPELINES_PLUGIN_NAME = "pipelines";
|
|
13327
13611
|
var SERVICE_PIPELINE_PREFIX = `${PIPELINES_PLUGIN_NAME}:pipeline`;
|
|
@@ -13374,32 +13658,32 @@ function bindingEntries(namespaces) {
|
|
|
13374
13658
|
}
|
|
13375
13659
|
|
|
13376
13660
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/queues/broker.worker.ts
|
|
13377
|
-
var
|
|
13378
|
-
var
|
|
13379
|
-
var
|
|
13380
|
-
var
|
|
13661
|
+
var import_fs23 = __toESM(require("fs"));
|
|
13662
|
+
var import_path27 = __toESM(require("path"));
|
|
13663
|
+
var import_url23 = __toESM(require("url"));
|
|
13664
|
+
var contents19;
|
|
13381
13665
|
function broker_worker_default() {
|
|
13382
|
-
if (
|
|
13383
|
-
const filePath =
|
|
13384
|
-
|
|
13385
|
-
return
|
|
13666
|
+
if (contents19 !== void 0) return contents19;
|
|
13667
|
+
const filePath = import_path27.default.join(__dirname, "workers", "queues/broker.worker.js");
|
|
13668
|
+
contents19 = import_fs23.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url23.default.pathToFileURL(filePath);
|
|
13669
|
+
return contents19;
|
|
13386
13670
|
}
|
|
13387
13671
|
|
|
13388
13672
|
// src/plugins/queues/index.ts
|
|
13389
|
-
var
|
|
13673
|
+
var import_zod20 = require("zod");
|
|
13390
13674
|
|
|
13391
13675
|
// src/plugins/queues/errors.ts
|
|
13392
13676
|
var QueuesError = class extends MiniflareError {
|
|
13393
13677
|
};
|
|
13394
13678
|
|
|
13395
13679
|
// src/plugins/queues/index.ts
|
|
13396
|
-
var QueuesOptionsSchema =
|
|
13397
|
-
queueProducers:
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13680
|
+
var QueuesOptionsSchema = import_zod20.z.object({
|
|
13681
|
+
queueProducers: import_zod20.z.union([
|
|
13682
|
+
import_zod20.z.record(QueueProducerOptionsSchema),
|
|
13683
|
+
import_zod20.z.string().array(),
|
|
13684
|
+
import_zod20.z.record(import_zod20.z.string())
|
|
13401
13685
|
]).optional(),
|
|
13402
|
-
queueConsumers:
|
|
13686
|
+
queueConsumers: import_zod20.z.union([import_zod20.z.record(QueueConsumerOptionsSchema), import_zod20.z.string().array()]).optional()
|
|
13403
13687
|
});
|
|
13404
13688
|
var QUEUES_PLUGIN_NAME = "queues";
|
|
13405
13689
|
var SERVICE_QUEUE_PREFIX = `${QUEUES_PLUGIN_NAME}:queue`;
|
|
@@ -13515,23 +13799,23 @@ function bindingKeys(namespaces) {
|
|
|
13515
13799
|
var import_promises11 = __toESM(require("fs/promises"));
|
|
13516
13800
|
|
|
13517
13801
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/r2/bucket.worker.ts
|
|
13518
|
-
var
|
|
13519
|
-
var
|
|
13520
|
-
var
|
|
13521
|
-
var
|
|
13802
|
+
var import_fs24 = __toESM(require("fs"));
|
|
13803
|
+
var import_path28 = __toESM(require("path"));
|
|
13804
|
+
var import_url24 = __toESM(require("url"));
|
|
13805
|
+
var contents20;
|
|
13522
13806
|
function bucket_worker_default() {
|
|
13523
|
-
if (
|
|
13524
|
-
const filePath =
|
|
13525
|
-
|
|
13526
|
-
return
|
|
13807
|
+
if (contents20 !== void 0) return contents20;
|
|
13808
|
+
const filePath = import_path28.default.join(__dirname, "workers", "r2/bucket.worker.js");
|
|
13809
|
+
contents20 = import_fs24.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url24.default.pathToFileURL(filePath);
|
|
13810
|
+
return contents20;
|
|
13527
13811
|
}
|
|
13528
13812
|
|
|
13529
13813
|
// src/plugins/r2/index.ts
|
|
13530
|
-
var
|
|
13531
|
-
var R2OptionsSchema =
|
|
13532
|
-
r2Buckets:
|
|
13814
|
+
var import_zod21 = require("zod");
|
|
13815
|
+
var R2OptionsSchema = import_zod21.z.object({
|
|
13816
|
+
r2Buckets: import_zod21.z.union([import_zod21.z.record(import_zod21.z.string()), import_zod21.z.string().array()]).optional()
|
|
13533
13817
|
});
|
|
13534
|
-
var R2SharedOptionsSchema =
|
|
13818
|
+
var R2SharedOptionsSchema = import_zod21.z.object({
|
|
13535
13819
|
r2Persist: PersistenceSchema
|
|
13536
13820
|
});
|
|
13537
13821
|
var R2_PLUGIN_NAME = "r2";
|
|
@@ -13625,38 +13909,38 @@ var R2_PLUGIN = {
|
|
|
13625
13909
|
};
|
|
13626
13910
|
|
|
13627
13911
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/ratelimit/ratelimit.worker.ts
|
|
13628
|
-
var
|
|
13629
|
-
var
|
|
13630
|
-
var
|
|
13631
|
-
var
|
|
13912
|
+
var import_fs25 = __toESM(require("fs"));
|
|
13913
|
+
var import_path29 = __toESM(require("path"));
|
|
13914
|
+
var import_url25 = __toESM(require("url"));
|
|
13915
|
+
var contents21;
|
|
13632
13916
|
function ratelimit_worker_default() {
|
|
13633
|
-
if (
|
|
13634
|
-
const filePath =
|
|
13635
|
-
|
|
13636
|
-
return
|
|
13917
|
+
if (contents21 !== void 0) return contents21;
|
|
13918
|
+
const filePath = import_path29.default.join(__dirname, "workers", "ratelimit/ratelimit.worker.js");
|
|
13919
|
+
contents21 = import_fs25.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url25.default.pathToFileURL(filePath);
|
|
13920
|
+
return contents21;
|
|
13637
13921
|
}
|
|
13638
13922
|
|
|
13639
13923
|
// src/plugins/ratelimit/index.ts
|
|
13640
|
-
var
|
|
13924
|
+
var import_zod22 = require("zod");
|
|
13641
13925
|
var PeriodType = /* @__PURE__ */ ((PeriodType2) => {
|
|
13642
13926
|
PeriodType2[PeriodType2["TENSECONDS"] = 10] = "TENSECONDS";
|
|
13643
13927
|
PeriodType2[PeriodType2["MINUTE"] = 60] = "MINUTE";
|
|
13644
13928
|
return PeriodType2;
|
|
13645
13929
|
})(PeriodType || {});
|
|
13646
|
-
var RatelimitConfigSchema =
|
|
13647
|
-
simple:
|
|
13648
|
-
limit:
|
|
13930
|
+
var RatelimitConfigSchema = import_zod22.z.object({
|
|
13931
|
+
simple: import_zod22.z.object({
|
|
13932
|
+
limit: import_zod22.z.number().gt(0),
|
|
13649
13933
|
// may relax this to be any number in the future
|
|
13650
|
-
period:
|
|
13934
|
+
period: import_zod22.z.nativeEnum(PeriodType).optional()
|
|
13651
13935
|
})
|
|
13652
13936
|
});
|
|
13653
|
-
var RatelimitOptionsSchema =
|
|
13654
|
-
ratelimits:
|
|
13937
|
+
var RatelimitOptionsSchema = import_zod22.z.object({
|
|
13938
|
+
ratelimits: import_zod22.z.record(RatelimitConfigSchema).optional()
|
|
13655
13939
|
});
|
|
13656
13940
|
var RATELIMIT_PLUGIN_NAME = "ratelimit";
|
|
13657
13941
|
var SERVICE_RATELIMIT_PREFIX = `${RATELIMIT_PLUGIN_NAME}`;
|
|
13658
13942
|
var SERVICE_RATELIMIT_MODULE = `cloudflare-internal:${SERVICE_RATELIMIT_PREFIX}:module`;
|
|
13659
|
-
function
|
|
13943
|
+
function buildJsonBindings2(bindings) {
|
|
13660
13944
|
return Object.entries(bindings).map(([name, value]) => ({
|
|
13661
13945
|
name,
|
|
13662
13946
|
json: JSON.stringify(value)
|
|
@@ -13673,7 +13957,7 @@ var RATELIMIT_PLUGIN = {
|
|
|
13673
13957
|
name,
|
|
13674
13958
|
wrapped: {
|
|
13675
13959
|
moduleName: SERVICE_RATELIMIT_MODULE,
|
|
13676
|
-
innerBindings:
|
|
13960
|
+
innerBindings: buildJsonBindings2({
|
|
13677
13961
|
namespaceId: name,
|
|
13678
13962
|
limit: config.simple.limit,
|
|
13679
13963
|
period: config.simple.period
|
|
@@ -13715,33 +13999,164 @@ var RATELIMIT_PLUGIN = {
|
|
|
13715
13999
|
}
|
|
13716
14000
|
};
|
|
13717
14001
|
|
|
14002
|
+
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/secrets-store/secret.worker.ts
|
|
14003
|
+
var import_fs26 = __toESM(require("fs"));
|
|
14004
|
+
var import_path30 = __toESM(require("path"));
|
|
14005
|
+
var import_url26 = __toESM(require("url"));
|
|
14006
|
+
var contents22;
|
|
14007
|
+
function secret_worker_default() {
|
|
14008
|
+
if (contents22 !== void 0) return contents22;
|
|
14009
|
+
const filePath = import_path30.default.join(__dirname, "workers", "secrets-store/secret.worker.js");
|
|
14010
|
+
contents22 = import_fs26.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url26.default.pathToFileURL(filePath);
|
|
14011
|
+
return contents22;
|
|
14012
|
+
}
|
|
14013
|
+
|
|
14014
|
+
// src/plugins/secret-store/index.ts
|
|
14015
|
+
var import_zod23 = require("zod");
|
|
14016
|
+
var SecretsStoreSecretsSchema = import_zod23.z.record(
|
|
14017
|
+
import_zod23.z.object({
|
|
14018
|
+
store_id: import_zod23.z.string(),
|
|
14019
|
+
secret_name: import_zod23.z.string()
|
|
14020
|
+
})
|
|
14021
|
+
);
|
|
14022
|
+
var SecretsStoreSecretsOptionsSchema = import_zod23.z.object({
|
|
14023
|
+
secretsStoreSecrets: SecretsStoreSecretsSchema.optional()
|
|
14024
|
+
});
|
|
14025
|
+
var SecretsStoreSecretsSharedOptionsSchema = import_zod23.z.object({
|
|
14026
|
+
secretsStorePersist: PersistenceSchema
|
|
14027
|
+
});
|
|
14028
|
+
var SECRET_STORE_PLUGIN_NAME = "secrets-store";
|
|
14029
|
+
function getkvNamespacesOptions(secretsStoreSecrets) {
|
|
14030
|
+
const storeIds = new Set(
|
|
14031
|
+
Object.values(secretsStoreSecrets).map((store) => store.store_id)
|
|
14032
|
+
);
|
|
14033
|
+
const storeIdKvNamespaceEntries = Array.from(storeIds).map((storeId) => [
|
|
14034
|
+
storeId,
|
|
14035
|
+
`${SECRET_STORE_PLUGIN_NAME}:${storeId}`
|
|
14036
|
+
]);
|
|
14037
|
+
return {
|
|
14038
|
+
kvNamespaces: Object.fromEntries(storeIdKvNamespaceEntries)
|
|
14039
|
+
};
|
|
14040
|
+
}
|
|
14041
|
+
function isKvBinding(binding) {
|
|
14042
|
+
return "kvNamespace" in binding;
|
|
14043
|
+
}
|
|
14044
|
+
var SECRET_STORE_PLUGIN = {
|
|
14045
|
+
options: SecretsStoreSecretsOptionsSchema,
|
|
14046
|
+
sharedOptions: SecretsStoreSecretsSharedOptionsSchema,
|
|
14047
|
+
async getBindings(options) {
|
|
14048
|
+
if (!options.secretsStoreSecrets) {
|
|
14049
|
+
return [];
|
|
14050
|
+
}
|
|
14051
|
+
const bindings = Object.entries(
|
|
14052
|
+
options.secretsStoreSecrets
|
|
14053
|
+
).map(([name, config]) => {
|
|
14054
|
+
return {
|
|
14055
|
+
name,
|
|
14056
|
+
service: {
|
|
14057
|
+
name: `${SECRET_STORE_PLUGIN_NAME}:${config.store_id}:${config.secret_name}`,
|
|
14058
|
+
entrypoint: "SecretsStoreSecret"
|
|
14059
|
+
}
|
|
14060
|
+
};
|
|
14061
|
+
});
|
|
14062
|
+
return bindings;
|
|
14063
|
+
},
|
|
14064
|
+
getNodeBindings(options) {
|
|
14065
|
+
if (!options.secretsStoreSecrets) {
|
|
14066
|
+
return {};
|
|
14067
|
+
}
|
|
14068
|
+
return Object.fromEntries(
|
|
14069
|
+
Object.keys(options.secretsStoreSecrets).map((name) => [
|
|
14070
|
+
name,
|
|
14071
|
+
new ProxyNodeBinding()
|
|
14072
|
+
])
|
|
14073
|
+
);
|
|
14074
|
+
},
|
|
14075
|
+
async getServices({ options, sharedOptions, ...restOptions }) {
|
|
14076
|
+
if (!options.secretsStoreSecrets) {
|
|
14077
|
+
return [];
|
|
14078
|
+
}
|
|
14079
|
+
const kvServices = await KV_PLUGIN.getServices({
|
|
14080
|
+
options: getkvNamespacesOptions(options.secretsStoreSecrets),
|
|
14081
|
+
sharedOptions: {
|
|
14082
|
+
kvPersist: sharedOptions.secretsStorePersist
|
|
14083
|
+
},
|
|
14084
|
+
...restOptions
|
|
14085
|
+
});
|
|
14086
|
+
const kvBindings = await KV_PLUGIN.getBindings(
|
|
14087
|
+
getkvNamespacesOptions(options.secretsStoreSecrets),
|
|
14088
|
+
restOptions.workerIndex
|
|
14089
|
+
);
|
|
14090
|
+
if (!kvBindings || !kvBindings.every(isKvBinding)) {
|
|
14091
|
+
throw new Error(
|
|
14092
|
+
"Expected KV plugin to return bindings with kvNamespace defined"
|
|
14093
|
+
);
|
|
14094
|
+
}
|
|
14095
|
+
if (!Array.isArray(kvServices)) {
|
|
14096
|
+
throw new Error("Expected KV plugin to return an array of services");
|
|
14097
|
+
}
|
|
14098
|
+
return [
|
|
14099
|
+
...kvServices,
|
|
14100
|
+
...Object.entries(options.secretsStoreSecrets).map(
|
|
14101
|
+
([_, config]) => {
|
|
14102
|
+
return {
|
|
14103
|
+
name: `${SECRET_STORE_PLUGIN_NAME}:${config.store_id}:${config.secret_name}`,
|
|
14104
|
+
worker: {
|
|
14105
|
+
compatibilityDate: "2025-01-01",
|
|
14106
|
+
modules: [
|
|
14107
|
+
{
|
|
14108
|
+
name: "secret.worker.js",
|
|
14109
|
+
esModule: secret_worker_default()
|
|
14110
|
+
}
|
|
14111
|
+
],
|
|
14112
|
+
bindings: [
|
|
14113
|
+
{
|
|
14114
|
+
name: "store",
|
|
14115
|
+
kvNamespace: kvBindings.find(
|
|
14116
|
+
// Look up the corresponding KV namespace for the store id
|
|
14117
|
+
(binding) => binding.name === config.store_id
|
|
14118
|
+
)?.kvNamespace
|
|
14119
|
+
},
|
|
14120
|
+
{
|
|
14121
|
+
name: "secret_name",
|
|
14122
|
+
json: JSON.stringify(config.secret_name)
|
|
14123
|
+
}
|
|
14124
|
+
]
|
|
14125
|
+
}
|
|
14126
|
+
};
|
|
14127
|
+
}
|
|
14128
|
+
)
|
|
14129
|
+
];
|
|
14130
|
+
}
|
|
14131
|
+
};
|
|
14132
|
+
|
|
13718
14133
|
// src/plugins/workflows/index.ts
|
|
13719
14134
|
var import_promises12 = __toESM(require("fs/promises"));
|
|
13720
14135
|
|
|
13721
14136
|
// embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/miniflare/src/workers/workflows/binding.worker.ts
|
|
13722
|
-
var
|
|
13723
|
-
var
|
|
13724
|
-
var
|
|
13725
|
-
var
|
|
14137
|
+
var import_fs27 = __toESM(require("fs"));
|
|
14138
|
+
var import_path31 = __toESM(require("path"));
|
|
14139
|
+
var import_url27 = __toESM(require("url"));
|
|
14140
|
+
var contents23;
|
|
13726
14141
|
function binding_worker_default() {
|
|
13727
|
-
if (
|
|
13728
|
-
const filePath =
|
|
13729
|
-
|
|
13730
|
-
return
|
|
14142
|
+
if (contents23 !== void 0) return contents23;
|
|
14143
|
+
const filePath = import_path31.default.join(__dirname, "workers", "workflows/binding.worker.js");
|
|
14144
|
+
contents23 = import_fs27.default.readFileSync(filePath, "utf8") + "//# sourceURL=" + import_url27.default.pathToFileURL(filePath);
|
|
14145
|
+
return contents23;
|
|
13731
14146
|
}
|
|
13732
14147
|
|
|
13733
14148
|
// src/plugins/workflows/index.ts
|
|
13734
|
-
var
|
|
13735
|
-
var WorkflowsOptionsSchema =
|
|
13736
|
-
workflows:
|
|
13737
|
-
|
|
13738
|
-
name:
|
|
13739
|
-
className:
|
|
13740
|
-
scriptName:
|
|
14149
|
+
var import_zod24 = require("zod");
|
|
14150
|
+
var WorkflowsOptionsSchema = import_zod24.z.object({
|
|
14151
|
+
workflows: import_zod24.z.record(
|
|
14152
|
+
import_zod24.z.object({
|
|
14153
|
+
name: import_zod24.z.string(),
|
|
14154
|
+
className: import_zod24.z.string(),
|
|
14155
|
+
scriptName: import_zod24.z.string().optional()
|
|
13741
14156
|
})
|
|
13742
14157
|
).optional()
|
|
13743
14158
|
});
|
|
13744
|
-
var WorkflowsSharedOptionsSchema =
|
|
14159
|
+
var WorkflowsSharedOptionsSchema = import_zod24.z.object({
|
|
13745
14160
|
workflowsPersist: PersistenceSchema
|
|
13746
14161
|
});
|
|
13747
14162
|
var WORKFLOWS_PLUGIN_NAME = "workflows";
|
|
@@ -13846,10 +14261,447 @@ var PLUGINS = {
|
|
|
13846
14261
|
[RATELIMIT_PLUGIN_NAME]: RATELIMIT_PLUGIN,
|
|
13847
14262
|
[ASSETS_PLUGIN_NAME]: ASSETS_PLUGIN,
|
|
13848
14263
|
[WORKFLOWS_PLUGIN_NAME]: WORKFLOWS_PLUGIN,
|
|
13849
|
-
[PIPELINES_PLUGIN_NAME]: PIPELINE_PLUGIN
|
|
14264
|
+
[PIPELINES_PLUGIN_NAME]: PIPELINE_PLUGIN,
|
|
14265
|
+
[SECRET_STORE_PLUGIN_NAME]: SECRET_STORE_PLUGIN,
|
|
14266
|
+
[EMAIL_PLUGIN_NAME]: EMAIL_PLUGIN,
|
|
14267
|
+
[ANALYTICS_ENGINE_PLUGIN_NAME]: ANALYTICS_ENGINE_PLUGIN
|
|
13850
14268
|
};
|
|
13851
14269
|
var PLUGIN_ENTRIES = Object.entries(PLUGINS);
|
|
13852
14270
|
|
|
14271
|
+
// src/plugins/core/inspector-proxy/inspector-proxy-controller.ts
|
|
14272
|
+
var import_node_crypto2 = __toESM(require("node:crypto"));
|
|
14273
|
+
var import_node_http = require("node:http");
|
|
14274
|
+
|
|
14275
|
+
// ../../node_modules/.pnpm/get-port@7.1.0/node_modules/get-port/index.js
|
|
14276
|
+
var import_node_net = __toESM(require("node:net"), 1);
|
|
14277
|
+
var import_node_os = __toESM(require("node:os"), 1);
|
|
14278
|
+
var Locked = class extends Error {
|
|
14279
|
+
constructor(port) {
|
|
14280
|
+
super(`${port} is locked`);
|
|
14281
|
+
}
|
|
14282
|
+
};
|
|
14283
|
+
var lockedPorts = {
|
|
14284
|
+
old: /* @__PURE__ */ new Set(),
|
|
14285
|
+
young: /* @__PURE__ */ new Set()
|
|
14286
|
+
};
|
|
14287
|
+
var releaseOldLockedPortsIntervalMs = 1e3 * 15;
|
|
14288
|
+
var timeout;
|
|
14289
|
+
var getLocalHosts = () => {
|
|
14290
|
+
const interfaces = import_node_os.default.networkInterfaces();
|
|
14291
|
+
const results = /* @__PURE__ */ new Set([void 0, "0.0.0.0"]);
|
|
14292
|
+
for (const _interface of Object.values(interfaces)) {
|
|
14293
|
+
for (const config of _interface) {
|
|
14294
|
+
results.add(config.address);
|
|
14295
|
+
}
|
|
14296
|
+
}
|
|
14297
|
+
return results;
|
|
14298
|
+
};
|
|
14299
|
+
var checkAvailablePort = (options) => new Promise((resolve2, reject) => {
|
|
14300
|
+
const server = import_node_net.default.createServer();
|
|
14301
|
+
server.unref();
|
|
14302
|
+
server.on("error", reject);
|
|
14303
|
+
server.listen(options, () => {
|
|
14304
|
+
const { port } = server.address();
|
|
14305
|
+
server.close(() => {
|
|
14306
|
+
resolve2(port);
|
|
14307
|
+
});
|
|
14308
|
+
});
|
|
14309
|
+
});
|
|
14310
|
+
var getAvailablePort = async (options, hosts) => {
|
|
14311
|
+
if (options.host || options.port === 0) {
|
|
14312
|
+
return checkAvailablePort(options);
|
|
14313
|
+
}
|
|
14314
|
+
for (const host of hosts) {
|
|
14315
|
+
try {
|
|
14316
|
+
await checkAvailablePort({ port: options.port, host });
|
|
14317
|
+
} catch (error) {
|
|
14318
|
+
if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
|
|
14319
|
+
throw error;
|
|
14320
|
+
}
|
|
14321
|
+
}
|
|
14322
|
+
}
|
|
14323
|
+
return options.port;
|
|
14324
|
+
};
|
|
14325
|
+
var portCheckSequence = function* (ports) {
|
|
14326
|
+
if (ports) {
|
|
14327
|
+
yield* ports;
|
|
14328
|
+
}
|
|
14329
|
+
yield 0;
|
|
14330
|
+
};
|
|
14331
|
+
async function getPorts(options) {
|
|
14332
|
+
let ports;
|
|
14333
|
+
let exclude = /* @__PURE__ */ new Set();
|
|
14334
|
+
if (options) {
|
|
14335
|
+
if (options.port) {
|
|
14336
|
+
ports = typeof options.port === "number" ? [options.port] : options.port;
|
|
14337
|
+
}
|
|
14338
|
+
if (options.exclude) {
|
|
14339
|
+
const excludeIterable = options.exclude;
|
|
14340
|
+
if (typeof excludeIterable[Symbol.iterator] !== "function") {
|
|
14341
|
+
throw new TypeError("The `exclude` option must be an iterable.");
|
|
14342
|
+
}
|
|
14343
|
+
for (const element of excludeIterable) {
|
|
14344
|
+
if (typeof element !== "number") {
|
|
14345
|
+
throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
|
|
14346
|
+
}
|
|
14347
|
+
if (!Number.isSafeInteger(element)) {
|
|
14348
|
+
throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
|
|
14349
|
+
}
|
|
14350
|
+
}
|
|
14351
|
+
exclude = new Set(excludeIterable);
|
|
14352
|
+
}
|
|
14353
|
+
}
|
|
14354
|
+
if (timeout === void 0) {
|
|
14355
|
+
timeout = setTimeout(() => {
|
|
14356
|
+
timeout = void 0;
|
|
14357
|
+
lockedPorts.old = lockedPorts.young;
|
|
14358
|
+
lockedPorts.young = /* @__PURE__ */ new Set();
|
|
14359
|
+
}, releaseOldLockedPortsIntervalMs);
|
|
14360
|
+
if (timeout.unref) {
|
|
14361
|
+
timeout.unref();
|
|
14362
|
+
}
|
|
14363
|
+
}
|
|
14364
|
+
const hosts = getLocalHosts();
|
|
14365
|
+
for (const port of portCheckSequence(ports)) {
|
|
14366
|
+
try {
|
|
14367
|
+
if (exclude.has(port)) {
|
|
14368
|
+
continue;
|
|
14369
|
+
}
|
|
14370
|
+
let availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
14371
|
+
while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
|
|
14372
|
+
if (port !== 0) {
|
|
14373
|
+
throw new Locked(port);
|
|
14374
|
+
}
|
|
14375
|
+
availablePort = await getAvailablePort({ ...options, port }, hosts);
|
|
14376
|
+
}
|
|
14377
|
+
lockedPorts.young.add(availablePort);
|
|
14378
|
+
return availablePort;
|
|
14379
|
+
} catch (error) {
|
|
14380
|
+
if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
|
|
14381
|
+
throw error;
|
|
14382
|
+
}
|
|
14383
|
+
}
|
|
14384
|
+
}
|
|
14385
|
+
throw new Error("No available ports found");
|
|
14386
|
+
}
|
|
14387
|
+
|
|
14388
|
+
// src/plugins/core/inspector-proxy/inspector-proxy-controller.ts
|
|
14389
|
+
var import_ws4 = __toESM(require("ws"));
|
|
14390
|
+
|
|
14391
|
+
// package.json
|
|
14392
|
+
var version = "0.0.0-e55f489db";
|
|
14393
|
+
|
|
14394
|
+
// src/plugins/core/inspector-proxy/inspector-proxy.ts
|
|
14395
|
+
var import_node_assert4 = __toESM(require("node:assert"));
|
|
14396
|
+
var import_ws3 = __toESM(require("ws"));
|
|
14397
|
+
|
|
14398
|
+
// src/plugins/core/inspector-proxy/devtools.ts
|
|
14399
|
+
function isDevToolsEvent(event, name) {
|
|
14400
|
+
return typeof event === "object" && event !== null && "method" in event && event.method === name;
|
|
14401
|
+
}
|
|
14402
|
+
|
|
14403
|
+
// src/plugins/core/inspector-proxy/inspector-proxy.ts
|
|
14404
|
+
var InspectorProxy = class {
|
|
14405
|
+
#workerName;
|
|
14406
|
+
#runtimeWs;
|
|
14407
|
+
#devtoolsWs;
|
|
14408
|
+
#devtoolsHaveFileSystemAccess = false;
|
|
14409
|
+
constructor(workerName, runtimeWs) {
|
|
14410
|
+
this.#workerName = workerName;
|
|
14411
|
+
this.#runtimeWs = runtimeWs;
|
|
14412
|
+
this.#runtimeWs.once("open", () => this.#handleRuntimeWebSocketOpen());
|
|
14413
|
+
}
|
|
14414
|
+
get workerName() {
|
|
14415
|
+
return this.#workerName;
|
|
14416
|
+
}
|
|
14417
|
+
get path() {
|
|
14418
|
+
return `/${this.#workerName}`;
|
|
14419
|
+
}
|
|
14420
|
+
onDevtoolsConnected(devtoolsWs, devtoolsHaveFileSystemAccess) {
|
|
14421
|
+
if (this.#devtoolsWs) {
|
|
14422
|
+
devtoolsWs.close(
|
|
14423
|
+
1013,
|
|
14424
|
+
"Too many clients; only one can be connected at a time"
|
|
14425
|
+
);
|
|
14426
|
+
return;
|
|
14427
|
+
}
|
|
14428
|
+
this.#devtoolsWs = devtoolsWs;
|
|
14429
|
+
this.#devtoolsHaveFileSystemAccess = devtoolsHaveFileSystemAccess;
|
|
14430
|
+
(0, import_node_assert4.default)(this.#devtoolsWs?.readyState === import_ws3.default.OPEN);
|
|
14431
|
+
this.#devtoolsWs.on("error", console.error);
|
|
14432
|
+
this.#devtoolsWs.once("close", () => {
|
|
14433
|
+
if (this.#runtimeWs?.OPEN) {
|
|
14434
|
+
this.#sendMessageToRuntime({
|
|
14435
|
+
method: "Debugger.disable",
|
|
14436
|
+
id: this.#nextCounter()
|
|
14437
|
+
});
|
|
14438
|
+
}
|
|
14439
|
+
this.#devtoolsWs = void 0;
|
|
14440
|
+
});
|
|
14441
|
+
this.#devtoolsWs.on("message", (data) => {
|
|
14442
|
+
const message = JSON.parse(data.toString());
|
|
14443
|
+
(0, import_node_assert4.default)(this.#runtimeWs?.OPEN);
|
|
14444
|
+
this.#sendMessageToRuntime(message);
|
|
14445
|
+
});
|
|
14446
|
+
}
|
|
14447
|
+
#runtimeMessageCounter = 1e8;
|
|
14448
|
+
#nextCounter() {
|
|
14449
|
+
return ++this.#runtimeMessageCounter;
|
|
14450
|
+
}
|
|
14451
|
+
#runtimeKeepAliveInterval;
|
|
14452
|
+
#handleRuntimeWebSocketOpen() {
|
|
14453
|
+
(0, import_node_assert4.default)(this.#runtimeWs?.OPEN);
|
|
14454
|
+
this.#runtimeWs.on("message", (data) => {
|
|
14455
|
+
const message = JSON.parse(data.toString());
|
|
14456
|
+
if (!this.#devtoolsWs) {
|
|
14457
|
+
return;
|
|
14458
|
+
}
|
|
14459
|
+
if (isDevToolsEvent(message, "Debugger.scriptParsed")) {
|
|
14460
|
+
return this.#handleRuntimeScriptParsed(message);
|
|
14461
|
+
}
|
|
14462
|
+
return this.#sendMessageToDevtools(message);
|
|
14463
|
+
});
|
|
14464
|
+
clearInterval(this.#runtimeKeepAliveInterval);
|
|
14465
|
+
this.#runtimeKeepAliveInterval = setInterval(() => {
|
|
14466
|
+
if (this.#runtimeWs?.OPEN) {
|
|
14467
|
+
this.#sendMessageToRuntime({
|
|
14468
|
+
method: "Runtime.getIsolateId",
|
|
14469
|
+
id: this.#nextCounter()
|
|
14470
|
+
});
|
|
14471
|
+
}
|
|
14472
|
+
}, 1e4);
|
|
14473
|
+
}
|
|
14474
|
+
#handleRuntimeScriptParsed(message) {
|
|
14475
|
+
if (!this.#devtoolsHaveFileSystemAccess && message.params.sourceMapURL !== void 0 && // Don't try to find a sourcemap for e.g. node-internal: scripts
|
|
14476
|
+
message.params.url.startsWith("file:")) {
|
|
14477
|
+
const url24 = new URL(message.params.sourceMapURL, message.params.url);
|
|
14478
|
+
if (url24.protocol === "file:") {
|
|
14479
|
+
message.params.sourceMapURL = url24.href.replace(
|
|
14480
|
+
"file:",
|
|
14481
|
+
"wrangler-file:"
|
|
14482
|
+
);
|
|
14483
|
+
}
|
|
14484
|
+
}
|
|
14485
|
+
return this.#sendMessageToDevtools(message);
|
|
14486
|
+
}
|
|
14487
|
+
#sendMessageToDevtools(message) {
|
|
14488
|
+
(0, import_node_assert4.default)(this.#devtoolsWs);
|
|
14489
|
+
if (!this.#devtoolsWs.OPEN) {
|
|
14490
|
+
this.#devtoolsWs.once(
|
|
14491
|
+
"open",
|
|
14492
|
+
() => this.#devtoolsWs?.send(JSON.stringify(message))
|
|
14493
|
+
);
|
|
14494
|
+
return;
|
|
14495
|
+
}
|
|
14496
|
+
this.#devtoolsWs.send(JSON.stringify(message));
|
|
14497
|
+
}
|
|
14498
|
+
#sendMessageToRuntime(message) {
|
|
14499
|
+
(0, import_node_assert4.default)(this.#runtimeWs?.OPEN);
|
|
14500
|
+
this.#runtimeWs.send(JSON.stringify(message));
|
|
14501
|
+
}
|
|
14502
|
+
async dispose() {
|
|
14503
|
+
clearInterval(this.#runtimeKeepAliveInterval);
|
|
14504
|
+
this.#devtoolsWs?.close();
|
|
14505
|
+
}
|
|
14506
|
+
};
|
|
14507
|
+
|
|
14508
|
+
// src/plugins/core/inspector-proxy/inspector-proxy-controller.ts
|
|
14509
|
+
var InspectorProxyController = class {
|
|
14510
|
+
constructor(inspectorPortOption, log, workerNamesToProxy) {
|
|
14511
|
+
this.inspectorPortOption = inspectorPortOption;
|
|
14512
|
+
this.log = log;
|
|
14513
|
+
this.workerNamesToProxy = workerNamesToProxy;
|
|
14514
|
+
this.#inspectorPort = this.#getInspectorPortToUse();
|
|
14515
|
+
this.#server = this.#initializeServer();
|
|
14516
|
+
this.#runtimeConnectionEstablished = new DeferredPromise();
|
|
14517
|
+
}
|
|
14518
|
+
#runtimeConnectionEstablished;
|
|
14519
|
+
#proxies = [];
|
|
14520
|
+
#server;
|
|
14521
|
+
#inspectorPort;
|
|
14522
|
+
async #getInspectorPortToUse() {
|
|
14523
|
+
return this.inspectorPortOption !== 0 ? this.inspectorPortOption : await getPorts();
|
|
14524
|
+
}
|
|
14525
|
+
async #initializeServer() {
|
|
14526
|
+
const server = (0, import_node_http.createServer)(async (req, res) => {
|
|
14527
|
+
const maybeJson = await this.#handleDevToolsJsonRequest(
|
|
14528
|
+
req.headers.host ?? "localhost",
|
|
14529
|
+
req.url ?? "/"
|
|
14530
|
+
);
|
|
14531
|
+
if (maybeJson !== null) {
|
|
14532
|
+
res.setHeader("Content-Type", "application/json");
|
|
14533
|
+
res.end(JSON.stringify(maybeJson));
|
|
14534
|
+
return;
|
|
14535
|
+
}
|
|
14536
|
+
res.statusCode = 404;
|
|
14537
|
+
res.end(null);
|
|
14538
|
+
});
|
|
14539
|
+
this.#initializeWebSocketServer(server);
|
|
14540
|
+
const listeningPromise = new Promise(
|
|
14541
|
+
(resolve2) => server.once("listening", resolve2)
|
|
14542
|
+
);
|
|
14543
|
+
server.listen(await this.#inspectorPort);
|
|
14544
|
+
await listeningPromise;
|
|
14545
|
+
return server;
|
|
14546
|
+
}
|
|
14547
|
+
async #restartServer() {
|
|
14548
|
+
const server = await this.#server;
|
|
14549
|
+
server.closeAllConnections();
|
|
14550
|
+
await new Promise((resolve2, reject) => {
|
|
14551
|
+
server.close((err) => err ? reject(err) : resolve2());
|
|
14552
|
+
});
|
|
14553
|
+
const listeningPromise = new Promise(
|
|
14554
|
+
(resolve2) => server.once("listening", resolve2)
|
|
14555
|
+
);
|
|
14556
|
+
server.listen(await this.#inspectorPort);
|
|
14557
|
+
await listeningPromise;
|
|
14558
|
+
}
|
|
14559
|
+
#initializeWebSocketServer(server) {
|
|
14560
|
+
const devtoolsWebSocketServer = new import_ws4.WebSocketServer({ server });
|
|
14561
|
+
devtoolsWebSocketServer.on("connection", (devtoolsWs, upgradeRequest) => {
|
|
14562
|
+
const validationError = this.#validateDevToolsWebSocketUpgradeRequest(upgradeRequest);
|
|
14563
|
+
if (validationError !== null) {
|
|
14564
|
+
devtoolsWs.close();
|
|
14565
|
+
return;
|
|
14566
|
+
}
|
|
14567
|
+
const proxy = this.#proxies.find(
|
|
14568
|
+
({ path: path34 }) => upgradeRequest.url === path34
|
|
14569
|
+
);
|
|
14570
|
+
if (!proxy) {
|
|
14571
|
+
this.log.warn(
|
|
14572
|
+
`Warning: An inspector connection was requested for the ${upgradeRequest.url} path but no such inspector exists`
|
|
14573
|
+
);
|
|
14574
|
+
devtoolsWs.close();
|
|
14575
|
+
return;
|
|
14576
|
+
}
|
|
14577
|
+
proxy.onDevtoolsConnected(
|
|
14578
|
+
devtoolsWs,
|
|
14579
|
+
this.#checkIfDevtoolsHaveFileSystemAccess(upgradeRequest)
|
|
14580
|
+
);
|
|
14581
|
+
});
|
|
14582
|
+
}
|
|
14583
|
+
#validateDevToolsWebSocketUpgradeRequest(req) {
|
|
14584
|
+
const hostHeader = req.headers.host;
|
|
14585
|
+
if (hostHeader == null) return { statusText: null, status: 400 };
|
|
14586
|
+
try {
|
|
14587
|
+
const host = new URL(`http://${hostHeader}`);
|
|
14588
|
+
if (!ALLOWED_HOST_HOSTNAMES.includes(host.hostname)) {
|
|
14589
|
+
return { statusText: "Disallowed `Host` header", status: 401 };
|
|
14590
|
+
}
|
|
14591
|
+
} catch {
|
|
14592
|
+
return { statusText: "Expected `Host` header", status: 400 };
|
|
14593
|
+
}
|
|
14594
|
+
let originHeader = req.headers.origin;
|
|
14595
|
+
if (!originHeader && !req.headers["user-agent"]) {
|
|
14596
|
+
originHeader = "http://localhost";
|
|
14597
|
+
}
|
|
14598
|
+
if (!originHeader) {
|
|
14599
|
+
return { statusText: "Expected `Origin` header", status: 400 };
|
|
14600
|
+
}
|
|
14601
|
+
try {
|
|
14602
|
+
const origin = new URL(originHeader);
|
|
14603
|
+
const allowed = ALLOWED_ORIGIN_HOSTNAMES.some((rule) => {
|
|
14604
|
+
if (typeof rule === "string") return origin.hostname === rule;
|
|
14605
|
+
else return rule.test(origin.hostname);
|
|
14606
|
+
});
|
|
14607
|
+
if (!allowed) {
|
|
14608
|
+
return { statusText: "Disallowed `Origin` header", status: 401 };
|
|
14609
|
+
}
|
|
14610
|
+
} catch {
|
|
14611
|
+
return { statusText: "Expected `Origin` header", status: 400 };
|
|
14612
|
+
}
|
|
14613
|
+
return null;
|
|
14614
|
+
}
|
|
14615
|
+
#checkIfDevtoolsHaveFileSystemAccess(req) {
|
|
14616
|
+
const userAgent = req.headers["user-agent"] ?? "";
|
|
14617
|
+
const hasFileSystemAccess = !/mozilla/i.test(userAgent);
|
|
14618
|
+
return hasFileSystemAccess;
|
|
14619
|
+
}
|
|
14620
|
+
#inspectorId = import_node_crypto2.default.randomUUID();
|
|
14621
|
+
async #handleDevToolsJsonRequest(host, path34) {
|
|
14622
|
+
if (path34 === "/json/version") {
|
|
14623
|
+
return {
|
|
14624
|
+
Browser: `miniflare/v${version}`,
|
|
14625
|
+
// TODO: (someday): The DevTools protocol should match that of workerd.
|
|
14626
|
+
// This could be exposed by the preview API.
|
|
14627
|
+
"Protocol-Version": "1.3"
|
|
14628
|
+
};
|
|
14629
|
+
}
|
|
14630
|
+
if (path34 === "/json" || path34 === "/json/list") {
|
|
14631
|
+
return this.#proxies.map(({ workerName }) => {
|
|
14632
|
+
const localHost = `${host}/${workerName}`;
|
|
14633
|
+
const devtoolsFrontendUrl = `https://devtools.devprod.cloudflare.dev/js_app?theme=systemPreferred&debugger=true&ws=${localHost}`;
|
|
14634
|
+
return {
|
|
14635
|
+
id: `${this.#inspectorId}-${workerName}`,
|
|
14636
|
+
type: "node",
|
|
14637
|
+
// TODO: can we specify different type?
|
|
14638
|
+
description: "workers",
|
|
14639
|
+
webSocketDebuggerUrl: `ws://${localHost}`,
|
|
14640
|
+
devtoolsFrontendUrl,
|
|
14641
|
+
devtoolsFrontendUrlCompat: devtoolsFrontendUrl,
|
|
14642
|
+
// Below are fields that are visible in the DevTools UI.
|
|
14643
|
+
title: workerName.length === 0 || this.#proxies.length === 1 ? `Cloudflare Worker` : `Cloudflare Worker: ${workerName}`,
|
|
14644
|
+
faviconUrl: "https://workers.cloudflare.com/favicon.ico"
|
|
14645
|
+
// url: "http://" + localHost, // looks unnecessary
|
|
14646
|
+
};
|
|
14647
|
+
});
|
|
14648
|
+
}
|
|
14649
|
+
return null;
|
|
14650
|
+
}
|
|
14651
|
+
async getInspectorURL() {
|
|
14652
|
+
return getWebsocketURL(await this.#inspectorPort);
|
|
14653
|
+
}
|
|
14654
|
+
async updateConnection(inspectorPortOption, runtimeInspectorPort) {
|
|
14655
|
+
if (this.inspectorPortOption !== inspectorPortOption) {
|
|
14656
|
+
this.inspectorPortOption = inspectorPortOption;
|
|
14657
|
+
this.#inspectorPort = this.#getInspectorPortToUse();
|
|
14658
|
+
await this.#restartServer();
|
|
14659
|
+
}
|
|
14660
|
+
const workerdInspectorJson = await fetch(
|
|
14661
|
+
`http://127.0.0.1:${runtimeInspectorPort}/json`
|
|
14662
|
+
).then((resp) => resp.json());
|
|
14663
|
+
this.#proxies = workerdInspectorJson.map(({ id }) => {
|
|
14664
|
+
if (!id.startsWith("core:user:")) {
|
|
14665
|
+
return;
|
|
14666
|
+
}
|
|
14667
|
+
const workerName = id.replace(/^core:user:/, "");
|
|
14668
|
+
if (!this.workerNamesToProxy.has(workerName)) {
|
|
14669
|
+
return;
|
|
14670
|
+
}
|
|
14671
|
+
return new InspectorProxy(
|
|
14672
|
+
workerName,
|
|
14673
|
+
new import_ws4.default(`ws://127.0.0.1:${runtimeInspectorPort}/${id}`)
|
|
14674
|
+
);
|
|
14675
|
+
}).filter(Boolean);
|
|
14676
|
+
this.#runtimeConnectionEstablished.resolve();
|
|
14677
|
+
}
|
|
14678
|
+
async #waitForReady() {
|
|
14679
|
+
await this.#runtimeConnectionEstablished;
|
|
14680
|
+
}
|
|
14681
|
+
get ready() {
|
|
14682
|
+
return this.#waitForReady();
|
|
14683
|
+
}
|
|
14684
|
+
async dispose() {
|
|
14685
|
+
await Promise.all(this.#proxies.map((proxy) => proxy.dispose()));
|
|
14686
|
+
const server = await this.#server;
|
|
14687
|
+
return new Promise((resolve2, reject) => {
|
|
14688
|
+
server.close((err) => err ? reject(err) : resolve2());
|
|
14689
|
+
});
|
|
14690
|
+
}
|
|
14691
|
+
};
|
|
14692
|
+
function getWebsocketURL(port) {
|
|
14693
|
+
return new URL(`ws://127.0.0.1:${port}`);
|
|
14694
|
+
}
|
|
14695
|
+
var ALLOWED_HOST_HOSTNAMES = ["127.0.0.1", "[::1]", "localhost"];
|
|
14696
|
+
var ALLOWED_ORIGIN_HOSTNAMES = [
|
|
14697
|
+
"devtools.devprod.cloudflare.dev",
|
|
14698
|
+
"cloudflare-devtools.pages.dev",
|
|
14699
|
+
/^[a-z0-9]+\.cloudflare-devtools\.pages\.dev$/,
|
|
14700
|
+
"127.0.0.1",
|
|
14701
|
+
"[::1]",
|
|
14702
|
+
"localhost"
|
|
14703
|
+
];
|
|
14704
|
+
|
|
13853
14705
|
// src/shared/mime-types.ts
|
|
13854
14706
|
var compressedByCloudflareFL = /* @__PURE__ */ new Set([
|
|
13855
14707
|
// list copied from https://developers.cloudflare.com/speed/optimization/content/brotli/content-compression/#:~:text=If%20supported%20by%20visitors%E2%80%99%20web%20browsers%2C%20Cloudflare%20will%20return%20Gzip%20or%20Brotli%2Dencoded%20responses%20for%20the%20following%20content%20types%3A
|
|
@@ -13907,6 +14759,9 @@ function isCompressedByCloudflareFL(contentTypeHeader) {
|
|
|
13907
14759
|
return compressedByCloudflareFL.has(contentType);
|
|
13908
14760
|
}
|
|
13909
14761
|
|
|
14762
|
+
// src/workers/secrets-store/constants.ts
|
|
14763
|
+
var ADMIN_API = "SecretsStoreSecret::admin_api";
|
|
14764
|
+
|
|
13910
14765
|
// src/zod-format.ts
|
|
13911
14766
|
var import_assert11 = __toESM(require("assert"));
|
|
13912
14767
|
var import_util4 = __toESM(require("util"));
|
|
@@ -13945,8 +14800,8 @@ function hasMultipleDistinctMessages(issues, atDepth) {
|
|
|
13945
14800
|
}
|
|
13946
14801
|
return false;
|
|
13947
14802
|
}
|
|
13948
|
-
function annotate(groupCounts, annotated, input, issue,
|
|
13949
|
-
if (
|
|
14803
|
+
function annotate(groupCounts, annotated, input, issue, path34, groupId) {
|
|
14804
|
+
if (path34.length === 0) {
|
|
13950
14805
|
if (issue.code === "invalid_union") {
|
|
13951
14806
|
const unionIssues = issue.unionErrors.flatMap(({ issues }) => issues);
|
|
13952
14807
|
let newGroupId;
|
|
@@ -13992,7 +14847,7 @@ function annotate(groupCounts, annotated, input, issue, path30, groupId) {
|
|
|
13992
14847
|
[kGroupId]: groupId
|
|
13993
14848
|
};
|
|
13994
14849
|
}
|
|
13995
|
-
const [head, ...tail] =
|
|
14850
|
+
const [head, ...tail] = path34;
|
|
13996
14851
|
(0, import_assert11.default)(isRecord(input), "Expected object/array input for nested issue");
|
|
13997
14852
|
if (annotated === void 0) {
|
|
13998
14853
|
if (Array.isArray(input)) {
|
|
@@ -14197,7 +15052,7 @@ function validateOptions(opts) {
|
|
|
14197
15052
|
);
|
|
14198
15053
|
const sharedRootPath = multipleWorkers ? getRootPath(sharedOpts) : "";
|
|
14199
15054
|
const workerRootPaths = workerOpts.map(
|
|
14200
|
-
(opts2) =>
|
|
15055
|
+
(opts2) => import_path32.default.resolve(sharedRootPath, getRootPath(opts2))
|
|
14201
15056
|
);
|
|
14202
15057
|
try {
|
|
14203
15058
|
for (const [key, plugin] of PLUGIN_ENTRIES) {
|
|
@@ -14213,7 +15068,7 @@ function validateOptions(opts) {
|
|
|
14213
15068
|
}
|
|
14214
15069
|
}
|
|
14215
15070
|
} catch (e) {
|
|
14216
|
-
if (e instanceof
|
|
15071
|
+
if (e instanceof import_zod26.z.ZodError) {
|
|
14217
15072
|
let formatted;
|
|
14218
15073
|
try {
|
|
14219
15074
|
formatted = formatZodError(e, opts);
|
|
@@ -14589,18 +15444,45 @@ var Miniflare2 = class _Miniflare {
|
|
|
14589
15444
|
#liveReloadServer;
|
|
14590
15445
|
#webSocketServer;
|
|
14591
15446
|
#webSocketExtraHeaders;
|
|
15447
|
+
#maybeInspectorProxyController;
|
|
15448
|
+
#previousRuntimeInspectorPort;
|
|
14592
15449
|
constructor(opts) {
|
|
14593
15450
|
const [sharedOpts, workerOpts] = validateOptions(opts);
|
|
14594
15451
|
this.#sharedOpts = sharedOpts;
|
|
14595
15452
|
this.#workerOpts = workerOpts;
|
|
15453
|
+
const workerNamesToProxy = new Set(
|
|
15454
|
+
this.#workerOpts.filter(({ core: { unsafeInspectorProxy } }) => !!unsafeInspectorProxy).map((w) => w.core.name ?? "")
|
|
15455
|
+
);
|
|
15456
|
+
const enableInspectorProxy = workerNamesToProxy.size > 0;
|
|
15457
|
+
if (enableInspectorProxy) {
|
|
15458
|
+
if (this.#sharedOpts.core.inspectorPort === void 0) {
|
|
15459
|
+
throw new MiniflareCoreError(
|
|
15460
|
+
"ERR_MISSING_INSPECTOR_PROXY_PORT",
|
|
15461
|
+
"inspector proxy requested but without an inspectorPort specified"
|
|
15462
|
+
);
|
|
15463
|
+
}
|
|
15464
|
+
}
|
|
14596
15465
|
if (maybeInstanceRegistry !== void 0) {
|
|
14597
15466
|
const object = { name: "Miniflare", stack: "" };
|
|
14598
15467
|
Error.captureStackTrace(object, _Miniflare);
|
|
14599
15468
|
maybeInstanceRegistry.set(this, object.stack);
|
|
14600
15469
|
}
|
|
14601
15470
|
this.#log = this.#sharedOpts.core.log ?? new NoOpLog();
|
|
14602
|
-
|
|
14603
|
-
|
|
15471
|
+
if (enableInspectorProxy) {
|
|
15472
|
+
if (this.#sharedOpts.core.inspectorPort === void 0) {
|
|
15473
|
+
throw new MiniflareCoreError(
|
|
15474
|
+
"ERR_MISSING_INSPECTOR_PROXY_PORT",
|
|
15475
|
+
"inspector proxy requested but without an inspectorPort specified"
|
|
15476
|
+
);
|
|
15477
|
+
}
|
|
15478
|
+
this.#maybeInspectorProxyController = new InspectorProxyController(
|
|
15479
|
+
this.#sharedOpts.core.inspectorPort,
|
|
15480
|
+
this.#log,
|
|
15481
|
+
workerNamesToProxy
|
|
15482
|
+
);
|
|
15483
|
+
}
|
|
15484
|
+
this.#liveReloadServer = new import_ws5.WebSocketServer({ noServer: true });
|
|
15485
|
+
this.#webSocketServer = new import_ws5.WebSocketServer({
|
|
14604
15486
|
noServer: true,
|
|
14605
15487
|
// Disable automatic handling of `Sec-WebSocket-Protocol` header,
|
|
14606
15488
|
// Cloudflare Workers require users to include this header themselves in
|
|
@@ -14619,7 +15501,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
14619
15501
|
}
|
|
14620
15502
|
}
|
|
14621
15503
|
});
|
|
14622
|
-
this.#tmpPath =
|
|
15504
|
+
this.#tmpPath = import_path32.default.join(
|
|
14623
15505
|
import_os2.default.tmpdir(),
|
|
14624
15506
|
`miniflare-${import_crypto3.default.randomBytes(16).toString("hex")}`
|
|
14625
15507
|
);
|
|
@@ -14627,7 +15509,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
14627
15509
|
this.#removeExitHook = (0, import_exit_hook.default)(() => {
|
|
14628
15510
|
void this.#runtime?.dispose();
|
|
14629
15511
|
try {
|
|
14630
|
-
|
|
15512
|
+
import_fs28.default.rmSync(this.#tmpPath, { force: true, recursive: true });
|
|
14631
15513
|
} catch (e) {
|
|
14632
15514
|
this.#log.debug(`Unable to remove temporary directory: ${String(e)}`);
|
|
14633
15515
|
}
|
|
@@ -14664,7 +15546,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
14664
15546
|
if (!(response instanceof Response)) {
|
|
14665
15547
|
response = new Response(response.body, response);
|
|
14666
15548
|
}
|
|
14667
|
-
return
|
|
15549
|
+
return import_zod26.z.instanceof(Response).parse(response);
|
|
14668
15550
|
} catch (e) {
|
|
14669
15551
|
return new Response(e?.stack ?? e, { status: 500 });
|
|
14670
15552
|
}
|
|
@@ -14687,11 +15569,11 @@ var Miniflare2 = class _Miniflare {
|
|
|
14687
15569
|
(0, import_assert12.default)(!Array.isArray(cfBlob));
|
|
14688
15570
|
const cf = cfBlob ? JSON.parse(cfBlob) : void 0;
|
|
14689
15571
|
const originalUrl = headers.get(CoreHeaders.ORIGINAL_URL);
|
|
14690
|
-
const
|
|
15572
|
+
const url24 = new URL(originalUrl ?? req.url ?? "", "http://localhost");
|
|
14691
15573
|
headers.delete(CoreHeaders.ORIGINAL_URL);
|
|
14692
15574
|
const noBody = req.method === "GET" || req.method === "HEAD";
|
|
14693
15575
|
const body = noBody ? void 0 : safeReadableStreamFrom(req);
|
|
14694
|
-
const request = new Request(
|
|
15576
|
+
const request = new Request(url24, {
|
|
14695
15577
|
method: req.method,
|
|
14696
15578
|
headers,
|
|
14697
15579
|
body,
|
|
@@ -14712,13 +15594,13 @@ var Miniflare2 = class _Miniflare {
|
|
|
14712
15594
|
request,
|
|
14713
15595
|
this
|
|
14714
15596
|
);
|
|
14715
|
-
} else if (
|
|
15597
|
+
} else if (url24.pathname === "/core/error") {
|
|
14716
15598
|
response = await handlePrettyErrorRequest(
|
|
14717
15599
|
this.#log,
|
|
14718
15600
|
this.#workerSrcOpts,
|
|
14719
15601
|
request
|
|
14720
15602
|
);
|
|
14721
|
-
} else if (
|
|
15603
|
+
} else if (url24.pathname === "/core/log") {
|
|
14722
15604
|
const level = parseInt(request.headers.get(SharedHeaders.LOG_LEVEL));
|
|
14723
15605
|
(0, import_assert12.default)(
|
|
14724
15606
|
0 /* NONE */ <= level && level <= 5 /* VERBOSE */,
|
|
@@ -14729,6 +15611,17 @@ var Miniflare2 = class _Miniflare {
|
|
|
14729
15611
|
if (!$.enabled) message = stripAnsi(message);
|
|
14730
15612
|
this.#log.logWithLevel(logLevel, message);
|
|
14731
15613
|
response = new Response(null, { status: 204 });
|
|
15614
|
+
} else if (url24.pathname === "/core/store-temp-file") {
|
|
15615
|
+
const prefix = url24.searchParams.get("prefix");
|
|
15616
|
+
const folder = prefix ? `files/${prefix}` : "files";
|
|
15617
|
+
await (0, import_promises13.mkdir)(import_path32.default.join(this.#tmpPath, folder), { recursive: true });
|
|
15618
|
+
const filePath = import_path32.default.join(
|
|
15619
|
+
this.#tmpPath,
|
|
15620
|
+
folder,
|
|
15621
|
+
`${import_crypto3.default.randomUUID()}.${url24.searchParams.get("extension") ?? "txt"}`
|
|
15622
|
+
);
|
|
15623
|
+
await (0, import_promises13.writeFile)(filePath, await request.text());
|
|
15624
|
+
response = new Response(filePath, { status: 200 });
|
|
14732
15625
|
}
|
|
14733
15626
|
} catch (e) {
|
|
14734
15627
|
this.#log.error(e);
|
|
@@ -14911,14 +15804,13 @@ var Miniflare2 = class _Miniflare {
|
|
|
14911
15804
|
);
|
|
14912
15805
|
if (maybeAssetTargetService && !binding.service?.entrypoint) {
|
|
14913
15806
|
(0, import_assert12.default)(binding.service?.name);
|
|
14914
|
-
binding.service.name =
|
|
15807
|
+
binding.service.name = `${RPC_PROXY_SERVICE_NAME}:${targetWorkerName}`;
|
|
14915
15808
|
}
|
|
14916
15809
|
}
|
|
14917
15810
|
}
|
|
14918
15811
|
}
|
|
14919
15812
|
}
|
|
14920
15813
|
const unsafeStickyBlobs = sharedOpts.core.unsafeStickyBlobs ?? false;
|
|
14921
|
-
const unsafeEnableAssetsRpc = sharedOpts.core.unsafeEnableAssetsRpc ?? false;
|
|
14922
15814
|
const unsafeEphemeralDurableObjects = workerOpts.core.unsafeEphemeralDurableObjects ?? false;
|
|
14923
15815
|
const pluginServicesOptionsBase = {
|
|
14924
15816
|
log: this.#log,
|
|
@@ -14933,8 +15825,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
14933
15825
|
durableObjectClassNames,
|
|
14934
15826
|
unsafeEphemeralDurableObjects,
|
|
14935
15827
|
queueProducers,
|
|
14936
|
-
queueConsumers
|
|
14937
|
-
unsafeEnableAssetsRpc
|
|
15828
|
+
queueConsumers
|
|
14938
15829
|
};
|
|
14939
15830
|
for (const [key, plugin] of PLUGIN_ENTRIES) {
|
|
14940
15831
|
const pluginServicesExtensions = await plugin.getServices({
|
|
@@ -14982,13 +15873,16 @@ var Miniflare2 = class _Miniflare {
|
|
|
14982
15873
|
directSocket.host,
|
|
14983
15874
|
directSocket.port
|
|
14984
15875
|
);
|
|
15876
|
+
const service = workerOpts.assets.assets && entrypoint === "default" ? {
|
|
15877
|
+
name: `${RPC_PROXY_SERVICE_NAME}:${workerOpts.core.name}`
|
|
15878
|
+
} : {
|
|
15879
|
+
name: getUserServiceName(workerName),
|
|
15880
|
+
entrypoint: entrypoint === "default" ? void 0 : entrypoint
|
|
15881
|
+
};
|
|
14985
15882
|
sockets.push({
|
|
14986
15883
|
name,
|
|
14987
15884
|
address,
|
|
14988
|
-
service
|
|
14989
|
-
name: getUserServiceName(workerName),
|
|
14990
|
-
entrypoint: entrypoint === "default" ? void 0 : entrypoint
|
|
14991
|
-
},
|
|
15885
|
+
service,
|
|
14992
15886
|
http: {
|
|
14993
15887
|
style: directSocket.proxy ? HttpOptions_Style.PROXY : void 0,
|
|
14994
15888
|
cfBlobHeader: CoreHeaders.CF_BLOB,
|
|
@@ -15001,15 +15895,15 @@ var Miniflare2 = class _Miniflare {
|
|
|
15001
15895
|
sharedOptions: sharedOpts.core,
|
|
15002
15896
|
allWorkerRoutes,
|
|
15003
15897
|
/*
|
|
15004
|
-
* - if Workers + Assets project but NOT Vitest,
|
|
15005
|
-
*
|
|
15006
|
-
*
|
|
15007
|
-
*
|
|
15008
|
-
*
|
|
15898
|
+
* - if Workers + Assets project but NOT Vitest, the fallback Worker (see
|
|
15899
|
+
* `MINIFLARE_USER_FALLBACK`) should point to the (assets) RPC Proxy Worker
|
|
15900
|
+
* - if Vitest with assets, the fallback Worker should point to the Vitest
|
|
15901
|
+
* runner Worker, while the SELF binding on the test runner will point to
|
|
15902
|
+
* the (assets) RPC Proxy Worker
|
|
15009
15903
|
*/
|
|
15010
15904
|
fallbackWorkerName: this.#workerOpts[0].assets.assets && !this.#workerOpts[0].core.name?.startsWith(
|
|
15011
15905
|
"vitest-pool-workers-runner-"
|
|
15012
|
-
) ?
|
|
15906
|
+
) ? `${RPC_PROXY_SERVICE_NAME}:${this.#workerOpts[0].core.name}` : getUserServiceName(this.#workerOpts[0].core.name),
|
|
15013
15907
|
loopbackPort,
|
|
15014
15908
|
log: this.#log,
|
|
15015
15909
|
proxyBindings
|
|
@@ -15060,14 +15954,19 @@ var Miniflare2 = class _Miniflare {
|
|
|
15060
15954
|
configuredHost,
|
|
15061
15955
|
this.#sharedOpts.core.port
|
|
15062
15956
|
);
|
|
15063
|
-
let
|
|
15957
|
+
let runtimeInspectorAddress;
|
|
15064
15958
|
if (this.#sharedOpts.core.inspectorPort !== void 0) {
|
|
15065
|
-
|
|
15959
|
+
let runtimeInspectorPort = this.#sharedOpts.core.inspectorPort;
|
|
15960
|
+
if (this.#maybeInspectorProxyController !== void 0) {
|
|
15961
|
+
runtimeInspectorPort = 0;
|
|
15962
|
+
}
|
|
15963
|
+
runtimeInspectorAddress = this.#getSocketAddress(
|
|
15066
15964
|
kInspectorSocket,
|
|
15067
|
-
this.#
|
|
15965
|
+
this.#previousRuntimeInspectorPort,
|
|
15068
15966
|
"localhost",
|
|
15069
|
-
|
|
15967
|
+
runtimeInspectorPort
|
|
15070
15968
|
);
|
|
15969
|
+
this.#previousRuntimeInspectorPort = runtimeInspectorPort;
|
|
15071
15970
|
}
|
|
15072
15971
|
const loopbackAddress = `${maybeGetLocallyAccessibleHost(configuredHost) ?? getURLSafeHost(configuredHost)}:${loopbackPort}`;
|
|
15073
15972
|
const runtimeOpts = {
|
|
@@ -15075,7 +15974,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
15075
15974
|
entryAddress,
|
|
15076
15975
|
loopbackAddress,
|
|
15077
15976
|
requiredSockets,
|
|
15078
|
-
inspectorAddress,
|
|
15977
|
+
inspectorAddress: runtimeInspectorAddress,
|
|
15079
15978
|
verbose: this.#sharedOpts.core.verbose,
|
|
15080
15979
|
handleRuntimeStdio: this.#sharedOpts.core.handleRuntimeStdio
|
|
15081
15980
|
};
|
|
@@ -15091,6 +15990,20 @@ var Miniflare2 = class _Miniflare {
|
|
|
15091
15990
|
);
|
|
15092
15991
|
}
|
|
15093
15992
|
this.#socketPorts = maybeSocketPorts;
|
|
15993
|
+
if (this.#maybeInspectorProxyController !== void 0 && this.#sharedOpts.core.inspectorPort !== void 0) {
|
|
15994
|
+
const maybePort = this.#socketPorts.get(kInspectorSocket);
|
|
15995
|
+
if (maybePort === void 0) {
|
|
15996
|
+
throw new MiniflareCoreError(
|
|
15997
|
+
"ERR_RUNTIME_FAILURE",
|
|
15998
|
+
"Unable to access the runtime inspector socket."
|
|
15999
|
+
);
|
|
16000
|
+
} else {
|
|
16001
|
+
await this.#maybeInspectorProxyController.updateConnection(
|
|
16002
|
+
this.#sharedOpts.core.inspectorPort,
|
|
16003
|
+
maybePort
|
|
16004
|
+
);
|
|
16005
|
+
}
|
|
16006
|
+
}
|
|
15094
16007
|
const entrySocket = config.sockets?.[0];
|
|
15095
16008
|
const secure = entrySocket !== void 0 && "https" in entrySocket;
|
|
15096
16009
|
const previousEntryURL = this.#runtimeEntryURL;
|
|
@@ -15122,10 +16035,12 @@ var Miniflare2 = class _Miniflare {
|
|
|
15122
16035
|
if (!this.#runtimeMutex.hasWaiting) {
|
|
15123
16036
|
const ready = initial ? "Ready" : "Updated and ready";
|
|
15124
16037
|
const urlSafeHost = getURLSafeHost(configuredHost);
|
|
15125
|
-
this.#
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
16038
|
+
if (this.#sharedOpts.core.logRequests) {
|
|
16039
|
+
this.#log.info(
|
|
16040
|
+
`${ready} on ${secure ? "https" : "http"}://${urlSafeHost}:${entryPort}`
|
|
16041
|
+
);
|
|
16042
|
+
}
|
|
16043
|
+
if (initial && this.#sharedOpts.core.logRequests) {
|
|
15129
16044
|
const hosts = [];
|
|
15130
16045
|
if (configuredHost === "::" || configuredHost === "*") {
|
|
15131
16046
|
hosts.push("localhost");
|
|
@@ -15145,6 +16060,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
15145
16060
|
await this.#initPromise;
|
|
15146
16061
|
await this.#runtimeMutex.drained();
|
|
15147
16062
|
if (disposing) return new URL("http://[100::]/");
|
|
16063
|
+
await this.#maybeInspectorProxyController?.ready;
|
|
15148
16064
|
this.#checkDisposed();
|
|
15149
16065
|
(0, import_assert12.default)(this.#runtimeEntryURL !== void 0);
|
|
15150
16066
|
return new URL(this.#runtimeEntryURL.toString());
|
|
@@ -15160,6 +16076,9 @@ var Miniflare2 = class _Miniflare {
|
|
|
15160
16076
|
async getInspectorURL() {
|
|
15161
16077
|
this.#checkDisposed();
|
|
15162
16078
|
await this.ready;
|
|
16079
|
+
if (this.#maybeInspectorProxyController !== void 0) {
|
|
16080
|
+
return this.#maybeInspectorProxyController.getInspectorURL();
|
|
16081
|
+
}
|
|
15163
16082
|
(0, import_assert12.default)(this.#socketPorts !== void 0);
|
|
15164
16083
|
const maybePort = this.#socketPorts.get(kInspectorSocket);
|
|
15165
16084
|
if (maybePort === void 0) {
|
|
@@ -15220,11 +16139,11 @@ var Miniflare2 = class _Miniflare {
|
|
|
15220
16139
|
(0, import_assert12.default)(this.#runtimeEntryURL !== void 0);
|
|
15221
16140
|
(0, import_assert12.default)(this.#runtimeDispatcher !== void 0);
|
|
15222
16141
|
const forward = new Request(input, init2);
|
|
15223
|
-
const
|
|
16142
|
+
const url24 = new URL(forward.url);
|
|
15224
16143
|
const actualRuntimeOrigin = this.#runtimeEntryURL.origin;
|
|
15225
|
-
const userRuntimeOrigin =
|
|
15226
|
-
|
|
15227
|
-
|
|
16144
|
+
const userRuntimeOrigin = url24.origin;
|
|
16145
|
+
url24.protocol = this.#runtimeEntryURL.protocol;
|
|
16146
|
+
url24.host = this.#runtimeEntryURL.host;
|
|
15228
16147
|
if (forward.body !== null && forward.headers.get("Content-Length") === "0") {
|
|
15229
16148
|
forward.headers.delete("Content-Length");
|
|
15230
16149
|
}
|
|
@@ -15238,7 +16157,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
15238
16157
|
);
|
|
15239
16158
|
const forwardInit = forward;
|
|
15240
16159
|
forwardInit.dispatcher = dispatcher;
|
|
15241
|
-
const response = await
|
|
16160
|
+
const response = await fetch4(url24, forwardInit);
|
|
15242
16161
|
const stack = response.headers.get(CoreHeaders.ERROR_STACK);
|
|
15243
16162
|
if (response.status === 500 && stack !== null) {
|
|
15244
16163
|
const caught = JsonErrorSchema.parse(await response.json());
|
|
@@ -15354,6 +16273,18 @@ var Miniflare2 = class _Miniflare {
|
|
|
15354
16273
|
getKVNamespace(bindingName, workerName) {
|
|
15355
16274
|
return this.#getProxy(KV_PLUGIN_NAME, bindingName, workerName);
|
|
15356
16275
|
}
|
|
16276
|
+
getSecretsStoreSecretAPI(bindingName, workerName) {
|
|
16277
|
+
return this.#getProxy(
|
|
16278
|
+
SECRET_STORE_PLUGIN_NAME,
|
|
16279
|
+
bindingName,
|
|
16280
|
+
workerName
|
|
16281
|
+
).then((binding) => {
|
|
16282
|
+
return binding[ADMIN_API];
|
|
16283
|
+
});
|
|
16284
|
+
}
|
|
16285
|
+
getSecretsStoreSecret(bindingName, workerName) {
|
|
16286
|
+
return this.#getProxy(SECRET_STORE_PLUGIN_NAME, bindingName, workerName);
|
|
16287
|
+
}
|
|
15357
16288
|
getQueueProducer(bindingName, workerName) {
|
|
15358
16289
|
return this.#getProxy(QUEUES_PLUGIN_NAME, bindingName, workerName);
|
|
15359
16290
|
}
|
|
@@ -15386,14 +16317,19 @@ var Miniflare2 = class _Miniflare {
|
|
|
15386
16317
|
await this.#proxyClient?.dispose();
|
|
15387
16318
|
await this.#runtime?.dispose();
|
|
15388
16319
|
await this.#stopLoopbackServer();
|
|
15389
|
-
await
|
|
16320
|
+
await import_fs28.default.promises.rm(this.#tmpPath, { force: true, recursive: true });
|
|
16321
|
+
await this.#maybeInspectorProxyController?.dispose();
|
|
15390
16322
|
maybeInstanceRegistry?.delete(this);
|
|
15391
16323
|
}
|
|
15392
16324
|
}
|
|
15393
16325
|
};
|
|
15394
16326
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15395
16327
|
0 && (module.exports = {
|
|
16328
|
+
ANALYTICS_ENGINE_PLUGIN,
|
|
16329
|
+
ANALYTICS_ENGINE_PLUGIN_NAME,
|
|
15396
16330
|
ASSETS_PLUGIN,
|
|
16331
|
+
AnalyticsEngineSchemaOptionsSchema,
|
|
16332
|
+
AnalyticsEngineSchemaSharedOptionsSchema,
|
|
15397
16333
|
AssetsOptionsSchema,
|
|
15398
16334
|
CACHE_PLUGIN,
|
|
15399
16335
|
CACHE_PLUGIN_NAME,
|
|
@@ -15420,6 +16356,9 @@ var Miniflare2 = class _Miniflare {
|
|
|
15420
16356
|
DispatchFetchDispatcher,
|
|
15421
16357
|
DurableObjectsOptionsSchema,
|
|
15422
16358
|
DurableObjectsSharedOptionsSchema,
|
|
16359
|
+
EMAIL_PLUGIN,
|
|
16360
|
+
EMAIL_PLUGIN_NAME,
|
|
16361
|
+
EmailOptionsSchema,
|
|
15423
16362
|
ErrorEvent,
|
|
15424
16363
|
File,
|
|
15425
16364
|
FormData,
|
|
@@ -15441,6 +16380,7 @@ var Miniflare2 = class _Miniflare {
|
|
|
15441
16380
|
LiteralSchema,
|
|
15442
16381
|
Log,
|
|
15443
16382
|
LogLevel,
|
|
16383
|
+
MAX_BULK_GET_KEYS,
|
|
15444
16384
|
MessageEvent,
|
|
15445
16385
|
Miniflare,
|
|
15446
16386
|
MiniflareCoreError,
|
|
@@ -15489,11 +16429,15 @@ var Miniflare2 = class _Miniflare {
|
|
|
15489
16429
|
Response,
|
|
15490
16430
|
RouterError,
|
|
15491
16431
|
Runtime,
|
|
16432
|
+
SECRET_STORE_PLUGIN,
|
|
16433
|
+
SECRET_STORE_PLUGIN_NAME,
|
|
15492
16434
|
SERVICE_ENTRY,
|
|
15493
16435
|
SERVICE_LOOPBACK,
|
|
15494
16436
|
SITES_NO_CACHE_PREFIX,
|
|
15495
16437
|
SOCKET_ENTRY,
|
|
15496
16438
|
SOCKET_ENTRY_LOCAL,
|
|
16439
|
+
SecretsStoreSecretsOptionsSchema,
|
|
16440
|
+
SecretsStoreSecretsSharedOptionsSchema,
|
|
15497
16441
|
SharedBindings,
|
|
15498
16442
|
SharedHeaders,
|
|
15499
16443
|
SiteBindings,
|