Documentation
¶
Overview ¶
Package didservice contains DID Document related functionality that only matters to the current node. All functionality here has zero relations to the network.
Index ¶
- Constants
- Variables
- func ByServiceType(serviceType string) types.Predicate
- func CreateDocument() did.Document
- func CreateNewVerificationMethodForDID(ctx context.Context, id did.DID, keyCreator nutsCrypto.KeyCreator) (*did.VerificationMethod, error)
- func DefaultCreationOptions() vdr.DIDCreationOptions
- func ExtractFirstRelationKeyIDByType(doc did.Document, relationType types.RelationType) (ssi.URI, error)
- func GetDIDFromURL(didURL string) (did.DID, error)
- func IsActive() types.Predicate
- func IsDeactivated(document did.Document) bool
- func IsFunctionalResolveError(target error) bool
- func IsServiceReference(endpoint string) bool
- func JWS2020ContextV1URI() ssi.URI
- func MakeServiceReference(subjectDID did.DID, serviceType string) ssi.URI
- func NutsDIDContextV1URI() ssi.URI
- func ValidAt(at time.Time) types.Predicate
- func ValidateServiceReference(endpointURI ssi.URI) error
- type Creator
- type DIDServiceQueryError
- type Finder
- type KeyResolver
- func (r KeyResolver) ResolveAssertionKeyID(id did.DID) (ssi.URI, error)
- func (r KeyResolver) ResolveKeyAgreementKey(id did.DID) (crypto.PublicKey, error)
- func (r KeyResolver) ResolvePublicKey(kid string, sourceTransactionsRefs []hash.SHA256Hash) (crypto.PublicKey, error)
- func (r KeyResolver) ResolveRelationKey(keyID string, validAt *time.Time, relationType types.RelationType) (crypto.PublicKey, error)
- func (r KeyResolver) ResolveRelationKeyID(id did.DID, relationType types.RelationType) (ssi.URI, error)
- func (r KeyResolver) ResolveSigningKey(keyID string, validAt *time.Time) (crypto.PublicKey, error)
- func (r KeyResolver) ResolveSigningKeyID(holder did.DID, validAt *time.Time) (string, error)
- type Manipulator
- type Resolver
- type ServiceResolver
Constants ¶
const DefaultMaxServiceReferenceDepth = 5
DefaultMaxServiceReferenceDepth holds the default max. allowed depth for DID service references.
const JWS2020ContextV1 = "https://w3c-ccg.github.io/lds-jws2020/contexts/lds-jws2020-v1.json"
JWS2020ContextV1 contains the JSON-LD context for JWS and JWK
const NutsDIDContextV1 = "https://nuts.nl/did/v1"
NutsDIDContextV1 contains the Nuts specific JSON-LD context for a DID Document
const NutsDIDMethodName = "nuts"
NutsDIDMethodName is the DID method name used by Nuts
Variables ¶
var ErrInvalidOptions = errors.New("create request has invalid combination of options: SelfControl = true and CapabilityInvocation = false")
ErrInvalidOptions is returned when the given options have an invalid combination
var ErrNestedDocumentsTooDeep = errors.New("DID Document controller structure has too many indirections")
ErrNestedDocumentsTooDeep is returned when a DID Document contains a multiple services with the same type
Functions ¶
func ByServiceType ¶
ByServiceType returns a predicate that matches on service type it only matches on DID Documents with a concrete endpoint (not starting with "did")
func CreateDocument ¶
CreateDocument creates an empty DID document with baseline properties set.
func CreateNewVerificationMethodForDID ¶
func CreateNewVerificationMethodForDID(ctx context.Context, id did.DID, keyCreator nutsCrypto.KeyCreator) (*did.VerificationMethod, error)
CreateNewVerificationMethodForDID creates a new VerificationMethod of type JsonWebKey2020 with a freshly generated key for a given DID.
func DefaultCreationOptions ¶
func DefaultCreationOptions() vdr.DIDCreationOptions
DefaultCreationOptions returns the default DIDCreationOptions when creating DID Documents.
func ExtractFirstRelationKeyIDByType ¶
func ExtractFirstRelationKeyIDByType(doc did.Document, relationType types.RelationType) (ssi.URI, error)
ExtractFirstRelationKeyIDByType returns the first relation key ID from the given DID document matching the relationType. Returns a types.ErrKeyNotFound if no relation key of the given relationType is present.
func GetDIDFromURL ¶
GetDIDFromURL returns the DID from the given URL, stripping any query parameters, path segments and fragments.
func IsDeactivated ¶
IsDeactivated returns true if the DID.Document has already been deactivated
func IsFunctionalResolveError ¶
IsFunctionalResolveError returns true if the given error indicates the DID or service not being found or invalid, e.g. because it is deactivated, referenced too deeply, etc.
func IsServiceReference ¶
IsServiceReference checks whether the given endpoint string looks like a service reference (e.g. did:nuts:1234/serviceType?type=HelloWorld).
func JWS2020ContextV1URI ¶
JWS2020ContextV1URI returns JWS2020ContextV1 as a URI
func MakeServiceReference ¶
MakeServiceReference creates a service reference, which can be used as query when looking up services.
func NutsDIDContextV1URI ¶
NutsDIDContextV1URI returns NutsDIDContextV1 as a URI
func ValidateServiceReference ¶
func ValidateServiceReference(endpointURI ssi.URI) error
ValidateServiceReference checks whether the given URI matches the format for a service reference.
Types ¶
type Creator ¶
type Creator struct {
// KeyStore is used for getting a fresh key and use it to generate the Nuts DID
KeyStore nutsCrypto.KeyCreator
}
Creator implements the DocCreator interface and can create Nuts DID Documents.
func (Creator) Create ¶
func (n Creator) Create(ctx context.Context, options vdr.DIDCreationOptions) (*did.Document, nutsCrypto.Key, error)
Create creates a Nuts DID Document with a valid DID id based on a freshly generated keypair. The key is added to the verificationMethod list and referred to from the Authentication list
type DIDServiceQueryError ¶
type DIDServiceQueryError struct {
Err error // cause
}
DIDServiceQueryError denies the query based on validation constraints.
func (DIDServiceQueryError) Error ¶
func (e DIDServiceQueryError) Error() string
Error implements the error interface.
func (DIDServiceQueryError) Unwrap ¶
func (e DIDServiceQueryError) Unwrap() error
Unwrap implements the errors.Unwrap convention.
type KeyResolver ¶
KeyResolver implements the KeyResolver interface with a types.Store as backend
func (KeyResolver) ResolveAssertionKeyID ¶
ResolveAssertionKeyID resolves the id of the first valid AssertionMethod of an indicated DID document in the current state.
func (KeyResolver) ResolveKeyAgreementKey ¶
ResolveKeyAgreementKey resolves the public key of the first valid KeyAgreement of an indicated DID document in the current state. If the document has no KeyAgreements, types.ErrKeyNotFound is returned.
func (KeyResolver) ResolvePublicKey ¶
func (r KeyResolver) ResolvePublicKey(kid string, sourceTransactionsRefs []hash.SHA256Hash) (crypto.PublicKey, error)
func (KeyResolver) ResolveRelationKey ¶
func (r KeyResolver) ResolveRelationKey(keyID string, validAt *time.Time, relationType types.RelationType) (crypto.PublicKey, error)
func (KeyResolver) ResolveRelationKeyID ¶
func (r KeyResolver) ResolveRelationKeyID(id did.DID, relationType types.RelationType) (ssi.URI, error)
func (KeyResolver) ResolveSigningKey ¶
ResolveSigningKey resolves the PublicKey of the first valid AssertionMethod for an indicated DID document at a validAt time.
func (KeyResolver) ResolveSigningKeyID ¶
ResolveSigningKeyID resolves the ID of the first valid AssertionMethod for an indicated DID document at a given time.
type Manipulator ¶
type Manipulator struct {
// KeyCreator is used for getting a fresh key and use it to generate the Nuts DID
KeyCreator nutsCrypto.KeyCreator
// Updater is used for updating DID documents after the operation has been performed
Updater types.DocUpdater
// Resolver is used for resolving DID Documents
Resolver types.DocResolver
}
Manipulator contains helper methods to update a Nuts DID document.
func (Manipulator) AddVerificationMethod ¶
func (u Manipulator) AddVerificationMethod(ctx context.Context, id did.DID, keyUsage types.DIDKeyFlags) (*did.VerificationMethod, error)
AddVerificationMethod adds a new key as a VerificationMethod to the document. The key is added to the VerficationMethod relationships specified by keyUsage.
func (Manipulator) Deactivate ¶
Deactivate updates the DID Document so it can no longer be updated It removes key material, services and controllers.
func (Manipulator) RemoveVerificationMethod ¶
RemoveVerificationMethod is a helper function to remove a verificationMethod from a DID Document
type Resolver ¶
Resolver implements the DocResolver interface with a types.Store as backend
func (Resolver) Resolve ¶
func (d Resolver) Resolve(id did.DID, metadata *types.ResolveMetadata) (*did.Document, *types.DocumentMetadata, error)
func (Resolver) ResolveControllers ¶
func (d Resolver) ResolveControllers(doc did.Document, metadata *types.ResolveMetadata) ([]did.Document, error)
ResolveControllers finds the DID Document controllers
type ServiceResolver ¶
ServiceResolver is a wrapper around a DID store that allows resolving services, following references.