social components inlay.at
atproto components sdui
86
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 46 lines 1.1 kB view raw
1import "server-only"; 2import { cacheLife, cacheTag } from "next/cache"; 3import { LexResolver, type LexiconDocument } from "@atproto/lex-resolver"; 4 5export type { LexiconDocument }; 6 7const resolver = new LexResolver({}); 8 9/** 10 * Resolve the DID that owns a lexicon namespace via DNS TXT lookup. 11 * Returns null if no DNS record is found (unclaimed namespace). 12 */ 13export async function resolveNamespaceOwner( 14 nsid: string 15): Promise<string | null> { 16 "use cache"; 17 cacheLife("hours"); 18 cacheTag(`lexicon-authority:${nsid}`); 19 20 try { 21 const uri = await resolver.resolve(nsid); 22 // AtUri.host is the authority DID 23 return uri.host; 24 } catch { 25 return null; 26 } 27} 28 29/** 30 * Resolve lexicon via network with signature verification. 31 * Only published lexicons are resolvable. 32 */ 33export async function resolveLexicon( 34 nsid: string 35): Promise<LexiconDocument | null> { 36 "use cache"; 37 cacheLife("hours"); 38 cacheTag(`lexicon:${nsid}`); 39 40 try { 41 const { lexicon } = await resolver.get(nsid); 42 return lexicon; 43 } catch { 44 return null; 45 } 46}