takeSignIn
uses tcmts.atproto.serviceAudiences, which uses process
Sign the caller in to the app's server as the account a service-auth token is from: checked for this server
(#ga5isctt) and SIGN_IN_LXM, then kept in the caller's server session for 30 days
(account says who). Who it is.
import { accountOf, serviceAudiences, SIGN_IN_LXM, verifyServiceAuth } from "#codebase/tcmts/atproto"; import type { Account } from "#codebase/tcmts/atproto"; import { HttpError, session, setSession } from "#codebase/tcmts/atproto/lib/server"; export async function takeSignIn(jwt: string): Promise<Account> { const audiences = serviceAudiences(); if (!audiences.length) throw new HttpError( 500, "This server doesn't know its own address, so it can't check a sign-in: set ATPROTO_SERVICE_URL.", ); let did: string; try { did = await verifyServiceAuth(jwt, { audiences, lxm: SIGN_IN_LXM }); } catch (e) { throw new HttpError(401, `Signing in didn't check: ${(e as Error).message}`); } const who = await accountOf(did); setSession({ ...session(), atproto: who }); return who; }
uses
- tcmts.atproto.Account
- tcmts.atproto.SIGN_IN_LXM
- tcmts.atproto.accountOf
- tcmts.atproto.lib.server.HttpError
- tcmts.atproto.lib.server.session
- tcmts.atproto.lib.server.setSession
- tcmts.atproto.serviceAudiences
- tcmts.atproto.verifyServiceAuth