tcm-ts.txt / code
tcm . hub . session
Types
HubSession
Server
codebaseHere
signedInHere
Browser
clientMetadata
configure
finishSignIn
hubSession
hubSignOut
resumeSession
startSignIn
Shared
COMING_BACK
HUB_SCOPE
SIGNED_IN
comingBack
configured
oauthSession
pageSession
tcmts.hub.session
Types
HubSession type Someone signed in: who, and how to call their PDS as them.
Server
codebaseHere (url: string) => Promise<void> Tell the hub the codebase whose libraries are "Libraries I use" (a `tcm serve` URL), or none.
signedInHere (did: string | undefined) => Promise<void> Tell the hub 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 hub serves. Either comes back to the hub'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 hub, and go back to the page it started from. Throws what went wrong, if it didn't work.
hubSession () => Promise<HubSession | undefined> Who this browser is signed in as, if anyone (asked once per page).
hubSignOut () => Promise<void> Sign out: here, on the account's server, and to the hub; the page is shown again, as anyone's.
resumeSession () => Promise<HubSession | 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 hub's home, which finishes it (`finishSignIn`).
Shared
COMING_BACK "tcm-hub.back" Where the page to come back to is kept while signing in.
HUB_SCOPE "atproto repo:codes.tcm.star" What the hub asks to write: stars, and nothing else.
SIGNED_IN "tcm-hub.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 hub's to say (`hubServices`).
oauthSession (s: Session) => HubSession A session from the OAuth library's.
pageSession { current?: Promise<HubSession | undefined> | undefined; } This page's session, found once: kept from before, if there is one.