GoAT Site is library that implements Standard.site in Go.
atprotocol standard-site atproto library
1
fork

Configure Feed

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

docs(info): example to use verify

+32 -17
+23 -1
README.md
··· 27 27 - `UpdateRecord[*site.Subscription]` to update a subscription; 28 28 - `DeleteRecord[*site.Publication]` to delete a publication. 29 29 30 - You can [verify](https://standard.site/docs/verification/) a publication with `Publication.Verify`. 30 + You can [verify](https://standard.site/docs/verification/) a publication with `Publication.Verify` and a document with 31 + `Document.Verify`: 32 + ```go 33 + var pub *site.Publication 34 + var client *atclient.APIClient 35 + valid, err := pub.Verify(context.Background(), client, "did:plc:123", "pub_rkey") 36 + if err != nil { 37 + panic(err) 38 + } 39 + if !valid { 40 + println("invalid publication :(") 41 + } 42 + 43 + var doc *site.Document 44 + url, err := doc.PublicationURL(context.Background(), client.Client) 45 + if err != nil { 46 + panic(err) 47 + } 48 + valid, err = doc.Verify(context.Background(), client, "did:plc:123", "doc_rkey") 49 + if !valid { 50 + panic("invalid document :(") 51 + } 52 + ``` 31 53 32 54 ## Creating custom records 33 55
+3 -3
document_test.go
··· 7 7 "testing" 8 8 "time" 9 9 10 + "github.com/bluesky-social/indigo/atproto/atclient" 10 11 "github.com/bluesky-social/indigo/atproto/syntax" 11 - lexutil "github.com/bluesky-social/indigo/lex/util" 12 12 site "tangled.org/anhgelus.world/goat-site" 13 13 ) 14 14 ··· 79 79 80 80 var ( 81 81 docURI syntax.ATURI 82 - docClient *lexutil.LexClient 82 + docClient *atclient.APIClient 83 83 ) 84 84 85 85 func TestGetDocument(t *testing.T) { ··· 137 137 } 138 138 valid, err := doc.Verify( 139 139 context.Background(), 140 - httpClient(client), 140 + client.Client, 141 141 pubURL, 142 142 uri.Authority(), 143 143 uri.RecordKey(),
+6 -13
publication_test.go
··· 3 3 import ( 4 4 "context" 5 5 "encoding/json" 6 - "net/http" 7 6 "testing" 8 7 9 8 "github.com/bluesky-social/indigo/atproto/atclient" 10 9 "github.com/bluesky-social/indigo/atproto/identity" 11 10 "github.com/bluesky-social/indigo/atproto/syntax" 12 - lexutil "github.com/bluesky-social/indigo/lex/util" 13 11 site "tangled.org/anhgelus.world/goat-site" 14 12 ) 15 13 ··· 134 132 135 133 var ( 136 134 pubURI syntax.ATURI 137 - pubClient *lexutil.LexClient 135 + pubClient *atclient.APIClient 138 136 ) 139 137 140 - func getClient(t *testing.T, test string, uri *syntax.ATURI, client **lexutil.LexClient) (syntax.ATURI, lexutil.LexClient) { 138 + func getClient(t *testing.T, test string, uri *syntax.ATURI, client **atclient.APIClient) (syntax.ATURI, *atclient.APIClient) { 141 139 var err error 142 140 defer func() { 143 141 if err == nil { ··· 145 143 } 146 144 }() 147 145 if *client != nil { 148 - return *uri, **client 146 + return *uri, *client 149 147 } 150 148 dir := identity.DefaultDirectory() 151 149 *uri, err = syntax.ParseATURI(test) ··· 158 156 t.Fatal(err) 159 157 } 160 158 t.Log("using", id.PDSEndpoint(), "for", test) 161 - c := lexutil.LexClient(atclient.NewAPIClient(id.PDSEndpoint())) 162 - *client = &c 163 - return *uri, **client 164 - } 165 - 166 - func httpClient(client lexutil.LexClient) *http.Client { 167 - return client.(*atclient.APIClient).Client 159 + *client = atclient.NewAPIClient(id.PDSEndpoint()) 160 + return *uri, *client 168 161 } 169 162 170 163 func TestGetPublication(t *testing.T) { ··· 224 217 if err != nil { 225 218 t.Fatal(err) 226 219 } 227 - v, err := pub.Verify(context.Background(), httpClient(client), id.Authority(), id.RecordKey()) 220 + v, err := pub.Verify(context.Background(), client.Client, id.Authority(), id.RecordKey()) 228 221 if err != nil { 229 222 t.Fatal(err) 230 223 }