this repo has no description
0
fork

Configure Feed

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

atproto/identity: add PublicKeyFor method (#611)

For labelers we need to specify which service public key we grab.

authored by

Jake Gold and committed by
GitHub
b4f57855 8da1d947

+16 -1
+16 -1
atproto/identity/identity.go
··· 167 167 if i.Keys == nil { 168 168 return nil, fmt.Errorf("identity has no atproto public key attached") 169 169 } 170 - k, ok := i.Keys["atproto"] 170 + return i.PublicKeyFor("atproto") 171 + } 172 + 173 + // Identifies and parses a specified service signing public key, specifically, out of any keys associated with this identity. 174 + // 175 + // Returns [ErrKeyNotFound] if there is no such key. 176 + // 177 + // Note that [crypto.PublicKey] is an interface, not a concrete type. 178 + func (i *Identity) PublicKeyFor(forKey string) (crypto.PublicKey, error) { 179 + if i.ParsedPublicKey != nil { 180 + return i.ParsedPublicKey, nil 181 + } 182 + if i.Keys == nil { 183 + return nil, fmt.Errorf("identity has no atproto public key attached") 184 + } 185 + k, ok := i.Keys[forKey] 171 186 if !ok { 172 187 return nil, ErrKeyNotDeclared 173 188 }