@moinulmoin/eden-runtime-cloudflare 0.2.0 → 0.2.2
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/eden-eve-host-worker.mjs +129 -1
- package/dist/eve-host-runtime.d.ts +13 -2
- package/dist/eve-host-runtime.js +47 -2
- package/dist/eve-host.d.ts +4 -0
- package/dist/eve-host.js +18 -3
- package/package.json +1 -1
|
@@ -94,6 +94,33 @@ function addTimeoutSignal(existingSignal, timeoutMs) {
|
|
|
94
94
|
controller.signal.addEventListener("abort", () => clearTimeout(timeoutId));
|
|
95
95
|
return controller.signal;
|
|
96
96
|
}
|
|
97
|
+
function simpleGlobMatch(pattern, value) {
|
|
98
|
+
const parts = pattern.split("*");
|
|
99
|
+
if (parts.length === 1)
|
|
100
|
+
return pattern === value;
|
|
101
|
+
if (!value.startsWith(parts[0]))
|
|
102
|
+
return false;
|
|
103
|
+
if (!value.endsWith(parts[parts.length - 1]))
|
|
104
|
+
return false;
|
|
105
|
+
let pos = parts[0].length;
|
|
106
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
107
|
+
const idx = value.indexOf(parts[i], pos);
|
|
108
|
+
if (idx === -1)
|
|
109
|
+
return false;
|
|
110
|
+
pos = idx + parts[i].length;
|
|
111
|
+
}
|
|
112
|
+
return pos <= value.length - parts[parts.length - 1].length;
|
|
113
|
+
}
|
|
114
|
+
function matchesHostList(hostname, patterns) {
|
|
115
|
+
return patterns.some((pattern) => simpleGlobMatch(pattern, hostname));
|
|
116
|
+
}
|
|
117
|
+
function normalizeHostname(hostname) {
|
|
118
|
+
let end = hostname.length;
|
|
119
|
+
while (end > 0 && hostname[end - 1] === ".") {
|
|
120
|
+
end--;
|
|
121
|
+
}
|
|
122
|
+
return hostname.slice(0, end);
|
|
123
|
+
}
|
|
97
124
|
var ContainerState = class {
|
|
98
125
|
storage;
|
|
99
126
|
status;
|
|
@@ -147,6 +174,60 @@ var ContainerState = class {
|
|
|
147
174
|
await this.storage.put(CONTAINER_STATE_KEY, this.status);
|
|
148
175
|
}
|
|
149
176
|
};
|
|
177
|
+
var ContainerProxy = class extends WorkerEntrypoint {
|
|
178
|
+
async fetch(request) {
|
|
179
|
+
const url = new URL(request.url);
|
|
180
|
+
const hostname = normalizeHostname(url.hostname);
|
|
181
|
+
const { className, containerId, outboundByHostOverrides, outboundHandlerOverride, enableInternet, allowedHosts, deniedHosts, interceptAll } = this.ctx.props;
|
|
182
|
+
const baseCtx = { containerId, className };
|
|
183
|
+
if (deniedHosts && matchesHostList(hostname, deniedHosts)) {
|
|
184
|
+
return new Response("Origin is disallowed", { status: 520 });
|
|
185
|
+
}
|
|
186
|
+
if (allowedHosts && !matchesHostList(hostname, allowedHosts)) {
|
|
187
|
+
return new Response("Origin is disallowed", { status: 520 });
|
|
188
|
+
}
|
|
189
|
+
const handlers = outboundHandlersRegistry.get(className);
|
|
190
|
+
if (outboundByHostOverrides && handlers) {
|
|
191
|
+
const override = outboundByHostOverrides[hostname] ?? Object.entries(outboundByHostOverrides).find(([pattern]) => pattern !== hostname && simpleGlobMatch(pattern, hostname))?.[1];
|
|
192
|
+
if (override && handlers[override.method]) {
|
|
193
|
+
return handlers[override.method](request, this.env, {
|
|
194
|
+
...baseCtx,
|
|
195
|
+
params: override.params
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const handlersByHost = outboundByHostRegistry.get(className);
|
|
200
|
+
if (handlersByHost) {
|
|
201
|
+
const handler = handlersByHost[hostname] ?? Object.entries(handlersByHost).find(([pattern]) => pattern !== hostname && simpleGlobMatch(pattern, hostname))?.[1];
|
|
202
|
+
if (handler) {
|
|
203
|
+
return handler(request, this.env, baseCtx);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (!interceptAll) {
|
|
207
|
+
if (allowedHosts || enableInternet) {
|
|
208
|
+
return fetch(request);
|
|
209
|
+
}
|
|
210
|
+
return new Response("Origin is disallowed", { status: 520 });
|
|
211
|
+
}
|
|
212
|
+
if (outboundHandlerOverride && handlers?.[outboundHandlerOverride.method]) {
|
|
213
|
+
return handlers[outboundHandlerOverride.method](request, this.env, {
|
|
214
|
+
...baseCtx,
|
|
215
|
+
params: outboundHandlerOverride.params
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const defaultOutboundHandlerName = defaultOutboundHandlerNameRegistry.get(className);
|
|
219
|
+
if (defaultOutboundHandlerName && handlers?.[defaultOutboundHandlerName]) {
|
|
220
|
+
return handlers[defaultOutboundHandlerName](request, this.env, baseCtx);
|
|
221
|
+
}
|
|
222
|
+
if (allowedHosts) {
|
|
223
|
+
return fetch(request);
|
|
224
|
+
}
|
|
225
|
+
if (enableInternet) {
|
|
226
|
+
return fetch(request);
|
|
227
|
+
}
|
|
228
|
+
return new Response("Origin is disallowed", { status: 520 });
|
|
229
|
+
}
|
|
230
|
+
};
|
|
150
231
|
var Container = class extends DurableObject {
|
|
151
232
|
static get outboundByHost() {
|
|
152
233
|
return outboundByHostRegistry.get(this.name);
|
|
@@ -1420,6 +1501,16 @@ var EVE_HOST_DEFAULTS = {
|
|
|
1420
1501
|
instanceType: "basic",
|
|
1421
1502
|
sleepAfter: "24h"
|
|
1422
1503
|
};
|
|
1504
|
+
function isEveWorkflowInternalRoute(pathname) {
|
|
1505
|
+
let decodedPath = pathname;
|
|
1506
|
+
try {
|
|
1507
|
+
decodedPath = decodeURIComponent(pathname);
|
|
1508
|
+
} catch {
|
|
1509
|
+
}
|
|
1510
|
+
return /^\/\.well-known\/workflow\/v1\/(?:flow|step)(?:\/|$)/iu.test(
|
|
1511
|
+
decodedPath.replace(/\/+/gu, "/")
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1423
1514
|
var EVE_HOST_OWNED_HEADERS = [
|
|
1424
1515
|
"forwarded",
|
|
1425
1516
|
"x-forwarded-for",
|
|
@@ -1595,6 +1686,7 @@ var RESERVED_EVE_HOST_VARIABLES = /* @__PURE__ */ new Set([
|
|
|
1595
1686
|
"PORT",
|
|
1596
1687
|
"NITRO_PORT",
|
|
1597
1688
|
"NODE_ENV",
|
|
1689
|
+
"NODE_EXTRA_CA_CERTS",
|
|
1598
1690
|
"WORKFLOW_LOCAL_BASE_URL",
|
|
1599
1691
|
"EDEN_EVE_DEPLOYMENT_ID",
|
|
1600
1692
|
"EDEN_EVE_GENERATION_ID",
|
|
@@ -1803,10 +1895,38 @@ function createEveReadinessGate(options) {
|
|
|
1803
1895
|
}
|
|
1804
1896
|
|
|
1805
1897
|
// src/eve-host-runtime.ts
|
|
1898
|
+
var EVE_CLOUDFLARE_CONTAINERS_CA_PATH = "/etc/cloudflare/certs/cloudflare-containers-ca.crt";
|
|
1899
|
+
async function routeEveOutboundRequest(request, env) {
|
|
1900
|
+
const publicOrigin = env.EVE_PUBLIC_ORIGIN;
|
|
1901
|
+
const bindingName = env.EVE_CONTAINER_BINDING_NAME;
|
|
1902
|
+
const instanceName = env.EVE_CONTAINER_INSTANCE_NAME;
|
|
1903
|
+
if (typeof publicOrigin !== "string" || typeof bindingName !== "string" || typeof instanceName !== "string") {
|
|
1904
|
+
throw new EveHostError(
|
|
1905
|
+
"HOST_ORIGIN_UNAVAILABLE",
|
|
1906
|
+
"The container loopback identity is unavailable to the outbound handler."
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
assertStableOrigin(publicOrigin);
|
|
1910
|
+
assertNonEmpty(bindingName, "Container binding name");
|
|
1911
|
+
assertNonEmpty(instanceName, "Container instance name");
|
|
1912
|
+
const hostname = new URL(request.url).hostname;
|
|
1913
|
+
if (hostname !== new URL(publicOrigin).hostname) {
|
|
1914
|
+
return fetch(request);
|
|
1915
|
+
}
|
|
1916
|
+
const namespace = env[bindingName];
|
|
1917
|
+
if (namespace === void 0) {
|
|
1918
|
+
throw new EveHostError(
|
|
1919
|
+
"HOST_READINESS_UNPROVEN",
|
|
1920
|
+
"The configured Container binding is unavailable to the outbound handler."
|
|
1921
|
+
);
|
|
1922
|
+
}
|
|
1923
|
+
return namespace.getByName(instanceName).containerFetch(request, EVE_HOST_DEFAULTS.internalPort);
|
|
1924
|
+
}
|
|
1806
1925
|
var EveHostContainer = class extends Container {
|
|
1807
1926
|
defaultPort = EVE_HOST_DEFAULTS.internalPort;
|
|
1808
1927
|
requiredPorts = [EVE_HOST_DEFAULTS.internalPort];
|
|
1809
1928
|
sleepAfter = EVE_HOST_DEFAULTS.sleepAfter;
|
|
1929
|
+
interceptHttps = true;
|
|
1810
1930
|
enableInternet = true;
|
|
1811
1931
|
pingEndpoint = "localhost/eve/v1/health";
|
|
1812
1932
|
lifecycle = createEveHostLifecycleObserver();
|
|
@@ -1838,6 +1958,9 @@ var EveHostContainer = class extends Container {
|
|
|
1838
1958
|
WORKFLOW_LOCAL_BASE_URL: publicOrigin,
|
|
1839
1959
|
EDEN_EVE_DEPLOYMENT_ID: deploymentId,
|
|
1840
1960
|
EDEN_EVE_GENERATION_ID: generationId,
|
|
1961
|
+
// Trust the runtime-mounted Cloudflare Containers CA so the intercepted
|
|
1962
|
+
// HTTPS deliveries to the public origin below complete TLS.
|
|
1963
|
+
NODE_EXTRA_CA_CERTS: EVE_CLOUDFLARE_CONTAINERS_CA_PATH,
|
|
1841
1964
|
...env.EDEN_EVE_RUNTIME_REVISION === void 0 ? {} : { EDEN_EVE_RUNTIME_REVISION: env.EDEN_EVE_RUNTIME_REVISION }
|
|
1842
1965
|
};
|
|
1843
1966
|
this.readiness = createEveReadinessGate({
|
|
@@ -1905,6 +2028,9 @@ function createEveHostWorker(options) {
|
|
|
1905
2028
|
}
|
|
1906
2029
|
return {
|
|
1907
2030
|
async fetch(request, env) {
|
|
2031
|
+
if (isEveWorkflowInternalRoute(new URL(request.url).pathname)) {
|
|
2032
|
+
return new Response(null, { status: 404 });
|
|
2033
|
+
}
|
|
1908
2034
|
const namespace = env[options.containerBindingName];
|
|
1909
2035
|
if (namespace === void 0) {
|
|
1910
2036
|
throw new EveHostError(
|
|
@@ -1947,6 +2073,8 @@ function createEveHostWorker(options) {
|
|
|
1947
2073
|
};
|
|
1948
2074
|
}
|
|
1949
2075
|
export {
|
|
2076
|
+
ContainerProxy,
|
|
1950
2077
|
EveHostContainer,
|
|
1951
|
-
createEveHostWorker
|
|
2078
|
+
createEveHostWorker,
|
|
2079
|
+
routeEveOutboundRequest
|
|
1952
2080
|
};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { Container } from "@cloudflare/containers";
|
|
1
|
+
import { Container, ContainerProxy } from "@cloudflare/containers";
|
|
2
2
|
import { type EveHostContainerEnvironment, type EveHostForwardingMetadata, type EveHostReadinessEvidence } from "./eve-host.js";
|
|
3
|
+
export { ContainerProxy };
|
|
4
|
+
/**
|
|
5
|
+
* Delivers the container's own HTTPS requests to its public workers.dev origin
|
|
6
|
+
* back into the container over the internal port instead of the public edge.
|
|
7
|
+
* The Workflow local World posts queue deliveries to
|
|
8
|
+
* `WORKFLOW_LOCAL_BASE_URL`, which must remain the public origin so Eve's
|
|
9
|
+
* externally visible callback URLs stay correct; re-routing that traffic
|
|
10
|
+
* inside the Worker lets the public Worker path refuse the unauthenticated
|
|
11
|
+
* queue endpoints without breaking delivery.
|
|
12
|
+
*/
|
|
13
|
+
export declare function routeEveOutboundRequest(request: Request, env: EveHostContainerEnvironment): Promise<Response>;
|
|
3
14
|
/**
|
|
4
15
|
* This module is the only Eve-host surface that depends on provider runtime
|
|
5
16
|
* packages. It is bundled into the deployed Worker directory instead of the
|
|
@@ -11,6 +22,7 @@ export declare class EveHostContainer extends Container<EveHostContainerEnvironm
|
|
|
11
22
|
defaultPort: 8080;
|
|
12
23
|
requiredPorts: 8080[];
|
|
13
24
|
sleepAfter: "24h";
|
|
25
|
+
interceptHttps: boolean;
|
|
14
26
|
enableInternet: boolean;
|
|
15
27
|
pingEndpoint: string;
|
|
16
28
|
readonly lifecycle: import("./eve-host.js").EveHostLifecycleObserver;
|
|
@@ -41,5 +53,4 @@ export interface EveHostWorkerHandler {
|
|
|
41
53
|
fetch(request: Request, env: EveHostWorkerEnvironment): Promise<Response>;
|
|
42
54
|
}
|
|
43
55
|
export declare function createEveHostWorker(options: EveHostWorkerOptions): EveHostWorkerHandler;
|
|
44
|
-
export {};
|
|
45
56
|
//# sourceMappingURL=eve-host-runtime.d.ts.map
|
package/dist/eve-host-runtime.js
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
import { Container } from "@cloudflare/containers";
|
|
2
|
-
import { EVE_HOST_DEFAULTS, EveHostError, assertNonEmpty, assertStableOrigin, createEveHostLifecycleObserver, createEveReadinessGate, createTrustedEveRequest, IDENTIFIER_PATTERN, readProtectedRuntimeVariables, WORKER_NAME_PATTERN, } from "./eve-host.js";
|
|
1
|
+
import { Container, ContainerProxy } from "@cloudflare/containers";
|
|
2
|
+
import { EVE_HOST_DEFAULTS, EveHostError, assertNonEmpty, assertStableOrigin, createEveHostLifecycleObserver, createEveReadinessGate, createTrustedEveRequest, IDENTIFIER_PATTERN, readProtectedRuntimeVariables, WORKER_NAME_PATTERN, isEveWorkflowInternalRoute, } from "./eve-host.js";
|
|
3
|
+
export { ContainerProxy };
|
|
4
|
+
const EVE_CLOUDFLARE_CONTAINERS_CA_PATH = "/etc/cloudflare/certs/cloudflare-containers-ca.crt";
|
|
5
|
+
/**
|
|
6
|
+
* Delivers the container's own HTTPS requests to its public workers.dev origin
|
|
7
|
+
* back into the container over the internal port instead of the public edge.
|
|
8
|
+
* The Workflow local World posts queue deliveries to
|
|
9
|
+
* `WORKFLOW_LOCAL_BASE_URL`, which must remain the public origin so Eve's
|
|
10
|
+
* externally visible callback URLs stay correct; re-routing that traffic
|
|
11
|
+
* inside the Worker lets the public Worker path refuse the unauthenticated
|
|
12
|
+
* queue endpoints without breaking delivery.
|
|
13
|
+
*/
|
|
14
|
+
export async function routeEveOutboundRequest(request, env) {
|
|
15
|
+
const publicOrigin = env.EVE_PUBLIC_ORIGIN;
|
|
16
|
+
const bindingName = env.EVE_CONTAINER_BINDING_NAME;
|
|
17
|
+
const instanceName = env.EVE_CONTAINER_INSTANCE_NAME;
|
|
18
|
+
if (typeof publicOrigin !== "string" ||
|
|
19
|
+
typeof bindingName !== "string" ||
|
|
20
|
+
typeof instanceName !== "string") {
|
|
21
|
+
throw new EveHostError("HOST_ORIGIN_UNAVAILABLE", "The container loopback identity is unavailable to the outbound handler.");
|
|
22
|
+
}
|
|
23
|
+
assertStableOrigin(publicOrigin);
|
|
24
|
+
assertNonEmpty(bindingName, "Container binding name");
|
|
25
|
+
assertNonEmpty(instanceName, "Container instance name");
|
|
26
|
+
const hostname = new URL(request.url).hostname;
|
|
27
|
+
if (hostname !== new URL(publicOrigin).hostname) {
|
|
28
|
+
return fetch(request);
|
|
29
|
+
}
|
|
30
|
+
const namespace = env[bindingName];
|
|
31
|
+
if (namespace === undefined) {
|
|
32
|
+
throw new EveHostError("HOST_READINESS_UNPROVEN", "The configured Container binding is unavailable to the outbound handler.");
|
|
33
|
+
}
|
|
34
|
+
return namespace
|
|
35
|
+
.getByName(instanceName)
|
|
36
|
+
.containerFetch(request, EVE_HOST_DEFAULTS.internalPort);
|
|
37
|
+
}
|
|
3
38
|
export class EveHostContainer extends Container {
|
|
4
39
|
defaultPort = EVE_HOST_DEFAULTS.internalPort;
|
|
5
40
|
requiredPorts = [EVE_HOST_DEFAULTS.internalPort];
|
|
6
41
|
sleepAfter = EVE_HOST_DEFAULTS.sleepAfter;
|
|
42
|
+
interceptHttps = true;
|
|
7
43
|
enableInternet = true;
|
|
8
44
|
pingEndpoint = "localhost/eve/v1/health";
|
|
9
45
|
lifecycle = createEveHostLifecycleObserver();
|
|
@@ -34,6 +70,9 @@ export class EveHostContainer extends Container {
|
|
|
34
70
|
WORKFLOW_LOCAL_BASE_URL: publicOrigin,
|
|
35
71
|
EDEN_EVE_DEPLOYMENT_ID: deploymentId,
|
|
36
72
|
EDEN_EVE_GENERATION_ID: generationId,
|
|
73
|
+
// Trust the runtime-mounted Cloudflare Containers CA so the intercepted
|
|
74
|
+
// HTTPS deliveries to the public origin below complete TLS.
|
|
75
|
+
NODE_EXTRA_CA_CERTS: EVE_CLOUDFLARE_CONTAINERS_CA_PATH,
|
|
37
76
|
...(env.EDEN_EVE_RUNTIME_REVISION === undefined
|
|
38
77
|
? {}
|
|
39
78
|
: { EDEN_EVE_RUNTIME_REVISION: env.EDEN_EVE_RUNTIME_REVISION }),
|
|
@@ -91,6 +130,12 @@ export function createEveHostWorker(options) {
|
|
|
91
130
|
}
|
|
92
131
|
return {
|
|
93
132
|
async fetch(request, env) {
|
|
133
|
+
// Queue deliveries to these endpoints arrive through the container's
|
|
134
|
+
// intercepted outbound loopback instead, so any request that reaches
|
|
135
|
+
// the public Worker fetch path is external and unauthenticated.
|
|
136
|
+
if (isEveWorkflowInternalRoute(new URL(request.url).pathname)) {
|
|
137
|
+
return new Response(null, { status: 404 });
|
|
138
|
+
}
|
|
94
139
|
const namespace = env[options.containerBindingName];
|
|
95
140
|
if (namespace === undefined) {
|
|
96
141
|
throw new EveHostError("HOST_READINESS_UNPROVEN", "The configured Container binding is unavailable.");
|
package/dist/eve-host.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export declare const EVE_HOST_DEFAULTS: {
|
|
|
6
6
|
readonly instanceType: "basic";
|
|
7
7
|
readonly sleepAfter: "24h";
|
|
8
8
|
};
|
|
9
|
+
/** Queue deliveries are private; webhook and manifest routes stay forwarded. */
|
|
10
|
+
export declare function isEveWorkflowInternalRoute(pathname: string): boolean;
|
|
9
11
|
export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-public-origin", "x-eden-eve-correlation-id", "x-eden-eve-container-name", "x-eden-eve-container-id", "x-eden-eve-runtime-revision", "x-eden-deployment-id", "x-eden-generation-id", "x-eden-container-name", "x-eden-container-id", "cf-container-target-port"];
|
|
10
12
|
export declare const WORKER_NAME_PATTERN: RegExp;
|
|
11
13
|
export declare const IDENTIFIER_PATTERN: RegExp;
|
|
@@ -45,6 +47,7 @@ export interface EveHostWranglerConfig {
|
|
|
45
47
|
readonly vars: {
|
|
46
48
|
readonly EVE_PUBLIC_ORIGIN: string;
|
|
47
49
|
readonly EVE_CONTAINER_INSTANCE_NAME: string;
|
|
50
|
+
readonly EVE_CONTAINER_BINDING_NAME: string;
|
|
48
51
|
readonly EDEN_EVE_DEPLOYMENT_ID: string;
|
|
49
52
|
readonly EDEN_EVE_GENERATION_ID: string;
|
|
50
53
|
readonly EVE_RUNTIME_VARIABLE_NAMES: readonly string[];
|
|
@@ -129,6 +132,7 @@ export interface EveHostContainerEnvironment {
|
|
|
129
132
|
readonly EVE_RUNTIME_VARIABLE_NAMES?: readonly string[];
|
|
130
133
|
readonly EVE_PUBLIC_ORIGIN?: string;
|
|
131
134
|
readonly EVE_CONTAINER_INSTANCE_NAME?: string;
|
|
135
|
+
readonly EVE_CONTAINER_BINDING_NAME?: string;
|
|
132
136
|
readonly EDEN_EVE_DEPLOYMENT_ID?: string;
|
|
133
137
|
readonly EDEN_EVE_GENERATION_ID?: string;
|
|
134
138
|
readonly EDEN_EVE_RUNTIME_REVISION?: string;
|
package/dist/eve-host.js
CHANGED
|
@@ -6,6 +6,17 @@ export const EVE_HOST_DEFAULTS = {
|
|
|
6
6
|
instanceType: "basic",
|
|
7
7
|
sleepAfter: "24h",
|
|
8
8
|
};
|
|
9
|
+
/** Queue deliveries are private; webhook and manifest routes stay forwarded. */
|
|
10
|
+
export function isEveWorkflowInternalRoute(pathname) {
|
|
11
|
+
let decodedPath = pathname;
|
|
12
|
+
try {
|
|
13
|
+
decodedPath = decodeURIComponent(pathname);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// Malformed escapes cannot name a queue route in Eve's router.
|
|
17
|
+
}
|
|
18
|
+
return /^\/\.well-known\/workflow\/v1\/(?:flow|step)(?:\/|$)/iu.test(decodedPath.replace(/\/+/gu, "/"));
|
|
19
|
+
}
|
|
9
20
|
export const EVE_HOST_OWNED_HEADERS = [
|
|
10
21
|
"forwarded",
|
|
11
22
|
"x-forwarded-for",
|
|
@@ -148,6 +159,7 @@ export function createEveHostConfig(request) {
|
|
|
148
159
|
vars: {
|
|
149
160
|
EVE_PUBLIC_ORIGIN: request.stableWorkersDevOrigin,
|
|
150
161
|
EVE_CONTAINER_INSTANCE_NAME: request.stableContainerInstanceName,
|
|
162
|
+
EVE_CONTAINER_BINDING_NAME: request.containerBindingName,
|
|
151
163
|
EDEN_EVE_DEPLOYMENT_ID: request.deploymentId,
|
|
152
164
|
EDEN_EVE_GENERATION_ID: request.generationId,
|
|
153
165
|
EVE_RUNTIME_VARIABLE_NAMES: request.runtimeVariableNames ?? [],
|
|
@@ -202,10 +214,12 @@ export function generateEveHostWorkerSource(request) {
|
|
|
202
214
|
}),
|
|
203
215
|
};
|
|
204
216
|
return [
|
|
205
|
-
`import { EveHostContainer, createEveHostWorker } from ${JSON.stringify(moduleSpecifier)};`,
|
|
217
|
+
`import { ContainerProxy, EveHostContainer, createEveHostWorker, routeEveOutboundRequest } from ${JSON.stringify(moduleSpecifier)};`,
|
|
206
218
|
request.config.container.className === "EveHostContainer"
|
|
207
|
-
? "export { EveHostContainer };"
|
|
208
|
-
: `export { EveHostContainer as ${request.config.container.className} };`,
|
|
219
|
+
? "export { ContainerProxy, EveHostContainer };"
|
|
220
|
+
: `export { ContainerProxy, EveHostContainer as ${request.config.container.className} };`,
|
|
221
|
+
"",
|
|
222
|
+
`EveHostContainer.outboundByHost = { ${JSON.stringify(new URL(request.config.container.publicOrigin).hostname)}: routeEveOutboundRequest };`,
|
|
209
223
|
"",
|
|
210
224
|
`export default createEveHostWorker(${JSON.stringify(workerOptions)});`,
|
|
211
225
|
"",
|
|
@@ -325,6 +339,7 @@ const RESERVED_EVE_HOST_VARIABLES = new Set([
|
|
|
325
339
|
"PORT",
|
|
326
340
|
"NITRO_PORT",
|
|
327
341
|
"NODE_ENV",
|
|
342
|
+
"NODE_EXTRA_CA_CERTS",
|
|
328
343
|
"WORKFLOW_LOCAL_BASE_URL",
|
|
329
344
|
"EDEN_EVE_DEPLOYMENT_ID",
|
|
330
345
|
"EDEN_EVE_GENERATION_ID",
|