gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitdf2e4fa0df2e4fa0calendar#12: test push rate limit (1 per 30 s per device), owner-only gate checksmredf2e4fa0/project.hl

4.3 KB

  1. // project.hl — calendar.worldapi.org: THE MAP. Config, routes and WHO HEARS WHAT. Hybriel on hl:web.
  2. // The month view at `/` (ticket #1); login with ident and the user's private events (ticket #2).
  3. //
  4. // WHERE WHAT IS (README "Files"):
  5. // events, every write to events.db, the faces' answers lib/events.hl (+ lib/events-helpers.hl)
  6. // the default reminders (settings.db) lib/settings.hl
  7. // users, the ident exchange, both logins' user step lib/users.hl
  8. // /login/callback lib/api.hl (+ lib/api-helpers.hl)
  9. // env, table folder, lists, id checks lib/util.hl
  10. // the page shell, login/logout faces components/main.hl
  11. // `/` and the event faces, /login/failed, all CSS components/calendar.hl, loginfailed.hl, styles.hl
  12. // Web Push: subscriptions + the clock that sends lib/push.hl (faces calPushSave / calPushOff in calendar.hl)
  13. // the month view (UI, dates, names, reminders, clock) components/month-view/
  14. import WebFramework from 'hl:web'
  15. import { env } from 'hl:proc'
  16. import Styles from './components/styles.hl'
  17. import { dark, darker } from './shared/tokens.hl'
  18. import { tagOf } from './lib/users.hl'
  19. import { loginCallback } from './lib/api.hl'
  20. import Calendar from './components/calendar.hl'
  21. import LoginFailed from './components/loginfailed.hl'
  22. import Push from './lib/push.hl'
  23. import { envOr } from './lib/util.hl'
  24. static siteName = "Calendar"
  25. appTitle = siteName
  26. appThemeColor = darker.value
  27. appBackgroundColor = dark.value
  28. appIcons = [
  29. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'any' }
  30. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'any' }
  31. { src = '/icons/icon-192.png' sizes = '192x192' purpose = 'maskable' }
  32. { src = '/icons/icon-512.png' sizes = '512x512' purpose = 'maskable' }
  33. ]
  34. offline = [ Calendar ]
  35. styles = Styles
  36. routes = [
  37. { pattern = "/favicon.ico" direct = "" }
  38. // the login button's return writes the session: the request and the store go BY REFERENCE (lib/api.hl)
  39. { pattern = "/login/callback" function = (route, req) => { return loginCallback(route, &req, &server.sessions) } }
  40. { pattern = "/login/failed" component = LoginFailed }
  41. { pattern = "/login.js" file = "./login.js" headers = { 'Cache-Control' = 'no-cache' } }
  42. // the installable app (ticket #3): the icons (manifest and service worker are hl:web's own, from appIcons / offline)
  43. { pattern = "/icons/icon-192.png" file = "./icons/icon-192.png" headers = { 'Cache-Control' = 'no-cache' } }
  44. { pattern = "/icons/icon-512.png" file = "./icons/icon-512.png" headers = { 'Cache-Control' = 'no-cache' } }
  45. { pattern = "/" component = Calendar }
  46. ]
  47. // WHO GETS THE PUSH: the login state reaches the tabs of one session.
  48. // `calendarSignedIn` / `calendarSignedOut` go to the tabs of ONE session: the one whose login carries that random tag.
  49. audience = {
  50. calendarSignedIn = (tag, session) => { return tag != null && tagOf(session) == tag }
  51. calendarSignedOut = (tag, session) => { return tag != null && tagOf(session) == tag }
  52. }
  53. sessionDir = env('CALENDAR_SESSIONS') != null ? env('CALENDAR_SESSIONS') : null
  54. port = env('CALENDAR_PORT') != null ? toNumber(env('CALENDAR_PORT')) : 8380
  55. // HL_HOST = the interface hl:web binds: 127.0.0.1 on Byrodin behind nginx; unset = 0.0.0.0 (dev on Loreana).
  56. // CALENDAR_WATCH=0 = no dev watcher.
  57. watching = env('CALENDAR_WATCH') != '0'
  58. // The session idles out after the 14 days of sessionMaxAge, not after 15 minutes.
  59. sessionCookie = 'calendarsid'
  60. sessionIdle = 1209600
  61. // WEB PUSH (calendar#9): the VAPID key pair and contact, all three or none (tools/vapid-keys.hl makes the pair; README "Web Push").
  62. // Unset = no push: the page still shows reminders while it is open.
  63. pushPublic = envOr('CALENDAR_PUSH_PUBLIC', '')
  64. pushPrivate = envOr('CALENDAR_PUSH_PRIVATE', '')
  65. pushContact = envOr('CALENDAR_PUSH_SUBJECT', '')
  66. pushOn = pushPublic != '' && pushPrivate != '' && pushContact != ''
  67. // the sender's clock lives on an INSTANCE of lib/push.hl
  68. push = new Push()
  69. server = new WebFramework(routes = routes, styles = styles, minify = true, port = port, watchMode = watching, sessionCookie = sessionCookie, pushKey = pushOn ? pushPublic : null, pushPrivateKey = pushOn ? pushPrivate : null, pushSubject = pushOn ? pushContact : null)
  70. on Error(e) { console.log('error absorbed: ' + e.message) }

Branches

Latest commits

  • df2e4fa0calendar#12: test push rate limit (1 per 30 s per device), owner-only gate checksmre
  • acb957cfcalendar#12: Send a test notification on a subscribed device (one push in ~10 s, owner's own device), push gate part 4mre
  • 0b222eb8tests: e2e-theme CDP port default from E2E_THEME_CDP_PORT (8756 unchanged)mre
  • 8b8a5abare-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
  • a69b27f9docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 1a97edfdcalendar mission 010: reminder rows at 390 px (the 7-column month grid no longer catches the reminder lists), gate checks, settings-shots, reportmre
  • 61b21404calendar mission 009: reminder times on hl:time in the browser (lib/push-plan.hl and the Intl code removed), DST gate tests/dst.mjs, E2E script, reportmre
  • 875353c1calendar mission 009: re-vendor Hybriel master 022a3ac1 (int 6 6b396322 hl:time browser side, int 7 65e8ec21; bin sha256 6e0f77d7, plugins whole)mre
  • ce16a4efdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • f490bc8cdeploy: Web Push gate tests/push.mjs (PUSH_GATE_PORT)mre
  • 3af29fc8calendar mission 008 (A8): report, README, LOG, push-shots.mjsmre
  • f91f3663calendar mission 008 (A8): push only asked of the browser when the app has the VAPID settings (pushAvailable); real-FCM E2E scripts (push-real-app.mjs, push-real.mjs)mre
  • bf571badcalendar mission 008 (A8): Turn off on this device (unsubscribes the browser, server drops the device, choice kept), subscribe/refresh when the app is shown again; push gate part 3mre
  • 50985708calendar mission 008 (A7): Web Push report, README, mission, LOGmre
  • ee318774calendar mission 008 (A7): push-real.mjs, push sent log linemre
  • ebda0fd1calendar mission 008 (A7): server-side reminder plan on hl:time (push-plan.hl; hl:time fromLocal in a browser static is refused: repro .scratch/hltime-client), push gate 9/9mre
  • d063dad3calendar mission 008 (A7): Web Push (WIP): lib/push.hl subscriptions + sender clock, faces calPushSave/calPushOff, button subscribes, VAPID tool, tests/push.mjs; instantOf on hl:timemre
  • cf175c80calendar mission 008 (A7): re-vendor Hybriel master 0e3c9830 (bin 9d957fed, plugins whole: hl:crypto Web Push primitives, hl:web sendPush)mre
  • 9bf3c38bcalendar mission 008: re-vendor Hybriel f9833544 (gates old = new); Web Push stopped: hl:crypto half missing on mastermre
  • 186f969bcalendar mission 007: signed-in gate for the first-pointer race (fails on 3c5604f), README theme section, reportmre