diff --git a/CLAUDE.md b/CLAUDE.md index c4c7cb7..97a8fd6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -168,6 +168,28 @@ Kalau `gh` belum ter-auth: **push branch saja**, kasih Axel URL `Compare & PR` Tujuan: tiap tiket terdokumentasi sebagai PR yang bisa dilacak. (Catatan historis: STE-5 terlanjur merge fast-forward langsung ke main sebelum konvensi ini ada — dibiarkan.) +### `main` dikunci ruleset + WAJIB signed commit (28 Sep 2026) + +Repo punya ruleset **`master`** (target: default branch, `bypass_actors: []`, +`current_user_can_bypass: "never"` — **admin pun tidak bisa bypass**, jadi `gh pr merge --admin` +TIDAK akan jalan). Aturannya: no direct push / no force-push / no delete ke `main`, wajib lewat PR, +`require_code_owner_review` (belum ada file `CODEOWNERS`, jadi belum mengikat), extra approval untuk +commit yang tidak ter-attribute ke akun GitHub, dan **`required_signatures`**. + +Konsekuensi praktis: **commit tanpa signature yang terverifikasi tidak bisa di-merge ke `main`.** +Worktree ini sudah diset (repo-local): `gpg.format=ssh`, `user.signingkey=~/.ssh/id_ed25519.pub`, +`commit.gpgsign=true`. + +Itu belum cukup sendiri: GitHub menolak dengan `reason: "unknown_key"` sampai public key yang sama +didaftarkan sebagai **Signing Key** (bukan cuma Authentication Key) di +. Cek kapan pun dengan: + + gh api repos/Lin1er/sterish/pulls//commits \ + --jq '.[] | {sha: .sha[0:8], verified: .commit.verification.verified, reason: .commit.verification.reason}' + +Harus `verified: true`. Kalau `unknown_key`, key-nya belum terdaftar; kalau `unsigned`, commit-nya +dibuat tanpa `-S`/`commit.gpgsign`. + ### Bukti deploy (STE-13 dst) — WAJIB dicatat di DUA tempat Setelah deploy apa pun, catat **SEMUA contract address (CA)** + link [stellar.expert](https://stellar.expert) di: 1. **Comment Linear** tiket deploy-nya, DAN diff --git a/docs/deployments.md b/docs/deployments.md index 8a550a9..959a8ca 100644 --- a/docs/deployments.md +++ b/docs/deployments.md @@ -22,18 +22,33 @@ address has not changed and is the same contract it always was — see --- -## Public URLs (checked 24 September 2026) +## Public URLs (checked 28 September 2026) | What | URL | Served by | Notes | |---|---|---|---| | **API** | **https://api.sterish.xyz** | VPS `187.53.142.100` via Cloudflare Tunnel (STE-54) | Canonical. `REPORT_BASE_URL`, the x402 `resource.url` and the STE-48 `challenge_url` all use it | | API (alias) | https://api-sterish.jameshub.fun | same stack, same tunnel | Kept so anything already pointing at it keeps working | | **Dashboard** | **https://app.sterish.xyz** | Vercel | Public since 24 September; renders live registry data and calls the API at `api.sterish.xyz` | -| Landing | https://sterish.xyz | — | Reserved for the landing page (STE-23); currently 404 | +| **Landing** | **https://sterish.xyz** | Vercel, the **same project** as the dashboard | Serves the landing page (STE-23) at `/` since 28 September (STE-57). The apex currently 308s to `www.sterish.xyz`, which is a Vercel domain setting | +| Landing (direct) | https://app.sterish.xyz/landing | same project | The route the landing page is authored at. Kept answering on every host, because shared links and the Instawards report point at it | The API allows any origin (`api-spec.md` §6): everything it serves is public ledger data, so the dashboard moving hostnames needs no change on the API side. +### One deployment, two front doors + +`sterish.xyz` and `app.sterish.xyz` are the same Vercel project and the same build. What differs is +one host-based rewrite in `frontend/next.config.ts`: on the brand hosts, `/` renders `/landing`; +everywhere else — `app.sterish.xyz`, preview URLs, `localhost` — `/` stays the registry dashboard. +Every other path resolves identically on every host, so a link to `/check` or `/skills/{id}` works +whichever hostname it was copied from. + +The rule lives in `frontend/src/lib/landingHosts.ts` with unit tests, because Next compiles rewrites +into the routes manifest at build time: a mistake there is invisible until it is deployed. It must +sit in `beforeFiles` — `/` is a real route, and `afterFiles` rules only run once nothing has matched. +`LANDING_HOSTS` overrides the host list at build time (`LANDING_HOSTS=localhost pnpm build` to try it +locally, empty to serve the dashboard everywhere). + --- ## Testnet — 2026-09-03 (STE-13) diff --git a/frontend/.env.example b/frontend/.env.example index f1d2700..8107e3c 100644 --- a/frontend/.env.example +++ b/frontend/.env.example @@ -32,3 +32,12 @@ NEXT_PUBLIC_STELLAR_NETWORK=testnet # The tokens contract the licences page reads (VERIFIED badges and licences). # Defaults to Tokens v2 from STE-44; set it only after a redeploy. # NEXT_PUBLIC_TOKENS_CONTRACT_ID=CB6VK4EXEN7V6MXLOFUI2ECMLSDUXAUV5EZICWBICKJDL3WPPU3CTP3T + +# Which hostnames serve the landing page at "/" instead of the registry +# dashboard. Comma-separated, port ignored, unset means sterish.xyz and +# www.sterish.xyz. Read at build time, not in the browser, so it is not a +# NEXT_PUBLIC_ value and a change needs a rebuild. +# +# LANDING_HOSTS=localhost see the landing page at / on a local build +# LANDING_HOSTS= serve the dashboard at / on every host +# LANDING_HOSTS=sterish.xyz,www.sterish.xyz diff --git a/frontend/README.md b/frontend/README.md index 404a8f9..7bdba12 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -26,6 +26,29 @@ pnpm build # next build CI runs exactly these four, in that order. +## Which host serves what + +One deployment answers on every Sterish hostname. A host-based rewrite decides +what `/` is: + +| Host | `/` renders | +|---|---| +| `sterish.xyz`, `www.sterish.xyz` | the landing page (`app/landing`) | +| `app.sterish.xyz` | the registry dashboard (`app/page.tsx`) | +| preview URLs, `localhost` | the registry dashboard | + +`/landing` keeps answering on every host, and every other route resolves the +same everywhere. The rule is `landingRewriteConfig()` in +`src/lib/landingHosts.ts`, wired into `next.config.ts` and covered by +`src/lib/landingHosts.test.ts`. + +Rewrites are compiled into the routes manifest at build time, so to see the +landing page at `/` locally, set the host list and rebuild: + +```bash +LANDING_HOSTS=localhost pnpm build && pnpm start # / is now the landing page +``` + ## Where the data comes from Every read goes through `src/lib/api.ts`. Nothing else in the app calls `fetch` diff --git a/frontend/next.config.ts b/frontend/next.config.ts index 2f6491c..fabd1c2 100644 --- a/frontend/next.config.ts +++ b/frontend/next.config.ts @@ -1,7 +1,15 @@ import type { NextConfig } from "next"; +import { landingRewriteConfig } from "./src/lib/landingHosts"; + const nextConfig: NextConfig = { reactStrictMode: true, + + // sterish.xyz serves the landing page, app.sterish.xyz serves the dashboard, + // and both are this one deployment. See src/lib/landingHosts.ts. + async rewrites() { + return landingRewriteConfig(process.env.LANDING_HOSTS); + }, }; export default nextConfig; diff --git a/frontend/src/lib/landingHosts.test.ts b/frontend/src/lib/landingHosts.test.ts new file mode 100644 index 0000000..08c101d --- /dev/null +++ b/frontend/src/lib/landingHosts.test.ts @@ -0,0 +1,109 @@ +import { describe, expect, it } from "vitest"; + +import { + DEFAULT_LANDING_HOSTS, + LANDING_PATH, + landingHostPattern, + landingRewriteConfig, + landingRewrites, + parseLandingHosts, +} from "@/lib/landingHosts"; + +/** + * Mirrors how Next evaluates a `has: [{ type: "host" }]` rule: it takes the + * Host header, drops the port, lowercases it, and tests it against + * `^$`. Reproduced here (node_modules/next/dist/shared/lib/router/ + * utils/prepare-destination.js) because the rules are compiled into the routes + * manifest at build time, so an anchoring mistake would only show up in + * production. + */ +function matches(pattern: string, hostHeader: string): boolean { + const hostname = hostHeader.split(":", 1)[0].toLowerCase(); + return new RegExp(`^${pattern}$`).test(hostname); +} + +describe("parseLandingHosts", () => { + it("falls back to the brand hosts when LANDING_HOSTS is unset", () => { + expect(parseLandingHosts(undefined)).toEqual(DEFAULT_LANDING_HOSTS); + expect(parseLandingHosts(null)).toEqual(DEFAULT_LANDING_HOSTS); + }); + + it("does not let a caller mutate the default list", () => { + parseLandingHosts(undefined).push("evil.example"); + expect(parseLandingHosts(undefined)).toEqual(["sterish.xyz", "www.sterish.xyz"]); + }); + + it("normalises whitespace, case and ports", () => { + expect(parseLandingHosts(" Localhost:3000 , STERISH.xyz ")).toEqual([ + "localhost", + "sterish.xyz", + ]); + }); + + it("treats an explicitly empty value as 'no landing host'", () => { + expect(parseLandingHosts("")).toEqual([]); + expect(parseLandingHosts(" , ")).toEqual([]); + }); +}); + +describe("landingHostPattern", () => { + const pattern = landingHostPattern(DEFAULT_LANDING_HOSTS); + + it("matches the brand hosts", () => { + expect(matches(pattern, "sterish.xyz")).toBe(true); + expect(matches(pattern, "www.sterish.xyz")).toBe(true); + expect(matches(pattern, "STERISH.XYZ")).toBe(true); + expect(matches(pattern, "sterish.xyz:443")).toBe(true); + }); + + it("leaves the dashboard, previews and local development alone", () => { + expect(matches(pattern, "app.sterish.xyz")).toBe(false); + expect(matches(pattern, "sterish-frontend.vercel.app")).toBe(false); + expect(matches(pattern, "localhost:3000")).toBe(false); + }); + + it("escapes the dot, so a lookalike host is not the brand host", () => { + expect(matches(pattern, "sterishaxyz")).toBe(false); + expect(matches(pattern, "not-sterish.xyz")).toBe(false); + expect(matches(pattern, "sterish.xyz.attacker.example")).toBe(false); + }); +}); + +describe("landingRewrites", () => { + it("rewrites only '/' and only for the landing hosts", () => { + expect(landingRewrites(undefined)).toEqual([ + { + source: "/", + destination: LANDING_PATH, + has: [{ type: "host", value: "(?:sterish\\.xyz|www\\.sterish\\.xyz)" }], + }, + ]); + }); + + it("emits nothing when no host should serve the landing page", () => { + expect(landingRewrites("")).toEqual([]); + }); + + it("can be pointed at a single host for local verification", () => { + const [rewrite] = landingRewrites("localhost"); + expect(rewrite.has[0].value).toBe("(?:localhost)"); + expect(matches(rewrite.has[0].value, "localhost:3000")).toBe(true); + }); +}); + +describe("landingRewriteConfig", () => { + it("puts the rule in beforeFiles, because '/' is a real route", () => { + const config = landingRewriteConfig(undefined); + expect(config.beforeFiles).toEqual(landingRewrites(undefined)); + expect(config.afterFiles).toEqual([]); + expect(config.fallback).toEqual([]); + }); + + it("stays empty everywhere when no host serves the landing page", () => { + expect(landingRewriteConfig("")).toEqual({ + beforeFiles: [], + afterFiles: [], + fallback: [], + }); + }); +}); diff --git a/frontend/src/lib/landingHosts.ts b/frontend/src/lib/landingHosts.ts new file mode 100644 index 0000000..41d433d --- /dev/null +++ b/frontend/src/lib/landingHosts.ts @@ -0,0 +1,110 @@ +/** + * Which hostnames serve the landing page at "/". + * + * One Vercel project answers on every Sterish hostname, so the dashboard and + * the landing page are the same deployment. What separates them is the host: + * + * sterish.xyz, www.sterish.xyz -> the landing page (this module) + * app.sterish.xyz -> the dashboard, the app's real "/" + * *.vercel.app, localhost -> the dashboard, so previews and `next dev` + * keep showing the page being worked on + * + * `/landing` keeps answering on every host. The report, docs/deployments.md and + * the links already shared point at it, and a rewrite adds a second entrance + * rather than moving the first one. + * + * Kept out of next.config.ts so the host matching is testable: the rules are + * baked into the routes manifest at build time, which makes a mistake here + * invisible until it is deployed. + */ + +/** + * The brand hosts. Both are listed because the apex -> www redirect is a Vercel + * domain setting, not something this repo controls: matching both means the + * landing page stays at "/" whichever way that redirect points. + */ +export const DEFAULT_LANDING_HOSTS = ["sterish.xyz", "www.sterish.xyz"]; + +/** The route the landing page is authored at, and keeps answering on. */ +export const LANDING_PATH = "/landing"; + +/** A Next.js rewrite, narrowed to the one shape this module emits. */ +export type LandingRewrite = { + source: string; + destination: string; + has: { type: "host"; value: string }[]; +}; + +/** + * Read the host list from `LANDING_HOSTS`. + * + * Unset falls back to the brand hosts. Set but empty disables the rewrite + * entirely, which is how a deploy can serve the dashboard everywhere without a + * code change. + * + * Ports are dropped because Next compares against the hostname only, so + * `localhost:3000` would never match anything; `LANDING_HOSTS=localhost` is how + * the rewrite is exercised against a local `next start`. + */ +export function parseLandingHosts(raw?: string | null): string[] { + if (raw === undefined || raw === null) { + return [...DEFAULT_LANDING_HOSTS]; + } + return raw + .split(",") + .map((host) => host.trim().toLowerCase().split(":")[0]) + .filter((host) => host.length > 0); +} + +function escapeRegExp(value: string): string { + return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +/** + * The `has` value for a host rule: an alternation of literal hostnames. + * + * Next wraps this in `^...$` and matches it against the lowercased hostname, so + * every metacharacter is escaped. An unescaped dot would make `sterishaxyz` a + * match for `sterish.xyz`. + */ +export function landingHostPattern(hosts: string[]): string { + return `(?:${hosts.map(escapeRegExp).join("|")})`; +} + +/** + * The rewrite rules themselves. + * + * Only "/" is rewritten. Every other path resolves the same on every host, so + * a link to /skills/{id} or /check keeps working whether it was copied from the + * apex or from app.sterish.xyz. + */ +export function landingRewrites(raw?: string | null): LandingRewrite[] { + const hosts = parseLandingHosts(raw); + if (hosts.length === 0) { + return []; + } + return [ + { + source: "/", + destination: LANDING_PATH, + has: [{ type: "host", value: landingHostPattern(hosts) }], + }, + ]; +} + +/** + * What `next.config.ts` returns from `rewrites()`. + * + * `beforeFiles`, not the plain array: the array form becomes `afterFiles`, + * which Next only consults once nothing else has matched the path. "/" is a + * real route (app/page.tsx, the registry), so it always matches first and an + * `afterFiles` rule never fires. Verified by serving a production build and + * sending both Host headers. + */ +export function landingRewriteConfig(raw?: string | null): { + beforeFiles: LandingRewrite[]; + afterFiles: LandingRewrite[]; + fallback: LandingRewrite[]; +} { + return { beforeFiles: landingRewrites(raw), afterFiles: [], fallback: [] }; +}