Lanyards is a dedicated profile for researchers, built on the AT Protocol.
at main 36 lines 743 B view raw
1import { AtpAgent } from '@atproto/api'; 2import { getSession } from './session'; 3 4export async function getAgent(): Promise<AtpAgent | null> { 5 const session = await getSession(); 6 7 if (!session) { 8 return null; 9 } 10 11 const agent = new AtpAgent({ 12 service: 'https://bsky.social', 13 }); 14 15 // Resume session 16 await agent.resumeSession({ 17 did: session.did, 18 handle: session.handle, 19 accessJwt: session.accessToken, 20 refreshJwt: session.refreshToken, 21 active: true, 22 }); 23 24 return agent; 25} 26 27export async function getProfile(did: string) { 28 const agent = await getAgent(); 29 30 if (!agent) { 31 throw new Error('Not authenticated'); 32 } 33 34 const profile = await agent.getProfile({ actor: did }); 35 return profile.data; 36}