Documentation ¶
Index ¶
- Constants
- func GenerateDIDCli(pubKeyType linkeddata.SuiteType, pubKeyFile string, didPersister Persister) (*did.Document, error)
- func GenerateEthURIDID() (*didlib.DID, error)
- func GenerateNewDocument(firstPK *did.DocPublicKey, addRefToAuth bool, addFragment bool) (*did.Document, error)
- func InitializeNewDocument(d *didlib.DID, firstPK *did.DocPublicKey, addRefToAuth bool, addFragment bool) (*did.Document, error)
- type CreateOrUpdateParams
- type InMemoryPersister
- type Persister
- type PostgresDocument
- type PostgresPersister
- type Service
- func (s *Service) CreateOrUpdateDocument(p *CreateOrUpdateParams) (*did.Document, error)
- func (s *Service) GetDocument(did string) (*did.Document, error)
- func (s *Service) GetDocumentFromDID(did *didlib.DID) (*did.Document, error)
- func (s *Service) IsEthURI(d string) bool
- func (s *Service) Resolve(d *didlib.DID) (*did.Document, error)
- func (s *Service) SaveDocument(doc *did.Document) error
Constants ¶
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 ¶
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.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetDocumentFromDID retrieves the DID document given the DID as a DID object If document is not found, will return a nil Document.