ident
All repositories: gitoria
6.1 KB
// components/embed.hl — `/embed/signin?key=<api key>&return=<url>` (ident#31): THE SELECTOR'S SIGN-IN, shown inside the selector's// panel on an app's page (an iframe; lib/api.hl embedSignin checks key + return, parks the request like the login button and allows// framing only by the app's registered origins). Signed out of ident: email → code → the identity list, all in this frame, with one// note that this signs the user in to ident. Choosing an identity (the identity row itself, no extra Continue click), and the way on for a NEW address, are plain links with// target="_top": the whole app page then goes to `<return>?ident_code=<code>` (lib/api.hl embedGo), the flow every app handles.// A new address (the account is created by the first right code) is sent on to ident in the same tab (`/signin/<rid>/welcome`)// to name its identity and pick it; ident then sends the browser back to the page it came from.parent './embedshell.hl'import { accountOfSession } from '../lib/accounts.hl'import EmailStep from './emailstep.hl'import CodeStep from './codestep.hl'import { identityRows } from '../lib/identities.hl'import { requestOf } from '../lib/apps.hl'import { leadLook, messageLook } from './styles.hl'session = nullrid = nullme = accountOfSession(&session)request = rid != null ? requestOf(rid) : nullappName = request != null ? request.app.name : ''identities = me != null ? identityRows(me.id) : []// the steps (a View's `if` takes a member): email → code → choose (or `fresh` for a new address)askEmail = me == nullaskCode = falsechoose = me != nullfresh = falsesentTo = ''message = ''rowsOf = (list) => {out = []for (row of list) { out.push({ label = row.label shortId = row.shortId href = '/embed/go?rid=' + rid + '&identity=' + row.id }) }return out}choices = rowsOf(identities)newHref = '/signin/' + rid + '/welcome'// the selector's sign-in frame (ident#31): inside the selector's panel (same surface colour), the same fields and buttonsStyle {pLead = leadLookpMessage = messageLook'html:has(embed-card), body:has(embed-card)' {background = 'var(--color-surface)'}fitMark {position = 'absolute'width = '0'height = '0'overflow = 'hidden'animation = 'ident-frame-fit 1s infinite'}'@keyframes ident-frame-fit' = {'from' = { opacity = '1' }to = { opacity = '0.99' }}embedCard {display = 'grid'gap = '.8rem'padding = '.5rem'}'embed-card p' {margin = '0'overflowWrap = 'anywhere'}'embed-card, embed-card form, embed-card label, embed-card input, embed-card li' {minWidth = '0'}'embed-card input' {width = '100%'maxWidth = '100%'boxSizing = 'border-box'}'embed-card #code' {fontSize = '1.2rem'letterSpacing = '.15em'}'embed-card form' {display = 'grid'gap = '.8rem'}'embed-card label' {display = 'grid'gap = '.25rem'marginBottom = '0'}'embed-card .message:empty' {display = 'none'}'embed-card .lead' {color = 'var(--color-text-muted)'}'embed-card #chooselist' {listStyle = 'none'margin = '0'padding = '0'display = 'grid'gap = '.5rem'}'embed-card #chooselist li' {background = 'var(--color-background-sunken)'flexWrap = 'nowrap'}'embed-card identity-main' {flex = '1 1 auto'}'embed-card #chooselist a.choose' {display = 'flex'flex = '1 1 auto'alignItems = 'center'minHeight = 'var(--layout-tap)'color = 'inherit'textDecoration = 'none'}'embed-card a.button' {display = 'inline-flex'alignItems = 'center'justifyContent = 'center'minHeight = 'var(--layout-tap)'textDecoration = 'none'}}View {embedCard {if (askEmail) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }p { id = "embednote" Style.pLead "This signs you in to ident. We mail you a one-time code." }EmailStep {}}if (askCode) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }CodeStep { sentTo = sentTo tail = '.' }}if (choose) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }p { Style.pLead "You are signed in to ident. Choose the identity to log in to " strong { appName } " with." }ul { id = "chooselist"for (row of choices) {li {a { class = "choose" target = "_top" href = row.hrefidentityMain { identityLabel { row.label } identityShortId { row.shortId } }}}}}}if (fresh) {fitMark { on animationstart(e) { emit fit(e) } on animationiteration(e) { emit fit(e) } }p { id = "freshnote" Style.pLead "This address is new to ident, so it has an account now. Create your identity on ident: it takes you there and brings you back to this page." }a { id = "gonew" class = "button" target = "_top" href = newHref "Create my identity" }}p { id = "message" Style.pMessage message }}}// THE FRAME'S HEIGHT: the selector (selector.js) cannot read this page's height across origins, so the page tells it. Every step has a// fitMark whose CSS animation starts when the step appears (and repeats each second for a resize or a message): then the page's content// height goes to the parent window. No JavaScript of ours; selector.js accepts it from ident's origin only.on fit(e) {// the card's bottom edge, not the document's height (the document is as tall as the frame, so it could never shrink)card = document.querySelector('embed-card')if (card != null) { window.parent.postMessage({ identFrameHeight = Math.ceil(card.getBoundingClientRect().bottom + window.scrollY) }, '*') }}// the email step (components/emailstep.hl) asked for a code (the plain POST to /api/code): the frame goes on to the code stepemailSent = (String address) => {sentTo = addressaskEmail = falseaskCode = true}// the code step (components/codestep.hl) checked the code: the answer, or why notcodeFailed = (String text) => { message = text }codeVerified = (r) => {askCode = falseidentities = r.identitieschoices = rowsOf(r.identities)if (r.created) {fresh = true} else {choose = true}}back = () => {message = ''askCode = falseaskEmail = true}
Branches
Latest commits
- 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
- 9f2ad803ident#34: notification switches: push/email by name=..., locked by aria-disabled, the switch look is the role=switch button (no switch/push/email/locked classes)mre
- e0f0ddaaident#34: inbox: the Mark read/unread button is styled as the button of its note-foot, the icon is found as the row's img (no toggle/icon classes)mre
- 16b49756ident#34: unused row classes (choice, usedrow, kind, shortid) droppedmre
- f9d6fb38ident#34: apps and identity rows: the Edit/New secret/Delete buttons carry name=..., the API key is found by its element; unused row classes (app, identity, shortid) droppedmre
- 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