feat: complete TASK-WP0-04 local data boundary

This commit is contained in:
suyx
2026-07-27 18:45:50 +08:00
parent 878788b1e2
commit b5a6c6629e
11 changed files with 1178 additions and 2 deletions
+17
View File
@@ -34,6 +34,7 @@ import {
type BrowserUnsupportedReason,
} from "./browser-support.js";
import { EventHub } from "./event-hub.js";
import type { PublicAssetResolver } from "./local-data-root.js";
import { isAllowedNetworkRequest, type NetworkBoundaryOptions } from "./network-boundary.js";
const defaultBootstrap: BootstrapResponse = {
@@ -55,6 +56,7 @@ export interface CreateAppOptions {
browserSupportSecret?: Buffer;
eventHub?: EventHub;
networkBoundary?: NetworkBoundaryOptions;
publicAssets?: PublicAssetResolver;
}
const supportGateDirectory = resolve("apps/web/support-gate");
@@ -211,6 +213,21 @@ export async function createApp(options: CreateAppOptions = {}) {
status: "ready",
}));
app.get(
"/api/v1/assets/public/:resourceVersion/:assetId",
{ schema: { hide: true } },
async (request, reply) => {
const { assetId, resourceVersion } = request.params as { assetId?: string; resourceVersion?: string };
const resource = assetId && resourceVersion
? options.publicAssets?.read(resourceVersion, assetId)
: undefined;
if (!resource) return reply.code(404).send();
reply.type(resource.mimeType);
reply.header("Content-Disposition", "inline");
return resource.bytes;
},
);
app.post(
"/api/v1/support/check",
{