did

package
v0.0.2-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandlerResolver

func NewHandlerResolver(handlers map[didsdk.Method]MethodHandler) (*resolution.MultiMethodResolver, error)

NewHandlerResolver creates a new HandlerResolver from a map of MethodHandlers which are used to resolve DIDs stored in our database

Types

type CreateDIDRequest

type CreateDIDRequest struct {
	Method  didsdk.Method           `json:"method" validate:"required"`
	KeyType crypto.KeyType          `validate:"required"`
	Options CreateDIDRequestOptions `json:"options"`
}

CreateDIDRequest is the JSON-serializable request for creating a DID across DID method

type CreateDIDRequestOptions

type CreateDIDRequestOptions interface {
	Method() didsdk.Method
}

type CreateDIDResponse

type CreateDIDResponse struct {
	DID didsdk.Document `json:"did"`
}

CreateDIDResponse is the JSON-serializable response for creating a DID

type CreateIONDIDOptions

type CreateIONDIDOptions struct {
	// TODO(gabe) for now we only allow adding service endpoints upon creation.
	//  we do not allow adding external keys or other properties.
	//  Related:
	//  - https://github.com/TBD54566975/ssi-sdk/issues/336
	//  - https://github.com/TBD54566975/ssi-sdk/issues/335
	ServiceEndpoints []did.Service `json:"serviceEndpoints"`
}

func (CreateIONDIDOptions) Method

func (c CreateIONDIDOptions) Method() did.Method

type CreateWebDIDOptions

type CreateWebDIDOptions struct {
	// e.g. did:web:example.com
	DIDWebID string `json:"didWebId" validate:"required"`
}

func (CreateWebDIDOptions) Method

func (c CreateWebDIDOptions) Method() did.Method

type DefaultStoredDID

type DefaultStoredDID struct {
	ID          string       `json:"id"`
	DID         did.Document `json:"did"`
	SoftDeleted bool         `json:"softDeleted"`
}

DefaultStoredDID is the default implementation of StoredDID if no other implementation requirements are needed.

func (DefaultStoredDID) GetDocument

func (d DefaultStoredDID) GetDocument() did.Document

func (DefaultStoredDID) GetID

func (d DefaultStoredDID) GetID() string

func (DefaultStoredDID) IsSoftDeleted

func (d DefaultStoredDID) IsSoftDeleted() bool

type DeleteDIDRequest

type DeleteDIDRequest struct {
	Method didsdk.Method `json:"method" validate:"required"`
	ID     string        `json:"id" validate:"required"`
}

type GetDIDRequest

type GetDIDRequest struct {
	Method didsdk.Method `json:"method" validate:"required"`
	ID     string        `json:"id" validate:"required"`
}

type GetDIDResponse

type GetDIDResponse struct {
	DID didsdk.Document `json:"did"`
}

GetDIDResponse is the JSON-serializable response for getting a DID

type GetKeyFromDIDRequest

type GetKeyFromDIDRequest struct {
	ID    string `json:"id" validate:"required"`
	KeyID string `json:"keyId,omitempty"`
}

type GetKeyFromDIDResponse

type GetKeyFromDIDResponse struct {
	KeyID     string             `json:"keyId"`
	PublicKey gocrypto.PublicKey `json:"publicKey"`
}

type GetSupportedMethodsResponse

type GetSupportedMethodsResponse struct {
	Methods []didsdk.Method `json:"method"`
}

type ListDIDsRequest

type ListDIDsRequest struct {
	Method  didsdk.Method `json:"method" validate:"required"`
	Deleted bool          `json:"deleted"`
}

type ListDIDsResponse

type ListDIDsResponse struct {
	DIDs []didsdk.Document `json:"dids"`
}

ListDIDsResponse is the JSON-serializable response for getting all DIDs for a given method

type MethodHandler

type MethodHandler interface {
	GetMethod() didsdk.Method
	CreateDID(ctx context.Context, request CreateDIDRequest) (*CreateDIDResponse, error)
	// TODO(gabe): support query parameters to get soft deleted and other DIDs https://github.com/TBD54566975/ssi-service/issues/364
	GetDID(ctx context.Context, request GetDIDRequest) (*GetDIDResponse, error)
	ListDIDs(ctx context.Context) (*ListDIDsResponse, error)
	ListDeletedDIDs(ctx context.Context) (*ListDIDsResponse, error)
	SoftDeleteDID(ctx context.Context, request DeleteDIDRequest) error
}

MethodHandler describes the functionality of *all* possible DID service, regardless of method TODO(gabe) consider smaller/more composable interfaces and promoting reusability across methods https://github.com/TBD54566975/ssi-service/issues/362

func NewIONHandler

func NewIONHandler(baseURL string, s *Storage, ks *keystore.Service) (MethodHandler, error)

func NewKeyHandler

func NewKeyHandler(s *Storage, ks *keystore.Service) (MethodHandler, error)

func NewWebHandler

func NewWebHandler(s *Storage, ks *keystore.Service) (MethodHandler, error)

type ResolveDIDRequest

type ResolveDIDRequest struct {
	DID string `json:"did" validate:"required"`
}

type ResolveDIDResponse

type ResolveDIDResponse struct {
	ResolutionMetadata  *resolution.Metadata         `json:"didResolutionMetadata,omitempty"`
	DIDDocument         *didsdk.Document             `json:"didDocument"`
	DIDDocumentMetadata *resolution.DocumentMetadata `json:"didDocumentMetadata,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewDIDService

func NewDIDService(config config.DIDServiceConfig, s storage.ServiceStorage, keyStore *keystore.Service) (*Service, error)

func (*Service) Config

func (s *Service) Config() config.DIDServiceConfig

func (*Service) CreateDIDByMethod

func (s *Service) CreateDIDByMethod(ctx context.Context, request CreateDIDRequest) (*CreateDIDResponse, error)

func (*Service) GetDIDByMethod

func (s *Service) GetDIDByMethod(ctx context.Context, request GetDIDRequest) (*GetDIDResponse, error)

func (*Service) GetKeyFromDID

func (s *Service) GetKeyFromDID(ctx context.Context, request GetKeyFromDIDRequest) (*GetKeyFromDIDResponse, error)

func (*Service) GetResolver

func (s *Service) GetResolver() didresolution.Resolver

func (*Service) GetSupportedMethods

func (s *Service) GetSupportedMethods() GetSupportedMethodsResponse

func (*Service) ListDIDsByMethod

func (s *Service) ListDIDsByMethod(ctx context.Context, request ListDIDsRequest) (*ListDIDsResponse, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, did string, opts ...didresolution.Option) (*didresolution.Result, error)

func (*Service) ResolveDID

func (s *Service) ResolveDID(request ResolveDIDRequest) (*ResolveDIDResponse, error)

func (*Service) SoftDeleteDIDByMethod

func (s *Service) SoftDeleteDIDByMethod(ctx context.Context, request DeleteDIDRequest) error

func (*Service) Status

func (s *Service) Status() framework.Status

Status is a self-reporting status for the DID service.

func (*Service) Type

func (s *Service) Type() framework.Type

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewDIDStorage

func NewDIDStorage(db storage.ServiceStorage) (*Storage, error)

func (*Storage) DeleteDID

func (ds *Storage) DeleteDID(ctx context.Context, id string) error

func (*Storage) GetDID

func (ds *Storage) GetDID(ctx context.Context, id string, out StoredDID) error

GetDID attempts to get a DID from the database. It will return an error if it cannot. The out parameter must be a pointer to a struct that implements the StoredDID interface.

func (*Storage) GetDIDDefault

func (ds *Storage) GetDIDDefault(ctx context.Context, id string) (*DefaultStoredDID, error)

GetDIDDefault is a convenience method for getting a DID that is stored as a DefaultStoredDID.

func (*Storage) ListDIDs

func (ds *Storage) ListDIDs(ctx context.Context, method string, outType StoredDID) ([]StoredDID, error)

ListDIDs attempts to get all DIDs for a given method. It will return those it can even if it has trouble with some. The out parameter must be a pointer to a struct for a type that implement the StoredDID interface. The result is a slice of the type of the out parameter (an array of pointers to the type of the out parameter).)

func (*Storage) ListDIDsDefault

func (ds *Storage) ListDIDsDefault(ctx context.Context, method string) ([]DefaultStoredDID, error)

func (*Storage) StoreDID

func (ds *Storage) StoreDID(ctx context.Context, did StoredDID) error

type StoredDID

type StoredDID interface {
	GetID() string
	GetDocument() did.Document
	IsSoftDeleted() bool
}

StoredDID is a DID that has been stored in the database. It is an interface to allow for different implementations of DID storage based on the DID method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL