gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit5bd14e125bd14e12mission 040: theme 76f99f6 gates + E2E green; 44 px fixes (skeleton row, type-word, genre-link/pill); README, reportmre5bd14e12/plugins/crypto/server.hl

4.5 KB

  1. \* hl:crypto — passwords first. Native realm wrapper (see server.js for the JS twin).
  2. The whole surface is eight calls, and six of them exist to serve the first two.
  3. What this plugin is FOR is that an application never stores a password: it
  4. stores the answer to "could this password have produced that", and the answer
  5. carries its own algorithm and cost so it stays readable when both change.
  6. hash(password, options) the stored value — a PHC string
  7. verify(password, stored) true / false, in constant time
  8. parsePhc(stored) what a stored value says about itself
  9. kdf() which algorithm THIS host hashes with
  10. sha256(data) content hashing (fast on purpose — not for passwords)
  11. randomBytes(n, encoding) n bytes from the kernel CSPRNG
  12. toBase64(data) a String's or a Bytes' bytes as base64 text
  13. fromBase64(text) base64 text back to a Bytes (null if it is not base64)
  14. The realm is SERVER (plugin.json). A password never crosses to the client, so
  15. importing this file is also a declaration about where the importing code runs. *\
  16. \* Hash a password for storage. Returns a self-describing PHC string:
  17. $argon2id$v=19$m=32768,t=2,p=1$<salt>$<hash>
  18. $scrypt$ln=15,r=8,p=1$<salt>$<hash>
  19. Every call salts freshly, so hashing the same password twice gives two
  20. different strings and both verify.
  21. `options` is optional: { cost = 15; kdf = "argon2id" }
  22. cost base-2 log of the working memory in KiB — 15 is 32 MiB, the default.
  23. CAPPED to 10..17 (1 MiB .. 128 MiB); the string records what was
  24. actually used, so asking for 999 and reading the result back is how
  25. you see the cap rather than being told about it.
  26. kdf force an algorithm instead of taking the host's best one. Normally
  27. unnecessary: `hash` picks argon2id when the system libcrypto has it
  28. (OpenSSL >= 3.2) and scrypt otherwise, and `verify` reads both. *\
  29. hash(password, options) {
  30. return __native("crypto.hash", password, options)
  31. }
  32. \* Check a password against a stored PHC string. The comparison is constant-time
  33. and the answer is a plain boolean: a wrong password, a truncated string, a
  34. flipped character and a string that is not PHC at all are all `false`. A
  35. stored string whose ALGORITHM this host cannot compute is a loud error
  36. instead, because answering `false` to that would read as "wrong password". *\
  37. verify(password, stored) {
  38. return __native("crypto.verify", password, stored)
  39. }
  40. \* Read a stored string without the password:
  41. { kdf = "argon2id"; version = 19; params = { m; t; p }; saltLen; hashLen }
  42. { kdf = "scrypt"; version = null; params = { ln; r; p }; saltLen; hashLen }
  43. `null` when the string is not a PHC string this plugin understands — which is
  44. also the cheapest way to spot a store that was never migrated. *\
  45. parsePhc(stored) {
  46. return __native("crypto.parse", stored)
  47. }
  48. \* Which algorithm `hash()` writes with on this host. Reporting only — nothing
  49. needs to branch on it, because every stored string names its own. *\
  50. kdf() {
  51. return __native("crypto.kdf")
  52. }
  53. \* SHA-256 of a string, as 64 lowercase hex characters. Content hashing: fast by
  54. design, and therefore exactly the wrong tool for a password. *\
  55. sha256(data) {
  56. return __native("crypto.sha256", data)
  57. }
  58. \* n random bytes from the kernel CSPRNG, rendered as "hex" (the default) or
  59. "base64". n is 1..1024. Suitable for session ids, one-time tokens and nonces. *\
  60. randomBytes(n, encoding) {
  61. return __native("crypto.random_bytes", n, encoding)
  62. }
  63. \* Base64 (the standard alphabet, padded) of a String's bytes — its UTF-8 — or
  64. of a Bytes, byte for byte:
  65. toBase64('user:pa55') \\ "dXNlcjpwYTU1"
  66. toBase64(req.bytes) \\ any bytes at all, NUL and 0xff included *\
  67. toBase64(
  68. data \\ a String or a Bytes
  69. ) {
  70. if (hlTypeName(data) == 'Bytes') {
  71. return __native("crypto.base64_encode_hex", data.hex())
  72. }
  73. return __native("crypto.base64_encode", data)
  74. }
  75. \* Base64 text back to its bytes, as a Bytes; `.toString()` of it is the text
  76. when the bytes are UTF-8. Padded and unpadded text both decode; anything
  77. that is not base64 in the standard alphabet is null, not an error — a
  78. malformed `Authorization: Basic` header is an answer, not a crash:
  79. let b = fromBase64(req.headers.authorization.slice(6))
  80. if (b != null) { let pair = b.toString() } \\ "user:pa55" *\
  81. fromBase64(String text) {
  82. let raw = __native("crypto.base64_decode", text)
  83. if (raw == null) {
  84. return null
  85. }
  86. return toBytes(raw)
  87. }

Branches

Latest commits

  • 5bd14e12mission 040: theme 76f99f6 gates + E2E green; 44 px fixes (skeleton row, type-word, genre-link/pill); README, reportmre
  • 77cfa45cmission 040: partial report (theme/modal/pagination re-copied, tilelist onPage, 44 px taps; gates new + E2E pending)mre
  • 4b14822fe2e-theme: menu marker by colourmre
  • 09780f4emission 040 WIP: theme, modal, pagination, tokens re-copied from layouts 76f99f6; tilelist uses onPage; tap sizes 44 px for tracker's own small buttons; tests/e2e-theme.mjsmre
  • fb80bb8chotfix: open the 5 show stores without compaction (compact = false) — compact-on-open left another handle on stale offsets, every read gave a bare Number (hybriel mpackdb refresh after a shrink); live down 2026-10-20 05:11mre
  • e00d3bf7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • a8c7f234tracker#36 (mission 039): tools/tmdb-check.hl survives a dropped connection (on Error, asked again, failed lines) and resumes with --from N; tests/tmdbcheck.mjs 6/6 against a fake TMDBmre
  • 9c230516mission brief w39mre
  • 3609121dmission 038 docs + report (quota stop): README/kinds.md for #43 #42 #36, STATUS, LOG; HEAD browser gate 374/8 in the in-app daily run block (hour-boundary suspected, rerun pending), other gates green; #36 real run needs TMDB_READ_TOKENmre
  • a5d06e79tracker#36 (mission 038): tools/tmdb-check.hl + lib/tmdbcheck.hl — every live migrated title's migrated title + year against its TMDB entry (one GET /movie|tv/<id>?append_to_response=alternative_titles, 260 ms apart, passing failures asked once more): ok / ambiguous (one of title, year disagrees) / clear (both, or 404); read-only; token only from TMDB_READ_TOKEN; --stored = a title-only preview from the TMDB names already stored (no request). Tested against a fake TMDB (.scratch/w38/t36): 7 titles, 3 ok, 2 ambiguous, 2 clear, data unchangedmre
  • 982554f3tracker#42 (mission 038): series pages — an unknown slug no longer scans every title (lib/shows.hl showBySlug: the slug map only; new titles are noted by refreshTitleCaches, which both title puts already reach): 10.7–15.7 s → 0.013 s on the real copy (the one-request-at-a-time server was blocked meanwhile); cast/crew rows take name + slug from a person-link cache (personLinkOf) instead of whole person records (SNL: 303 cast with 4,761 credits, ~49k allocations per render) — allocations per series page −5…−40 %; HTML of 20 pages identical to beforemre
  • 4586b6e3docker-compose: init: true (hybriel#156)mre
  • 085c2e5ftracker#43 (mission 038): TVmaze's type makes Variety / Talk Show / Game Show / Reality / News / Panel Show / Award Show / Sports titles Shows (TMDB calls Saturday Night Live UK Scripted) — the #43 part of parked w37-wip a79c8c1 only (no re-vendor, no cache volume): tvmazeType stored by the sync and the TVmaze status backfill (asks every series with a TVmaze id once), kindOfTitle/kindWithTvmaze, tools/tvmaze-types.hl, gate fixture Variety Gate Series; start waits 150 smre
  • 4fa303b5mission brief w38mre
  • 975f6843tracker#41 (mission 037b): no request tap — an old /movies|/series slug renders the keeper's page (slug map) with og:url naming the keeper's address, /shows/ 301; no moved slug in any page's HTML. Real copy 168/168 old addresses, 0 moved slugs in 54 pages, 300x + 1000x stress without a crash; gates on 06617221 380/0, 32/0, 53/0, 229/0, 26/0, theme 0mre
  • 6decff4ftracker#41 (mission 037): moved slugs no longer listed in every page's HTML — a request tap answers their 301 by a slug-map lookup (shows.hl movedTitlePath); catalog.hl buildIndex pushes genre lists in place (the quadratic copy hung the boot > 20 min on today's data); gate: no moved slug in 19 page kinds signed out/in, immediate 301 after a merge. Gates on hybriel 06617221 green (380/0, 32/0, 53/0, 229/0, 26/0, theme 0); real copy 84/84 301, 0 moved slugs in 54 pages. NOT deployable: the tap faults after ~38 answers on 06617221 (report 037).mre
  • 35f7a872mission brief 037mre
  • 5cbcddd7tracker mission 036: recheck of the 16 review tickets — 15 WORKS, #39 PARTLY; review packages + bugs in reports/036-review-recheck.md (no code change)mre
  • 9e18c2d0mission brief (w36)mre
  • 216fac57missions 028-035 + reports 033/034 (were untracked)mre