chadtmiller.com/group-host
atmosphere group host
Joining a group
An app that joins a group for a person, as the person's own app: the side of a group that reading a group doesn't see. Signed in to the person's own PDS, it:
- makes their inbox,
at:space/<them>/org.atgrp.inbox/self, a space of their own that any group may write an invite in and only they read, or finds the one they have; - reads the invite the group wrote there, if it sent one;
- asks the group's host to let them in (
org.atgrp.requestJoin), through their own PDS, which signs the call as them and sends it on; - once they're in, confirms the membership with an
org.atgrp.confirmationin their own repo in the group's members space, at their own PDS.
A live invite lets them in whatever the group's join policy. Otherwise a
group that takes requests (approval) keeps theirs waiting, with their
message, for its admins, and an invite-only group refuses it
(JoinClosed).
It is one file, main.ts, on atproto's own TypeScript packages, from the
spaces alpha the host runs against:
@atproto/oauth-client-nodesigns the person in at their own PDS: the loopback clienthttp://localhost, an app on this machine.@atproto/lexcalls the host'sorg.atgrp.requestJoin, typed by the schemas underlexicons/at the top of this repository, sent to the host's#atgrpservice through the PDS (theatproto-proxyheader).@atproto/lex-spacemakes the inbox, reads the group's invite there with a credential their PDS gives for their delegation token, and writes the confirmation.
Membership says what the host does on its side.
Running it
It needs Node at the version .node-version names, which runs main.ts
as it is.
cd examples/join-a-group
npm install
npm start <your handle> <group handle or DID> [message to the group]
It prints a link to the person's PDS. Sign in there and allow the app, and the browser comes back to it. Asked of a group that takes requests, with no invite:
Signed in as did:plc:atldqeavl57gbxg4q6zrnigb
Made your inbox, where groups write their invites
Asked to join did:plc:fycrfwtr6yn64r3u6afr5dtg: waiting for its admins.
and again, once the group has invited them:
Signed in as did:plc:atldqeavl57gbxg4q6zrnigb
did:plc:fycrfwtr6yn64r3u6afr5dtg invited you: Ride with us on Sunday.
Joined did:plc:fycrfwtr6yn64r3u6afr5dtg, and confirmed it.
An invite sent before the person had an inbox isn't in it, as the host had nowhere to write it, but the host keeps its own list of invites, so asking to join is let in all the same. Reading the group afterwards with read-a-group shows them as members, confirmed.
What the app asks of the person:
| Scope | For |
|---|---|
space:org.atgrp.inbox?action=read&manage=create | making their inbox, and reading what groups wrote there |
space:org.atgrp.members?authority=*&collection=org.atgrp.confirmation&action=create | writing their confirmation in any group's members space |
rpc:org.atgrp.requestJoin?aud=* | asking a group's host to let them in |
A group host's own permission set,
include:org.atgrp.authParticipate, holds these and the rest of what a
person does in a group (withdrawing a request, leaving, declining an
invite, reporting, appealing), where the person's PDS can read its
lexicon.
On just dev
just dev runs a PDS and a host on a network of their own, with a PLC
directory of their own, on http. Name the directory, and the PDS to
resolve handles, from what it prints:
PLC_URL=<the directory> HANDLE_RESOLVER=<the PDS> npm start alice.test hikers.groups.localtest.me
Hikers, bob's group, has invited alice. Signing in as alice.test with
the password password makes her inbox and lets her in.
What it leaves out
- The members space type is declared in
main.tswithl.space(...), naming the collection it writes, rather than generated: the alpha'slex buildmakes a space type of several collections that TypeScript cannot type, sonpm run lexleavesorg.atgrp.metaandorg.atgrp.membersout. Fixed upstream by bluesky-social/atproto#6085. - It doesn't name the invite it read (
requestJoin'sinvite): a live invite from the group lets them in without it. - It leaves the rest of what a person does to the host's methods the
permission set lists:
cancelJoinRequest,leaveGroup,org.atgrp.internal.declineInvite, and the moderation methods.