chadtmiller.com/monolith
An atproto PDS
0
0
// Sessions and the server: getSession and describeServer
// (spec/ACCOUNTS.md). createSession is in accounts.mjs.
import { rand } from '../lib/random.mjs'
import { cand } from '../lib/processes.mjs'
import { differ } from '../lib/report.mjs'
import { own } from '../lib/server.mjs'
import { both, normalize } from '../lib/xrpc.mjs'
/// getSession with the account's token, none, or one never given out,
/// compared whole, its DID named alike (spec/ACCOUNTS.md, "Sessions").
export async function getSession(acct) {
const r = rand()
const token = r < 0.6 ? acct : r < 0.8 ? undefined : 'never-given-out'
await both('getSession', 'com.atproto.server.getSession', { token })
}
/// describeServer, of which `did`, `availableUserDomains` and
/// `inviteCodeRequired` are compared (spec/ACCOUNTS.md, "Environment").
/// Monolith must also answer `spacesAlpha: true` (spec/SPACES.md,
/// "describeServer"), which the `latest` reference does not, so it is held
/// to that and not compared; another implementation is not held to it
/// (spec/COMPAT.md).
export async function describeServer() {
const [, b] = await both('describeServer', 'com.atproto.server.describeServer', {})
if (own() && b.status === 200 && b.body?.spacesAlpha !== true) await differ('describeServer spacesAlpha', {}, true, b.body?.spacesAlpha ?? normalize(cand, b, 'com.atproto.server.describeServer'), 'held to spec/SPACES.md, not to the reference')
}