testAnAppsClientDocument
An app's OAuth client document is where it's served, comes back to the app's home (under its base, the client's path taken off), and asks for the app's scope, and, told to its server, a token for that server too.
import { askedScope, atprotoClient, repo, scope, SIGN_IN_LXM } from "#codebase/tcmts/atproto"; import assert from "node:assert/strict"; export const testAnAppsClientDocument = () => { const plain = atprotoClient({ name: "Notes", scope: scope(repo("app.notes.note")) }); const doc = plain(new Request("https://notes.example/app/oauth/client")); assert.equal(doc.client_id, "https://notes.example/app/oauth/client"); assert.deepEqual(doc.redirect_uris, ["https://notes.example/app/"]); assert.equal(doc.client_uri, "https://notes.example/app/"); assert.equal(doc.scope, "atproto repo:app.notes.note"); assert.equal(doc.dpop_bound_access_tokens, true); const told = atprotoClient({ name: "Forge", scope: "atproto", client: "/api/oauth/client", server: true, }); const d = told(new Request("https://tcm.example/forge/api/oauth/client")); assert.deepEqual(d.redirect_uris, ["https://tcm.example/forge/"]); assert.equal(d.scope, `atproto rpc:${SIGN_IN_LXM}?aud=*`); assert.equal(askedScope({ scope: "atproto" }), "atproto"); }