Attic is a cozy space with lofty ambitions. attic.social
at main 28 lines 762 B view raw
1import { 2 CompositeDidDocumentResolver, 3 PlcDidDocumentResolver, 4 WebDidDocumentResolver, 5} from "@atcute/identity-resolver"; 6import type { Did } from "@atcute/lexicons"; 7 8const didResolver = new CompositeDidDocumentResolver({ 9 methods: { 10 plc: new PlcDidDocumentResolver(), 11 web: new WebDidDocumentResolver(), 12 }, 13}); 14 15export const resolvePDS = async (did: Did): Promise<URL | null> => { 16 try { 17 const document = await didResolver.resolve(did as Did<"plc"> | Did<"web">); 18 if (Array.isArray(document.service) === false) { 19 return null; 20 } 21 for (const service of document.service) { 22 if (service.id === "#atproto_pds") { 23 return URL.parse(service.serviceEndpoint.toString()); 24 } 25 } 26 } catch {} 27 return null; 28};