tickets
All repositories: gitoria
3.2 KB
// invites.hl — PEOPLE JOIN A PROJECT THROUGH IDENT'S INVITE SERVICE (ticket #20; ident README "Invites",// ident#22). tickets asks ident for an invite for one project and a role and shows the link; whoever opens// it and picks an identity is sent back to /login/callback?ident_code=…&invite=<invite id>. project.hl then// exchanges the code (users.hl), asks ident who ACCEPTED the invite (`identities`) and only then makes that// person a member. Statics only, the server realm. A failed fetch is absorbed by project.hl's `on Error`// (the call then yields null → "ident did not answer").import { fetch } from 'hl:fetch'import { identKey, identSecret, identExchangeUrl, callbackUrl } from './users.hl'static ua = { 'user-agent' = 'tickets.worldapi.org (ident invites)' }// only letters, digits and dashes (ident's invite ids)static isInviteId = (s) => {if (s == null || hlTypeName(s) != 'String' || s.length == 0 || s.length > 100) { return false }let i = 0while (i < s.length) {let c = s.charCodeAt(i)if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 122) || (c >= 65 && c <= 90) || c == 45 || c == 95)) { return false }i = i + 1}return true}static identCall = (path, body) => {if (identKey == '' || identSecret == '') { return { error = 'invites are not set up on this server (IDENT_API_KEY / IDENT_API_SECRET missing)' } }let json = { key = identKey secret = identSecret }for (k of body.keys()) { json[k] = body[k] }let r = fetch(identExchangeUrl + path, { method = 'POST' json = json headers = ua timeoutMs = 10000 })if (r == null || r.status == null || r.status == 0) { return { error = 'ident did not answer' } }let j = r.json()if (r.status != 200) { return { error = 'ident refused (' + r.status + (j != null && j.error != null ? ': ' + j.error : '') + ')' } }if (j == null) { return { error = 'ident answered nothing readable' } }return { body = j }}// an invite link for `projectId` and `role`: { url, id, expires } | { error }. `email` (optional) makes ident mail it.static createInvite = (projectId, role, uses, days, email) => {let body = { project = projectId role = role return = callbackUrl uses = uses days = days }if (email != null && email != '') { body.email = email }let r = identCall('/api/invites', body)if (r.error != null) { return r }let j = r.bodyif (j.url == null || j.id == null) { return { error = 'ident answered no invite link' } }return { url = j.url id = j.id expires = j.expires mailed = j.mailed == true }}// did this identity accept this invite? { project (id), role } | { error }static acceptedInvite = (inviteId, identity) => {if (!isInviteId(inviteId)) { return { error = 'that is not an invite id' } }let r = identCall('/api/invites/get', { id = inviteId })if (r.error != null) { return r }let inv = r.body.inviteif (inv == null || inv.project == null || inv.role == null) { return { error = 'ident answered no invite' } }let ok = falseif (inv.identities != null && countOfIds(inv.identities) > 0) { for (i of inv.identities) { if (i == identity) { ok = true } } }if (!ok) { return { error = 'this login did not accept that invite' } }return { project = inv.project role = inv.role }}static countOfIds = (list) => {let n = list.lengthreturn n == null ? 0 : n}
Branches
- mainmain branch
Latest commits
- 4137be0fantcolony#40: mission references point to the moved missionsmre
- 9bfba36aantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- c7bd2645tickets: Hybriel master 73267707 (#122 fixed); compactNow workaround removed (#110 covered)mre
- 2ab91ee9tickets: gate checks rows appear once (session sync); re-vendor to ff51cf46 stopped on hybriel#122, stays 837fe120mre
- e01c2b1dtickets#24: installable app (manifest, service worker, offline list), own icon; gate waits for the hello's pongmre
- 752fbb7fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- 38bdd5e4deploy.sh: never send .git or .gitignore to Byrodinmre
- f12fa1bcState of 2026-09-27, before the move to gitoriamre