Documentation
¶
Index ¶
- Constants
- Variables
- func Complement(vs []string, ts []string) []string
- func Contains(vs []string, t string) bool
- func ContainsFragment(didUrl string) bool
- func ContainsModule(didUrl string) bool
- func ContainsPath(didUrl string) bool
- func ContainsQuery(didUrl string) bool
- func ContainsString(s string, t string) bool
- func CreateDIDFromAccount(creator string) string
- func DIDContextV1URI() ssi.URI
- func ExtractBase(did string) (bool, string)
- func ExtractFragment(didUrl string) (bool, string)
- func ExtractIdentifier(did string) (bool, string)
- func ExtractPath(didUrl string) (bool, string)
- func ExtractQuery(didUrl string) (bool, string)
- func Filter(vs []string, f func(string) bool) []string
- func IndexOf(vs []string, t string) int
- func IsFragment(didUrl string) bool
- func IsPath(didUrl string) bool
- func IsQuery(didUrl string) bool
- func IsValidDid(did string) bool
- func ToFragment(str string) string
- func ToIdentifier(str string) string
- func ToNetwork(str string) string
- func ToQuery(str string) string
- type Authenticator
- type Credential
- type DID
- type Document
- type DocumentImpl
- func (d *DocumentImpl) AddAlias(alias string)
- func (d *DocumentImpl) AddAssertionMethod(v *VerificationMethod)
- func (d *DocumentImpl) AddAuthenticationMethod(v *VerificationMethod)
- func (d *DocumentImpl) AddCapabilityDelegation(v *VerificationMethod)
- func (d *DocumentImpl) AddCapabilityInvocation(v *VerificationMethod)
- func (d *DocumentImpl) AddController(id DID)
- func (d *DocumentImpl) AddKeyAgreement(v *VerificationMethod)
- func (d *DocumentImpl) AddService(s Service)
- func (d *DocumentImpl) ControllerCount() int
- func (d *DocumentImpl) ControllersAsString() []string
- func (d *DocumentImpl) CopyFromBytes(b []byte) error
- func (d DocumentImpl) EqualsAlsoKnownAs(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsAssertionMethod(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsAuthentication(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsCapabilityDelegation(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsCapabilityInvocation(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsKeyAgreement(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsService(doc *DocumentImpl) bool
- func (d DocumentImpl) EqualsVerificationMethod(doc *DocumentImpl) bool
- func (d *DocumentImpl) FindAssertionMethod(id DID) *VerificationMethod
- func (d *DocumentImpl) FindAuthenticationMethod(id DID) *VerificationMethod
- func (d *DocumentImpl) FindCapabilityDelegation(id DID) *VerificationMethod
- func (d *DocumentImpl) FindCapabilityInvocation(id DID) *VerificationMethod
- func (d *DocumentImpl) GetAlsoKnownAs() []string
- func (d *DocumentImpl) GetAssertionMethods() VerificationRelationships
- func (d *DocumentImpl) GetAuthenticationMethods() VerificationRelationships
- func (d *DocumentImpl) GetCapabilityDelegations() VerificationRelationships
- func (d *DocumentImpl) GetCapabilityInvocations() VerificationRelationships
- func (d *DocumentImpl) GetContext() []ssi.URI
- func (d *DocumentImpl) GetController(did DID) (DID, error)
- func (d *DocumentImpl) GetID() DID
- func (d *DocumentImpl) GetKeyAgreements() VerificationRelationships
- func (d *DocumentImpl) GetServices() Services
- func (d *DocumentImpl) GetVerificationMethods() VerificationMethods
- func (d DocumentImpl) IsController(controller DID) bool
- func (d DocumentImpl) MarshalJSON() ([]byte, error)
- func (d DocumentImpl) MatchesID(doc *DocumentImpl) bool
- func (d *DocumentImpl) ResolveEndpointURL(serviceType string) (endpointID ssi.URI, endpointURL string, err error)
- func (d *DocumentImpl) UnmarshalJSON(b []byte) error
- type DocumentMetadata
- type MultiValidator
- type ParserError
- type Resolver
- type Service
- type Services
- type Validator
- type VerificationMethod
- type VerificationMethods
- type VerificationRelationship
- type VerificationRelationships
- type W3CSpecValidator
Constants ¶
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") )
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 )
const DIDContextV1 = "https://www.w3.org/ns/did/v1"
DIDContextV1 contains the JSON-LD context for a DID Document
Variables ¶
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(`^[^&\\]+$`) )
var ErrDIDDocumentInvalid = validationError{}
ErrDIDDocumentInvalid indicates DID Document validation failed
var ErrInvalidAssertionMethod = errors.New("invalid assertionMethod")
ErrInvalidAssertionMethod indicates the assertion method is invalid (e.g. invalid `id` or `type`)
var ErrInvalidAuthentication = errors.New("invalid authentication")
ErrInvalidAuthentication indicates the authentication is invalid (e.g. invalid `id` or `type`)
var ErrInvalidCapabilityDelegation = errors.New("invalid capabilityDelegation")
ErrInvalidCapabilityDelegation indicates the capabilityDelegation is invalid (e.g. invalid `id` or `type`)
var ErrInvalidCapabilityInvocation = errors.New("invalid capabilityInvocation")
ErrInvalidCapabilityInvocation indicates the capabilityInvocation is invalid (e.g. invalid `id` or `type`)
var ErrInvalidContext = errors.New("invalid context")
ErrInvalidContext indicates the DID Document's `@context` is invalid
var ErrInvalidController = errors.New("invalid controller")
ErrInvalidController indicates the DID Document's `controller` is invalid
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.
var ErrInvalidID = errors.New("invalid ID")
ErrInvalidID indicates the DID Document's `id` is invalid
var ErrInvalidKeyAgreement = errors.New("invalid keyAgreement")
ErrInvalidKeyAgreement indicates the keyAgreement is invalid (e.g. invalid `id` or `type`)
var ErrInvalidService = errors.New("invalid service")
ErrInvalidService indicates the service is invalid (e.g. invalid `id` or `type`)
var ErrInvalidVerificationMethod = errors.New("invalid verificationMethod")
ErrInvalidVerificationMethod indicates the verificationMethod is invalid (e.g. invalid `id` or `type`)
Functions ¶
func Complement ¶
Complement returns a new slice containing all strings from the slice that do not satisfy the predicate
func ContainsFragment ¶
ContainsFragment checks if a DID has a fragment in the full string
func ContainsModule ¶
ContainsModule checks if a core service module is present in the DID
func ContainsPath ¶
ContainsPath returns true if a DID has a path in the full string
func ContainsQuery ¶
ContainsQuery checks if a DID has a query in the full string
func ContainsString ¶
ContainsString returns true if this string contains target string
func CreateDIDFromAccount ¶ added in v0.3.0
GetCreatorDid returns the creator did
func ExtractBase ¶
ExtractBase extracts the did base (did:snr:<network>:<address>) or (did:snr:address)
func ExtractFragment ¶
ExtractFragment splits a DID URL and pulls the fragment
func ExtractIdentifier ¶
ExtractIdentifier extracts the identifier from a DID
func ExtractPath ¶
ExtractPath splits a DID URL and pulls the path
func ExtractQuery ¶
ExtractQuery splits a DID URL and pulls the query
func Filter ¶
Filter returns a new slice containing all strings from the slice that satisfy the predicate
func ToFragment ¶
func ToIdentifier ¶
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 ¶
DID represents a Decentralized Identifier as specified by the DID Core specification (https://www.w3.org/TR/did-core/#identifier).
func MustParseDID ¶
MustParseDID is like ParseDID but panics if the string cannot be parsed. It simplifies safe initialization of global variables holding compiled UUIDs.
func ParseDID ¶
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) Equals ¶
Equals checks whether the DID is exactly equal to another DID The check is case sensitive.
func (DID) MarshalJSON ¶
MarshalJSON marshals the DID to a JSON string
func (DID) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (*DID) UnmarshalJSON ¶
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
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 (*Service) UnmarshalJSON ¶
func (Service) UnmarshalServiceEndpoint ¶
Unmarshal unmarshalls the service endpoint into a domain-specific type.
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 ¶
func (vms *VerificationMethods) Add(v *VerificationMethod)
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 ¶
func (vmr *VerificationRelationships) Add(vm *VerificationMethod)
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 ¶
func (vmr VerificationRelationships) FindByID(id DID) *VerificationMethod
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 ¶
func (vmr *VerificationRelationships) Remove(id DID) *VerificationRelationship
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