Add Thesisly research reader frontend and project design skills

This commit is contained in:
2026-11-07 01:35:35 +08:00
parent e6ee10ff84
commit 9cb04ee69b
135 changed files with 17322 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { maxAge, cookie, sameOrigin, allowedAuthMethod } from "../src/lib/auth-policy.mjs";
test("session renewal honors backend absolute lifetime and clamps idle time",()=>{ assert.equal(maxAge("7"),7);assert.equal(maxAge(99999999),2592000);assert.equal(maxAge(-1),null);assert.equal(maxAge(""),null);assert.equal(maxAge(null),null); });
test("cookies stay inaccessible to JavaScript and expire on logout",()=>{ assert.match(cookie("secret;bad",90,true),/secret%3Bbad; HttpOnly; SameSite=Lax; Path=\/; Max-Age=90; Secure$/);assert.match(cookie("",0,false),/Max-Age=0$/); });
test("mutations cannot use another origin or method",()=>{assert.equal(sameOrigin("https://evil.test","http://localhost:17322"),false);assert.equal(sameOrigin("http://localhost:17321","http://localhost:17322"),false);assert.equal(sameOrigin("null","http://localhost:17322"),false);assert.equal(allowedAuthMethod("auth/login","GET"),false);assert.equal(allowedAuthMethod("auth/me","POST"),false);assert.equal(allowedAuthMethod("auth/exchange","POST"),true);assert.equal(allowedAuthMethod("canvas","POST"),false);});
+12
View File
@@ -0,0 +1,12 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
const snapshot = JSON.parse(readFileSync(new URL("../src/data/papers.json",import.meta.url),"utf8"));
test("paper sample has unique source identities and retained abstracts",()=>{
assert.equal(snapshot.papers.length,20);
assert.equal(new Set(snapshot.papers.map(p=>p.id)).size,20);
for(const p of snapshot.papers){assert.ok(p.title.length>0);assert.ok(p.abstract?.length>0);assert.ok(p.authors.length>0);assert.ok(p.sources.length>0);for(const s of p.sources){assert.equal(new URL(s.url).protocol,"https:");assert.ok(s.externalId);}}
});
test("sample does not invent popularity, code repositories or editorial conclusions",()=>{
for(const p of snapshot.papers){for(const k of ["stars","downloads","citations","codeUrl","aiSummary","trendingRank"])assert.equal(k in p,false);}
});