ident
All repositories: gitoria
2.9 KB
// lib/selector.hl — THE IDENTITY SELECTOR (piece 3 of 6, ticket #26; CONCEPT.md "Flow 2: identity selector"// and "Decided 2026-09-24"). Statics only, the server realm. Its two CORS endpoints are lib/api.hl// (apiSelectorIdentities, apiSelectorChoose; the CORS answers and the caller check: lib/api-helpers.hl);// the browser half is selector.js (served at /selector.js).//// GET /api/selector/identities?key=<api key> → { signedIn, identities: [{ id, name }] }// POST /api/selector/choose?key=<api key> { identity: <id from the list> } → { code }// OPTIONS /api/selector/choose?key=… the CORS preflight of the POST//// CORS: ident answers ONLY a request whose Origin header is one of the app's registered// origins AND whose key is that app's API key. Then (and only then) the answer carries// `Access-Control-Allow-Origin: <that exact origin>` and `…-Allow-Credentials: true`// (never `*`). Anything else is a 403 without those headers: the browser hands the page// nothing, and nothing is written.// The ident user is the one of the `identsid` cookie the browser sends along (credentials;// SameSite=Lax, so it only travels from the SAME SITE — our apps; other ports of the same// host count). Function routes get no session: it is resolved from the cookie (hybriel #18).//// THE LIST'S ids are not ident's identity ids: each is sha256(app's secret hash : identity)// cut to 32 hex — stable for one app, different for every app, not guessable, and it// means nothing outside this selector. The CODE of a choice follows the login button's// rules exactly (lib/apps.hl issueCode: single use, 60 s, this app only); the host's server// trades it with POST /api/exchange (key + secret) for the app-specific identity id.import { sha256 } from 'hl:crypto'import { issueCode } from './apps.hl'import { identityRecords, isAgent } from './identities.hl'import { labelOf } from './identities-helpers.hl'// (since mission 009 the identity's id is its UUID, so every pick id changed once then)static pickOf = (appRec, identityRec) => { return sha256(appRec.secretHash + ':' + identityRec.id).slice(0, 32) }// the account's identities for the app's page: the id to pick it by and the identity// name (CONCEPT.md: "that one is shown in the selector"; blank → the list's fallback)static selectorList = (appRec, accountId) => {out = []let n = 1for (r of identityRecords(accountId)) {// ident#27: an agent identity (a conductor's) is not offered at a login; its numbering is keptif (!isAgent(r)) { out.push({ id = pickOf(appRec, r) name = labelOf(r, n) }) }n = n + 1}return out}// THE CHOICE: the account's identity whose pick id is `pick` gets a one-time code for the app. Answers the// code, or null (no such identity).static codeOfPick = (appRec, accountId, pick) => {for (r of identityRecords(accountId)) {if (pickOf(appRec, r) == pick && !isAgent(r)) {return issueCode(appRec.id, r.id)}}return null}
Branches
Latest commits
- 47841dd4ident#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
- 7ae13f59ident#34: the lead, message and notice lines are named with Style.pLead / pMessage / pNotice (shared bodies in lib/looks.hl) instead of class stringsmre
- b323265aMerge branch 'f5-styles' into mainIdent
- 9ced53c3|||PR ident#33 ident#35 every component's styles live in its own Style block; styles.hl keeps the page-wide rest; the account bar is phone first (min-width: 60rem block); the avatar preview is hidden with the hidden attribute (ident#34 in part)mre
- f28333e4ident#33 ident#35: styles.hl keeps only the accent, the page column and the shared patterns; the account bar is written phone first (base rule + one min-width: 60rem block) instead of a max-width overridemre
- 5b4541fcident#33: the selector sign-in frame's rules move into embed.hl's Stylemre
- 00235f21ident#33: the per-app notification switches move into appsettings.hl's Stylemre
- 2249945cident#33: the inbox and connection list rules move into inbox.hl's Stylemre
- f2d9f79fident#33: the apps list and the secret box move into apps.hl's Stylemre
- 8370b748ident#33: the app request box moves into home.hl's Stylemre
- 40bf3b97ident#33: the 404 page's home link rule moves into notfound.hlmre
- 40627a89ident#33: the time zone section's spacing moves into timezone.hlmre
- d389db08ident#33: the identity page's rules and the Notif. chip move into identity.hl's Stylemre
- ddda0b5bident#33: the identity row's parts move into identitylist.hl's Stylemre
- 47e516afident#33 ident#34: the identity form's avatar rules move into identityform.hl; the preview and Remove button are hidden with the hidden attribute instead of built class strings (avatarPreviewClass, avatarRemoveClass gone)mre
- 5cb5cf0eident#33: the code field's look moves into codestep.hl's Stylemre
- f421cd60ident#33: the shell's own rules (user menu address, offline note, network probe) move into main.hl's Stylemre
- c512fb96Merge branch 'f4-homesplit' into mainIdent
- 07d1717c|||PR ident#40 home.hl is split into components, one per area: email step, identity form, identity list, app identity choice, time zone; each moves its faces with it, the email step is shared with embed.hl (#40.3, rest of #40.2)mre
- 59e8fcc1ident#40.3: the app's identity choice is one component (components/chooseidentity.hl); its face chooseIdentity moves with itmre