gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchf7-hookseee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmref7-hooks/README.md

72.5 KB

  1. # ident.worldapi.org — for developers of ident
  2. **What ident is and how an app uses it is explained at https://ident.worldapi.org/docs** (source: `docs/IDENT.md`, the only copy
  3. of that text; the page renders the file). Read that first if you use ident or build an app on it. This README is for people who
  4. work on ident itself: how to run it, the gates, the deploy, the files, and the exact edge cases of every endpoint.
  5. **`CONCEPT.md` (the creator's) is the source of truth** — nothing is built that it does not describe.
  6. History in one line: built in pieces under AntColony (byrodin `/CONTAINERS/projects/antcolony/README.md`): piece 1 #24 the
  7. login and identities (`/`), piece 2 #25 apps and the login button (`/apps`), piece 3 #26 the selector (`/selector.js`), piece 4
  8. ident#6 notifications (`/inbox`), piece 5 ident#7 delivery (the daily mail); push (piece 6, ident#8) is not built: an urgent
  9. notification is mailed. ident#45 added the docs page `/docs`.
  10. Written in **Hybriel** on **hl:web** (hybriel master, since antcolony mission 036), same stack and conventions as
  11. `/media/STORAGE/projects/WorldAPI/tickets.worldapi.org`.
  12. ## Run (dev, Loreana)
  13. ```bash
  14. cd /media/STORAGE/projects/WorldAPI/ident.worldapi.org
  15. setsid nohup ./bin/hybriel project.hl > server.log 2>&1 < /dev/null & echo $! > server.pid
  16. # stop: kill $(cat server.pid)
  17. ```
  18. * Port **8351** on 0.0.0.0 — http://100.77.141.84:8351 (tailnet), http://192.168.178.75:8351 (LAN).
  19. * The dev watcher is on: saving a `.hl` file reloads; restart after `.env`/binary changes and after
  20. changing `components/styles.hl` root members or `shared/tokens.hl` (the served sheet is not rebuilt).
  21. * **The dev server sends REAL mail** (SMTP via mail.byrod.in, `.env` — do not read or print it,
  22. it holds the SMTP password). Never trigger an OTP on :8351 in a test; tests start their
  23. own servers with `IDENT_MAIL_SINK`.
  24. * **Test app** (`testapp/`, :8354): see "How apps use ident" → "Try it".
  25. * Config: **`.env`** in the app folder (read from the cwd; the real environment outranks it):
  26. | Variable | Default | |
  27. |---|---|---|
  28. | `IDENT_PORT` | 8351 | |
  29. | `IDENT_MAIL_SINK` | — | file that gets `<address> <code>` appended per code INSTEAD of mail. Dev: `storage/mail-sink.txt` |
  30. | `SMTP_HOST` `SMTP_PORT` `SMTP_USER` `SMTP_PASSWORD` `SMTP_FROM` | — / 587 | hl:smtp; used when `IDENT_MAIL_SINK` is empty. Neither set → the code is only logged as NOT SENT |
  31. | `IDENT_STORAGE` | `./storage/mpackdb` | table DIRECTORY (`<dir>/<table>.*`); absolute for tools |
  32. | `IDENT_SESSIONS` | `.sessions/` | session store |
  33. | `IDENT_OTP_TTL_MS`, `IDENT_SEND_WINDOW_MS`, `IDENT_SEND_LIMIT` | 600000, 600000, 3 | clocks/limits (the gate shortens the OTP TTL) |
  34. | `IDENT_IP_LIMIT`, `IDENT_IP_WINDOW_MS` | 10, 600000 | codes per client IP per 10 min (mission 006 (old 010)) |
  35. | `IDENT_IP_DAY_LIMIT`, `IDENT_IP_DAY_WINDOW_MS` | 30, 86400000 | codes per client IP per 24 h |
  36. | `HL_HOST` (or `HOST`) | 0.0.0.0 | interface to bind; `127.0.0.1` on Byrodin (hl:web reads it itself, hybriel#24) |
  37. | `IDENT_WATCH` | on | `0` = no dev watcher (the container) |
  38. | `IDENT_GRANT_TTL_MS` | 60000 | life of a login button's one-time code (`tests/apps.mjs` shortens it) |
  39. | `IDENT_DIGEST_EVERY` | 60 | seconds between two rounds of the daily mail (`tests/delivery.mjs`: 0.2) |
  40. | `IDENT_TEST_CLOCK` | — | GATES ONLY: a file holding an epoch-ms instant that delivery takes as "now" (never set it in the container) |
  41. | `IDENT_PUBLIC_URL` | — | the invite links' and the notification mails' base (`<url>/inbox`); the container sets it |
  42. ## Identity access (ident#27): one key per identity
  43. An account gives one of its identities (a person or an **agent**, e.g. a conductor) access to some of its apps from the **Access** page (`/access`), without logging out and in.
  44. Code: `lib/access.hl` (the tables and rules), `components/access.hl` (the page), `POST /api/introspect` in `lib/api.hl`, the gate `tests/access.mjs`.
  45. * One key per identity, `idt_` + 48 hex, for all its apps. It is shown **once** (when first given, or after a rotate); ident stores only its sha256 (`accesskeys.db`). Keys never expire.
  46. * The grants (`access.db`) say in which apps the key counts and with which level, `write` (default) or `read`. Agent identities (`kind = 'agent'`) are not offered in the login selector.
  47. * **Revoke** deletes the grant: the app's next question gets `active:false`. **Rotate** makes a new key and kills the old one in every app at once (no grace period).
  48. * The app's server asks, with its own key and secret: `POST /api/introspect { key, secret, token }` → `200 { active: true, identity: <short id>, name, access: 'read' | 'write' }`, or `200 { active: false }` (unknown, revoked, no grant for THIS app, identity gone, token of the wrong shape); `401` wrong key or secret; `400` strict body. Every `active:true` answer records the last use and counts a call. ident never caches; the 30 s of the proposal is the app's own cache.
  49. ## What it does (piece 1)
  50. * **Login**: email → 6-digit code (10 min, single use, 5 wrong tries kill it, a new request
  51. replaces the old code, max 3 codes per address per 10 min, **max 10 codes per client IP
  52. per 10 min and 30 per 24 h**) → signed in.
  53. * **Per-IP limit** (mission 006 (old 010)): the code request is `POST /api/code {email}` (the sign-in
  54. form fetches it; it is NOT a face any more — a face sees no request headers). The client IP
  55. is the **`X-Client-IP`** header only (nginx on Byrodin sets it and overwrites a client's:
  56. `/CONTAINERS/web/nginx/conf.d/cloudflare-client-ip.conf`); `CF-Connecting-IP`,
  57. `X-Forwarded-For`, `X-Real-IP` are never read. IPv6 counts per **/64**, `::ffff:a.b.c.d`
  58. as the IPv4. **No header (dev, no nginx) = ONE shared bucket `direct`** (hl:web's
  59. `req.remoteAddress` would only be nginx's). Refusal: 429 `{error}` shown under the form ("too many codes were
  60. requested from your network …"); per address: 429 "too many codes were sent to this address …".
  61. Table `ipsends` `{ip (bucket), at}`. **Only safe while ident is reachable through nginx
  62. alone** (on Byrodin it binds 127.0.0.1) — anyone reaching it directly could send any header. Session cookie
  63. `identsid` (manifest `sessionCookie`, not hl:web's default `hlsid`: cookies ignore ports, tickets on :8350 uses `hlsid`).
  64. * **The code step is its own page** (ident#20, mission 008 (old 032); creator: "just make a /code where
  65. it checks a pending code"): after `POST /api/code` succeeds the page calls the face
  66. `rememberPending(email)` (records `session.data.pendingEmail`; refused unless a code for that
  67. address is really waiting — `lib/login.hl codeWaiting`) and goes to **`/code`** (app login:
  68. **`/signin/<rid>/code`**). That route (`lib/api.hl codePage`, a function route because a
  69. component route cannot redirect) shows Home's code form for the session's pending address
  70. while its code is waiting (unused, unexpired, < 5 wrong tries), else **302 back** to `/` resp.
  71. `/signin/<rid>` (also when signed in, or a rid that is not 32 hex). So a reload, a second tab,
  72. a re-seed keeps the code form. Cleared on: sign-in (`verifyCode`), "Other address" (face
  73. `forgetPending`, → the email page), expiry / killed code (read as none). A wrong code keeps it.
  74. After sign-in the address bar is set back to `/` resp. `/signin/<rid>` (`history.replaceState`).
  75. * **No registration**: the first right code for an address creates the account **and its
  76. default identity** (identity name `Default`), then shows that identity's fields with
  77. "all of these fields are optional" and **Save** / **Skip**.
  78. * **Identities**: fields identity name, nickname, first name, last name — all optional
  79. (trimmed, ≤ 60 chars, no control characters). List, new, edit, delete. The last identity
  80. cannot be deleted. The **default** identity is the oldest remaining one (badge in the list).
  81. The list shows the identity name; without one: nickname, else first + last name, else
  82. `Identity <n>`.
  83. * **Avatar** (ticket #15, reworked after the creator asked for an upload): an optional `avatar` field
  84. on an identity — a picture **uploaded** in the identity form (file chooser, "Remove picture" to
  85. clear). `avatar.js` (route `/avatar.js`, included by `components/main.hl`) cuts it to a centred
  86. square, scales it to 128×128 in the browser and writes it as a data URL (WebP; JPEG if the browser
  87. cannot make WebP and PNG is too big) into the form's hidden `#favatar`; an `input` event hands it to
  88. the page (a page script cannot emit, hybriel #31). The server (`lib/identities-helpers.hl checkAvatarUrl`) accepts
  89. only `data:image/(png|jpeg|webp);base64,` with the type's magic bytes at the start, base64
  90. characters only, ≤ 60000 characters — no links, no SVG. Stored in the identity record's `avatar`.
  91. Shown as a small round image in the identity list and the "choose an identity" list, and as a
  92. preview in the form. Old avatars that were http(s) links (first version) are no longer shown and
  93. are dropped on the next save. Apps do not get it yet — handed over once ticket #11 (property
  94. hand-over at first handshake) is built; until then apps fall back to the name's first letter.
  95. **Lesson (hybriel #32/#41)**: no `if` block next to the text inputs of the form (recreates the form,
  96. loses focus) — the preview and the remove button are always rendered and toggled with a `hidden`
  97. CSS class from a plain reactive field.
  98. * **Time zone**: the browser's IANA zone (`Intl…resolvedOptions().timeZone`) is stored at the
  99. first login; shown and changeable (text field + "Use this browser's"; "Your daily mail of notifications comes at
  100. 17:00 in this time zone."). The page refuses names the browser does not know; the server checks the shape AND
  101. hl:time's zone database (`isZone`, hybriel#5 — the system's tz files; the container's debian:12-slim has `tzdata`):
  102. `unknown time zone: <name>`. A first login with an unknown zone stores UTC; an account without a (known) zone
  103. reads as UTC (`lib/accounts.hl zoneOf`) — no migration, nothing rewritten. A later login does NOT overwrite it.
  104. * **Apps** (`/apps`, piece 2): any signed-in account registers apps — name + the origins it
  105. runs on (`http(s)://host[:port]`, 1–10; an app that runs on many subdomains registers ONE wildcard origin
  106. `https://*.example.org` = every one-label subdomain, gitoria's repository addresses). Each app gets a public **API key** (`pk_` + 32 hex)
  107. and a **secret** (`sk_` + 48 hex) shown **once** (after register / "New secret"; only its
  108. sha256 is stored). List, edit (name, origins; the key stays), new secret (old one dies at
  109. once), delete (its per-app ids go with it). Only the owner sees/changes an app.
  110. * **One public short id per identity** (ident#23, replaces "one id per app"): every identity has
  111. a `shortId` — 5 characters like `a68sz`, random, made when the identity is made, kept forever,
  112. the same in every app. Alphabet: the digits 2–9 and the letters a–z without i, l, o (31
  113. characters, 28.6 million ids; no 0/O, 1/l/I to mix up on the phone), lower case, unique
  114. (checked against an index when made; longer only if it ever runs out). Case does not matter when
  115. it is typed (`A68SZ` finds `a68sz`). The identity page shows it (selectable). Only the id is
  116. public — names, email and avatar stay as the identity sets them. Identities that existed
  117. before get theirs at the first start (`lib/identities.hl backfillShortIds`, touched from `project.hl`).
  118. The first login of an identity in an app still creates a **connection** (its creation time =
  119. "when they registered in it", for the per-app page); it holds no id of its own any more.
  120. Connections made before ident#23 keep their old 32-hex `appIdentity` only until the app has
  121. migrated (below).
  122. * **Migration for the apps** (ident#23): `POST /api/migrate-ids {"key","secret","finish"?}` →
  123. `200 {"ids":{"<old per-app id>":"<short id>"},"count":n,"finished":bool}` (every connection of
  124. that app that still has an old id; an identity deleted since is left out; 401 wrong key/secret).
  125. The app's server calls it once and rewrites its stored users. Until then `/api/notify` also
  126. accepts the old id. With `"finish":true` the answer is the same and the old ids are dropped
  127. afterwards — from then on they are unknown (404) and the map is `{}`. Gate: `tests/migration.mjs`.
  128. * **Ids** (mission 005 (old 009), creator's convention): every table's key is the mpackdb UUID
  129. (`@id`, 12 chars like `0mufcrs6sb3v`); accounts, identities and apps are addressed by it
  130. (faces take it as a string; an old numeric id finds nothing). "Oldest first" (the default
  131. identity, the app list) sorts by the stored `created`, never by key order.
  132. * JSON endpoints: `POST /api/code` (the login code, above), `POST /api/exchange`, `POST /api/kinds`, `POST /api/notify` (piece 4), and the selector's `GET /api/selector/identities`,
  133. `POST /api/selector/choose` (CORS, piece 3); other `/api/*` answer a JSON 404. The pages'
  134. server faces (`components/home.hl`, `components/apps.hl`) do all other writes. Face arguments are checked strictly (unknown field / wrong type
  135. → error naming the field) and every face only trusts a real framework session (see Lessons
  136. in STATUS.md — a forged trailing argument is refused).
  137. * **Removed (mission 002 (old 005))**: the mission-003 app login (`/login?app=&return=`, `/continue/:rid`,
  138. the origin allow list `IDENT_ALLOWED_ORIGINS`, `testclient/`); old files in
  139. `.scratch/removed-mission003/`. Piece 2 rebuilt `/login` and `/api/exchange` per the concept.
  140. * **Session hardening (ticket #2)**: a signed-in session gets its OWN expiry, stamped at
  141. sign-in (`lib/accounts.hl` `beginSession`) and checked on every use (`accountOfSession`) —
  142. independent of the hl:web session file's own rolling idle/maxAge. `IDENT_SESSION_TTL_MS`
  143. (default 99 years: logins never expire, creator 2026-10-23; only a sign-out ends them). An older session (no expiry stamped yet, e.g. from before this ticket
  144. or the mission-009 migration) is upgraded on its next use, not force-signed-out.
  145. **"Sign out everywhere"** (`/`, account bar) bumps the account's session epoch, which
  146. invalidates every session of that account — the caller's own included — on its next check,
  147. without touching any other session file. Ticket #19: it also DELETES every session of the
  148. account at once (resident ones and files; `lib/accounts.hl` `dropUserSessions` on project.hl's server, reached through
  149. `lib/accounts.hl` `sessionHooks`) and pushes the `signedOutAll` event (audience: connections whose
  150. session is the account's) — `components/main.hl` reloads every open page on every device into
  151. the signed-out state, no click. Gate: `tests/signoutall.mjs` (:8702, two Chromes). **"Sign out of this app"** (the per-app page,
  152. `/inbox/<connection id>`) forgets one app connection; a later login gets the same short id
  153. again. Gate: `tests/hardening.mjs`.
  154. ## Invites (ticket ident#22)
  155. Reference for developers: the overview for app builders is https://ident.worldapi.org/docs (`docs/IDENT.md`); this section keeps
  156. the exact rules, limits and error answers.
  157. An app invites people to one of ITS projects through ident. CONCEPT.md does not describe it; the
  158. ticket is the spec. Code: `lib/invites.hl` (the person's login flow: `lib/apps.hl` openInvite / grantInvite), routes in `lib/api.hl`, table `invites` (`lib/invites.hl`).
  159. All calls are `POST` with a strict JSON body and the app's **key + secret** (401 otherwise):
  160. ```
  161. POST /api/invites {key, secret, project, role, return, uses?, days?, email?}
  162. 200 {id, url, state:"open", project, role, uses, expires, mailed}
  163. POST /api/invites/list {key, secret, project?} → {invites:[{id, project, role, state, uses, used, identities, expires, created}]}
  164. POST /api/invites/get {key, secret, id} → {invite}
  165. POST /api/invites/revoke {key, secret, id} → {invite} (409 unless it is open)
  166. ```
  167. * `project` / `role`: the app's own words (1–60 chars). `return`: where the person lands — like the
  168. login button, absolute http(s) on one of the app's origins. `uses` (default **1**, up to 1000),
  169. `days` (default **7**, up to 90). `state`: `open`, `used` (all uses taken), `expired`, `revoked`.
  170. * The **link** (`<ident>/invite/<token>`) is in the create answer ONLY (ident keeps its sha256). The
  171. app shows it (copy / share) itself. With `email`, ident also **mails it through its own mailer**
  172. (`lib/mail.hl sendInvite`; sink: `<IDENT_MAIL_SINK>.invites`); max 50 invitation mails per app per 24 h
  173. (`IDENT_INVITE_MAIL_LIMIT`, 429). The address is not stored and not tied to the login: whoever holds the link joins.
  174. * **The person**: `GET /invite/<token>` — used / expired / withdrawn / unknown give an error page
  175. (410 / 404) with a plain message; an open one is the login button's own flow: a login request
  176. carrying the invite → `/signin/<rid>` ("You are invited to <app>"), email → code if signed out,
  177. the identity choice (one click) if signed in. Choosing an identity **accepts** the invite (takes a use;
  178. the same identity again takes none) and sends the browser to `<return>?ident_code=<code>&invite=<invite id>`.
  179. * **The app's server** exchanges the code (`/api/exchange`, gives the identity id) and asks
  180. `/api/invites/get` for the invite: `identities` lists who accepted — check that the exchanged id is in it.
  181. Two people racing for the last use: the second is told "already used".
  182. * `IDENT_PUBLIC_URL` (compose: https://ident.worldapi.org) = where links point; unset → the request's Host.
  183. `IDENT_INVITE_DAY_MS` (gate only) shortens a "day". Gate: `tests/invites.mjs` (:8700/:8701). The test app has `/invites`.
  184. ## How apps use ident (login button, piece 2)
  185. Reference for developers: the overview for app builders is https://ident.worldapi.org/docs (`docs/IDENT.md`); this section keeps
  186. the exact rules, limits and error answers.
  187. 1. **Register the app** in ident: `/apps` → "Register an app": name + origin(s). Keep the API
  188. key (public) and the secret (server only; shown once).
  189. 2. **The button** sends the browser to
  190. `<ident>/login?key=<API key>&return=<percent-encoded return URL>`.
  191. The return URL must be absolute http(s), no `#`, ≤ 2000 chars, and its origin one of the
  192. app's origins — else ident shows an **error page (HTTP 400) and never redirects**.
  193. 3. ident parks the request (30 min) and shows `/signin/<rid>`: signs the browser in to ident
  194. if needed (email code; a first login shows the optional names first), then **"Choose an
  195. identity"** (also with one identity: it is shown, one click).
  196. 4. ident redirects to `<return URL>?ident_code=<code>` (or `&ident_code=` if it has a query).
  197. The code is 48 hex, **single use, 60 s**, for this app only.
  198. 5. **The app's server** exchanges it:
  199. ```
  200. POST <ident>/api/exchange {"key":"pk_…","secret":"sk_…","code":"…"}
  201. 200 {"identity":"a68sz"} ← the identity's public short id, NOTHING else
  202. 401 unknown key or wrong secret 400 unknown/used/expired code, code of another app
  203. 400 invalid JSON, unknown/missing/wrong-type field (named); 405 not POST
  204. ```
  205. **Profile fields (ident#11).** Add `"fields"` to ask for what the person entered on their
  206. identity in ident: `nickname`, `firstname`, `lastname` (the identity name stays private).
  207. ```
  208. POST <ident>/api/exchange {"key":"pk_…","secret":"sk_…","code":"…","fields":["nickname","firstname","lastname"]}
  209. 200 {"identity":"a68sz","nickname":"Caro","firstname":"Caroline","lastname":null}
  210. 400 unknown field name (named in the error; the code is NOT spent), fields not a list
  211. ```
  212. A field the person has not filled in is `null`: never left out, never made up. The app decides
  213. itself what to show (nickname, else first + last name, else the short id). Without `fields`
  214. the answer is `{"identity":"a68sz"}` exactly as before. Later, for an identity that signed in
  215. to your app before, ask again (the person may have filled in a name since):
  216. ```
  217. POST <ident>/api/profile {"key":"pk_…","secret":"sk_…","identity":"a68sz","fields":["nickname","lastname"]}
  218. 200 {"identity":"a68sz","nickname":"Caro","lastname":null}
  219. 401 wrong key or secret 404 no such identity in this app (also when it never signed in to it)
  220. 400 bad body or unknown field name 405 not POST
  221. ```
  222. A code presented by the wrong app is spent. The same identity always gets the same id, in
  223. every app (ident#23); a person can say it aloud and others find them by it. The app asks the
  224. user itself for any further data it needs.
  225. ### The identity selector (piece 3)
  226. Same app registration (key + secret, origins). The app's page includes ident's script and
  227. the element, configured with the app's **public API key**:
  228. ```html
  229. <script src="https://<ident>/selector.js"></script>
  230. <ident-selector key="pk_…"></ident-selector> <!-- add logged-in when the site's session is logged in -->
  231. <script>
  232. const sel = document.querySelector('ident-selector');
  233. sel.addEventListener('ident-login', async (e) => { // the user chose an identity = the login
  234. await fetch('/my-login', { method: 'POST', body: JSON.stringify({ code: e.detail.code }) });
  235. // → YOUR SERVER: POST <ident>/api/exchange {key, secret, code} → {identity}, keep it server side
  236. sel.loggedIn = true; // the host tells the selector (or the attribute)
  237. });
  238. // logout on the website = reset the selector: sel.loggedIn = false / sel.reset()
  239. </script>
  240. ```
  241. * The element (shadow DOM, ident's design) first says **"choose ident"**. Opening it fetches
  242. `GET <ident>/api/selector/identities?key=` **with credentials** (the browser's ident
  243. session cookie; same site only — `SameSite=Lax`). ident answers **only** when the
  244. request's `Origin` is one of the app's registered origins **and** the key is that app's:
  245. then `Access-Control-Allow-Origin: <that origin>` + `…-Allow-Credentials: true` (never
  246. `*`) and `{"signedIn":true,"identities":[{"id","name"}]}` — the identity **name** only;
  247. `id` is an opaque per-app pick id (not ident's id, not the short id). Otherwise
  248. **403 without CORS headers** (the page gets nothing). Signed out of ident:
  249. `{"signedIn":false,"identities":[]}` → the panel holds **ident's own sign-in page in an iframe** (ident#31, below);
  250. opening it again re-asks.
  251. * Choosing an identity: `POST <ident>/api/selector/choose?key=` `{"identity":"<id>"}`
  252. (preflighted, same CORS rule; strict body) → `{"code"}` — **the same one-time code as the
  253. login button's** (48 hex, single use, 60 s, this app only). The element fires
  254. **`ident-login`** (`event.detail.code`, bubbles, composed) and closes. The host's server
  255. exchanges the code exactly as in step 5 above.
  256. * **Signing in inside the panel (ident#31).** Signed out of ident, the panel shows `GET <ident>/embed/signin?key=<API key>&return=<URL>`
  257. in an iframe (`lib/api.hl embedSignin`, `components/embed.hl`): "This signs you in to ident.", the email field, the code field (the same
  258. code mail, the same per-address and per-IP limits, `POST /api/code`), then the identities. The frame is the same checks as the login
  259. button (known key, return URL on one of the app's origins, else a 400 page) and may be **framed only by the app's registered origins**
  260. (`Content-Security-Policy: frame-ancestors <origins>`). Choosing an identity is a plain link with `target="_top"` to
  261. `/embed/go?rid=&identity=`, which answers a redirect to `<return>?ident_code=<code>`: the whole app page goes there (the login button's
  262. step 4) and the app exchanges the code as always. A **new address** (the first right code creates its account) gets a "Create my identity"
  263. link, also `target="_top"`, to `/signin/<rid>/welcome`: ident in the same tab with the default identity's name form, then the choice, then
  264. back to the app. (ident learns that an address is new only after the code proved it is the user's: no account enumeration.)
  265. The element's optional **`return`** attribute names the URL ident sends the browser back to (default: the current page, which then must
  266. handle `ident_code`; most apps point it at their login callback). Gate: `node tests/signin.mjs` (ports 8700–8702, Chrome 8710–8719).
  267. * **`logged-in`** attribute / `loggedIn` property: set by the HOST (it knows its own
  268. session): the element shows "✓ logged in with ident" (+ the identity's name if chosen on
  269. this page) instead of the button. Removing it (`loggedIn = false`, `reset()`) = back to
  270. "choose ident". The selector sets **no cookie** and keeps no login state of its own.
  271. * **Restyle** from the host page: CSS custom properties on the element —
  272. `--ident-accent`, `--ident-accent-text`, `--ident-background`, `--ident-text`,
  273. `--ident-text-strong`, `--ident-text-muted`, `--ident-border`, `--ident-radius`,
  274. `--ident-font` — and `::part(button | panel | identity | status | message | link)`,
  275. e.g. `ident-selector { --ident-accent: #569bd4 } ident-selector::part(button) { text-transform: uppercase }`.
  276. **Try it** (test app, `testapp/`, a separate hybriel app): http://100.77.141.84:8354 —
  277. register an app in ident with origin `http://100.77.141.84:8354`, paste key + secret into
  278. the test app's form, press "Log in with ident" — or, on the same page, **"choose ident"** (the selector; you
  279. must be signed in to ident at http://100.77.141.84:8351 in the same browser). The test app
  280. shows the id it got (a real app never would) and "new user"/"welcome back"; the selector
  281. switches it to "Logged in" without a reload, "Log out" resets the selector. Its own session
  282. cookie: `testapp<port>sid`. Its data: `testapp/storage/testapp.json`.
  283. ```bash
  284. cd testapp && TESTAPP_PORT=8354 TESTAPP_URL=http://100.77.141.84:8354 IDENT_URL=http://100.77.141.84:8351 \
  285. setsid nohup ../bin/hybriel project.hl > testapp.log 2>&1 < /dev/null & echo $! > testapp.pid
  286. ```
  287. ## How apps send notifications (piece 4)
  288. Reference for developers: the overview for app builders is https://ident.worldapi.org/docs (`docs/IDENT.md`); this section keeps
  289. the exact rules, limits and error answers.
  290. CONCEPT.md "Notifications" / "Per-app page". The app's SERVER calls ident with its API key +
  291. **secret** (never from a page) and the **app-specific identity id** it got from the exchange.
  292. Apps never get an email address. Strict JSON bodies (unknown/missing/wrong-type field → 400
  293. naming it; invalid JSON 400; not POST 405; wrong secret / unknown key 401).
  294. 1. **Register the kinds** (by name) with their **preset channels** — optional, but a kind must
  295. be registered before it can be **pushed**. Upsert: a name already there gets the new
  296. preset. Answers every registered kind. `kinds: []` just lists them. ≤ 50 per call, ≤ 200 per app;
  297. a refused call writes nothing.
  298. ```
  299. POST <ident>/api/kinds {"key":"pk_…","secret":"sk_…","kinds":[{"name":"New comment","push":true,"email":false}]}
  300. 200 {"kinds":[{"name":"New comment","push":true,"email":false}]}
  301. ```
  302. 2. **Send** a notification: `name` (1–60 chars, one line — the kind), `text` (1–2000 chars,
  303. Markdown by the worldapi convention; the inbox shows it as plain text with its line breaks),
  304. optional `icon` and `link` (absolute http(s) URLs ≤ 2000), optional `urgent` (bool).
  305. ```
  306. POST <ident>/api/notify {"key":"pk_…","secret":"sk_…","identity":"a68sz","name":"New comment",
  307. "text":"Bea commented …","icon":"https://…/i.png","link":"https://…/post/7","urgent":false}
  308. 200 {"id":"<notification id>"}
  309. 404 unknown identity for this app (the identity never logged in to this app, an unknown id;
  310. until the app has migrated, its old per-app ids work too)
  311. ```
  312. **An unregistered name is allowed**: it becomes an unregistered kind with the concept's
  313. default (daily mail, no push); push stays impossible for it until the app registers it.
  314. **Effective settings** (per connection = identity in app, per kind; stored in `settings`):
  315. the app's preset, replaced by the user's switch where the user set one; the user's **override
  316. for all**, when on, replaces both for every kind; push is always off for an unregistered kind.
  317. **Channels of a notification**, fixed when it arrives (stored on it, with `pushSent`/`mailSent`
  318. = false — delivery: section "Delivery"): normal → `push` = effective push, `mail` = `daily` if
  319. effective email else `none`; urgent → push if effective push AND a push device exists (none
  320. before piece 6), else `mail = now` if push or email is on for it, else `none`. Every
  321. notification lands in the inbox.
  322. **The user**: `/inbox` (nav "Inbox") = all notifications of all identities, newest first
  323. (max 200 shown): name, app · identity, text, icon (`referrerpolicy=no-referrer`), "Open"
  324. (the action link, new tab), time (UTC — hl:time has no zones), urgent badge, read/unread
  325. toggle. Below: every app connection (app, identity, since) → **per-app page**
  326. `/inbox/<connection id>`: app, identity, "registered in this app since" (the connection's
  327. `created`), **All notifications** (Override all / Push / Email switches) and every kind of the
  328. app with Push and Email switches (effective state; "app default: …" under the name; an
  329. unregistered kind shows "—" for push; locked while the override is on). Each flip is saved at
  330. once. Faces: `inboxMark`, `inboxSwitch`, `inboxOverride` (session-checked, #31).
  331. **Try it** (dev): the test app shows the identity id it got; with the app's key + secret:
  332. ```bash
  333. curl -s -X POST http://100.77.141.84:8351/api/notify -H 'content-type: application/json' \
  334. -d '{"key":"pk_…","secret":"sk_…","identity":"<id>","name":"Hello","text":"First notification"}'
  335. ```
  336. then open http://100.77.141.84:8351/inbox.
  337. ## Delivery (piece 5, ticket ident#7, mission 011)
  338. `lib/delivery.hl` (texts and the clock: `lib/delivery-helpers.hl`), constructed once in project.hl (`delivery = new
  339. Delivery()`, like the mailer). The zone rules are Hybriel's: hl:time `local(ms, zone)` (hybriel#5).
  340. * **The daily mail**: every `IDENT_DIGEST_EVERY` seconds (60) a round over every account: local time (the account's
  341. zone; none/unknown = UTC) at 17:00 or later and the stored `lastDate` is not today's LOCAL date → today's date is
  342. stored first (table `digests` `{account, lastDate, sentAt, count}`), then ONE mail "ident: N notifications
  343. (YYYY-MM-DD)" lists every pending one (mail = `daily`, not mailed yet, email STILL on for its kind now — the user's
  344. switches at delivery time), oldest first, at most 200 (more wait for the next day): `* <name> — <app> · <identity>`,
  345. the text (indented, line breaks kept), the action link; footer: the inbox link (`IDENT_PUBLIC_URL`) and where to switch
  346. mail off. They are marked `mailSent`/`mailedAt`. Nothing pending = no mail (the day still counts: what arrives after
  347. 17:00 waits for tomorrow). Never twice per local day, also across restarts (the date is stored); a server down at
  348. 17:00 sends at its first round after it, the same day. DST days need nothing of ours (`local()` is the wall clock).
  349. * **Urgent** (`POST /api/notify` with `urgent: true` → `lib/api.hl` → `deliverUrgent`): the channels were fixed at
  350. arrival (lib/notify.hl, the user's switches): `mail = now` → mailed at once ("<app>: <name>"), before the API answers.
  351. Push (ident#8): `pushHooks.push` in lib/delivery.hl + `hasPushDevice` in lib/notify.hl are the hooks.
  352. * A notification of a kind the user switched mail off for after it arrived stays pending, unmailed (inbox); switched on
  353. again, the next daily mail takes it.
  354. * Mail goes through `lib/mail.hl sendNotificationMail` (SMTP; with `IDENT_MAIL_SINK` one JSON line `{to, subject,
  355. text}` per mail to `<sink>.mail`). A delivery failure is only logged (`mail: FAILED`), as for codes.
  356. ## PWA (installable app, antcolony mission 046)
  357. ident installs as an app (Chrome "Install", Android/iOS home screen) through hl:web's own support, as calendar does:
  358. `project.hl` declares `appIcons`, `appThemeColor` (token `darker` rgb(15,20,25) = the header's colour, as in every app), `appBackgroundColor` (token `dark`),
  359. `appFavicon` (`/favicon.ico`), `appTouchIcon`, `offline = [ Start ]` and `appManifest = { start_url = '/start' }`. hl:web generates `/__hl/manifest.webmanifest`
  360. (linked in every head with apple-touch-icon + theme-color) and the service worker `/__hl/sw.js`. No JavaScript of ours.
  361. - **Icons** `icons/`: `icon.svg` (the source: a key in orange on rgb(25,30,35), glyph inside the maskable safe zone),
  362. `icon-192.png` / `icon-512.png` (manifest, `any` and `maskable`), `apple-touch-icon.png` (180), `favicon.ico`
  363. (16/32/48, from `favicon.svg` = the same key cropped tighter). Re-render after editing the SVG:
  364. `rsvg-convert -w 512 -h 512 icons/icon.svg -o icons/icon-512.png` (192, 180 likewise);
  365. favicon: `rsvg-convert -w N -h N icons/favicon.svg` for 16/32/48, then `magick fav-16.png fav-32.png fav-48.png icons/favicon.ico`.
  366. - **Offline, with NO personal data** (ident is the identity provider; phones get shared): the worker keeps only the
  367. shell's assets and `/start` (`components/start.hl`, a page without any data) — never `/`, whose copy would hold the
  368. signed-in address and identities (hl:web caches a kept page's document as the server rendered it for that user, and
  369. its state in IndexedDB). The installed app starts at `/start`: online the shell's probe sends it on to `/` at once;
  370. offline it shows the header, "Offline — ident needs the network to sign in and to save" and an "Open ident" button,
  371. and opens `/` by itself once the probe gets an answer again. Every other page offline (`/` included, e.g. a tab
  372. reload) is hl:web's data-free "Unavailable offline" page (503).
  373. - **How the shell knows it is offline** (`components/main.hl`): a zero-size `<net-probe>` runs a CSS animation
  374. (`components/styles.hl` `ident-net-probe`, starts 0.5 s after the page is up, repeats every 20 s); its `animationstart` /
  375. `animationiteration` handlers fetch `GET /api/online` (204, no-store — never cached by the worker). No answer →
  376. `noNetwork = true` → `<offline-note id="offline">` in the header; the next answer clears it (and on `/start` goes on to `/`). (A View has no "mounted"
  377. event; a probe fired before hydration would be lost, hence the delayed animation.)
  378. ## Test
  379. ```bash
  380. node tests/browser.mjs # THE GATE: 152 checks, ~40 s (ident#20 /code: 38 of them; PWA: 19). Own servers :8356 (ident) and :8357
  381. # (OTP TTL 3 s, reached as localhost); own storage .scratch/gate-store;
  382. # two Chromes on debug ports 8640-8659 (--disable-gpu), time zones
  383. # emulated (Pacific/Auckland, Asia/Tokyo). Covers avatar: save/edit,
  384. # live preview, list display, URL validation negatives (ticket #15)
  385. # other ports: IDENT_GATE_PORT=8732 IDENT_GATE_SHORT_PORT=8733 IDENT_GATE_CHROME=8734-8739
  386. # THE OTHER NINE GATES ON OTHER PORTS: temporary copies with the ports remapped, one by one:
  387. # node .scratch/w074/runall.mjs [apps selector migration iplimit notify hardening signoutall shortid invites]
  388. # (ports 8760-8767; outputs .scratch/w074/gate-<name>.txt; w072/runall.mjs = same on 8720-8727,
  389. # w048/runall.mjs on 8750-8757). Last run (074, hybriel 06617221): browser 152/0 with
  390. # IDENT_GATE_PORT=8760 IDENT_GATE_SHORT_PORT=8761 IDENT_GATE_CHROME=8762-8769, the nine all green
  391. # PWA (antcolony mission 046): head links, manifest (start_url /start, theme = token darker), icons
  392. # real PNGs, favicon ICO, /api/online 204, worker registered, installable; browser A SIGNED IN,
  393. # then OFFLINE (tab AND the worker's own CDP target — the tab's emulation alone leaves the
  394. # worker online): reload of / = "Unavailable offline" without the email; /start = shell +
  395. # offline note, no email; EVERY worker cache entry + hl:web's IndexedDB scanned: no email, no
  396. # identity; /apps unavailable; back online /start → / by itself.
  397. # Screenshots .scratch/gate-phone-pwa-{offline,online}.png
  398. node tests/apps.mjs # PIECE 2 GATE: 107 checks, ~15 s (ident#20 /signin/<rid>/code: 8). Own servers: ident :8370, ident :8371
  399. # (code TTL 1.5 s), test apps :8372/:8373; storage .scratch/apps-gate;
  400. # two Chromes on 8670-8679. Screenshots .scratch/apps-*.png
  401. node tests/selector.mjs # PIECE 3 GATE: 99 checks, ~10 s. Own servers: ident :8390, test apps
  402. # :8391/:8392, a node page on :8393 (an unregistered origin);
  403. # storage .scratch/selector-gate; Chromes on 8690-8699.
  404. # Screenshots .scratch/selector-*.png
  405. node tests/sessionwrites.mjs # SESSION-WRITES GATE (A28G): 20 checks, ~15 s, HTTP only (SESSIONWRITES_PORT, default 8700). Sign-in, pending address, embed sign-in and selector must really land in the session files (&-parameters need & at the call)
  406. node tests/shortid.mjs # SHORT ID GATE (ident#23): 19 checks, ~10 s, HTTP only. Own ident :8706 (storage
  407. # .scratch/shortid-gate): every identity's id, unique, same in two apps, notify, migrate-ids
  408. node tests/migration.mjs # MIGRATION GATE (mission 005 (old 009) + ident#23): 33 checks, ~10 s. Old-format fixture
  409. # (tests/oldstore-009.hl) → tools/migrate-009.hl twice on a copy →
  410. # ident :8395 + test app :8396 on the result: old session cookies
  411. # still signed in, stored per-app ids come out of the exchange again
  412. # (Chrome, login button → "welcome back"), pre-migration code still
  413. # works. Storage .scratch/migration-gate; Chrome on 8710-8719
  414. node tests/notify.mjs # PIECE 4 GATE (mission 007 (old 013)): 130 checks, ~20 s. Own ident :8410 +
  415. # a node "app site" :8413 (icon + link target); storage
  416. # .scratch/notify-gate (the stored state is read off COPIES with
  417. # tools/dump-store.hl); Chromes on 8740-8749.
  418. # Screenshots .scratch/notify-{inbox,inbox-read,appsettings,override}-*.png
  419. node tests/delivery.mjs # PIECE 5 GATE (mission 011): 49 checks, ~40 s. Own ident :8700 with a FAKE CLOCK
  420. # (IDENT_TEST_CLOCK file, rounds every 0.2 s), storage .scratch/delivery-gate, mail sink
  421. # (<sink>.mail); three Chromes on 8706-8719 (zones emulated). Vienna / New York / Tokyo / UTC
  422. # users get their digest at THEIR 17:00 (16:59: nothing), once; urgent at once; mail off →
  423. # nothing; after 17:00 → tomorrow; down at 17:00 → sent after the restart, never twice; DST
  424. # days Vienna 25 Oct / New York 1 Nov 2026; zone changed on `/` (Australia/Adelaide) moves it.
  425. # Screenshots .scratch/delivery-account-{390,1280}.png
  426. node tests/iplimit.mjs # PER-IP GATE (mission 006 (old 010)): 39 checks, ~15 s. Own servers: ident :8400
  427. # (HL_HOST=127.0.0.1, IP limit 3), :8401 (IP window 2 s, day limit 5);
  428. # storage .scratch/iplimit-gate; Chromes on 8720-8739, each with its
  429. # own X-Client-IP (CDP). Screenshots .scratch/iplimit-refused-*.png
  430. # the other gates run their servers with IDENT_IP_LIMIT/IDENT_IP_DAY_LIMIT=1000 (no header =
  431. # one shared bucket, and they request many codes)
  432. node tests/hardening.mjs # ticket #2: 17 checks. node tests/signoutall.mjs # ticket #19: 6 checks
  433. # tests/dev-smoke.mjs: DO NOT RUN any more — the dev server sends real mail now
  434. ps -eo pid,args | grep [h]l-browser-tier # must print nothing afterwards
  435. ```
  436. The gate covers, in real browsers: signed-out login page, first login → account + default
  437. identity + optional-names form, **Skip** (A) and **names filled** (B), reload keeps the
  438. session, edit, cancel, second and third (empty) identity, delete with a dismissed and an
  439. accepted confirm, deleting the default one, the last one cannot be deleted, time zone from
  440. the browser at first use / change / unknown zone refused / "Use this browser's" / not reset by
  441. a later login, sign out; OTP rules (lowercasing, wrong-code countdown, 5 tries, replaced code,
  442. rate limit, single use, expiry on the short-clock server); face negatives over
  443. `POST /__hl/emit` (no session, unknown/wrong-type/too-long/control-char fields, another
  444. account's identity, forged session argument); the removed routes are 404; palette; no console
  445. errors; 390px/1280px without horizontal overflow. Screenshots: `.scratch/gate-*.png` — look.
  446. **ident#20 (mission 008 (old 032)), the code page `/code`**: "Send me a code" lands on `/code`; GET `/code`
  447. without a pending code / without a cookie / signed in → 302 `/`; SSR of `/code` (plain GET with
  448. the cookie) = the code form + address; a real `Page.reload` keeps the code form (390/1280 px,
  449. `.scratch/gate-*-code-reloaded.png`); a second tab of the same browser shows it too; a wrong code
  450. + reload keeps it; one mail only; the code typed after the reloads signs in (welcome, URL `/`);
  451. signed out → `/code` lands on the email form; "Other address" → `/`, server forgot it, reload =
  452. email form; 5 wrong codes → reload lands on `/`; face `rememberPending` refuses an address without
  453. a waiting code, a number, a forged trailing session, accepts (normalised) an address with a waiting
  454. code — for that session only; `forgetPending`; `/signin/xyz/code` and a CR/LF rid → 302 `/`;
  455. `/signin/<rid>/code` with nothing pending → 302 `/signin/<rid>`; short-clock server: reload right
  456. after asking = code form, expired code → reload lands on `/`, expiry without a try → `/`.
  457. `tests/apps.mjs` adds (app login): "Send me a code" → `/signin/<rid>/code`, reload keeps the code
  458. form under the app banner (`.scratch/apps-code-for-app-reloaded-*.png`), the code signs in (URL back
  459. to `/signin/<rid>`) and the app flow completes; "Other address" → `/signin/<rid>` email form, a
  460. reload stays there, `/signin/<rid>/code` with nothing pending → `/signin/<rid>`.
  461. The other gates' login helpers wait for the `/code` page to hydrate before typing the code.
  462. (Ticket #37, mission 004 (old 007): its two checks of the removed mission-003 routes now check that
  463. the old shapes are refused by the piece-2 routes: `POST /api/exchange {"code"}` → 400
  464. `missing field: key`; `/login?app=…` → 400 error page, no redirect. 81 passed.)
  465. `tests/apps.mjs` covers, in real browsers: /apps signed out; register (bad origin refused,
  466. secret shown once, not after reload), list, edit; test app setup; login button signed in
  467. with one and with two identities (same identity + app → same id, other app → other id,
  468. other identity → other id, the answer is only `{identity}`); signed out → ident login →
  469. (first login: optional names, then) choice → back; login negatives (foreign origin, the
  470. other app's origin, `user@host` trick, `javascript:`, missing/unknown key, unknown request
  471. id); exchange negatives (wrong secret/unknown key 401, reused, other app's code, expired,
  472. unknown, invalid JSON, not an object, missing/unknown/wrong-type field, surrogate escape,
  473. GET); forged session argument on every new face (#31), strict app fields, another account
  474. cannot touch an app or use an identity; new secret (dismissed/accepted confirm, old secret
  475. 401, the test app with the old secret fails visibly), delete (its key → error page);
  476. no console errors; 390/1280 px without overflow.
  477. `tests/selector.mjs` covers, in real browsers: signed in to ident on ident's origin → the
  478. test app's page (own origin) shows the selector ("choose ident", ident's colours), open →
  479. the identities by name, the answer holds only `{id, name}` (no email, opaque ids) → choose →
  480. `ident-login` code → host exchange → logged in WITHOUT reload (a window marker survives),
  481. `logged-in` set, status shows the identity, no cookie from the selector → reload: the
  482. host renders `logged-in` → host logout resets (no reload) → other identity → other id; the
  483. button flow gives the same id as the selector; app B → other ids and other pick ids;
  484. host restyle (custom properties and `::part`) changes computed styles; negatives:
  485. unregistered origin (same site, so the cookie travels — the Origin check alone stops it; the
  486. page's own fetch is CORS-blocked, the preflight too), another app's key / an unknown key,
  487. signed out of ident (second browser, and after sign-out), 403 without CORS headers for
  488. bad/missing/`null`/prefix origins, no key, made-up cookie, preflight good/bad, strict choose
  489. body (unknown/missing/wrong-type field, invalid JSON, a forged `session` field), ident's own
  490. identity id or another app's pick refused, another account cannot choose alice's identity,
  491. code reuse / other app's code / spent code, 405s, forged face sessions on 8 faces (#31);
  492. console clean; 390/1280 px without overflow, closed and open.
  493. `tests/notify.mjs` covers: the app registers kinds (strict body, 401s, refused call writes
  494. nothing, re-register changes presets), sends normal/urgent, with/without icon + link, a
  495. registered and an unregistered name, to two identities in two apps (+ another account);
  496. send negatives (wrong secret, unknown key, another app's id, ident's own ids, unknown/missing/
  497. wrong-type fields, bad URLs, control characters, surrogate escape, GET); stored channels per
  498. notification (push/daily/now/none, not delivered); in Chrome: inbox (all identities, newest
  499. first, app · identity, text line breaks, icon loaded, link, urgent badge, time, unread count),
  500. mark read / unread (survives reload, stored); per-app page (since = connection created, all
  501. kinds, presets, unregistered = no push), flip switches → stored effective settings change,
  502. survive reload, a later notification follows them; override on (locked switches, all kinds
  503. follow, user switches kept) and off again; forged/no session on the 3 faces (#31), bob can't
  504. see/mark/switch alice's, alice can't switch bob's, unknown connection, signed out; bob's own
  505. Chrome sees only his; console clean; 390/1280 px without overflow.
  506. `tests/iplimit.mjs` covers: two IPs via `X-Client-IP` (the limit hits one, not the other);
  507. `X-Forwarded-For` / `CF-Connecting-IP` / `X-Real-IP` / `Forwarded` beside it change nothing;
  508. lower case / blanks; no header = one shared bucket (forwarded headers do not split it), empty
  509. header = none; IPv6 /64 buckets, IPv4-mapped; per-address limit across IPs; refused codes
  510. are not mailed; the old `requestCode` face is gone; 405 / strict body / invalid JSON; the
  511. short window expires, the day limit holds; `HL_HOST=127.0.0.1` not reachable on the LAN
  512. address, without it 0.0.0.0 as before; two real Chromes (one IP each): A's 4th code refused
  513. VISIBLY on the page (390/1280 px, no overflow), B signs in, reload keeps the session.
  514. ### Same output (code-order cleanups, mission 009)
  515. A cleanup must answer exactly as before. `tests/realdata-baseline.mjs` runs a CODE-ONLY copy of a tree (no `.env`) on a
  516. COPY of the live storage and saves every answer: 187 reads (every page signed in as the creator — session file for account
  517. `0mufd5afy0xm`, identity az5b2 — and signed out, the browser modules, every live app's `/login` and selector variants, the
  518. refused API calls) and 104 writes (identities, time zone, an app + secret, the login button + exchange, the selector,
  519. kinds + notifications, inbox switches, invites, migrate-ids, the OTP login of a new and of the creator's address into a mail
  520. sink, sign out (everywhere), app delete, then the stored state). `tests/realdata-compare.py` masks only what differs per run
  521. (times, random ids / codes / keys, source positions, module hashes) and compares two outputs; two runs of the same tree
  522. compare clean (291/291).
  523. ```bash
  524. # the live copy (from Byrodin; holds real addresses — keep it in .scratch, delete it afterwards)
  525. tar -C /CONTAINERS/projects/ident.worldapi.org/storage -cf - mpackdb | ssh loreana tar -C <repo>/.scratch/m009/realdata -xf -
  526. git archive <old commit> | tar -x -C .scratch/m009/old && cp -a bin .scratch/m009/old/ # the old tree, code only
  527. rsync -a --exclude=/.env --exclude='/.env.*' --exclude=/.scratch/ --exclude=/storage/ --exclude=/.sessions/ --exclude=/.git/ ./ .scratch/m009/new/
  528. node tests/realdata-baseline.mjs .scratch/m009/old 8750 .scratch/m009/rd-old # ~5 s each (port 8750 only)
  529. node tests/realdata-baseline.mjs .scratch/m009/new 8750 .scratch/m009/rd-new
  530. python3 tests/realdata-compare.py .scratch/m009/rd-old .scratch/m009/rd-new [-v] # exit 0 = same output
  531. python3 tests/letcount.py . # root .hl files, project.hl lines, lets
  532. ```
  533. All ten gates on ports 8750–8759 only (browser with `IDENT_GATE_PORT=8750 IDENT_GATE_SHORT_PORT=8751 IDENT_GATE_CHROME=8752-8759`,
  534. the nine others as port-remapped temporary copies, one by one): `TAG=<step> .scratch/m009/gates.sh` (outputs
  535. `.scratch/m009/gate-<name>-<step>.txt`); `.scratch/m009/step.sh <step>` = code copy + real-data run + compare + all gates.
  536. ## Deploy (Byrodin)
  537. Target: `/CONTAINERS/projects/ident.worldapi.org` on Byrodin, container `ident.worldapi.org`
  538. (`docker-compose.yml`: debian:12-slim, host network, `HL_HOST=127.0.0.1`, `IDENT_PORT=45002`,
  539. `IDENT_WATCH=0`, the folder mounted at `/home/ident`, `./bin/hybriel project.hl`), public
  540. https://ident.worldapi.org/ via nginx (TLS ends there; no baseUrl/tls in the app, like notes).
  541. * **First deploy: done by the architect** (folder, `.env` with SMTP on Byrodin, nginx vhost with
  542. WebSocket Upgrade headers and `proxy_set_header X-Client-IP $client_ip;`, cert, DNS).
  543. * **Later: `./deploy.sh`** on Loreana, in this folder: runs the seven gates (delivery since mission 011) (refuses on a
  544. failure; `--skip-tests` skips them LOUDLY), backs up `storage/`/`.sessions/`/`.env` (what exists) to
  545. Loreana's `/media/SLOW1TB2/deploy-backups/<app>/` (newest 5 kept; an empty/failed backup stops
  546. the deploy), then rsyncs the code to
  547. `[email protected]:/CONTAINERS/projects/ident.worldapi.org` (never `storage/`, `.sessions/`,
  548. `.env`, `.scratch/`, `server.*`, `testapp/`, logs — the preview is checked for them; no
  549. `--delete`), then hands the container over through its standby (`ident-standby` on port 45012, nginx's backup server; compose profile `standby`, `IDENT_STANDBY=1` switches the daily mail round off there) with `worldapi-conductor/standby-swap.sh` over `ssh -F /dev/null`, so a deploy has no gap; then
  550. waits for https://ident.worldapi.org/ to answer 200. Every step is printed.
  551. * `./deploy.sh --dry-run` = gates + `rsync -n` + the commands it would run (no restart, no URL
  552. check). `--target DIR|HOST:DIR` and `--url URL` point it elsewhere (tested only against a
  553. local directory: see STATUS "mission 006 (old 010)").
  554. * Session cookie `identsid`: `HttpOnly; SameSite=Lax`, no `Secure` (hl:web sets it — checked 2026-09-26: `identsid=…; Path=/; HttpOnly; SameSite=Lax; Max-Age=1209600`; it works
  555. on https — checked behind a local TLS proxy). The selector's CORS is exact-origin: register
  556. apps with their https origin (`https://tickets.worldapi.org`); the `http://` twin is refused.
  557. ## Data
  558. `storage/mpackdb/{accounts,identities,otp,sends,ipsends,apps,connections,requests,grants,kinds,settings,notifications,digests}.*`
  559. (hl:mpackdb, pk `@id` UUID; no admin UI/API). Tables and fields: the headers of `lib/accounts.hl`,
  560. `lib/identities.hl`, `lib/login.hl`, `lib/apps.hl`, `lib/invites.hl`, `lib/notify.hl` (piece 4: `kinds`, `settings`, `notifications` — new tables, created
  561. empty at the first start; no migration), `lib/delivery.hl` (piece 5: `digests`, new, empty at the first start). **Opening a table rewrites its files (hybriel #40): only ever open a COPY.**
  562. Everything as JSON (on a copy; the output holds apps' secret HASHES — keep it in .scratch):
  563. ```bash
  564. rm -rf /tmp/identcopy && cp -a storage/mpackdb /tmp/identcopy
  565. IDENT_STORAGE=/tmp/identcopy ./bin/hybriel tools/dump-store.hl | python3 -m json.tool | less
  566. ```
  567. Quick look without opening: `strings storage/mpackdb/accounts.mpack`. Dev mail:
  568. `storage/mail-sink.txt`. Mission-003 data: `.scratch/storage-backup-20260924-060627/`.
  569. ### Migration 009 (`*id` → UUID, done 2026-09-24)
  570. The old tables `storage/ident-<table>.*` (pk `*id`, public ids = id + 1) stay in `storage/`
  571. as a backup; nothing reads them. `tools/migrate-009.hl` (one-off, idempotent: rows carry
  572. `oldId` = the old public id; a second run writes nothing) copied every row of every table,
  573. rewrote the references to the new UUIDs, kept `apiKey`, `secretHash`, `appIdentity`, `rid`,
  574. grant hashes byte-identical, and rewrote the session files' `"user":{"id":<n>}` to the
  575. account's UUID (the creator stayed signed in). Run it only on a COPY of the old tables with
  576. the server stopped (header of the tool). A connection of an identity deleted before the
  577. migration keeps its per-app id with `identity = 'gone:<old id>'`.
  578. Selector pick ids (sha256(secret hash : identity id)) changed once with the identity ids —
  579. harmless, the selector re-fetches them on every open.
  580. ## Files
  581. Code order (antcolony docs/code-order.md, ident mission 009): `project.hl` is the MAP (an index comment, config, routes,
  582. wiring) and the only `.hl` file in the root; ONE `lib/` file per topic holds its central logic and every write to its
  583. tables, its noise (checks, formatting) is in `lib/<topic>-helpers.hl`, shared small helpers in `lib/util.hl`; the function
  584. routes (`lib/api.hl`) and the faces (`components/`) are thin wrappers. `let` only where a variable is reassigned (or
  585. Hybriel needs it: loop bodies, a name that is also a member of the file, a name declared twice in one function —
  586. `python3 tests/letcount.py .`). Imports go one way: util ← identities-helpers ← identities ← accounts ← login-helpers ←
  587. login; util ← apps-helpers ← invites-helpers ← invites ← apps ← selector / notify ← delivery-helpers ← delivery (also
  588. ← accounts, mail) ← api-helpers ← api ← project.hl.
  589. | File | |
  590. |---|---|
  591. | `CONCEPT.md` | the creator's concept — do not edit |
  592. | `project.hl` | THE MAP: feature → file index, PWA settings (`appIcons`, `offline = [ Start ]`, start_url `/start`, README "PWA"), routes (`/`, `/signin/:rid`, `/apps`, `/inbox`, `/inbox/:cid`, `/start`, the function routes of `lib/api.hl`, `/code` + `/signin/:rid/code` → `codePage` with the server by reference, `/selector.js`, `/avatar.js`, `/favicon.ico` + `/icons/*`), the mailer instance, cookie name, the listener (`HL_HOST`), the push audience, `sessionHooks.dropUser` |
  593. | `lib/login.hl` | the login: tables otp / sends / ipsends, `startLogin` (limits per address and per client IP), `checkCode` (the first right code creates the account), `signInWithCode` (face verifyCode), the pending sign-in `codeWaiting` / `recordPending` / `pendingOf` / `dropPending` (ident#20) |
  594. | `lib/login-helpers.hl` | `newOtp`, `otpHash` (codes stored as sha256 only), `ipBucket` (the per-IP limit's bucket) |
  595. | `lib/accounts.hl` | table accounts, `createAccount` (+ its default identity), sessions: `beginSession`, `accountOfSession` (own expiry, epoch), `signOutEverywhere` + `sessionHooks`, `dropUserSessions` (ticket #19), `setTimeZone` |
  596. | `lib/identities.hl` | table identities: short ids (`freshShortId`, `identityByShortId`, `backfillShortIds`, ident#23), `identityRecords` / `identityRows`, `ownIdentity`, create / update / delete (the last one stays), `addDefaultIdentity` |
  597. | `lib/identities-helpers.hl` | strict identity fields `checkFields`, the avatar `checkAvatarUrl` / `shownAvatar` (ticket #15), `labelOf`, the short id's alphabet `newShortId` / `normShortId` |
  598. | `lib/apps.hl` | tables apps / connections / requests / grants: apps (create, edit, new secret, delete → its connections + invites), `appOfSecret` (the app's key + secret), the login button (`openRequest`, `requestOf`, `grantLogin`, `issueCode`: the one-time code of both flows, `exchange`), an invite's login (`openInvite`, `grantInvite`, `grantRequest` for the face chooseIdentity), `disconnectConnection`, `connectionByAnyId`, `migrateIds` (ident#23) |
  599. | `lib/apps-helpers.hl` | the app form `checkAppInput`, `checkOrigin`, `checkReturn` (a return URL against the app's origins), `newKey` / `newSecret`, `originsOf`, `appRowOf` |
  600. | `lib/selector.hl` | the selector's pick ids (`pickOf`), the list (`selectorList`), the choice → code (`codeOfPick`); its two CORS endpoints are in `lib/api.hl` |
  601. | `lib/docs.hl` | the docs page's text (ident#45): reads `docs/IDENT.md` on every request and parses it with hl:markdown (`docsBlocks`) |
  602. | `components/docs.hl` | `/docs` (ident#45), public: the blocks of `docs/IDENT.md` in hl:markdown's View; main menu entry "Docs" (`components/main.hl`). Gate: `tests/docs.mjs` |
  603. | `docs/IDENT.md` | what ident is and how it works, for users and app builders: the ONLY copy of the text on `/docs` (edit the file, the page follows) |
  604. | `selector.js` | the browser half: `<ident-selector>` custom element (shadow DOM), served at `/selector.js` |
  605. | `lib/invites.hl` | table invites (ident#22): state, create (+ mail limit), list, get, revoke, `dropInvitesOf` (app deleted), `openableInvite`, `acceptInvite` |
  606. | `lib/invites-helpers.hl` | `checkText`, `isWhole`, `acceptedList` / `usedCount`, `problemOf` |
  607. | `lib/notify.hl` | piece 4: tables kinds / settings / notifications, `registerKinds`, effective settings (`effectiveOf`, `storeEffective`), `sendNotification`, the inbox (`inboxRows`, `markRead`) and the per-app page (`connectionRows`, `settingsPage`, `setSwitch`, `setOverride`) |
  608. | `lib/notify-helpers.hl` | checks of a kind name / text / URL, `stamp`, `newestFirst`, `byName`, `switchValue`, `onOff`, `unreadCount` |
  609. | `lib/mail.hl` | hl:smtp Mailer + `IDENT_MAIL_SINK` (codes; invitations → `<sink>.invites`; notification mails → `<sink>.mail`) |
  610. | `lib/delivery.hl` | piece 5 (ident#7): table digests, the daily round (`runDigests`, `digestFor`) on a clock, `deliverUrgent`, `pushHooks` |
  611. | `lib/delivery-helpers.hl` | the clock (`clockNow`, `IDENT_TEST_CLOCK`), the local date, the two mails' subject and text |
  612. | `lib/api.hl` | THE FUNCTION ROUTES, thin: `/login`, `/api/exchange` (+ profile fields), `/api/profile`, `/api/migrate-ids`, `/api/code`, `/api/selector/*` (CORS), `/api/kinds`, `/api/notify`, `/api/invites*`, `/invite/:token`, `codePage`, `/api/online` (204, the offline probe), `/api/*` 404 |
  613. | `lib/api-helpers.hl` | JSON replies, redirect, strict JSON body, the login button's error page, `inviteCaller` (key + secret + body), `baseOf`, `hexId`, the selector's CORS answers and `caller` check |
  614. | `lib/jsoncheck.hl` | JSON syntax pre-check (copied from tickets, hybriel #12) |
  615. | `lib/util.hl` | shared small helpers: `dir` (IDENT_STORAGE), `envNumber`, `countOf` / `first` / `merged` / `str`, `isId` / `isList` / `isObject`, `oldestFirst`, `hasControl`, `urlChars`, `normEmail` / `validEmail`, `checkTimeZone` |
  616. | `components/home.hl` | `/` and `/signin/:rid` (and, rendered by `codePage` with `step = 'code'` + `pending` (the address), `/code` + `/signin/:rid/code`): login, welcome, identities, time zone, the identity choice for an app |
  617. | `components/start.hl` | `/start`: the installed app's start page, data-free, the only page kept offline (antcolony mission 046) |
  618. | `components/apps.hl` | `/apps`: register / list / edit / new secret / delete apps |
  619. | `components/inbox.hl` | `/inbox`: the notifications of all identities, read/unread, the app connections |
  620. | `components/appsettings.hl` | `/inbox/:cid`: the per-app page (since, override, per-kind push/email switches) |
  621. | `components/main.hl` | shell (header, offline probe, live sign-out) |
  622. | `components/styles.hl` | all CSS (imports the tokens from `shared/tokens.hl`; accent `colorAccent = var(orange)` = #ce9178, danger `colorDanger` = `var(--red)` = #f44747) |
  623. | `shared/tokens.hl` | the WorldAPI tokens (hl:web `var()`), the hl:web copy all apps share (see "Design tokens"); README "Design tokens" |
  624. | `avatar.js` | the avatar upload's browser half (crop, scale, data URL), served at `/avatar.js` |
  625. | `icons/` | app icons: `icon.svg` source, 192/512 PNG (any + maskable), `apple-touch-icon.png`, `favicon.svg` → `favicon.ico` |
  626. | `testapp/` | the minimal app using the login button and the selector (:8354) |
  627. | `tests/browser.mjs`, `tests/apps.mjs`, `tests/selector.mjs` | gates of pieces 1, 2, 3; `dev-smoke.mjs` retired (real mail); `cdp.mjs`/`ports.mjs` copied from tickets |
  628. | `tests/migration.mjs`, `tests/oldstore-009.hl` | the migration gate and its old-format fixture (mission 005 (old 009); also the short-id migration, ident#23) |
  629. | `tests/shortid.mjs` | the short id gate (ident#23) |
  630. | `tests/iplimit.mjs` | the per-IP limit gate (mission 006 (old 010)) |
  631. | `tests/notify.mjs` | the piece-4 gate (mission 007 (old 013)) |
  632. | `tests/delivery.mjs` | the piece-5 gate (mission 011): fake clock, daily mail per zone, urgent, DST |
  633. | `tests/invites.mjs` | the invite gate (ident#22) |
  634. | `tests/signoutall.mjs` | ticket #19 gate: sign out everywhere pushes to open pages on other devices, session files deleted (:8702, Chrome debug 8703-8709) |
  635. | `tests/hardening.mjs` | ticket #2 gate: session own-expiry, sign out everywhere, sign out of an app (own servers :8700/:8701) |
  636. | `tests/realdata-baseline.mjs`, `tests/realdata-compare.py` | SAME OUTPUT on a live-data copy, two code trees compared (mission 009; README "Test" → "Same output") |
  637. | `tests/letcount.py` | the code-order counts: root `.hl` files, project.hl lines, every `let` by kind |
  638. | `tools/migrate-009.hl` | one-off migration `*id` → UUID + sessions (done; kept for the record) |
  639. | `tools/dump-store.hl` | every table as JSON — on a COPY only |
  640. | `docker-compose.yml`, `deploy.sh` | Byrodin container; the deploy from Loreana (section "Deploy") |
  641. ## Design tokens (shared, ticket antcolony#3 — antcolony mission 021)
  642. * **`shared/tokens.hl`** declares the WorldAPI palette + semantic tokens as hl:web css variables,
  643. hand-written: `static dark = var('rgb(25, 30, 35)')`, `static colorText = var(light)`, …
  644. (`import { var } from 'hl:web/css'`). It is a copy of the one source
  645. `loreana:/media/STORAGE/projects/WorldAPI/worldapi-tokens/tokens.hl` (vendored like `plugins/`, no generator):
  646. edit it THERE, then `cp /media/STORAGE/projects/WorldAPI/worldapi-tokens/tokens.hl shared/tokens.hl` in every
  647. app and restart it. Check: `cmp /media/STORAGE/projects/WorldAPI/worldapi-tokens/tokens.hl shared/tokens.hl`.
  648. (2026-09-26: the apps' copy = gitoria's; it differs from the source only in 3 COMMENT lines that
  649. still say webex — update the source's comments, then the check is byte-exact again.)
  650. * `components/styles.hl` IMPORTS the tokens it uses (`import { colorText, colorBorder, … } from '../shared/tokens.hl'`)
  651. and writes them as members: `color = colorText`, `border = '1px solid ' + colorBorder`. It sets only
  652. its accent: `colorAccent = var(orange)` (#ce9178). A token it uses must be in the import list,
  653. a new token must be added to tokens.hl (static) first.
  654. * hl:web names each token after its member (`colorTextMuted` → `--color-text-muted`), writes EVERY
  655. token of tokens.hl into the one `:root` (declaration order), then the app's `colorAccent` (a second
  656. `--color-accent`, later wins), and writes each use as `var(--…)`. Components/JS may still use
  657. `var(--color-…)` strings — the custom property names are the same.
  658. * hl:web does this itself since hybriel#39 (the webex LOCAL PATCH of antcolony mission 021 is gone, antcolony mission 036).
  659. * A change of tokens.hl or of components/styles.hl root members needs a RESTART: the dev watcher re-analyses
  660. but the served sheet keeps the old values (measured, antcolony mission 021).
  661. * Deploy: `shared/` is part of the app folder; `deploy.sh`'s rsync sends it (proved in antcolony mission 021:
  662. deploy.sh excludes + debian:12-slim container → byte-identical `/__hl/app.css`).
  663. ## Vendored Hybriel
  664. **hybriel day38b, SOURCE 1e554d75** (ident V38, 2026-11-03; Anton's set `/media/STORAGE/claude-scratch/anton/set-day38b`, checked against its SHA256SUMS). `bin/hybriel` sha256 `5ff2a46db81ef88fd7a72a3c32c3d67ca1faff7bfed60587341d2307b10b6e96` plus `hlc.o`, `libhlrt.a`, `hlrt/` from the set's `lib/`; `plugins/core` and `plugins/web` = `git archive 1e554d75 plugins/<p>`; the other plugin dirs keep their sources with the set's `.so` (mpackdb carries the store-open race fix); `plugins/smtp` (ident's own) untouched. No local patch. Previous vendor (ac1ed9da) follows below.
  665. **hybriel master ac1ed9da** (ident#28, F28C, 2026-10-26; Anton's build `/media/STORAGE/claude-scratch/anton/build-ac1ed9da/wt`). `bin/hybriel` sha256
  666. `74ab371547b19310b88bd5a15a0fae61cfaaf2cc1a87ca9f5794ecf19c2d6e50` plus `hlc.o`, `libhlrt.a`, `hlrt/` from its `native/zig-out`; `plugins/` = its
  667. core crypto data fetch fs http http1 mpackdb proc time web (replaced whole) + `plugins/smtp` (ident's own); `plugins/markdown` (hl:markdown, for `/docs`, ident#45) added from the same commit ac1ed9da (`git archive ac1ed9da plugins/markdown`). No local patch. Carries the fix for lost
  668. logins: `plugins/web/sessions.hl` reloads a session file another process wrote (`refresh`), and a replayed reconnect carries the server's derived state
  669. (`WebFramework.hl` helloTab, `client.hl` resumed). Changes the app had to follow: sessions are lazy (a page request or an emit that stores nothing sets no
  670. cookie; the cookie comes with the first face that stores something), hl:web adds `X-Frame-Options: SAMEORIGIN` to answers that name none (ident switches
  671. that default off with `pageHeaders` so the embed page is framed by `frame-ancestors` alone), `<meta>` prints `http-equiv` first, JSON objects keep insertion
  672. order. `project.hl` has `on Error`: a startup fault exits 1. Previous vendor (0f396652) follows below.
  673. **hybriel 0f396652** (ident mission 010, 2026-10-19; shared vendor `/media/STORAGE/claude-scratch/vendor-0f396652/`, built from
  674. `git archive 0f396652` with `HL_NO_PLUGINS=1 bash native/build.sh`). `bin/hybriel` sha256
  675. `60fa02f341ffa799b41a3dbd26d76057169f786e20dae0f98bb2ca3c46c39080` (static), `bin/` also `libhlrt.a`, `hlc.o`, `hlrt/`; `plugins/` =
  676. the vendor's 11 plugins + `plugins/smtp` (ident's own, not in the vendor). No local patch: the hybriel#34 XSS escape
  677. (`replaceAll('<','\u003c')` in the page seed) is in the vendor's `plugins/web/WebFramework.hl` itself. The server compiles the app at
  678. its start (hybriel#148): docker-compose has the cache volume `hybriel-cache` + tmpfs `/tmp`; cold ~16 s, warm <1 s;
  679. deploy.sh waits up to `DEPLOY_URL_WAIT` (120 s) for the URL. Gates (own ports 8700–8719 via a sed-remapped copy of tests/): apps 107/0,
  680. selector 99/0, migration 33/0, iplimit 39/0, notify 130/0, browser 152/0 — old and new. Same-output run
  681. (`tests/realdata-compare.py`): hl:web now registers its routes first and one more (`/__hl/up`), so the seed's route list is compared as a
  682. set without `/__hl/up`; everything else identical except the browser modules (new runtime/emitter). Previous vendor (06617221) was:
  683. **hybriel master 06617221** (antcolony mission 074, 2026-10-03; adds the plugin allocators 3a781359 + 413f60e4 (#126:
  684. every plugin allocates with malloc via plugin_api.zig), mpackdb 2cb7ae5e (frees per-operation buffers), http1 773de63e (request
  685. owns its parse), f0ac2d2d (event order; plugin ABI field — bin and .so must match); no lambda semantics change). `bin/hybriel`
  686. sha256 `21059cc741459ded8a004d44ed17c071aa296609be9fd0359202383210d77bdb`, built the same way from `git archive 06617221` into
  687. `~/scratch-074/src` (removed). Old vendor (190aa11d) in `.scratch/pre-074/`. Gates: browser 152/0 + the nine via
  688. `node .scratch/w074/runall.mjs` (8760–8767) all green. Memory: `LOADS=2500 node .scratch/w074/memtest.mjs <appdir>
  689. <mpackdb copy> <label> 0mufd5afy0xm` (port 8760, Chrome 8762–8769; `marks` = RSS every 500 loads): new 211 → 212 MB flat over
  690. 2500 loads, old 190aa11d 211 → 246 MB.
  691. Before: **hybriel master 190aa11d** (antcolony mission 072, 2026-10-02; adds fc838894 GC correctness (string index `t[k]` and plugin
  692. error messages could read freed memory), 038d84b3 (#126 returned closure scopes collected), #127 big SSR pages
  693. (d98926c6, 04df4428); no lambda/parameter semantics change since 8efba065, so no new `&` audit). `bin/hybriel` sha256
  694. `860f5e61878be75fe84a569eee03c95a25f2757940903b2ed0afee0871a23626`, built read-only from `git archive 190aa11d` into
  695. `~/scratch-072/src` (removed) with `/media/STORAGE/projects/hybriel/native/zig-toolchain/zig build -Doptimize=ReleaseFast
  696. -Dtarget=x86_64-linux-gnu.2.39` in `native/`. Old vendor (8efba065) in `.scratch/pre-072/`. Gates: browser 152/0 + the nine
  697. others via `node .scratch/w072/runall.mjs` (ports 8720–8727). Memory, live-data copy (mpackdb = `storage/mpackdb`, NOT
  698. `storage/` — the top-level `ident-*` files are pre-009 leftovers), account `0mufd5afy0xm` (4 identities), 200 Chrome loads:
  699. RSS 211 → 216 MB, 35 ms avg (old 8efba065: 282 → 305 MB, 41 ms) — `node .scratch/w072/memtest.mjs <appdir> <mpackdb copy>
  700. <label> <account id>` (port 8720, Chrome 8722–8729).
  701. Before: **hybriel master 8efba065** (antcolony mission 069, 2026-10-02; adds #126 = f685f240 (interpreter GC also collects by bytes),
  702. #48 = 4371b7aa (a lambda parameter COPIES its argument), #112 #117 #119 #120 (opt-in, not used)).
  703. `bin/hybriel` sha256 `ce4c7507f65a856f6088c7c120a0033c5d22647a47997d5ea7c3f923b2bdf4eb`, built read-only
  704. (`git -C /media/STORAGE/projects/hybriel archive master | tar -x -C ~/scratch-069-ident/src`, then
  705. `cd native && /media/STORAGE/projects/termuplex/.tools/zig/zig build -Dtarget=x86_64-linux-gnu.2.39 -Doptimize=ReleaseFast`).
  706. `plugins/` = master's core crypto data fetch fs http http1 mpackdb proc smtp time web — **no local patch**.
  707. Re-vendor = copy the binary + these plugins, run every gate. Previous vendor (73267707) in `.scratch/pre-069/`
  708. (bin, plugins, project.hl, README, STATUS); older ones in `.scratch/pre-048/` (837fe120), `.scratch/pre-036/` (webex).
  709. * **Lesson of the 069 re-vendor (hybriel #48)**: a lambda parameter is a COPY — the framework's `Session` instance too.
  710. Every lambda that writes the session it is handed takes `&session`: (since mission 009) `lib/accounts.hl` beginSession,
  711. accountOfSession; `lib/login.hl` recordPending, pendingOf, dropPending, signInWithCode; `lib/api.hl` selectorIdentities,
  712. selectorChoose (pass it on to accountOfSession); `lib/accounts.hl dropUserSessions` and `lib/api.hl codePage` take the server as `&srv`.
  713. Without `&`: sign-in never sticks (browser gate aborts at "code page"), the old-session upgrade is lost (hardening
  714. 16/1), /code shows a dropped address (browser 148/4). Audit tool: `python3 .scratch/w069/lambdas.py` (every lambda,
  715. flags params it writes) + `lambdas2.py` (params handed on / aliased). Memory (#126), live-data copy, 200 Chrome
  716. page loads: RSS boot 311 MB / after 354 MB (old binary 600 / 1287 MB) — `.scratch/w069/memtest.mjs <appdir> <mpackdb copy> <label> <account id>`.
  717. * **Lessons of the 048 re-vendor** (each broke a gate):
  718. - `server.page(match, session, host, headers)` since hybriel #105 — `project.hl codePage` called the old
  719. `page(m, req, s)`, which still compiles and renders an EMPTY card (req taken as the session).
  720. - A member whose initializer reads `session` is re-derived on the server after EVERY face that takes the session
  721. and synced to the page (hybriel 64527baa). Home's `pendingEmail` read `pendingOf(session)`: after the 5th wrong
  722. code it became null and the code form vanished (dead end). `codePage` now hands the address in as the param
  723. `pending`. Lists (identities, apps, inbox) are replaced whole by the faces' answers, never pushed to → no double
  724. rows (hybriel#121); gate checks "listed ONCE" in browser/apps/invites.
  725. - A fresh `*id` mpackdb table counts from 1 (hybriel #4, 5bb08628): `tests/oldstore-009.hl` writes explicit ids
  726. 0, 1, … so the fixture still looks like the real old store (public id = id + 1).
  727. * Framework pages use content-hashed URLs: `/__hl/hl-runtime.js?v=…`, `/__hl/web/client.js?v=…`,
  728. `/__hl/app.css?v=…` (`Cache-Control: public, max-age=31536000, immutable`; bare `/__hl/app.css` = `no-cache`).
  729. Check: `~/scratch-036/hashcheck.sh ident.worldapi.org IDENT /` (own server :8730, temp storage).
  730. * **A forged trailing session argument is refused by hl:web itself** (hybriel#16): the ack is
  731. `ok:false`, "… the `session` parameter is filled by the server, never by the peer" — the face never
  732. runs. The gates' forged-session checks (20: browser 4, apps 5, selector 8, notify 3) accept that
  733. refusal (`framework_refused`) or the app's own `{error}`. `realSession()` is gone; faces check `session == null`.
  734. * Kept on purpose: `lib/mail.hl` placeholder host 127.0.0.1 (a Mailer must exist for `deliver()`/handlers),
  735. `lib/jsoncheck.hl` (JSON.parse still aborts on bad input), `X-Client-IP` for the IP limit (behind nginx
  736. `req.remoteAddress` is nginx), hand sorts (no list `sort()`), `avatar.js` guard.
  737. ## History and worker briefs
  738. - `LOG.md` — append-only history, one dated line per step (moved here from the antcolony LOG on 2026-10-01).
  739. - `missions/NNN-*.md` — worker briefs for this app; `reports/NNN-*.md` — their reports (same name). Numbered per
  740. project since 2026-10-01 (antcolony#40); older text, code comments and commits use the old antcolony numbers →
  741. map: `/media/STORAGE/projects/antcolony-docs/docs/mission-map.md` (Byrodin: `/CONTAINERS/projects/antcolony/docs/mission-map.md`).
  742. The deploy hands over through `ident-standby` (port 45012), so a restart of ident does not cut sign-in for the other apps.

Branches

Latest commits

  • eee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmre
  • ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre
  • 24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre
  • 03ed26c7ident#34: access.hl: the remaining lead classes droppedmre
  • 1d066c42ident#34: access.hl drops its unstyled lead class (the shared lead rule would otherwise mute it)mre
  • 1e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre
  • 89ac6553ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
  • e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre
  • fb7111faident#34: access page: unstyled test-hook classes (idrow, never, who, whoname, appname, neverrevoke) dropped; the tests use element/name selectorsmre
  • 9f2ad803ident#34: notification switches: push/email by name=..., locked by aria-disabled, the switch look is the role=switch button (no switch/push/email/locked classes)mre
  • e0f0ddaaident#34: inbox: the Mark read/unread button is styled as the button of its note-foot, the icon is found as the row's img (no toggle/icon classes)mre
  • 16b49756ident#34: unused row classes (choice, usedrow, kind, shortid) droppedmre
  • f9d6fb38ident#34: apps and identity rows: the Edit/New secret/Delete buttons carry name=..., the API key is found by its element; unused row classes (app, identity, shortid) droppedmre
  • b323265aMerge branch 'f5-styles' into mainIdent
  • 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
  • f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
  • 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
  • 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
  • 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
  • f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre