this repo has no description

simplify imports

Hailey b8a45307 536b10bd

Changed files
+33 -34
identity
plc
+13 -14
identity/identity.go
··· 10 "strings" 11 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 - "github.com/haileyok/cocoon/plc" 14 ) 15 16 func ResolveHandle(ctx context.Context, handle string) (string, error) { ··· 94 } 95 96 type DidData struct { 97 - Did string `json:"did"` 98 - VerificationMethods map[string]string `json:"verificationMethods"` 99 - RotationKeys []string `json:"rotationKeys"` 100 - AlsoKnownAs []string `json:"alsoKnownAs"` 101 - Services map[string]DidDataService `json:"services"` 102 } 103 104 - type DidDataService struct { 105 Type string `json:"type"` 106 Endpoint string `json:"endpoint"` 107 } ··· 109 type DidLog []DidLogEntry 110 111 type DidLogEntry struct { 112 - Sig string `json:"sig"` 113 - Prev *string `json:"prev"` 114 - Type string `json:"string"` 115 - Services map[string]plc.OperationService `json:"services"` 116 - AlsoKnownAs []string `json:"alsoKnownAs"` 117 - RotationKeys []string `json:"rotationKeys"` 118 - VerificationMethods map[string]string `json:"verificationMethods"` 119 } 120 121 type DidAuditEntry struct {
··· 10 "strings" 11 12 "github.com/bluesky-social/indigo/atproto/syntax" 13 ) 14 15 func ResolveHandle(ctx context.Context, handle string) (string, error) { ··· 93 } 94 95 type DidData struct { 96 + Did string `json:"did"` 97 + VerificationMethods map[string]string `json:"verificationMethods"` 98 + RotationKeys []string `json:"rotationKeys"` 99 + AlsoKnownAs []string `json:"alsoKnownAs"` 100 + Services map[string]OperationService `json:"services"` 101 } 102 103 + type OperationService struct { 104 Type string `json:"type"` 105 Endpoint string `json:"endpoint"` 106 } ··· 108 type DidLog []DidLogEntry 109 110 type DidLogEntry struct { 111 + Sig string `json:"sig"` 112 + Prev *string `json:"prev"` 113 + Type string `json:"string"` 114 + Services map[string]OperationService `json:"services"` 115 + AlsoKnownAs []string `json:"alsoKnownAs"` 116 + RotationKeys []string `json:"rotationKeys"` 117 + VerificationMethods map[string]string `json:"verificationMethods"` 118 } 119 120 type DidAuditEntry struct {
+12 -12
plc/client.go
··· 48 }, nil 49 } 50 51 - func (c *Client) CreateDID(ctx context.Context, sigkey *crypto.PrivateKeyK256, recovery string, handle string) (string, *Operation, error) { 52 pubsigkey, err := sigkey.PublicKey() 53 if err != nil { 54 return "", nil, err ··· 93 return "", nil, err 94 } 95 96 - did, err := didFromOp(&op) 97 if err != nil { 98 return "", nil, err 99 } ··· 101 return did, &op, nil 102 } 103 104 - func didFromOp(op *Operation) (string, error) { 105 - b, err := op.MarshalCBOR() 106 - if err != nil { 107 - return "", err 108 - } 109 - s := sha256.Sum256(b) 110 - b32 := strings.ToLower(base32.StdEncoding.EncodeToString(s[:])) 111 - return "did:plc:" + b32[0:24], nil 112 - } 113 - 114 func (c *Client) SignOp(sigkey *crypto.PrivateKeyK256, op *Operation) error { 115 b, err := op.MarshalCBOR() 116 if err != nil { ··· 153 154 return nil 155 }
··· 48 }, nil 49 } 50 51 + func (c *Client) CreateDID(sigkey *crypto.PrivateKeyK256, recovery string, handle string) (string, *Operation, error) { 52 pubsigkey, err := sigkey.PublicKey() 53 if err != nil { 54 return "", nil, err ··· 93 return "", nil, err 94 } 95 96 + did, err := DidFromOp(&op) 97 if err != nil { 98 return "", nil, err 99 } ··· 101 return did, &op, nil 102 } 103 104 func (c *Client) SignOp(sigkey *crypto.PrivateKeyK256, op *Operation) error { 105 b, err := op.MarshalCBOR() 106 if err != nil { ··· 143 144 return nil 145 } 146 + 147 + func DidFromOp(op *Operation) (string, error) { 148 + b, err := op.MarshalCBOR() 149 + if err != nil { 150 + return "", err 151 + } 152 + s := sha256.Sum256(b) 153 + b32 := strings.ToLower(base32.StdEncoding.EncodeToString(s[:])) 154 + return "did:plc:" + b32[0:24], nil 155 + }
+8 -8
plc/types.go
··· 4 "encoding/json" 5 6 "github.com/bluesky-social/indigo/atproto/data" 7 cbg "github.com/whyrusleeping/cbor-gen" 8 ) 9 10 type Operation struct { 11 - Type string `json:"type"` 12 - VerificationMethods map[string]string `json:"verificationMethods"` 13 - RotationKeys []string `json:"rotationKeys"` 14 - AlsoKnownAs []string `json:"alsoKnownAs"` 15 - Services map[string]OperationService `json:"services"` 16 - Prev *string `json:"prev"` 17 - Sig string `json:"sig,omitempty"` 18 } 19 20 type OperationService struct { ··· 22 Endpoint string `json:"endpoint"` 23 } 24 25 - // This is kinda gross. We could just use cborgen i suppose? 26 func (po *Operation) MarshalCBOR() ([]byte, error) { 27 if po == nil { 28 return cbg.CborNull, nil
··· 4 "encoding/json" 5 6 "github.com/bluesky-social/indigo/atproto/data" 7 + "github.com/haileyok/cocoon/identity" 8 cbg "github.com/whyrusleeping/cbor-gen" 9 ) 10 11 type Operation struct { 12 + Type string `json:"type"` 13 + VerificationMethods map[string]string `json:"verificationMethods"` 14 + RotationKeys []string `json:"rotationKeys"` 15 + AlsoKnownAs []string `json:"alsoKnownAs"` 16 + Services map[string]identity.OperationService `json:"services"` 17 + Prev *string `json:"prev"` 18 + Sig string `json:"sig,omitempty"` 19 } 20 21 type OperationService struct { ··· 23 Endpoint string `json:"endpoint"` 24 } 25 26 func (po *Operation) MarshalCBOR() ([]byte, error) { 27 if po == nil { 28 return cbg.CborNull, nil