cursedbelt-server 4.48.0 → 4.48.1
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/server/activity/store.d.ts +1 -1
- package/dist/server/analytics/injectedScripts.d.ts +1 -1
- package/dist/server/analytics/injectedScripts.js +1 -1
- package/dist/server/analytics/webAnalytics.d.ts +1 -1
- package/dist/server/analytics/webAnalytics.js +1 -1
- package/dist/server/auth/loginThrottleDurable.d.ts +3 -3
- package/dist/server/auth/loginThrottleDurable.js +3 -3
- package/dist/server/auth/passwordCost.js +1 -1
- package/dist/server/ctgrChunkDurable.d.ts +1 -1
- package/dist/server/ctgrChunkDurable.js +1 -1
- package/dist/server/d1/backup.d.ts +1 -1
- package/dist/server/d1/backup.js +1 -1
- package/dist/server/d1/http.d.ts +2 -2
- package/dist/server/d1/http.js +2 -2
- package/dist/server/d1/invocation.js +1 -1
- package/dist/server/d1/limits.d.ts +1 -1
- package/dist/server/d1/limits.js +1 -1
- package/dist/server/d1/scheduling.d.ts +1 -1
- package/dist/server/d1/scheduling.js +1 -1
- package/dist/server/d1/types.d.ts +1 -1
- package/dist/server/d1/types.js +1 -1
- package/dist/server/d1/values.d.ts +1 -1
- package/dist/server/d1/values.js +1 -1
- package/dist/server/dropzone/scan.d.ts +1 -1
- package/dist/server/engagement/index.d.ts +1 -1
- package/dist/server/engagement/index.js +1 -1
- package/dist/server/guard/argon2Binding.js +1 -1
- package/dist/server/guard/kdfWorkerEntry.js +2 -2
- package/dist/server/incidents/index.d.ts +1 -1
- package/dist/server/incidents/index.js +1 -1
- package/dist/server/incidents/store.d.ts +1 -1
- package/dist/server/incidents/store.js +1 -1
- package/dist/server/jobs/timeout.d.ts +1 -1
- package/dist/server/jobs/timeout.js +1 -1
- package/dist/server/master-lock/accountsPage.d.ts +1 -1
- package/dist/server/master-lock/accountsPage.js +2 -2
- package/dist/server/master-lock/guard.js +1 -1
- package/dist/server/master-lock/lockPage.d.ts +1 -1
- package/dist/server/master-lock/lockPage.js +2 -2
- package/dist/server/master-lock/masterLock.d.ts +2 -2
- package/dist/server/master-lock/masterLock.js +2 -2
- package/dist/server/metrics/normalizeRoute.js +1 -1
- package/dist/server/metrics/telemetrySink.d.ts +2 -2
- package/dist/server/metrics/telemetrySink.js +1 -1
- package/dist/server/middleware/zValidator.js +2 -2
- package/dist/server/notifications/hub.js +1 -1
- package/dist/server/requestLog/requestMetrics.d.ts +2 -2
- package/dist/server/requestLog/requestMetrics.js +2 -2
- package/dist/server/retention/archive.d.ts +1 -1
- package/dist/server/retention/archive.js +2 -2
- package/dist/server/satellite/config.js +2 -2
- package/dist/server/satellite/door.d.ts +1 -1
- package/dist/server/sharing/contract.d.ts +1 -1
- package/dist/server/storage/binaryStore.d.ts +1 -1
- package/dist/server/storage/binaryStore.js +3 -3
- package/dist/server/storage/derivatives.d.ts +2 -2
- package/dist/server/storage/derivatives.js +2 -2
- package/dist/server/storage/files/adapter.d.ts +2 -2
- package/dist/server/storage/files/adapter.js +10 -10
- package/dist/server/storage/files/catalogue.d.ts +1 -1
- package/dist/server/storage/files/catalogue.js +4 -4
- package/dist/server/storage/files/chunkedUpload.d.ts +2 -2
- package/dist/server/storage/files/chunkedUpload.js +1 -1
- package/dist/server/storage/files/fileRoutes.d.ts +1 -1
- package/dist/server/storage/files/fileRoutes.js +4 -4
- package/dist/server/storage/files/mimeByExt.js +1 -1
- package/dist/server/storage/files/stack.d.ts +2 -2
- package/dist/server/storage/files/types.d.ts +4 -4
- package/dist/server/storage/files/types.js +1 -1
- package/dist/server/storage/index.js +1 -1
- package/dist/server/storage/objectStoreMediaStore.js +1 -1
- package/dist/server/storage/transcodeJobs.js +5 -5
- package/dist/server/storage/types.d.ts +1 -1
- package/dist/server/storage/types.js +1 -1
- package/dist/server/storage/videoDerivativeKeys.d.ts +1 -1
- package/dist/server/storage/videoDerivativeKeys.js +1 -1
- package/dist/server/storage/videoProcessor.js +1 -1
- package/dist/server/sync/status.d.ts +1 -1
- package/dist/server/zipStream.d.ts +1 -1
- package/dist/server/zipStream.js +1 -1
- package/docs/activity.md +2 -2
- package/docs/retention.md +2 -2
- package/package.json +1 -1
- package/src/leafSubpathsImportNothing.spec.ts +1 -1
- package/src/namedSubpathsResolve.spec.ts +1 -1
- package/src/noTimerDialsAPeer.spec.ts +1 -1
- package/src/nodeBuiltinsAreProbedByCalling.spec.ts +1 -1
- package/src/publishShape.spec.ts +1 -1
- package/src/server/activity/store.ts +1 -1
- package/src/server/analytics/injectedScripts.spec.ts +1 -1
- package/src/server/analytics/injectedScripts.ts +1 -1
- package/src/server/analytics/webAnalytics.ts +1 -1
- package/src/server/auth/loginThrottleDurable.ts +3 -3
- package/src/server/auth/passwordCost.ts +1 -1
- package/src/server/bench/cpuBudget.spec.ts +1 -1
- package/src/server/bench/tail.spec.ts +1 -1
- package/src/server/ctgrChunkDurable.ts +1 -1
- package/src/server/d1/backup.spec.ts +1 -1
- package/src/server/d1/backup.ts +1 -1
- package/src/server/d1/http.ts +2 -2
- package/src/server/d1/invocation.spec.ts +1 -1
- package/src/server/d1/invocation.ts +1 -1
- package/src/server/d1/limits.ts +1 -1
- package/src/server/d1/pullD1.spec.ts +1 -1
- package/src/server/d1/scheduling.ts +1 -1
- package/src/server/d1/types.ts +1 -1
- package/src/server/d1/values.ts +1 -1
- package/src/server/dropzone/scan.spec.ts +2 -2
- package/src/server/dropzone/scan.ts +1 -1
- package/src/server/engagement/engagement.spec.ts +1 -1
- package/src/server/engagement/index.ts +1 -1
- package/src/server/google-oauth/googleOAuth.spec.ts +1 -1
- package/src/server/guard/argon2Binding.ts +1 -1
- package/src/server/guard/kdfWorkerEntry.ts +2 -2
- package/src/server/incidents/index.ts +1 -1
- package/src/server/incidents/store.ts +1 -1
- package/src/server/jobs/timeout.ts +1 -1
- package/src/server/master-lock/accountsPage.spec.ts +2 -2
- package/src/server/master-lock/accountsPage.ts +2 -2
- package/src/server/master-lock/beaconNeverReachesTheWall.spec.ts +2 -2
- package/src/server/master-lock/guard.spec.ts +2 -2
- package/src/server/master-lock/guard.ts +1 -1
- package/src/server/master-lock/lockPage.spec.ts +1 -1
- package/src/server/master-lock/lockPage.ts +2 -2
- package/src/server/master-lock/masterLock.spec.ts +1 -1
- package/src/server/master-lock/masterLock.ts +2 -2
- package/src/server/master-lock/sessions.spec.ts +1 -1
- package/src/server/metrics/normalizeRoute.ts +1 -1
- package/src/server/metrics/telemetrySink.ts +3 -3
- package/src/server/middleware/bodyLimit.spec.ts +1 -1
- package/src/server/middleware/zValidator.spec.ts +3 -3
- package/src/server/middleware/zValidator.ts +3 -3
- package/src/server/notifications/hub.ts +1 -1
- package/src/server/requestLog/requestMetrics.spec.ts +2 -2
- package/src/server/requestLog/requestMetrics.ts +3 -3
- package/src/server/retention/archive.spec.ts +2 -2
- package/src/server/retention/archive.ts +2 -2
- package/src/server/satellite/config.ts +2 -2
- package/src/server/satellite/door.ts +1 -1
- package/src/server/satellite/satellite.spec.ts +1 -1
- package/src/server/sharing/contract.ts +1 -1
- package/src/server/storage/binaryServerProcessing.spec.ts +1 -1
- package/src/server/storage/binaryServerProcessing.ts +4 -4
- package/src/server/storage/binaryStore.spec.ts +6 -6
- package/src/server/storage/binaryStore.ts +4 -4
- package/src/server/storage/chunked.integration.spec.ts +2 -2
- package/src/server/storage/derivatives.ts +2 -2
- package/src/server/storage/fileUploadClient.integration.spec.ts +1 -1
- package/src/server/storage/files/adapter.photo.spec.ts +2 -2
- package/src/server/storage/files/adapter.spec.ts +3 -3
- package/src/server/storage/files/adapter.ts +10 -10
- package/src/server/storage/files/catalogue.spec.ts +1 -1
- package/src/server/storage/files/catalogue.ts +4 -4
- package/src/server/storage/files/chunkedUpload.spec.ts +5 -5
- package/src/server/storage/files/chunkedUpload.ts +3 -3
- package/src/server/storage/files/fileRoutes.spec.ts +3 -3
- package/src/server/storage/files/fileRoutes.ts +5 -5
- package/src/server/storage/files/mimeByExt.ts +1 -1
- package/src/server/storage/files/stack.ts +3 -3
- package/src/server/storage/files/types.ts +6 -6
- package/src/server/storage/index.ts +1 -1
- package/src/server/storage/objectStoreMediaStore.ts +1 -1
- package/src/server/storage/sources.ts +1 -1
- package/src/server/storage/transcodeJobs.ts +5 -5
- package/src/server/storage/types.ts +2 -2
- package/src/server/storage/uploadSession.spec.ts +1 -1
- package/src/server/storage/videoDerivativeKeys.spec.ts +3 -3
- package/src/server/storage/videoDerivativeKeys.ts +1 -1
- package/src/server/storage/videoProcessor.ts +1 -1
- package/src/server/sync/status.ts +1 -1
- package/src/server/sync/timer.spec.ts +1 -1
- package/src/server/worker-argon2/index.spec.ts +1 -1
- package/src/server/zipStream.spec.ts +2 -2
- package/src/server/zipStream.ts +1 -1
- package/src/shippedFilesAreTracked.spec.ts +2 -2
|
@@ -91,7 +91,7 @@ export function createNotificationHub(options: NotificationHubOptions = {}): Not
|
|
|
91
91
|
const set = listeners.get(userId);
|
|
92
92
|
if (!set) return;
|
|
93
93
|
// Snapshot: a listener may unsubscribe itself while being called (a
|
|
94
|
-
// stream that has just been
|
|
94
|
+
// stream that has just been canceled does exactly that).
|
|
95
95
|
for (const listener of [...set]) {
|
|
96
96
|
try {
|
|
97
97
|
listener(event);
|
|
@@ -94,7 +94,7 @@ describe("the check: a request through a real app lands a row", () => {
|
|
|
94
94
|
expect(rows()).toEqual([]);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
test("it sees every route: a
|
|
97
|
+
test("it sees every route: a parameterized route by its PATTERN, and a miss", async () => {
|
|
98
98
|
const metrics = track(openRequestMetrics(dir));
|
|
99
99
|
const app = appOver(metrics, (a) => a.get("/api/v1/thing/:id", (c) => c.json({ ok: true })));
|
|
100
100
|
await app.fetch(new Request("http://app.test/api/v1/thing/42"));
|
|
@@ -261,7 +261,7 @@ describe("0002_request_place — where a request came from, never its address (t
|
|
|
261
261
|
expect(names).toEqual(expect.arrayContaining(["region", "city"]));
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
-
test("the default places a
|
|
264
|
+
test("the default places a tunneled request by its cf-ipcountry header; a direct one is unplaced", async () => {
|
|
265
265
|
const m = track(openRequestMetrics(dir));
|
|
266
266
|
const app = appOver(m);
|
|
267
267
|
await app.fetch(new Request("http://app.test/healthz", { headers: { "cf-ipcountry": "CA" } }));
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* ── Why it is here (4.21.0) ─────────────────────────────────────────────────
|
|
7
7
|
* `apps/family` and `apps/roms` held this module byte-identically (task 265's rollout), and
|
|
8
8
|
* `check-copies` counted it as five copy groups. The API, the header marker and the migration name
|
|
9
|
-
* are exactly the apps' — a live corpus is
|
|
9
|
+
* are exactly the apps' — a live corpus is recognized by `METRICS_APPLICATION_ID` and by the
|
|
10
10
|
* `0001_request_metrics` row in its migrations table, so changing either would make every
|
|
11
11
|
* existing `metrics.sqlite` look inherited and archive it. Bun-only (`bun:sqlite`, `node:fs`): under
|
|
12
12
|
* Node the export map routes this subpath to `_bunOnly.js`, the way `./engagement` does; it is NOT
|
|
@@ -138,7 +138,7 @@ const sizeOf = (path: string): number => (existsSync(path) ? statSync(path).size
|
|
|
138
138
|
export function retireInheritedCorpus(dir: string): string | null {
|
|
139
139
|
const live = join(dir, METRICS_DB);
|
|
140
140
|
if (!existsSync(live)) return null;
|
|
141
|
-
// An empty file with no journal holds nothing — SQLite simply
|
|
141
|
+
// An empty file with no journal holds nothing — SQLite simply initializes it.
|
|
142
142
|
if (sizeOf(live) === 0 && SIDECARS.every((s) => sizeOf(live + s) === 0)) return null;
|
|
143
143
|
if (headerApplicationId(live) === METRICS_APPLICATION_ID) return null;
|
|
144
144
|
|
|
@@ -182,7 +182,7 @@ export interface RequestMetricsOptions {
|
|
|
182
182
|
/**
|
|
183
183
|
* Place each request (`{ country, region?, city? }` or `null`) — never an address; the raw IP
|
|
184
184
|
* is not stored. Default: the edge's own answer, `locateFromCloudflare` (the `cf-ipcountry`
|
|
185
|
-
* header every
|
|
185
|
+
* header every tunneled request carries). station passes its DB-IP reader here.
|
|
186
186
|
*/
|
|
187
187
|
locate?: RequestLocator;
|
|
188
188
|
}
|
|
@@ -46,7 +46,7 @@ describe("createJsonlArchive", () => {
|
|
|
46
46
|
]);
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
test("every segment is
|
|
49
|
+
test("every segment is cataloged in an APPEND-only index, and verifyArchive re-proves them", () => {
|
|
50
50
|
const dir = tmp();
|
|
51
51
|
const sink = createJsonlArchive({ app: "notes", resource: "sync-history", home: home(dir) });
|
|
52
52
|
sink.write([{ seq: 1 }], AT);
|
|
@@ -125,7 +125,7 @@ describe("pendingBytes — the staleness signal a deployed box can actually obse
|
|
|
125
125
|
expect(sink.pendingBytes()).toBe(second.bytes);
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
test("the
|
|
128
|
+
test("the catalog is not counted as pending — it is not history, it is the list", () => {
|
|
129
129
|
const dir = tmp();
|
|
130
130
|
const sink = createJsonlArchive({ app: "notes", resource: "sync-history", home: home(dir, false) });
|
|
131
131
|
const only = sink.write([{ seq: 1 }], AT);
|
|
@@ -190,7 +190,7 @@ export interface JsonlArchiveOptions {
|
|
|
190
190
|
* The index is what makes the archive answerable without reading gigabytes —
|
|
191
191
|
* "what is in here, how many rows, and does it still hash the same" — and it is
|
|
192
192
|
* appended rather than rewritten so a crash mid-write can cost at most the last
|
|
193
|
-
* line, never the
|
|
193
|
+
* line, never the catalog.
|
|
194
194
|
*/
|
|
195
195
|
export function createJsonlArchive(options: JsonlArchiveOptions): ArchiveSink {
|
|
196
196
|
const { app, resource } = options;
|
|
@@ -292,7 +292,7 @@ export function createJsonlArchive(options: JsonlArchiveOptions): ArchiveSink {
|
|
|
292
292
|
`${JSON.stringify({ app, resource, ...segment, path: undefined, file })}\n`,
|
|
293
293
|
);
|
|
294
294
|
} catch {
|
|
295
|
-
// The
|
|
295
|
+
// The catalog is a convenience; the segment is the archive. A failed
|
|
296
296
|
// index append must never make a sealed segment look unsealed and send
|
|
297
297
|
// the same rows through again.
|
|
298
298
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* ## Why, since 4.19.0 (task 281)
|
|
8
8
|
*
|
|
9
9
|
* Measured 2026-09-23: nine `appConfig.ts` copies in five versions, plus `appData.ts`,
|
|
10
|
-
* `stageIdentity.ts` and `runtimeMode.ts`
|
|
10
|
+
* `stageIdentity.ts` and `runtimeMode.ts` traveling with them. The file's whole job is
|
|
11
11
|
* `productionBlockers` + `assertUsable`, and the versions differed in exactly that job:
|
|
12
12
|
*
|
|
13
13
|
* · lineage B (`flix`, `station`, `patterns`) threw a plain `Error` — a misconfigured boot
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* The union of the protections is what is here. What an app still owns is its identity: its own
|
|
24
24
|
* fields, its `stakes` sentence, and its own blockers, passed as `extra` — never a fork of this.
|
|
25
25
|
*
|
|
26
|
-
* ## The one
|
|
26
|
+
* ## The one behavior that is STRICTER than every copy
|
|
27
27
|
*
|
|
28
28
|
* The refusal fires when the instance is `live` — a release OR a production build — where lineage
|
|
29
29
|
* A asked only "is this a production build". Every `scripts/service.ts` sets
|
|
@@ -139,7 +139,7 @@ export function parseEmailList(raw: string | undefined): string[] {
|
|
|
139
139
|
export interface DoorConfig {
|
|
140
140
|
/** A release — {@link isRelease}. */
|
|
141
141
|
deployed: boolean;
|
|
142
|
-
/** This instance's own origin, when known. A stage is
|
|
142
|
+
/** This instance's own origin, when known. A stage is recognized by it. */
|
|
143
143
|
publicUrl?: string;
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -55,7 +55,7 @@ describe('isRelease — one question, one variable', () => {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
describe('who the door opens for', () => {
|
|
58
|
-
it('a stage is
|
|
58
|
+
it('a stage is recognized by its own hostname, never by a flag', () => {
|
|
59
59
|
expect(isStageOrigin('https://vault-stage.cursedalchemy.com')).toBe(true);
|
|
60
60
|
expect(isStageOrigin('https://vault.cursedalchemy.com')).toBe(false);
|
|
61
61
|
expect(isStageOrigin('not a url')).toBe(false);
|
|
@@ -100,7 +100,7 @@ export type Awaitable<T> = T | Promise<T>;
|
|
|
100
100
|
/**
|
|
101
101
|
* Either store, as a consumer that works over both sees it: every method's result is
|
|
102
102
|
* {@link Awaitable}. `mountShareRoutes` takes this, and awaits every call — awaiting a
|
|
103
|
-
* synchronous value is a no-op, so the sync store's
|
|
103
|
+
* synchronous value is a no-op, so the sync store's behavior through it is unchanged.
|
|
104
104
|
*/
|
|
105
105
|
export type AwaitableShareStore = {
|
|
106
106
|
readonly [K in keyof AsyncShareStore]: AsyncShareStore[K] extends (...args: infer A) => Promise<infer R>
|
|
@@ -83,7 +83,7 @@ describe('createBinaryServerProcessing — video', () => {
|
|
|
83
83
|
expect(bs.submissions[0]?.posterOnly).toBe(true);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
test('a failed job maps to status failed (never throws into the
|
|
86
|
+
test('a failed job maps to status failed (never throws into the catalog)', async () => {
|
|
87
87
|
const bs = fakeBs({ fail: true });
|
|
88
88
|
const { videoProcessor } = createBinaryServerProcessing(cfg(bs.fetchImpl));
|
|
89
89
|
const res = await videoProcessor({
|
|
@@ -2,12 +2,12 @@ import type { ImageDerivatives, VideoProcessor } from './files/catalogue.js';
|
|
|
2
2
|
import { createTranscodeJobClient } from './transcodeJobs.js';
|
|
3
3
|
import { fsHlsPrefix, fsMp4Key, fsPosterKey, fsSpriteKey, fsVttKey } from './types.js';
|
|
4
4
|
|
|
5
|
-
// The cursedbelt file
|
|
5
|
+
// The cursedbelt file CATALOG's two derivative seams, bound to binary-server's transcode
|
|
6
6
|
// API. The transport itself — submit, poll, and the two derivative shapes — lives in
|
|
7
|
-
// `./transcodeJobs`, so an app that stores binaries WITHOUT a
|
|
7
|
+
// `./transcodeJobs`, so an app that stores binaries WITHOUT a catalog (apps/notes keys
|
|
8
8
|
// attachments by sha256 through satellite-kit's binary-store) can reach the same pipeline
|
|
9
|
-
// without adopting the
|
|
10
|
-
// pipeline in the fleet; this file is the
|
|
9
|
+
// without adopting the catalog or writing a second HTTP client. There is one derivative
|
|
10
|
+
// pipeline in the fleet; this file is the catalog-shaped door onto it.
|
|
11
11
|
//
|
|
12
12
|
// Why remote at all: the bytes already live on the binary-server host, which has real CPU,
|
|
13
13
|
// disk and ffmpeg. Pulling a multi-GB source down to the app host defeats the point, and the
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* the fork it replaces: the same risk, now with one blast radius instead of five.
|
|
19
19
|
*
|
|
20
20
|
* So the deliverable is the module AND its first real coverage. Everything below is an
|
|
21
|
-
* assertion about a
|
|
21
|
+
* assertion about a behavior the file's own prose claims — the memo demotions, the
|
|
22
22
|
* 429-is-not-a-404 rule, the chunk fallback, the stable window, the two-barrier delete
|
|
23
23
|
* — each one a documented incident that nothing could have caught a regression of.
|
|
24
24
|
*
|
|
@@ -49,7 +49,7 @@ import * as binaryStoreModule from './binaryStore.js';
|
|
|
49
49
|
import { binaryStoreFakeDefaults } from './binaryStoreFake.js';
|
|
50
50
|
|
|
51
51
|
// Read off the namespace, not named imports, so the task-2505 specs run (and go red on the
|
|
52
|
-
//
|
|
52
|
+
// BEHAVIOR) against a build that predates these exports — which is what prove-red does.
|
|
53
53
|
const { BINARY_PACED_MAX_WAIT_MS, BinaryStoreRateLimitedError } = binaryStoreModule;
|
|
54
54
|
|
|
55
55
|
// One 2048-bit keypair for the whole file — generation is the slow part, and every
|
|
@@ -253,7 +253,7 @@ describe('put', () => {
|
|
|
253
253
|
expect(calls.every((c) => c.url.includes('/upload-chunk/'))).toBe(true);
|
|
254
254
|
expect(tokenOf(calls[0]!.url).payload.sid).toBeString();
|
|
255
255
|
|
|
256
|
-
// …and `Infinity` restores the pre-2026-08-08
|
|
256
|
+
// …and `Infinity` restores the pre-2026-08-08 behavior for a caller that has a
|
|
257
257
|
// measured reason to want one request.
|
|
258
258
|
calls = [];
|
|
259
259
|
const direct = makeStore({ autoChunkBytes: Number.POSITIVE_INFINITY });
|
|
@@ -371,7 +371,7 @@ describe('the negative memo', () => {
|
|
|
371
371
|
expect(calls, 'a lapsed absence must re-ask').toHaveLength(2);
|
|
372
372
|
});
|
|
373
373
|
|
|
374
|
-
it('
|
|
374
|
+
it('honors a shorter TTL when an app has a measured reason', async () => {
|
|
375
375
|
const store = makeStore({ absenceTtlMs: 1_000 });
|
|
376
376
|
reply = () => ok(null, { status: 404 });
|
|
377
377
|
await store.get('art/missing');
|
|
@@ -621,7 +621,7 @@ describe('mediaUrl and the stable window', () => {
|
|
|
621
621
|
expect(a.payload.iat % 3600 === 0 && a.payload.exp - a.payload.iat === 7200).toBe(false);
|
|
622
622
|
});
|
|
623
623
|
|
|
624
|
-
it('
|
|
624
|
+
it('honors an explicit ttlSeconds', async () => {
|
|
625
625
|
const store = makeStore();
|
|
626
626
|
const { payload } = tokenOf(await store.mediaUrl('art/z', { ttlSeconds: 15 }));
|
|
627
627
|
expect(payload.exp - payload.iat).toBe(15);
|
|
@@ -739,7 +739,7 @@ describe('fetchMedia', () => {
|
|
|
739
739
|
expect(calls[0]?.init?.headers).toBeUndefined();
|
|
740
740
|
});
|
|
741
741
|
|
|
742
|
-
it('
|
|
742
|
+
it('honors HEAD and forwards an abort signal', async () => {
|
|
743
743
|
const store = makeStore();
|
|
744
744
|
reply = () => ok(null);
|
|
745
745
|
const controller = new AbortController();
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* binary-server.
|
|
29
29
|
*
|
|
30
30
|
* 🔴 It is published as the LEAF subpath `cursedbelt-server/binary-store`, never through
|
|
31
|
-
* the `./storage` barrel — that barrel drags the file-
|
|
31
|
+
* the `./storage` barrel — that barrel drags the file-catalog and transcode graph, and
|
|
32
32
|
* this module's whole promise is that an app pays nothing but `node:crypto` for it.
|
|
33
33
|
* `src/leafSubpathsImportNothing.spec.ts` is what holds that promise.
|
|
34
34
|
*
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* three forks of the fleet's binary-storage client looked like from the outside. The
|
|
39
39
|
* divergence was measured before the move and was entirely in prose and in one stale
|
|
40
40
|
* import specifier (`cursedbelt/server/storage`, the pre-split package name) — no
|
|
41
|
-
*
|
|
41
|
+
* behavioral difference in any of the three, so nothing was dropped to land the union.
|
|
42
42
|
*/
|
|
43
43
|
import { createHash, createPrivateKey, createPublicKey, sign as cryptoSign, type KeyObject } from 'node:crypto';
|
|
44
44
|
import type { FileTokenClaims } from './types.js';
|
|
@@ -263,7 +263,7 @@ export interface ReadOptions {
|
|
|
263
263
|
* 🔴 Wait out binary-server's read ceiling instead of throwing it (task 2505).
|
|
264
264
|
*
|
|
265
265
|
* The store allows a tenant a burst of reads, then a steady rate, and answers 429 with the
|
|
266
|
-
* `retry-after` it wants
|
|
266
|
+
* `retry-after` it wants honored (`apps/binary-server/src/rateLimit.ts`). A batch read —
|
|
267
267
|
* roms filing a disc's 256 parts, a hash backfill, an import — met it at read ~204 and threw
|
|
268
268
|
* the whole pass away. `paced` makes `get`/`meta`/`stat` sleep the named `retry-after` and ask
|
|
269
269
|
* again, for at most {@link BINARY_PACED_MAX_WAIT_MS} in total (or `{ maxWaitMs }`).
|
|
@@ -906,7 +906,7 @@ export function createBinaryStore(cfg: BinaryStoreConfig): BinaryStore {
|
|
|
906
906
|
known(key) {
|
|
907
907
|
// Order matters: a lapsed absence is DROPPED by `knownAbsent`, so asking it
|
|
908
908
|
// first keeps this accessor from reporting an expiry the next real read would
|
|
909
|
-
// not
|
|
909
|
+
// not honor. A positive memo has no expiry, so it needs no such care.
|
|
910
910
|
if (knownAbsent(key)) return 'absent';
|
|
911
911
|
return present.has(key) ? 'present' : 'unknown';
|
|
912
912
|
},
|
|
@@ -19,7 +19,7 @@ import type { MediaCtx } from './types.js';
|
|
|
19
19
|
|
|
20
20
|
// End-to-end PROOF of the large-file (chunked) upload against a REAL binary-server: spawn bs with
|
|
21
21
|
// a boot-registered app (our RS256 public key), then run the exact client flow — init → PUT each
|
|
22
|
-
// chunk DIRECT to bs → bs assembles on the last chunk → complete registers the
|
|
22
|
+
// chunk DIRECT to bs → bs assembles on the last chunk → complete registers the catalog row over
|
|
23
23
|
// the assembled bytes — and read the bytes back through the store. Skips cleanly when the local
|
|
24
24
|
// binary-server checkout isn't present (CI / other machines).
|
|
25
25
|
const BS_DIR = process.env.BINARY_SERVER_DIR ?? '';
|
|
@@ -174,7 +174,7 @@ describe.skipIf(!BS_PRESENT)('chunked upload → real binary-server (integration
|
|
|
174
174
|
}
|
|
175
175
|
expect(assembled).toBe(true); // bs assembled on the final chunk
|
|
176
176
|
|
|
177
|
-
// Complete → the
|
|
177
|
+
// Complete → the catalog row exists over the already-assembled bytes (no re-upload).
|
|
178
178
|
const rec = await svc.complete(init.sid, { size });
|
|
179
179
|
expect(rec?.id).toBe(init.fileId);
|
|
180
180
|
expect(rec?.name).toBe('big.bin');
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* owner's 2026-08-14 ruling — *"Make it in cb because many apps may move to cloudflare and share
|
|
6
6
|
* the logic"*); what was still copied into `collections` and `family` as `src/kit/imageDerivatives.ts`
|
|
7
7
|
* and `src/kit/videoDerivatives.ts` was the READING strategy built on them — the part with the
|
|
8
|
-
*
|
|
8
|
+
* judgment in it. The video copy had already forked (three import lines and a doc comment, benign
|
|
9
9
|
* by accident), and the HEIC rule below decides whether a photograph appears AT ALL, which may not
|
|
10
10
|
* exist in two places.
|
|
11
11
|
*
|
|
@@ -178,7 +178,7 @@ export const isUnviewableStill = (
|
|
|
178
178
|
* ── 🔴 Why this is here, from the owner's report (2026-08-14) ────────────────────────
|
|
179
179
|
* *"videos are not showing with thumbnails in the family app keepsakes"*, with a screenshot
|
|
180
180
|
* of one album: eleven photographs with tiles and three videos — 129, 282 and 633 MB — drawn
|
|
181
|
-
* as a
|
|
181
|
+
* as a gray play triangle.
|
|
182
182
|
*
|
|
183
183
|
* Nothing was broken. binary-server's `runPoster` had always existed and was reachable only
|
|
184
184
|
* from its `library` strategy, while `family` and `collections` both submit `faststart`,
|
|
@@ -60,7 +60,7 @@ describe('createFileUploadClient ⇄ mountFileRoutes', () => {
|
|
|
60
60
|
|
|
61
61
|
let uploadedId = '';
|
|
62
62
|
|
|
63
|
-
test('upload carries filename + tags through to the
|
|
63
|
+
test('upload carries filename + tags through to the catalog row', async () => {
|
|
64
64
|
const res = await client.upload(new File(['hello'], 'notes.txt', { type: 'text/plain' }), {
|
|
65
65
|
tags: ['a', 'b'],
|
|
66
66
|
});
|
|
@@ -13,7 +13,7 @@ import type { FileUrls } from './fileRoutes.js';
|
|
|
13
13
|
import { FILE_CATALOGUE_MIGRATIONS } from './migrations.js';
|
|
14
14
|
import type { FileCatalogue } from './types.js';
|
|
15
15
|
|
|
16
|
-
// The photo source is an image-filtered VIEW over the
|
|
16
|
+
// The photo source is an image-filtered VIEW over the catalog: primary bytes via the file
|
|
17
17
|
// route URL, grid thumb via the type-agnostic poster URL (only when the thumbnailer produced one).
|
|
18
18
|
|
|
19
19
|
const CTX: MediaCtx = { userId: 'u1', tenantId: 't1' };
|
|
@@ -114,7 +114,7 @@ describe('createCataloguePhotoSource', () => {
|
|
|
114
114
|
).rejects.toThrow(/image/);
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
test('remove trashes (soft-deletes) through to the
|
|
117
|
+
test('remove trashes (soft-deletes) through to the catalog, not a hard delete', async () => {
|
|
118
118
|
const rec = await cat.ingest(CTX, {
|
|
119
119
|
name: 'gone.png',
|
|
120
120
|
mime: 'image/png',
|
|
@@ -72,7 +72,7 @@ describe('createFileToPlayable', () => {
|
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
describe('createCatalogueVideoSource (gallery = view over
|
|
75
|
+
describe('createCatalogueVideoSource (gallery = view over catalog)', () => {
|
|
76
76
|
let db: Database;
|
|
77
77
|
let root: string;
|
|
78
78
|
let cat: FileCatalogue;
|
|
@@ -105,10 +105,10 @@ describe('createCatalogueVideoSource (gallery = view over catalogue)', () => {
|
|
|
105
105
|
urls: fakeUrls,
|
|
106
106
|
});
|
|
107
107
|
const page = await src.list(CTX, {});
|
|
108
|
-
expect(page.items).toEqual([]); //
|
|
108
|
+
expect(page.items).toEqual([]); // catalog has an image + a doc, zero videos
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
test('tags() reflects the
|
|
111
|
+
test('tags() reflects the catalog facets', async () => {
|
|
112
112
|
const src = createCatalogueVideoSource({
|
|
113
113
|
id: 'files',
|
|
114
114
|
title: 'Files',
|
|
@@ -36,15 +36,15 @@ function createFileToPhoto(cfg: {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// ── FileCatalogue → media seam ────────────────────────────────────────────────────
|
|
39
|
-
// The
|
|
40
|
-
// separate store — it is a video-filtered VIEW over the
|
|
39
|
+
// The catalog is the ONE source of truth for a user's binaries. The video gallery is not a
|
|
40
|
+
// separate store — it is a video-filtered VIEW over the catalog. These two adapters are the
|
|
41
41
|
// seam: `createFileToPlayable` turns a video FileRecord into the player's PlayableVideo (URLs
|
|
42
42
|
// baked server-side via the shared token/serve infra), and `createCatalogueVideoSource` exposes
|
|
43
|
-
// the
|
|
43
|
+
// the catalog as a `MediaSource` so the existing `mountMediaRoutes` + gallery serve it
|
|
44
44
|
// unchanged. Because the serve routes address bytes by (owner, videoId) through the shared
|
|
45
|
-
// keyspace, a
|
|
45
|
+
// keyspace, a catalog video is served by the same routes regardless of `sourceId`.
|
|
46
46
|
|
|
47
|
-
/** Resolve a video FileRecord to a PlayableVideo with
|
|
47
|
+
/** Resolve a video FileRecord to a PlayableVideo with tokenized URLs. Non-video ⇒ null. */
|
|
48
48
|
export function createFileToPlayable(urls: MediaUrls, sourceId: string): FileToPlayable {
|
|
49
49
|
return async (ctx, file) => {
|
|
50
50
|
if (file.fileType !== 'video') return null;
|
|
@@ -117,7 +117,7 @@ export function createCatalogueVideoSource(cfg: {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// ── Photo view ────────────────────────────────────────────────────────────────────
|
|
120
|
-
// The photo gallery is the image-filtered sibling of the video view: same
|
|
120
|
+
// The photo gallery is the image-filtered sibling of the video view: same catalog, same
|
|
121
121
|
// token/serve infra. The primary image is served by the file byte route (fileUrls) and the grid
|
|
122
122
|
// thumbnail by the type-agnostic poster route (mediaUrls) when the ingest thumbnailer produced
|
|
123
123
|
// one — so a PhotoSource needs BOTH URL builders.
|
|
@@ -179,15 +179,15 @@ export function createCataloguePhotoSource(cfg: {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// ── Mixed media view ───────────────────────────────────────────────────────────────
|
|
182
|
-
// A combined gallery lists BOTH photos and videos from the one
|
|
182
|
+
// A combined gallery lists BOTH photos and videos from the one catalog. This adapter
|
|
183
183
|
// reuses the same two mappers (`createFileToPlayable`, `createFileToPhoto`) so a mixed
|
|
184
184
|
// item renders identically to its single-type sibling — it just tags each with
|
|
185
185
|
// `mediaKind` for the UI to pick a tile/stage. It needs BOTH URL builders (video streams
|
|
186
|
-
// + image bytes/poster). A `kind` filter maps to the
|
|
186
|
+
// + image bytes/poster). A `kind` filter maps to the catalog's `type`; `all` lists
|
|
187
187
|
// untyped and keeps only image|video (dropping docs/audio the mixed gallery can't show).
|
|
188
188
|
|
|
189
189
|
/** Expose a FileCatalogue as a `MediaGallerySource` — photos + videos in one feed.
|
|
190
|
-
* Videos are
|
|
190
|
+
* Videos are tokenized under `videoSourceId` (must match the registered video source so
|
|
191
191
|
* `mountMediaRoutes` serves their streams); photo posters/thumbnails under this source's `id`. */
|
|
192
192
|
export function createCatalogueMediaSource(cfg: {
|
|
193
193
|
id: string;
|
|
@@ -218,7 +218,7 @@ export function createCatalogueMediaSource(cfg: {
|
|
|
218
218
|
title: cfg.title,
|
|
219
219
|
|
|
220
220
|
async list(ctx, opts) {
|
|
221
|
-
// `all` ⇒ no
|
|
221
|
+
// `all` ⇒ no catalog type filter, then drop non-image/video below.
|
|
222
222
|
const type = opts.kind === 'image' ? 'image' : opts.kind === 'video' ? 'video' : undefined;
|
|
223
223
|
const page = await cfg.catalogue.list(ctx, {
|
|
224
224
|
type,
|
|
@@ -109,7 +109,7 @@ describe('FileCatalogue (SQLite)', () => {
|
|
|
109
109
|
|
|
110
110
|
test('remove deletes an image’s binary AND its poster thumbnail from the store', async () => {
|
|
111
111
|
const img = await ingest('orphan.png', 'image/png');
|
|
112
|
-
const owner = CTX.tenantId; //
|
|
112
|
+
const owner = CTX.tenantId; // catalog's default ownerOf
|
|
113
113
|
// Simulate the thumbnail the async kickImageThumbnail pipeline writes.
|
|
114
114
|
await store.put(fsPosterKey(owner, img.id), bytes('thumb'), 'image/jpeg');
|
|
115
115
|
expect(await store.stat(fileBinaryKey(owner, img.id))).not.toBeNull();
|
|
@@ -64,7 +64,7 @@ export const fileBinaryKey = (owner: string, id: string) => `fs/${owner}/${id}`;
|
|
|
64
64
|
|
|
65
65
|
/** Where a file's uploaded bytes must land for `registerUploaded` to find them: a video's raw
|
|
66
66
|
* source (fed to the transcode), else the primary binary. The chunked-upload path targets this key
|
|
67
|
-
* so an out-of-band upload lands exactly where the
|
|
67
|
+
* so an out-of-band upload lands exactly where the catalog + serve routes expect it. */
|
|
68
68
|
export const catalogueUploadKey = (owner: string, id: string, mime: string): string =>
|
|
69
69
|
mime.startsWith('video/') ? fsSourceKey(owner, id) : fileBinaryKey(owner, id);
|
|
70
70
|
|
|
@@ -423,7 +423,7 @@ export function createSqliteFileCatalogue(opts: SqliteFileCatalogueOptions): Fil
|
|
|
423
423
|
updatedAt: row.updated_at,
|
|
424
424
|
});
|
|
425
425
|
|
|
426
|
-
// A background job can outlive this
|
|
426
|
+
// A background job can outlive this catalog's Database — a host shutting down mid-transcode,
|
|
427
427
|
// or a test teardown that closed the db after its settle timeout. The job's late progress/result
|
|
428
428
|
// writes must not crash the process (the rows they'd update are gone with the closed db, and
|
|
429
429
|
// recoverProcessing re-kicks anything left 'processing' on the next boot) — drop exactly the
|
|
@@ -748,7 +748,7 @@ export function createSqliteFileCatalogue(opts: SqliteFileCatalogueOptions): Fil
|
|
|
748
748
|
|
|
749
749
|
async registerUploaded(ctx, upload) {
|
|
750
750
|
// Bytes were uploaded out-of-band (a chunked upload direct to binary-server) and already sit
|
|
751
|
-
// at the
|
|
751
|
+
// at the catalog's key (fsSourceKey for video, fileBinaryKey otherwise). Just create the
|
|
752
752
|
// row + kick processing — no re-store. The caller owns having placed the bytes correctly.
|
|
753
753
|
return finalizePublicRow(ownerOf(ctx), upload.id, upload, upload.size, now());
|
|
754
754
|
},
|
|
@@ -895,7 +895,7 @@ export function createSqliteFileCatalogue(opts: SqliteFileCatalogueOptions): Fil
|
|
|
895
895
|
}
|
|
896
896
|
|
|
897
897
|
// Directory: recurse, tagging each file with its immediate containing folder name so the
|
|
898
|
-
// origin structure survives as a (flat) tag facet rather than a tree the
|
|
898
|
+
// origin structure survives as a (flat) tag facet rather than a tree the catalog doesn't
|
|
899
899
|
// model. The top-level directory itself is NOT used as a tag (it's just the import root).
|
|
900
900
|
const walk = async (dir: string, isRoot: boolean): Promise<void> => {
|
|
901
901
|
let entries: Dirent[];
|
|
@@ -71,7 +71,7 @@ describe('chunked upload', () => {
|
|
|
71
71
|
// without this the minter has nothing to put in the token's `sz` claim, and binary-server's
|
|
72
72
|
// only end-to-end check of the finished object against its source stays inert.
|
|
73
73
|
expect(minted.map((m) => m.sz)).toEqual([20 * 1024 * 1024, 20 * 1024 * 1024, 20 * 1024 * 1024]);
|
|
74
|
-
// The mint targets exactly the key the
|
|
74
|
+
// The mint targets exactly the key the catalog will look for on complete.
|
|
75
75
|
expect(init.key).toBe(catalogueUploadKey('u1', init.fileId, 'image/png'));
|
|
76
76
|
|
|
77
77
|
// A durable pending 'upload' op keyed by the session id.
|
|
@@ -84,7 +84,7 @@ describe('chunked upload', () => {
|
|
|
84
84
|
|
|
85
85
|
test('🔴 a size the caller could not state is OMITTED, never declared as zero', async () => {
|
|
86
86
|
// `sz: 0` would compare zero to the assembled length and refuse every assemble — so an
|
|
87
|
-
// unknown size degrades to exactly today's
|
|
87
|
+
// unknown size degrades to exactly today's behavior (no claim, recorded undeclared) rather
|
|
88
88
|
// than to a 422. `chunkCount` still clamps to one chunk, which is the old `req.size || 1`.
|
|
89
89
|
const { svc, minted } = build();
|
|
90
90
|
const init = await svc.init(CTX, { name: 'unknown.bin', mime: 'application/octet-stream', size: 0 });
|
|
@@ -92,7 +92,7 @@ describe('chunked upload', () => {
|
|
|
92
92
|
expect(minted.map((m) => m.sz)).toEqual([undefined]);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
test('complete registers the
|
|
95
|
+
test('complete registers the catalog row over the assembled bytes + marks the op done', async () => {
|
|
96
96
|
const { catalogue, ledger, svc } = build();
|
|
97
97
|
const init = await svc.init(CTX, {
|
|
98
98
|
name: 'photo.png',
|
|
@@ -105,7 +105,7 @@ describe('chunked upload', () => {
|
|
|
105
105
|
expect(rec?.id).toBe(init.fileId);
|
|
106
106
|
expect(rec?.name).toBe('photo.png');
|
|
107
107
|
expect(rec?.tags).toEqual(['big']);
|
|
108
|
-
// Now discoverable through the normal
|
|
108
|
+
// Now discoverable through the normal catalog (no re-upload happened).
|
|
109
109
|
expect((await catalogue.get(CTX, init.fileId))?.name).toBe('photo.png');
|
|
110
110
|
expect(ledger.get(init.sid)?.status).toBe('done');
|
|
111
111
|
expect(svc.pending()).toBe(0);
|
|
@@ -114,7 +114,7 @@ describe('chunked upload', () => {
|
|
|
114
114
|
expect(await svc.complete(init.sid)).toBeNull();
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
test('abort marks the op failed and drops the session (no
|
|
117
|
+
test('abort marks the op failed and drops the session (no catalog row)', async () => {
|
|
118
118
|
const { catalogue, ledger, svc } = build();
|
|
119
119
|
const init = await svc.init(CTX, { name: 'x.png', mime: 'image/png', size: 1 });
|
|
120
120
|
svc.abort(init.sid);
|
|
@@ -10,7 +10,7 @@ import type { FileCatalogue, FileRecord } from './types.js';
|
|
|
10
10
|
// backend (binary-server), records a durable `upload` ledger op, and hands the URLs back. The
|
|
11
11
|
// client PUTs each chunk to the backend, which assembles them at the target key once the last
|
|
12
12
|
// arrives. Then the client (or a backend webhook) calls COMPLETE, and the app registers the
|
|
13
|
-
//
|
|
13
|
+
// catalog row over the already-stored bytes (no re-upload) + kicks processing.
|
|
14
14
|
//
|
|
15
15
|
// This module is backend-AGNOSTIC: the app injects `mintChunkUpload` (the binary-server chunk URL
|
|
16
16
|
// + signed sid/ci/tc token). On disk-only deploys, an app simply doesn't wire chunked uploads and
|
|
@@ -52,10 +52,10 @@ export interface ChunkedUploadService {
|
|
|
52
52
|
ctx: MediaCtx,
|
|
53
53
|
req: { name: string; mime: string; size: number; tags?: string[] },
|
|
54
54
|
): Promise<ChunkedInit>;
|
|
55
|
-
/** Finish it: mark the op done and register the
|
|
55
|
+
/** Finish it: mark the op done and register the catalog row over the assembled bytes. Returns
|
|
56
56
|
* the new record, or null if the session is unknown (already completed / server restarted). */
|
|
57
57
|
complete(sid: string, confirmed?: { size?: number }): Promise<FileRecord | null>;
|
|
58
|
-
/** Give up on a session (client
|
|
58
|
+
/** Give up on a session (client canceled / a chunk failed) — mark the ledger op failed. */
|
|
59
59
|
abort(sid: string): void;
|
|
60
60
|
/** Open session count (observability / tests). */
|
|
61
61
|
pending(): number;
|
|
@@ -145,12 +145,12 @@ describe('fileRoutes — GET list route (filters + sort passthrough)', () => {
|
|
|
145
145
|
|
|
146
146
|
describe('fileRoutes — single-PUT upload cap (MAX_SINGLE_UPLOAD_BYTES → 413)', () => {
|
|
147
147
|
// The law: no single request may carry more than the cap; larger files must chunk. The guard
|
|
148
|
-
// fails fast on Content-Length. A fake
|
|
148
|
+
// fails fast on Content-Length. A fake catalog captures whether ingest was even reached.
|
|
149
149
|
let ingested = 0;
|
|
150
150
|
const fakeCatalogue = {
|
|
151
151
|
async ingest(_ctx: MediaCtx, upload: { body: ReadableStream<Uint8Array> }) {
|
|
152
152
|
// Drain the body so the guard's streaming byte-cap transform actually runs (a real
|
|
153
|
-
//
|
|
153
|
+
// catalog writes it to the store; here we just discard it). Over the cap, the transform
|
|
154
154
|
// errors the stream and this read rejects.
|
|
155
155
|
const reader = upload.body.getReader();
|
|
156
156
|
let done = false;
|
|
@@ -194,7 +194,7 @@ describe('fileRoutes — single-PUT upload cap (MAX_SINGLE_UPLOAD_BYTES → 413)
|
|
|
194
194
|
const res = await putWithLength(MAX_SINGLE_UPLOAD_BYTES + 1);
|
|
195
195
|
expect(res.status).toBe(413);
|
|
196
196
|
expect(((await res.json()) as { error: string }).error).toBe(SINGLE_UPLOAD_TOO_LARGE);
|
|
197
|
-
expect(ingested).toBe(0); // fail-fast: never touched the
|
|
197
|
+
expect(ingested).toBe(0); // fail-fast: never touched the catalog
|
|
198
198
|
});
|
|
199
199
|
|
|
200
200
|
test('Content-Length at the cap → allowed', async () => {
|
|
@@ -14,7 +14,7 @@ import { FILE_SORTS, type FileCatalogue, type ListFilesOptions } from './types.j
|
|
|
14
14
|
// can't send a Bearer). Uploads DO carry the app Bearer, so the PUT routes are session-guarded.
|
|
15
15
|
//
|
|
16
16
|
// `sourceId` for a file token is the constant 'files'. The served Content-Type is carried as a
|
|
17
|
-
// signed-URL query (`?ct=`) — the
|
|
17
|
+
// signed-URL query (`?ct=`) — the catalog knows each file's mime when it builds the URL, so the
|
|
18
18
|
// route needn't re-derive it. It only ever serves the token owner's own bytes.
|
|
19
19
|
|
|
20
20
|
const FILE_SOURCE_ID = 'files';
|
|
@@ -42,7 +42,7 @@ const isUploadTooLarge = (e: unknown): boolean =>
|
|
|
42
42
|
* Content-Length header (browsers set it for a File/Blob body), and — for length-less chunked
|
|
43
43
|
* transfer — wraps the stream to abort once the accumulated bytes pass the cap (the wrapping error
|
|
44
44
|
* surfaces from `catalogue.ingest`, which the handlers turn into a 413). Returns either the body to
|
|
45
|
-
* hand to the
|
|
45
|
+
* hand to the catalog, or a 413 Response to return immediately.
|
|
46
46
|
*/
|
|
47
47
|
function guardSingleUpload(
|
|
48
48
|
c: Context,
|
|
@@ -99,7 +99,7 @@ export type MountFileRoutesOptions = {
|
|
|
99
99
|
basePath?: string;
|
|
100
100
|
/** Session auth for the upload PUTs (a fetch CAN send the Bearer). Return a ctx or null. */
|
|
101
101
|
authorizeUpload?: (c: Context) => Promise<MediaCtx | null> | MediaCtx | null;
|
|
102
|
-
/** The
|
|
102
|
+
/** The catalog uploads land in. Required for the upload routes to be mounted. */
|
|
103
103
|
catalogue?: FileCatalogue;
|
|
104
104
|
/** Wire large-file chunked uploads (direct-to-backend). Omit ⇒ init/complete routes are absent
|
|
105
105
|
* and clients use the streamed `PUT /upload`. Uses the same `authorizeUpload` guard. */
|
|
@@ -221,12 +221,12 @@ export function mountFileRoutes(app: Hono, opts: MountFileRoutesOptions): void {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
// ── Listing + collection routes ───────────────────────────────────────────────
|
|
224
|
-
// All require authorizeUpload (session auth) and a
|
|
224
|
+
// All require authorizeUpload (session auth) and a catalog. They follow the same
|
|
225
225
|
// auth/ctx/envelope pattern as the upload routes above. The `includeUnlockable` gate is the
|
|
226
226
|
// caller's responsibility — the route passes the query param through, and it's the app's session
|
|
227
227
|
// middleware that decides whether the caller has unlocked.
|
|
228
228
|
if (opts.authorizeUpload && catalogue) {
|
|
229
|
-
// GET /_files/list → cursor-paginated
|
|
229
|
+
// GET /_files/list → cursor-paginated catalog listing. Query params mirror
|
|
230
230
|
// ListFilesOptions: type, tag, query (q), collectionId, favorite, includeUnlockable,
|
|
231
231
|
// sort (recent|oldest|name|size|random|lastViewed), cursor, limit.
|
|
232
232
|
app.get(`${base}/list`, async (c) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mimeForFilename } from 'cwip/string';
|
|
2
2
|
|
|
3
|
-
// Ext → mime for local-disk import (catalogue.importFromPath) — the
|
|
3
|
+
// Ext → mime for local-disk import (catalogue.importFromPath) — the catalog needs SOME mime
|
|
4
4
|
// to classify + serve a file that never passed through a browser's upload Content-Type.
|
|
5
5
|
//
|
|
6
6
|
// The table itself moved DOWN to `cwip/string`'s `fileKind` (2026-07-31): the viewer UI and the
|