WIP! A BB-style forum, on the ATmosphere!
We're still working... we'll be back soon when we have something to show off!
node
typescript
hono
htmx
atproto
1import { AtpAgent } from "@atproto/api";
2
3export interface ResolvedIdentity {
4 did: string;
5 handle?: string;
6}
7
8/**
9 * Resolve a handle or DID string to a confirmed DID.
10 * If the input already starts with "did:", returns it directly.
11 * Otherwise, treats it as a handle and resolves via the PDS.
12 */
13export async function resolveIdentity(
14 input: string,
15 pdsUrl: string
16): Promise<ResolvedIdentity> {
17 if (input.startsWith("did:")) {
18 return { did: input };
19 }
20
21 const agent = new AtpAgent({ service: pdsUrl });
22 const res = await agent.resolveHandle({ handle: input });
23 return { did: res.data.did, handle: input };
24}