@hachej/boring-core 0.1.82 → 0.1.83
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/app/server/index.js +12 -1
- package/package.json +4 -4
package/dist/app/server/index.js
CHANGED
|
@@ -69,6 +69,7 @@ var MAX_SESSION_OWNER_CACHE = 5e3;
|
|
|
69
69
|
function createCoreWorkspaceBridge(options) {
|
|
70
70
|
const { resolveWorkspaceId, workspaceStore, validateWorkspaceId, agentSessionId } = options;
|
|
71
71
|
const admittedBrowserWorkspaces = /* @__PURE__ */ new WeakMap();
|
|
72
|
+
const admittedRuntimeWorkspaces = /* @__PURE__ */ new WeakMap();
|
|
72
73
|
const bridges = /* @__PURE__ */ new Map();
|
|
73
74
|
const getBridge = (workspaceId) => {
|
|
74
75
|
const safeWorkspaceId = validateWorkspaceId(workspaceId);
|
|
@@ -100,6 +101,8 @@ function createCoreWorkspaceBridge(options) {
|
|
|
100
101
|
return runtime;
|
|
101
102
|
};
|
|
102
103
|
const resolveBridgeWorkspaceId = async (request) => {
|
|
104
|
+
const admittedRuntimeWorkspace = admittedRuntimeWorkspaces.get(request);
|
|
105
|
+
if (admittedRuntimeWorkspace) return admittedRuntimeWorkspace;
|
|
103
106
|
const authHeader = request.headers.authorization;
|
|
104
107
|
if (options.workspaceBridge?.runtimeTokenSecret && typeof authHeader === "string" && authHeader.startsWith("Bearer ")) {
|
|
105
108
|
return verifyWorkspaceBridgeRuntimeToken(authHeader.slice("Bearer ".length), {
|
|
@@ -176,6 +179,7 @@ function createCoreWorkspaceBridge(options) {
|
|
|
176
179
|
}
|
|
177
180
|
} : void 0;
|
|
178
181
|
const registerHttpRoutes = async (app) => {
|
|
182
|
+
const assertRuntimeWorkspaceScope = options.assertRuntimeWorkspaceScope;
|
|
179
183
|
await app.register(async (bridgeApp) => {
|
|
180
184
|
bridgeApp.addHook("preHandler", async (request) => {
|
|
181
185
|
const pathname = request.url.split("?")[0];
|
|
@@ -189,6 +193,10 @@ function createCoreWorkspaceBridge(options) {
|
|
|
189
193
|
getIdempotencyStore: async (request) => getRuntime(await resolveBridgeWorkspaceId(request)).idempotencyStore,
|
|
190
194
|
runtimeTokenSecret: options.workspaceBridge?.runtimeTokenSecret,
|
|
191
195
|
runtimeRefreshTokenSecret: options.workspaceBridge?.runtimeRefreshTokenSecret,
|
|
196
|
+
assertRuntimeWorkspaceScope: assertRuntimeWorkspaceScope ? async (request, claims) => {
|
|
197
|
+
await assertRuntimeWorkspaceScope(request, claims.workspaceId);
|
|
198
|
+
admittedRuntimeWorkspaces.set(request, claims.workspaceId);
|
|
199
|
+
} : void 0,
|
|
192
200
|
getRuntimeRefreshTokenStore: (_request, claims) => getRuntime(claims.workspaceId).refreshTokenStore,
|
|
193
201
|
getOwnerWorkspaceId: async (request) => await resolveBridgeWorkspaceId(request),
|
|
194
202
|
browserAuthPolicy: createBrowserBridgeAuthPolicy({
|
|
@@ -923,7 +931,10 @@ async function createCoreWorkspaceAgentServer(options = {}) {
|
|
|
923
931
|
workspaceStore,
|
|
924
932
|
corsOrigins: app.config.cors.origins,
|
|
925
933
|
validateWorkspaceId: validateWorkspaceIdSegment,
|
|
926
|
-
agentSessionId: agentSessionIdFromRequest
|
|
934
|
+
agentSessionId: agentSessionIdFromRequest,
|
|
935
|
+
assertRuntimeWorkspaceScope: options.requestScopeResolver ? (request, workspaceId) => {
|
|
936
|
+
if (request.requestScope?.workspaceId !== workspaceId) d1HostScopeViolation(request);
|
|
937
|
+
} : void 0
|
|
927
938
|
});
|
|
928
939
|
app.addHook("preHandler", async (request) => {
|
|
929
940
|
await coreBridge.rememberSessionOwner(request);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hachej/boring-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.83",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Foundation package for boring-ui-v2 apps: DB, auth, config, HTTP app factory, and frontend app shell.",
|
|
@@ -80,9 +80,9 @@
|
|
|
80
80
|
"react-router-dom": "^7.18.0",
|
|
81
81
|
"smol-toml": "^1.7.0",
|
|
82
82
|
"zod": "^3.25.76",
|
|
83
|
-
"@hachej/boring-agent": "0.1.
|
|
84
|
-
"@hachej/boring-
|
|
85
|
-
"@hachej/boring-
|
|
83
|
+
"@hachej/boring-agent": "0.1.83",
|
|
84
|
+
"@hachej/boring-workspace": "0.1.83",
|
|
85
|
+
"@hachej/boring-ui-kit": "0.1.83"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@testing-library/jest-dom": "^6.9.1",
|