accountOf
Who a DID is, as the server finds it: their handle, checked both ways.
import { isDid, resolve } from "#codebase/tcmts/atproto"; import type { Account } from "#codebase/tcmts/atproto"; import { HttpError } from "#codebase/tcmts/atproto/lib/server"; export async function accountOf(did: string): Promise<Account> { if (!isDid(did)) throw new HttpError(400, "That isn't a DID."); const id = await resolve(did).catch(() => undefined); return { did, ...(id?.handle ? { handle: id.handle } : {}) }; }