chadtmiller.com/monolith
An atproto PDS
0
0
consent: spaces said from the account's side, every clause a sentence
.changeset/consent-spaces-wording.mdnew+13−0
| @@ -0,0 +1,13 @@ | ||
--- | ||
default: patch | ||
--- | ||
| ||
# Consent says what an app may do in spaces, from your side | ||
| ||
The consent page's space rows now say what the app may do as you, rather than reading the scope word for word: | ||
| ||
- **Others' spaces:** where the scope names any owner, or another account, the row is the spaces "you're in", not "Everyone's", as the space itself still decides who gets in. | ||
- **Writes:** these are "your own" records, since a write in a space only ever reaches the writer's own records. | ||
- **Managing:** changing who's in a space or deleting it reads "the ones you made", as only a space's owner can. | ||
.changeset/consent-spaces-wording.mdline 11Since e9f31f8, a scope naming one particular other account says nothing about managing. Only an any-owner ( | ||
| ||
Each part of a space row or a data row is now a sentence of its own ("Read everything in them. Add, change and remove your own notes."), with no semicolons. | ||
harness/checks/pages.mjs+26−16
| @@ -132,6 +132,8 @@ const PASSKEY_WORDS = { | ||
/// Words joined as spec/OAUTH-PAGES.md joins them: `a`, `a and b`, `a, b and c`. | ||
const join = (xs) => (xs.length < 2 ? xs.join('') : `${xs.slice(0, -1).join(', ')} and ${xs.at(-1)}`) | ||
const capital = (s) => `${s[0].toUpperCase()}${s.slice(1)}` | ||
/// Clauses, each a sentence of its own, joined with a space. | ||
const sentences = (xs) => xs.map((x) => `${capital(x)}.`).join(' ') | ||
const ACTIONS = [['create', 'add'], ['update', 'change'], ['delete', 'remove']] | ||
const ACCOUNT = { | ||
email: { read: 'see your email address', manage: 'see and change your email address' }, | ||
| @@ -245,10 +247,10 @@ function spaceRows(ps, spaces, handles) { | ||
const did = g.authority.startsWith('did:') | ||
const owner = did ? (handles?.[g.authority] ? `@${handles[g.authority]}` : g.authority) : null | ||
const name = g.type === '*' ? null : spaceName(g.type, spaces) | ||
let heading = g.type === '*' | ||
? (g.authority === 'self' ? 'All your spaces' : g.authority === '*' ? "Every space you're in" : `All of ${owner}'s spaces`) | ||
: (g.authority === 'self' ? `Your ${name} spaces` : g.authority === '*' ? `Everyone's ${name} spaces` : `${owner}'s ${name} spaces`) | ||
if (g.skey !== '*') heading += ` named “${g.skey}”` | ||
const key = g.skey !== '*' ? ` named “${g.skey}”` : '' | ||
const heading = g.type === '*' | ||
? (g.authority === 'self' ? `All your spaces${key}` : g.authority === '*' ? `Every space${key} you're in` : `${owner}'s spaces${key} you're in`) | ||
: (g.authority === 'self' ? `Your ${name} spaces${key}` : g.authority === '*' ? `${name} spaces${key} you're in` : `${owner}'s ${name} spaces${key} you're in`) | ||
const clauses = [] | ||
if (g.read) clauses.push('read everything in them') | ||
else if (g.readSelf) clauses.push("see what you've written in them") | ||
| @@ -258,12 +260,18 @@ function spaceRows(ps, spaces, handles) { | ||
if (c !== '*' && star && [...acts].every((a) => star.has(a))) continue | ||
const k = ACTIONS.filter(([a]) => acts.has(a)).map(([a]) => a).join(',') | ||
if (!byActions.has(k)) byActions.set(k, []) | ||
byActions.get(k).push(c === '*' ? 'anything' : thingOf(c)) | ||
byActions.get(k).push(c === '*' ? 'records of any kind' : thingOf(c)) | ||
} | ||
for (const [k, things] of byActions) clauses.push(`${verbs(new Set(k.split(',')))} ${join(things)}`) | ||
const manage = [['create', 'make new ones'], ['update', "change who's in them"], ['delete', 'delete them']].filter(([m]) => g.manage.has(m)).map(([, w]) => w) | ||
if (manage.length) clauses.push(join(manage)) | ||
const sentence = clauses.length ? `${capital(clauses.join('; '))}.` : 'Asks for nothing this server grants.' | ||
for (const [k, things] of byActions) clauses.push(`${verbs(new Set(k.split(',')))} your own ${join(things)}`) | ||
if (g.authority === 'self') { | ||
const manage = [['create', 'make new ones'], ['update', "change who's in them"], ['delete', 'delete them']].filter(([m]) => g.manage.has(m)).map(([, w]) => w) | ||
if (manage.length) clauses.push(join(manage)) | ||
} else if (g.authority === '*') { | ||
const made = [['update', "change who's in"], ['delete', 'delete']].filter(([m]) => g.manage.has(m)).map(([, w]) => w) | ||
const parts = [...(g.manage.has('create') ? ['make new ones'] : []), ...(made.length ? [`${made.join(' or ')} the ones you made`] : [])] | ||
if (parts.length) clauses.push(parts.join(', and ')) | ||
} | ||
const sentence = clauses.length ? sentences(clauses) : 'Asks for nothing this server grants.' | ||
return { heading, sentence, codes: did && !handles?.[g.authority] ? [g.authority] : [] } | ||
}) | ||
} | ||
| @@ -367,7 +375,7 @@ export function consentRows(tokens, sets = {}, spaces = {}, handles = {}) { | ||
const asked = askedOf(repos) | ||
const star = asked.get('*') | ||
if (star) rows.push(row('All your data', `${capital(verbs(star))} all your data.`)) | ||
for (const [app, data] of dataClauses(asked, star)) rows.push(row(`Your data in ${app}`, `${capital(data.join('; '))}.`)) | ||
for (const [app, data] of dataClauses(asked, star)) rows.push(row(`Your data in ${app}`, sentences(data))) | ||
} | ||
| ||
const blobs = of('blob') | ||
| @@ -1178,17 +1186,17 @@ async function alertsFlow() { | ||
} | ||
| ||
/// The clients whose consent views show spaces, `other` the DID of an | ||
/// account of the server, whose handle verifies (spec/OAUTH-PAGES.md, "How | ||
/// it is checked"): a bare type merged with one managing it, another's, | ||
/// every space of each authority, the set granting spaces, a type with a | ||
/// key, collections of another app and `*`, a DID with no handle, and | ||
/// writes with no collection to write. | ||
/// account of the server (spec/OAUTH-PAGES.md, "How it is checked"): a | ||
/// bare type merged with one managing it, another's, every space of each | ||
/// authority, one of any owner managed in every way, the set granting | ||
/// spaces, a type with a key, collections of another app and `*`, a DID | ||
/// with no handle, and writes with no collection to write. | ||
function spaceClients(other) { | ||
const W = SPACE_TYPES.workspace | ||
const B = SPACE_TYPES.board | ||
const nobody = 'did:plc:aaaaaaaaaaaaaaaaaaaaaaaa' | ||
return [ | ||
`atproto space:${W} space:${W}?manage=create&manage=update space:${B}?authority=${other}&action=read space:*?authority=*&action=read_self repo:com.example.profile`, | ||
`atproto space:${W} space:${W}?manage=create&manage=update space:${B}?authority=${other}&action=read space:*?authority=*&action=read_self space:${B}?authority=*&collection=*&manage=create&manage=update&manage=delete repo:com.example.profile`, | ||
`atproto include:${SETS.forum} space:${B}?action=create&collection=com.example.zz.thing&collection=*&collection=com.example.forum.post space:${W}?skey=main&action=read_self space:*?authority=${nobody}&action=read`, | ||
`atproto space:*?action=create space:*?authority=${other}&manage=delete space:${B}?authority=*&action=update&action=delete space?spaceType=${W}&collection=com.example.zz.thing&action=create&action=read_self transition:generic`, | ||
] | ||
| @@ -1212,6 +1220,8 @@ async function spacesFlow(scope) { | ||
const answered = w.page.waitForResponse((r) => r.url().includes('/~api/sign-in')) | ||
await button(w, SERVER.signIn).click() | ||
await answered | ||
// The view changes once the answer is read; until then it is Sign in still. | ||
await w.page.getByRole('heading', { name: SERVER.headings.consent, exact: true }).waitFor({ timeout: 8000 }).catch(() => {}) | ||
if ((await viewOf(w)) !== 'consent') return held('the view after a sign-in', 'Allow access', await shown(w)) | ||
await checkView(w, 'consent', { appeared: true, loopback: true }) | ||
count('pages: a consent with spaces', true) | ||
spec/OAUTH-PAGES.md+49−30
| @@ -249,10 +249,10 @@ The view says who is asking and for which account: | ||
| 2 | `Identity` | `Change your handle, and take over your account's identity, which could move your account elsewhere.` with `identity:*`; else `Change your handle.` | `identity:*`, `identity:handle` | | ||
| 3 | `Account` | `<Account clauses>.` | `account:…`, `transition:email` | | ||
| 4 | `Direct messages` | `Read and send your Bluesky direct messages.` | `transition:chat.bsky` | | ||
| 5 | `<Space heading>` | `<Space clauses>.` | the scope's `space:` tokens, a row for each space they name (below), in the order the scope first names it | | ||
| 5 | `<Space heading>` | `<Space clauses>` | the scope's `space:` tokens, a row for each space they name (below), in the order the scope first names it | | ||
| 6 | the set's title, or else its NSID | the set's detail; or else, for a set with a title, its NSID; or else none. Then **What it grants** (below) | each `include:` token, a row of its own, in the scope's order | | ||
| 7 | `All your data` | `<Actions> all your data.` | `repo:` tokens of collection `*`, unless the scope has `transition:generic` | | ||
| 8 | `Your data in <app>`, one row for each app, in the order the scope first names it | `<Data clauses>.` | the other `repo:` collections, unless the scope has `transition:generic` | | ||
| 8 | `Your data in <app>`, one row for each app, in the order the scope first names it | `<Data clauses>` | the other `repo:` collections, unless the scope has `transition:generic` | | ||
| 9 | `Uploads` | `Upload <kinds>.` | `blob:…`, unless the scope has `transition:generic` | | ||
| 10 | `Other services` | `Act as you on <services>.` | `rpc:…`, unless the scope has `transition:generic` | | ||
| 11 | `Permission` | the token, in `<code>` | each other token the server keeps but an `include:` or a `space:`, a row of its own, in the scope's order | | ||
| @@ -321,17 +321,18 @@ b and c`, and a sentence's first letter is a capital: | ||
labels, `co.uk`: the scope alone cannot say better.) | ||
- **`<Data clauses>`**: an app's collections that have the same actions | ||
make one clause, `<Actions> <things>`, in the order the scope first | ||
names them, joined with `; `. A thing is the NSID's last segment, its | ||
camel case split into lower-case words, its last word made plural: as | ||
it is when it ends in `s`; `ies` in place of a final `y` after a letter | ||
other than `a`, `e`, `i`, `o` and `u`; `es` after a final `x`, `z`, `ch` | ||
or `sh`; else `s` after it (`post` `posts`, `listItem` `list items`, | ||
`notes` `notes`, `reply` `replies`, `day` `days`, `box` `boxes`), and | ||
the things are joined as a list. So | ||
names them, each a sentence of its own (its first letter a capital, a | ||
full stop after it), the sentences joined with a space. A thing is the | ||
NSID's last segment, its camel case split into lower-case words, its | ||
last word made plural: as it is when it ends in `s`; `ies` in place of | ||
a final `y` after a letter other than `a`, `e`, `i`, `o` and `u`; `es` | ||
after a final `x`, `z`, `ch` or `sh`; else `s` after it (`post` `posts`, | ||
`listItem` `list items`, `notes` `notes`, `reply` `replies`, `day` | ||
`days`, `box` `boxes`), and the things are joined as a list. So | ||
`repo:app.bsky.feed.post?action=create&action=delete | ||
repo:app.bsky.feed.like repo:app.bsky.graph.follow?action=create` | ||
reads `Your data in bsky.app: Add and remove posts; add, change and | ||
remove likes; add follows.` | ||
reads `Your data in bsky.app: Add and remove posts. Add, change and | ||
remove likes. Add follows.` | ||
- **`<kinds>`**: by each type the `blob:` tokens accept, once each, in the | ||
order first given, but `files` last: `any file` for `*/*`, which says | ||
all; else `images` for `image/…`, `videos` for `video/…`, `audio` for | ||
| @@ -342,15 +343,18 @@ b and c`, and a sentence's first letter is a capital: | ||
(`api.bsky.app` for `did:web:api.bsky.app#bsky_appview`), then `a | ||
service` once for any other DID, then `any service` for `*`; joined as | ||
a list. Which methods are asked is in `Technical details`. | ||
- **`<Space heading>`**: whose spaces, and of which type, by the space's | ||
`spaceType` and `authority`; then, for an `skey` that is not `*`, | ||
` named “<skey>”`: | ||
- **`<Space heading>`**: whose spaces, and of which type, said from the | ||
account's side: a space it does not own it reaches only as the space | ||
lets it, so those are the spaces it is in (`SPACES-POLICIES.md`, "Who | ||
is authorized"). By the space's `spaceType` and `authority`: | ||
| ||
| `spaceType` | `authority` `self` | a DID | `*` | | ||
| --- | --- | --- | --- | | ||
| a type | `Your <Name> spaces` | `<Owner>'s <Name> spaces` | `Everyone's <Name> spaces` | | ||
| `*` | `All your spaces` | `All of <Owner>'s spaces` | `Every space you're in` | | ||
| a type | `Your <Name> spaces` | `<Owner>'s <Name> spaces you're in` | `<Name> spaces you're in` | | ||
| `*` | `All your spaces` | `<Owner>'s spaces you're in` | `Every space you're in` | | ||
| ||
For an `skey` that is not `*`, ` named “<skey>”` follows the word | ||
`spaces` (or `space`): `Inbox spaces named “self” you're in`. | ||
`<Name>` is the type's declaration's title (`title:lang`'s `en`, or else | ||
its first key that begins `en-`, or else `title`), or else the type's | ||
NSID's last segment, its camel case split into words, its first letter | ||
| @@ -358,27 +362,42 @@ b and c`, and a sentence's first letter is a capital: | ||
`<Owner>` is `@<handle>` when `spaceHandles` has the DID, or else the | ||
DID, in `<code>`. | ||
- **`<Space clauses>`**: what the space's tokens ask between them, as | ||
clauses in this order, joined with `; `: | ||
clauses in this order, each a sentence of its own as `<Data clauses>` | ||
are, joined with a space: | ||
1. `read everything in them`, when any asks `read`; or else `see what | ||
you've written in them`, when any asks `read_self`; | ||
2. the writes: each collection a token names, or for a token that names | ||
none, of a `spaceType` that is not `*`, each of its declaration's | ||
`collections`, with each of that token's actions that is `create`, | ||
`update` or `delete`. Collections with the same actions make one | ||
clause, `<Actions> <things>`, in the order first named, as `<Data | ||
clauses>` make them but whatever app each is of; `*`'s thing is | ||
`anything`, and a collection other than `*` whose actions `*` has too | ||
is not said again; | ||
3. its `manage` operations, as `make new ones` (`create`), `change who's | ||
in them` (`update`) and `delete them` (`delete`), in that order, | ||
joined as a list. | ||
2. the writes, which are to the account's own records alone | ||
(`SPACES-REPO.md`): each collection a token names, or for a token | ||
that names none, of a `spaceType` that is not `*`, each of its | ||
declaration's `collections`, with each of that token's actions that | ||
is `create`, `update` or `delete`. Collections with the same actions | ||
make one clause, `<Actions> your own <things>`, in the order first | ||
named, the things as `<Data clauses>` name them, whatever app each is | ||
of; `*`'s thing is `records of any kind`, and a collection other | ||
than `*` whose actions `*` has too is not said again; | ||
3. its `manage` operations, as `OAUTH-SCOPES.md` ("What it allows", | ||
"What each method needs") lets them reach only a space the account | ||
owns (`SPACES-POLICIES.md`). For `authority` `self`: `make new ones` | ||
(`create`), `change who's in them` (`update`) and `delete them` | ||
(`delete`), in that order, joined as a list. For `*`: `make new ones` | ||
(`create`); then `change who's in` (`update`) and `delete` | ||
(`delete`), joined as `a` or `a or b`, with ` the ones you made` | ||
after them; the two joined with `, and ` when there are both. For a | ||
DID, nothing: making a space checks the account's own DID, and | ||
changing or deleting one asks that the account be the space's | ||
authority, so a DID's `manage` reaches no space. | ||
| ||
A space that asks none of these reads `Asks for nothing this server | ||
grants.` So `space:com.example.workspace` with a declaration titled | ||
`Workspace` of `[com.example.note, com.example.tile]`, and | ||
`space:com.example.workspace?manage=create&manage=update`, read `Your | ||
Workspace spaces: Read everything in them; add, change and remove notes | ||
and tiles; make new ones and change who's in them.` | ||
Workspace spaces: Read everything in them. Add, change and remove your | ||
own notes and tiles. Make new ones and change who's in them.`; and | ||
`space:fyi.opensocial.conversation?authority=*&collection=*&manage=create&manage=update&manage=delete`, | ||
of a declaration titled `Conversation`, reads `Conversation spaces | ||
you're in: Read everything in them. Add, change and remove your own | ||
records of any kind. Make new ones, and change who's in or delete the | ||
ones you made.` | ||
| ||
**Seeing it all.** Allow, Deny and Back (or Another account) are always | ||
in view: at 360 by 740 and at 1200 by 900 CSS pixels, whatever the scope, | ||
web/src/lib/scopes.ts+34−26
| @@ -99,6 +99,8 @@ function joined(items: string[]): string { | ||
// A sentence: its first letter a capital, and a full stop. | ||
const said = (text: string): string => `${text.charAt(0).toUpperCase()}${text.slice(1)}.`; | ||
const sentence = (text: string): Part[] => [said(text)]; | ||
// Clauses, each a sentence of its own, joined with a space. | ||
const sentences = (clauses: string[]): string => clauses.map(said).join(' '); | ||
| ||
// The verbs of a set of record actions, joined as a list. | ||
const verbs = (actions: Set<string>): string => | ||
| @@ -192,7 +194,7 @@ function dataRows(tokens: Token[]): Item[] { | ||
) | ||
); | ||
for (const [app, clauses] of clausesByApp(rest)) | ||
rows.push({ heading: [`Your data in ${app}`], sentence: sentence(clauses.join('; ')) }); | ||
rows.push({ heading: [`Your data in ${app}`], sentence: [sentences(clauses)] }); | ||
return rows; | ||
} | ||
| ||
| @@ -450,12 +452,18 @@ export type SpaceData = { declarations?: Record<string, unknown>; handles?: Reco | ||
// A space as a row or a set's Details says it. | ||
export type Space = { heading: Part[]; sentence: string }; | ||
| ||
// A space's `manage` operation and its clause, in the order said. | ||
// A space's `manage` operation and its clause, in the order said: for one | ||
// the account owns (`self`), and for every space (`*`), where only those it | ||
// made are changed or deleted. Of another's spaces nothing is said. | ||
const MANAGE: [string, string][] = [ | ||
['create', 'make new ones'], | ||
['update', "change who's in them"], | ||
['delete', 'delete them'] | ||
]; | ||
const MANAGE_MADE: [string, string][] = [ | ||
['update', "change who's in"], | ||
['delete', 'delete'] | ||
]; | ||
| ||
// What the tokens naming one space ask between them. | ||
type Asked = { | ||
| @@ -483,32 +491,22 @@ function spaceName(data: SpaceData, type: string): string { | ||
return `${last.charAt(0).toUpperCase()}${last.slice(1)}`; | ||
} | ||
| ||
// <Space heading>: whose spaces, of which type, and by which key. | ||
// <Space heading>: whose spaces, of which type, and by which key, said | ||
// from the account's side. | ||
function spaceHeading(data: SpaceData, s: Asked): Part[] { | ||
const handle = isObject(data.handles) && Object.hasOwn(data.handles, s.authority) ? data.handles[s.authority] : undefined; | ||
const owner: Part = typeof handle === 'string' && handle ? `@${handle}` : { code: s.authority }; | ||
const named = s.skey === '*' ? '' : ` named “${s.skey}”`; | ||
const name = s.spaceType === '*' ? '' : spaceName(data, s.spaceType); | ||
const parts: Part[] = | ||
s.authority === 'self' | ||
? [s.spaceType === '*' ? 'All your spaces' : `Your ${name} spaces`] | ||
: s.authority === '*' | ||
? [s.spaceType === '*' ? "Every space you're in" : `Everyone's ${name} spaces`] | ||
: s.spaceType === '*' | ||
? ['All of ', owner, "'s spaces"] | ||
: [owner, `'s ${name} spaces`]; | ||
if (named) parts.push(named); | ||
// Neighbouring texts as one run. | ||
return parts.reduce<Part[]>((out, p) => { | ||
const last = out[out.length - 1]; | ||
if (typeof p === 'string' && typeof last === 'string') out[out.length - 1] = last + p; | ||
else out.push(p); | ||
return out; | ||
}, []); | ||
if (s.authority === 'self') return [s.spaceType === '*' ? `All your spaces${named}` : `Your ${name} spaces${named}`]; | ||
if (s.authority === '*') | ||
return [s.spaceType === '*' ? `Every space${named} you're in` : `${name} spaces${named} you're in`]; | ||
return [owner, s.spaceType === '*' ? `'s spaces${named} you're in` : `'s ${name} spaces${named} you're in`]; | ||
} | ||
| ||
// <Space clauses>: reading, the writes grouped by their actions (`*`'s | ||
// thing `anything`, what `*` covers not said again), then managing. | ||
// <Space clauses>: reading, the writes to the account's own records | ||
// grouped by their actions (`*`'s thing `records of any kind`, what `*` | ||
// covers not said again), then managing; each a sentence. | ||
function spaceSentence(s: Asked): string { | ||
const clauses: string[] = []; | ||
if (s.read) clauses.push('read everything in them'); | ||
| @@ -518,12 +516,22 @@ function spaceSentence(s: Asked): string { | ||
for (const [c, actions] of s.writes) { | ||
if (c !== '*' && star && [...actions].every((a) => star.has(a))) continue; | ||
const key = ALL_ACTIONS.filter((a) => actions.has(a)).join(','); | ||
groups.set(key, [...(groups.get(key) ?? []), c === '*' ? 'anything' : thingOf(c)]); | ||
groups.set(key, [...(groups.get(key) ?? []), c === '*' ? 'records of any kind' : thingOf(c)]); | ||
} | ||
for (const [key, things] of groups) | ||
clauses.push(`${verbs(new Set(key.split(',')))} your own ${joined(things)}`); | ||
if (s.authority === 'self') { | ||
const manage = MANAGE.filter(([m]) => s.manage.has(m)).map(([, said]) => said); | ||
if (manage.length) clauses.push(joined(manage)); | ||
} else if (s.authority === '*') { | ||
const made = MANAGE_MADE.filter(([m]) => s.manage.has(m)).map(([, said]) => said); | ||
const manage = [ | ||
...(s.manage.has('create') ? ['make new ones'] : []), | ||
...(made.length ? [`${made.join(' or ')} the ones you made`] : []) | ||
]; | ||
if (manage.length) clauses.push(manage.join(', and ')); | ||
} | ||
for (const [key, things] of groups) clauses.push(`${verbs(new Set(key.split(',')))} ${joined(things)}`); | ||
const manage = MANAGE.filter(([m]) => s.manage.has(m)).map(([, said]) => said); | ||
if (manage.length) clauses.push(joined(manage)); | ||
return clauses.length ? said(clauses.join('; ')) : 'Asks for nothing this server grants.'; | ||
return clauses.length ? sentences(clauses) : 'Asks for nothing this server grants.'; | ||
} | ||
| ||
// The spaces `space` tokens name, by type, authority and key, each as | ||