github.com/hyperledger/aries-framework-go@v0.3.2/pkg/framework/aries/api/vdr/vdr.go (about)

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