~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

An app's permission set grants its own spaces

Open chadtmiller.com wants to merge into main from chadtmiller.com/hud:app-set-spaces
.changeset/app-sets-grant-their-spaces.mdnew+7−0
@@ -0,0 +1,7 @@
---
default: minor
---
# An app's permission set grants its own spaces
An app's permission set may now hold the spaces of types in its own namespace, as it holds its collections and methods: where a view writes into a space whose type is under the set's namespace (`social.grain.group.pool` under `social.grain.authFull`), sign-in asks for it through the set's `include:` and no longer as a `space:` permission beside it, so the consent screen shows the app's set alone. List those writes in the set as a `space` permission (`spaceType`, `authority: "*"`, the `collection`s and the `action`s the views write: create, update, delete), or HUD logs `<set> does not grant space:…` as it starts. A server that serves no spaces skips a set's `space` permissions and grants the rest. A space of another namespace's type is still asked for directly.
crates/hud-core/src/testdata/grain/apps/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",
@@ -24,6 +24,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",
crates/hud-core/src/testdata/grain/apps/lexicons/social/grain/basePermissions.jsondeleted+0−29
@@ -1,29 +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",
"authority": "*",
"skey": "*",
"collection": [
"social.grain.gallery",
"social.grain.gallery.item",
"social.grain.photo",
"social.grain.favorite",
"social.grain.comment"
],
"action": ["read", "create", "update", "delete"]
}
]
}
}
}
crates/hud-core/src/testdata/grain/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",
@@ -24,6 +24,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",
crates/hud-core/src/testdata/grain/social.grain.group.pool.jsonnew+20−0
@@ -0,0 +1,20 @@
{
"lexicon": 1,
"id": "social.grain.group.pool",
"defs": {
"main": {
"type": "space",
"key": "any",
"name": "Group pool",
"description": "A group's pool of galleries: the photos its members put in, with the camera details each carries, and their favourites and comments on them, held together as one space. The group is its authority and its space key is self. Each member's records stay in their own repo; the space says who may read them, which is the group's members. A favourite, a comment or a photo's camera details belong here rather than in the public repo for the same reason the photos do: in the public repo they would name a private gallery or photo to the whole network.",
"collections": [
"social.grain.gallery",
"social.grain.gallery.item",
"social.grain.photo",
"social.grain.photo.exif",
"social.grain.favorite",
"social.grain.comment"
]
}
}
}
crates/hud-core/src/scope.rs+53−22
@@ -22,7 +22,7 @@
//! `atproto::scope::Include`), HUD asks for those first (`including`): each
//! `include:`, which the account's server resolves from the set's published
//! lexicon, and of the rest only what no set can hold (pictures, others'
//! collections and services). A set grows as its app does, and reaches
//! collections, services and spaces). A set grows as its app does, and reaches
//! accounts signed in as their tokens are refreshed, so a view added asks
//! for nothing new. What the views do (`asked`) stays what HUD holds its
//! own writes and calls to, and what it asks a server that refuses the
@@ -42,18 +42,17 @@ use serde_json::Value;
/// Whether the permission set `set` could hold `scope`, a permission of
/// what the views do: to write or delete a collection in its namespace,
/// or to call methods of the service its include names (`call`); and,
/// HUD's own set alone, HUD's spaces of a type in its namespace
/// (`config::SPACE_SCOPE` and the like), which it grants. A set holds no
/// to write into spaces of a type in its namespace (a group's pool of
/// Grain's, `config::SPACE_SCOPE` and the like of HUD's), or to call
/// methods of the service its include names (`call`). A set holds no
/// `blob`, `account` or `identity` permission, nothing of another
/// namespace, no audience but the one its include names, and no method
/// but those it lists, which `ungranted` checks against what the views
/// call. An app's set is held to no `space:` permission: a view's are
/// asked for as they are.
/// but those it lists; whether it grants what it holds, a space's
/// collections and actions among it, `ungranted` checks.
fn holds(set: &Include, scope: &Scope) -> bool {
match scope {
Scope::Repo(r) => r.collections.iter().all(|c| set.within(c)),
Scope::Space(s) => set.nsid == SET && set.within(&s.space_type),
Scope::Space(s) => set.within(&s.space_type),
s => set.aud.as_deref().is_some_and(|a| *s == call(a)),
}
}
@@ -796,18 +795,27 @@ mod tests {
serde_json::from_slice(&std::fs::read(path).unwrap()).unwrap()
}
/// What Grain's views write into groups' pools, as `asked` asks it
/// (`space_write`): Grain's `apps/`'s Add a gallery and favorites.
const POOL: &str = "space:social.grain.group.pool?authority=*&collection=social.grain.gallery&collection=social.grain.gallery.item&collection=social.grain.photo&collection=social.grain.photo.exif&action=create&action=update&action=delete";
/// A write into a space of another namespace's type.
const OTHER_SPACE: &str = "space:com.example.forum.content?authority=*&collection=com.example.forum.post&action=create&action=update&action=delete";
/// An instance serving Grain's apps alone asks for Grain's set, which
/// holds its collections and its service's methods in its namespace,
/// and directly for what its views do outside it: the Bluesky post a
/// gallery is posted as, the pictures, and the one method of another's
/// its views call there, reporting; with the workspace, the rest of
/// what it does too. With no set named, nothing is asked first.
/// holds its collections, its spaces' writes and its service's methods
/// in its namespace, and directly for what its views do outside it:
/// the Bluesky post a gallery is posted as, the pictures, the one
/// method of another's its views call there, reporting, and a space of
/// another namespace's type; with the workspace, the rest of what it
/// does too. With no set named, nothing is asked first.
#[test]
fn permission_sets_asked_first() {
let views = grain_alone();
assert_eq!(views.sets(), [grain_set()]);
let s = asked(&views, false, false);
let first = including(&views, &s, views.sets()).unwrap();
let first_grain = first.clone();
assert_eq!(
first,
"atproto include:social.grain.authFull?aud=did:web:grain.social%23grain_appview \
@@ -831,16 +839,26 @@ mod tests {
};
assert_eq!(bare.to_string(), "include:social.grain.authFull");
assert!(!holds(&bare, &call(GRAIN)) && holds(&grain_set(), &call(GRAIN)));
// A write into a space, even of a type in its namespace (a group's
// pool), is asked for directly, beside the set.
// A write into a space of a type in its namespace (a group's pool)
// it holds too; one of another namespace's, or of any type, it
// does not.
assert!(holds(&grain_set(), &Scope::parse(POOL)));
for t in [
"repo:social.grainy.photo",
"repo:social.grain.",
"blob:image/png",
"space:social.grain.group.pool?authority=*&collection=social.grain.gallery&action=create&action=update&action=delete",
OTHER_SPACE,
"space:*?authority=*&collection=social.grain.gallery",
] {
assert!(!holds(&grain_set(), &Scope::parse(t)), "{t}");
}
// So what Grain's views write into groups' pools is asked through
// Grain's set, and another namespace's space directly, beside it.
let pooled = format!("{s} {POOL} {OTHER_SPACE}");
assert_eq!(
including(&views, &pooled, views.sets()).unwrap(),
format!("{first_grain} {OTHER_SPACE}")
);
assert!(holds(
&grain_set(),
&Scope::parse("repo:social.grain.group.item?action=delete")
@@ -864,9 +882,20 @@ mod tests {
] {
assert!(methods.contains(m), "{m}");
}
assert!(ungranted(&views, &s, &grain_set(), &grain_doc()).is_empty());
let pooled = format!("{s} {POOL}");
assert!(ungranted(&views, &pooled, &grain_set(), &grain_doc()).is_empty());
// Its space grants a pool's writes of the collections and actions
// it lists alone: not a collection it leaves out, nor reading.
let wider = [
"space:social.grain.group.pool?authority=*&collection=social.grain.story&action=create",
"space:social.grain.group.pool?authority=*&collection=social.grain.gallery&action=read_self&action=update",
];
assert_eq!(
ungranted(&views, &wider.join(" "), &grain_set(), &grain_doc()),
wider.map(|t| format!("social.grain.authFull does not grant {t}"))
);
// A set that grants less: a write's every action, a delete, a method
// listed with its audience inherited.
// listed with its audience inherited, a space's writes.
let doc = json!({ "defs": { "main": { "type": "permission-set", "permissions": [
{ "resource": "repo", "collection": ["social.grain.photo"], "action": ["create"] },
{ "resource": "repo", "collection": ["social.grain.gallery"] },
@@ -875,7 +904,7 @@ mod tests {
{ "resource": "rpc", "inheritAud": true, "lxm": ["social.grain.actor.getProfile"] },
] } } });
let deleting = format!(
"{s} repo:social.grain.story?action=delete repo:social.grain.group.item?action=delete"
"{pooled} repo:social.grain.story?action=delete repo:social.grain.group.item?action=delete"
);
let short = ungranted(&views, &deleting, &grain_set(), &doc);
let says = |t: &str| short.contains(&format!("social.grain.authFull does not grant {t}"));
@@ -885,6 +914,7 @@ mod tests {
assert!(
says("rpc:social.grain.feed.getFeed") && !says("rpc:social.grain.actor.getProfile")
);
assert!(says(POOL));
assert_eq!(
ungranted(
&views,
@@ -1025,12 +1055,13 @@ mod tests {
"{t}: {refused}"
);
}
// An app's set holds none: a view's spaces are asked for as they
// are; nor HUD's another namespace's space.
// HUD's set holds its namespace's spaces, as an app's holds its
// own's; neither another namespace's.
let hud = own(None);
let held = |set: &Include, t: &str| holds(set, &Scope::parse(t));
assert!(held(&hud, INSTANCE_SPACE_SCOPE) && !held(&hud, "space:place.hudx.thing"));
assert!(!held(&grain_set(), "space:social.grain.group.pool"));
assert!(held(&grain_set(), "space:social.grain.group.pool"));
assert!(!held(&grain_set(), INSTANCE_SPACE_SCOPE) && !held(&hud, POOL));
// A set's space naming no authority is the account's own, manages
// nothing and takes every action but `read_self`; naming only some
// actions, it grants a space asked for with every one no more.
docs/sign-in.md+9−9
@@ -59,7 +59,7 @@ HUD asks an account's server for what it does and no more, as atproto's permissi
| --- | --- |
| `repo:<collection>` | each collection a served view writes (an `Action`'s `create`, a `Compose`'s `writes`), and `place.hud.theme`, `place.hud.app` and `place.hud.app.entry` ([frame apps](frame-apps.md#entries)) where the workspace is served |
| `repo:<collection>?action=delete` | each collection a served view's `deletes` names that no served view writes ([Action](views.md#action)) |
| `space:<type>?authority=*&collection=<collection>&…&action=create&action=update&action=delete` | each type of space a served view writes into ([writing into a space](views.md#writing-into-a-space)), listing the collections it writes there, in any group's or community's space (`authority=*`): to create, update and delete them, and where one is updated (a gallery edited, at its key) `action=read_self` too, as an update reads the record first. Asked whatever `HUD_SPACES` says, and beside an app's permission sets, never through them. Grain's views posting galleries into groups' pools ask `space:social.grain.group.pool?authority=*&collection=social.grain.gallery&collection=social.grain.gallery.item&collection=social.grain.photo&action=create&action=update&action=delete`. |
| `space:<type>?authority=*&collection=<collection>&…&action=create&action=update&action=delete` | each type of space a served view writes into ([writing into a space](views.md#writing-into-a-space)), listing the collections it writes there, in any group's or community's space (`authority=*`): to create, update and delete them, and where one is updated (a gallery edited, at its key) `action=read_self` too, as an update reads the record first. Asked whatever `HUD_SPACES` says. With permission sets, a type in an app's set's namespace is asked through that set ([permission sets](#permission-sets)). Grain's views posting galleries into groups' pools ask `space:social.grain.group.pool?authority=*&collection=social.grain.gallery&collection=social.grain.gallery.item&collection=social.grain.photo&collection=social.grain.photo.exif&action=create&action=update&action=delete`. |
| `blob:<type>` | the images a composer uploads (JPEG, PNG, WebP, HEIC), where a served `Compose` has a `photos` or `card` field, and where the workspace is served a frame app's files (`text/html`, `application/json`, PNG, WebP: [publishing](frame-apps.md#publishing-and-previewing)) |
| `rpc?lxm=*&aud=<service>` | any method of each service a served view names, and each service an app file's `push` or `refresh` calls. Bluesky's AppView comes with saved feeds and interactions too. |
| `rpc:app.bsky.actor.getPreferences?aud=*` | saved feeds, where a served view draws `app.bsky.feed.getFeed` or `getFeedGenerators`. The PDS answers it itself and checks it against whichever AppView it's set up with, so the audience is any. |
@@ -70,17 +70,17 @@ HUD asks an account's server for what it does and no more, as atproto's permissi
HUD's own set grants the three `space:place.hud.*` permissions, so with the set HUD doesn't ask for them as tokens ([HUD's own set](#huds-own-set)).
Grain's instance (next.grain.social) serves Grain's apps alone. Its views write ten `social.grain.*` collections, upload photos and call Grain's AppView, so what they do is exactly this:
Grain's instance (next.grain.social) serves Grain's apps alone. Its views write a Bluesky post and eleven `social.grain.*` collections, write four into groups' pools, upload photos and call Grain's AppView and its groups' host, so what they do is exactly this:
```
atproto repo:social.grain.actor.profile repo:social.grain.comment repo:social.grain.favorite repo:social.grain.gallery repo:social.grain.gallery.item repo:social.grain.graph.block repo:social.grain.graph.follow repo:social.grain.photo repo:social.grain.photo.exif repo:social.grain.story blob:image/jpeg blob:image/png blob:image/webp blob:image/heic rpc?lxm=*&aud=did:web:grain.social%23grain_appview
atproto repo:app.bsky.feed.post repo:social.grain.actor.profile repo:social.grain.comment repo:social.grain.favorite repo:social.grain.gallery repo:social.grain.gallery.item repo:social.grain.graph.block repo:social.grain.graph.follow repo:social.grain.group.submission repo:social.grain.photo repo:social.grain.photo.exif repo:social.grain.story space:social.grain.group.pool?authority=*&collection=social.grain.gallery&collection=social.grain.gallery.item&collection=social.grain.photo&collection=social.grain.photo.exif&action=create&action=update&action=delete blob:image/jpeg blob:image/png blob:image/webp blob:image/heic rpc?lxm=*&aud=did:web:grain.social%23grain_appview rpc?lxm=*&aud=did:web:groups.grain.social%23atgrp
```
A query to a service no served view names goes as no one, and a write of a collection none writes is refused ([tools](tools.md#writes)). `/oauth/client-metadata.json` declares the whole scope, with the permission sets below and, where the workspace is served, an app's page's (any file an app takes), since an authorization server refuses a sign-in asking for anything its client didn't declare. A PDS may keep a copy of that document for a few minutes, so sign-ins can fail with `invalid_scope` for a little while after a change that adds a permission.
### Permission sets
A scope like that is fixed at sign-in. So every collection or method an app adds has everyone sign in again. An app file can name [atproto permission sets](https://atproto.com/specs/permission#permission-sets) instead (`permissions`, [the operator's views](views.md#permission-sets)). A permission set is a lexicon the app publishes, listing its collections and its methods. The account's server resolves it as the person signs in, and again as HUD refreshes their token. So a set that grows reaches people already signed in, within the day a server may keep its copy.
A scope like that is fixed at sign-in. So every collection or method an app adds has everyone sign in again. An app file can name [atproto permission sets](https://atproto.com/specs/permission#permission-sets) instead (`permissions`, [the operator's views](views.md#permission-sets)). A permission set is a lexicon the app publishes, listing its collections, its methods and the spaces of its own types it writes into. The account's server resolves it as the person signs in, and again as HUD refreshes their token. So a set that grows reaches people already signed in, within the day a server may keep its copy. A server that serves no spaces skips a set's `space` permissions as it resolves it, and grants the rest.
Where sign-in is on with the workspace, or the served apps name sets, HUD asks for them first:
@@ -88,17 +88,17 @@ Where sign-in is on with the workspace, or the served apps name sets, HUD asks f
| --- | --- |
| `include:place.hud.authFull?aud=<HUD_INDEX>` | HUD's own set ([HUD's own set](#huds-own-set)), with the workspace, its index's methods called at `HUD_INDEX` (no `?aud=` where it's unset) |
| `include:<set>?aud=<service>` | each set an app file names, its methods called at the `service` it names |
| the rest of the table above | what no set can hold: pictures (`blob:`), collections outside the set's namespace, other services, methods of the set's service outside its namespace (Grain's views report to Grain's AppView with `com.atproto.moderation.createReport`), and the spaces a served view writes into |
| the rest of the table above | what no set can hold: pictures (`blob:`), collections outside the set's namespace, other services, methods of the set's service outside its namespace (Grain's views report to Grain's AppView with `com.atproto.moderation.createReport`), and spaces of a type outside the set's namespace |
So Grain's instance asks for this, with groups left out of Grain's set until they work:
So Grain's instance asks for this, its groups' pools through Grain's set (`social.grain.authFull` grants writing Grain's collections in `social.grain.group.pool` spaces of any authority):
```
atproto include:social.grain.authFull?aud=did:web:grain.social%23grain_appview blob:image/jpeg blob:image/png blob:image/webp blob:image/heic rpc:com.atproto.moderation.createReport?aud=did:web:grain.social%23grain_appview
atproto include:social.grain.authFull?aud=did:web:grain.social%23grain_appview repo:app.bsky.feed.post blob:image/jpeg blob:image/png blob:image/webp blob:image/heic rpc:com.atproto.moderation.createReport?aud=did:web:grain.social%23grain_appview rpc?lxm=*&aud=did:web:groups.grain.social%23atgrp
```
A server that doesn't know permission sets, or can't resolve one now, refuses that request with `invalid_scope`. HUD then pushes the request again, asking for what the views do (the scope above), and the sign-in is held to that. The reference PDS, pds.js and zds all refuse so at PAR. Tranquil resolves a set only at its consent page, so a set it can't resolve fails the sign-in there, and HUD can't tell.
HUD still holds its own writes and calls to what the views do, so it uses nothing a set grants beyond that. As HUD starts, it resolves each set and logs a warning for each collection or method a view needs that the set doesn't grant (`a permission set does not grant what a view does`).
HUD still holds its own writes and calls to what the views do, so it uses nothing a set grants beyond that. As HUD starts, it resolves each set and logs a warning for each collection, space write or method a view needs that the set doesn't grant (`a permission set does not grant what a view does`), as `social.grain.authFull does not grant space:social.grain.group.pool?…` for a set that lists the pool short of a collection or an action the views write there.
A server expands a set into the permissions it lists when it grants a token, so the token's `scope` never holds the `include:`. The reference PDS resolves the set again on every refresh, keeping its copy five minutes, and tranquil keeps one a day. pds.js and zds keep the expansion made at sign-in until the person signs in again. So when a PDS refuses a call for want of scope, HUD refreshes the token and tries once more. A sign-in that asked for a set more than a day ago and is still refused signs in again, for the set as it is now.
@@ -110,7 +110,7 @@ HUD publishes its own set, `place.hud.authFull` (`schemas/place.hud.authFull.jso
- making, changing and deleting spaces of HUD's types, and reading and writing in anyone's they're in: canvases (`place.hud.workspace`), chats (`place.hud.chat`) and [private instances](frame-apps.md#private-instances) of apps (`place.hud.app.instance`), any authority, to manage create, update and delete
- calling HUD's index (`place.hud.index.query`, `place.hud.index.getStatus`) at the service its include names
So the scope with the workspace asks for the set in place of those `repo:place.hud.*` permissions, in place of `rpc?lxm=*&aud=<HUD_INDEX>` where a served view calls the index there, and in place of the `space:place.hud.*` permissions with `HUD_SPACES=on`. A collection or method HUD adds goes into the set, and reaches signed-in accounts as their tokens are refreshed, so nobody signs in again for it. A server that serves no spaces skips the set's `space` permissions as it resolves it, and grants the rest.
So the scope with the workspace asks for the set in place of those `repo:place.hud.*` permissions, in place of `rpc?lxm=*&aud=<HUD_INDEX>` where a served view calls the index there, and in place of the `space:place.hud.*` permissions with `HUD_SPACES=on`. A collection or method HUD adds goes into the set, and reaches signed-in accounts as their tokens are refreshed, so nobody signs in again for it.
A server that refuses sets gets the explicit scope above, `repo:place.hud.*` permissions and the index's `rpc` among them, and with `HUD_SPACES=on` the three `space:place.hud.*` tokens. HUD embeds its set as it embeds its lexicons, and refuses to start if the set doesn't grant a `place.hud.*` collection the scope writes or an index method a served view calls (`HUD's own permission set does not grant what HUD does: …`). With sign-in off, or `HUD_WORKSPACE=off`, HUD asks for no set of its own.
docs/views.md+8−5
@@ -2472,15 +2472,18 @@ for in place of the permissions its views' collections and methods would each ta
]
```
The set is a lexicon the app publishes (`type: permission-set`), listing its `repo` collections
and the `rpc` methods it calls, each with `inheritAud: true`. Its `service` is the audience those
The set is a lexicon the app publishes (`type: permission-set`), listing its `repo` collections,
the `rpc` methods it calls, each with `inheritAud: true`, and the `space` permissions its views
[write into spaces](#writing-into-a-space) by (Grain's, its collections in `social.grain.group.pool`
spaces of any authority, to create, update and delete). Its `service` is the audience those
methods take, so HUD asks for `include:social.grain.authFull?aud=did:web:grain.social%23grain_appview`.
A set may only list NSIDs under its own namespace (`social.grain.` for Grain's), so HUD asks for
what the views do outside it, and their pictures, directly.
what the views do outside it, their pictures and their writes into another namespace's spaces,
directly.
A set's contents are the app's to keep up. As HUD starts, it resolves each set and logs what a
view writes, deletes or calls that the set doesn't grant. Grain's `next/check-apps.mjs` checks the
same against its own copy of the set.
view writes (in the account's repository or a space), deletes or calls that the set doesn't grant.
Grain's `next/check-apps.mjs` checks the same against its own copy of the set.
### Account setup
harness/pds.mjs+10−8
@@ -19,8 +19,9 @@
// names one, so the PDS is told an authority for every NSID (its
// PDS_LEXICON_AUTHORITY_DID): `lexicons.test`, an account of its own,
// which publishes HUD's own permission set and space types (schemas/) and
// the permission sets of the operator's apps the harnesses serve
// (crates/hud-core/src/testdata/grain: Grain's), read from its own
// the permission sets and space types of the operator's apps the harnesses
// serve (crates/hud-core/src/testdata/grain: Grain's, with the group pool
// its set grants), read from its own
// repository. A flow republishes one to change it; the PDS keeps a lexicon
// it resolved five minutes, which a flow can age in `db`'s `lexicon` table.
//
@@ -121,8 +122,10 @@ async function migrateOnce() {
/// The account that publishes the lexicons the PDS resolves, made on it,
/// and the PDS told it is the authority of every NSID; each permission set
/// under crates/hud-core/src/testdata, and HUD's own set and space types
/// (schemas/), published as its `com.atproto.lexicon.schema` record. Its
/// and space type under crates/hud-core/src/testdata (Grain's set, and the
/// group pool its `space` permission names, which the spaces alpha resolves
/// as it grants the set), and HUD's own set and space types (schemas/),
/// published as its `com.atproto.lexicon.schema` record. Its
/// `{ handle, did, password }`.
async function publishLexicons(net) {
const password = 'password';
@@ -139,10 +142,9 @@ async function publishLexicons(net) {
e.isDirectory() ? files(join(dir, e.name)) : e.name.endsWith('.json') ? [join(dir, e.name)] : []
);
const read = (file) => JSON.parse(readFileSync(file, 'utf8'));
const sets = files(join(root, 'crates/hud-core/src/testdata'))
.map(read)
.filter((doc) => doc.defs?.main?.type === 'permission-set');
if (sets.length === 0) throw new Error('no permission sets under crates/hud-core/src/testdata');
const published = (doc) => ['permission-set', 'space'].includes(doc.defs?.main?.type);
const sets = files(join(root, 'crates/hud-core/src/testdata')).map(read).filter(published);
if (!sets.some((doc) => doc.defs.main.type === 'permission-set')) throw new Error('no permission sets under crates/hud-core/src/testdata');
const schemas = join(root, 'schemas');
const hud = readdirSync(schemas)
.filter((file) => file.endsWith('.json'))