this repo has no description
0
fork

Configure Feed

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

rename some indigo:atproto/* packages (#1169)

Closes: https://github.com/bluesky-social/indigo/issues/1167

authored by

bnewbold and committed by
GitHub
a5b28160 3bc289db

+156 -156
+2 -2
HACKING.md
··· 26 26 - `api/bsky`: generated types for `app.bsky` lexicon 27 27 - `api/chat`: generated types for `chat.bsky` lexicon 28 28 - `api/ozone`: generated types for `tools.ozone` lexicon 29 - - `atproto/crypto`: cryptographic helpers (signing, key generation and serialization) 29 + - `atproto/atcrypto`: cryptographic helpers (signing, key generation and serialization) 30 30 - `atproto/syntax`: string types and parsers for identifiers, datetimes, etc 31 31 - `atproto/identity`: DID and handle resolution 32 - - `atproto/data`: helpers for atproto data as JSON or CBOR with unknown schema 32 + - `atproto/atdata`: helpers for atproto data as JSON or CBOR with unknown schema 33 33 - `atproto/lexicon`: lexicon validation of generic data 34 34 - `atproto/repo`: repo and MST implementation 35 35 - `automod`: moderation and anti-spam rules engine
+1 -1
README.md
··· 25 25 | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | 26 26 | `api/atproto`: generated types for `com.atproto.*` Lexicons | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/api/atproto)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/api/atproto) | 27 27 | `api/bsky`: generated types for `app.bsky.*` Lexicons | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/api/bsky)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/api/bsky) | 28 - | `atproto/crypto`: crytographic signing and key serialization | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/atproto/crypto)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/atproto/crypto) | 28 + | `atproto/atcrypto`: crytographic signing and key serialization | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/atproto/atcrypto)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/atproto/atcrypto) | 29 29 | `atproto/identity`: DID and handle resolution | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/atproto/identity)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/atproto/identity) | 30 30 | `atproto/syntax`: string types and parsers for identifiers | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/atproto/syntax)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/atproto/syntax) | 31 31 | `atproto/lexicon`: schema validation of data | [![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/bluesky-social/indigo/atproto/lexicon)](https://pkg.go.dev/mod/github.com/bluesky-social/indigo/atproto/lexicon) |
+2 -2
atproto/auth/http_test.go
··· 6 6 "testing" 7 7 "time" 8 8 9 - "github.com/bluesky-social/indigo/atproto/crypto" 9 + "github.com/bluesky-social/indigo/atproto/atcrypto" 10 10 "github.com/bluesky-social/indigo/atproto/identity" 11 11 "github.com/bluesky-social/indigo/atproto/syntax" 12 12 ··· 78 78 aud := "did:example:aud#svc" 79 79 lxm := syntax.NSID("com.example.api") 80 80 81 - priv, err := crypto.GeneratePrivateKeyP256() 81 + priv, err := atcrypto.GeneratePrivateKeyP256() 82 82 require.NoError(err) 83 83 pub, err := priv.PublicKey() 84 84 require.NoError(err)
+5 -5
atproto/auth/jwt.go
··· 9 9 "log/slog" 10 10 "time" 11 11 12 - "github.com/bluesky-social/indigo/atproto/crypto" 12 + "github.com/bluesky-social/indigo/atproto/atcrypto" 13 13 "github.com/bluesky-social/indigo/atproto/identity" 14 14 "github.com/bluesky-social/indigo/atproto/syntax" 15 15 ··· 122 122 return base64.RawURLEncoding.EncodeToString(buf) 123 123 } 124 124 125 - func SignServiceAuth(iss syntax.DID, aud string, ttl time.Duration, lexMethod *syntax.NSID, priv crypto.PrivateKey) (string, error) { 125 + func SignServiceAuth(iss syntax.DID, aud string, ttl time.Duration, lexMethod *syntax.NSID, priv atcrypto.PrivateKey) (string, error) { 126 126 claims := serviceAuthClaims{ 127 127 RegisteredClaims: jwt.RegisteredClaims{ 128 128 ExpiresAt: jwt.NewNumericDate(time.Now().Add(ttl)), ··· 138 138 139 139 var sm *signingMethodAtproto 140 140 141 - // NOTE: could also have a crypto.PrivateKey.Alg() method which returns a string 141 + // NOTE: could also have a atcrypto.PrivateKey.Alg() method which returns a string 142 142 switch priv.(type) { 143 - case *crypto.PrivateKeyP256: 143 + case *atcrypto.PrivateKeyP256: 144 144 sm = signingMethodES256 145 - case *crypto.PrivateKeyK256: 145 + case *atcrypto.PrivateKeyK256: 146 146 sm = signingMethodES256K 147 147 default: 148 148 return "", fmt.Errorf("unknown signing key type: %T", priv)
+2 -2
atproto/auth/jwt_signing.go
··· 3 3 import ( 4 4 "crypto" 5 5 6 - atcrypto "github.com/bluesky-social/indigo/atproto/crypto" 6 + "github.com/bluesky-social/indigo/atproto/atcrypto" 7 7 "github.com/golang-jwt/jwt/v5" 8 8 ) 9 9 ··· 13 13 supportedAlgs []string 14 14 ) 15 15 16 - // Implementation of jwt.SigningMethod for the `atproto/crypto` types. 16 + // Implementation of jwt.SigningMethod for the `atproto/atcrypto` types. 17 17 type signingMethodAtproto struct { 18 18 alg string 19 19 hash crypto.Hash
+7 -7
atproto/auth/jwt_test.go
··· 6 6 "testing" 7 7 "time" 8 8 9 - "github.com/bluesky-social/indigo/atproto/crypto" 9 + "github.com/bluesky-social/indigo/atproto/atcrypto" 10 10 "github.com/bluesky-social/indigo/atproto/identity" 11 11 "github.com/bluesky-social/indigo/atproto/syntax" 12 12 ··· 19 19 return time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) 20 20 } 21 21 22 - func validateMinimal(token string, iss, aud string, pub crypto.PublicKey) error { 22 + func validateMinimal(token string, iss, aud string, pub atcrypto.PublicKey) error { 23 23 24 24 p := jwt.NewParser( 25 25 jwt.WithValidMethods(supportedAlgs), ··· 71 71 72 72 for _, fix := range jwtTestFixtures { 73 73 74 - pubk, err := crypto.ParsePublicDIDKey(fix.pubkey) 74 + pubk, err := atcrypto.ParsePublicDIDKey(fix.pubkey) 75 75 if err != nil { 76 76 t.Fatal(err) 77 77 } ··· 80 80 } 81 81 } 82 82 83 - func testSigningValidation(t *testing.T, priv crypto.PrivateKey) { 83 + func testSigningValidation(t *testing.T, priv atcrypto.PrivateKey) { 84 84 assert := assert.New(t) 85 85 ctx := context.Background() 86 86 ··· 88 88 aud := "did:example:aud#svc" 89 89 lxm := syntax.NSID("com.example.api") 90 90 91 - priv, err := crypto.GeneratePrivateKeyP256() 91 + priv, err := atcrypto.GeneratePrivateKeyP256() 92 92 if err != nil { 93 93 t.Fatal(err) 94 94 } ··· 140 140 } 141 141 142 142 func TestP256SigningValidation(t *testing.T) { 143 - priv, err := crypto.GeneratePrivateKeyP256() 143 + priv, err := atcrypto.GeneratePrivateKeyP256() 144 144 if err != nil { 145 145 t.Fatal(err) 146 146 } ··· 148 148 } 149 149 150 150 func TestK256SigningValidation(t *testing.T) { 151 - priv, err := crypto.GeneratePrivateKeyK256() 151 + priv, err := atcrypto.GeneratePrivateKeyK256() 152 152 if err != nil { 153 153 t.Fatal(err) 154 154 }
+2 -2
atproto/auth/oauth/cmd/oauth-web-demo/main.go
··· 12 12 13 13 _ "github.com/joho/godotenv/autoload" 14 14 15 + "github.com/bluesky-social/indigo/atproto/atcrypto" 15 16 "github.com/bluesky-social/indigo/atproto/auth/oauth" 16 - "github.com/bluesky-social/indigo/atproto/crypto" 17 17 "github.com/bluesky-social/indigo/atproto/identity" 18 18 "github.com/bluesky-social/indigo/atproto/syntax" 19 19 ··· 101 101 102 102 // If a client secret key is provided (as a multibase string), turn this in to a confidential client 103 103 if cctx.String("client-secret-key") != "" && hostname != "" { 104 - priv, err := crypto.ParsePrivateMultibase(cctx.String("client-secret-key")) 104 + priv, err := atcrypto.ParsePrivateMultibase(cctx.String("client-secret-key")) 105 105 if err != nil { 106 106 return err 107 107 }
+2 -2
atproto/auth/oauth/jwt_signing.go
··· 4 4 "crypto" 5 5 "fmt" 6 6 7 - atcrypto "github.com/bluesky-social/indigo/atproto/crypto" 7 + "github.com/bluesky-social/indigo/atproto/atcrypto" 8 8 "github.com/golang-jwt/jwt/v5" 9 9 ) 10 10 ··· 15 15 supportedAlgs []string 16 16 ) 17 17 18 - // Implementation of jwt.SigningMethod for the `atproto/crypto` types. 18 + // Implementation of jwt.SigningMethod for the `atproto/atcrypto` types. 19 19 type signingMethodAtproto struct { 20 20 alg string 21 21 hash crypto.Hash
+11 -11
atproto/auth/oauth/oauth.go
··· 11 11 "strings" 12 12 "time" 13 13 14 - "github.com/bluesky-social/indigo/atproto/crypto" 14 + "github.com/bluesky-social/indigo/atproto/atcrypto" 15 15 "github.com/bluesky-social/indigo/atproto/identity" 16 16 "github.com/bluesky-social/indigo/atproto/syntax" 17 17 ··· 43 43 UserAgent string 44 44 45 45 // For confidential clients, the private client assertion key. Note that while an interface is used here, only P-256 is allowed by the current specification. 46 - PrivateKey crypto.PrivateKey 46 + PrivateKey atcrypto.PrivateKey 47 47 48 48 // ID for current client assertion key (should be provided if PrivateKey is) 49 49 KeyID *string ··· 112 112 return config.PrivateKey != nil && config.KeyID != nil 113 113 } 114 114 115 - func (config *ClientConfig) SetClientSecret(priv crypto.PrivateKey, keyID string) error { 115 + func (config *ClientConfig) SetClientSecret(priv atcrypto.PrivateKey, keyID string) error { 116 116 switch priv.(type) { 117 - case *crypto.PrivateKeyP256: 117 + case *atcrypto.PrivateKeyP256: 118 118 // pass 119 - case *crypto.PrivateKeyK256: 119 + case *atcrypto.PrivateKeyK256: 120 120 return fmt.Errorf("only P-256 (ES256) private keys supported for atproto OAuth") 121 121 default: 122 122 return fmt.Errorf("unknown private key type: %T", priv) ··· 131 131 // If the client does not have any keys (eg, public client), returns an empty set. 132 132 func (config *ClientConfig) PublicJWKS() JWKS { 133 133 134 - jwks := JWKS{Keys: []crypto.JWK{}} 134 + jwks := JWKS{Keys: []atcrypto.JWK{}} 135 135 136 136 // public client with no keys 137 137 if config.PrivateKey == nil || config.KeyID == nil { ··· 148 148 } 149 149 jwk.KeyID = config.KeyID 150 150 151 - jwks.Keys = []crypto.JWK{*jwk} 151 + jwks.Keys = []atcrypto.JWK{*jwk} 152 152 return jwks 153 153 } 154 154 ··· 209 209 } 210 210 211 211 // TODO: refactor this in to ClientAuthStore layer? 212 - priv, err := crypto.ParsePrivateMultibase(sd.DPoPPrivateKeyMultibase) 212 + priv, err := atcrypto.ParsePrivateMultibase(sd.DPoPPrivateKeyMultibase) 213 213 if err != nil { 214 214 return nil, err 215 215 } ··· 264 264 // Creates a DPoP token (JWT) for use with an OAuth Auth Server (not to be used with Resource Server). The returned JWT is not bound to an Access Token (no 'ath'), and does not indicate an issuer ('iss'). 265 265 // 266 266 // This is used during initial auth request (PAR), initial token request, and subsequent refresh token requests. Note that a full [ClientSession] is not available in several of these circumstances, so this is a stand-alone function. 267 - func NewAuthDPoP(httpMethod, url, dpopNonce string, privKey crypto.PrivateKey) (string, error) { 267 + func NewAuthDPoP(httpMethod, url, dpopNonce string, privKey atcrypto.PrivateKey) (string, error) { 268 268 269 269 claims := dpopClaims{ 270 270 HTTPMethod: httpMethod, ··· 356 356 dpopServerNonce := "" 357 357 358 358 // create new key for the session 359 - dpopPrivKey, err := crypto.GeneratePrivateKeyP256() 359 + dpopPrivKey, err := atcrypto.GeneratePrivateKeyP256() 360 360 if err != nil { 361 361 return nil, err 362 362 } ··· 447 447 body.ClientAssertion = &clientAssertion 448 448 } 449 449 450 - dpopPrivKey, err := crypto.ParsePrivateMultibase(info.DPoPPrivateKeyMultibase) 450 + dpopPrivKey, err := atcrypto.ParsePrivateMultibase(info.DPoPPrivateKeyMultibase) 451 451 if err != nil { 452 452 return nil, err 453 453 }
+7 -7
atproto/auth/oauth/session.go
··· 13 13 "sync" 14 14 "time" 15 15 16 - "github.com/bluesky-social/indigo/atproto/client" 17 - "github.com/bluesky-social/indigo/atproto/crypto" 16 + "github.com/bluesky-social/indigo/atproto/atclient" 17 + "github.com/bluesky-social/indigo/atproto/atcrypto" 18 18 "github.com/bluesky-social/indigo/atproto/syntax" 19 19 20 20 "github.com/golang-jwt/jwt/v5" ··· 64 64 // TODO: also persist access token creation time / expiration time? In context that token might not be an easily parsed JWT 65 65 } 66 66 67 - // Implementation of [client.AuthMethod] for an OAuth session. Handles DPoP request token signing and nonce rotation, and token refresh requests. Optionally uses a callback to persist updated session data. 67 + // Implementation of [atclient.AuthMethod] for an OAuth session. Handles DPoP request token signing and nonce rotation, and token refresh requests. Optionally uses a callback to persist updated session data. 68 68 // 69 69 // A single ClientSession instance can be called concurrently: updates to session data (the 'Data' field) are protected with a RW mutex lock. Note that concurrent calls to distinct ClientSession instances for the same session could result in clobbered session data. 70 70 type ClientSession struct { ··· 73 73 74 74 Config *ClientConfig 75 75 Data *ClientSessionData 76 - DPoPPrivateKey crypto.PrivateKey 76 + DPoPPrivateKey atcrypto.PrivateKey 77 77 78 78 PersistSessionCallback PersistSessionCallback 79 79 ··· 397 397 return nil, fmt.Errorf("OAuth client ran out of request retries") 398 398 } 399 399 400 - // Creates a new [client.APIClient] which wraps this session for auth. 401 - func (sess *ClientSession) APIClient() *client.APIClient { 402 - c := client.APIClient{ 400 + // Creates a new [atclient.APIClient] which wraps this session for auth. 401 + func (sess *ClientSession) APIClient() *atclient.APIClient { 402 + c := atclient.APIClient{ 403 403 Client: sess.Client, 404 404 Host: sess.Data.HostURL, 405 405 Auth: sess,
+2 -2
atproto/auth/oauth/types.go
··· 7 7 "slices" 8 8 "strings" 9 9 10 - "github.com/bluesky-social/indigo/atproto/crypto" 10 + "github.com/bluesky-social/indigo/atproto/atcrypto" 11 11 "github.com/bluesky-social/indigo/atproto/syntax" 12 12 ) 13 13 ··· 19 19 ) 20 20 21 21 type JWKS struct { 22 - Keys []crypto.JWK `json:"keys"` 22 + Keys []atcrypto.JWK `json:"keys"` 23 23 } 24 24 25 25 // Expected response type from looking up OAuth Protected Resource information on a server (eg, a PDS instance)
+1 -1
atproto/client/admin_auth.go atproto/atclient/admin_auth.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "net/http"
+1 -1
atproto/client/admin_auth_test.go atproto/atclient/admin_auth_test.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "context"
+1 -1
atproto/client/apiclient.go atproto/atclient/apiclient.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "bytes"
+1 -1
atproto/client/apiclient_test.go atproto/atclient/apiclient_test.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "testing"
+1 -1
atproto/client/apierror.go atproto/atclient/apierror.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "fmt"
+1 -1
atproto/client/apirequest.go atproto/atclient/apirequest.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "context"
+8 -8
atproto/client/cmd/atp-client-demo/main.go atproto/atclient/cmd/atp-client-demo/main.go
··· 8 8 "os" 9 9 10 10 comatproto "github.com/bluesky-social/indigo/api/agnostic" 11 - "github.com/bluesky-social/indigo/atproto/client" 11 + "github.com/bluesky-social/indigo/atproto/atclient" 12 12 "github.com/bluesky-social/indigo/atproto/identity" 13 13 "github.com/bluesky-social/indigo/atproto/syntax" 14 14 ··· 120 120 app.RunAndExitOnError() 121 121 } 122 122 123 - func getFeed(ctx context.Context, c *client.APIClient) error { 123 + func getFeed(ctx context.Context, c *atclient.APIClient) error { 124 124 params := map[string]any{ 125 125 "actor": "atproto.com", 126 126 "limit": 2, ··· 141 141 return nil 142 142 } 143 143 144 - func listRecords(ctx context.Context, c *client.APIClient) error { 144 + func listRecords(ctx context.Context, c *atclient.APIClient) error { 145 145 146 146 list, err := comatproto.RepoListRecords(ctx, c, "app.bsky.actor.profile", "", 10, "did:plc:ewvi7nxzyoun6zhxrhs64oiz", false) 147 147 if err != nil { ··· 159 159 func runGetFeedPublic(cctx *cli.Context) error { 160 160 ctx := cctx.Context 161 161 162 - c := client.APIClient{ 162 + c := atclient.APIClient{ 163 163 Host: cctx.String("host"), 164 164 } 165 165 ··· 169 169 func runListRecordsPublic(cctx *cli.Context) error { 170 170 ctx := cctx.Context 171 171 172 - c := client.APIClient{ 172 + c := atclient.APIClient{ 173 173 Host: cctx.String("host"), 174 174 } 175 175 ··· 186 186 187 187 dir := identity.DefaultDirectory() 188 188 189 - c, err := client.LoginWithPassword(ctx, dir, *atid, cctx.String("password"), "", nil) 189 + c, err := atclient.LoginWithPassword(ctx, dir, *atid, cctx.String("password"), "", nil) 190 190 if err != nil { 191 191 return err 192 192 } ··· 215 215 216 216 dir := identity.DefaultDirectory() 217 217 218 - c, err := client.LoginWithPassword(ctx, dir, *atid, cctx.String("password"), "", nil) 218 + c, err := atclient.LoginWithPassword(ctx, dir, *atid, cctx.String("password"), "", nil) 219 219 if err != nil { 220 220 return err 221 221 } ··· 227 227 func runLookupAdmin(cctx *cli.Context) error { 228 228 ctx := cctx.Context 229 229 230 - c := client.NewAdminClient(cctx.String("host"), cctx.String("admin-password")) 230 + c := atclient.NewAdminClient(cctx.String("host"), cctx.String("admin-password")) 231 231 232 232 var d json.RawMessage 233 233 params := map[string]any{
+1 -1
atproto/client/doc.go atproto/atclient/doc.go
··· 18 18 19 19 This package tries to use minimal dependencies beyond the Go standard library, to make it easy to reference as a dependency. It does require the [github.com/bluesky-social/indigo/atproto/syntax] and [github.com/bluesky-social/indigo/atproto/identity] sibling packages. In particular, this package does not include any auth methods requiring JWTs, to avoid adding any specific JWT implementation as a dependency. 20 20 */ 21 - package client 21 + package atclient
+1 -1
atproto/client/examples_test.go atproto/atclient/examples_test.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "context"
+1 -1
atproto/client/lexclient.go atproto/atclient/lexclient.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "bytes"
+1 -1
atproto/client/params.go atproto/atclient/params.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "encoding"
+1 -1
atproto/client/params_test.go atproto/atclient/params_test.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "net/url"
+1 -1
atproto/client/password_auth.go atproto/atclient/password_auth.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "context"
+1 -1
atproto/client/password_auth_test.go atproto/atclient/password_auth_test.go
··· 1 - package client 1 + package atclient 2 2 3 3 import ( 4 4 "bytes"
atproto/client/testdata/body.json atproto/atclient/testdata/body.json
+3 -3
atproto/crypto/cmd/atp-crypto/main.go atproto/atcrypto/cmd/atp-crypto/main.go
··· 5 5 "log/slog" 6 6 "os" 7 7 8 - "github.com/bluesky-social/indigo/atproto/crypto" 8 + "github.com/bluesky-social/indigo/atproto/atcrypto" 9 9 10 10 "github.com/urfave/cli/v2" 11 11 ) ··· 40 40 41 41 func runGenerate(cctx *cli.Context) error { 42 42 if cctx.Bool("k256") { 43 - priv, err := crypto.GeneratePrivateKeyK256() 43 + priv, err := atcrypto.GeneratePrivateKeyK256() 44 44 if err != nil { 45 45 return err 46 46 } 47 47 fmt.Println(priv.Multibase()) 48 48 } else { 49 - priv, err := crypto.GeneratePrivateKeyP256() 49 + priv, err := atcrypto.GeneratePrivateKeyP256() 50 50 if err != nil { 51 51 return err 52 52 }
+2 -2
atproto/crypto/docs.go atproto/atcrypto/docs.go
··· 1 - // Package crypto provides cryptographic keys and operations, as used in atproto (the protocol) 1 + // Package atcrypto provides cryptographic keys and operations, as used in atproto (the protocol) 2 2 // 3 3 // This package attempts to abstract away the specific curves, compressions, signature variations, and other implementation details. The goal is to provide as few knobs and options as possible when working with this library. Use of cryptography in atproto is specified in https://atproto.com/specs/cryptography. 4 4 // ··· 8 8 // - K-256/secp256r1, internally implemented using https://gitlab.com/yawning/secp256k1-voi 9 9 // 10 10 // "Low-S" signatures are enforced for both key types, both when creating signatures and during verification, as required by the atproto specification. 11 - package crypto 11 + package atcrypto
+1 -1
atproto/crypto/examples_test.go atproto/atcrypto/examples_test.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "encoding/base64"
+1 -1
atproto/crypto/interop_fixtures_test.go atproto/atcrypto/interop_fixtures_test.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "encoding/base64"
+1 -1
atproto/crypto/jwk.go atproto/atcrypto/jwk.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "crypto/ecdsa"
+1 -1
atproto/crypto/jwk_test.go atproto/atcrypto/jwk_test.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "testing"
+1 -1
atproto/crypto/k256.go atproto/atcrypto/k256.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "crypto"
+1 -1
atproto/crypto/keys.go atproto/atcrypto/keys.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "errors"
+1 -1
atproto/crypto/keys_test.go atproto/atcrypto/keys_test.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "crypto/rand"
+1 -1
atproto/crypto/p256.go atproto/atcrypto/p256.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "crypto/ecdh"
+1 -1
atproto/crypto/p256_lowS.go atproto/atcrypto/p256_lowS.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "crypto/elliptic"
atproto/crypto/testdata/signature-fixtures.json atproto/atcrypto/testdata/signature-fixtures.json
atproto/crypto/testdata/w3c_didkey_K256.json atproto/atcrypto/testdata/w3c_didkey_K256.json
atproto/crypto/testdata/w3c_didkey_P256.json atproto/atcrypto/testdata/w3c_didkey_P256.json
+1 -1
atproto/crypto/w3c_didkey_test.go atproto/atcrypto/w3c_didkey_test.go
··· 1 - package crypto 1 + package atcrypto 2 2 3 3 import ( 4 4 "encoding/hex"
+1 -1
atproto/data/basic_test.go atproto/atdata/basic_test.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "encoding/json"
+1 -1
atproto/data/blob.go atproto/atdata/blob.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "bytes"
+1 -1
atproto/data/bytes.go atproto/atdata/bytes.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "encoding/base64"
+3 -3
atproto/data/cbor_gen.go atproto/atdata/cbor_gen.go
··· 1 1 // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 2 3 - package data 3 + package atdata 4 4 5 5 import ( 6 6 "fmt" ··· 264 264 return err 265 265 } 266 266 267 - // t.Ref (data.CIDLink) (struct) 267 + // t.Ref (atdata.CIDLink) (struct) 268 268 if len("ref") > 1000000 { 269 269 return xerrors.Errorf("Value in field \"ref\" was too long") 270 270 } ··· 387 387 } 388 388 389 389 switch string(nameBuf[:nameLen]) { 390 - // t.Ref (data.CIDLink) (struct) 390 + // t.Ref (atdata.CIDLink) (struct) 391 391 case "ref": 392 392 393 393 {
+1 -1
atproto/data/cidlink.go atproto/atdata/cidlink.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "encoding/json"
+1 -1
atproto/data/const.go atproto/atdata/const.go
··· 1 - package data 1 + package atdata 2 2 3 3 const ( 4 4 // maximum size of any CBOR data, in any context, in atproto
+1 -1
atproto/data/data.go atproto/atdata/data.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "encoding/json"
+2 -2
atproto/data/doc.go atproto/atdata/doc.go
··· 1 1 /* 2 - Package data supports schema-less serializaiton and deserialization of atproto data 2 + Package atdata supports schema-less serializaiton and deserialization of atproto data 3 3 4 4 Some restrictions from the data model include: 5 5 - string sizes ··· 15 15 16 16 Has a helper for serializing generic data (map[string]interface{}) to CBOR, which handles converting JSON-style object types (like $link and $bytes) as needed. There is no "MarshalJSON" method; simply use the standard library's `encoding/json`. 17 17 */ 18 - package data 18 + package atdata
+1 -1
atproto/data/extract.go atproto/atdata/extract.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "bytes"
+1 -1
atproto/data/extract_test.go atproto/atdata/extract_test.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "io"
+1 -1
atproto/data/interop_test.go atproto/atdata/interop_test.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "encoding/base64"
+1 -1
atproto/data/parse.go atproto/atdata/parse.go
··· 1 - package data 1 + package atdata 2 2 3 3 import ( 4 4 "encoding"
atproto/data/testdata/data-model-fixtures.json atproto/atdata/testdata/data-model-fixtures.json
atproto/data/testdata/data-model-invalid.json atproto/atdata/testdata/data-model-invalid.json
atproto/data/testdata/data-model-valid.json atproto/atdata/testdata/data-model-valid.json
atproto/data/testdata/feedpost_record.cbor atproto/atdata/testdata/feedpost_record.cbor
+8 -8
atproto/identity/identity.go
··· 5 5 "net/url" 6 6 "strings" 7 7 8 - "github.com/bluesky-social/indigo/atproto/crypto" 8 + "github.com/bluesky-social/indigo/atproto/atcrypto" 9 9 "github.com/bluesky-social/indigo/atproto/syntax" 10 10 11 11 "github.com/mr-tron/base58" ··· 119 119 // 120 120 // Returns [ErrKeyNotFound] if there is no such key. 121 121 // 122 - // Note that [crypto.PublicKey] is an interface, not a concrete type. 123 - func (i *Identity) PublicKey() (crypto.PublicKey, error) { 122 + // Note that [atcrypto.PublicKey] is an interface, not a concrete type. 123 + func (i *Identity) PublicKey() (atcrypto.PublicKey, error) { 124 124 return i.GetPublicKey("atproto") 125 125 } 126 126 ··· 128 128 // 129 129 // Returns [ErrKeyNotFound] if there is no such key. 130 130 // 131 - // Note that [crypto.PublicKey] is an interface, not a concrete type. 132 - func (i *Identity) GetPublicKey(id string) (crypto.PublicKey, error) { 131 + // Note that [atcrypto.PublicKey] is an interface, not a concrete type. 132 + func (i *Identity) GetPublicKey(id string) (atcrypto.PublicKey, error) { 133 133 if i.Keys == nil { 134 134 return nil, ErrKeyNotDeclared 135 135 } ··· 139 139 } 140 140 switch k.Type { 141 141 case "Multikey": 142 - return crypto.ParsePublicMultibase(k.PublicKeyMultibase) 142 + return atcrypto.ParsePublicMultibase(k.PublicKeyMultibase) 143 143 case "EcdsaSecp256r1VerificationKey2019": 144 144 if len(k.PublicKeyMultibase) < 2 || k.PublicKeyMultibase[0] != 'z' { 145 145 return nil, fmt.Errorf("identity key not a multibase base58btc string") ··· 148 148 if err != nil { 149 149 return nil, fmt.Errorf("identity key multibase parsing: %w", err) 150 150 } 151 - return crypto.ParsePublicUncompressedBytesP256(keyBytes) 151 + return atcrypto.ParsePublicUncompressedBytesP256(keyBytes) 152 152 case "EcdsaSecp256k1VerificationKey2019": 153 153 if len(k.PublicKeyMultibase) < 2 || k.PublicKeyMultibase[0] != 'z' { 154 154 return nil, fmt.Errorf("identity key not a multibase base58btc string") ··· 157 157 if err != nil { 158 158 return nil, fmt.Errorf("identity key multibase parsing: %w", err) 159 159 } 160 - return crypto.ParsePublicUncompressedBytesK256(keyBytes) 160 + return atcrypto.ParsePublicUncompressedBytesK256(keyBytes) 161 161 default: 162 162 return nil, fmt.Errorf("unsupported atproto public key type: %s", k.Type) 163 163 }
+3 -3
atproto/label/cbor_gen.go atproto/labeling/cbor_gen.go
··· 1 1 // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. 2 2 3 - package label 3 + package labeling 4 4 5 5 import ( 6 6 "fmt" ··· 159 159 } 160 160 } 161 161 162 - // t.Sig (data.Bytes) (slice) 162 + // t.Sig (atdata.Bytes) (slice) 163 163 if t.Sig != nil { 164 164 165 165 if len("sig") > 1000000 { ··· 408 408 t.Negated = &val 409 409 } 410 410 } 411 - // t.Sig (data.Bytes) (slice) 411 + // t.Sig (atdata.Bytes) (slice) 412 412 case "sig": 413 413 414 414 maj, extra, err = cr.ReadHeader()
+15 -15
atproto/label/label.go atproto/labeling/label.go
··· 1 - package label 1 + package labeling 2 2 3 3 import ( 4 4 "bytes" 5 5 "fmt" 6 6 7 7 comatproto "github.com/bluesky-social/indigo/api/atproto" 8 - "github.com/bluesky-social/indigo/atproto/crypto" 9 - "github.com/bluesky-social/indigo/atproto/data" 8 + "github.com/bluesky-social/indigo/atproto/atcrypto" 9 + "github.com/bluesky-social/indigo/atproto/atdata" 10 10 "github.com/bluesky-social/indigo/atproto/syntax" 11 11 ) 12 12 ··· 14 14 const ATPROTO_LABEL_VERSION int64 = 1 15 15 16 16 type Label struct { 17 - CID *string `json:"cid,omitempty" cborgen:"cid,omitempty"` 18 - CreatedAt string `json:"cts" cborgen:"cts"` 19 - ExpiresAt *string `json:"exp,omitempty" cborgen:"exp,omitempty"` 20 - Negated *bool `json:"neg,omitempty" cborgen:"neg,omitempty"` 21 - SourceDID string `json:"src" cborgen:"src"` 22 - URI string `json:"uri" cborgen:"uri"` 23 - Val string `json:"val" cborgen:"val"` 24 - Version int64 `json:"ver" cborgen:"ver"` 25 - Sig data.Bytes `json:"sig,omitempty" cborgen:"sig,omitempty"` 17 + CID *string `json:"cid,omitempty" cborgen:"cid,omitempty"` 18 + CreatedAt string `json:"cts" cborgen:"cts"` 19 + ExpiresAt *string `json:"exp,omitempty" cborgen:"exp,omitempty"` 20 + Negated *bool `json:"neg,omitempty" cborgen:"neg,omitempty"` 21 + SourceDID string `json:"src" cborgen:"src"` 22 + URI string `json:"uri" cborgen:"uri"` 23 + Val string `json:"val" cborgen:"val"` 24 + Version int64 `json:"ver" cborgen:"ver"` 25 + Sig atdata.Bytes `json:"sig,omitempty" cborgen:"sig,omitempty"` 26 26 } 27 27 28 28 // converts to map[string]any for printing as JSON ··· 45 45 d["neg"] = l.Negated 46 46 } 47 47 if l.Sig != nil { 48 - d["sig"] = data.Bytes(l.Sig) 48 + d["sig"] = atdata.Bytes(l.Sig) 49 49 } 50 50 return d 51 51 } ··· 110 110 } 111 111 112 112 // Signs the commit, storing the signature in the `Sig` field 113 - func (l *Label) Sign(privkey crypto.PrivateKey) error { 113 + func (l *Label) Sign(privkey atcrypto.PrivateKey) error { 114 114 b, err := l.UnsignedBytes() 115 115 if err != nil { 116 116 return err ··· 124 124 } 125 125 126 126 // Verifies `Sig` field using the provided key. Returns `nil` if signature is valid. 127 - func (l *Label) VerifySignature(pubkey crypto.PublicKey) error { 127 + func (l *Label) VerifySignature(pubkey atcrypto.PublicKey) error { 128 128 if l.Sig == nil { 129 129 return fmt.Errorf("can not verify unsigned commit") 130 130 }
+4 -4
atproto/label/label_test.go atproto/labeling/label_test.go
··· 1 - package label 1 + package labeling 2 2 3 3 import ( 4 4 "encoding/json" 5 5 "testing" 6 6 7 7 comatproto "github.com/bluesky-social/indigo/api/atproto" 8 - "github.com/bluesky-social/indigo/atproto/crypto" 8 + "github.com/bluesky-social/indigo/atproto/atcrypto" 9 9 10 10 "github.com/stretchr/testify/assert" 11 11 ) ··· 14 14 assert := assert.New(t) 15 15 16 16 pubkeyStr := "zQ3shcnfWLQN1bY4d2patsEAYFzy4xp1zdckEvHsV7S4ocTnC" 17 - pubkey, err := crypto.ParsePublicMultibase(pubkeyStr) 17 + pubkey, err := atcrypto.ParsePublicMultibase(pubkeyStr) 18 18 if err != nil { 19 19 t.Fatal(err) 20 20 } ··· 77 77 SourceDID: "did:plc:ewvi7nxzyoun6zhxrhs64oiz", 78 78 } 79 79 80 - priv, err := crypto.GeneratePrivateKeyK256() 80 + priv, err := atcrypto.GeneratePrivateKeyK256() 81 81 if err != nil { 82 82 t.Fatal(err) 83 83 }
+2 -2
atproto/lexicon/cmd/lextool/net.go
··· 7 7 "log/slog" 8 8 "net/http" 9 9 10 - "github.com/bluesky-social/indigo/atproto/data" 10 + "github.com/bluesky-social/indigo/atproto/atdata" 11 11 "github.com/bluesky-social/indigo/atproto/identity" 12 12 "github.com/bluesky-social/indigo/atproto/lexicon" 13 13 "github.com/bluesky-social/indigo/atproto/syntax" ··· 64 64 return err 65 65 } 66 66 67 - body, err := data.UnmarshalJSON(respBytes) 67 + body, err := atdata.UnmarshalJSON(respBytes) 68 68 if err != nil { 69 69 return err 70 70 }
+2 -2
atproto/lexicon/examples_test.go
··· 3 3 import ( 4 4 "fmt" 5 5 6 - atdata "github.com/bluesky-social/indigo/atproto/data" 6 + "github.com/bluesky-social/indigo/atproto/atdata" 7 7 ) 8 8 9 9 func ExampleValidateRecord() { ··· 14 14 panic("failed to load lexicons") 15 15 } 16 16 17 - // Parse record JSON data using atproto/data helper 17 + // Parse record JSON data using atdata helper 18 18 recordJSON := `{ 19 19 "$type": "example.lexicon.record", 20 20 "integer": 123,
+3 -3
atproto/lexicon/interop_record_test.go
··· 7 7 "os" 8 8 "testing" 9 9 10 - "github.com/bluesky-social/indigo/atproto/data" 10 + "github.com/bluesky-social/indigo/atproto/atdata" 11 11 12 12 "github.com/stretchr/testify/assert" 13 13 ) ··· 44 44 45 45 for _, fixture := range fixtures { 46 46 fmt.Println(fixture.Name) 47 - d, err := data.UnmarshalJSON(fixture.Data) 47 + d, err := atdata.UnmarshalJSON(fixture.Data) 48 48 if err != nil { 49 49 t.Fatal(err) 50 50 } ··· 79 79 80 80 for _, fixture := range fixtures { 81 81 fmt.Println(fixture.Name) 82 - d, err := data.UnmarshalJSON(fixture.Data) 82 + d, err := atdata.UnmarshalJSON(fixture.Data) 83 83 if err != nil { 84 84 t.Fatal(err) 85 85 }
+4 -4
atproto/lexicon/language.go
··· 6 6 "reflect" 7 7 "strings" 8 8 9 - "github.com/bluesky-social/indigo/atproto/data" 9 + "github.com/bluesky-social/indigo/atproto/atdata" 10 10 "github.com/bluesky-social/indigo/atproto/syntax" 11 11 12 12 "github.com/rivo/uniseg" ··· 810 810 } 811 811 812 812 func (s *SchemaBytes) Validate(d any) error { 813 - v, ok := d.(data.Bytes) 813 + v, ok := d.(atdata.Bytes) 814 814 if !ok { 815 815 return fmt.Errorf("expecting bytes") 816 816 } ··· 830 830 } 831 831 832 832 func (s *SchemaCIDLink) Validate(d any) error { 833 - _, ok := d.(data.CIDLink) 833 + _, ok := d.(atdata.CIDLink) 834 834 if !ok { 835 835 return fmt.Errorf("expecting a cid-link") 836 836 } ··· 915 915 } 916 916 917 917 func (s *SchemaBlob) Validate(d any, flags ValidateFlags) error { 918 - v, ok := d.(data.Blob) 918 + v, ok := d.(atdata.Blob) 919 919 if !ok { 920 920 return fmt.Errorf("expected a blob") 921 921 }
+2 -2
atproto/lexicon/resolve.go
··· 7 7 "log/slog" 8 8 9 9 "github.com/bluesky-social/indigo/api/agnostic" 10 - "github.com/bluesky-social/indigo/atproto/data" 10 + "github.com/bluesky-social/indigo/atproto/atdata" 11 11 "github.com/bluesky-social/indigo/atproto/identity" 12 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 13 "github.com/bluesky-social/indigo/xrpc" ··· 25 25 return nil, err 26 26 } 27 27 28 - d, err := data.UnmarshalJSON(*record) 28 + d, err := atdata.UnmarshalJSON(*record) 29 29 if err != nil { 30 30 return nil, fmt.Errorf("fetched Lexicon schema record was invalid: %w", err) 31 31 }
+7 -7
atproto/repo/commit.go
··· 4 4 "bytes" 5 5 "fmt" 6 6 7 - "github.com/bluesky-social/indigo/atproto/crypto" 8 - "github.com/bluesky-social/indigo/atproto/data" 7 + "github.com/bluesky-social/indigo/atproto/atcrypto" 8 + "github.com/bluesky-social/indigo/atproto/atdata" 9 9 "github.com/bluesky-social/indigo/atproto/syntax" 10 10 11 11 "github.com/ipfs/go-cid" ··· 45 45 d := map[string]any{ 46 46 "did": c.DID, 47 47 "version": c.Version, 48 - "prev": (*data.CIDLink)(c.Prev), 49 - "data": data.CIDLink(c.Data), 48 + "prev": (*atdata.CIDLink)(c.Prev), 49 + "data": atdata.CIDLink(c.Data), 50 50 } 51 51 if c.Sig != nil { 52 - d["sig"] = data.Bytes(c.Sig) 52 + d["sig"] = atdata.Bytes(c.Sig) 53 53 } 54 54 if c.Rev != "" { 55 55 d["rev"] = c.Rev ··· 80 80 } 81 81 82 82 // Signs the commit, storing the signature in the `Sig` field 83 - func (c *Commit) Sign(privkey crypto.PrivateKey) error { 83 + func (c *Commit) Sign(privkey atcrypto.PrivateKey) error { 84 84 b, err := c.UnsignedBytes() 85 85 if err != nil { 86 86 return err ··· 94 94 } 95 95 96 96 // Verifies `Sig` field using the provided key. Returns `nil` if signature is valid. 97 - func (c *Commit) VerifySignature(pubkey crypto.PublicKey) error { 97 + func (c *Commit) VerifySignature(pubkey atcrypto.PublicKey) error { 98 98 if c.Sig == nil { 99 99 return fmt.Errorf("can not verify unsigned commit") 100 100 }
+4 -4
automod/engine/blobs.go
··· 7 7 "strings" 8 8 "time" 9 9 10 - "github.com/bluesky-social/indigo/atproto/data" 10 + "github.com/bluesky-social/indigo/atproto/atdata" 11 11 lexutil "github.com/bluesky-social/indigo/lex/util" 12 12 13 13 "github.com/carlmjohnson/versioninfo" ··· 22 22 return []lexutil.LexBlob{}, nil 23 23 } 24 24 25 - rec, err := data.UnmarshalCBOR(c.RecordOp.RecordCBOR) 25 + rec, err := atdata.UnmarshalCBOR(c.RecordOp.RecordCBOR) 26 26 if err != nil { 27 27 return nil, fmt.Errorf("parsing generic record CBOR: %v", err) 28 28 } 29 - blobs := data.ExtractBlobs(rec) 29 + blobs := atdata.ExtractBlobs(rec) 30 30 31 - // convert from data.Blob to lexutil.LexBlob; plan is to merge these types eventually 31 + // convert from atdata.Blob to lexutil.LexBlob; plan is to merge these types eventually 32 32 var out []lexutil.LexBlob 33 33 for _, b := range blobs { 34 34 lb := lexutil.LexBlob{
+2 -2
cmd/astrolabe/handlers.go
··· 9 9 "github.com/bluesky-social/indigo/api/agnostic" 10 10 comatproto "github.com/bluesky-social/indigo/api/atproto" 11 11 _ "github.com/bluesky-social/indigo/api/bsky" 12 - "github.com/bluesky-social/indigo/atproto/data" 12 + "github.com/bluesky-social/indigo/atproto/atdata" 13 13 "github.com/bluesky-social/indigo/atproto/identity" 14 14 "github.com/bluesky-social/indigo/atproto/syntax" 15 15 "github.com/bluesky-social/indigo/xrpc" ··· 231 231 return fmt.Errorf("empty record in response") 232 232 } 233 233 234 - record, err := data.UnmarshalJSON(*resp.Value) 234 + record, err := atdata.UnmarshalJSON(*resp.Value) 235 235 if err != nil { 236 236 return fmt.Errorf("fetched record was invalid data: %w", err) 237 237 }
+2 -2
cmd/netsync/main.go
··· 19 19 "syscall" 20 20 "time" 21 21 22 - "github.com/bluesky-social/indigo/atproto/data" 22 + "github.com/bluesky-social/indigo/atproto/atdata" 23 23 "github.com/bluesky-social/indigo/repo" 24 24 "github.com/ipfs/go-cid" 25 25 _ "github.com/joho/godotenv/autoload" ··· 573 573 collectionsSeen[collection] = struct{}{} 574 574 } 575 575 576 - asCbor, err := data.UnmarshalCBOR(*rec) 576 + asCbor, err := atdata.UnmarshalCBOR(*rec) 577 577 if err != nil { 578 578 log.Error("Error unmarshalling record", "err", err) 579 579 return fmt.Errorf("Failed to unmarshal record: %w", err)
+4 -4
gen/main.go
··· 6 6 atproto "github.com/bluesky-social/indigo/api/atproto" 7 7 bsky "github.com/bluesky-social/indigo/api/bsky" 8 8 chat "github.com/bluesky-social/indigo/api/chat" 9 - "github.com/bluesky-social/indigo/atproto/data" 10 - "github.com/bluesky-social/indigo/atproto/label" 9 + "github.com/bluesky-social/indigo/atproto/atdata" 10 + "github.com/bluesky-social/indigo/atproto/labeling" 11 11 atrepo "github.com/bluesky-social/indigo/atproto/repo" 12 12 atmst "github.com/bluesky-social/indigo/atproto/repo/mst" 13 13 "github.com/bluesky-social/indigo/events" ··· 122 122 panic(err) 123 123 } 124 124 125 - if err := genCfg.WriteMapEncodersToFile("atproto/data/cbor_gen.go", "data", data.GenericRecord{}, data.LegacyBlobSchema{}, data.BlobSchema{}); err != nil { 125 + if err := genCfg.WriteMapEncodersToFile("atproto/atdata/cbor_gen.go", "atdata", atdata.GenericRecord{}, atdata.LegacyBlobSchema{}, atdata.BlobSchema{}); err != nil { 126 126 panic(err) 127 127 } 128 128 ··· 134 134 panic(err) 135 135 } 136 136 137 - if err := genCfg.WriteMapEncodersToFile("atproto/label/cbor_gen.go", "label", label.Label{}); err != nil { 137 + if err := genCfg.WriteMapEncodersToFile("atproto/labeling/cbor_gen.go", "labeling", labeling.Label{}); err != nil { 138 138 panic(err) 139 139 } 140 140 }