Skip to content

Commit

Permalink
add context for Iden3ResolutionMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
daveroga committed Jul 25, 2024
1 parent 30b97c4 commit 032a697
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/document/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -51,6 +54,10 @@ func NewDidResolution() *DidResolution {
}
}

func DidResolutionMetadataSigContext() []string {
return []string{iden3ResolutionContext, eip712sigContext}
}

func NewDidMethodNotSupportedResolution(msg string) *DidResolution {
return NewDidErrorResolution(ErrMethodNotSupported, msg)
}
Expand Down Expand Up @@ -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"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/services/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 032a697

Please sign in to comment.