did

package
v0.6.0-dev.8 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

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")
)
View Source
const (
	// Minimum length of base colon separated DID
	MIN_BASE_PART_LENGTH = 3

	// Maximum length of base colon separated DID
	MAX_BASE_PART_LENGTH = 4
)
View Source
const DIDContextV1 = "https://www.w3.org/ns/did/v1"

DIDContextV1 contains the JSON-LD context for a DID Document

Variables

View Source
var (
	ErrBaseNotFound              = errors.New("Unable to determine base did of provided string.")
	ErrFragmentAndQuery          = errors.New("Unable to create new DID. Fragment and Query are mutually exclusive")
	ErrParseInvalid              = errors.New("Unable to parse string into DID, invalid format.")
	DidForbiddenSymbolsRegexp, _ = regexp.Compile(`^[^&\\]+$`)
)
View Source
var ErrDIDDocumentInvalid = validationError{}

ErrDIDDocumentInvalid indicates DID Document validation failed

View Source
var ErrInvalidAssertionMethod = errors.New("invalid assertionMethod")

ErrInvalidAssertionMethod indicates the assertion method is invalid (e.g. invalid `id` or `type`)

View Source
var ErrInvalidAuthentication = errors.New("invalid authentication")

ErrInvalidAuthentication indicates the authentication is invalid (e.g. invalid `id` or `type`)

View Source
var ErrInvalidCapabilityDelegation = errors.New("invalid capabilityDelegation")

ErrInvalidCapabilityDelegation indicates the capabilityDelegation is invalid (e.g. invalid `id` or `type`)

View Source
var ErrInvalidCapabilityInvocation = errors.New("invalid capabilityInvocation")

ErrInvalidCapabilityInvocation indicates the capabilityInvocation is invalid (e.g. invalid `id` or `type`)

View Source
var ErrInvalidContext = errors.New("invalid context")

ErrInvalidContext indicates the DID Document's `@context` is invalid

View Source
var ErrInvalidController = errors.New("invalid controller")

ErrInvalidController indicates the DID Document's `controller` is invalid

View Source
var ErrInvalidDID = ParserError{/* contains filtered or unexported fields */}

ErrInvalidDID is returned when a parser function is supplied with a string that can't be parsed as DID.

View Source
var ErrInvalidID = errors.New("invalid ID")

ErrInvalidID indicates the DID Document's `id` is invalid

View Source
var ErrInvalidKeyAgreement = errors.New("invalid keyAgreement")

ErrInvalidKeyAgreement indicates the keyAgreement is invalid (e.g. invalid `id` or `type`)

View Source
var ErrInvalidService = errors.New("invalid service")

ErrInvalidService indicates the service is invalid (e.g. invalid `id` or `type`)

View Source
var ErrInvalidVerificationMethod = errors.New("invalid verificationMethod")

ErrInvalidVerificationMethod indicates the verificationMethod is invalid (e.g. invalid `id` or `type`)

Functions

func Complement

func Complement(vs []string, ts []string) []string

Complement returns a new slice containing all strings from the slice that do not satisfy the predicate

func Contains

func Contains(vs []string, t string) bool

Contains returns true if the string is in the slice

func ContainsFragment

func ContainsFragment(didUrl string) bool

ContainsFragment checks if a DID has a fragment in the full string

func ContainsModule

func ContainsModule(didUrl string) bool

ContainsModule checks if a core service module is present in the DID

func ContainsPath

func ContainsPath(didUrl string) bool

ContainsPath returns true if a DID has a path in the full string

func ContainsQuery

func ContainsQuery(didUrl string) bool

ContainsQuery checks if a DID has a query in the full string

func ContainsString

func ContainsString(s string, t string) bool

ContainsString returns true if this string contains target string

func CreateDIDFromAccount added in v0.3.0

func CreateDIDFromAccount(creator string) string

GetCreatorDid returns the creator did

func DIDContextV1URI

func DIDContextV1URI() ssi.URI

DIDContextV1URI returns DIDContextV1 as a URI

func ExtractBase

func ExtractBase(did string) (bool, string)

ExtractBase extracts the did base (did:snr:<network>:<address>) or (did:snr:address)

func ExtractFragment

func ExtractFragment(didUrl string) (bool, string)

ExtractFragment splits a DID URL and pulls the fragment

func ExtractIdentifier

func ExtractIdentifier(did string) (bool, string)

ExtractIdentifier extracts the identifier from a DID

func ExtractPath

func ExtractPath(didUrl string) (bool, string)

ExtractPath splits a DID URL and pulls the path

func ExtractQuery

func ExtractQuery(didUrl string) (bool, string)

ExtractQuery splits a DID URL and pulls the query

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings from the slice that satisfy the predicate

func IndexOf

func IndexOf(vs []string, t string) int

IndexOf returns the index of the first instance of a value in a slice

func IsFragment

func IsFragment(didUrl string) bool

IsFragment checks if a DID fragment is valid

func IsPath

func IsPath(didUrl string) bool

IsPath returns true if a DID has a path in the full string

func IsQuery

func IsQuery(didUrl string) bool

IsQuery checks if a DID query is valid

func IsValidDid

func IsValidDid(did string) bool

IsValidDid checks if a DID is valid

func ToFragment

func ToFragment(str string) string

func ToIdentifier

func ToIdentifier(str string) string

func ToNetwork

func ToNetwork(str string) string

func ToQuery

func ToQuery(str string) string

Types

type Authenticator

type Authenticator struct {
	// The AAGUID of the authenticator. An AAGUID is defined as an array containing the globally unique
	// identifier of the authenticator model being sought.
	AAGUID []byte `json:"aaguid"`
	// SignCount -Upon a new login operation, the Relying Party compares the stored signature counter value
	// with the new signCount value returned in the assertion’s authenticator data. If this new
	// signCount value is less than or equal to the stored value, a cloned authenticator may
	// exist, or the authenticator may be malfunctioning.
	SignCount uint32 `json:"signCount"`
	// CloneWarning - This is a signal that the authenticator may be cloned, i.e. at least two copies of the
	// credential private key may exist and are being used in parallel. Relying Parties should incorporate
	// this information into their risk scoring. Whether the Relying Party updates the stored signature
	// counter value in this case, or not, or fails the authentication ceremony or not, is Relying Party-specific.
	CloneWarning bool `json:"cloneWarning"`
}

func (*Authenticator) UpdateCounter

func (a *Authenticator) UpdateCounter(authDataCount uint32)

VerifyCounter Step 17 of §7.2. about verifying attestation. If the signature counter value authData.signCount is nonzero or the value stored in conjunction with credential’s id attribute is nonzero, then run the following sub-step:

If the signature counter value authData.signCount is

→ Greater than the signature counter value stored in conjunction with credential’s id attribute.
Update the stored signature counter value, associated with credential’s id attribute, to be the value of
authData.signCount.

→ Less than or equal to the signature counter value stored in conjunction with credential’s id attribute.
This is a signal that the authenticator may be cloned, see CloneWarning above for more information.

type Credential

type Credential struct {
	// A probabilistically-unique byte sequence identifying a public key credential source and its authentication assertions.
	ID []byte `json:"id"`
	// The public key portion of a Relying Party-specific credential key pair, generated by an authenticator and returned to
	// a Relying Party at registration time (see also public key credential). The private key portion of the credential key
	// pair is known as the credential private key. Note that in the case of self attestation, the credential key pair is also
	// used as the attestation key pair, see self attestation for details.
	PublicKey []byte `json:"publicKey"`
	// The attestation format used (if any) by the authenticator when creating the credential.
	AttestationType string `json:"attestationType"`
	// The Authenticator information for a given certificate
	Authenticator Authenticator `json:"authenticator"`
}

Credential contains all needed information about a WebAuthn credential for storage

type DID

type DID struct {
	odid.DID
}

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

func MustParseDID

func MustParseDID(input string) DID

MustParseDID is like ParseDID but panics if the string cannot be parsed. It simplifies safe initialization of global variables holding compiled UUIDs.

func New added in v0.1.0

func New(addr string) (*DID, error)

func ParseDID

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

ParseDID parses a raw DID. If the input contains a path, query or fragment, use the ParseDIDURL instead. If it can't be parsed, an error is returned.

func (*DID) Address

func (d *DID) Address() string

Address returns the Sonr Account address from the given DID

func (DID) Empty

func (d DID) Empty() bool

Empty checks whether the DID is set or not

func (DID) Equals

func (d DID) Equals(other DID) bool

Equals checks whether the DID is exactly equal to another DID The check is case sensitive.

func (DID) MarshalJSON

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

MarshalJSON marshals the DID to a JSON string

func (DID) MarshalText

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

MarshalText implements encoding.TextMarshaler

func (DID) String

func (d DID) String() string

String returns the DID as formatted string.

func (DID) URI

func (d DID) URI() ssi.URI

URI converts the DID to an URI. URIs are used in Verifiable Credentials

func (*DID) UnmarshalJSON

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

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

type Document

type Document interface {
	json.Marshaler

	// AddCapabilityDelegation adds a VerificationMethod as CapabilityDelegation
	// If the controller is not set, it will be set to the document's ID
	AddCapabilityDelegation(v *VerificationMethod)
	// AddCapabilityDelegation adds a VerificationMethod as CapabilityDelegation
	// If the controller is not set, it will be set to the document's ID
	AddAuthenticationMethod(v *VerificationMethod)
	AddAssertionMethod(v *VerificationMethod)
	// AddCapabilityInvocation adds a VerificationMethod as CapabilityInvocation
	// If the controller is not set, it will be set to the document's ID
	AddCapabilityInvocation(v *VerificationMethod)
	// AddService adds a Service
	AddService(s Service)

	CopyFromBytes(b []byte) error

	// IsController returns whether the given DID is a controller of the DID document.
	IsController(controller DID) bool
	ControllersAsString() []string
	ControllerCount() int

	GetContext() []ssi.URI

	GetID() DID

	GetAlsoKnownAs() []string

	MarshalJSON() ([]byte, error)
	UnmarshalJSON(b []byte) error

	// AddAlias adds a string alias to the document for a .snr domain name into the AlsoKnownAs field
	// in the document.
	AddAlias(alias string)

	AddController(id DID)

	// ResolveEndpointURL finds the endpoint with the given type and unmarshalls it as single URL.
	// It returns the endpoint ID and URL, or an error if anything went wrong;
	// - holder document can't be resolved,
	// - service with given type doesn't exist,
	// - multiple services match,
	// - serviceEndpoint isn't a string.
	ResolveEndpointURL(serviceType string) (endpointID ssi.URI, endpointURL string, err error)

	// EncryptJWE(id DID, buf []byte) (string, error)
	// DecryptJWE(id DID, serial string) ([]byte, error)
	GetController(id DID) (DID, error)

	// FindAssertionMethod finds the first AssertionMethod with the given DID
	FindAssertionMethod(id DID) *VerificationMethod

	// FindAuthenticationMethod finds the first AuthenticationMethod with the given DID
	FindAuthenticationMethod(id DID) *VerificationMethod

	// FindCapabilityDelegation finds the first CapabilityDelegation with the given DID
	FindCapabilityDelegation(id DID) *VerificationMethod

	// FindCapabilityInvocation finds the first CapabilityInvocation with the given DID
	FindCapabilityInvocation(id DID) *VerificationMethod

	// GetAssertionMethods returns all AssertionMethods
	GetAssertionMethods() VerificationRelationships

	GetVerificationMethods() VerificationMethods

	// GetAuthenticationMethods returns all AuthenticationMethods
	GetAuthenticationMethods() VerificationRelationships

	// GetCapabilityDelegations returns all CapabilityDelegations
	GetCapabilityDelegations() VerificationRelationships

	// GetCapabilityInvocations returns all CapabilityInvocations
	GetCapabilityInvocations() VerificationRelationships

	GetKeyAgreements() VerificationRelationships

	// GetServices gets all services on the DID Document
	GetServices() Services
}

func BlankDocument added in v0.1.0

func BlankDocument() Document

BlankDocument creates a Blank Default DID Document

func NewDocument added in v0.1.0

func NewDocument(idStr string) (Document, error)

NewDocument generates a new DID Document for the provided ID string

type DocumentImpl added in v0.1.0

type DocumentImpl struct {
	Context              []ssi.URI                 `json:"@context"`
	ID                   DID                       `json:"id"`
	Controller           []DID                     `json:"controller,omitempty"`
	VerificationMethod   VerificationMethods       `json:"verificationMethod,omitempty"`
	Authentication       VerificationRelationships `json:"authentication,omitempty"`
	AssertionMethod      VerificationRelationships `json:"assertionMethod,omitempty"`
	KeyAgreement         VerificationRelationships `json:"keyAgreement,omitempty"`
	CapabilityInvocation VerificationRelationships `json:"capabilityInvocation,omitempty"`
	CapabilityDelegation VerificationRelationships `json:"capabilityDelegation,omitempty"`
	Service              Services                  `json:"service,omitempty"`
	AlsoKnownAs          []string                  `json:"alsoKnownAs,omitempty"`
}

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

func (*DocumentImpl) AddAlias added in v0.1.0

func (d *DocumentImpl) AddAlias(alias string)

AddAlias adds a string alias to the document for a .snr domain name into the AlsoKnownAs field in the document.

func (*DocumentImpl) AddAssertionMethod added in v0.1.0

func (d *DocumentImpl) AddAssertionMethod(v *VerificationMethod)

AddAssertionMethod adds a VerificationMethod as AssertionMethod If the controller is not set, it will be set to the documents ID

func (*DocumentImpl) AddAuthenticationMethod added in v0.1.0

func (d *DocumentImpl) AddAuthenticationMethod(v *VerificationMethod)

AddAuthenticationMethod adds a VerificationMethod as AuthenticationMethod If the controller is not set, it will be set to the document's ID

func (*DocumentImpl) AddCapabilityDelegation added in v0.1.0

func (d *DocumentImpl) AddCapabilityDelegation(v *VerificationMethod)

AddCapabilityDelegation adds a VerificationMethod as CapabilityDelegation If the controller is not set, it will be set to the document's ID

func (*DocumentImpl) AddCapabilityInvocation added in v0.1.0

func (d *DocumentImpl) AddCapabilityInvocation(v *VerificationMethod)

AddCapabilityInvocation adds a VerificationMethod as CapabilityInvocation If the controller is not set, it will be set to the document's ID

func (*DocumentImpl) AddController added in v0.1.0

func (d *DocumentImpl) AddController(id DID)

AddController adds a DID as a controller

func (*DocumentImpl) AddKeyAgreement added in v0.1.0

func (d *DocumentImpl) AddKeyAgreement(v *VerificationMethod)

AddKeyAgreement adds a VerificationMethod as KeyAgreement If the controller is not set, it will be set to the document's ID

func (*DocumentImpl) AddService added in v0.3.0

func (d *DocumentImpl) AddService(s Service)

func (*DocumentImpl) ControllerCount added in v0.1.0

func (d *DocumentImpl) ControllerCount() int

func (*DocumentImpl) ControllersAsString added in v0.1.0

func (d *DocumentImpl) ControllersAsString() []string

ControllersAsString returns all DID controllers as a string array

func (*DocumentImpl) CopyFromBytes added in v0.1.0

func (d *DocumentImpl) CopyFromBytes(b []byte) error

CopyFromBytes unmarshals a JSON document from a byte slice and copies the data into the receiver.

func (DocumentImpl) EqualsAlsoKnownAs added in v0.1.0

func (d DocumentImpl) EqualsAlsoKnownAs(doc *DocumentImpl) bool

EqualsAlsoKnownAs compares doc AlsoKnownAs and given docs also known as then returns true if they are equal.

func (DocumentImpl) EqualsAssertionMethod added in v0.1.0

func (d DocumentImpl) EqualsAssertionMethod(doc *DocumentImpl) bool

EqualsAssertionMethod compares doc AssertionMethod and given docs assertion method then returns true if they are equal.

func (DocumentImpl) EqualsAuthentication added in v0.1.0

func (d DocumentImpl) EqualsAuthentication(doc *DocumentImpl) bool

EqualsAuthentication compares doc Authentication and given docs authentication then returns true if they are equal.

func (DocumentImpl) EqualsCapabilityDelegation added in v0.1.0

func (d DocumentImpl) EqualsCapabilityDelegation(doc *DocumentImpl) bool

EqualsCapabilityDelegation compares doc CapabilityDelegation and given docs capability delegation then returns true if they are equal.

func (DocumentImpl) EqualsCapabilityInvocation added in v0.1.0

func (d DocumentImpl) EqualsCapabilityInvocation(doc *DocumentImpl) bool

DocumentImpl compares doc CapabilityInvocation and given docs capability invocation then returns true if they are equal.

func (DocumentImpl) EqualsKeyAgreement added in v0.1.0

func (d DocumentImpl) EqualsKeyAgreement(doc *DocumentImpl) bool

EqualsKeyAgreement compares doc KeyAgreement and given docs key agreement then returns true if they are equal.

func (DocumentImpl) EqualsService added in v0.1.0

func (d DocumentImpl) EqualsService(doc *DocumentImpl) bool

EqualsService compares doc Service and given docs service then returns true if they are equal.

func (DocumentImpl) EqualsVerificationMethod added in v0.1.0

func (d DocumentImpl) EqualsVerificationMethod(doc *DocumentImpl) bool

EqualsVerificationMethod compares doc Verification Method and given docs verification method then returns true if they are equal.

func (*DocumentImpl) FindAssertionMethod added in v0.1.2

func (d *DocumentImpl) FindAssertionMethod(id DID) *VerificationMethod

FindAssertionMethod finds a VerificationMethod by its ID

func (*DocumentImpl) FindAuthenticationMethod added in v0.1.2

func (d *DocumentImpl) FindAuthenticationMethod(id DID) *VerificationMethod

FindAuthenticationMethod finds a VerificationMethod by its ID

func (*DocumentImpl) FindCapabilityDelegation added in v0.1.2

func (d *DocumentImpl) FindCapabilityDelegation(id DID) *VerificationMethod

FindCapabilityDelegation finds a VerificationMethod by its ID

func (*DocumentImpl) FindCapabilityInvocation added in v0.1.2

func (d *DocumentImpl) FindCapabilityInvocation(id DID) *VerificationMethod

FindCapabilityInvocation finds a VerificationMethod by its ID

func (*DocumentImpl) GetAlsoKnownAs added in v0.1.0

func (d *DocumentImpl) GetAlsoKnownAs() []string

func (*DocumentImpl) GetAssertionMethods added in v0.1.3

func (d *DocumentImpl) GetAssertionMethods() VerificationRelationships

GetAssertionMethods returns the list of assertion methods

func (*DocumentImpl) GetAuthenticationMethods added in v0.1.3

func (d *DocumentImpl) GetAuthenticationMethods() VerificationRelationships

GetAuthenticationMethods returns the list of authentication methods

func (*DocumentImpl) GetCapabilityDelegations added in v0.1.3

func (d *DocumentImpl) GetCapabilityDelegations() VerificationRelationships

GetCapabilityDelegations returns the list of capability delegations

func (*DocumentImpl) GetCapabilityInvocations added in v0.1.3

func (d *DocumentImpl) GetCapabilityInvocations() VerificationRelationships

GetCapabilityInvocations returns the list of capability invocations

func (*DocumentImpl) GetContext added in v0.3.0

func (d *DocumentImpl) GetContext() []ssi.URI

func (*DocumentImpl) GetController added in v0.1.0

func (d *DocumentImpl) GetController(did DID) (DID, error)

func (*DocumentImpl) GetID added in v0.1.0

func (d *DocumentImpl) GetID() DID

func (*DocumentImpl) GetKeyAgreements added in v0.3.0

func (d *DocumentImpl) GetKeyAgreements() VerificationRelationships

func (*DocumentImpl) GetServices added in v0.3.0

func (d *DocumentImpl) GetServices() Services

func (*DocumentImpl) GetVerificationMethods added in v0.3.0

func (d *DocumentImpl) GetVerificationMethods() VerificationMethods

func (DocumentImpl) IsController added in v0.1.0

func (d DocumentImpl) IsController(controller DID) bool

IsController returns whether the given DID is a controller of the DID document.

func (DocumentImpl) MarshalJSON added in v0.1.0

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

func (DocumentImpl) MatchesID added in v0.1.0

func (d DocumentImpl) MatchesID(doc *DocumentImpl) bool

MatchesID returns true if the two DIDs are equal.

func (*DocumentImpl) ResolveEndpointURL added in v0.1.0

func (d *DocumentImpl) ResolveEndpointURL(serviceType string) (endpointID ssi.URI, endpointURL string, err error)

ResolveEndpointURL finds the endpoint with the given type and unmarshalls it as single URL. It returns the endpoint ID and URL, or an error if anything went wrong; - holder document can't be resolved, - service with given type doesn't exist, - multiple services match, - serviceEndpoint isn't a string.

func (*DocumentImpl) UnmarshalJSON added in v0.1.0

func (d *DocumentImpl) 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 MultiValidator

type MultiValidator struct {
	Validators []Validator
}

MultiValidator is a validator that executes zero or more validators. It returns the first validation error it encounters.

func (MultiValidator) Validate

func (m MultiValidator) Validate(document DocumentImpl) error

type ParserError

type ParserError struct {
	// contains filtered or unexported fields
}

ParserError is used when returning DID-parsing related errors.

func (ParserError) Error

func (w ParserError) Error() string

Error returns the message of the error.

func (ParserError) Is

func (w ParserError) Is(other error) bool

Is checks whether the given error is a ParserError

func (ParserError) Unwrap

func (w ParserError) Unwrap() error

Unwrap returns the underlying error.

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              ssi.URI           `json:"id"`
	Type            string            `json:"type,omitempty"`
	ServiceEndpoint map[string]string `json:"serviceEndpoint,omitempty"`
}

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

func (Service) MarshalJSON

func (s Service) MarshalJSON() ([]byte, error)

func (*Service) UnmarshalJSON

func (s *Service) UnmarshalJSON(data []byte) error

func (Service) UnmarshalServiceEndpoint

func (s Service) UnmarshalServiceEndpoint(target interface{}) error

Unmarshal unmarshalls the service endpoint into a domain-specific type.

type Services added in v0.1.0

type Services []Service

func (Services) FindByID added in v0.1.0

func (srs Services) FindByID(id ssi.URI) *Service

FindByID returns the first VerificationRelationship that matches with the id. For comparison both the ID of the embedded VerificationMethod and reference is used.

type Validator

type Validator interface {
	// Validate validates a DID document. It returns the first validation error is finds wrapped in ErrDIDDocumentInvalid.
	Validate(document DocumentImpl) error
}

Validator defines functions for validating a DID document.

type VerificationMethod

type VerificationMethod struct {
	ID              DID                    `json:"id"`
	Type            ssi.KeyType            `json:"type,omitempty"`
	Controller      DID                    `json:"controller,omitempty"`
	PublicKeyBase58 string                 `json:"publicKeyBase58,omitempty"`
	PublicKeyJwk    map[string]interface{} `json:"publicKeyJwk,omitempty"`
	Credential      *Credential            `json:"credential,omitempty"`
}

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

func NewVerificationMethod

func NewVerificationMethod(id DID, keyType ssi.KeyType, controller DID, key crypto.PublicKey) (*VerificationMethod, error)

NewVerificationMethod is a convenience method to easily create verificationMethods based on a set of given params. It automatically encodes the provided public key based on the keyType.

func NewVerificationMethodFromBytes added in v0.5.0

func NewVerificationMethodFromBytes(id DID, keyType ssi.KeyType, controller DID, key []byte) (*VerificationMethod, error)

NewVerificationMethod is a convenience method to easily create verificationMethods based on a set of given params. It automatically encodes the provided public key based on the keyType.

func (*VerificationMethod) UnmarshalJSON

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

type VerificationMethods

type VerificationMethods []*VerificationMethod

func (*VerificationMethods) Add

Add adds a verificationMethod to the verificationMethods if it not already present.

func (VerificationMethods) FindByID

func (vms VerificationMethods) FindByID(id DID) *VerificationMethod

FindByID find the first VerificationMethod which matches the provided DID. Returns nil when not found

func (*VerificationMethods) Remove

func (vms *VerificationMethods) Remove(id DID) *VerificationMethod

Remove removes a VerificationMethod from the slice. If a verificationMethod was removed with the given DID, it will be returned

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) MarshalJSON

func (v VerificationRelationship) MarshalJSON() ([]byte, error)

func (*VerificationRelationship) UnmarshalJSON

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

type VerificationRelationships

type VerificationRelationships []VerificationRelationship

func (*VerificationRelationships) Add

Add adds a verificationMethod to a relationship collection. When the collection already contains the method it will not be added again.

func (VerificationRelationships) Count added in v0.1.3

func (vmr VerificationRelationships) Count() int

Count returns the number of VerificationRelationships in the slice

func (VerificationRelationships) FindByID

FindByID returns the first VerificationRelationship that matches with the id. For comparison both the ID of the embedded VerificationMethod and reference is used.

func (*VerificationRelationships) Remove

Remove removes a VerificationRelationship from the slice. If a VerificationRelationship was removed with the given DID, it will be returned

type W3CSpecValidator

type W3CSpecValidator struct {
}

W3CSpecValidator validates a DID document according to the W3C DID Core Data Model specification (https://www.w3.org/TR/did-core/).

func (W3CSpecValidator) Validate

func (w W3CSpecValidator) Validate(document DocumentImpl) error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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