did

package
v0.0.0-...-ef7a112 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 27 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 Anchor

type Anchor struct {
	// The result of calling anchor.
	Err string
}

type BatchCreateDIDsRequest

type BatchCreateDIDsRequest struct {
	Requests []CreateDIDRequest `json:"requests"`
}

type BatchCreateDIDsResponse

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

type BatchService

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

func (*BatchService) BatchCreateDIDs

func (s *BatchService) BatchCreateDIDs(ctx context.Context, batchReq BatchCreateDIDsRequest) (*BatchCreateDIDsResponse, error)

func (*BatchService) Config

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

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 {
	// Services to add to the DID document that will be created.
	ServiceEndpoints []did.Service `json:"serviceEndpoints"`

	// List of JSON Web Signatures serialized using compact serialization. The payload must be a JSON object that
	// represents a publicKey object. Such object must follow the schema described in step 3 of
	// https://identity.foundation/sidetree/spec/#add-public-keys. The payload must be signed
	// with the private key associated with the `publicKeyJwk` that will be added in the DID document.
	// The input will be parsed and verified, and the payload will be used to add public keys to the DID document in the
	// same way in which the `add-public-keys` patch action adds keys (see https://identity.foundation/sidetree/spec/#add-public-keys).
	JWSPublicKeys []string `json:"jwsPublicKeys"`
}

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"`

	PageRequest *common.Page
}

type ListDIDsResponse

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

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

type MethodHandler

type MethodHandler interface {
	// GetMethod returns the did method that this handler is implementing.
	GetMethod() didsdk.Method

	// CreateDID creates a DID who's did method is `GetMethod`.
	CreateDID(ctx context.Context, request CreateDIDRequest) (*CreateDIDResponse, error)

	// GetDID returns a DID document for a did who's method is `GetMethod`. The DID must not have been soft-deleted.
	// TODO(gabe): support query parameters to get soft deleted and other DIDs https://github.com/fapiper/onchain-access-control/issues/364
	GetDID(ctx context.Context, request GetDIDRequest) (*GetDIDResponse, error)

	// ListDIDs returns all non-deleted DIDs for the given page. When page is nil, all non-deleted DIDs will be returned.
	ListDIDs(ctx context.Context, page *common.Page) (*ListDIDsResponse, error)

	// ListDeletedDIDs returns all soft-deleted DIDs.
	ListDeletedDIDs(ctx context.Context) (*ListDIDsResponse, error)

	// SoftDeleteDID marks the given DID as deleted. It is not removed from storage.
	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/fapiper/onchain-access-control/issues/362

func NewIONHandler

func NewIONHandler(baseURL string, s *Storage, ks *keystore.Service, factory keystore.ServiceFactory, storageFactory StorageFactory) (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 PreAnchor

type PreAnchor struct {
	UpdateOperation        *ion.UpdateRequest
	NextUpdatePublicJWK    *jwx.PublicKeyJWK
	UpdatedDID             *ionStoredDID
	NextUpdatePrivateJWKID string
}

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, factory keystore.ServiceFactory) (*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

func (*Service) UpdateIONDID

func (s *Service) UpdateIONDID(ctx context.Context, request UpdateIONDIDRequest) (*UpdateIONDIDResponse, error)

type Storage

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

func NewDIDStorage

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

func (*Storage) DIDExists

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

DIDExists returns true if DID exists, false if not

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) ListDIDsPage

func (ds *Storage) ListDIDsPage(ctx context.Context, method string, page *common.Page, outType StoredDID) (*StoredDIDs, error)

func (*Storage) StoreDID

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

type StorageFactory

type StorageFactory func(tx storage.Tx) (*Storage, error)

func NewDIDStorageFactory

func NewDIDStorageFactory(db storage.ServiceStorage) StorageFactory

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.

type StoredDIDs

type StoredDIDs struct {
	DIDs          []StoredDID
	NextPageToken string
}

type UpdateIONDIDRequest

type UpdateIONDIDRequest struct {
	DID ion.ION `json:"did"`

	StateChange ion.StateChange `json:"stateChange"`
}

type UpdateIONDIDResponse

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

type UpdateRequestStatus

type UpdateRequestStatus string
const (
	PreAnchorStatus   UpdateRequestStatus = "pre-anchor"
	AnchorErrorStatus UpdateRequestStatus = "anchor-error"
	AnchoredStatus    UpdateRequestStatus = "anchored"
	DoneStatus        UpdateRequestStatus = "done"
)

func (UpdateRequestStatus) Bytes

func (s UpdateRequestStatus) Bytes() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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