porting all github actions from bluesky-social/indigo to tangled CI
at main 808 B view raw
1package identity 2 3import ( 4 "context" 5 "errors" 6 "fmt" 7 "net" 8 9 "github.com/bluesky-social/indigo/atproto/syntax" 10) 11 12var ( 13 ErrNSIDResolutionFailed = fmt.Errorf("NSID resolution mechanism failed") 14 ErrNSIDNotFound = fmt.Errorf("NSID not associated with a DID") 15) 16 17// Resolves an NSID to a DID, as used for Lexicon resolution (using "_lexicon" DNS TXT record) 18func (d *BaseDirectory) ResolveNSID(ctx context.Context, nsid syntax.NSID) (syntax.DID, error) { 19 20 domain := nsid.Authority() 21 res, err := d.Resolver.LookupTXT(ctx, "_lexicon."+domain) 22 23 // check for NXDOMAIN 24 var dnsErr *net.DNSError 25 if errors.As(err, &dnsErr) { 26 if dnsErr.IsNotFound { 27 return "", ErrNSIDNotFound 28 } 29 } 30 31 if err != nil { 32 return "", fmt.Errorf("%w: %w", ErrNSIDResolutionFailed, err) 33 } 34 35 return parseTXTResp(res) 36}