34 Commits
Author SHA1 Message Date
poli0981andClaude Opus 5.5 7bcbcf59dd docs: maintenance mode — policy, triage bot, issue forms, status badge, docs for 2.3.0 (#139)
* docs: maintenance mode — policy, triage bot, issue forms, status badge, docs for 2.3.0

From v2.3.0 the project takes no new features (CONTRIBUTING.md, in Vietnamese and
English). Accepted: scheduled dependency updates; security fixes (High/Critical
advisories, runtime vulnerabilities); major language/runtime/framework upgrades; bug
fixes including UI/UX and accessibility; language fixes.

- .github/workflows/triage.yml + scripts/triage.mjs (unit-tested): an issue or pull
  request whose title or label asks for a feature is labelled enhancement + out-of-scope,
  answered in both languages and closed (issues as "not planned"). The owner's items, bots,
  `maintenance-exception` and anything the owner does are left alone. It runs on
  pull_request_target but checks out only that one script from the default branch, never a
  pull request's code; workflow_dispatch is a dry run.
- Issue forms: blank issues off, questions and ideas to Discussions, security to the
  private policy; a new language-problem form; the bug form no longer claims the site's
  report button fills it (those reports go to a private repository). The pull request
  template asks which of the five kinds of change it is.
- README: a maintenance-mode badge and a Status section; the admin paragraph describes
  auto-publish. SECURITY.md: High/Critical fixes ship out of schedule; the age-check
  answer is local storage only.
- Docs: decisions D21–D24, maintenance policy and cadence (17 §0, QODANA_TOKEN rotation),
  roadmap frozen, CI (Qodana, whole-tree licences, triage, merge rules), architecture
  tree, the Workers Builds deploy command, licence notes without the stale
  license-checker/GSAP lines.
- CHANGELOG [2.3.0]; sonar.projectVersion 2.3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: link #138 in the 2.3.0 changelog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: album labels come from both language entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(ci): triage without a checkout, and linear title patterns

SonarCloud and Qodana on #139:
- githubactions:S7631 flags any checkout in a pull_request_target workflow, even of the
  default branch. The workflow now reads scripts/triage.mjs from the default branch through
  the API and imports it from a data: URL — nothing is checked out at all.
- javascript:S8786: `\s+a?\s*` let two quantifiers compete for the same spaces. The title
  is trimmed once and the patterns are written so no two quantifiers overlap.
- Qodana RegExpRedundantEscape: the bot check is `endsWith("[bot]")`, no regex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 08:48:09 +07:00
poli0981andClaude Opus 5.5 0c56acd806 ci: Qodana analysis and a licence check over the whole dependency tree (#135)
* ci: Qodana analysis and a licence check over the whole dependency tree

- Qodana (JetBrains, Qodana for JS) runs on every PR, on main and by hand
  (.github/workflows/qodana.yml, settings in qodana.yaml): native mode on the runner's
  Node 26 after `npm ci --ignore-scripts` and the generated types, profile
  qodana.recommended over the whole repository, build output, generated files, the
  content submodule and the design docs excluded, spelling/grammar checks off (they do
  not read Vietnamese). Results go to Qodana Cloud and, for main, to code scanning as
  SARIF. Dependabot and fork PRs skip it (no secrets), so it stays advisory.
- Licences: the allowlist moves to scripts/license-policy.mjs, shared by gen-notices
  (direct dependencies, THIRD-PARTY-NOTICES.md) and a new check-licenses step in the
  build job that reads every package in package-lock.json — transitive ones and every
  platform binary — with a small SPDX evaluator (OR, AND, WITH, parentheses). Packages
  with no licence fail; reviews are per package with a reason instead of per licence
  (an MPL note written for satori used to clear @axe-core/playwright too). Today:
  735 packages, 42 cleared (MPL-2.0 build/test tools, sharp's LGPL libvips).
- README badges and Quality row, THIRD-PARTY-NOTICES tool list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: Qodana's first findings, and a zero-problem quality gate

The first Qodana run reported 11 problems; all are handled:
- scripts/smoke-worker.mjs: the forged Access JWT is now built from its JSON parts at run
  time (same bytes) instead of sitting in the source as a token literal, which secret
  scanners rightly flag; the "did not come up" case reports through the same helper as
  any other failure instead of throwing into its own catch.
- scripts/check-csp-hashes.mjs: ("|') → ["'] in the JSON-LD matcher.
- src/lib/format.ts: drop the two escapes of `]` outside a character class (a lone `]`
  is a literal there); the classes keep theirs.
- src/lib/legal-lang.ts: the heading → language table is a Map, so "Tiếng Việt" is data,
  not a property name mixing scripts.
- qodana.yaml: ES6PreferShortImport off, with the reason — the build scripts and
  astro.config.mjs run under plain Node, where the `@/` alias doesn't resolve and a
  TypeScript import keeps its `.ts`.
- failThreshold: 0, so any new problem turns the check red.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: sort the licence report with an explicit compare function

Sonar S2871: Array#sort() without a compare function sorts by UTF-16 code units, which
is not alphabetical for every name. Both lists now sort with localeCompare.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 07:55:31 +07:00
dependabot[bot] 76869fabec chore(deps): Bump google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml (#128)
Bumps [google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml](https://github.com/google/osv-scanner-action) from 2.7.0 to 2.7.1.
- [Release notes](https://github.com/google/osv-scanner-action/releases)
- [Commits](https://github.com/google/osv-scanner-action/compare/b1d267aea5211fa648d9d442fa64b90dbdcbdd36...32d3cd482bdadfb38b186c0ad1b031902d55d932)

---
updated-dependencies:
- dependency-name: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml
  dependency-version: 2.7.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-21 07:11:39 +07:00
dependabot[bot] 6824c92fa0 chore(deps): Bump SonarSource/sonarqube-scan-action from 8.4.1 to 8.5.0 (#127)
Bumps [SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 8.4.1 to 8.5.0.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](https://github.com/sonarsource/sonarqube-scan-action/compare/e805d875275f728fac1885b413934be6d7c63f65...59202af334b4ba7b5db01b701b8e79f8b3bef0f4)

---
updated-dependencies:
- dependency-name: SonarSource/sonarqube-scan-action
  dependency-version: 8.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-21 07:11:29 +07:00
poli0981andClaude Fable 5.2 24d7c1b117 test(a11y): wider coverage, status checks, and claims that match it
Every sitemap page is checked for sideways scrolling at 320px; the light-theme and phone scans cover a page of every template; a page that does not answer the expected status fails instead of being scanned as an error page; the search focus trap is exercised with results listed; the legal notice is checked at tablet and small-laptop sizes; the story reader is walked backwards with Shift+Tab; each half of a legal page must declare its language. ACCESSIBILITY.md says what the palette test and the suite actually cover, and that the live widgets are not in the test build. CI prints the preview log when the job fails.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 a6aef58b46 docs: absolute link to ACCESSIBILITY.md in the pull request template
The template's text becomes a pull request body, where a relative link resolves against the pull request's URL, not the repository tree.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 0fb60fe867 test(a11y): axe-core, keyboard, reflow and forced-colours suite in the build check
npm run test:a11y drives the installed Chrome through Playwright against npm run preview: axe-core (WCAG 2.2 A and AA plus best practices) over every page in the build's sitemap, one page per template again in the light theme and at phone width, and the menu, search, photo viewer, report dialog, reading settings and legal notice while open; then the keyboard contract, no sideways scrolling at 320, 360 and 390px, and the forced-colours rules. It runs inside the required build job after the smoke test. New dev dependencies playwright 1.65.0 and @axe-core/playwright 4.14.0, both past the three-day cooldown and without install scripts. sonar.projectVersion catches up to 2.2.0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
poli0981andClaude Fable 5.2 004cf466ce feat(a11y): accessibility statement, issue and PR templates
A seventh legal page, /legal/accessibility (content repo c9e9827), linked from the footer, the menu, the legal sidebar and the legal notice. ACCESSIBILITY.md at the root is the repository's copy with the notes for contributors, which also ticks the Accessibility entry of GitHub's community standards. New issue template (label accessibility) and a pull request template carrying the checklist. The content bump also brings alt text for the four FrameLedger screenshots.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 08:27:12 +07:00
dependabot[bot] 5eb87b45d5 chore(deps): Bump SonarSource/sonarqube-scan-action from 8.4.0 to 8.4.1 (#124)
Bumps [SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 8.4.0 to 8.4.1.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](https://github.com/sonarsource/sonarqube-scan-action/compare/4d1dc0c91ee400dcf8a6dddf2f705ac36542e304...e805d875275f728fac1885b413934be6d7c63f65)

---
updated-dependencies:
- dependency-name: SonarSource/sonarqube-scan-action
  dependency-version: 8.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-09 20:53:14 +07:00
dependabot[bot] 886db0eae7 chore(deps): Bump SonarSource/sonarqube-scan-action from 8.3.0 to 8.4.0 (#116)
Bumps [SonarSource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 8.3.0 to 8.4.0.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](https://github.com/sonarsource/sonarqube-scan-action/compare/d209202bc7d53ff1cc128f7f907dac145c9d6ae9...4d1dc0c91ee400dcf8a6dddf2f705ac36542e304)

---
updated-dependencies:
- dependency-name: SonarSource/sonarqube-scan-action
  dependency-version: 8.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-09 07:09:48 +07:00
poli0981andClaude Opus 5.5 bf66593c7d Faster first paint on phones: inline CSS, idle hydration (#105)
* perf: inline page CSS, hydrate the theme toggle and hero wave when idle

Lighthouse puts every page's LCP (a text block) about 2.4 s after the
first byte on a throttled phone, almost all of it render delay: two
render-blocking stylesheets (34 KB raw, 9 KB brotli) cost a round trip
before first paint, and the theme toggle's client:load pulled the Svelte
runtime into the same window on every page.

Inline every page's CSS (build.inlineStylesheets "always"; the CSP check
still finds every style block hashed) and hydrate ThemeToggle and the
home hero's Waveline on idle: CSS already shows the toggle's icon from
data-theme-pref, and the wave renders as a flatline until it hydrates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(lighthouse): measure through a compressing proxy, like production

astro preview serves HTML, CSS and JS uncompressed; Cloudflare's edge
compresses every text response with brotli. Measured straight off the
preview, the simulated phone downloaded three to four times the bytes a
real one does (home HTML 108 KB vs 25 KB), so LCP overshot on transfer
time alone. scripts/compress-proxy.mjs sits in front of the preview in
the Lighthouse job and compresses text responses with br or gzip; fonts,
images, redirects and HEAD pass through untouched.

Docs 14 and the changelog describe the inline CSS, the idle islands and
how CI now measures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci(lighthouse): compress through nginx instead of a Node proxy

Sonar's taint rules flagged the hand-written proxy (the request URL and
upstream headers flowing into an outgoing request and into response
headers: S5144, S5146, S6109) and failed the gate, though it only ever
joined two ports on the CI runner. nginx is preinstalled on the Ubuntu
runner: the step writes a short config that gzips text responses from
the preview and listens on 127.0.0.1 only. gzip is a little larger than
the edge's brotli, so the numbers stay slightly pessimistic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:58:43 +07:00
poli0981andClaude Opus 5.5 8a1316280f Platform 2026-10: Node 26, TypeScript 7, SonarCloud + 99% coverage, edge & API hardening (#98)
* chore: add .gitattributes so working trees are LF on every OS

core.autocrlf=true (the Windows default) checked 144 text files out as CRLF, which made
`prettier --check` and `gen-notices --check` fail locally while CI on Linux passed. The
index was already LF, so this changes no content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: Node 26, TypeScript 7 next to TS6, ES2025, latest dependencies

- Node 26 (.nvmrc, engines); Workers Builds already builds with NODE_VERSION=26.
- TypeScript 7.0 ships no JS API, so the tools that need one (astro check/Volar,
  typescript-eslint, svelte2tsx) keep the real typescript@6 package, while
  @typescript/native (npm:typescript@7) type-checks every .ts file:
  `npm run typecheck`. Called by path so the outcome never depends on which package
  wins the shared `tsc` bin link.
- tsconfig: target/lib ES2025, no baseUrl (removed in TS 7; Astro's alias plugin falls
  back to the tsconfig directory), explicit `types: ["node"]` (TS 6+ default is []),
  and erasableSyntaxOnly so Node can strip types for the unit tests — which meant
  turning three constructor parameter properties into plain fields.
- Dependencies to current: astro 7.4.2, @astrojs/cloudflare 14.4.2, mdx 8.1.1,
  svelte 9.1.1, check 0.9.12, zod 4.6.7 (GHSA-mrhx-c7xc-m3w5), wrangler 4.152.0,
  eslint 10.13, typescript-eslint 8.72 (the Svelte false positives that pinned 8.70
  are gone), knip 6.42, lefthook 2.2, prettier 3.9.10, satori 0.63.
- Override miniflare's pinned undici to ^7.30.1 (GHSA-xjj6-f33q-929c and two more,
  published 2026-10-23). `npm audit`: 0 vulnerabilities.
- ESLint: defineConfig from eslint/config (tseslint.config is deprecated).
- wrangler.jsonc: compatibility date 2026-10-15, version_metadata binding, Workers Logs
  with invocation logs and redacted query strings, sampled traces, REPORT_REPO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: SonarCloud analysis, no npx or install scripts in CI, Dependabot-proof notices

- New `sonarcloud` job (SonarSource/sonarqube-scan-action v8.3.0, pinned) fed with the
  lcov report from the build job; sonar-project.properties carries the whole setup and
  waits for the quality gate. Skipped where SONAR_TOKEN can't exist (Dependabot, forks)
  and for content/bump dispatches.
- `npm ci --ignore-scripts`: esbuild, workerd and sharp take their binaries from
  optionalDependencies, so CI needs no lifecycle script at all (verified with a clean
  install + full build). Every `npx` became an npm script, and the TS 7 compiler gets
  its own step. Jobs have timeouts.
- Lighthouse runs through treosh/lighthouse-ci-action (pinned) instead of fetching
  @lhci/cli with npx at run time, and measures mobile as docs 14 says (it was desktop).
- gen-notices no longer prints the resolved-package count inside the checked block:
  every Dependabot PR that changed one transitive package failed CI on it (PR #94).
- Dependabot: a 3-day cooldown on both ecosystems, a typescript group, the TS 6 pin
  explained, and the typescript-eslint pin dropped (8.72 lints Svelte cleanly).
- osv-scanner-action v2.7.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(edge): denylist on every route, a gate that fails closed, /ext-img, version reporting

- IP denylist moved from the middleware (on-demand routes only — pages were never covered)
  into the worker entry, for every route. One `denylist` KV key with CIDR ranges and
  expiry (lib/denylist), memoized per isolate for a minute, failing open on KV errors.
- The Turnstile gate fails CLOSED: if deciding or rendering it throws, the visitor gets a
  503, never the page behind it. Pass signatures must be exactly 43 characters.
- frame-ancestors 'none' as a header-only CSP (it cannot work from <meta>); appended, so
  /media's and /ext-img's own sandbox CSP stays. Admin responses add CORP same-origin.
- /ext-img: the widgets' YouTube thumbnails and Steam icons are mirrored into KV by the
  cron worker and served from this origin, so a page never contacts Google or Steam before
  the visitor presses play; img-src is back to 'self' data:. The route only reads KV —
  nothing a visitor sends makes the Worker fetch anything.
- /api/health reports the Worker version (version_metadata) and the git commit it was
  built from (Workers Builds' WORKERS_CI_COMMIT_SHA), so a deploy is verifiable from
  outside. Structured JSON logs (lib/log) for denylist, gate, admin and rate limits.
- Middleware error pages keep their status under `astro dev` (a rewrite used to answer 200).
- Widgets cron: parallel sources, 10 s timeouts, per-source error logs, the KV contract in
  one shared types module, its bindings typed locally (WidgetsEnv).
- gate.js: Turnstile follows the theme actually shown (system preference included).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): bounded bodies, timeouts, server-side validation, private bug reports

- Request bodies are refused by Content-Length before anything is buffered, and streamed
  bodies stop at the limit (lib/body): report 32 KB, gate 8 KB, admin JSON 512 KB, upload
  20 MB. The old code read the whole body first, whatever its size.
- Every outbound fetch has a timeout: GitHub (admin, 15 s), GitHub issues and Discord (10 s).
- /api/report files into REPORT_REPO — the private poli0981/site-reports, as the privacy
  policy always said — breaks @mentions, fences the console log so it can't escape its
  code block, sends allowed_mentions: none to Discord, and no longer echoes the issue URL.
- Admin content API: frontmatter validated against the collection's fields (the same
  validateFrontmatter the editor will use), plain objects only, JSON content type
  required, "already exists" instead of a misleading edit conflict when creating, and
  legal / now / album entries can no longer be deleted from the admin.
- Admin gallery and media APIs: the same JSON/size rules, existing-album check on create,
  oversized uploads refused before formData() parses them.
- Publish status says when the content token is doing the dispatching (no publish token).
- Structured logs for saves, deletes, uploads, publishes and every GitHub failure.
- Admin client: specific messages for the new error codes; a failed Turnstile load is
  retried instead of replayed until reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: SonarCloud findings, two checks that passed without checking, RepoLens link

Checks that silently checked nothing:
- check-exif handed exifr file paths; its reader throws on current Node and the old
  `.catch(() => null)` read that as "no EXIF" — CI never inspected a single image. It now
  reads the bytes itself, fails on unreadable images, honours --changed (it ignored the
  flag) and stops git from octal-quoting Vietnamese file names out of its filter.
- check-csp-hashes skipped any page whose CSP meta it failed to parse and reported
  "ok — 0 pages". The meta tag is now found in any attribute order or quoting (self-tested),
  a page without one fails, and zero checked pages fails.

SonarCloud (29 open issues):
- Six super-linear regexes rewritten linearly (format, bugbuffer, access, cookie,
  new-post); the email mask works token by token.
- smoke-worker runs wrangler via process.execPath + its CLI file (no PATH lookup, and it
  finally works on Windows: no `npx` without a shell, taskkill instead of a POSIX process
  group), sends `%2e%2e` raw instead of letting fetch normalize it, has a deadline, and
  covers /ext-img, frame-ancestors, oversized bodies, malformed gate passes and the
  denylist (a third phase). KV seeding names the namespace, as wrangler 4.152 requires.
- strip-exif only walks src/assets (path traversal), recurses, and actually enforces its
  1.5 MB budget; sw.js keeps the worker alive until cache.put settles and caps the warm
  cache; gate.js rejects with Errors; the mini-game draws obstacles from the CSPRNG.
- new check-install-scripts: CI installs with --ignore-scripts, which also switches off
  npm's own strict-allow-scripts — this keeps the "unreviewed install script" alarm.
- gen-og imports ogKey() from src/lib/og.ts instead of keeping a copy in sync by hand;
  new-post parses flags anywhere and escapes titles for YAML properly.

Also: the "all repositories" link now points at https://repolens.poli0981.dev/repos.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: run the TypeScript sources under node:test with Astro/Workers stand-ins

No new dependencies. tests/support/register.mjs installs Node 26 module hooks:
- `@/…` and extensionless/directory imports resolve to the .ts sources;
- astro:env/*, astro:content, astro:middleware, cloudflare:workers and the Cloudflare
  adapter's handler resolve to small stubs whose values tests change at run time;
- `import.meta.env` / `import.meta.glob` are rewritten to same-length globals, so V8
  coverage still maps character for character onto the files on disk.
tests/support/fakes.ts provides KV, R2, Images, the Cache API, ASSETS, rate limiters, a
minimal HTMLRewriter and a fetch router; tests/support/github.ts an in-memory content
repo speaking REST, Git Data and GraphQL.

162 tests across the worker entry, middleware, every API route, the admin libraries
(including real RS256 Access JWTs), media, gate rendering, content queries, RSS, the
client modules and the widgets cron: 99.5% of lines, 94.6% of branches. Writing them
found the middleware's error pages losing their status under `astro dev`. The
frontmatter round-trip test used to skip itself on Windows (`URL.pathname` → "/E:/…").

`npm run test:coverage` writes coverage/lcov.info (80% line floor) for SonarCloud, with
the same exclusions as sonar-project.properties, which now also analyzes .github, versions
the project, and waits for the quality gate on pull requests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore(content): publish 9265c94 — legal pages for this release

Private bug reports, widget images served by the site, Workers Logs and IP blocks
disclosed, the AI disclosure's merge policy, and the full third-party/service list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: match script end tags loosely in the HTMLRewriter fake

CodeQL (js/bad-tag-filter) flagged the fake's script regexes because they
miss end tags such as `</script >` or `</SCRIPT>`. The fake only rewrites
HTML this repo builds, but there is no reason to keep a pattern the
analyzer rightly calls fragile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: cut script elements by offset in the HTMLRewriter fake

The looser end-tag regex did not satisfy CodeQL's js/bad-tag-filter, which
distrusts any regex that matches whole <script>…</script> elements. The fake
now finds each element with indexOf and checks the opening tag's attributes,
so there is no tag-filtering regex left to flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 10:42:10 +07:00
dependabot[bot] 408af42756 chore(deps): Bump actions/upload-artifact from 7.0.1 to 7.0.2 (#89) 2026-10-17 00:16:49 +07:00
dependabot[bot] d20a511c33 chore(deps): Bump actions/setup-node from 7.0.0 to 7.1.0 (#88) 2026-10-17 00:15:05 +07:00
poli0981andClaude Opus 5.5 7ec559d216 feat(admin): admin.poli0981.dev — editor, R2 media library, gallery albums, publish (#83)
An admin for the owner, on its own host behind Cloudflare Access.

Security
- src/lib/hosts.ts: admin.poli0981.dev serves only /admin*, /api/admin* and /media/*
  (other paths 301 to the site); poli0981.dev/admin* 301s to the admin host and
  /api/admin* 404s there. Same origin would let any XSS on a public page drive the
  admin API with the Access cookie.
- Every admin route (matched on Astro's routePattern) needs a valid Cloudflare Access
  JWT, verified in the Worker with jose against the team JWKS: aud = ACCESS_AUD, iss =
  team domain, RS256, unexpired; optional ADMIN_EMAILS allowlist. So a forged header,
  another app's token or any non-Access URL gets 403 even though Access already guards
  the edge. State-changing requests must be same-origin (Sec-Fetch-Site + Origin);
  RL_ADMIN is keyed by email; responses are no-store + noindex. `astro dev` gets a
  stand-in identity only under import.meta.env.DEV.
- GITHUB_CONTENT_TOKEN (fine-grained) writes ONLY poli0981/content, plus dispatching the
  publish workflow on this repo. A leak means content edits, never code pushed here.

Content (src/lib/admin/{collections,frontmatter,github}.ts, api/admin/content.ts)
- One GraphQL request lists every entry with its frontmatter; edits commit straight to
  content's main through the Git Data API (tree → commit → fast-forward ref, one atomic
  commit for multi-file changes), refusing with 409 when a file moved since it was
  opened. New entries are .md only (MDX runs code at build).
- Frontmatter round-trips through yaml's Document API and only rewrites keys whose
  value changed: all 28 content entries come back byte-for-byte when unedited (unit
  test against the real submodule), flow lists and quoting survive edits.

Media (src/lib/media/process.ts, api/admin/media.ts)
- Upload: magic-byte sniffing (no SVG), ≤ 20 MB, id = SHA-256 prefix — the same file
  again returns the existing record without a single new transformation. A full-size
  WebP master (re-encoded: EXIF/GPS gone; no original kept) and the fixed variants
  (AVIF 480/800/1200, WebP 800/1600) are made once with the Images binding and stored
  in R2 with their real content type; sizes come from the output, after EXIF rotation.
- Library: list from R2 metadata, edit alt, copy the <picture> snippet, delete (refused
  while any content still references the id; purges this colo's cache).

Gallery (api/admin/gallery.ts): albums from gallery/*.md + gallery-photos/<album>.json;
reorder, caption (vi + en required), add from the library; a new album writes its vi/en
entries and photo list in one commit and needs at least one photo.

Publish (.github/workflows/content-bump.yml, api/admin/publish.ts): the admin
dispatches the workflow, which points src/content at content's main on content/bump,
opens/updates the PR, enables auto-merge only when the diff is .md/.json, and runs
ci.yml on the bump commit (GITHUB_TOKEN PRs don't trigger pull_request workflows) so
the required `build` check exists. ci.yml gains workflow_dispatch. "Allow GitHub
Actions to create pull requests" is enabled on the repo; default token stays read.

UI: AdminLayout + Svelte islands (client:only) — content list with search and "new",
editor (schema-driven form, Markdown with marked preview, image insert, cover picker,
unsaved-changes guard), media library (drag-and-drop), gallery manager, and a publish
bar that shows pending changes, the bump PR and its build status.

Also
- wrangler: Images binding, ACCESS_TEAM_DOMAIN/ACCESS_AUD vars (not secrets), and
  run_worker_first now excludes /@*, /src/*, /node_modules/* — in `astro dev` the
  Cloudflare Vite plugin applied "/*" before Vite's own middleware, so /@vite/client
  and every module 404'd and no island hydrated (dev-only regression from #79).
- robots.txt disallows /admin/. Deps: jose, marked; yaml moves to dependencies.
- Tests: hosts routing (unit), frontmatter round-trip (unit), smoke: admin 403
  without/with a forged JWT. Verified locally on astro dev: upload → 5 variants of the
  right sizes with no EXIF, re-upload deduped, CSRF refused, alt edit, delete → 404;
  editor defaults, preview and picker work.
- Docs: 00 (D2, D11–D15), 01, 02 (ADR-04, ADR-08), 04 §5a, 06 §9, 07 §13b + checklist,
  08 §0 (what actually runs), 16, 17.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 21:01:43 +07:00
poli0981andClaude Opus 5.5 af4cf073df feat(gate): Turnstile bot check before any page, 48-hour pass (ships switched off) (#80)
Visitors without a pass get a "checking you're human" step instead of the page; solving
Turnstile earns a signed 48-hour cookie. Lives in the worker entry, since static pages
never reach Astro middleware.

How a page request is decided (src/lib/gate/policy.ts):
- off unless GATE_MODE is "on"/"force" AND GATE_SECRET and TURNSTILE_SECRET exist — CI,
  Lighthouse and branch previews are never gated;
- never gated: non-GET, the admin host, /api, /admin, /media and the legal pages (the
  privacy policy must be readable first); feeds, sitemap, robots, OG images, hashed
  assets, sw.js and /offline/ don't even reach the Worker (run_worker_first);
- `x-verified-bot: true` passes. A zone Transform Rule sets that header on every request
  to to_string(cf.client.bot), so clients can't forge it. No header at all means the rule
  isn't deployed: fail OPEN and log, rather than lock search engines out ("force" skips
  this for local testing);
- a valid `__Host-gate` pass passes (src/lib/gate/cookie.ts: v1.<exp>.<nonce>.<HMAC>,
  Max-Age 172800, Secure, HttpOnly, SameSite=Lax; expiry can't be extended or pushed
  past one TTL; rotating GATE_SECRET voids every pass).

The gate page (src/lib/gate/render.ts) is the requested page with its <body> swapped by
HTMLRewriter. The <head> stays as built — title, description, canonical, OG/Twitter,
CSS, fonts, theme bootstrap and the CSP meta — so link previews from bots that aren't
"verified" (Zalo, Telegram…) still show the real title, and the page's own CSP already
allows /gate.js ('self') and Turnstile. External scripts, modulepreloads and JSON-LD
(the Q&A page carries every answer in it) are dropped. It answers 200 — preview bots
ignore non-2xx — with no-store, noindex and no validators. Only 200 text/html becomes
the gate; redirects, 304s and 404s pass through. /pagefind/* (full text of every page)
is 403 without a pass.

public/gate.js renders Turnstile (action "gate", page language, current theme), trades
the token at POST /api/gate (rate-limited by RL_GATE, same-origin only, verified with
action + hostname) for the cookie and reloads. Strings in i18n `humanCheck`; styles in
global.css (the gate can't add a <style> without breaking the page's CSP hashes).

Ships with GATE_MODE "off". Turning it on is a one-line follow-up once the Transform
Rule is confirmed to reach the Worker.

Legal: privacy §1/§3/§8 (content#2, bumped) disclose Turnstile, the one strictly
necessary cookie and that JS is needed once; the legal sheet's line 3 and SECURITY.md
no longer say "cookieless" / "no cookies". Docs: 06 §3b (flow, kill switch), 07 §8/§8b
(reusing the widget, GATE_SECRET, the exact Transform Rule), 09.

Tests: `npm test` (node --test, 11 cases: pass lifetime, wrong secret, tampered/too-far
expiry, garbage, cookie format/parsing, settings, decisions) and smoke phase 2, which
forces the gate on with Turnstile's always-pass test secret and walks the whole flow
against the built worker (gate page, exemptions, 403 pagefind, cross-site rejection,
/api/gate → cookie → real page, tampered cookie → gate).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 20:02:01 +07:00
poli0981andClaude Opus 5.5 b1020e6357 feat(edge): custom worker entry in front of every page (no gate yet) (#79)
Prerendered pages are served by the adapter's static-asset lookup before the Astro
middleware runs, so nothing at runtime could touch them — the www→apex redirect, the
denylist and the security headers only ever applied to /api routes (the headers reached
pages through public/_headers). The upcoming Turnstile gate and /media route need a
hook there, so this adds one.

- wrangler `main` → src/worker.ts, which wraps `handle()` from
  @astrojs/cloudflare/handler (the adapter's documented custom-entry API; the build-time
  prerender worker still uses the adapter's own entry, so nothing here runs at build).
- `assets.run_worker_first`: every path except hashed /_astro assets, OG images, the
  favicon, sw.js/skullhop.js/gate.js, /offline/, robots/sitemaps/feeds and /.well-known
  — those stay on the asset layer (unbilled, unaffected by any gate). /pagefind/* goes
  through the Worker on purpose: its fragments hold every page's full text.
- Pages are fetched from ASSETS with the original request. The adapter's own lookup
  fetches by URL string, which drops the method and conditional headers: once pages run
  through the Worker, every revalidation would have become a full 200 and HEAD a GET.
- www→apex moves from the middleware into the entry, so it covers static pages too.
- Security headers come from src/lib/security-headers.ts, shared with the middleware,
  and are set on every response leaving the entry (copying immutable asset responses).
- Edge logic fails open to `handle()`; a bug there must not take the site down.
- `preview_urls: false`: per-version preview URLs live on workers.dev, outside the
  zone's WAF, Transform Rules and Access. Explicit because an omitted key keeps the
  current setting.

CI: `wrangler types --strict-vars=false` (vars typed as string, not literals), and a
smoke test (scripts/smoke-worker.mjs, `npm run smoke`) boots the built worker with
`wrangler dev` and checks /, headers, 304 revalidation, HEAD, the trailing-slash 307,
404, /api/health, sw.js, a hashed asset, RSS and security.txt.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 19:50:29 +07:00
poli0981andClaude Opus 5.5 637dac67ff fix(deps): clear every open Dependabot/OSV advisory and unblock CI (#74)
main has been red since September: the `npm audit --omit=dev --audit-level=high`
gate in ci.yml tripped on advisories that piled up, so every PR failed — including
the 13 Dependabot PRs, each of which only fixed one package and so could never go
green on its own. This bumps everything in one go.

- astro 7.2.0 → 7.3.6 (critical RCE via AVIF image optimization, GHSA-26w7-cxv4-gfx2;
  path-segment auth bypass GHSA-376h-93r7-7g6f), @astrojs/cloudflare 14.3.4,
  @astrojs/mdx 8.0.3 (Astro 7.3 ships markdown-satteri 0.4, which mdx 7 can't peer
  with), @astrojs/sitemap, svelte 5.57.2, zod 4.6.5, sharp 0.35.5, wrangler 4.148.
- Transitive fixes now come from the parents (svgo 4.1, devalue 5.9.4, undici 7.29.1/
  8.x, fast-uri 3.1.8, http-cache-semantics 4.3, source-map-js 1.2.2, …), so the old
  overrides are gone. Two remain because a parent pins an exact vulnerable version:
  fflate (satori → 0.7.3) and sharp (miniflare → 0.35.4, librsvg CVE fixed in 0.35.5).
  The old `undici` override also forced 7.x onto unifont's ^8 range — that's fixed.
- gray-matter → yaml in scripts/gen-og.mjs: gray-matter's js-yaml@3 → argparse@1 →
  sprintf-js chain carries an advisory with no fixed version. Only frontmatter is read.
- Dev tools bumped; typescript-eslint held at 8.70.x (8.71 reports 131 false
  `no-unused-vars` in Svelte files) and prettier-plugin-astro at 0.14 (1.x reflows
  inline expressions in 50 .astro files — a visual change). Both are in Dependabot's
  ignore list with the reason.
- `z` now comes from astro/zod (the astro:content re-export is deprecated).

CI:
- ci.yml no longer path-filters pull_request: `build` is a required check, so a
  docs-only PR could never merge.
- OSV now uses the reusable SARIF workflow (repo is public → code scanning is free);
  findings land in Security → Code scanning and still fail the run. v2.6.0 (#70).

npm audit: 0 vulnerabilities (prod and dev). Build: 63 pages, sitemap unchanged,
CSP guard ok, OG images generated.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 19:17:59 +07:00
poli0981andClaude Opus 5 fb798af1d8 fix(a11y,ci): accessible names must contain their visible text; make Lighthouse warn-only
Lighthouse CI failed on its very first run, and it was right twice — once about the
site, once about my own config.

**WCAG 2.5.3 Label in Name (Level A), two violations.** Both had an `aria-label` that
replaced the visible text instead of containing it, so the accessible name and the
words on screen disagreed. Voice control acts on the accessible name: a user saying
"click SkullMute" or "click English" could not activate either control.

  brand logo   aria-label "poli0981.dev — home"  visible "SkullMute"
  lang switch  aria-label "Ngôn ngữ"             visible "English"

Now "SkullMute — poli0981.dev" and "English — Ngôn ngữ": visible text first, context
after. Verified 0 mismatches across vi, en and a listing page.

**The job could never have been warn-only as written.** `assert.preset:
"lighthouse:no-pwa"` switches on Lighthouse's full default assertion set at ERROR
level, which is what actually failed the run — my four explicit `warn` entries were
beside the point. docs 14 §3 says warn only, so the preset is gone and the config now
asserts exactly the budget from §1 and nothing else.

**The reports artifact was empty in the only case that mattered.** `lhci autorun`
aborts on a failed assertion before writing anything, so the run that needed
inspecting produced no artifact ("No files were found with the provided path"). Split
into separate collect and assert steps: collect always writes, assert is free to fail.

Findings I have NOT verified, kept as warnings rather than silenced: uses-text-
compression (workerd preview does not gzip; Cloudflare does in production),
errors-in-console and inspector-issues (likely the unset Turnstile/KV env in CI, but
that is a guess). They will show as warnings with a readable artifact next run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 08:13:09 +07:00
poli0981andClaude Opus 5 746e26dd6c feat(ci): Lighthouse CI against the perf budget, warn-only
docs 14 §3 asks for a Lighthouse job on a preview build asserting the §1 budget,
explicitly "chỉ warn, không block" — Lighthouse numbers move with runner load, and a
hard gate would block deploys on noise rather than on regressions.

Advisory by construction, in two independent ways: every assertion is `warn`, and the
job is `continue-on-error` so a red run cannot fail the check suite. Per the doc, act
when it is red twice in a row, not on one bad sample.

Budget from docs 14 §1: performance/a11y/best-practices/SEO >= 0.95, LCP < 2.0s,
CLS < 0.05, total weight < 600KB. INP is a field metric with no lab equivalent, so
total-blocking-time <= 200ms stands in for it — noted here so the substitution is not
mistaken for the real thing.

Runs against `astro preview`, i.e. the built worker in workerd with real bindings and
_headers, rather than a bare static server — otherwise the numbers would not reflect
what visitors get. Four representative pages per the doc: home, a blog post, a story
chapter, a gallery album. Three runs each to blunt variance. Reports upload as an
artifact so a warning can be read rather than guessed at.

`@lhci/cli` is fetched with npx in CI instead of added to devDependencies: it is a
large tree that would land in the audit surface, the notices file and Dependabot's
queue for a job that never blocks anything.

Note on the pins: I wrote the upload-artifact SHA from memory and it was WRONG — a
fabricated pin is worse than a floating tag, because it looks authoritative while
pointing at nothing. All four action pins in the repo are now verified against the
GitHub API: checkout v7.0.1, setup-node v7.0.0, upload-artifact v7.0.1,
osv-scanner-action v2.5.0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 07:46:34 +07:00
poli0981andClaude Opus 5 c324a4231a feat(ci): generate THIRD-PARTY-NOTICES.md and fail CI when it drifts
docs 08 §6 specifies `node scripts/gen-notices.mjs --check` as a CI gate and it
never existed, so the notices file was hand-maintained — which is how it ended up
crediting `@vite-pwa/astro`, a package this repo has never depended on.

The file now follows the A/B split docs 12 describes: hand-written framing outside
the BEGIN/END markers, generated table inside. `--check` regenerates in memory and
diffs, so a dependency change without a regenerate fails the build.

Licenses are read from each package's own package.json rather than via
`license-checker` — same source of truth, one fewer dependency to vet, which is
rather the point of a licence audit.

Two things fell out of building it:

1. **The survey has to be deterministic or the gate is useless.** npm installs only
   the platform-matching binaries (`@img/sharp-*`, `*-msvc`), so a disk-based walk
   of the resolved tree produces a different file on Windows than in Linux CI and
   `--check` could never pass. The table is therefore built from direct
   dependencies, which are installed everywhere; the transitive tree contributes a
   count straight from the lockfile. Verified: every row corresponds to a
   package.json entry, 31/31.

2. **sharp's prebuilt binaries are Apache-2.0 AND LGPL-3.0-or-later** — they bundle
   libvips. Nobody had noticed. It is fine here (build-time only, never served,
   LGPL attaches to distributing the library) but it is now written down instead of
   waiting to be rediscovered. Documented in prose alongside the MPL-2.0 build
   tools, since platform binaries are outside the generated block.

Licenses outside the allowlist are reported and fail `--check` unless they carry an
explicit REVIEWED entry with a reason.

THIRD-PARTY-NOTICES.md is added to .prettierignore: prettier re-aligns markdown
tables, so leaving it in put the two tools in permanent disagreement — prettier
rewrites the block, then --check reports drift, every run. Confirmed by running the
full CI order twice.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 07:23:12 +07:00
poli0981andClaude Opus 5 7eb47f7248 refactor(content): move src/content to the poli0981/content submodule
Separates writing from deploying: content now lives in its own repo and the site
pins a commit of it.

Chose a submodule over a remote content loader specifically to keep the existing
pipeline intact. Because the files stay at the same physical path, everything
resolves exactly as before:
  - Astro content collections (the glob loaders keep base ./src/content/<dir>)
  - the `image()` schema helper, which resolves relative to the .md file
  - blog/lan-dau-viet-truyen.mdx importing "@/components/Callout.astro" — that
    alias points into the site's src/, which still contains the submodule
  - Pagefind indexing and build-time OG generation
A remote loader would have broken the middle two.

27 entries moved: blog 3, stories 2, projects 2, faq 3, gallery 12, legal 6.
CONTENT-LICENSE.md is copied into the content repo so the All-Rights-Reserved
terms travel with the content — both repos are public now, and the site repo's
GPL-3.0 LICENSE must not be read as covering the stories and photos.

  - ci.yml checkout gains `submodules: recursive`; without it the collections
    resolve to an empty directory and the build dies on the first getCollection()
  - .prettierignore now skips src/content/: formatting a submodule from the
    parent leaves it permanently dirty, and the reformat could never be committed
    from here anyway

Note: a commit in the content repo does NOT deploy on its own — the site builds
from the commit it has pinned, so publishing is a two-step (commit there, bump
the pointer here). That is the intended tradeoff of pinning.

Verified locally: 61 pages build, Callout renders inside the MDX post, CSP guard
343/343, check/lint/knip/prettier green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 01:24:39 +07:00
poli0981andClaude Opus 5 2e672270b7 chore(dependabot): stop proposing TypeScript 7, which can never resolve
The dev-tools group PR (#34) fails at `npm ci` with ERESOLVE because the group
sweeps typescript up to ~7.0.2, and nothing in this toolchain accepts it:

  typescript-eslint  peers >=4.8.4 <6.1.0   <- the binding constraint
  @astrojs/check     peers ^5.0.0 || ^6.0.0
  @astrojs/svelte    peers ^5.3.3 || ^6.0.0

So 6.0.x is the only version that satisfies everyone — which is why package.json
pins `~6.0.3`. This is not new information; it was decided during scaffolding. But
Dependabot had no way to know, so it re-proposed the same impossible bump every
week and took 9 unrelated dev-tool updates down with it each time.

Ignoring only the major means patch and minor TypeScript updates still flow.
Remove this entry when typescript-eslint widens its peer range past 7.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 00:55:05 +07:00
poli0981andClaude Opus 5 d32321c015 fix(deps): patch js-yaml 3.x properly instead of suppressing it
The OSV scan added in the previous commit immediately earned its keep by
catching a mistake in that same commit.

I had claimed js-yaml 3.x had no patched release ("the fix was not
backported") and wrote an osv-scanner.toml suppression for it. That was
wrong. OSV reports FIXED VERSION 3.15.1, and 3.15.1 is published and
satisfies gray-matter's declared `^3.13.1` — so it needed a one-line
override, not an exception. npm audit had been saying "fix available" all
along; I read the advisory title instead of the fix field.

- overrides: add `js-yaml@^3` -> `^3.15.1` (range-scoped alongside the
  existing `js-yaml@^4` -> `^4.3.1`, so each major gets its own patch line
  and gray-matter keeps the v3 API it needs)
- delete osv-scanner.toml — with nothing left to suppress, an empty policy
  file is just a place for future exceptions to accumulate
- drop it from the workflow's pull_request paths filter

`npm audit` now reports **0 vulnerabilities** (was 1 high). Verified
gray-matter still parses frontmatter on 3.15.1: `npm run build` regenerates
all 8 OG images, which goes through gray-matter in scripts/gen-og.mjs.

Also fixes the config bug that made the suppression a no-op anyway: the key
is `ignoreUntil`, not `untilDate`, so the scanner logged "Ignored invalid
config file ... unknown keys in config file: IgnoredVulns.untilDate" and
scanned as if the file were absent. Moot now that the file is gone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 00:45:18 +07:00
poli0981andClaude Opus 5 32f1272377 chore(ci): pin actions to SHAs, add weekly OSV scan, enforce install-script allowlist
Three supply-chain gaps, two of which the repo already claimed to have closed.

1. Actions were pinned to floating tags (`actions/checkout@v7`). A tag is mutable,
   so CI executed whatever that tag pointed at on the day it ran. Now pinned to
   commit SHAs with the version in a trailing comment; the existing
   github-actions Dependabot ecosystem keeps both in sync.

2. Weekly OSV scan (.github/workflows/osv-scanner.yml). docs 06 §6 and 08 §2 both
   require one and none existed. It complements the per-PR audit gate: `npm audit
   --omit=dev --audit-level=high` only sees the production tree and only fails on
   high+, while OSV covers the whole lockfile against the full database. Also runs
   on PRs that touch package-lock.json so a bad bump is caught on the PR instead of
   up to a week later.

   It runs the scanner directly rather than the reusable SARIF workflow, because
   SARIF upload needs `security-events: write` plus code scanning, which this plan
   does not have. A non-zero exit failing the run is the alert. Switch to the
   reusable workflow once the repo is public and code scanning is free.

   osv-scanner.toml carries one suppression: gray-matter -> js-yaml@3.15.0
   (GHSA-5p4m-2wfm-xmqj), which has no patched 3.x and only ever parses our own
   committed frontmatter at build time. It has an `untilDate` so it expires and
   gets re-argued rather than becoming permanent.

3. Install-script hardening. `.npmrc` asserted "ignore-scripts is applied in CI"
   and that sharp needed scripts. Both were false: ci.yml never set it, and
   sharp@0.35 ships prebuilt @img/sharp-* binaries with no install script at all.
   Replaced with npm 11's allowlist model, which is what docs 06 §6 actually asks
   for: package.json#allowScripts names the four packages that legitimately have
   install scripts (esbuild, workerd, lefthook, fsevents) and .npmrc sets
   strict-allow-scripts so anything unreviewed is a hard failure.

   Verified in a clean directory: with strict on and esbuild NOT allow-listed,
   `npm install` exits 1 with ESTRICTALLOWSCRIPTS; with it allow-listed, it
   succeeds. A dependency that suddenly grows a postinstall now stops the build
   instead of executing it.

Also: job-level `permissions:` on the build job, and dependabot.yml's stale note
about /workers/widgets corrected — the worker exists now; it is skipped because it
is deliberately dependency-free and has no manifest to read.

Verified: prettier, eslint, astro check (0 errors), knip, build + CSP guard, audit
gate all green; `npm ci --dry-run` confirms lockfile and package.json stay in sync.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 00:41:04 +07:00
poli0981 8e6c83482d Merge pull request #4 from poli0981/dependabot/github_actions/actions/checkout-7
chore(deps): Bump actions/checkout from 4 to 7
2026-07-30 18:44:47 +07:00
poli0981 018ac3150b Merge pull request #3 from poli0981/dependabot/github_actions/actions/setup-node-7
chore(deps): Bump actions/setup-node from 4 to 7
2026-07-30 18:44:00 +07:00
poli0981andClaude Opus 4.8 6e11f01d70 feat(report): bug-report pipeline (Turnstile -> GitHub Issue + Discord)
Ships fully but degrades gracefully until the owner provisions secrets.

- /api/report (on-demand): Turnstile siteverify -> Zod validate (<=32KB) ->
  GitHub Issue (poli0981/poli0981-dev, labels bug/from-site) -> Discord webhook
  -> 201; if GitHub fails, still Discord + 202. Secrets via astro:env (optional):
  TURNSTILE_SECRET, GITHUB_ISSUES_TOKEN, DISCORD_WEBHOOK_BUG (503 until set).
- src/lib/bugbuffer.ts: client error ring-buffer (20, scrubbed: query strings
  stripped, 3-frame stack, emails/tokens masked, 500-char cap); auto-installs.
- ReportDialog.astro: vanilla <dialog> (textarea + console-attach + preview +
  Turnstile) used on normal pages (footer) AND error pages (404/500), no island.
  Degrades to copy + Discord when PUBLIC_TURNSTILE_SITE_KEY is unset.
- CSP: challenges.cloudflare.com added to script-src/frame-src/connect-src.
- middleware: rate-limit key namespaced per endpoint group (report vs widgets).
- .github/ISSUE_TEMPLATE/bug_report.yml; privacy policy already documents this.
- i18n: report namespace (vi + en); zod dependency.

User action (later): create a Turnstile widget, a fine-grained GitHub Issues
token, and a Discord webhook; set PUBLIC_TURNSTILE_SITE_KEY (build env) and
`wrangler secret put` the three server secrets.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 23:27:57 +07:00
dependabot[bot] 814120bdae chore(deps): Bump actions/setup-node from 4 to 7
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 7.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-19 12:14:16 +00:00
dependabot[bot] 013e3f3203 chore(deps): Bump actions/checkout from 4 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-19 12:14:08 +00:00
poli0981andClaude Opus 4.8 432d57f216 feat: gallery + lightbox + EXIF pipeline
Album index + album detail pages with an image lightbox (doc 04/05 P2), plus the
EXIF hygiene tooling and an AI-crawler robots.txt.

Gallery:
- src/lib/gallery.ts: import.meta.glob resolver mapping src/assets/gallery/<album>/
  → sorted ImageMetadata joined with a sibling captions.json (build-fails on a
  missing vi/en key). getGalleryAlbums/galleryAlbumPaths mirror the projects helpers.
- Routes gallery/{index,[album]} + /en mirrors. Album route param = the shared
  `album` folder name so /gallery/demo ↔ /en/gallery/demo share a slug (LangSwitch
  works, no findTranslation change). GalleryCard mirrors ProjectCard.
- Lightbox.svelte island (client:idle): full AVIF slides generated via getImage() in
  the page and passed as plain props; thumbnails are <button data-lightbox-index> and
  the island attaches one delegated document click listener (CSP-safe, no inline
  onclick). Keyboard ←/→/Esc, focus trap, pointer swipe (offset via CSSOM var),
  x/y counter, caption, reduced-motion branch. No GSAP.
- Nav: Gallery added to primaryNav (Header + menu). i18n `gallery` block in vi/en.
- CSP unchanged (self-hosted /_astro images covered by 'self').

Demo content: scripts/gen-demo-gallery.mjs generates 5 EXIF-clean gradient placeholder
JPGs (swap for real photos later) + captions.json + vi/en album entries.

EXIF + robots:
- scripts/strip-exif.mjs (sharp re-encode, manual pre-commit) + scripts/check-exif.mjs
  (exifr devDep; fails CI if a changed src/assets image carries GPS/serial).
- CI: checkout fetch-depth 0 + Check EXIF step (before Build). knip entry scripts/*.mjs.
  eslint ignore widened to **/.wrangler/ (nested widgets worker temp files).
- public/robots.txt: block /api + AI-training crawlers (ARR content) + sitemap.

Gates green: prettier, eslint, astro check (0 errors), knip, npm audit, build, check-exif.
Built HTML verified: 4 gallery routes, thumbnails + island present, robots + sitemap OK.
(Local astro preview is broken on this Win/Node25 box — interactive lightbox verified
on the live deploy.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 19:09:16 +07:00
poli0981andClaude Opus 4.8 198e4012c0 feat: widgets — YouTube + Steam homepage blocks (cron → KV → island)
Implements the doc-11 widgets feature (data about you, never fetched by visitors).

Cron worker (workers/widgets/, dependency-free, own tsconfig — excluded from the
root check):
- scheduled */45: fetch YouTube RSS (hand-parsed) + Steam recently-played + GitHub
  public events; normalize and overwrite widgets:{yt,steam,gh,status} in the shared
  KV namespace (no TTL).
- Resilience: on per-source failure keep the old KV value and mark stale; stale >24h
  → na; 3 consecutive fully-failed runs → one Discord alert (widgets:fails counter).
- Secrets (STEAM_API_KEY/STEAM_ID64/DISCORD_WEBHOOK_CI) via `wrangler secret put`;
  YT_CHANNEL_ID is a public var. Deployed manually.

Site:
- src/pages/api/widgets.ts (prerender=false) reads KV → JSON, Cache-Control max-age=300.
- src/lib/widgets.ts: shared types + best-effort build-time KV snapshot.
- src/components/WidgetsRefresh.svelte (client:visible): SSRs the snapshot then refetches
  /api/widgets on mount and renders declaratively — YouTube facade (i.ytimg thumb + ▶ →
  youtube-nocookie iframe) and Steam now-playing. Whole section hidden on na/empty.
- Mounted on both homepages (vi + en) between hero and Recent; i18n `widgets` group.
- CSP img-src += media.steampowered.com + *.steamstatic.com (Steam icons).

Scope: GitHub is fetched into KV but has no display component yet (deferred to /dev).
Tooling: root tsconfig excludes workers/; eslint ignores **/worker-configuration.d.ts;
knip entry for the worker; CI typechecks the worker (deploy is manual).

Gates green: prettier, eslint, astro check (0 errors), knip, npm audit, build, worker tsc.
Preview smoke test: /api/widgets 200 + empty→block-hidden; island hydrates without errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 16:48:40 +07:00
poli0981andClaude Opus 4.8 a0dee6cf04 ci: remove GitHub Actions deploy step (Workers Builds deploys instead)
Cloudflare Workers Builds is connected to this repo and deploys on push, so the
GH Actions deploy job was double-deploying. Keep this workflow as CI gates only
(prettier/eslint/astro check/knip/npm audit/build). Workers Builds must deploy
with `wrangler deploy --config ./dist/server/wrangler.json` (root wrangler.jsonc
has no `main`). CLOUDFLARE_* GitHub secrets are now unused by CI (harmless).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 16:06:43 +07:00
poli0981andClaude Opus 4.8 4b5ce980cc ci: add inline deploy + CI pipeline, remove boom test route
Wire up roadmap spike S1 (get poli0981.dev live) as a single self-contained
PR on this repo — no shared poli0981/.github reusable-workflow repo.

- .github/workflows/ci.yml: single-job pipeline (npm ci → wrangler types →
  prettier/eslint/astro check/knip/npm audit → build), plus a deploy step
  gated to push-on-main via cloudflare/wrangler-action. paths-ignore uses
  *.md (root only) so src/content/**.md(x) still deploys.
- .github/dependabot.yml: weekly npm (grouped) + github-actions.
- package.json: `deploy` script. Deploy config path VERIFIED via dry-run —
  the adapter writes dist/server/wrangler.json (main: entry.mjs,
  assets: ../client, auto SESSION binding), NOT dist/client/ as prior notes said.
- Remove src/pages/api/boom.ts (temp 500-test route). No production 500 trigger
  by design; re-test 500 locally via a temporary uncommitted throw.
- knip.json: ignore `lefthook` (knip 6.x no longer detects it via lefthook.yml,
  same class as the existing `cloudflare` ignore).

Local gates all green: prettier, eslint, astro check (0 errors), knip,
npm audit (0 vuln), build, and `wrangler deploy --dry-run`.

PENDING (user-gated, Part B of the plan): wrangler login, create real KV
namespace + wire its id into wrangler.jsonc, first manual deploy, bind custom
domain (apex + www), SSL/HTTPS, CI secrets (CLOUDFLARE_API_TOKEN/ACCOUNT_ID).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 15:20:05 +07:00