didparser

package module
v0.0.0-...-cee3799 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

README

golang-nutsdid

Documentation

Index

Constants

View Source
const (
	// InvalidDIDErr indicates: "The DID supplied to the DID resolution function does not conform to valid syntax. (See § 3.1 DID Syntax.)"
	InvalidDIDErr = constError("supplied DID is invalid")
	// NotFoundErr indicates: "The DID resolver was unable to find the DID document resulting from this resolution request."
	NotFoundErr = constError("supplied DID wasn't found")
	// DeactivatedErr indicates: The DID supplied to the DID resolution function has been deactivated. (See § 7.2.4 Deactivate .)
	DeactivatedErr = constError("supplied DID is deactivated")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DID

type DID struct {
	ockamDid.DID
}

DID represents a Decentralized Identifier as specified by the DID Core specification (https://www.w3.org/TR/did-core/#identifier).

func ParseDID

func ParseDID(input string) (*DID, error)

ParseDID parses a raw DID. If it can't be parsed, an error is returned.

func (DID) Empty

func (d DID) Empty() bool

Empty returns whether the DID is empty or not

func (DID) Equals

func (d DID) Equals(other DID) bool

Equals checks whether the DID is exactly equal to another DID

func (DID) MarshalJSON

func (d DID) MarshalJSON() ([]byte, error)

MarshalJSON marshals the DID to a JSON string

func (*DID) UnmarshalJSON

func (d *DID) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals a DID encoded as JSON string, e.g.: "did:nuts:c0dc584345da8a0e1e7a584aa4a36c30ebdb79d907aff96fe0e90ee972f58a17"

type Document

type Document struct {
	Context            []URI                      `json:"@context"`
	ID                 DID                        `json:"id"`
	Controller         []DID                      `json:"controller,omitempty"`
	VerificationMethod []VerificationMethod       `json:"verificationMethod,omitempty"`
	Authentication     []VerificationRelationship `json:"authentication,omitempty"`
	AssertionMethod    []VerificationRelationship `json:"assertionMethod,omitempty"`
	Service            []Service                  `json:"service,omitempty"`
}

Document represents a DID Document as specified by the DID Core specification (https://www.w3.org/TR/did-core/).

func (*Document) UnmarshalJSON

func (d *Document) UnmarshalJSON(b []byte) error

type DocumentMetadata

type DocumentMetadata struct {
	Created    *time.Time
	Updated    *time.Time
	Properties map[string]interface{}
}

DocumentMedata represents DID Document Metadata as specified by the DID Core specification (https://www.w3.org/TR/did-core/#did-document-metadata-properties).

type Resolver

type Resolver interface {
	// Resolve tries to resolve the given input DID to its DID Document and Metadata. In addition to errors specific
	// to this resolver it can return InvalidDIDErr, NotFoundErr and DeactivatedErr as specified by the DID Core specification.
	// If no error occurs the DID Document and Medata are returned.
	Resolve(inputDID string) (*Document, *DocumentMetadata, error)
}

Resolver defines the interface for DID resolution as specified by the DID Core specification (https://www.w3.org/TR/did-core/#did-resolution).

type Service

type Service struct {
	ID   DID
	Type string
}

Service represents a DID Service Endpoint as specified by the DID Core specification (https://www.w3.org/TR/did-core/#service-endpoints).

type URI

type URI struct {
	url.URL
}

URI is a wrapper around url.URL to add json marshalling

func (*URI) UnmarshalJSON

func (v *URI) UnmarshalJSON(bytes []byte) error

type VerificationMethod

type VerificationMethod struct {
	ID         DID
	Type       string
	Controller DID

	PublicKeyJwk map[string]interface{}
	// contains filtered or unexported fields
}

VerificationMethod represents a DID Verification Method as specified by the DID Core specification (https://www.w3.org/TR/did-core/#verification-methods).

func (VerificationMethod) JWK

func (v VerificationMethod) JWK() jwk.Key

JWK returns the key described by the VerificationMethod as JSON Web Key.

func (*VerificationMethod) UnmarshalJSON

func (v *VerificationMethod) UnmarshalJSON(bytes []byte) error

type VerificationRelationship

type VerificationRelationship struct {
	*VerificationMethod
	// contains filtered or unexported fields
}

VerificationRelationship represents the usage of a VerificationMethod e.g. in authentication, assertionMethod, or keyAgreement.

func (*VerificationRelationship) UnmarshalJSON

func (v *VerificationRelationship) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL