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
|
@@ -46,7 +46,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
46
46
|
* dependency: `sync/timer.ts`'s callback calls `deps.sync(peer)`, which dials, and
|
|
47
47
|
* that is legitimate (it is the push). A reintroduced `deps.checkRequest(peer)`
|
|
48
48
|
* would be structurally identical and this check would miss it. Nothing static can
|
|
49
|
-
* separate those two — so the strict measurement is **
|
|
49
|
+
* separate those two — so the strict measurement is **behavioral** and lives in
|
|
50
50
|
* `sync/timer.spec.ts` ("a healthy peer with no local news is dialed ONCE at boot,
|
|
51
51
|
* then never", 24 simulated hours) and `sync/signal.spec.ts` ("a connected client
|
|
52
52
|
* issues exactly ONE outbound request, forever"). Those two bound the sync engine
|
|
@@ -46,7 +46,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
46
46
|
* ## The excuse, and why there is one
|
|
47
47
|
*
|
|
48
48
|
* A line carrying `probe-by-calling:ignore` (on it, or on the line above) is allowed — for
|
|
49
|
-
* the one honest use left:
|
|
49
|
+
* the one honest use left: labeling. `cpuClock.ts` decides by calling and then uses a
|
|
50
50
|
* presence check only to say `(absent)` or `(throws)` in the clock's source string. Excuse
|
|
51
51
|
* the LINE, never delete the rule.
|
|
52
52
|
*
|
package/src/publishShape.spec.ts
CHANGED
|
@@ -65,7 +65,7 @@ describe('publish shape', () => {
|
|
|
65
65
|
// npm rejects a "./"-prefixed bin value, calls the NAME invalid, and drops
|
|
66
66
|
// the entry — with a warning, not an error. The package publishes fine and
|
|
67
67
|
// installs with no CLI at all. Invisible under a file: link, where the bin
|
|
68
|
-
// is linked from the source manifest before npm ever
|
|
68
|
+
// is linked from the source manifest before npm ever normalizes it.
|
|
69
69
|
const bin = (pkg as { bin?: Record<string, string> }).bin ?? {};
|
|
70
70
|
const prefixed = Object.entries(bin).filter(([, v]) => v.startsWith('./'));
|
|
71
71
|
expect(
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
21
|
* ── 🔴 Four properties this file exists to guarantee ────────────────────────
|
|
22
|
-
* 1. **Append only.** No update verb, no delete verb, no `TRUNCATE`.
|
|
22
|
+
* 1. **Append only.** No update verb, no delete verb, no `TRUNCATE`. Aging
|
|
23
23
|
* rows out is the fleet retention standard's job, through a declaration the
|
|
24
24
|
* owner can see (`satellite-kit/retention`) — never a silent cutoff here.
|
|
25
25
|
* 2. **A source is READ, never copied.** `share_events` stays the canonical
|
|
@@ -9,7 +9,7 @@ const PAGE = "https://collections.cursedalchemy.com/";
|
|
|
9
9
|
* The tag Cloudflare's Automatic Setup appended, byte-for-byte as the zone emitted it on
|
|
10
10
|
* 2026-09-18 — pinned path, integrity hash, `crossorigin` and all. It is kept in its
|
|
11
11
|
* AUTOMATIC spelling on purpose: this is the shape that was arriving unasked-for, and a
|
|
12
|
-
* checker that only
|
|
12
|
+
* checker that only recognized the manual snippet would go quiet the moment somebody turned
|
|
13
13
|
* auto-install back on.
|
|
14
14
|
*/
|
|
15
15
|
const BEACON =
|
|
@@ -41,7 +41,7 @@ export interface InjectedScript {
|
|
|
41
41
|
* Every `<script src=…>` in `html` whose origin is NOT `pageUrl`'s.
|
|
42
42
|
*
|
|
43
43
|
* Inline scripts are ignored: they are the page's own (most shells here ship one, a pre-paint
|
|
44
|
-
*
|
|
44
|
+
* color-scheme script) and a CSP that refuses them is a different finding from this one.
|
|
45
45
|
* `data:` and `blob:` are ignored for the same reason — neither is a host anything could have
|
|
46
46
|
* injected.
|
|
47
47
|
*/
|
|
@@ -139,7 +139,7 @@ export const WEB_ANALYTICS_PUBLIC_HOST = "cursedalchemy.com";
|
|
|
139
139
|
*
|
|
140
140
|
* A device in GET-only mode (`cursedbelt-core/ctgr-client`) sits behind something that drops
|
|
141
141
|
* every non-GET, and the beacon reports with a POST to the page's `/cdn-cgi/rum`. It cannot be
|
|
142
|
-
*
|
|
142
|
+
* tunneled the way our own API is — the script is Cloudflare's — so there it only ever failed,
|
|
143
143
|
* a red line per page view, and recorded nothing. Not loading it loses no data (2026-10-08).
|
|
144
144
|
*
|
|
145
145
|
* The guard reads the URL as well as `localStorage.ctgr`: this script runs before the app's
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* spread across N isolates gets N × the global allowance the header calls "the actual defense".
|
|
12
12
|
*
|
|
13
13
|
* A Durable Object is the exact shape of the fix: one instance addressed by name, requests to it
|
|
14
|
-
*
|
|
14
|
+
* serialized, so every isolate in every colo meets the same counts. It runs the SAME
|
|
15
15
|
* `createLoginThrottle` algorithm — nothing here re-decides a threshold or a delay — and persists
|
|
16
16
|
* the ledger to the object's storage after every change, so the object's own eviction (minutes
|
|
17
17
|
* idle, measured on patterns' live object) forgets nothing either.
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
* The throttle is checked BEFORE argon2, on every attempt, and the point of checking first is
|
|
21
21
|
* that a refused attempt is cheap. A D1 read-modify-write per attempt is a query against the
|
|
22
22
|
* invocation's 1,000-query budget and, worse, not atomic across concurrent invocations: two
|
|
23
|
-
* guesses that snapshot the same count both write count+1. The object
|
|
23
|
+
* guesses that snapshot the same count both write count+1. The object serializes for free.
|
|
24
24
|
*
|
|
25
25
|
* ── `attempt` is one operation, not two ─────────────────────────────────────
|
|
26
|
-
* `/throttle/attempt` checks and charges in one
|
|
26
|
+
* `/throttle/attempt` checks and charges in one serialized step, so a burst of concurrent guesses
|
|
27
27
|
* is admitted only up to the threshold rather than all at once against one stale count. See
|
|
28
28
|
* `loginThrottle.ts`'s `attempt` section.
|
|
29
29
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* production cost 52.85 s
|
|
15
15
|
* test cost 7.32 s
|
|
16
16
|
*
|
|
17
|
-
* Eighty-six
|
|
17
|
+
* Eighty-six percent of what was, that morning, the largest single workspace in
|
|
18
18
|
* `verify:scoped` — paid by every agent on every branch touching auth or any shared
|
|
19
19
|
* package, and again on every union gate.
|
|
20
20
|
*
|
|
@@ -328,7 +328,7 @@ describe('the bench runner', () => {
|
|
|
328
328
|
*
|
|
329
329
|
* Filed 2026-09-19 by the `collections` port — the first app to mount this harness — which
|
|
330
330
|
* had to leave `POST /api/duplicates/rescan` and `POST /api/recycle/purge`, the only two
|
|
331
|
-
* routes in it whose cost is O(
|
|
331
|
+
* routes in it whose cost is O(catalog), declared but unbenched for exactly this reason.
|
|
332
332
|
*/
|
|
333
333
|
describe('a destructive case — the fixture rebuild between iterations', () => {
|
|
334
334
|
/** ~4 CPU-ms per item held, ~0 CPU-ms when the library is empty. */
|
|
@@ -55,7 +55,7 @@ describe('recordTailTraces', () => {
|
|
|
55
55
|
expect(report.routes.map((r) => r.key)).toEqual(['GET /api/items/:id']);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it('🔴 refuses a PROXY recorder — real numbers may not be
|
|
58
|
+
it('🔴 refuses a PROXY recorder — real numbers may not be labeled a proxy, nor the reverse', () => {
|
|
59
59
|
const recorder = createCpuRecorder({ clock: processCpuClock(), config: BUDGETS });
|
|
60
60
|
expect(() => recordTailTraces(recorder, [])).toThrow(/is a PROXY/);
|
|
61
61
|
});
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* ── One object per payload ───────────────────────────────────────────────────
|
|
20
20
|
* Addressed by `ctgr:<_cid>` (a `crypto.randomUUID()` the client mints per request), so the
|
|
21
|
-
* chunks of one request are
|
|
21
|
+
* chunks of one request are serialized through one object and different requests never
|
|
22
22
|
* contend. The partial lives in the object's memory: chunks arrive milliseconds apart, the idle
|
|
23
23
|
* TTL is 30 s, and an object is only evicted after minutes idle — a partial it loses is one a
|
|
24
24
|
* deploy would have lost too. An object holding nothing costs nothing.
|
|
@@ -98,7 +98,7 @@ describe('the D1 half records a coordinate instead of copying bytes', () => {
|
|
|
98
98
|
|
|
99
99
|
test('🔴 it reports needsPeriodicCapture: false — Time Travel is automatic', () => {
|
|
100
100
|
// A nightly no-op job logging "backup complete" is worse than no job, because it
|
|
101
|
-
// reads as evidence. A scheduler must
|
|
101
|
+
// reads as evidence. A scheduler must honor this flag.
|
|
102
102
|
expect(createTimeTravelBackup({ databaseName: 'patterns' }).needsPeriodicCapture).toBe(false);
|
|
103
103
|
});
|
|
104
104
|
|
package/src/server/d1/backup.ts
CHANGED
|
@@ -67,7 +67,7 @@ export interface TimeTravelOpts {
|
|
|
67
67
|
/**
|
|
68
68
|
* The D1 implementation: record the coordinate, because retention is automatic.
|
|
69
69
|
*
|
|
70
|
-
* 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must
|
|
70
|
+
* 🔴 It reports `needsPeriodicCapture: false`, and a scheduler must honor that rather
|
|
71
71
|
* than calling `capture()` on a timer — a nightly no-op job that logs "backup complete"
|
|
72
72
|
* is worse than no job, because it reads as evidence.
|
|
73
73
|
*/
|
package/src/server/d1/http.ts
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
* the only other door into D1 was a per-app bearer route on the Worker for each one.
|
|
11
11
|
*
|
|
12
12
|
* So the Mac gets the same {@link D1LikeDatabase} a Worker holds, pointed at the same
|
|
13
|
-
* database, and the app's own
|
|
13
|
+
* database, and the app's own catalog code runs unchanged against production — ONE writer
|
|
14
14
|
* of the rows, one schema, one set of statements.
|
|
15
15
|
*
|
|
16
16
|
* ── How ──────────────────────────────────────────────────────────────────────────────────
|
|
17
17
|
* It is a {@link D1BindingLike} over `POST /accounts/:account/d1/database/:db/query` (and
|
|
18
|
-
* `/raw`), handed to {@link createRemoteD1} — so every value
|
|
18
|
+
* `/raw`), handed to {@link createRemoteD1} — so every value normalization, limit check and
|
|
19
19
|
* `success: false` guard is the binding driver's own, not a second copy that could drift.
|
|
20
20
|
* `batch()` sends `{ batch: [...] }`, which D1 runs as one unit exactly as a binding's batch
|
|
21
21
|
* does: measured 2026-09-23 on a throwaway database, a batch whose second statement violated
|
|
@@ -129,7 +129,7 @@ describe('the per-invocation query budget', () => {
|
|
|
129
129
|
expect(db.used).toBe(0);
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
test('a budget above D1\'s real cap is refused rather than
|
|
132
|
+
test('a budget above D1\'s real cap is refused rather than honored', () => {
|
|
133
133
|
expect(() => perInvocation(base, { max: LIMITS.queriesPerInvocation + 1 })).toThrow(D1LimitError);
|
|
134
134
|
expect(() => perInvocation(base, { max: 0 })).toThrow(RangeError);
|
|
135
135
|
expect(() => perInvocation(base, { max: 1.5 })).toThrow(RangeError);
|
|
@@ -170,7 +170,7 @@ export function perInvocation(db: D1LikeDatabase, opts: { max?: number } = {}):
|
|
|
170
170
|
'queries per Worker invocation',
|
|
171
171
|
max,
|
|
172
172
|
LIMITS.queriesPerInvocation,
|
|
173
|
-
'A budget above D1\'s own cap cannot be
|
|
173
|
+
'A budget above D1\'s own cap cannot be honored — the service refuses first. Lower it, or split the work across invocations.',
|
|
174
174
|
);
|
|
175
175
|
}
|
|
176
176
|
const budget = new Budget(max);
|
package/src/server/d1/limits.ts
CHANGED
|
@@ -226,7 +226,7 @@ export function chunkForBind<T>(items: readonly T[], paramsPerItem: number): T[]
|
|
|
226
226
|
* `WHERE … ORDER BY … LIMIT ? OFFSET ?` page and the `COUNT(*)` beside it), and on a write
|
|
227
227
|
* it trades one atomic statement for a batch that is atomic only per chunk. `json_each`
|
|
228
228
|
* over a JSON array is one parameter however long the list is, keeps the statement whole,
|
|
229
|
-
* and SQLite still drives the column's index through the
|
|
229
|
+
* and SQLite still drives the column's index through the materialized set.
|
|
230
230
|
*
|
|
231
231
|
* The array travels as one TEXT value, so the ceiling moves from 100 ids to
|
|
232
232
|
* `LIMITS.valueBytes` (2 MB) of JSON — about 70,000 of this fleet's 25-character ids — and
|
|
@@ -324,7 +324,7 @@ describe('pulling D1 down — paged SELECTs, table by table, never an export', (
|
|
|
324
324
|
|
|
325
325
|
test('a page that blips is asked again at the SAME size — a wire failure is not a page too large', async () => {
|
|
326
326
|
const source = live("INSERT INTO items VALUES ('i1', 'a');");
|
|
327
|
-
// wrangler's
|
|
327
|
+
// wrangler's colored form, as patterns' log has it.
|
|
328
328
|
const { run, seen } = blipping(source, (sql) => sql.includes('FROM "items"'), 1, '✘ \u001b[1mfetch failed\u001b[0m');
|
|
329
329
|
const slept: number[] = [];
|
|
330
330
|
await pullWaiting(scratch(), run, slept);
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* a 6-field expression with a leading seconds column, and this repo already contains three
|
|
32
32
|
* jobs declared `'* * * * * *'` — once per second. Those cannot become Cron Triggers at
|
|
33
33
|
* all, and {@link classifySchedule} says so by name instead of silently rounding them up to
|
|
34
|
-
* a minute, which would change
|
|
34
|
+
* a minute, which would change behavior in production and nowhere else.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
import type { D1LikeDatabase } from './types.js';
|
package/src/server/d1/types.ts
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
*
|
|
41
41
|
* D1 has no interactive transaction — there is no `BEGIN`/`COMMIT` over HTTP, only
|
|
42
42
|
* {@link D1LikeDatabase.batch}, which is atomic and runs as one round trip. A local
|
|
43
|
-
* driver that happily
|
|
43
|
+
* driver that happily honored `BEGIN` would be the sync-vs-async trap a third time, so
|
|
44
44
|
* {@link D1UnsupportedError} is thrown by both. Wrap the statements in `batch()` instead;
|
|
45
45
|
* it is atomic on D1 and wrapped in a real `bun:sqlite` transaction locally, so the
|
|
46
46
|
* guarantee is the same.
|
package/src/server/d1/values.ts
CHANGED
|
@@ -97,7 +97,7 @@ const LEADING_NOISE = /^(?:\s|--[^\n]*\n?|\/\*[\s\S]*?\*\/)+/;
|
|
|
97
97
|
* Only a leading `SELECT` is claimed, because that is the one keyword that is
|
|
98
98
|
* unambiguous: `WITH … INSERT … RETURNING` and `INSERT … RETURNING` both return rows AND
|
|
99
99
|
* write. Anything this returns `false` for is measured exactly instead (see
|
|
100
|
-
* `local.ts`), so a statement shape this does not
|
|
100
|
+
* `local.ts`), so a statement shape this does not recognize costs two extra queries —
|
|
101
101
|
* never a wrong number.
|
|
102
102
|
*/
|
|
103
103
|
export const isPureReadSql = (sql: string): boolean => /^select\b/i.test(sql.replace(LEADING_NOISE, ''));
|
|
@@ -61,7 +61,7 @@ describe("scanDropzone", () => {
|
|
|
61
61
|
|
|
62
62
|
test("captureSiblings records each directory's file list on the ONE walk", async () => {
|
|
63
63
|
// A folder's cover.jpg is only reachable while the directory still exists, and filing
|
|
64
|
-
// the audio out of it removes the
|
|
64
|
+
// the audio out of it removes the neighbors. Re-reading later finds nothing.
|
|
65
65
|
write("Album/track.mp3");
|
|
66
66
|
write("Album/cover.jpg");
|
|
67
67
|
const found = await scanDropzone(root, { captureSiblings: true });
|
|
@@ -113,7 +113,7 @@ describe("sweepDropzone — what gets deleted", () => {
|
|
|
113
113
|
expect(report.failed).toHaveLength(1);
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
test("🔴 a DUPLICATE is deleted — that is the point of
|
|
116
|
+
test("🔴 a DUPLICATE is deleted — that is the point of recognizing one", async () => {
|
|
117
117
|
// "if it's a dup skip it then delete it". The bytes are already safe at the destination,
|
|
118
118
|
// so keeping the local copy is exactly the two-copies problem the owner is solving.
|
|
119
119
|
write("already-have.mp3");
|
|
@@ -89,7 +89,7 @@ export interface ScanOptions {
|
|
|
89
89
|
*
|
|
90
90
|
* 🔴 Load-bearing for sidecar art, and it cannot be done later. A folder's `cover.jpg` is
|
|
91
91
|
* only reachable while the directory still exists, and filing the audio out of it removes
|
|
92
|
-
* the
|
|
92
|
+
* the neighbors — by the time anything else could look, they are gone. Capturing on the
|
|
93
93
|
* walk also costs one `readdir` per directory instead of one per file, which on a 6,000
|
|
94
94
|
* track library is the difference between seconds and minutes.
|
|
95
95
|
*/
|
|
@@ -443,7 +443,7 @@ describe("the data directory is the APP's answer, and no answer means OFF", () =
|
|
|
443
443
|
expect(verdict).toEqual({ enabled: true, dbPath: "/data/family/engagement.sqlite", reason: null });
|
|
444
444
|
});
|
|
445
445
|
|
|
446
|
-
test("an assigned APP_DATA_DIR is
|
|
446
|
+
test("an assigned APP_DATA_DIR is honored with no resolver at all", () => {
|
|
447
447
|
const verdict = readEngagementEnv("family", { ...live, APP_DATA_DIR: "/srv/family" });
|
|
448
448
|
expect(verdict.dbPath).toBe("/srv/family/engagement.sqlite");
|
|
449
449
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `policy.ts` holds the three privacy rules that make it safe to run USER-KEYED analytics
|
|
8
8
|
* inside private household apps, and four copies of a privacy promise is four promises, with
|
|
9
9
|
* nothing keeping them the same — three of the twelve files had already forked (in `music`,
|
|
10
|
-
* doc comments only; the
|
|
10
|
+
* doc comments only; the behavior was identical in all four, so the plurality's text is what
|
|
11
11
|
* came across). The browser half — the beacon — is React and lives in the design system's tier;
|
|
12
12
|
* it depends on nothing here but the wire shape `POST <mount>/view {place}`.
|
|
13
13
|
*
|
|
@@ -243,7 +243,7 @@ describe('buildConsentUrl', () => {
|
|
|
243
243
|
expect(u.searchParams.get('prompt')).toBe('consent');
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
-
test('an explicit prompt is
|
|
246
|
+
test('an explicit prompt is honored', () => {
|
|
247
247
|
expect(url({ prompt: 'select_account' }).searchParams.get('prompt')).toBe('select_account');
|
|
248
248
|
});
|
|
249
249
|
|
|
@@ -114,7 +114,7 @@ export const argon2idDeriverFrom = (binding: RawArgon2idBinding): Argon2idDerive
|
|
|
114
114
|
// 0x10 and 0x13 ARE the Argon2 version identifiers: the spec, the reference
|
|
115
115
|
// implementation and every envelope on disk write them in hex. Biome's autofix
|
|
116
116
|
// rewrites them as 16 and 19 — the same map and a worse one, because nobody
|
|
117
|
-
// reading an `$argon2id$v=19$` record would
|
|
117
|
+
// reading an `$argon2id$v=19$` record would recognize the decimal.
|
|
118
118
|
// biome-ignore lint/complexity/useSimpleNumberKeys: see above — hex IS the spec's spelling
|
|
119
119
|
const NODE_RS_VERSION: Readonly<Record<number, number>> = { 0x10: 0, 0x13: 1 };
|
|
120
120
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The SHIPPED KDF worker entry (05 §B6).
|
|
3
3
|
*
|
|
4
|
-
* Unlike a
|
|
5
|
-
* because every
|
|
4
|
+
* Unlike a marshaling worker — where every marshaler declares its own entry
|
|
5
|
+
* because every marshaler has its own schema — there is exactly ONE password
|
|
6
6
|
* KDF in the platform (Law #7), so there is exactly one entry and the framework
|
|
7
7
|
* ships it. A host does not write this file; it points
|
|
8
8
|
* `createKdfWorkerPasswordVerifier({ entry: kdfWorkerEntryUrl() })` at it.
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* something is new.
|
|
30
30
|
* - {@link runIncidentSweep} — runs checks; a check that THROWS resolves
|
|
31
31
|
* nothing, so a broken detector can never announce that an outage is over.
|
|
32
|
-
* - channels — in-app (the fleet's existing notification
|
|
32
|
+
* - channels — in-app (the fleet's existing notification center), email, and a
|
|
33
33
|
* text message from this Mac that reads `chat.db` back to prove it left.
|
|
34
34
|
* - {@link createIncidentNotifier} — composes the three-sentence message and
|
|
35
35
|
* sends it on OPEN, on ESCALATE and on RESOLVE. Never on an observation.
|
|
@@ -89,7 +89,7 @@ const toIncident = (r: Row): Incident => ({
|
|
|
89
89
|
* bytes free, items failed, commits behind — and a string slipping in there is
|
|
90
90
|
* how a file name reaches an SMS. See the header of `types.ts`.
|
|
91
91
|
*
|
|
92
|
-
* It throws rather than
|
|
92
|
+
* It throws rather than sanitizing, because a detector author meets the failure
|
|
93
93
|
* in their own test run, which is the only moment the mistake is cheap.
|
|
94
94
|
*/
|
|
95
95
|
export function assertNoContent(report: IncidentReport): void {
|
|
@@ -21,7 +21,7 @@ export class JobTimeoutError extends Error {
|
|
|
21
21
|
* Resolve/reject with `promise`, but reject with a {@link JobTimeoutError} if it
|
|
22
22
|
* has not settled within `timeoutMs`. `onTimeout` fires on timeout — the runner
|
|
23
23
|
* uses it to abort the handler's context signal so a cooperative handler can
|
|
24
|
-
* short-circuit (a pending promise cannot be force-
|
|
24
|
+
* short-circuit (a pending promise cannot be force-canceled).
|
|
25
25
|
*
|
|
26
26
|
* Order matters: the timeout promise is rejected BEFORE `onTimeout` runs. Aborting
|
|
27
27
|
* the signal can synchronously resolve a cooperative handler; if that resolution
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 🔴 The accounts page, and the one bug it exists to make impossible.
|
|
3
3
|
*
|
|
4
4
|
* `cursedbelt@2.5.1`'s React dialog minted a FRESH `kdf` salt on every rotation. Every
|
|
5
|
-
* account on an app derives under one shared descriptor, so
|
|
5
|
+
* account on an app derives under one shared descriptor, so honoring that salt stores a
|
|
6
6
|
* verifier hash nothing can match — the owner sets a new password, the rotation logs him
|
|
7
7
|
* out, and neither the old nor the new one opens the app. The server refuses that shape with
|
|
8
8
|
* `409 stale-client`; this page is what replaces the client that sent it.
|
|
@@ -104,7 +104,7 @@ describe("🔴 the rotation this page performs cannot be the one that locked the
|
|
|
104
104
|
|
|
105
105
|
test("and the shape it replaced is still refused, distinguishably", async () => {
|
|
106
106
|
// The 409 stays. This page is why nothing sends that shape any more — not a reason to
|
|
107
|
-
// start
|
|
107
|
+
// start honoring it, which would be the lockout itself.
|
|
108
108
|
const { guard } = build();
|
|
109
109
|
const cookie = await open(guard);
|
|
110
110
|
const res = await guard.handle(
|
|
@@ -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.
|
|
@@ -62,7 +62,7 @@ export { MASTER_LOCK_MIN_PASSWORD_LENGTH } from "./lockPage.js";
|
|
|
62
62
|
* The document.
|
|
63
63
|
*
|
|
64
64
|
* It links the LOCK's stylesheet first and its own second, so the two pages share one set of
|
|
65
|
-
*
|
|
65
|
+
* color tokens and a change to the palette cannot land on only one of them.
|
|
66
66
|
*/
|
|
67
67
|
export function accountsPageHtml(options: LockPageOptions): string {
|
|
68
68
|
const label = escapeHtml(options.appLabel);
|
|
@@ -188,7 +188,7 @@ describe("the CSP keeps the beacon out by construction", () => {
|
|
|
188
188
|
|
|
189
189
|
describe("the other half — a public shell that carries it", () => {
|
|
190
190
|
/**
|
|
191
|
-
* The shell an app ships: inline
|
|
191
|
+
* The shell an app ships: inline color-scheme bootstrap, its own bundle, and the beacon.
|
|
192
192
|
* An app asserts this about ITS OWN `index.html` (rule 3 — a repo's gate proves that repo);
|
|
193
193
|
* what this package owes it is a helper pair that cannot disagree with the wall's.
|
|
194
194
|
*/
|
|
@@ -197,7 +197,7 @@ describe("the other half — a public shell that carries it", () => {
|
|
|
197
197
|
${WEB_ANALYTICS_TAG}
|
|
198
198
|
</head><body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body></html>`;
|
|
199
199
|
|
|
200
|
-
test("the helper
|
|
200
|
+
test("the helper recognizes the tag, and says no when it is missing", () => {
|
|
201
201
|
expect(htmlCarriesWebAnalytics(SHELL)).toBe(true);
|
|
202
202
|
expect(htmlCarriesWebAnalytics(SHELL.replace(WEB_ANALYTICS_TAG, ""))).toBe(false);
|
|
203
203
|
});
|
|
@@ -156,9 +156,9 @@ describe("while locked", () => {
|
|
|
156
156
|
expect(JSON.stringify(body)).not.toContain("argon2");
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
test("🔴 a rotation carrying a STALE kdf is refused, not silently
|
|
159
|
+
test("🔴 a rotation carrying a STALE kdf is refused, not silently honored", async () => {
|
|
160
160
|
// The pre-accounts wire minted a fresh salt on every rotation. Every account now
|
|
161
|
-
// derives under one shared descriptor, so
|
|
161
|
+
// derives under one shared descriptor, so honoring that would store a verifier hash
|
|
162
162
|
// nothing can ever match — the owner sets a new password, the rotation logs him out,
|
|
163
163
|
// and neither the old nor the new one opens the app. `409 stale-client` is the one
|
|
164
164
|
// refusal here that is deliberately distinguishable from a wrong password.
|
|
@@ -304,7 +304,7 @@ export function createMasterLockGuard(options: MasterLockGuardOptions): MasterLo
|
|
|
304
304
|
* owner would set a new password, be logged out by the rotation, and find that
|
|
305
305
|
* neither the old nor the new one opens the app.
|
|
306
306
|
*
|
|
307
|
-
* There is no safe way to
|
|
307
|
+
* There is no safe way to honor it either, since every account on this app shares
|
|
308
308
|
* one descriptor. So it is refused, loudly, with the one thing that distinguishes
|
|
309
309
|
* it from a wrong password.
|
|
310
310
|
*/
|
|
@@ -113,7 +113,7 @@ describe("🔴 every password field on the wall can be shown and hidden (task 07
|
|
|
113
113
|
expect(inputs.length).toBeGreaterThan(0);
|
|
114
114
|
expect((html.match(/data-reveal/g) ?? []).length).toBe(inputs.length);
|
|
115
115
|
for (const input of inputs) expect(input).toMatch(/autocomplete="(current|new)-password"/);
|
|
116
|
-
// …and still no inline script: the
|
|
116
|
+
// …and still no inline script: the behavior ships in the same-origin file.
|
|
117
117
|
expect(html).not.toMatch(/<script(?![^>]*\bsrc=)[^>]*>/);
|
|
118
118
|
});
|
|
119
119
|
}
|
|
@@ -192,7 +192,7 @@ button.quiet[disabled]{opacity:.5}
|
|
|
192
192
|
*
|
|
193
193
|
* Markup: {@link withRevealToggles} wraps each `type="password"` input in `.secret` with a
|
|
194
194
|
* `<button type="button" data-reveal>` after it — the inputs keep every attribute, `autocomplete`
|
|
195
|
-
* included, so a password manager still sees a password field.
|
|
195
|
+
* included, so a password manager still sees a password field. Behavior:
|
|
196
196
|
* {@link MASTER_LOCK_REVEAL_SOURCE}, interpolated into BOTH same-origin scripts, because the wall's
|
|
197
197
|
* CSP is `script-src 'self'` and allows no inline script (`MASTER_LOCK_CSP`, pinned by
|
|
198
198
|
* `beaconNeverReachesTheWall.spec.ts`). Nothing about the CSP changes for this.
|
|
@@ -216,7 +216,7 @@ export function withRevealToggles(html: string): string {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
|
-
* The toggle's
|
|
219
|
+
* The toggle's behavior, as browser source. It flips the input BEFORE it to `text` and back,
|
|
220
220
|
* keeps `aria-pressed`/`aria-label` true to what is on screen, and returns every field to
|
|
221
221
|
* `password` when its form submits — so a manager saving the credential sees a password field.
|
|
222
222
|
* Publishes itself on `globalThis`, the seam `lockPage.spec.ts` drives it through.
|
|
@@ -135,7 +135,7 @@ describe("unlock", () => {
|
|
|
135
135
|
expect(locked).toEqual([false]);
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
test("the minted token is what `presents`
|
|
138
|
+
test("the minted token is what `presents` recognizes, and nothing else is", async () => {
|
|
139
139
|
const { lock } = build();
|
|
140
140
|
const result = await lock.unlock(VERIFIER);
|
|
141
141
|
if (!result.ok) throw new Error("expected an unlock");
|
|
@@ -414,7 +414,7 @@ export class MasterLock {
|
|
|
414
414
|
*
|
|
415
415
|
* `null` means "no live unlock is presented here", which is the only thing that may
|
|
416
416
|
* ever refuse a request. It deliberately does not fall back to {@link unlocked}: that
|
|
417
|
-
* reads "somebody's device is open", and
|
|
417
|
+
* reads "somebody's device is open", and honoring it would make the unlock AMBIENT —
|
|
418
418
|
* a second browser signed in as the owner would walk through having typed nothing, and
|
|
419
419
|
* would then be served whichever tenant happened to be open. While an app had one
|
|
420
420
|
* password that was merely sloppy; with several it hands the wrong library to the
|
|
@@ -482,7 +482,7 @@ export class MasterLock {
|
|
|
482
482
|
* answer's latency says nothing the answer itself does not.
|
|
483
483
|
*
|
|
484
484
|
* 🔴 **Every account is tried, and the loop does not stop at the first match.**
|
|
485
|
-
* Stopping early is the obvious
|
|
485
|
+
* Stopping early is the obvious optimization and it is a timing oracle: a password
|
|
486
486
|
* matching the first account would answer in one argon2id and a wrong one in N, so the
|
|
487
487
|
* shape of the reply would say how many tenants exist and roughly where in the list
|
|
488
488
|
* this one sits. The cost is bounded by how many passwords the owner has made — single
|
|
@@ -74,7 +74,7 @@ function world() {
|
|
|
74
74
|
return { lock, settle: () => writes.settle() };
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/** Does a brand-new request, after everything settled,
|
|
77
|
+
/** Does a brand-new request, after everything settled, honor this token? */
|
|
78
78
|
async function opens(token: string): Promise<boolean> {
|
|
79
79
|
const { lock } = await request();
|
|
80
80
|
return lock.presents(req(token));
|
|
@@ -5,7 +5,7 @@ import type { Context } from 'hono';
|
|
|
5
5
|
* (e.g. `/api/v1/notes/:id`). The method is tracked separately.
|
|
6
6
|
*
|
|
7
7
|
* Two wrinkles, same as the old Express normalizer:
|
|
8
|
-
* 1. ctgr GET-
|
|
8
|
+
* 1. ctgr GET-tunneled mutations match the `/ctgr<xx>` twin route — we map them
|
|
9
9
|
* back to the real verb + path so a POST and its ctgr twin aggregate together.
|
|
10
10
|
* 2. Unmatched requests (404s, static, the SPA fallback) have no matched route
|
|
11
11
|
* pattern, so we collapse dynamic-looking segments to avoid unbounded
|
|
@@ -27,7 +27,7 @@ import { createMetricsBuffer, type MetricRow, type MetricsBuffer } from './metri
|
|
|
27
27
|
* run concurrently in many datacentres, so a `/metrics` scrape reaches ONE
|
|
28
28
|
* arbitrary isolate holding a random fraction of the counters. The in-process
|
|
29
29
|
* registry has nowhere to live. (A Durable Object does have a durable identity
|
|
30
|
-
* *and* memory, and is the real `prom-client`
|
|
30
|
+
* *and* memory, and is the real `prom-client` analog — but it is a whole
|
|
31
31
|
* stateful object to operate for counters Analytics Engine already aggregates.
|
|
32
32
|
* Prometheus itself also needs an always-on host to scrape FROM, and that host
|
|
33
33
|
* is the Mac this fleet is trying to switch off.)
|
|
@@ -46,7 +46,7 @@ import { createMetricsBuffer, type MetricRow, type MetricsBuffer } from './metri
|
|
|
46
46
|
* Worker supplies the real binding at runtime).
|
|
47
47
|
*
|
|
48
48
|
* Platform limits, which {@link toDataPoint} respects:
|
|
49
|
-
* **1** index of ≤96 bytes, ≤**20** blobs
|
|
49
|
+
* **1** index of ≤96 bytes, ≤**20** blobs totaling ≤5120 bytes, ≤**20** doubles.
|
|
50
50
|
*/
|
|
51
51
|
export interface AnalyticsEngineDataset {
|
|
52
52
|
writeDataPoint(point: {
|
|
@@ -124,7 +124,7 @@ function truncateUtf8(value: string, maxBytes: number): string {
|
|
|
124
124
|
const encoded = new TextEncoder().encode(value);
|
|
125
125
|
if (encoded.length <= maxBytes) return value;
|
|
126
126
|
return new TextDecoder('utf-8', { fatal: false }).decode(encoded.subarray(0, maxBytes)).replace(
|
|
127
|
-
// A cut through a multi-byte sequence decodes to U+FFFD; drop that trailing
|
|
127
|
+
// A cut through a multi-byte sequence decodes to U+FFFD; drop that trailing artifact.
|
|
128
128
|
/�+$/,
|
|
129
129
|
'',
|
|
130
130
|
);
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
* `apps/roms/src/server/limits.test.ts` is where this came from (2026-09-17). Most of
|
|
17
17
|
* that file is about roms' own `routes.ts` — that every bounded-body call site takes its
|
|
18
18
|
* ceiling from `MAX_BODY_BYTES` — and stays there, because it asserts about an app's
|
|
19
|
-
* routes. What travels with the module is its two
|
|
19
|
+
* routes. What travels with the module is its two behavioral tests (an honest oversized
|
|
20
20
|
* declaration is refused with both numbers in the message; a body with no declared length
|
|
21
21
|
* is NOT refused on that ground alone), extended here to the three readers the app-side
|
|
22
22
|
* file never exercised.
|
|
@@ -190,7 +190,7 @@ describe('zValidator — ctgr GET-tunnel integration (the protection-critical pa
|
|
|
190
190
|
return app;
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
-
test('a
|
|
193
|
+
test('a tunneled POST validates the decoded body (not the empty GET body)', async () => {
|
|
194
194
|
const enc = await encodeRequest('POST', '/notes', { body: 'hi' });
|
|
195
195
|
const res = await makeApp().fetch(new Request(ORIGIN + enc.chunks[0].url));
|
|
196
196
|
expect(res.status).toBe(200);
|
|
@@ -198,7 +198,7 @@ describe('zValidator — ctgr GET-tunnel integration (the protection-critical pa
|
|
|
198
198
|
expect(await res.json()).toEqual({ ok: true, body: { body: 'hi', pinned: false } });
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
test('a
|
|
201
|
+
test('a tunneled POST with an invalid decoded body returns the 400 envelope', async () => {
|
|
202
202
|
const enc = await encodeRequest('POST', '/notes', { body: 123 });
|
|
203
203
|
const res = await makeApp().fetch(new Request(ORIGIN + enc.chunks[0].url));
|
|
204
204
|
expect(res.status).toBe(400);
|
|
@@ -207,7 +207,7 @@ describe('zValidator — ctgr GET-tunnel integration (the protection-critical pa
|
|
|
207
207
|
expect(env.error.context?.issues?.[0].path).toBe('body');
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
test('the direct (non-
|
|
210
|
+
test('the direct (non-tunneled) verb route still validates the live body', async () => {
|
|
211
211
|
const res = await makeApp().fetch(json('/notes', { body: 'direct' }));
|
|
212
212
|
expect(res.status).toBe(200);
|
|
213
213
|
expect(await res.json()).toEqual({ ok: true, body: { body: 'direct', pinned: false } });
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* The raw request that reaches this middleware is a *GET with no body*, so reading
|
|
16
16
|
* `c.req.json()` would validate `undefined` and every tunneled call would 400.
|
|
17
17
|
* We therefore read the ctgr-decoded body first and fall back to the live request
|
|
18
|
-
* only for direct (non-
|
|
18
|
+
* only for direct (non-tunneled) calls. This is exactly why a route must use
|
|
19
19
|
* `zValidator` and never the raw `@hono/zod-validator`.
|
|
20
20
|
* 2. **The canonical envelope.** `@hono/zod-validator`'s default failure body is its
|
|
21
21
|
* own shape; cursedbelt maps every zod issue to a `ValidationIssue` under
|
|
@@ -37,8 +37,8 @@ export type ZValidatorTarget = 'json' | 'form' | 'query' | 'param';
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Read the value a target validates against. The body targets (`json`/`form`) prefer
|
|
40
|
-
* the ctgr-decoded body so a
|
|
41
|
-
* URL-bound targets (`query`/`param`) are never
|
|
40
|
+
* the ctgr-decoded body so a tunneled mutation validates its real payload; the
|
|
41
|
+
* URL-bound targets (`query`/`param`) are never tunneled (GETs go direct) and read
|
|
42
42
|
* from the live request. A query object collapses single-valued keys to a string so
|
|
43
43
|
* `z.string()`/`z.coerce.number()` field schemas see a scalar (repeated keys stay an
|
|
44
44
|
* array) — matching Hono's own validator semantics.
|