Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 2.3 KB

README.md

File metadata and controls

39 lines (27 loc) · 2.3 KB

preferences

The small choices people make in an app — the theme, the language, a menu pinned open — and whose they are.

A choice is… Declared with Kept in Signing out
the person's (theme, language, a welcome already seen) preferences.OfThePerson("theme") the server, with a copy in the browser erases the browser's copy
this device's (a menu pinned open on a wide screen) preferences.OfThisDevice("menu-pinned") the browser only keeps it
var Theme = preferences.OfThePerson("theme")

value, ok := Theme.Get() // ok is false when nobody chose: the app's own default applies
err := Theme.Set("dark")
err = Theme.Forget()

var WelcomeSeen = preferences.OfThePerson("welcome-seen")
seen, _ := WelcomeSeen.For(m.ModelName()).Get() // one per screen

Nothing sensitive is a preference. Everything here is stored where any script of the page can read it (OWASP HTML5 Security Cheat Sheet). A secret never lives in the page: passkeys stay in the authenticator and the session in an HttpOnly cookie.

How it reaches the server

A component only imports webtyp.com/preferences, which uses nothing but the browser: it never knows about sessions or servers. The app shell plugs the server in.

  • webtyp.com/preferences/mine is the crud module that keeps each person's choices (key: person + name; every rule refuses another person's row). appkit builds it and grants it to every signed-in person in any app with a sign-in, and appkitc migrates its table: the app lists nothing.
  • In the browser, appkit calls preferences.Fill with the person's choices once they are known, preferences.SaveWith(mine.Saver(…)) so their changes reach the server, and preferences.ForgetPerson() when they sign out.
  • preferences.Language is the one choice two pieces share: components/languagepicker writes it and appkit applies it before drawing the page.
  • A page that reloads right after a change waits for the server: preferences.WhenSaved(func() { dom.Navigate("") }).

Outside a browser nothing is kept: every preference reads as not chosen.

Documentation

File What
docs/TESTS.md Test suite inventory