gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitd69665f6d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmred69665f6/lib/selector.hl

2.9 KB

  1. // lib/selector.hl — THE IDENTITY SELECTOR (piece 3 of 6, ticket #26; CONCEPT.md "Flow 2: identity selector"
  2. // and "Decided 2026-09-24"). Statics only, the server realm. Its two CORS endpoints are lib/api.hl
  3. // (apiSelectorIdentities, apiSelectorChoose; the CORS answers and the caller check: lib/api-helpers.hl);
  4. // the browser half is selector.js (served at /selector.js).
  5. //
  6. // GET /api/selector/identities?key=<api key> → { signedIn, identities: [{ id, name }] }
  7. // POST /api/selector/choose?key=<api key> { identity: <id from the list> } → { code }
  8. // OPTIONS /api/selector/choose?key=… the CORS preflight of the POST
  9. //
  10. // CORS: ident answers ONLY a request whose Origin header is one of the app's registered
  11. // origins AND whose key is that app's API key. Then (and only then) the answer carries
  12. // `Access-Control-Allow-Origin: <that exact origin>` and `…-Allow-Credentials: true`
  13. // (never `*`). Anything else is a 403 without those headers: the browser hands the page
  14. // nothing, and nothing is written.
  15. // The ident user is the one of the `identsid` cookie the browser sends along (credentials;
  16. // SameSite=Lax, so it only travels from the SAME SITE — our apps; other ports of the same
  17. // host count). Function routes get no session: it is resolved from the cookie (hybriel #18).
  18. //
  19. // THE LIST'S ids are not ident's identity ids: each is sha256(app's secret hash : identity)
  20. // cut to 32 hex — stable for one app, different for every app, not guessable, and it
  21. // means nothing outside this selector. The CODE of a choice follows the login button's
  22. // rules exactly (lib/apps.hl issueCode: single use, 60 s, this app only); the host's server
  23. // trades it with POST /api/exchange (key + secret) for the app-specific identity id.
  24. import { sha256 } from 'hl:crypto'
  25. import { issueCode } from './apps.hl'
  26. import { identityRecords, isAgent } from './identities.hl'
  27. import { labelOf } from './identities-helpers.hl'
  28. // (since mission 009 the identity's id is its UUID, so every pick id changed once then)
  29. static pickOf = (appRec, identityRec) => { return sha256(appRec.secretHash + ':' + identityRec.id).slice(0, 32) }
  30. // the account's identities for the app's page: the id to pick it by and the identity
  31. // name (CONCEPT.md: "that one is shown in the selector"; blank → the list's fallback)
  32. static selectorList = (appRec, accountId) => {
  33. out = []
  34. let n = 1
  35. for (r of identityRecords(accountId)) {
  36. // ident#27: an agent identity (a conductor's) is not offered at a login; its numbering is kept
  37. if (!isAgent(r)) { out.push({ id = pickOf(appRec, r) name = labelOf(r, n) }) }
  38. n = n + 1
  39. }
  40. return out
  41. }
  42. // THE CHOICE: the account's identity whose pick id is `pick` gets a one-time code for the app. Answers the
  43. // code, or null (no such identity).
  44. static codeOfPick = (appRec, accountId, pick) => {
  45. for (r of identityRecords(accountId)) {
  46. if (pickOf(appRec, r) == pick && !isAgent(r)) {
  47. return issueCode(appRec.id, r.id)
  48. }
  49. }
  50. return null
  51. }

Branches

Latest commits

  • d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
  • 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
  • eb039073ident#34: tests: signin and migration find the choice without the classmre
  • 4b94a594ident#34: tests: fix selector of the identity choicemre
  • bebc88e4ident#34: main.hl drops the unstyled classes inboxlink and whomre
  • b4e7ad04ident#34: the identity choice link/button has no class (rule on #chooselist a)mre
  • 3c33d6eaident#34: the connection link in inbox has no class (rule on #conns a)mre
  • dc97ec0dident#34: the Notif. chip and the Used in link share chipLook (Style.pChip) instead of the classes chip/used/notifmre
  • 378bd432ident#34: the identity picture look is a static in styles.hl (Style.pAvatar); sizes stay with each listmre
  • 1cf79e7eident#34: the wide page column is a static in styles.hl (Style.pWide), not the class "wide"mre
  • ddc7d135Merge branch 'f7-hooks' into mainIdent
  • eee0b513|||PR ident#34 part: test-hook classes replaced by name/element/attribute selectors (tests adjusted), the shared lead/message/notice looks are statics in styles.hlmre
  • ccd6d0c4ident#34: browser gate: rowButton finds the row's button by namemre
  • 24dd414eident#34: the shared lead, message and notice looks are statics in components/styles.hl, imported by the components (lib/looks.hl gone)mre
  • 03ed26c7ident#34: access.hl: the remaining lead classes droppedmre
  • 1d066c42ident#34: access.hl drops its unstyled lead class (the shared lead rule would otherwise mute it)mre
  • 1e1dd7b4ident#34: the access page keeps its lead class string (the page has no ident-card, so its lead line was never muted; a shared rule would change the look)mre
  • 89ac6553ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
  • e84be3deident#34: browser gate lists the Edit/Delete buttons by namemre
  • fb7111faident#34: access page: unstyled test-hook classes (idrow, never, who, whoname, appname, neverrevoke) dropped; the tests use element/name selectorsmre