0
2
lexicons: authFull grants the group pool, basePermissions retired
harness/lexicons.mjs+4−0
| @@ -322,6 +322,10 @@ const RETIRED = new Set([ | ||
"social.grain.group.listFeed", | ||
"social.grain.group.listGalleries", | ||
"social.grain.group.putFavorite", | ||
// A permission set of the pool's space alone, which nothing asked for: | ||
// social.grain.authFull grants the pool, as it grants the rest of what | ||
// Grain writes, so a sign-in shows Grain once. | ||
"social.grain.basePermissions", | ||
]); | ||
| ||
if (base) { | ||
lexicons/social/grain/authFull.json+17−2
| @@ -5,8 +5,8 @@ | ||
"main": { | ||
"type": "permission-set", | ||
"title": "Grain", | ||
"detail": "Post, edit and delete your galleries, photos, stories, comments, favorites, follows, blocks and profile on Grain, and use Grain as you", | ||
"description": "Everything a Grain app does as an account: write and delete Grain's records in its repository, and call Grain's methods at the service the include names (`include:social.grain.authFull?aud=did:web:grain.social%23grain_appview`). Grows as Grain does: a collection or method added here reaches signed-in accounts as their tokens are refreshed.", | ||
"detail": "Post, edit and delete your galleries, photos, stories, comments, favorites, follows, blocks and profile on Grain and in your groups, and use Grain as you", | ||
"description": "Everything a Grain app does as an account: write and delete Grain's records in its repository and in its own repo of each group's pool it is in, and call Grain's methods at the service the include names (`include:social.grain.authFull?aud=did:web:grain.social%23grain_appview`). Grows as Grain does: a collection or method added here reaches signed-in accounts as their tokens are refreshed.", | ||
"permissions": [ | ||
{ | ||
"type": "permission", | ||
| @@ -25,6 +25,21 @@ | ||
"social.grain.story" | ||
] | ||
}, | ||
{ | ||
"type": "permission", | ||
"resource": "space", | ||
"spaceType": "social.grain.group.pool", | ||
"authority": "*", | ||
"collection": [ | ||
"social.grain.comment", | ||
"social.grain.favorite", | ||
"social.grain.gallery", | ||
"social.grain.gallery.item", | ||
"social.grain.photo", | ||
"social.grain.photo.exif" | ||
], | ||
"action": ["create", "update", "delete"] | ||
}, | ||
{ | ||
"type": "permission", | ||
"resource": "rpc", | ||
lexicons/social/grain/basePermissions.jsondeleted+0−30
| @@ -1,30 +0,0 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "social.grain.basePermissions", | ||
"defs": { | ||
"main": { | ||
"description": "The photo pools of an account's groups, to read and to add galleries, photos, favorites and comments of its own to.", | ||
"type": "permission-set", | ||
"title": "Photos", | ||
"detail": "Read your groups' photo pools, and add galleries, favourites and comments of your own to them", | ||
"permissions": [ | ||
{ | ||
"type": "permission", | ||
"resource": "space", | ||
"spaceType": "social.grain.group.pool", | ||
"authority": "*", | ||
"skey": "*", | ||
"collection": [ | ||
"social.grain.gallery", | ||
"social.grain.gallery.item", | ||
"social.grain.photo", | ||
"social.grain.photo.exif", | ||
"social.grain.favorite", | ||
"social.grain.comment" | ||
], | ||
"action": ["read", "create", "update", "delete"] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
next/lexicons/social/grain/authFull.json+17−2
| @@ -5,8 +5,8 @@ | ||
"main": { | ||
"type": "permission-set", | ||
"title": "Grain", | ||
"detail": "Post, edit and delete your galleries, photos, stories, comments, favorites, follows, blocks and profile on Grain, and use Grain as you", | ||
"description": "Everything a Grain app does as an account: write and delete Grain's records in its repository, and call Grain's methods at the service the include names (`include:social.grain.authFull?aud=did:web:grain.social%23grain_appview`). Grows as Grain does: a collection or method added here reaches signed-in accounts as their tokens are refreshed.", | ||
"detail": "Post, edit and delete your galleries, photos, stories, comments, favorites, follows, blocks and profile on Grain and in your groups, and use Grain as you", | ||
"description": "Everything a Grain app does as an account: write and delete Grain's records in its repository and in its own repo of each group's pool it is in, and call Grain's methods at the service the include names (`include:social.grain.authFull?aud=did:web:grain.social%23grain_appview`). Grows as Grain does: a collection or method added here reaches signed-in accounts as their tokens are refreshed.", | ||
"permissions": [ | ||
{ | ||
"type": "permission", | ||
| @@ -25,6 +25,21 @@ | ||
"social.grain.story" | ||
] | ||
}, | ||
{ | ||
"type": "permission", | ||
"resource": "space", | ||
"spaceType": "social.grain.group.pool", | ||
"authority": "*", | ||
"collection": [ | ||
"social.grain.comment", | ||
"social.grain.favorite", | ||
"social.grain.gallery", | ||
"social.grain.gallery.item", | ||
"social.grain.photo", | ||
"social.grain.photo.exif" | ||
], | ||
"action": ["create", "update", "delete"] | ||
}, | ||
{ | ||
"type": "permission", | ||
"resource": "rpc", | ||
next/lexicons/social/grain/basePermissions.jsondeleted+0−30
| @@ -1,30 +0,0 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "social.grain.basePermissions", | ||
"defs": { | ||
"main": { | ||
"description": "The photo pools of an account's groups, to read and to add galleries, photos, favorites and comments of its own to.", | ||
"type": "permission-set", | ||
"title": "Photos", | ||
"detail": "Read your groups' photo pools, and add galleries, favourites and comments of your own to them", | ||
"permissions": [ | ||
{ | ||
"type": "permission", | ||
"resource": "space", | ||
"spaceType": "social.grain.group.pool", | ||
"authority": "*", | ||
"skey": "*", | ||
"collection": [ | ||
"social.grain.gallery", | ||
"social.grain.gallery.item", | ||
"social.grain.photo", | ||
"social.grain.photo.exif", | ||
"social.grain.favorite", | ||
"social.grain.comment" | ||
], | ||
"action": ["read", "create", "update", "delete"] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
next/check-apps.mjs+21−4
| @@ -6,8 +6,10 @@ | ||
// a path opens a page or a route; that each permission set it names | ||
// (`permissions`) is one of grain's lexicons and grants the collections | ||
// under its namespace the views write (with the parts they share, | ||
// parts/), and the methods under it they, push and refresh call at its | ||
// service (a set grants nothing outside its namespace); that each font | ||
// parts/), in the repository and in spaces of a type under it (HUD asks | ||
// for those through the set alone), and the methods under it they, push | ||
// and refresh call at its service (a set grants nothing outside its | ||
// namespace); that each font | ||
// file its look names (`look.fonts.faces`) is under static/fonts/, named | ||
// by the start of its SHA-256, as serve.js keeps it for good; and that | ||
// lexicons/, the lexicons HUD checks the views against and serves them | ||
| @@ -28,12 +30,18 @@ const read = (f) => { | ||
| ||
const methods = new Map(); | ||
const writes = new Map(); // collection -> view file | ||
const spaceWrites = new Map(); // "space type collection" -> view file | ||
const calls = new Map(); // "method service" -> where | ||
const gather = (o, f) => { | ||
if (Array.isArray(o)) return o.forEach((x) => gather(x, f)); | ||
if (!o || typeof o !== "object") return; | ||
if (typeof o.create?.collection === "string") writes.set(o.create.collection, f); | ||
if (Array.isArray(o.writes)) for (const w of o.writes) if (typeof w?.collection === "string") writes.set(w.collection, f); | ||
const wrote = (w) => { | ||
if (typeof w?.collection !== "string") return; | ||
if (typeof w.space?.type === "string") spaceWrites.set(`${w.space.type} ${w.collection}`, f); | ||
else writes.set(w.collection, f); | ||
}; | ||
wrote(o.create); | ||
if (Array.isArray(o.writes)) o.writes.forEach(wrote); | ||
if (typeof o.method === "string" && typeof o.service === "string") calls.set(`${o.method} ${o.service}`, f); | ||
for (const v of Object.values(o)) gather(v, f); | ||
}; | ||
| @@ -92,6 +100,15 @@ for (const [i, { include, service } = {}] of (Array.isArray(app?.permissions) ? | ||
const repo = new Set(perms.filter((p) => p.resource === "repo" && !p.action).flatMap((p) => p.collection ?? [])); | ||
for (const [collection, f] of writes) | ||
if (needed(collection) && !repo.has(collection)) fail.push(`${f}: writes ${collection}, which ${include} grants no repo permission (all actions) for`); | ||
// A space's writes: create, update and delete of the collection, as HUD | ||
// asks them, by a permission naming its type for any authority. | ||
const writing = ["create", "update", "delete"]; | ||
const spaces = perms.filter((p) => p.resource === "space" && p.authority === "*" && writing.every((a) => p.action?.includes(a))); | ||
for (const [key, f] of spaceWrites) { | ||
const [type, collection] = key.split(" "); | ||
if (needed(type) && !spaces.some((p) => p.spaceType === type && p.collection?.includes(collection))) | ||
fail.push(`${f}: writes ${collection} in ${type}, which ${include} grants no space permission (create, update, delete, any authority) for`); | ||
} | ||
if (typeof service !== "string") continue; | ||
const rpc = new Set(perms.filter((p) => p.resource === "rpc" && p.inheritAud === true).flatMap((p) => p.lxm ?? [])); | ||
for (const [key, f] of calls) { | ||