tcmts.registry.session

Types

RegistrySession type
Someone signed in: who, and how to call their PDS as them.

Server

codebaseHere (url: string) => Promise<void>
Tell the registry the codebase whose libraries are "Libraries I use" (a `tcm serve` URL), or none.
signedInHere (did: string | undefined) => Promise<void>
Tell the registry who this browser is signed in as (or that nobody is), for the pages it renders.

Browser

clientMetadata () => { client_id: string; redirect_uri: string; }
The OAuth client this page is: the loopback one on localhost, else the metadata document the registry serves. Either comes back to the registry's home, which finishes signing in and goes back to the page it started from.
configure () => Promise<void>
Set up the OAuth client, once per page.
finishSignIn () => Promise<boolean>
If the page was opened coming back from signing in (its fragment holds the answer), finish signing in, tell the registry, and go back to the page it started from. Throws what went wrong, if it didn't work.
registrySession () => Promise<RegistrySession | undefined>
Who this browser is signed in as, if anyone (asked once per page).
registrySignOut () => Promise<void>
Sign out: here, on the account's server, and to the registry; the page is shown again, as anyone's.
resumeSession () => Promise<RegistrySession | undefined>
The session kept from a visit before, if there is one and it still works.
startSignIn (handle: string) => Promise<void>
Send the browser to sign in as `handle`; it comes back to the registry's home, which finishes it (`finishSignIn`).

Shared

COMING_BACK "tcm-registry.back"
Where the page to come back to is kept while signing in.
REGISTRY_SCOPE "atproto repo:codes.tcm.star"
What the registry asks to write: stars, and nothing else.
SIGNED_IN "tcm-registry.did"
Where the signed-in DID is kept between visits (the tokens are kept by the OAuth library).
comingBack (kept: string | null, fallback: string) => string
Where to go back to after signing in: the page it started from, if it's a path of this site (not `//elsewhere` nor `/\elsewhere`, which a browser takes for another site), else `fallback`.
configured { done?: Promise<void> | undefined; }
OAuth set up on this page, once: where it resolves handles and DIDs is the registry's to say (`registryServices`).
oauthSession (s: Session) => RegistrySession
A session from the OAuth library's.
pageSession { current?: Promise<RegistrySession | undefined> | undefined; }
This page's session, found once: kept from before, if there is one.