Documentation ¶
Overview ¶
Package doc contains DID Document related functionality that only matters to the current node. All functionality here has zero relations to the network.
Package doc is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ByServiceType(serviceType string) types.Predicate
- func CreateDocument() did.Document
- func CreateNewVerificationMethodForDID(id did.DID, keyCreator nutsCrypto.KeyCreator) (*did.VerificationMethod, error)
- func DefaultCreationOptions() vdr.DIDCreationOptions
- func ExtractAssertionKeyID(doc did.Document) (ssi.URI, error)
- func IsActive() types.Predicate
- func IsServiceReference(endpoint string) bool
- func MakeServiceReference(subjectDID did.DID, serviceType string) ssi.URI
- func MergeDocuments(docA did.Document, docB did.Document) (*did.Document, error)
- func ValidAt(at time.Time) types.Predicate
- func ValidateServiceReference(endpointURI ssi.URI) error
- type Creator
- 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) ResolvePublicKeyInTime(kid string, validAt *time.Time) (crypto.PublicKey, 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 MockServiceResolver
- type MockServiceResolverMockRecorder
- type Resolver
- type ServiceResolver
- type StaticKeyResolver
- func (s StaticKeyResolver) ResolveAssertionKeyID(_ did.DID) (ssi.URI, error)
- func (s StaticKeyResolver) ResolveKeyAgreementKey(_ did.DID) (crypto.PublicKey, error)
- func (s StaticKeyResolver) ResolvePublicKey(_ string, _ []hash.SHA256Hash) (crypto.PublicKey, error)
- func (s StaticKeyResolver) ResolvePublicKeyInTime(_ string, _ *time.Time) (crypto.PublicKey, error)
- func (s StaticKeyResolver) ResolveSigningKey(_ string, _ *time.Time) (crypto.PublicKey, error)
- func (s StaticKeyResolver) ResolveSigningKeyID(_ did.DID, _ *time.Time) (string, error)
Constants ¶
const DefaultMaxServiceReferenceDepth = 5
DefaultMaxServiceReferenceDepth holds the default max. allowed depth for DID service references.
const NutsDIDMethodName = "nuts"
NutsDIDMethodName is the DID method name used by Nuts
Variables ¶
var ErrDiffID = errors.New("no matching IDs")
ErrDiffID is returned when a merge is done on documents that do not share the same ID
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(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 ExtractAssertionKeyID ¶
ExtractAssertionKeyID returns a assertionMethod ID from the given DID document. it returns types.ErrKeyNotFound is no assertionMethod key is present.
func IsServiceReference ¶
IsServiceReference checks whether the given endpoint string looks like a service reference (e.g. did:nuts:1234/serviceType?type=HelloWorld).
func MakeServiceReference ¶
MakeServiceReference creates a service reference, which can be used as query when looking up services.
func MergeDocuments ¶
MergeDocuments merges two DID Documents that share the same ID
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(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 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) ResolvePublicKeyInTime ¶
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 a 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(id did.DID) (*did.VerificationMethod, error)
AddVerificationMethod adds a new key as a VerificationMethod to the document. The key is not used yet and should be manually added to one of the VerificationRelationships
func (Manipulator) Deactivate ¶
func (u Manipulator) Deactivate(id did.DID) error
Deactivate updates the DID Document so it can no longer be updated It removes key material, services and controllers.
func (Manipulator) RemoveVerificationMethod ¶
func (u Manipulator) RemoveVerificationMethod(id, keyID did.DID) error
RemoveVerificationMethod is a helper function to remove a verificationMethod from a DID Document When the verificationMethod is used in an assertion or authentication method, it is also removed there.
type MockServiceResolver ¶
type MockServiceResolver struct {
// contains filtered or unexported fields
}
MockServiceResolver is a mock of ServiceResolver interface.
func NewMockServiceResolver ¶
func NewMockServiceResolver(ctrl *gomock.Controller) *MockServiceResolver
NewMockServiceResolver creates a new mock instance.
func (*MockServiceResolver) EXPECT ¶
func (m *MockServiceResolver) EXPECT() *MockServiceResolverMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockServiceResolverMockRecorder ¶
type MockServiceResolverMockRecorder struct {
// contains filtered or unexported fields
}
MockServiceResolverMockRecorder is the mock recorder for MockServiceResolver.
func (*MockServiceResolverMockRecorder) Resolve ¶
func (mr *MockServiceResolverMockRecorder) Resolve(query, maxDepth interface{}) *gomock.Call
Resolve indicates an expected call of Resolve.
func (*MockServiceResolverMockRecorder) ResolveEx ¶
func (mr *MockServiceResolverMockRecorder) ResolveEx(endpoint, depth, maxDepth, documentCache interface{}) *gomock.Call
ResolveEx indicates an expected call of ResolveEx.
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 ¶
type ServiceResolver interface { // Resolve looks up the DID document of the specified query and then tries to find the service with the specified type. // The query must be in the form of a service query, e.g. `did:nuts:12345/serviceEndpoint?type=some-type`. // The maxDepth indicates how deep references are followed. If maxDepth = 0, no references are followed (and an error is returned if the given query resolves to a reference). // If the DID document or service is not found, a reference can't be resolved or the references exceed maxDepth, an error is returned. Resolve(query ssi.URI, maxDepth int) (did.Service, error) // ResolveEx tries to resolve a DID service from the given endpoint URI, following references (URIs that begin with 'did:'). // When the endpoint is a reference it resolves it up until the (per spec) max reference depth. When resolving a reference it recursively calls itself with depth + 1. // The documentCache map is used to avoid resolving the same document over and over again, which might be a (slightly more) expensive operation. ResolveEx(endpoint ssi.URI, depth int, maxDepth int, documentCache map[string]*did.Document) (did.Service, error) }
ServiceResolver allows looking up DID document services, following references.
func NewServiceResolver ¶
func NewServiceResolver(documentResolver types.DocResolver) ServiceResolver
NewServiceResolver creates a ServiceResolver with the specified types.DocResolver
type StaticKeyResolver ¶
func (StaticKeyResolver) ResolveAssertionKeyID ¶
func (StaticKeyResolver) ResolveKeyAgreementKey ¶
func (StaticKeyResolver) ResolvePublicKey ¶
func (s StaticKeyResolver) ResolvePublicKey(_ string, _ []hash.SHA256Hash) (crypto.PublicKey, error)