cursedbelt-server 4.47.1 → 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/actions.d.ts +20 -0
- package/dist/server/engagement/actions.js +62 -0
- package/dist/server/engagement/api.d.ts +13 -2
- package/dist/server/engagement/api.js +30 -2
- package/dist/server/engagement/d1.d.ts +13 -2
- package/dist/server/engagement/d1.js +30 -2
- package/dist/server/engagement/index.d.ts +5 -4
- package/dist/server/engagement/index.js +3 -2
- package/dist/server/engagement/manifestPlaces.d.ts +7 -1
- package/dist/server/engagement/manifestPlaces.js +21 -0
- package/dist/server/engagement/places.d.ts +3 -0
- package/dist/server/engagement/places.js +9 -2
- package/dist/server/engagement/policy.d.ts +21 -0
- package/dist/server/engagement/policy.js +27 -0
- package/dist/server/engagement/store.d.ts +12 -3
- package/dist/server/engagement/store.js +30 -2
- package/dist/server/engagement/summary.d.ts +15 -1
- package/dist/server/engagement/summary.js +15 -0
- package/dist/server/engagement/types.d.ts +9 -0
- 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/engagement.md +10 -1
- 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/actions.ts +71 -0
- package/src/server/engagement/api.ts +36 -1
- package/src/server/engagement/d1.spec.ts +49 -3
- package/src/server/engagement/d1.ts +35 -2
- package/src/server/engagement/engagement.spec.ts +103 -1
- package/src/server/engagement/index.ts +5 -2
- package/src/server/engagement/manifestPlaces.ts +21 -1
- package/src/server/engagement/places.ts +12 -2
- package/src/server/engagement/policy.ts +34 -0
- package/src/server/engagement/store.ts +33 -4
- package/src/server/engagement/summary.ts +33 -0
- package/src/server/engagement/types.ts +10 -0
- 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
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
foldView,
|
|
24
24
|
MAX_DWELL_SLICE_MS,
|
|
25
25
|
OTHER_PLACE,
|
|
26
|
+
resolveAction,
|
|
26
27
|
resolvePlace,
|
|
27
28
|
SESSION_GAP_MS,
|
|
28
29
|
} from "./policy.js";
|
|
@@ -442,7 +443,7 @@ describe("the data directory is the APP's answer, and no answer means OFF", () =
|
|
|
442
443
|
expect(verdict).toEqual({ enabled: true, dbPath: "/data/family/engagement.sqlite", reason: null });
|
|
443
444
|
});
|
|
444
445
|
|
|
445
|
-
test("an assigned APP_DATA_DIR is
|
|
446
|
+
test("an assigned APP_DATA_DIR is honored with no resolver at all", () => {
|
|
446
447
|
const verdict = readEngagementEnv("family", { ...live, APP_DATA_DIR: "/srv/family" });
|
|
447
448
|
expect(verdict.dbPath).toBe("/srv/family/engagement.sqlite");
|
|
448
449
|
});
|
|
@@ -460,3 +461,104 @@ describe("the data directory is the APP's answer, and no answer means OFF", () =
|
|
|
460
461
|
expect(readEngagementEnv("vault", live, { dataDir: () => "/data/vault" }).enabled).toBe(false);
|
|
461
462
|
});
|
|
462
463
|
});
|
|
464
|
+
|
|
465
|
+
describe("feature actions — what they DID on a page, by name only (task 3470)", () => {
|
|
466
|
+
const ACTIONS = [{ id: "search", label: "run a search" }, { id: "play" }, { id: "download" }];
|
|
467
|
+
const mount = (resolveUser: (c: Context) => string | null, clock = { t: T0 }) => {
|
|
468
|
+
const s = store();
|
|
469
|
+
const app = new Hono();
|
|
470
|
+
app.route(
|
|
471
|
+
"/api/engagement",
|
|
472
|
+
createEngagementRecorder({ store: s, app: "music", places: PLACES, actions: ACTIONS, resolveUser, now: () => clock.t }),
|
|
473
|
+
);
|
|
474
|
+
const post = (body: unknown) =>
|
|
475
|
+
app.request("/api/engagement/action", {
|
|
476
|
+
method: "POST",
|
|
477
|
+
headers: { "content-type": "application/json" },
|
|
478
|
+
body: JSON.stringify(body),
|
|
479
|
+
});
|
|
480
|
+
return { s, post, clock };
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
test("a declared name resolves to itself, case-blind; anything else is `other`", () => {
|
|
484
|
+
expect(resolveAction("search", ACTIONS)).toBe("search");
|
|
485
|
+
expect(resolveAction(" Play ", ACTIONS)).toBe("play");
|
|
486
|
+
expect(resolveAction("search:my private query", ACTIONS)).toBe(OTHER_PLACE);
|
|
487
|
+
expect(resolveAction("", ACTIONS)).toBe(OTHER_PLACE);
|
|
488
|
+
expect(resolveAction("play", [])).toBe(OTHER_PLACE);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
test("🔴 a value cannot become a row — the query, the track and the URL go nowhere", async () => {
|
|
492
|
+
const { s, post } = mount(() => "u1");
|
|
493
|
+
const res = await post({ place: "/#/note/my-divorce-reading-list", action: "search", query: "a secret", track: "x" });
|
|
494
|
+
expect(await res.json()).toMatchObject({ ok: true, place: "note", action: "search", bucketed: false });
|
|
495
|
+
expect(await (await post({ place: "files", action: "searched for a secret" })).json()).toMatchObject({
|
|
496
|
+
action: OTHER_PLACE,
|
|
497
|
+
bucketed: true,
|
|
498
|
+
});
|
|
499
|
+
const stored = JSON.stringify(s.handle.query("SELECT * FROM engagement_actions").all());
|
|
500
|
+
expect(stored).not.toContain("secret");
|
|
501
|
+
expect(stored).not.toContain("divorce");
|
|
502
|
+
const columns = (s.handle.query("PRAGMA table_info(engagement_actions)").all() as { name: string }[]).map((c) => c.name);
|
|
503
|
+
expect(columns).toEqual(["user_key", "place", "action", "uses", "first_ts", "last_ts"]);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
test("no session → 401; a body userKey is ignored; a missing action is a 400", async () => {
|
|
507
|
+
const anon = mount(() => null);
|
|
508
|
+
expect((await anon.post({ place: "files", action: "play" })).status).toBe(401);
|
|
509
|
+
expect(anon.s.actions()).toEqual([]);
|
|
510
|
+
|
|
511
|
+
const signed = mount(() => "the-session-user");
|
|
512
|
+
await signed.post({ place: "files", action: "play", userKey: "somebody-else" });
|
|
513
|
+
expect(signed.s.actions().map((a) => a.userKey)).toEqual(["the-session-user"]);
|
|
514
|
+
expect((await signed.post({ place: "files" })).status).toBe(400);
|
|
515
|
+
expect((await signed.post({ place: 7, action: "play" })).status).toBe(400);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
test("counts per account, keeps first and last, and never moves the view clock", async () => {
|
|
519
|
+
const { s, post, clock } = mount(() => "u1");
|
|
520
|
+
await post({ place: "files", action: "play" });
|
|
521
|
+
clock.t = T0 + 2 * DAY;
|
|
522
|
+
await post({ place: "files", action: "play" });
|
|
523
|
+
expect(s.actions()).toEqual([{ userKey: "u1", place: "files", action: "play", uses: 2, firstTs: T0, lastTs: T0 + 2 * DAY }]);
|
|
524
|
+
expect(s.handle.query("SELECT day, uses FROM engagement_action_days ORDER BY day").all()).toEqual([
|
|
525
|
+
{ day: "2026-08-10", uses: 1 },
|
|
526
|
+
{ day: "2026-08-12", uses: 1 },
|
|
527
|
+
]);
|
|
528
|
+
// An action is not a view: no session, no dwell, no user row.
|
|
529
|
+
expect(s.users()).toEqual([]);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
test("the daily prune trims action DAYS and keeps the roll-up that says who used it", () => {
|
|
533
|
+
const s = store();
|
|
534
|
+
s.recordAction({ userKey: "u1", place: "files", action: "play", ts: T0 });
|
|
535
|
+
s.prune(T0 + 200 * DAY);
|
|
536
|
+
expect(s.handle.query("SELECT COUNT(*) AS n FROM engagement_action_days").get()).toEqual({ n: 0 });
|
|
537
|
+
expect(s.actions()).toHaveLength(1);
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
test("an app that declares no actions has no action door", async () => {
|
|
541
|
+
const app = new Hono();
|
|
542
|
+
app.route("/api/engagement", createEngagementRecorder({ store: store(), app: "family", places: PLACES, resolveUser: () => "u1" }));
|
|
543
|
+
const res = await app.request("/api/engagement/action", {
|
|
544
|
+
method: "POST",
|
|
545
|
+
headers: { "content-type": "application/json" },
|
|
546
|
+
body: JSON.stringify({ place: "files", action: "play" }),
|
|
547
|
+
});
|
|
548
|
+
expect(res.status).toBe(404);
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
test("the summary folds actions per place across accounts, most used first", () => {
|
|
552
|
+
const s = store();
|
|
553
|
+
s.recordAction({ userKey: "u1", place: "files", action: "play", ts: T0 });
|
|
554
|
+
s.recordAction({ userKey: "u1", place: "files", action: "play", ts: T0 + MINUTE });
|
|
555
|
+
s.recordAction({ userKey: "u2", place: "files", action: "play", ts: T0 + 2 * MINUTE });
|
|
556
|
+
s.recordAction({ userKey: "u2", place: "ask", action: "search", ts: T0 + 3 * MINUTE });
|
|
557
|
+
const snap = readAppEngagement(s, "music", T0 + DAY, PLACES, ACTIONS);
|
|
558
|
+
expect(snap.actions).toEqual([
|
|
559
|
+
{ place: "files", name: "play", count: 3, accounts: 2, lastTs: T0 + 2 * MINUTE },
|
|
560
|
+
{ place: "ask", name: "search", count: 1, accounts: 1, lastTs: T0 + 3 * MINUTE },
|
|
561
|
+
]);
|
|
562
|
+
expect(snap.knownActions).toEqual(["search", "play", "download"]);
|
|
563
|
+
});
|
|
564
|
+
});
|
|
@@ -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
|
*
|
|
@@ -54,8 +54,10 @@ export {
|
|
|
54
54
|
readAppEngagement,
|
|
55
55
|
} from "./api.js";
|
|
56
56
|
export { type EngagementEnv, type EngagementEnvOptions, readEngagementEnv } from "./env.js";
|
|
57
|
-
export {
|
|
57
|
+
export { actionsFromManifest } from "./manifestPlaces.js";
|
|
58
|
+
export { type EngagementPlace, engagementActionsFor, engagementPlacesFor } from "./places.js";
|
|
58
59
|
export {
|
|
60
|
+
type ActionRef,
|
|
59
61
|
classifyInterest,
|
|
60
62
|
dayKey,
|
|
61
63
|
daysSince,
|
|
@@ -82,6 +84,7 @@ export {
|
|
|
82
84
|
type EngagementUserPlace,
|
|
83
85
|
} from "./store.js";
|
|
84
86
|
export {
|
|
87
|
+
type ActionEngagement,
|
|
85
88
|
type AppEngagement,
|
|
86
89
|
type DailyEngagement,
|
|
87
90
|
type PlaceEngagement,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Anything it cannot read is `[]`, never a throw: see `places.ts`, "Missing is EMPTY".
|
|
7
7
|
*/
|
|
8
|
-
import type { PlaceRef } from "./policy.js";
|
|
8
|
+
import type { ActionRef, PlaceRef } from "./policy.js";
|
|
9
9
|
|
|
10
10
|
export function placesFromManifest(doc: unknown): PlaceRef[] {
|
|
11
11
|
const routes = Array.isArray(doc) ? doc : ((doc as { routes?: unknown } | null)?.routes as unknown[] | undefined);
|
|
@@ -22,3 +22,23 @@ export function placesFromManifest(doc: unknown): PlaceRef[] {
|
|
|
22
22
|
places.sort((a, b) => a.id.localeCompare(b.id));
|
|
23
23
|
return places;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A parsed `routes.manifest.json` → the ACTION allowlist (task 3470): its top-level `actions`,
|
|
28
|
+
* each `{ id, label }` or a bare id. The same contract as the places — anything unreadable is
|
|
29
|
+
* `[]`, never a throw — and the same consequence: an app with no `actions` has no action door.
|
|
30
|
+
*/
|
|
31
|
+
export function actionsFromManifest(doc: unknown): ActionRef[] {
|
|
32
|
+
const raw = Array.isArray(doc) ? undefined : (doc as { actions?: unknown } | null)?.actions;
|
|
33
|
+
if (!Array.isArray(raw)) return [];
|
|
34
|
+
const seen = new Set<string>();
|
|
35
|
+
const actions: ActionRef[] = [];
|
|
36
|
+
for (const item of raw) {
|
|
37
|
+
const a = (typeof item === "string" ? { id: item } : item) as { id?: unknown; label?: unknown } | null;
|
|
38
|
+
if (!a || typeof a.id !== "string" || !a.id.trim() || seen.has(a.id)) continue;
|
|
39
|
+
seen.add(a.id);
|
|
40
|
+
actions.push(typeof a.label === "string" ? { id: a.id, label: a.label } : { id: a.id });
|
|
41
|
+
}
|
|
42
|
+
actions.sort((a, b) => a.id.localeCompare(b.id));
|
|
43
|
+
return actions;
|
|
44
|
+
}
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
*/
|
|
25
25
|
import { existsSync, readFileSync } from "node:fs";
|
|
26
26
|
import { join } from "node:path";
|
|
27
|
-
import { placesFromManifest } from "./manifestPlaces.js";
|
|
27
|
+
import { actionsFromManifest, placesFromManifest } from "./manifestPlaces.js";
|
|
28
|
+
import type { ActionRef } from "./policy.js";
|
|
28
29
|
|
|
29
30
|
/** Where the manifest sits, in a source tree and in a built artifact alike. */
|
|
30
31
|
const MANIFEST = "routes.manifest.json";
|
|
@@ -52,10 +53,19 @@ export interface EngagementPlace {
|
|
|
52
53
|
* manifest is copied into both.
|
|
53
54
|
*/
|
|
54
55
|
export function engagementPlacesFor(dir: string): EngagementPlace[] {
|
|
56
|
+
return readManifest(dir, placesFromManifest);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The declared ACTIONS in `<dir>/routes.manifest.json` — `[]` when it has none (task 3470). */
|
|
60
|
+
export function engagementActionsFor(dir: string): ActionRef[] {
|
|
61
|
+
return readManifest(dir, actionsFromManifest);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function readManifest<T>(dir: string, read: (doc: unknown) => T[]): T[] {
|
|
55
65
|
const path = join(dir, MANIFEST);
|
|
56
66
|
if (!existsSync(path)) return [];
|
|
57
67
|
try {
|
|
58
|
-
return
|
|
68
|
+
return read(JSON.parse(readFileSync(path, "utf8")) as unknown);
|
|
59
69
|
} catch {
|
|
60
70
|
return [];
|
|
61
71
|
}
|
|
@@ -141,6 +141,40 @@ export function normalizePlaceId(raw: string): string {
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Resolve the action a browser reported to one of the app's DECLARED actions (task 3470).
|
|
146
|
+
*
|
|
147
|
+
* A place says where somebody was; an action says what they DID there — a search run, a track
|
|
148
|
+
* played, a download started. The owner's question ("what features do they use and ignore") is
|
|
149
|
+
* about the second, and it carries the same risk as the first: the obvious way to record "a
|
|
150
|
+
* search" is to record the search. So rule 1 holds for actions exactly as for places — an action
|
|
151
|
+
* is a NAME from the app's own `routes.manifest.json` `actions` list, never a value. There is no
|
|
152
|
+
* field for the query, the track or the URL, and anything off the list records as
|
|
153
|
+
* {@link OTHER_PLACE}, so an app that forgot to declare a name sees an `other` row rather than
|
|
154
|
+
* a feature that reads as unused.
|
|
155
|
+
*/
|
|
156
|
+
export function resolveAction(claimed: string, allowed: readonly (string | ActionRef)[]): string {
|
|
157
|
+
const want = normalizeActionId(claimed);
|
|
158
|
+
if (!want) return OTHER_PLACE;
|
|
159
|
+
for (const entry of allowed) {
|
|
160
|
+
const id = typeof entry === "string" ? entry : entry.id;
|
|
161
|
+
if (normalizeActionId(id) === want) return id;
|
|
162
|
+
}
|
|
163
|
+
return OTHER_PLACE;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** One declared action — `routes.manifest.json`'s `actions[]`. */
|
|
167
|
+
export interface ActionRef {
|
|
168
|
+
id: string;
|
|
169
|
+
/** What the console shows beside the id — "play a track". */
|
|
170
|
+
label?: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** `Play ` → `play`. Case and surrounding space are one action, not two. */
|
|
174
|
+
export function normalizeActionId(raw: string): string {
|
|
175
|
+
return raw.trim().toLowerCase();
|
|
176
|
+
}
|
|
177
|
+
|
|
144
178
|
/**
|
|
145
179
|
* How long a gap between two views before the second one starts a new session.
|
|
146
180
|
*
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
import { Database } from "bun:sqlite";
|
|
35
35
|
import { mkdirSync } from "node:fs";
|
|
36
36
|
import { dirname, resolve } from "node:path";
|
|
37
|
+
import { type ActionUse, actionStatements, ENGAGEMENT_ACTION_DDL } from "./actions.js";
|
|
37
38
|
import { dayKey, foldView } from "./policy.js";
|
|
38
|
-
import type { EngagementDay, EngagementUser, EngagementUserPlace } from "./types.js";
|
|
39
|
+
import type { EngagementActionUse, EngagementDay, EngagementUser, EngagementUserPlace } from "./types.js";
|
|
39
40
|
|
|
40
|
-
export type { EngagementDay, EngagementUser, EngagementUserPlace } from "./types.js";
|
|
41
|
+
export type { EngagementActionUse, EngagementDay, EngagementUser, EngagementUserPlace } from "./types.js";
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* `bun:sqlite`'s `create: true` creates the FILE, never the directory above it, so a first boot
|
|
@@ -123,6 +124,8 @@ export class EngagementStore {
|
|
|
123
124
|
last_ts INTEGER NOT NULL,
|
|
124
125
|
last_place TEXT NOT NULL DEFAULT ''
|
|
125
126
|
)`);
|
|
127
|
+
// Feature actions (task 3470) — `actions.ts` says why they are their own two tables.
|
|
128
|
+
for (const ddl of ENGAGEMENT_ACTION_DDL) this.handle.run(ddl);
|
|
126
129
|
}
|
|
127
130
|
|
|
128
131
|
/**
|
|
@@ -202,6 +205,30 @@ export class EngagementStore {
|
|
|
202
205
|
return fold;
|
|
203
206
|
}
|
|
204
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Count one resolved action. Like {@link recordView}, `place` and `action` must ALREADY be
|
|
210
|
+
* resolved against the app's manifest — the door (`api.ts`) does it. Touches no clock and no
|
|
211
|
+
* dwell: an action is something done on the page the view already counted.
|
|
212
|
+
*/
|
|
213
|
+
recordAction(use: ActionUse): void {
|
|
214
|
+
const statements = actionStatements(use);
|
|
215
|
+
this.handle.transaction(() => {
|
|
216
|
+
for (const { sql, params } of statements) this.handle.run(sql, params);
|
|
217
|
+
})();
|
|
218
|
+
if (++this.writes % 256 === 0) this.prune(use.ts);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Every (user, place, action) lifetime roll-up, most used first. */
|
|
222
|
+
actions(): EngagementActionUse[] {
|
|
223
|
+
return this.handle
|
|
224
|
+
.query<EngagementActionUse, []>(
|
|
225
|
+
`SELECT user_key AS userKey, place, action, uses, first_ts AS firstTs, last_ts AS lastTs
|
|
226
|
+
FROM engagement_actions
|
|
227
|
+
ORDER BY uses DESC`,
|
|
228
|
+
)
|
|
229
|
+
.all();
|
|
230
|
+
}
|
|
231
|
+
|
|
205
232
|
/** Every account's roll-up for this app, most recently seen first. */
|
|
206
233
|
users(): EngagementUser[] {
|
|
207
234
|
return this.handle
|
|
@@ -241,14 +268,16 @@ export class EngagementStore {
|
|
|
241
268
|
/**
|
|
242
269
|
* Drop daily rows older than the retention window.
|
|
243
270
|
*
|
|
244
|
-
* 🔴 Only `engagement_days
|
|
271
|
+
* 🔴 Only the daily grains (`engagement_days`, `engagement_action_days`). The roll-ups are deliberately untouched —
|
|
245
272
|
* see the file header. An agent "completing" this by trimming them too would
|
|
246
273
|
* delete the only record that somebody used to be here, which is the entire
|
|
247
274
|
* drop-off signal.
|
|
248
275
|
*/
|
|
249
276
|
prune(at: number = Date.now()): number {
|
|
250
277
|
const cutoff = dayKey(at - this.retentionDays * 86_400_000);
|
|
251
|
-
|
|
278
|
+
// The action DAYS age out with the view days; `engagement_actions` is a roll-up and stays.
|
|
279
|
+
const actionDays = this.handle.run("DELETE FROM engagement_action_days WHERE day < ?", [cutoff]).changes;
|
|
280
|
+
return this.handle.run("DELETE FROM engagement_days WHERE day < ?", [cutoff]).changes + actionDays;
|
|
252
281
|
}
|
|
253
282
|
|
|
254
283
|
/** Row counts + age bounds, for the retention card. */
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import {
|
|
17
17
|
classifyInterest,
|
|
18
18
|
dayKey,
|
|
19
|
+
type EngagementActionUse,
|
|
19
20
|
type EngagementDay,
|
|
20
21
|
type EngagementUser,
|
|
21
22
|
type EngagementUserPlace,
|
|
@@ -50,6 +51,17 @@ export interface PlaceEngagement {
|
|
|
50
51
|
msPerView: number;
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
/** One declared action on one place, across every account — "what features they use" (task 3470). */
|
|
55
|
+
export interface ActionEngagement {
|
|
56
|
+
place: string;
|
|
57
|
+
name: string;
|
|
58
|
+
/** Times it was used, every account together. */
|
|
59
|
+
count: number;
|
|
60
|
+
/** Distinct accounts that have used it. */
|
|
61
|
+
accounts: number;
|
|
62
|
+
lastTs: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
/** One day of the app's whole activity. */
|
|
54
66
|
export interface DailyEngagement {
|
|
55
67
|
day: string;
|
|
@@ -74,6 +86,8 @@ export interface AppEngagement {
|
|
|
74
86
|
lastTs: number;
|
|
75
87
|
}>;
|
|
76
88
|
daily: DailyEngagement[];
|
|
89
|
+
/** Per place, per action — most used first. Empty for an app that records no actions. */
|
|
90
|
+
actions: ActionEngagement[];
|
|
77
91
|
totals: {
|
|
78
92
|
users: number;
|
|
79
93
|
views: number;
|
|
@@ -94,6 +108,8 @@ export interface SummarizeInput {
|
|
|
94
108
|
users: EngagementUser[];
|
|
95
109
|
places: EngagementUserPlace[];
|
|
96
110
|
days: EngagementDay[];
|
|
111
|
+
/** The (user, place, action) roll-ups. Absent → no actions. */
|
|
112
|
+
actions?: EngagementActionUse[];
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
export function summarize(input: SummarizeInput): AppEngagement {
|
|
@@ -168,6 +184,22 @@ export function summarize(input: SummarizeInput): AppEngagement {
|
|
|
168
184
|
}))
|
|
169
185
|
.sort((a, b) => b.views - a.views);
|
|
170
186
|
|
|
187
|
+
const byAction = new Map<string, ActionEngagement>();
|
|
188
|
+
for (const row of input.actions ?? []) {
|
|
189
|
+
const key = `${row.place}\u0000${row.action}`;
|
|
190
|
+
const existing = byAction.get(key);
|
|
191
|
+
if (existing) {
|
|
192
|
+
existing.count += row.uses;
|
|
193
|
+
existing.accounts += 1;
|
|
194
|
+
existing.lastTs = Math.max(existing.lastTs, row.lastTs);
|
|
195
|
+
} else {
|
|
196
|
+
byAction.set(key, { place: row.place, name: row.action, count: row.uses, accounts: 1, lastTs: row.lastTs });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const actions = [...byAction.values()].sort(
|
|
200
|
+
(a, b) => b.count - a.count || a.place.localeCompare(b.place) || a.name.localeCompare(b.name),
|
|
201
|
+
);
|
|
202
|
+
|
|
171
203
|
return {
|
|
172
204
|
app,
|
|
173
205
|
generatedAt: now,
|
|
@@ -175,6 +207,7 @@ export function summarize(input: SummarizeInput): AppEngagement {
|
|
|
175
207
|
places,
|
|
176
208
|
userPlaces,
|
|
177
209
|
daily,
|
|
210
|
+
actions,
|
|
178
211
|
totals: {
|
|
179
212
|
users: users.length,
|
|
180
213
|
views: users.reduce((n, u) => n + u.views, 0),
|
|
@@ -48,6 +48,16 @@ export interface EngagementUserPlace {
|
|
|
48
48
|
lastTs: number;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** One (user, place, action) lifetime roll-up — "who uses this feature, and when last" (task 3470). */
|
|
52
|
+
export interface EngagementActionUse {
|
|
53
|
+
userKey: string;
|
|
54
|
+
place: string;
|
|
55
|
+
action: string;
|
|
56
|
+
uses: number;
|
|
57
|
+
firstTs: number;
|
|
58
|
+
lastTs: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
51
61
|
/** One account's relationship with the whole app. */
|
|
52
62
|
export interface EngagementUser {
|
|
53
63
|
userKey: string;
|
|
@@ -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
|