From 28d2ee478a6a84251fdf269c475023733a8aa683 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Thu, 5 Dec 2024 17:11:35 -0800 Subject: [PATCH] move DID doc code out to separate file --- atproto/identity/did.go | 20 --------------- atproto/identity/diddoc.go | 25 +++++++++++++++++++ .../identity/{did_test.go => diddoc_text.go} | 0 3 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 atproto/identity/diddoc.go rename atproto/identity/{did_test.go => diddoc_text.go} (100%) diff --git a/atproto/identity/did.go b/atproto/identity/did.go index ab2f3439a..ca13b323c 100644 --- a/atproto/identity/did.go +++ b/atproto/identity/did.go @@ -13,26 +13,6 @@ import ( "github.com/bluesky-social/indigo/atproto/syntax" ) -type DIDDocument struct { - DID syntax.DID `json:"id"` - AlsoKnownAs []string `json:"alsoKnownAs,omitempty"` - VerificationMethod []DocVerificationMethod `json:"verificationMethod,omitempty"` - Service []DocService `json:"service,omitempty"` -} - -type DocVerificationMethod struct { - ID string `json:"id"` - Type string `json:"type"` - Controller string `json:"controller"` - PublicKeyMultibase string `json:"publicKeyMultibase"` -} - -type DocService struct { - ID string `json:"id"` - Type string `json:"type"` - ServiceEndpoint string `json:"serviceEndpoint"` -} - // WARNING: this does *not* bi-directionally verify account metadata; it only implements direct DID-to-DID-document lookup for the supported DID methods, and parses the resulting DID Doc into an Identity struct func (d *BaseDirectory) ResolveDID(ctx context.Context, did syntax.DID) (*DIDDocument, error) { start := time.Now() diff --git a/atproto/identity/diddoc.go b/atproto/identity/diddoc.go new file mode 100644 index 000000000..4c7070c20 --- /dev/null +++ b/atproto/identity/diddoc.go @@ -0,0 +1,25 @@ +package identity + +import ( + "github.com/bluesky-social/indigo/atproto/syntax" +) + +type DIDDocument struct { + DID syntax.DID `json:"id"` + AlsoKnownAs []string `json:"alsoKnownAs,omitempty"` + VerificationMethod []DocVerificationMethod `json:"verificationMethod,omitempty"` + Service []DocService `json:"service,omitempty"` +} + +type DocVerificationMethod struct { + ID string `json:"id"` + Type string `json:"type"` + Controller string `json:"controller"` + PublicKeyMultibase string `json:"publicKeyMultibase"` +} + +type DocService struct { + ID string `json:"id"` + Type string `json:"type"` + ServiceEndpoint string `json:"serviceEndpoint"` +} diff --git a/atproto/identity/did_test.go b/atproto/identity/diddoc_text.go similarity index 100% rename from atproto/identity/did_test.go rename to atproto/identity/diddoc_text.go