cursedbelt-server 4.48.0 → 4.49.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/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/pullD1.d.ts +4 -1
- package/dist/server/d1/pullD1.js +5 -2
- 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/index.d.ts +1 -0
- package/dist/server/dropzone/index.js +1 -0
- package/dist/server/dropzone/report.d.ts +188 -0
- package/dist/server/dropzone/report.js +430 -0
- package/dist/server/dropzone/scan.d.ts +22 -3
- package/dist/server/dropzone/scan.js +46 -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 +9 -1
- package/src/server/d1/pullD1.ts +5 -2
- 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/index.ts +8 -0
- package/src/server/dropzone/report.spec.ts +275 -0
- package/src/server/dropzone/report.ts +568 -0
- package/src/server/dropzone/scan.spec.ts +2 -2
- package/src/server/dropzone/scan.ts +68 -5
- 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
|
@@ -19,7 +19,7 @@ export class JobTimeoutError extends Error {
|
|
|
19
19
|
* Resolve/reject with `promise`, but reject with a {@link JobTimeoutError} if it
|
|
20
20
|
* has not settled within `timeoutMs`. `onTimeout` fires on timeout — the runner
|
|
21
21
|
* uses it to abort the handler's context signal so a cooperative handler can
|
|
22
|
-
* short-circuit (a pending promise cannot be force-
|
|
22
|
+
* short-circuit (a pending promise cannot be force-canceled).
|
|
23
23
|
*
|
|
24
24
|
* Order matters: the timeout promise is rejected BEFORE `onTimeout` runs. Aborting
|
|
25
25
|
* the signal can synchronously resolve a cooperative handler; if that resolution
|
|
@@ -18,7 +18,7 @@ export { MASTER_LOCK_MIN_PASSWORD_LENGTH } from "./lockPage.js";
|
|
|
18
18
|
* The document.
|
|
19
19
|
*
|
|
20
20
|
* It links the LOCK's stylesheet first and its own second, so the two pages share one set of
|
|
21
|
-
*
|
|
21
|
+
* color tokens and a change to the palette cannot land on only one of them.
|
|
22
22
|
*/
|
|
23
23
|
export declare function accountsPageHtml(options: LockPageOptions): string;
|
|
24
24
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* ── Why it is here and not in the app ───────────────────────────────────────
|
|
5
5
|
* `cursedbelt@2.5.1`'s React `MasterLockMenuItems` dialog minted a FRESH `kdf` salt on every
|
|
6
6
|
* rotation, which is what the wire looked like before accounts existed. Every account on an
|
|
7
|
-
* app now derives under ONE shared descriptor, so
|
|
7
|
+
* app now derives under ONE shared descriptor, so honoring that salt would store a verifier
|
|
8
8
|
* hash nothing could ever match: the owner sets a new password, the rotation logs him out,
|
|
9
9
|
* and neither the old nor the new one opens the app. `guard.ts` therefore answers that shape
|
|
10
10
|
* `409 {"error":"stale-client"}`. That is the safe failure; this page is the fix.
|
|
@@ -54,7 +54,7 @@ export { MASTER_LOCK_MIN_PASSWORD_LENGTH } from "./lockPage.js";
|
|
|
54
54
|
* The document.
|
|
55
55
|
*
|
|
56
56
|
* It links the LOCK's stylesheet first and its own second, so the two pages share one set of
|
|
57
|
-
*
|
|
57
|
+
* color tokens and a change to the palette cannot land on only one of them.
|
|
58
58
|
*/
|
|
59
59
|
export function accountsPageHtml(options) {
|
|
60
60
|
const label = escapeHtml(options.appLabel);
|
|
@@ -209,7 +209,7 @@ export function createMasterLockGuard(options) {
|
|
|
209
209
|
* owner would set a new password, be logged out by the rotation, and find that
|
|
210
210
|
* neither the old nor the new one opens the app.
|
|
211
211
|
*
|
|
212
|
-
* There is no safe way to
|
|
212
|
+
* There is no safe way to honor it either, since every account on this app shares
|
|
213
213
|
* one descriptor. So it is refused, loudly, with the one thing that distinguishes
|
|
214
214
|
* it from a wrong password.
|
|
215
215
|
*/
|
|
@@ -37,7 +37,7 @@ export declare function lockPageHtml(options: LockPageOptions): string;
|
|
|
37
37
|
export declare const LOCK_STYLE = ":root{color-scheme:light dark;\n --ml-bg:#f4f5f7;--ml-card:#ffffff;--ml-text:#14171c;--ml-muted:#69707c;--ml-border:#d9dde3;\n --ml-accent:#1f6feb;--ml-accent-text:#ffffff;--ml-danger:#b42318;\n --ml-shadow:0 18px 48px rgba(16,18,22,.14)}\n@media (prefers-color-scheme:dark){:root{\n --ml-bg:#0d0f13;--ml-card:#171a20;--ml-text:#e7eaef;--ml-muted:#8b93a1;--ml-border:#2b3039;\n --ml-accent:#4f8cf7;--ml-accent-text:#0b0d11;--ml-danger:#f97066;\n --ml-shadow:0 18px 48px rgba(0,0,0,.55)}}\n*{box-sizing:border-box}\nbody{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px;\n background:var(--ml-bg);color:var(--ml-text);\n font:15px/1.55 ui-sans-serif,system-ui,-apple-system,\"Segoe UI\",sans-serif}\n.card{width:100%;max-width:23rem;background:var(--ml-card);border:1px solid var(--ml-border);\n border-radius:16px;padding:28px 26px 24px;box-shadow:var(--ml-shadow);text-align:center}\n.glyph{font-size:30px;line-height:1;margin-bottom:10px}\nh1{margin:0 0 6px;font-size:18px;font-weight:650;letter-spacing:-.01em}\n.note{margin:0 0 20px;font-size:13px;color:var(--ml-muted)}\n.field{display:block;text-align:left;margin-bottom:14px}\n.field span{display:block;font-size:12px;font-weight:600;color:var(--ml-muted);margin-bottom:6px}\ninput{width:100%;height:40px;padding:0 12px;border:1px solid var(--ml-border);border-radius:9px;\n background:var(--ml-bg);color:inherit;font:inherit;font-size:16px}\ninput:focus{outline:2px solid var(--ml-accent);outline-offset:1px;border-color:transparent}\nbutton{width:100%;height:40px;border:0;border-radius:9px;background:var(--ml-accent);\n color:var(--ml-accent-text);font:inherit;font-weight:600;cursor:pointer}\nbutton[disabled]{opacity:.6;cursor:progress}\n.status{margin:14px 0 0;min-height:1.2em;font-size:12.5px;color:var(--ml-muted)}\n.status[data-tone=\"error\"]{color:var(--ml-danger)}\n.field span em{font-style:normal;font-weight:500;text-transform:none;opacity:.7}\nbutton.quiet{margin-top:10px;height:32px;background:none;color:var(--ml-muted);font-weight:500;\n font-size:12.5px;text-decoration:underline;text-underline-offset:3px}\nbutton.quiet:hover{color:var(--ml-text)}\nbutton.quiet[disabled]{opacity:.5}\n.hints{margin:10px 0 0;padding:12px 14px;text-align:left;border:1px solid var(--ml-border);\n border-radius:10px;background:var(--ml-bg);font-size:12.5px}\n.hints dt{font-weight:650;color:var(--ml-text)}\n.hints dd{margin:2px 0 10px;color:var(--ml-muted);overflow-wrap:anywhere}\n.hints dd:last-child{margin-bottom:0}\n.secret{position:relative;display:block}\n.secret input{padding-right:48px}\n.secret .reveal{position:absolute;right:5px;top:50%;transform:translateY(-50%);width:36px;height:32px;\n display:grid;place-items:center;padding:0;border-radius:7px;background:none;color:var(--ml-muted)}\n.secret .reveal svg{width:18px;height:18px}\n.secret .reveal .eye-off,.secret .reveal[aria-pressed=\"true\"] .eye{display:none}\n.secret .reveal[aria-pressed=\"true\"] .eye-off{display:block}\n.secret .reveal:hover{color:var(--ml-text);background:var(--ml-card)}\n.secret .reveal:focus-visible{outline:2px solid var(--ml-accent);outline-offset:1px}\n";
|
|
38
38
|
export declare function withRevealToggles(html: string): string;
|
|
39
39
|
/**
|
|
40
|
-
* The toggle's
|
|
40
|
+
* The toggle's behavior, as browser source. It flips the input BEFORE it to `text` and back,
|
|
41
41
|
* keeps `aria-pressed`/`aria-label` true to what is on screen, and returns every field to
|
|
42
42
|
* `password` when its form submits — so a manager saving the credential sees a password field.
|
|
43
43
|
* Publishes itself on `globalThis`, the seam `lockPage.spec.ts` drives it through.
|
|
@@ -157,7 +157,7 @@ button.quiet[disabled]{opacity:.5}
|
|
|
157
157
|
*
|
|
158
158
|
* Markup: {@link withRevealToggles} wraps each `type="password"` input in `.secret` with a
|
|
159
159
|
* `<button type="button" data-reveal>` after it — the inputs keep every attribute, `autocomplete`
|
|
160
|
-
* included, so a password manager still sees a password field.
|
|
160
|
+
* included, so a password manager still sees a password field. Behavior:
|
|
161
161
|
* {@link MASTER_LOCK_REVEAL_SOURCE}, interpolated into BOTH same-origin scripts, because the wall's
|
|
162
162
|
* CSP is `script-src 'self'` and allows no inline script (`MASTER_LOCK_CSP`, pinned by
|
|
163
163
|
* `beaconNeverReachesTheWall.spec.ts`). Nothing about the CSP changes for this.
|
|
@@ -174,7 +174,7 @@ export function withRevealToggles(html) {
|
|
|
174
174
|
return html.replace(/(<input\b[^>]*\btype="password"[^>]*>)/g, `<span class="secret">$1<button type="button" class="reveal" data-reveal aria-label="Show password" aria-pressed="false">${EYE}${EYE_OFF}</button></span>`);
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
|
-
* The toggle's
|
|
177
|
+
* The toggle's behavior, as browser source. It flips the input BEFORE it to `text` and back,
|
|
178
178
|
* keeps `aria-pressed`/`aria-label` true to what is on screen, and returns every field to
|
|
179
179
|
* `password` when its form submits — so a manager saving the credential sees a password field.
|
|
180
180
|
* Publishes itself on `globalThis`, the seam `lockPage.spec.ts` drives it through.
|
|
@@ -286,7 +286,7 @@ export declare class MasterLock {
|
|
|
286
286
|
*
|
|
287
287
|
* `null` means "no live unlock is presented here", which is the only thing that may
|
|
288
288
|
* ever refuse a request. It deliberately does not fall back to {@link unlocked}: that
|
|
289
|
-
* reads "somebody's device is open", and
|
|
289
|
+
* reads "somebody's device is open", and honoring it would make the unlock AMBIENT —
|
|
290
290
|
* a second browser signed in as the owner would walk through having typed nothing, and
|
|
291
291
|
* would then be served whichever tenant happened to be open. While an app had one
|
|
292
292
|
* password that was merely sloppy; with several it hands the wrong library to the
|
|
@@ -325,7 +325,7 @@ export declare class MasterLock {
|
|
|
325
325
|
* answer's latency says nothing the answer itself does not.
|
|
326
326
|
*
|
|
327
327
|
* 🔴 **Every account is tried, and the loop does not stop at the first match.**
|
|
328
|
-
* Stopping early is the obvious
|
|
328
|
+
* Stopping early is the obvious optimization and it is a timing oracle: a password
|
|
329
329
|
* matching the first account would answer in one argon2id and a wrong one in N, so the
|
|
330
330
|
* shape of the reply would say how many tenants exist and roughly where in the list
|
|
331
331
|
* this one sits. The cost is bounded by how many passwords the owner has made — single
|
|
@@ -226,7 +226,7 @@ export class MasterLock {
|
|
|
226
226
|
*
|
|
227
227
|
* `null` means "no live unlock is presented here", which is the only thing that may
|
|
228
228
|
* ever refuse a request. It deliberately does not fall back to {@link unlocked}: that
|
|
229
|
-
* reads "somebody's device is open", and
|
|
229
|
+
* reads "somebody's device is open", and honoring it would make the unlock AMBIENT —
|
|
230
230
|
* a second browser signed in as the owner would walk through having typed nothing, and
|
|
231
231
|
* would then be served whichever tenant happened to be open. While an app had one
|
|
232
232
|
* password that was merely sloppy; with several it hands the wrong library to the
|
|
@@ -291,7 +291,7 @@ export class MasterLock {
|
|
|
291
291
|
* answer's latency says nothing the answer itself does not.
|
|
292
292
|
*
|
|
293
293
|
* 🔴 **Every account is tried, and the loop does not stop at the first match.**
|
|
294
|
-
* Stopping early is the obvious
|
|
294
|
+
* Stopping early is the obvious optimization and it is a timing oracle: a password
|
|
295
295
|
* matching the first account would answer in one argon2id and a wrong one in N, so the
|
|
296
296
|
* shape of the reply would say how many tenants exist and roughly where in the list
|
|
297
297
|
* this one sits. The cost is bounded by how many passwords the owner has made — single
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (e.g. `/api/v1/notes/:id`). The method is tracked separately.
|
|
4
4
|
*
|
|
5
5
|
* Two wrinkles, same as the old Express normalizer:
|
|
6
|
-
* 1. ctgr GET-
|
|
6
|
+
* 1. ctgr GET-tunneled mutations match the `/ctgr<xx>` twin route — we map them
|
|
7
7
|
* back to the real verb + path so a POST and its ctgr twin aggregate together.
|
|
8
8
|
* 2. Unmatched requests (404s, static, the SPA fallback) have no matched route
|
|
9
9
|
* pattern, so we collapse dynamic-looking segments to avoid unbounded
|
|
@@ -26,7 +26,7 @@ import { type MetricRow } from './metricsBuffer.js';
|
|
|
26
26
|
* run concurrently in many datacentres, so a `/metrics` scrape reaches ONE
|
|
27
27
|
* arbitrary isolate holding a random fraction of the counters. The in-process
|
|
28
28
|
* registry has nowhere to live. (A Durable Object does have a durable identity
|
|
29
|
-
* *and* memory, and is the real `prom-client`
|
|
29
|
+
* *and* memory, and is the real `prom-client` analog — but it is a whole
|
|
30
30
|
* stateful object to operate for counters Analytics Engine already aggregates.
|
|
31
31
|
* Prometheus itself also needs an always-on host to scrape FROM, and that host
|
|
32
32
|
* is the Mac this fleet is trying to switch off.)
|
|
@@ -44,7 +44,7 @@ import { type MetricRow } from './metricsBuffer.js';
|
|
|
44
44
|
* Worker supplies the real binding at runtime).
|
|
45
45
|
*
|
|
46
46
|
* Platform limits, which {@link toDataPoint} respects:
|
|
47
|
-
* **1** index of ≤96 bytes, ≤**20** blobs
|
|
47
|
+
* **1** index of ≤96 bytes, ≤**20** blobs totaling ≤5120 bytes, ≤**20** doubles.
|
|
48
48
|
*/
|
|
49
49
|
export interface AnalyticsEngineDataset {
|
|
50
50
|
writeDataPoint(point: {
|
|
@@ -34,7 +34,7 @@ function truncateUtf8(value, maxBytes) {
|
|
|
34
34
|
if (encoded.length <= maxBytes)
|
|
35
35
|
return value;
|
|
36
36
|
return new TextDecoder('utf-8', { fatal: false }).decode(encoded.subarray(0, maxBytes)).replace(
|
|
37
|
-
// A cut through a multi-byte sequence decodes to U+FFFD; drop that trailing
|
|
37
|
+
// A cut through a multi-byte sequence decodes to U+FFFD; drop that trailing artifact.
|
|
38
38
|
/�+$/, '');
|
|
39
39
|
}
|
|
40
40
|
const num = (value) => typeof value === 'number' && Number.isFinite(value) ? value : -1;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { validationEnvelope } from '../errors.js';
|
|
2
2
|
/**
|
|
3
3
|
* Read the value a target validates against. The body targets (`json`/`form`) prefer
|
|
4
|
-
* the ctgr-decoded body so a
|
|
5
|
-
* URL-bound targets (`query`/`param`) are never
|
|
4
|
+
* the ctgr-decoded body so a tunneled mutation validates its real payload; the
|
|
5
|
+
* URL-bound targets (`query`/`param`) are never tunneled (GETs go direct) and read
|
|
6
6
|
* from the live request. A query object collapses single-valued keys to a string so
|
|
7
7
|
* `z.string()`/`z.coerce.number()` field schemas see a scalar (repeated keys stay an
|
|
8
8
|
* array) — matching Hono's own validator semantics.
|
|
@@ -25,7 +25,7 @@ export function createNotificationHub(options = {}) {
|
|
|
25
25
|
if (!set)
|
|
26
26
|
return;
|
|
27
27
|
// Snapshot: a listener may unsubscribe itself while being called (a
|
|
28
|
-
// stream that has just been
|
|
28
|
+
// stream that has just been canceled does exactly that).
|
|
29
29
|
for (const listener of [...set]) {
|
|
30
30
|
try {
|
|
31
31
|
listener(event);
|
|
@@ -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
|
|
@@ -85,7 +85,7 @@ export interface RequestMetricsOptions {
|
|
|
85
85
|
/**
|
|
86
86
|
* Place each request (`{ country, region?, city? }` or `null`) — never an address; the raw IP
|
|
87
87
|
* is not stored. Default: the edge's own answer, `locateFromCloudflare` (the `cf-ipcountry`
|
|
88
|
-
* header every
|
|
88
|
+
* header every tunneled request carries). station passes its DB-IP reader here.
|
|
89
89
|
*/
|
|
90
90
|
locate?: RequestLocator;
|
|
91
91
|
}
|
|
@@ -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
|
|
@@ -129,7 +129,7 @@ export function retireInheritedCorpus(dir) {
|
|
|
129
129
|
const live = join(dir, METRICS_DB);
|
|
130
130
|
if (!existsSync(live))
|
|
131
131
|
return null;
|
|
132
|
-
// An empty file with no journal holds nothing — SQLite simply
|
|
132
|
+
// An empty file with no journal holds nothing — SQLite simply initializes it.
|
|
133
133
|
if (sizeOf(live) === 0 && SIDECARS.every((s) => sizeOf(live + s) === 0))
|
|
134
134
|
return null;
|
|
135
135
|
if (headerApplicationId(live) === METRICS_APPLICATION_ID)
|
|
@@ -60,7 +60,7 @@ export interface JsonlArchiveOptions {
|
|
|
60
60
|
* The index is what makes the archive answerable without reading gigabytes —
|
|
61
61
|
* "what is in here, how many rows, and does it still hash the same" — and it is
|
|
62
62
|
* appended rather than rewritten so a crash mid-write can cost at most the last
|
|
63
|
-
* line, never the
|
|
63
|
+
* line, never the catalog.
|
|
64
64
|
*/
|
|
65
65
|
export declare function createJsonlArchive(options: JsonlArchiveOptions): ArchiveSink;
|
|
66
66
|
/**
|
|
@@ -125,7 +125,7 @@ export function resolveArchiveHome(app, env = process.env) {
|
|
|
125
125
|
* The index is what makes the archive answerable without reading gigabytes —
|
|
126
126
|
* "what is in here, how many rows, and does it still hash the same" — and it is
|
|
127
127
|
* appended rather than rewritten so a crash mid-write can cost at most the last
|
|
128
|
-
* line, never the
|
|
128
|
+
* line, never the catalog.
|
|
129
129
|
*/
|
|
130
130
|
export function createJsonlArchive(options) {
|
|
131
131
|
const { app, resource } = options;
|
|
@@ -224,7 +224,7 @@ export function createJsonlArchive(options) {
|
|
|
224
224
|
appendFileSync(indexPath, `${JSON.stringify({ app, resource, ...segment, path: undefined, file })}\n`);
|
|
225
225
|
}
|
|
226
226
|
catch {
|
|
227
|
-
// The
|
|
227
|
+
// The catalog is a convenience; the segment is the archive. A failed
|
|
228
228
|
// index append must never make a sealed segment look unsealed and send
|
|
229
229
|
// the same rows through again.
|
|
230
230
|
}
|
|
@@ -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
|
|
@@ -88,7 +88,7 @@ export declare function parseEmailList(raw: string | undefined): string[];
|
|
|
88
88
|
export interface DoorConfig {
|
|
89
89
|
/** A release — {@link isRelease}. */
|
|
90
90
|
deployed: boolean;
|
|
91
|
-
/** This instance's own origin, when known. A stage is
|
|
91
|
+
/** This instance's own origin, when known. A stage is recognized by it. */
|
|
92
92
|
publicUrl?: string;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
@@ -87,7 +87,7 @@ export type Awaitable<T> = T | Promise<T>;
|
|
|
87
87
|
/**
|
|
88
88
|
* Either store, as a consumer that works over both sees it: every method's result is
|
|
89
89
|
* {@link Awaitable}. `mountShareRoutes` takes this, and awaits every call — awaiting a
|
|
90
|
-
* synchronous value is a no-op, so the sync store's
|
|
90
|
+
* synchronous value is a no-op, so the sync store's behavior through it is unchanged.
|
|
91
91
|
*/
|
|
92
92
|
export type AwaitableShareStore = {
|
|
93
93
|
readonly [K in keyof AsyncShareStore]: AsyncShareStore[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => Awaitable<R> : AsyncShareStore[K];
|
|
@@ -162,7 +162,7 @@ export interface ReadOptions {
|
|
|
162
162
|
* 🔴 Wait out binary-server's read ceiling instead of throwing it (task 2505).
|
|
163
163
|
*
|
|
164
164
|
* The store allows a tenant a burst of reads, then a steady rate, and answers 429 with the
|
|
165
|
-
* `retry-after` it wants
|
|
165
|
+
* `retry-after` it wants honored (`apps/binary-server/src/rateLimit.ts`). A batch read —
|
|
166
166
|
* roms filing a disc's 256 parts, a hash backfill, an import — met it at read ~204 and threw
|
|
167
167
|
* the whole pass away. `paced` makes `get`/`meta`/`stat` sleep the named `retry-after` and ask
|
|
168
168
|
* again, for at most {@link BINARY_PACED_MAX_WAIT_MS} in total (or `{ maxWaitMs }`).
|
|
@@ -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 } from 'node:crypto';
|
|
44
44
|
/** The batched `/internal/ops/meta` client — its own module so the store's graph stays the store's. */
|
|
@@ -577,7 +577,7 @@ export function createBinaryStore(cfg) {
|
|
|
577
577
|
known(key) {
|
|
578
578
|
// Order matters: a lapsed absence is DROPPED by `knownAbsent`, so asking it
|
|
579
579
|
// first keeps this accessor from reporting an expiry the next real read would
|
|
580
|
-
// not
|
|
580
|
+
// not honor. A positive memo has no expiry, so it needs no such care.
|
|
581
581
|
if (knownAbsent(key))
|
|
582
582
|
return 'absent';
|
|
583
583
|
return present.has(key) ? 'present' : 'unknown';
|
|
@@ -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
|
*
|
|
@@ -147,7 +147,7 @@ export declare const isUnviewableStill: (mime: string | null | undefined, fileNa
|
|
|
147
147
|
* ── 🔴 Why this is here, from the owner's report (2026-08-14) ────────────────────────
|
|
148
148
|
* *"videos are not showing with thumbnails in the family app keepsakes"*, with a screenshot
|
|
149
149
|
* of one album: eleven photographs with tiles and three videos — 129, 282 and 633 MB — drawn
|
|
150
|
-
* as a
|
|
150
|
+
* as a gray play triangle.
|
|
151
151
|
*
|
|
152
152
|
* Nothing was broken. binary-server's `runPoster` had always existed and was reachable only
|
|
153
153
|
* from its `library` strategy, while `family` and `collections` both submit `faststart`,
|
|
@@ -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
|
*
|
|
@@ -156,7 +156,7 @@ export const isUnviewableStill = (mime, fileName) => {
|
|
|
156
156
|
* ── 🔴 Why this is here, from the owner's report (2026-08-14) ────────────────────────
|
|
157
157
|
* *"videos are not showing with thumbnails in the family app keepsakes"*, with a screenshot
|
|
158
158
|
* of one album: eleven photographs with tiles and three videos — 129, 282 and 633 MB — drawn
|
|
159
|
-
* as a
|
|
159
|
+
* as a gray play triangle.
|
|
160
160
|
*
|
|
161
161
|
* Nothing was broken. binary-server's `runPoster` had always existed and was reachable only
|
|
162
162
|
* from its `library` strategy, while `family` and `collections` both submit `faststart`,
|
|
@@ -2,7 +2,7 @@ import type { MediaUrls } from '../sources.js';
|
|
|
2
2
|
import type { MediaGallerySource, MediaSource, PhotoSource } from '../types.js';
|
|
3
3
|
import type { FileUrls } from './fileRoutes.js';
|
|
4
4
|
import type { FileCatalogue, FileToPlayable } from './types.js';
|
|
5
|
-
/** Resolve a video FileRecord to a PlayableVideo with
|
|
5
|
+
/** Resolve a video FileRecord to a PlayableVideo with tokenized URLs. Non-video ⇒ null. */
|
|
6
6
|
export declare function createFileToPlayable(urls: MediaUrls, sourceId: string): FileToPlayable;
|
|
7
7
|
/** Expose a FileCatalogue as a video-only `MediaSource` — the gallery is a view, not a store. */
|
|
8
8
|
export declare function createCatalogueVideoSource(cfg: {
|
|
@@ -20,7 +20,7 @@ export declare function createCataloguePhotoSource(cfg: {
|
|
|
20
20
|
mediaUrls: MediaUrls;
|
|
21
21
|
}): PhotoSource;
|
|
22
22
|
/** Expose a FileCatalogue as a `MediaGallerySource` — photos + videos in one feed.
|
|
23
|
-
* Videos are
|
|
23
|
+
* Videos are tokenized under `videoSourceId` (must match the registered video source so
|
|
24
24
|
* `mountMediaRoutes` serves their streams); photo posters/thumbnails under this source's `id`. */
|
|
25
25
|
export declare function createCatalogueMediaSource(cfg: {
|
|
26
26
|
id: string;
|
|
@@ -26,14 +26,14 @@ function createFileToPhoto(cfg) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
// ── FileCatalogue → media seam ────────────────────────────────────────────────────
|
|
29
|
-
// The
|
|
30
|
-
// separate store — it is a video-filtered VIEW over the
|
|
29
|
+
// The catalog is the ONE source of truth for a user's binaries. The video gallery is not a
|
|
30
|
+
// separate store — it is a video-filtered VIEW over the catalog. These two adapters are the
|
|
31
31
|
// seam: `createFileToPlayable` turns a video FileRecord into the player's PlayableVideo (URLs
|
|
32
32
|
// baked server-side via the shared token/serve infra), and `createCatalogueVideoSource` exposes
|
|
33
|
-
// the
|
|
33
|
+
// the catalog as a `MediaSource` so the existing `mountMediaRoutes` + gallery serve it
|
|
34
34
|
// unchanged. Because the serve routes address bytes by (owner, videoId) through the shared
|
|
35
|
-
// keyspace, a
|
|
36
|
-
/** Resolve a video FileRecord to a PlayableVideo with
|
|
35
|
+
// keyspace, a catalog video is served by the same routes regardless of `sourceId`.
|
|
36
|
+
/** Resolve a video FileRecord to a PlayableVideo with tokenized URLs. Non-video ⇒ null. */
|
|
37
37
|
export function createFileToPlayable(urls, sourceId) {
|
|
38
38
|
return async (ctx, file) => {
|
|
39
39
|
if (file.fileType !== 'video')
|
|
@@ -95,7 +95,7 @@ export function createCatalogueVideoSource(cfg) {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
// ── Photo view ────────────────────────────────────────────────────────────────────
|
|
98
|
-
// The photo gallery is the image-filtered sibling of the video view: same
|
|
98
|
+
// The photo gallery is the image-filtered sibling of the video view: same catalog, same
|
|
99
99
|
// token/serve infra. The primary image is served by the file byte route (fileUrls) and the grid
|
|
100
100
|
// thumbnail by the type-agnostic poster route (mediaUrls) when the ingest thumbnailer produced
|
|
101
101
|
// one — so a PhotoSource needs BOTH URL builders.
|
|
@@ -143,14 +143,14 @@ export function createCataloguePhotoSource(cfg) {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
// ── Mixed media view ───────────────────────────────────────────────────────────────
|
|
146
|
-
// A combined gallery lists BOTH photos and videos from the one
|
|
146
|
+
// A combined gallery lists BOTH photos and videos from the one catalog. This adapter
|
|
147
147
|
// reuses the same two mappers (`createFileToPlayable`, `createFileToPhoto`) so a mixed
|
|
148
148
|
// item renders identically to its single-type sibling — it just tags each with
|
|
149
149
|
// `mediaKind` for the UI to pick a tile/stage. It needs BOTH URL builders (video streams
|
|
150
|
-
// + image bytes/poster). A `kind` filter maps to the
|
|
150
|
+
// + image bytes/poster). A `kind` filter maps to the catalog's `type`; `all` lists
|
|
151
151
|
// untyped and keeps only image|video (dropping docs/audio the mixed gallery can't show).
|
|
152
152
|
/** Expose a FileCatalogue as a `MediaGallerySource` — photos + videos in one feed.
|
|
153
|
-
* Videos are
|
|
153
|
+
* Videos are tokenized under `videoSourceId` (must match the registered video source so
|
|
154
154
|
* `mountMediaRoutes` serves their streams); photo posters/thumbnails under this source's `id`. */
|
|
155
155
|
export function createCatalogueMediaSource(cfg) {
|
|
156
156
|
const toPlayable = createFileToPlayable(cfg.urls, cfg.videoSourceId ?? cfg.id);
|
|
@@ -170,7 +170,7 @@ export function createCatalogueMediaSource(cfg) {
|
|
|
170
170
|
id: cfg.id,
|
|
171
171
|
title: cfg.title,
|
|
172
172
|
async list(ctx, opts) {
|
|
173
|
-
// `all` ⇒ no
|
|
173
|
+
// `all` ⇒ no catalog type filter, then drop non-image/video below.
|
|
174
174
|
const type = opts.kind === 'image' ? 'image' : opts.kind === 'video' ? 'video' : undefined;
|
|
175
175
|
const page = await cfg.catalogue.list(ctx, {
|
|
176
176
|
type,
|
|
@@ -32,7 +32,7 @@ export type ImageDerivatives = (opts: ImageDerivativesOptions) => Promise<{
|
|
|
32
32
|
export declare const fileBinaryKey: (owner: string, id: string) => string;
|
|
33
33
|
/** Where a file's uploaded bytes must land for `registerUploaded` to find them: a video's raw
|
|
34
34
|
* source (fed to the transcode), else the primary binary. The chunked-upload path targets this key
|
|
35
|
-
* so an out-of-band upload lands exactly where the
|
|
35
|
+
* so an out-of-band upload lands exactly where the catalog + serve routes expect it. */
|
|
36
36
|
export declare const catalogueUploadKey: (owner: string, id: string, mime: string) => string;
|
|
37
37
|
export type SqliteFileCatalogueOptions = {
|
|
38
38
|
db: Database;
|
|
@@ -11,7 +11,7 @@ import { classifyFileType, } from './types.js';
|
|
|
11
11
|
export const fileBinaryKey = (owner, id) => `fs/${owner}/${id}`;
|
|
12
12
|
/** Where a file's uploaded bytes must land for `registerUploaded` to find them: a video's raw
|
|
13
13
|
* source (fed to the transcode), else the primary binary. The chunked-upload path targets this key
|
|
14
|
-
* so an out-of-band upload lands exactly where the
|
|
14
|
+
* so an out-of-band upload lands exactly where the catalog + serve routes expect it. */
|
|
15
15
|
export const catalogueUploadKey = (owner, id, mime) => mime.startsWith('video/') ? fsSourceKey(owner, id) : fileBinaryKey(owner, id);
|
|
16
16
|
const b64 = (s) => Buffer.from(s).toString('base64url');
|
|
17
17
|
const unb64 = (s) => Buffer.from(s, 'base64url').toString();
|
|
@@ -210,7 +210,7 @@ export function createSqliteFileCatalogue(opts) {
|
|
|
210
210
|
createdAt: row.created_at,
|
|
211
211
|
updatedAt: row.updated_at,
|
|
212
212
|
});
|
|
213
|
-
// A background job can outlive this
|
|
213
|
+
// A background job can outlive this catalog's Database — a host shutting down mid-transcode,
|
|
214
214
|
// or a test teardown that closed the db after its settle timeout. The job's late progress/result
|
|
215
215
|
// writes must not crash the process (the rows they'd update are gone with the closed db, and
|
|
216
216
|
// recoverProcessing re-kicks anything left 'processing' on the next boot) — drop exactly the
|
|
@@ -512,7 +512,7 @@ export function createSqliteFileCatalogue(opts) {
|
|
|
512
512
|
},
|
|
513
513
|
async registerUploaded(ctx, upload) {
|
|
514
514
|
// Bytes were uploaded out-of-band (a chunked upload direct to binary-server) and already sit
|
|
515
|
-
// at the
|
|
515
|
+
// at the catalog's key (fsSourceKey for video, fileBinaryKey otherwise). Just create the
|
|
516
516
|
// row + kick processing — no re-store. The caller owns having placed the bytes correctly.
|
|
517
517
|
return finalizePublicRow(ownerOf(ctx), upload.id, upload, upload.size, now());
|
|
518
518
|
},
|
|
@@ -648,7 +648,7 @@ export function createSqliteFileCatalogue(opts) {
|
|
|
648
648
|
return { imported, skipped };
|
|
649
649
|
}
|
|
650
650
|
// Directory: recurse, tagging each file with its immediate containing folder name so the
|
|
651
|
-
// origin structure survives as a (flat) tag facet rather than a tree the
|
|
651
|
+
// origin structure survives as a (flat) tag facet rather than a tree the catalog doesn't
|
|
652
652
|
// model. The top-level directory itself is NOT used as a tag (it's just the import root).
|
|
653
653
|
const walk = async (dir, isRoot) => {
|
|
654
654
|
let entries;
|
|
@@ -22,12 +22,12 @@ export interface ChunkedUploadService {
|
|
|
22
22
|
size: number;
|
|
23
23
|
tags?: string[];
|
|
24
24
|
}): Promise<ChunkedInit>;
|
|
25
|
-
/** Finish it: mark the op done and register the
|
|
25
|
+
/** Finish it: mark the op done and register the catalog row over the assembled bytes. Returns
|
|
26
26
|
* the new record, or null if the session is unknown (already completed / server restarted). */
|
|
27
27
|
complete(sid: string, confirmed?: {
|
|
28
28
|
size?: number;
|
|
29
29
|
}): Promise<FileRecord | null>;
|
|
30
|
-
/** Give up on a session (client
|
|
30
|
+
/** Give up on a session (client canceled / a chunk failed) — mark the ledger op failed. */
|
|
31
31
|
abort(sid: string): void;
|
|
32
32
|
/** Open session count (observability / tests). */
|
|
33
33
|
pending(): number;
|
|
@@ -6,7 +6,7 @@ import { catalogueUploadKey } from './catalogue.js';
|
|
|
6
6
|
// backend (binary-server), records a durable `upload` ledger op, and hands the URLs back. The
|
|
7
7
|
// client PUTs each chunk to the backend, which assembles them at the target key once the last
|
|
8
8
|
// arrives. Then the client (or a backend webhook) calls COMPLETE, and the app registers the
|
|
9
|
-
//
|
|
9
|
+
// catalog row over the already-stored bytes (no re-upload) + kicks processing.
|
|
10
10
|
//
|
|
11
11
|
// This module is backend-AGNOSTIC: the app injects `mintChunkUpload` (the binary-server chunk URL
|
|
12
12
|
// + signed sid/ci/tc token). On disk-only deploys, an app simply doesn't wire chunked uploads and
|
|
@@ -24,7 +24,7 @@ export type MountFileRoutesOptions = {
|
|
|
24
24
|
basePath?: string;
|
|
25
25
|
/** Session auth for the upload PUTs (a fetch CAN send the Bearer). Return a ctx or null. */
|
|
26
26
|
authorizeUpload?: (c: Context) => Promise<MediaCtx | null> | MediaCtx | null;
|
|
27
|
-
/** The
|
|
27
|
+
/** The catalog uploads land in. Required for the upload routes to be mounted. */
|
|
28
28
|
catalogue?: FileCatalogue;
|
|
29
29
|
/** Wire large-file chunked uploads (direct-to-backend). Omit ⇒ init/complete routes are absent
|
|
30
30
|
* and clients use the streamed `PUT /upload`. Uses the same `authorizeUpload` guard. */
|
|
@@ -9,7 +9,7 @@ import { FILE_SORTS } from './types.js';
|
|
|
9
9
|
// can't send a Bearer). Uploads DO carry the app Bearer, so the PUT routes are session-guarded.
|
|
10
10
|
//
|
|
11
11
|
// `sourceId` for a file token is the constant 'files'. The served Content-Type is carried as a
|
|
12
|
-
// signed-URL query (`?ct=`) — the
|
|
12
|
+
// signed-URL query (`?ct=`) — the catalog knows each file's mime when it builds the URL, so the
|
|
13
13
|
// route needn't re-derive it. It only ever serves the token owner's own bytes.
|
|
14
14
|
const FILE_SOURCE_ID = 'files';
|
|
15
15
|
// Guard the echoed Content-Type: a plain type/subtype, no header injection.
|
|
@@ -31,7 +31,7 @@ const isUploadTooLarge = (e) => e instanceof UploadTooLargeError || (e instanceo
|
|
|
31
31
|
* Content-Length header (browsers set it for a File/Blob body), and — for length-less chunked
|
|
32
32
|
* transfer — wraps the stream to abort once the accumulated bytes pass the cap (the wrapping error
|
|
33
33
|
* surfaces from `catalogue.ingest`, which the handlers turn into a 413). Returns either the body to
|
|
34
|
-
* hand to the
|
|
34
|
+
* hand to the catalog, or a 413 Response to return immediately.
|
|
35
35
|
*/
|
|
36
36
|
function guardSingleUpload(c, body) {
|
|
37
37
|
const declared = Number(c.req.header('content-length'));
|
|
@@ -187,12 +187,12 @@ export function mountFileRoutes(app, opts) {
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
// ── Listing + collection routes ───────────────────────────────────────────────
|
|
190
|
-
// All require authorizeUpload (session auth) and a
|
|
190
|
+
// All require authorizeUpload (session auth) and a catalog. They follow the same
|
|
191
191
|
// auth/ctx/envelope pattern as the upload routes above. The `includeUnlockable` gate is the
|
|
192
192
|
// caller's responsibility — the route passes the query param through, and it's the app's session
|
|
193
193
|
// middleware that decides whether the caller has unlocked.
|
|
194
194
|
if (opts.authorizeUpload && catalogue) {
|
|
195
|
-
// GET /_files/list → cursor-paginated
|
|
195
|
+
// GET /_files/list → cursor-paginated catalog listing. Query params mirror
|
|
196
196
|
// ListFilesOptions: type, tag, query (q), collectionId, favorite, includeUnlockable,
|
|
197
197
|
// sort (recent|oldest|name|size|random|lastViewed), cursor, limit.
|
|
198
198
|
app.get(`${base}/list`, async (c) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mimeForFilename } from 'cwip/string';
|
|
2
|
-
// Ext → mime for local-disk import (catalogue.importFromPath) — the
|
|
2
|
+
// Ext → mime for local-disk import (catalogue.importFromPath) — the catalog needs SOME mime
|
|
3
3
|
// to classify + serve a file that never passed through a browser's upload Content-Type.
|
|
4
4
|
//
|
|
5
5
|
// The table itself moved DOWN to `cwip/string`'s `fileKind` (2026-07-31): the viewer UI and the
|
|
@@ -8,7 +8,7 @@ import { type ChunkedUploadService, type MintChunkUpload } from './chunkedUpload
|
|
|
8
8
|
import { type FileUrls } from './fileRoutes.js';
|
|
9
9
|
import type { FileCatalogue } from './types.js';
|
|
10
10
|
export interface FilesStackOptions {
|
|
11
|
-
/** The
|
|
11
|
+
/** The catalog database. The stack runs FILE_CATALOGUE_MIGRATIONS on it itself. */
|
|
12
12
|
db: Database;
|
|
13
13
|
/** Byte backend (disk / binary-server / s3) — the swappable piece. */
|
|
14
14
|
store: MediaStore;
|
|
@@ -62,7 +62,7 @@ export interface FilesStackOptions {
|
|
|
62
62
|
backfillPosters?: boolean;
|
|
63
63
|
/** Wire LARGE-file chunked uploads (direct-to-backend). Give the backend-specific per-chunk URL
|
|
64
64
|
* minter (for binary-server: a signed `${base}/upload-chunk/${app}/${key}?token=`) and the stack
|
|
65
|
-
* builds the ChunkedUploadService over its own
|
|
65
|
+
* builds the ChunkedUploadService over its own catalog + a storage-ops ledger on `db`, then
|
|
66
66
|
* mount() auto-wires the /upload-init, /upload-complete, /upload-abort routes. Omit ⇒ chunked is
|
|
67
67
|
* off and clients fall back to the streamed single PUT (disk-only deploys). */
|
|
68
68
|
chunkedUpload?: {
|