gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit727cd083727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre727cd083/lib/transport-helpers.hl

2.4 KB

  1. // lib/transport-helpers.hl — what lib/transport.hl looks up: the Basic password of a request, the plain-text answers,
  2. // the protocol version a client asks for, git's pkt-line. Statics only.
  3. import { Response } from 'hl:http1'
  4. import { run } from 'hl:proc'
  5. import { NL } from './util.hl'
  6. static isBase64 = (s) => {
  7. if (s.length == 0 || s.length > 600) { return false }
  8. let i = 0
  9. while (i < s.length) {
  10. let c = s.charCodeAt(i)
  11. if (!((c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c == 43 || c == 47 || c == 61)) { return false }
  12. i = i + 1
  13. }
  14. return true
  15. }
  16. // the password of a Basic `Authorization` header ('user:password' → 'password'); null without one.
  17. // Hybriel has no base64 decoder (hybriel ticket candidate), so `base64 -d` decodes it — the text goes in as an
  18. // argument, after a check that it only holds base64 characters.
  19. static passwordOf = (header) => {
  20. if (header == null || hlTypeName(header) != 'String') { return null }
  21. h = header.trim()
  22. if (h.length < 7 || h.slice(0, 6).toLowerCase() != 'basic ') { return null }
  23. b = h.slice(6).trim()
  24. if (!isBase64(b)) { return null }
  25. r = run(['sh', '-c', 'printf %s "$1" | base64 -d 2>/dev/null', 'sh', b], { timeout = 10 })
  26. if (r == null || r.exit != 0 || r.lines.length == 0) { return null }
  27. text = r.lines[0]
  28. colon = text.indexOf(':')
  29. return colon < 0 ? null : text.slice(colon + 1)
  30. }
  31. static plain = (status, text, extra) => {
  32. let headers = { 'Content-Type' = 'text/plain; charset=utf-8' 'Cache-Control' = 'no-store' 'X-Content-Type-Options' = 'nosniff' }
  33. if (extra != null) { for (k of extra.keys()) { headers[k] = extra[k] } }
  34. return new Response(text + NL, { status = status headers = headers })
  35. }
  36. // git speaks protocol v2 when the client says so: `Git-Protocol: version=2` (only that shape is passed on)
  37. static protocolEnv = (req) => {
  38. v = req.headers['git-protocol']
  39. if (v == null || hlTypeName(v) != 'String' || v.length > 40) { return {} }
  40. let ok = v.length > 0
  41. let i = 0
  42. while (i < v.length) {
  43. let c = v.charCodeAt(i)
  44. if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 122) || c == 61 || c == 58)) { ok = false }
  45. i = i + 1
  46. }
  47. return ok ? { GIT_PROTOCOL = v } : {}
  48. }
  49. // pkt-line: 4 hex digits of the length (itself included), then the text
  50. static pktLine = (text) => {
  51. let n = text.length + 4
  52. hex = '0123456789abcdef'
  53. let out = ''
  54. let i = 0
  55. while (i < 4) {
  56. let d = n % 16
  57. out = hex[d] + out
  58. n = (n - d) / 16
  59. i = i + 1
  60. }
  61. return out + text
  62. }

Branches

Latest commits

  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre
  • 76e0587aWIP gs 2mre
  • a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
  • 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre
  • a0727ca3ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
  • a06975f9gitoria: a gap between your name and Log out in the phone header (they touched); gate checks itmre
  • 32ba9d59gitoria: leave the host-only cookie experiment out of the browser gate (gitoria#24 is a separate mission)mre
  • 43ad2bcfgitoria header: the selector alone plus your name and Log out as before the theme missions; tests follow (WIP: host-only cookie experiment fails)mre
  • ac2c4e3fident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
  • b279f536theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre
  • 2b01515ctests/ticketskit: a failed start kills the tickets server (own process group); stop() kills the groupmre
  • 109cfc5ctests/ticketskit: keep the rotated session cookie of the tickets login (tickets ST2 session rotation)mre
  • 7eb6be27sessions last 99 years (creator 2026-10-23: logins never expire; only sign out ends them)mre