ethuri

package
v0.0.0-...-cda998f Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EthURISchemeMethod is the prefix string for all DIDs in the ethuri DID method
	EthURISchemeMethod = "did:ethuri"
)

Variables

This section is empty.

Functions

func GenerateDIDCli

func GenerateDIDCli(pubKeyType linkeddata.SuiteType, pubKeyFile string, didPersister Persister) (*did.Document, error)

GenerateDIDCli is the logic to handle the generatedid command for CLI

func GenerateEthURIDID

func GenerateEthURIDID() (*didlib.DID, error)

GenerateEthURIDID generates a new EthURI method DID

func GenerateNewDocument

func GenerateNewDocument(firstPK *did.DocPublicKey, addRefToAuth bool,
	addFragment bool) (*did.Document, error)

GenerateNewDocument generates a new DID and DID document and sets the first public key for the DID. Sets the public key into the publicKeys field and adds a reference to the key to the authentication field. If firstPK has an empty ID field, will populate it with the new DID.

func InitializeNewDocument

func InitializeNewDocument(d *didlib.DID, firstPK *did.DocPublicKey, addRefToAuth bool,
	addFragment bool) (*did.Document, error)

InitializeNewDocument generates a simple version of a DID document given the DID and an initial public key.

Types

type CreateOrUpdateParams

type CreateOrUpdateParams struct {
	Did              *string
	PublicKeys       []did.DocPublicKey
	Auths            []did.DocAuthenicationWrapper
	Services         []did.DocService
	Proof            *linkeddata.Proof
	KeepKeyFragments bool
}

CreateOrUpdateParams are input params for CreateOrUpdateDocument

type InMemoryPersister

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

InMemoryPersister is a persister that stores and get did documents in memory Mainly used for testing.

func (*InMemoryPersister) GetDocument

func (p *InMemoryPersister) GetDocument(d *didlib.DID) (*did.Document, error)

GetDocument retrieves a DID document from the given DID

func (*InMemoryPersister) SaveDocument

func (p *InMemoryPersister) SaveDocument(doc *did.Document) error

SaveDocument saves a DID document

type Persister

type Persister interface {
	// GetDocument retrieves a DID document from the given DID
	GetDocument(d *didlib.DID) (*did.Document, error)
	// SaveDocument saves a DID document
	SaveDocument(doc *did.Document) error
}

Persister is the interface of storing and retrieving DID documents for the ID hub. Implement this interface with different backing stores.

type PostgresDocument

type PostgresDocument struct {
	DID       string         `gorm:"column:did;primary_key"`
	Document  postgres.Jsonb `gorm:"not null"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

PostgresDocument is the GORM model for storing the serialized DID document to DID mapping

func (*PostgresDocument) FromDocument

func (p *PostgresDocument) FromDocument(doc *did.Document) error

FromDocument sets up this PostgresDocument with data from the given did.Document

func (PostgresDocument) TableName

func (PostgresDocument) TableName() string

TableName sets the tablename for PostgresDocuments

func (*PostgresDocument) ToDocument

func (p *PostgresDocument) ToDocument() (*did.Document, error)

ToDocument returns the did.Document from this PostgresDocument

type PostgresPersister

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

PostgresPersister is the Postgresql implementation of the DID persister

func NewPostgresPersister

func NewPostgresPersister(db *gorm.DB) *PostgresPersister

NewPostgresPersister is a convenience function to return a populated PostgresPersister

func (*PostgresPersister) GetDocument

func (p *PostgresPersister) GetDocument(d *didlib.DID) (*did.Document, error)

GetDocument retrieves a DID document from the given DID

func (*PostgresPersister) SaveDocument

func (p *PostgresPersister) SaveDocument(doc *did.Document) error

SaveDocument saves a DID document with the given DID

type Service

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

Service is the service module for DIDs. It is the direct interface for managing DIDs and DID documents and should be used when possible.

func NewService

func NewService(persister Persister) *Service

NewService is a convenience function to return a new populated did.Service object

func (*Service) CreateOrUpdateDocument

func (s *Service) CreateOrUpdateDocument(p *CreateOrUpdateParams) (*did.Document, error)

CreateOrUpdateDocument will create a new document or update an existing one given the params in CreateOrUpdateParams. If did is given and valid, will attempt to retrieve the existing did and document and add any new data to the document If no did is given, it will create a new document with a new DID and the given data. In both cases it will persist to store.

func (*Service) GetDocument

func (s *Service) GetDocument(did string) (*did.Document, error)

GetDocument retrieves the DID document given the DID as a string id If document is not found, will return a nil Document.

func (*Service) GetDocumentFromDID

func (s *Service) GetDocumentFromDID(did *didlib.DID) (*did.Document, error)

GetDocumentFromDID retrieves the DID document given the DID as a DID object If document is not found, will return a nil Document.

func (*Service) IsEthURI

func (s *Service) IsEthURI(d string) bool

IsEthURI is a quick check to see if a did is for ethuri

func (*Service) Resolve

func (s *Service) Resolve(d *didlib.DID) (*did.Document, error)

Resolve implements the did.Resolver interface and returns the did document of a given DID for the ethuri method.

func (*Service) SaveDocument

func (s *Service) SaveDocument(doc *did.Document) error

SaveDocument saves the DID document given the DID as a string id

Jump to

Keyboard shortcuts

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