+2
atproto/identity/base_directory.go
+2
atproto/identity/base_directory.go
···
33
33
//
34
34
// The intended use-case for this flag is as an optimization for services which do not care about handles, but still want to use the `Directory` interface (instead of `ResolveDID`). For example, relay implementations, or services validating inter-service auth requests.
35
35
SkipHandleVerification bool
36
+
// User-Agent header for HTTP requests. Optional (ignored if empty string).
37
+
UserAgent string
36
38
}
37
39
38
40
var _ Directory = (*BaseDirectory)(nil)
+8
atproto/identity/did.go
+8
atproto/identity/did.go
···
98
98
if err != nil {
99
99
return nil, fmt.Errorf("constructing HTTP request for did:web resolution: %w", err)
100
100
}
101
+
if d.UserAgent != "" {
102
+
req.Header.Set("User-Agent", d.UserAgent)
103
+
}
104
+
101
105
resp, err := d.HTTPClient.Do(req)
102
106
103
107
// look for NXDOMAIN
···
143
147
if err != nil {
144
148
return nil, fmt.Errorf("constructing HTTP request for did:plc resolution: %w", err)
145
149
}
150
+
if d.UserAgent != "" {
151
+
req.Header.Set("User-Agent", d.UserAgent)
152
+
}
153
+
146
154
resp, err := d.HTTPClient.Do(req)
147
155
if err != nil {
148
156
return nil, fmt.Errorf("%w: PLC directory lookup: %w", ErrDIDResolutionFailed, err)
+3
atproto/identity/directory.go
+3
atproto/identity/directory.go
···
8
8
"time"
9
9
10
10
"github.com/bluesky-social/indigo/atproto/syntax"
11
+
12
+
"github.com/carlmjohnson/versioninfo"
11
13
)
12
14
13
15
// Ergonomic interface for atproto identity lookup, by DID or handle.
···
80
82
TryAuthoritativeDNS: true,
81
83
// primary Bluesky PDS instance only supports HTTP resolution method
82
84
SkipDNSDomainSuffixes: []string{".bsky.social"},
85
+
UserAgent: "indigo-identity/" + versioninfo.Short(),
83
86
}
84
87
cached := NewCacheDirectory(&base, 250_000, time.Hour*24, time.Minute*2, time.Minute*5)
85
88
return &cached
+3
atproto/identity/handle.go
+3
atproto/identity/handle.go