gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit72e0f58772e0f587ident#26: identity page with "Used in" (app, since, last use, Notif. chip, empty state); lastLogin recorded at exchange; gates + lisbeth E2E; mission 016 reportmre72e0f587/project.hl

9.0 KB

  1. // project.hl — ident.worldapi.org: THE MAP. Config, routes and wiring; the logic lives in lib/. Concept: CONCEPT.md
  2. // (the creator's).
  3. //
  4. // WHERE THINGS ARE (one line per feature; README.md "Files" has the full list):
  5. // the login: email → code, limits per address / IP, the code page lib/login.hl (codes, IP buckets: lib/login-helpers.hl)
  6. // the account, its sessions, sign out everywhere, time zone lib/accounts.hl
  7. // identities, the short id, avatar lib/identities.hl (checks, label: lib/identities-helpers.hl)
  8. // apps, connections, the login button + exchange, an invite's login lib/apps.hl (checks, return URL: lib/apps-helpers.hl)
  9. // the identity selector (pick ids, the choice) lib/selector.hl (browser half: selector.js)
  10. // invites (ident#22) lib/invites.hl (checks: lib/invites-helpers.hl)
  11. // notifications: kinds, sending, inbox, per-app switches lib/notify.hl (checks, orders: lib/notify-helpers.hl)
  12. // mail (codes, invitations; IDENT_MAIL_SINK) lib/mail.hl
  13. // delivery: the daily mail at 17:00 in the user's zone, urgent at once lib/delivery.hl (texts, clock: lib/delivery-helpers.hl)
  14. // the function routes (/login, /api/*, /invite/:token, /code) lib/api.hl (plumbing: lib/api-helpers.hl, lib/jsoncheck.hl)
  15. // shared small helpers (storage dir, env, lists, text checks) lib/util.hl
  16. // an identity's page, "Used in" (ident#26) lib/usedin.hl (texts: lib/usedin-helpers.hl; page: components/identity.hl)
  17. // pages: shell, sign-in + identities, start, apps, inbox, per-app components/*.hl; CSS components/styles.hl
  18. //
  19. // THE FLOWS (README "How apps use ident", "How apps send notifications", "Invites"):
  20. // GET /login?key=<api key>&return=<url> → error page, or → /signin/<rid> (sign in, choose the identity,
  21. // → <return url>?ident_code=<one-time code>)
  22. // POST /api/exchange { key, secret, code } → { identity } (the identity's short id only)
  23. // GET /selector.js, GET /api/selector/identities?key=, POST /api/selector/choose?key= {identity} → { code }
  24. // POST /api/code { email } → { email } | 400/429 { error } (a function route: the per-IP limit needs the request)
  25. // GET /code, /signin/<rid>/code the code form for this session's pending address, or → / resp. /signin/<rid>
  26. // Deploy (Byrodin): HL_HOST=127.0.0.1 binds loopback only (hl:web reads HL_HOST, hybriel#24),
  27. // IDENT_PORT the port.
  28. import WebFramework from 'hl:web'
  29. import { env } from 'hl:proc'
  30. import Styles from './components/styles.hl'
  31. import { dark, darker } from './shared/tokens.hl'
  32. import { appLogin, apiExchange, apiMigrateIds, apiCode, apiSelectorIdentities, apiSelectorChoose, apiInvites, apiInvitesList, apiInvitesGet, apiInvitesRevoke, inviteLink, apiKinds, apiNotify, apiOnline, notFoundApi, codePage } from './lib/api.hl'
  33. import Mail from './lib/mail.hl'
  34. import Delivery from './lib/delivery.hl'
  35. import { sessionHooks, dropUserSessions } from './lib/accounts.hl'
  36. import { shortIdsBackfilled } from './lib/identities.hl'
  37. // ident#23: statics run on first use — touching it here gives every older identity its short id at boot
  38. console.log('ident: ' + shortIdsBackfilled + ' identities got their short id')
  39. import Home from './components/home.hl'
  40. import Start from './components/start.hl'
  41. import Apps from './components/apps.hl'
  42. import Inbox from './components/inbox.hl'
  43. import Identity from './components/identity.hl'
  44. import AppSettings from './components/appsettings.hl'
  45. static siteName = "ident"
  46. appTitle = siteName
  47. styles = Styles
  48. // ---- THE INSTALLABLE APP (mission 046, as calendar#3): hl:web generates the web app manifest
  49. // (/__hl/manifest.webmanifest, linked in every head with the apple-touch-icon and theme-color)
  50. // from these, and the service worker (/__hl/sw.js) from `offline`. No JavaScript of ours.
  51. // Icons: icons/ (icon.svg is the source, README "PWA"). Theme colour = the header's colour (token
  52. // `darker`), background `dark` — the same in every app (mission 046); the icon carries the accent.
  53. appThemeColor = darker.value
  54. appBackgroundColor = dark.value
  55. appFavicon = '/favicon.ico'
  56. appTouchIcon = '/icons/apple-touch-icon.png'
  57. appIcons = [
  58. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  59. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  60. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  61. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  62. ]
  63. // OFFLINE, WITHOUT PERSONAL DATA: the worker keeps only `/start` (components/start.hl, a page
  64. // with no data — never `/`, whose copy would hold the signed-in address and identities) and the
  65. // shell's assets. The installed app starts at `/start` (appManifest); online the shell's probe
  66. // (main.hl) sends it on to `/`, offline the header says it is offline. Every other page offline
  67. // is the worker's "Unavailable offline" (README "PWA").
  68. offline = [ Start ]
  69. appManifest = { start_url = '/start' }
  70. // ---- THE ROUTES: files, the function routes (lib/api.hl), the pages (components/) ----------------
  71. routes = [
  72. { pattern = "/favicon.ico" file = "./icons/favicon.ico" headers = { 'Cache-Control' = 'no-cache' } }
  73. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }
  74. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }
  75. { pattern = "/icons/apple-touch-icon.png" file = "./icons/apple-touch-icon.png" headers = { 'Cache-Control' = 'no-cache' } }
  76. { pattern = "/icons/icon.svg" file = "./icons/icon.svg" headers = { 'Cache-Control' = 'no-cache' } }
  77. { pattern = "/login" function = appLogin }
  78. { pattern = "/api/exchange" function = apiExchange }
  79. { pattern = "/api/migrate-ids" function = apiMigrateIds }
  80. { pattern = "/api/code" function = apiCode }
  81. { pattern = "/api/selector/identities" function = apiSelectorIdentities }
  82. { pattern = "/api/selector/choose" function = apiSelectorChoose }
  83. { pattern = "/api/invites" function = apiInvites }
  84. { pattern = "/api/invites/list" function = apiInvitesList }
  85. { pattern = "/api/invites/get" function = apiInvitesGet }
  86. { pattern = "/api/invites/revoke" function = apiInvitesRevoke }
  87. { pattern = "/invite/:token" function = inviteLink }
  88. { pattern = "/api/kinds" function = apiKinds }
  89. { pattern = "/api/notify" function = apiNotify }
  90. { pattern = "/selector.js" file = "./selector.js" headers = { 'Cache-Control' = 'no-cache' } }
  91. { pattern = "/avatar.js" file = "./avatar.js" headers = { 'Cache-Control' = 'no-cache' } }
  92. // the offline probe of the shell (components/main.hl): 204
  93. { pattern = "/api/online" function = apiOnline }
  94. { pattern = "/api/*" function = notFoundApi }
  95. // THE CODE PAGE (ident#20): renders Home through the framework's page render — it needs the server, BY REFERENCE
  96. { pattern = "/code" function = (route, req) => { return codePage(route, req, &server, Home) } }
  97. { pattern = "/signin/:rid/code" function = (route, req) => { return codePage(route, req, &server, Home) } }
  98. { pattern = "/" component = Home }
  99. { pattern = "/start" component = Start }
  100. { pattern = "/signin/:rid" component = Home }
  101. { pattern = "/apps" component = Apps }
  102. { pattern = "/identity/:iid" component = Identity }
  103. { pattern = "/inbox" component = Inbox }
  104. { pattern = "/inbox/:cid" component = AppSettings }
  105. ]
  106. // the mailer's result handlers live on an INSTANCE of lib/mail.hl
  107. mail = new Mail()
  108. // THE DAILY MAIL's clock (one round a minute) lives on an INSTANCE of lib/delivery.hl
  109. delivery = new Delivery()
  110. sessionDir = env('IDENT_SESSIONS') != null ? env('IDENT_SESSIONS') : null
  111. port = env('IDENT_PORT') != null ? toNumber(env('IDENT_PORT')) : 8351
  112. // THE LISTENER's interface: hl:web reads HL_HOST (or HOST) itself (hybriel#24): 127.0.0.1 on
  113. // Byrodin behind nginx; unset = 0.0.0.0 (dev on Loreana).
  114. // IDENT_WATCH=0 turns the dev watcher off (the container: a deploy is an rsync + restart,
  115. // half-copied .hl files must not be re-analysed); unset = on, as before.
  116. watching = env('IDENT_WATCH') != '0'
  117. // WHO A PUSHED EVENT IS FOR: "signed out everywhere" reaches every open connection whose
  118. // session is the account's (checked before dropUserSessions clears the sessions).
  119. audience = {
  120. signedOutAll = (accountId, session) => { return session != null && session.user != null && session.user.id == accountId }
  121. }
  122. // ident's OWN COOKIE NAME. Cookies are per host, not per port: with the default `hlsid` an app
  123. // on the same host (tickets on :8350) and ident would overwrite each other's session cookie
  124. // → hl:web's `sessionCookie` setting (hybriel#10/#17).
  125. sessionCookie = 'identsid'
  126. server = new WebFramework(routes = routes, styles = styles, audience = audience, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie)
  127. // SIGN OUT EVERYWHERE deletes every session of the account (ticket #19, lib/accounts.hl dropUserSessions): the
  128. // session store is this server's
  129. sessionHooks.dropUser = (userId) => { return dropUserSessions(&server, userId) }

Branches

Latest commits

  • 72e0f587ident#26: identity page with "Used in" (app, since, last use, Notif. chip, empty state); lastLogin recorded at exchange; gates + lisbeth E2E; mission 016 reportmre
  • 94576fbcident#26 WIP: identity page /identity/:iid with "Used in" (app, since, last use, Notif. chip), lastLogin recorded at exchange, "Used in…" link on the identities list; apps gate 4b, e2e-usedin.mjsmre
  • 349cb502tests/invites: wait for hydration on the code page before entering the code (native GET submit raced the welcome form); mission 015 reportmre
  • d1bf4720tests: no hard-coded ports — every gate's ports and fixture origins come from <GATE>_PORT / _CHROME env (defaults unchanged; Bob/fixture origins follow, selector cookie name too)mre
  • 6280c92fre-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 147744bftests/migration: the fixture app origin follows MIGRATION_GATE_TESTAPP_PORT (oldstore-009 OLD_TESTAPP)mre
  • 48cd36bctests/migration: ports from env (MIGRATION_GATE_PORT, MIGRATION_GATE_TESTAPP_PORT); 8395/8396 were taken by a foreign servermre
  • 3d9b2fd8docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 19b7e3c3deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • c8a596f4re-vendor Hybriel 66c3db71 (web batch 4); e2e: main menu marked after in-place sign-in is a normal check; report 014mre
  • 8f3dc1ectests: delivery allow-list for the stopped server's network errors uses the gate port, not 8700mre
  • 9cc8eddftests: notify and iplimit gate Chrome ports from env (NOTIFY_GATE_CHROME, IPLIMIT_GATE_CHROME_A/B)mre
  • d6da2d02tests: delivery and migration gate ports from env (DELIVERY_GATE_PORT, DELIVERY_GATE_CHROME, MIGRATION_GATE_CHROME) — hard-coded 8700-8719 collided with a worker during deploymre
  • 7276a008ident mission 013: re-vendor Hybriel master f9614007 (#200, #202 mpackdb copy fix); gates and e2e rerunmre
  • e13e30c3ident mission 013: report, mission, repro, LOGmre
  • eff734f3ident mission 013: in-place sign-out also closes the code step (no leftover code form); checksmre
  • b7a61546ident mission 013: e2e — in-place main-menu mark kept as a known gapmre
  • 59b43d81ident mission 013: sign out everywhere keeps this browser's own (signed-out) session so the page goes on in placemre
  • 716e14ffident mission 013: browser gate — Bob signs out everywhere (no second code request)mre
  • 5885f1c9ident mission 013 step 2: stopgap reload removed (in-place sign-in/out reach the shell via emit, notices back, route-marked main menu), gates updatedmre