This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
/
vdr.go
62 lines (49 loc) · 1.8 KB
/
vdr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package vdr
import (
"errors"
"github.com/hyperledger/aries-framework-go/pkg/doc/did"
)
// ErrNotFound is returned when a DID resolver does not find the DID.
var ErrNotFound = errors.New("DID does not exist")
const (
// DIDCommServiceType default DID Communication service endpoint type.
DIDCommServiceType = "did-communication"
// DIDCommV2ServiceType is the DID Communications V2 service type.
DIDCommV2ServiceType = "DIDCommMessaging"
// LegacyServiceType is the DID Communication V1 indy based service type.
LegacyServiceType = "IndyAgent"
)
// Registry vdr registry.
type Registry interface {
Resolve(did string, opts ...DIDMethodOption) (*did.DocResolution, error)
Create(method string, did *did.Doc, opts ...DIDMethodOption) (*did.DocResolution, error)
Update(did *did.Doc, opts ...DIDMethodOption) error
Deactivate(did string, opts ...DIDMethodOption) error
Close() error
}
// VDR verifiable data registry interface.
// TODO https://github.com/hyperledger/aries-framework-go/issues/2475
type VDR interface {
Read(did string, opts ...DIDMethodOption) (*did.DocResolution, error)
Create(did *did.Doc, opts ...DIDMethodOption) (*did.DocResolution, error)
Accept(method string, opts ...DIDMethodOption) bool
Update(did *did.Doc, opts ...DIDMethodOption) error
Deactivate(did string, opts ...DIDMethodOption) error
Close() error
}
// DIDMethodOpts did method opts.
type DIDMethodOpts struct {
Values map[string]interface{}
}
// DIDMethodOption is a did method option.
type DIDMethodOption func(opts *DIDMethodOpts)
// WithOption add option for did method.
func WithOption(name string, value interface{}) DIDMethodOption {
return func(didMethodOpts *DIDMethodOpts) {
didMethodOpts.Values[name] = value
}
}