@jakuta-inc/worker-proxy 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/same-origin-proxy.d.ts +31 -16
- package/dist/same-origin-proxy.d.ts.map +1 -1
- package/dist/same-origin-proxy.js +75 -46
- package/dist/same-origin-proxy.js.map +1 -1
- package/dist/venture_api_route.d.ts +5 -7
- package/dist/venture_api_route.d.ts.map +1 -1
- package/dist/venture_api_route.js +3 -5
- package/dist/venture_api_route.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AllowedHosts, Backend, PathRewrite,
|
|
2
|
-
export { createProxyHandler, createAdminAuthRoute } from "./same-origin-proxy.js";
|
|
1
|
+
export type { AllowedHosts, Backend, PathRewrite, ProxyRoute, HealthProbeResult, ProxyHealthCheck, ProxyHandlerConfig, ProxyOutcome, ProxyHandler, ProxyError } from "./same-origin-proxy.js";
|
|
2
|
+
export { createProxyHandler, createAdminAuthRoute, createAdminApiAuthRoute } from "./same-origin-proxy.js";
|
|
3
3
|
export { VENTURE_API_PREFIX, createVentureApiRoute } from "./venture_api_route.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC9L,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createProxyHandler, createAdminAuthRoute } from "./same-origin-proxy.js";
|
|
1
|
+
export { createProxyHandler, createAdminAuthRoute, createAdminApiAuthRoute } from "./same-origin-proxy.js";
|
|
2
2
|
export { VENTURE_API_PREFIX, createVentureApiRoute } from "./venture_api_route.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC3G,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -28,11 +28,11 @@ interface BackendBase {
|
|
|
28
28
|
* - `"venture"` — a venture backend must never see the raw `admin_session`
|
|
29
29
|
* cookie. The proxy deletes the `Cookie` header and, if an `admin_session`
|
|
30
30
|
* was present, injects `X-Admin-Session: <session_id>` carrying the raw
|
|
31
|
-
* session id for `admin-
|
|
31
|
+
* session id for `admin-shared`'s `extract_session_from_handoff_header`.
|
|
32
32
|
* Any inbound `X-Admin-Session` header is stripped first (forgery defense).
|
|
33
33
|
*
|
|
34
34
|
* Cookie-transform semantics are an attribute of the Backend, not of the
|
|
35
|
-
*
|
|
35
|
+
* ProxyRoute. There is no per-route override. Any caller that could point a route
|
|
36
36
|
* at the admin backend while running the venture cookie-stripping transform
|
|
37
37
|
* would break web session restore on admin-api; attaching the transform to
|
|
38
38
|
* backend identity makes that state unrepresentable.
|
|
@@ -46,7 +46,7 @@ export type Backend = (BackendBase & {
|
|
|
46
46
|
* A path-rewrite policy applied to the incoming pathname before forwarding.
|
|
47
47
|
* Either an identity passthrough or an explicit transform function. Encoded
|
|
48
48
|
* as a discriminated union so `createProxyHandler` callers cannot omit the
|
|
49
|
-
* decision — every
|
|
49
|
+
* decision — every ProxyRoute states its rewrite policy explicitly.
|
|
50
50
|
*/
|
|
51
51
|
export type PathRewrite = {
|
|
52
52
|
readonly kind: "identity";
|
|
@@ -63,19 +63,19 @@ export type PathRewrite = {
|
|
|
63
63
|
* @field target - Backend to forward matched requests to
|
|
64
64
|
* @field rewrite - Path rewrite policy applied before forwarding
|
|
65
65
|
*/
|
|
66
|
-
export interface
|
|
66
|
+
export interface ProxyRoute {
|
|
67
67
|
readonly pathPrefix: string;
|
|
68
68
|
readonly target: Backend;
|
|
69
69
|
readonly rewrite: PathRewrite;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Result of probing a backend's `/
|
|
72
|
+
* Result of probing a backend's Jakuta `/status` endpoint.
|
|
73
73
|
*
|
|
74
|
-
* @field
|
|
74
|
+
* @field healthStatus - `"ok"` if the backend responded with a 2xx, `"error"` on non-2xx or network failure
|
|
75
75
|
* @field probeUrl - The full URL that was probed, useful for error reporting
|
|
76
76
|
*/
|
|
77
77
|
export interface HealthProbeResult {
|
|
78
|
-
readonly
|
|
78
|
+
readonly healthStatus: "ok" | "error";
|
|
79
79
|
readonly probeUrl: string;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -96,9 +96,9 @@ export type ProxyHealthCheck = {
|
|
|
96
96
|
readonly kind: "disabled";
|
|
97
97
|
} | {
|
|
98
98
|
readonly kind: "enabled";
|
|
99
|
-
readonly
|
|
99
|
+
readonly healthPath: string;
|
|
100
100
|
readonly probeTargets: readonly Backend[];
|
|
101
|
-
readonly buildHealthResponse: (
|
|
101
|
+
readonly buildHealthResponse: (healthResults: Record<string, HealthProbeResult>) => Response;
|
|
102
102
|
};
|
|
103
103
|
/**
|
|
104
104
|
* Declarative configuration for `createProxyHandler`.
|
|
@@ -109,7 +109,7 @@ export type ProxyHealthCheck = {
|
|
|
109
109
|
*/
|
|
110
110
|
export interface ProxyHandlerConfig {
|
|
111
111
|
readonly allowedHosts: AllowedHosts;
|
|
112
|
-
readonly routes: readonly
|
|
112
|
+
readonly routes: readonly ProxyRoute[];
|
|
113
113
|
readonly healthCheck: ProxyHealthCheck;
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
@@ -145,7 +145,7 @@ export interface ProxyHandler {
|
|
|
145
145
|
handleRequest(workerRequest: Request): Promise<ProxyOutcome>;
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
|
-
* Build a `
|
|
148
|
+
* Build a `ProxyRoute` that proxies `/auth/*` to the admin backend's `/api/auth/*`
|
|
149
149
|
* surface with cookies preserved. Every frontend that renders admin-shell's
|
|
150
150
|
* login UI needs this route, because admin-shell's `AdminRoute.*` constants
|
|
151
151
|
* (`/auth/login`, `/auth/logout`, `/auth/session`) are the single source of
|
|
@@ -155,16 +155,31 @@ export interface ProxyHandler {
|
|
|
155
155
|
* Spread the result into your `routes` array; do not hand-maintain the
|
|
156
156
|
* rewrite.
|
|
157
157
|
*
|
|
158
|
-
* @why
|
|
158
|
+
* @why Prevents each Worker from hand-writing the admin login rewrite because admin-shell's browser paths and admin-api's server paths intentionally differ.
|
|
159
159
|
* @param adminBaseUrl - Origin of the jakuta-admin API (scheme + host, no path)
|
|
160
|
-
* @returns A
|
|
160
|
+
* @returns A ProxyRoute that matches `/auth` / `/auth/*` and forwards to `adminBaseUrl/api/auth/*`
|
|
161
161
|
*/
|
|
162
|
-
export declare function createAdminAuthRoute(adminBaseUrl: string):
|
|
162
|
+
export declare function createAdminAuthRoute(adminBaseUrl: string): ProxyRoute;
|
|
163
|
+
/**
|
|
164
|
+
* Build a `ProxyRoute` that proxies generated admin-shell `/api/auth/*` requests
|
|
165
|
+
* to the Central Admin backend with cookies preserved.
|
|
166
|
+
*
|
|
167
|
+
* Mount this before the venture `/api/*` route. The generated admin-shell
|
|
168
|
+
* auth client now uses the same `/api/auth/*` route templates as the Central
|
|
169
|
+
* Admin backend, so the worker should forward those paths without rewriting
|
|
170
|
+
* them or applying venture cookie-to-header handoff.
|
|
171
|
+
*
|
|
172
|
+
* @why Preserves generated admin auth paths because venture workers must route
|
|
173
|
+
* Central Admin session requests before the general venture API proxy.
|
|
174
|
+
* @param adminBaseUrl - Origin of the jakuta-admin API (scheme + host, no path)
|
|
175
|
+
* @returns A ProxyRoute that matches `/api/auth` / `/api/auth/*` and forwards to Central Admin unchanged.
|
|
176
|
+
*/
|
|
177
|
+
export declare function createAdminApiAuthRoute(adminBaseUrl: string): ProxyRoute;
|
|
163
178
|
/**
|
|
164
179
|
* Build a `ProxyHandler` from a declarative `ProxyHandlerConfig`. This is the
|
|
165
180
|
* single handler constructor — there is no separate venture or central-admin
|
|
166
181
|
* handler. Consumers express their routing topology as a list of
|
|
167
|
-
* `
|
|
182
|
+
* `ProxyRoute`s pointing at `Backend`s, and the handler dispatches by first-match.
|
|
168
183
|
*
|
|
169
184
|
* Every config must declare its `allowedHosts` — the non-empty list of
|
|
170
185
|
* hostnames this worker accepts. A request for any other hostname is
|
|
@@ -177,7 +192,7 @@ export declare function createAdminAuthRoute(adminBaseUrl: string): Route;
|
|
|
177
192
|
* handoff). There is no per-route override. See the `Backend` doc comment for
|
|
178
193
|
* why this is unrepresentable state, not a missing feature.
|
|
179
194
|
*
|
|
180
|
-
* @why
|
|
195
|
+
* @why Centralizes host allowlisting, backend URL normalization, and cookie-transform routing because individual worker entries must not diverge on those security rules.
|
|
181
196
|
* @param config - Declarative host allowlist, route list, and health-check hook
|
|
182
197
|
* @returns A ProxyHandler whose `handleRequest` dispatches the inbound request
|
|
183
198
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"same-origin-proxy.d.ts","sourceRoot":"","sources":["../src/same-origin-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAE1D,UAAU,WAAW;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,OAAO,GACf,CAAC,WAAW,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,GAC1C,CAAC,WAAW,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CAAC;AAErF;;;;;;;;GAQG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"same-origin-proxy.d.ts","sourceRoot":"","sources":["../src/same-origin-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;AAE1D,UAAU,WAAW;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,OAAO,GACf,CAAC,WAAW,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAA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xC;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,aAAa,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9D;AAiPD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CASrE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAMxE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CA+D3E"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const HEALTH_TIMEOUT_MS = 5000;
|
|
2
2
|
function stripTrailingSlash(originUrl) {
|
|
3
|
-
|
|
3
|
+
if (originUrl.endsWith("/")) {
|
|
4
|
+
return originUrl.slice(0, -1);
|
|
5
|
+
}
|
|
6
|
+
return originUrl;
|
|
4
7
|
}
|
|
5
8
|
function jsonErrorResponse(errorInput) {
|
|
6
9
|
return new Response(JSON.stringify(errorInput.errorBody), {
|
|
@@ -9,15 +12,18 @@ function jsonErrorResponse(errorInput) {
|
|
|
9
12
|
});
|
|
10
13
|
}
|
|
11
14
|
async function probeHealth(probedBaseUrl) {
|
|
12
|
-
const probeUrl = new URL("/
|
|
15
|
+
const probeUrl = new URL("/status", probedBaseUrl).toString();
|
|
13
16
|
try {
|
|
14
17
|
const healthResponse = await fetch(probeUrl, {
|
|
15
18
|
signal: AbortSignal.timeout(HEALTH_TIMEOUT_MS),
|
|
16
19
|
});
|
|
17
|
-
|
|
20
|
+
if (healthResponse.ok) {
|
|
21
|
+
return { healthStatus: "ok", probeUrl };
|
|
22
|
+
}
|
|
23
|
+
return { healthStatus: "error", probeUrl };
|
|
18
24
|
}
|
|
19
25
|
catch {
|
|
20
|
-
return {
|
|
26
|
+
return { healthStatus: "error", probeUrl };
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
const ADMIN_SESSION_COOKIE_NAME = "admin_session";
|
|
@@ -33,11 +39,11 @@ function findAdminSessionCookieValue(cookieHeader) {
|
|
|
33
39
|
return { kind: "absent" };
|
|
34
40
|
}
|
|
35
41
|
function readCookieHeader(headers) {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
42
|
+
const cookieHeaderValue = headers.get("cookie");
|
|
43
|
+
if (cookieHeaderValue === null) {
|
|
38
44
|
return { kind: "absent" };
|
|
39
45
|
}
|
|
40
|
-
return { kind: "present",
|
|
46
|
+
return { kind: "present", cookieHeaderValue };
|
|
41
47
|
}
|
|
42
48
|
function buildVentureForwardedHeaders(originalHeaders) {
|
|
43
49
|
const forwarded = new Headers(originalHeaders);
|
|
@@ -45,7 +51,7 @@ function buildVentureForwardedHeaders(originalHeaders) {
|
|
|
45
51
|
const cookieLookup = readCookieHeader(forwarded);
|
|
46
52
|
forwarded.delete("cookie");
|
|
47
53
|
if (cookieLookup.kind === "present") {
|
|
48
|
-
const sessionLookup = findAdminSessionCookieValue(cookieLookup.
|
|
54
|
+
const sessionLookup = findAdminSessionCookieValue(cookieLookup.cookieHeaderValue);
|
|
49
55
|
if (sessionLookup.kind === "found") {
|
|
50
56
|
forwarded.set(ADMIN_SESSION_HANDOFF_HEADER, sessionLookup.sessionValue);
|
|
51
57
|
}
|
|
@@ -57,17 +63,25 @@ function stripInboundHandoffHeader(originalHeaders) {
|
|
|
57
63
|
stripped.delete(ADMIN_SESSION_HANDOFF_HEADER);
|
|
58
64
|
return stripped;
|
|
59
65
|
}
|
|
60
|
-
async function forwardToBackend(
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
async function forwardToBackend({ originalRequest, originalUrl, target, targetPath, }) {
|
|
67
|
+
const targetUrl = new URL(targetPath + originalUrl.search, target.baseUrl);
|
|
68
|
+
let forwardedHeaders;
|
|
69
|
+
switch (target.kind) {
|
|
70
|
+
case "venture":
|
|
71
|
+
forwardedHeaders = buildVentureForwardedHeaders(originalRequest.headers);
|
|
72
|
+
break;
|
|
73
|
+
case "admin":
|
|
74
|
+
forwardedHeaders = stripInboundHandoffHeader(originalRequest.headers);
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
forwardedHeaders = target;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
66
80
|
try {
|
|
67
81
|
return await fetch(new Request(targetUrl, {
|
|
68
|
-
method:
|
|
82
|
+
method: originalRequest.method,
|
|
69
83
|
headers: forwardedHeaders,
|
|
70
|
-
body:
|
|
84
|
+
body: originalRequest.body,
|
|
71
85
|
redirect: "manual",
|
|
72
86
|
}));
|
|
73
87
|
}
|
|
@@ -88,26 +102,23 @@ async function forwardToBackend(forwardInput) {
|
|
|
88
102
|
});
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
|
-
function matchPathPrefix(
|
|
92
|
-
if (
|
|
105
|
+
function matchPathPrefix(pathPrefixMatchInput) {
|
|
106
|
+
if (pathPrefixMatchInput.pathname === pathPrefixMatchInput.prefix) {
|
|
93
107
|
return { kind: "match" };
|
|
94
108
|
}
|
|
95
|
-
if (
|
|
109
|
+
if (pathPrefixMatchInput.pathname.startsWith(pathPrefixMatchInput.prefix + "/")) {
|
|
96
110
|
return { kind: "match" };
|
|
97
111
|
}
|
|
98
112
|
return { kind: "no_match" };
|
|
99
113
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
function applyPathRewrite(params) {
|
|
104
|
-
switch (params.rewrite.kind) {
|
|
114
|
+
function applyPathRewrite(pathRewriteInput) {
|
|
115
|
+
switch (pathRewriteInput.rewrite.kind) {
|
|
105
116
|
case "identity":
|
|
106
|
-
return
|
|
117
|
+
return pathRewriteInput.incomingPath;
|
|
107
118
|
case "transform":
|
|
108
|
-
return
|
|
119
|
+
return pathRewriteInput.rewrite.apply(pathRewriteInput.incomingPath);
|
|
109
120
|
default:
|
|
110
|
-
return
|
|
121
|
+
return pathRewriteInput.rewrite;
|
|
111
122
|
}
|
|
112
123
|
}
|
|
113
124
|
function matchAllowedHost(matchParams) {
|
|
@@ -134,16 +145,13 @@ function buildHostRejectionResponse(rejectionInput) {
|
|
|
134
145
|
function normalizeBackend(backend) {
|
|
135
146
|
return { kind: backend.kind, baseUrl: stripTrailingSlash(backend.baseUrl) };
|
|
136
147
|
}
|
|
137
|
-
function normalizeRoute(
|
|
148
|
+
function normalizeRoute(proxyRoute) {
|
|
138
149
|
return {
|
|
139
|
-
pathPrefix:
|
|
140
|
-
target: normalizeBackend(
|
|
141
|
-
rewrite:
|
|
150
|
+
pathPrefix: proxyRoute.pathPrefix,
|
|
151
|
+
target: normalizeBackend(proxyRoute.target),
|
|
152
|
+
rewrite: proxyRoute.rewrite,
|
|
142
153
|
};
|
|
143
154
|
}
|
|
144
|
-
function assertNeverHealthCheck(healthCheck) {
|
|
145
|
-
throw new Error(`unreachable ProxyHealthCheck variant: ${JSON.stringify(healthCheck)}`);
|
|
146
|
-
}
|
|
147
155
|
function normalizeHealthCheck(healthCheck) {
|
|
148
156
|
switch (healthCheck.kind) {
|
|
149
157
|
case "disabled":
|
|
@@ -151,16 +159,16 @@ function normalizeHealthCheck(healthCheck) {
|
|
|
151
159
|
case "enabled":
|
|
152
160
|
return {
|
|
153
161
|
kind: "enabled",
|
|
154
|
-
|
|
162
|
+
healthPath: healthCheck.healthPath,
|
|
155
163
|
probeTargets: healthCheck.probeTargets.map(normalizeBackend),
|
|
156
164
|
buildHealthResponse: healthCheck.buildHealthResponse,
|
|
157
165
|
};
|
|
158
166
|
default:
|
|
159
|
-
return
|
|
167
|
+
return healthCheck;
|
|
160
168
|
}
|
|
161
169
|
}
|
|
162
170
|
/**
|
|
163
|
-
* Build a `
|
|
171
|
+
* Build a `ProxyRoute` that proxies `/auth/*` to the admin backend's `/api/auth/*`
|
|
164
172
|
* surface with cookies preserved. Every frontend that renders admin-shell's
|
|
165
173
|
* login UI needs this route, because admin-shell's `AdminRoute.*` constants
|
|
166
174
|
* (`/auth/login`, `/auth/logout`, `/auth/session`) are the single source of
|
|
@@ -170,9 +178,9 @@ function normalizeHealthCheck(healthCheck) {
|
|
|
170
178
|
* Spread the result into your `routes` array; do not hand-maintain the
|
|
171
179
|
* rewrite.
|
|
172
180
|
*
|
|
173
|
-
* @why
|
|
181
|
+
* @why Prevents each Worker from hand-writing the admin login rewrite because admin-shell's browser paths and admin-api's server paths intentionally differ.
|
|
174
182
|
* @param adminBaseUrl - Origin of the jakuta-admin API (scheme + host, no path)
|
|
175
|
-
* @returns A
|
|
183
|
+
* @returns A ProxyRoute that matches `/auth` / `/auth/*` and forwards to `adminBaseUrl/api/auth/*`
|
|
176
184
|
*/
|
|
177
185
|
export function createAdminAuthRoute(adminBaseUrl) {
|
|
178
186
|
return {
|
|
@@ -184,11 +192,32 @@ export function createAdminAuthRoute(adminBaseUrl) {
|
|
|
184
192
|
},
|
|
185
193
|
};
|
|
186
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Build a `ProxyRoute` that proxies generated admin-shell `/api/auth/*` requests
|
|
197
|
+
* to the Central Admin backend with cookies preserved.
|
|
198
|
+
*
|
|
199
|
+
* Mount this before the venture `/api/*` route. The generated admin-shell
|
|
200
|
+
* auth client now uses the same `/api/auth/*` route templates as the Central
|
|
201
|
+
* Admin backend, so the worker should forward those paths without rewriting
|
|
202
|
+
* them or applying venture cookie-to-header handoff.
|
|
203
|
+
*
|
|
204
|
+
* @why Preserves generated admin auth paths because venture workers must route
|
|
205
|
+
* Central Admin session requests before the general venture API proxy.
|
|
206
|
+
* @param adminBaseUrl - Origin of the jakuta-admin API (scheme + host, no path)
|
|
207
|
+
* @returns A ProxyRoute that matches `/api/auth` / `/api/auth/*` and forwards to Central Admin unchanged.
|
|
208
|
+
*/
|
|
209
|
+
export function createAdminApiAuthRoute(adminBaseUrl) {
|
|
210
|
+
return {
|
|
211
|
+
pathPrefix: "/api/auth",
|
|
212
|
+
target: { kind: "admin", baseUrl: stripTrailingSlash(adminBaseUrl) },
|
|
213
|
+
rewrite: { kind: "identity" },
|
|
214
|
+
};
|
|
215
|
+
}
|
|
187
216
|
/**
|
|
188
217
|
* Build a `ProxyHandler` from a declarative `ProxyHandlerConfig`. This is the
|
|
189
218
|
* single handler constructor — there is no separate venture or central-admin
|
|
190
219
|
* handler. Consumers express their routing topology as a list of
|
|
191
|
-
* `
|
|
220
|
+
* `ProxyRoute`s pointing at `Backend`s, and the handler dispatches by first-match.
|
|
192
221
|
*
|
|
193
222
|
* Every config must declare its `allowedHosts` — the non-empty list of
|
|
194
223
|
* hostnames this worker accepts. A request for any other hostname is
|
|
@@ -201,7 +230,7 @@ export function createAdminAuthRoute(adminBaseUrl) {
|
|
|
201
230
|
* handoff). There is no per-route override. See the `Backend` doc comment for
|
|
202
231
|
* why this is unrepresentable state, not a missing feature.
|
|
203
232
|
*
|
|
204
|
-
* @why
|
|
233
|
+
* @why Centralizes host allowlisting, backend URL normalization, and cookie-transform routing because individual worker entries must not diverge on those security rules.
|
|
205
234
|
* @param config - Declarative host allowlist, route list, and health-check hook
|
|
206
235
|
* @returns A ProxyHandler whose `handleRequest` dispatches the inbound request
|
|
207
236
|
*/
|
|
@@ -227,7 +256,7 @@ export function createProxyHandler(config) {
|
|
|
227
256
|
}
|
|
228
257
|
const pathname = requestUrl.pathname;
|
|
229
258
|
if (normalizedHealthCheck.kind === "enabled" &&
|
|
230
|
-
pathname === normalizedHealthCheck.
|
|
259
|
+
pathname === normalizedHealthCheck.healthPath) {
|
|
231
260
|
const probeResults = await Promise.all(normalizedHealthCheck.probeTargets.map(async (backend) => {
|
|
232
261
|
const probeResult = await probeHealth(backend.baseUrl);
|
|
233
262
|
return [backend.kind, probeResult];
|
|
@@ -239,17 +268,17 @@ export function createProxyHandler(config) {
|
|
|
239
268
|
const proxiedResponse = normalizedHealthCheck.buildHealthResponse(resultsByKind);
|
|
240
269
|
return { proxied: true, proxiedResponse };
|
|
241
270
|
}
|
|
242
|
-
for (const
|
|
243
|
-
const match = matchPathPrefix({ pathname, prefix:
|
|
271
|
+
for (const proxyRoute of normalizedRoutes) {
|
|
272
|
+
const match = matchPathPrefix({ pathname, prefix: proxyRoute.pathPrefix });
|
|
244
273
|
if (match.kind === "match") {
|
|
245
274
|
const rewrittenPath = applyPathRewrite({
|
|
246
|
-
rewrite:
|
|
275
|
+
rewrite: proxyRoute.rewrite,
|
|
247
276
|
incomingPath: pathname,
|
|
248
277
|
});
|
|
249
278
|
const proxiedResponse = await forwardToBackend({
|
|
250
279
|
originalRequest: workerRequest,
|
|
251
280
|
originalUrl: requestUrl,
|
|
252
|
-
target:
|
|
281
|
+
target: proxyRoute.target,
|
|
253
282
|
targetPath: rewrittenPath,
|
|
254
283
|
});
|
|
255
284
|
return { proxied: true, proxiedResponse };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"same-origin-proxy.js","sourceRoot":"","sources":["../src/same-origin-proxy.ts"],"names":[],"mappings":"AAuJA,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,SAAS,kBAAkB,CAAC,SAAiB;IAC3C,
|
|
1
|
+
{"version":3,"file":"same-origin-proxy.js","sourceRoot":"","sources":["../src/same-origin-proxy.ts"],"names":[],"mappings":"AAuJA,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,SAAS,kBAAk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AAE,aAAa;qBAC1B,CAAC,CAAC;oBACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;gBAC5C,CAAC;YACH,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ProxyRoute } from "./same-origin-proxy.js";
|
|
2
2
|
export declare const VENTURE_API_PREFIX = "/api";
|
|
3
3
|
/**
|
|
4
|
-
* @why
|
|
5
|
-
*
|
|
6
|
-
* Worker-side path contract aligned with the Rust `VENTURE_API_PREFIX`
|
|
7
|
-
* constant.
|
|
4
|
+
* @why Preserves the shared venture API prefix contract because worker proxy
|
|
5
|
+
* routes and Rust venture routing must agree on one mounted path.
|
|
8
6
|
*
|
|
9
7
|
* @param ventureBaseUrl - Origin of the venture backend (scheme + host, no path).
|
|
10
|
-
* @returns A
|
|
8
|
+
* @returns A ProxyRoute that matches `/api` / `/api/*` and forwards to `ventureBaseUrl`.
|
|
11
9
|
*/
|
|
12
|
-
export declare function createVentureApiRoute(ventureBaseUrl: string):
|
|
10
|
+
export declare function createVentureApiRoute(ventureBaseUrl: string): ProxyRoute;
|
|
13
11
|
//# sourceMappingURL=venture_api_route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"venture_api_route.d.ts","sourceRoot":"","sources":["../src/venture_api_route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"venture_api_route.d.ts","sourceRoot":"","sources":["../src/venture_api_route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAKzD,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,CAMxE"}
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
// and venture Worker proxies all agree on where the admin surface is nested.
|
|
4
4
|
export const VENTURE_API_PREFIX = "/api";
|
|
5
5
|
/**
|
|
6
|
-
* @why
|
|
7
|
-
*
|
|
8
|
-
* Worker-side path contract aligned with the Rust `VENTURE_API_PREFIX`
|
|
9
|
-
* constant.
|
|
6
|
+
* @why Preserves the shared venture API prefix contract because worker proxy
|
|
7
|
+
* routes and Rust venture routing must agree on one mounted path.
|
|
10
8
|
*
|
|
11
9
|
* @param ventureBaseUrl - Origin of the venture backend (scheme + host, no path).
|
|
12
|
-
* @returns A
|
|
10
|
+
* @returns A ProxyRoute that matches `/api` / `/api/*` and forwards to `ventureBaseUrl`.
|
|
13
11
|
*/
|
|
14
12
|
export function createVentureApiRoute(ventureBaseUrl) {
|
|
15
13
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"venture_api_route.js","sourceRoot":"","sources":["../src/venture_api_route.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"venture_api_route.js","sourceRoot":"","sources":["../src/venture_api_route.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,2EAA2E;AAC3E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,cAAsB;IACxD,OAAO;QACH,UAAU,EAAE,kBAAkB;QAC9B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE;QACpD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;KAChC,CAAC;AACN,CAAC"}
|