From 032a6973f084ea6f3161dbcbe53a43dd84a4e8fa Mon Sep 17 00:00:00 2001 From: daveroga Date: Thu, 25 Jul 2024 16:37:32 +0200 Subject: [PATCH] add context for Iden3ResolutionMetadata --- pkg/document/did.go | 16 ++++++++++++---- pkg/services/did.go | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/document/did.go b/pkg/document/did.go index 9ec3d9d..f49788b 100644 --- a/pkg/document/did.go +++ b/pkg/document/did.go @@ -15,14 +15,17 @@ const ( ErrUnknownNetwork ErrorCode = "unknownNetwork" StateType = "Iden3StateInfo2023" + Iden3ResolutionMetadataType = "Iden3ResolutionMetadata" EcdsaSecp256k1RecoveryMethod2020Type = "EcdsaSecp256k1RecoveryMethod2020" ) const ( - defaultContext = "https://w3id.org/did-resolution/v1" - defaultDidDocContext = "https://www.w3.org/ns/did/v1" - iden3Context = "https://schema.iden3.io/core/jsonld/auth.jsonld" - defaultContentType = "application/did+ld+json" + defaultContext = "https://w3id.org/did-resolution/v1" + defaultDidDocContext = "https://www.w3.org/ns/did/v1" + iden3Context = "https://schema.iden3.io/core/jsonld/auth.jsonld" + defaultContentType = "application/did+ld+json" + iden3ResolutionContext = "https://schema.iden3.io/core/jsonld/resolution.jsonld" + eip712sigContext = "https://w3id.org/security/suites/eip712sig-2021/v1" ) // DidResolution representation of did resolution. @@ -51,6 +54,10 @@ func NewDidResolution() *DidResolution { } } +func DidResolutionMetadataSigContext() []string { + return []string{iden3ResolutionContext, eip712sigContext} +} + func NewDidMethodNotSupportedResolution(msg string) *DidResolution { return NewDidErrorResolution(ErrMethodNotSupported, msg) } @@ -80,6 +87,7 @@ func NewDidErrorResolution(errCode ErrorCode, errMsg string) *DidResolution { // DidResolutionMetadata representation of resolution metadata. type DidResolutionMetadata struct { + Context interface{} `json:"@context,omitempty"` Error ErrorCode `json:"error,omitempty"` Message string `json:"message,omitempty"` ContentType string `json:"contentType,omitempty"` diff --git a/pkg/services/did.go b/pkg/services/did.go index d37e76c..51988a8 100644 --- a/pkg/services/did.go +++ b/pkg/services/did.go @@ -160,6 +160,8 @@ func (d *DidDocumentServices) GetDidDocument(ctx context.Context, did string, op Created: time.Now(), } + didResolution.DidResolutionMetadata.Context = document.DidResolutionMetadataSigContext() + didResolution.DidResolutionMetadata.Type = document.Iden3ResolutionMetadataType didResolution.DidResolutionMetadata.Proof = append(didResolution.DidResolutionMetadata.Proof, eip712Proof) }