Documentation ¶
Index ¶
- Constants
- Variables
- func Concat(vs ...[]byte) []byte
- type JWTClaimPGPersister
- func (p *JWTClaimPGPersister) AddJWT(tokenString string, senderDID *didlib.DID) (*jwt.Token, string, error)
- func (p *JWTClaimPGPersister) GetJWTByHash(hash string) (*jwt.Token, error)
- func (p *JWTClaimPGPersister) GetJWTByMultihash(mHash string) (*jwt.Token, error)
- func (p *JWTClaimPGPersister) GetJWTBySubjectsOrIssuers(issuers []string, subjs []string) ([]*JWTClaimPostgres, error)
- type JWTClaimPostgres
- type Node
- type NodePGPersister
- func (c *NodePGPersister) Batch(cache *kvMap, prefix []byte) error
- func (c *NodePGPersister) Get(key []byte) (*Node, error)
- func (c *NodePGPersister) GetAll() ([]db.KV, error)
- func (c *NodePGPersister) GetAllForPrefix(prefixBytes []byte, limit int) ([]db.KV, error)
- func (c *NodePGPersister) GetLatestRootClaimInSnapshot(did *didlib.DID, tree *merkletree.MerkleTree) (*claimtypes.ClaimSetRootKeyDID, error)
- func (c *NodePGPersister) GetLatestRootClaimNodes(did *didlib.DID) (*[]Node, error)
- func (c *NodePGPersister) GetNextRootClaimVersion(did *didlib.DID) (uint32, error)
- func (c *NodePGPersister) Info() string
- type PGStore
- func (s PGStore) Close()
- func (s *PGStore) Get(b []byte) ([]byte, error)
- func (s *PGStore) Info() string
- func (s *PGStore) Iterate(f func([]byte, []byte) (bool, error)) error
- func (s *PGStore) List(limit int) ([]db.KV, error)
- func (s *PGStore) NewTx() (db.Tx, error)
- func (s *PGStore) WithPrefix(prefix []byte) db.Storage
- type PGTX
- type RootCommit
- type RootCommitsPGPersister
- type SignedClaimPGPersister
- type SignedClaimPostgres
- func (c *SignedClaimPostgres) FromContentCredential(cred *claimtypes.ContentCredential) error
- func (c *SignedClaimPostgres) FromLicenseCredential(cred *claimtypes.LicenseCredential) error
- func (SignedClaimPostgres) TableName() string
- func (c *SignedClaimPostgres) ToCredential() (claimtypes.Credential, error)
Constants ¶
const ( // LeafNode is string value signifying node is a leaf LeafNode = "leafnode" // MiddleNode is string value signifying node is not a leaf MiddleNode = "middlenode" )
Variables ¶
var ( // PrefixRootMerkleTree prefix value for root tree PrefixRootMerkleTree = []byte("root_merkletree") // ErrTooLongDIDMethod did to binary is a bit fragile for now, fails when method is more than 15 bytes ErrTooLongDIDMethod = errors.New("method string is too long to fit in merkletree elembytes") // ErrWrongSizByteSliceDID if the slice is the wrong size can't convert it back to a did ErrWrongSizByteSliceDID = errors.New("binaryToDID expects a byte slice of length 32") )
var ( // ErrNoRootCommitForDID is an error for when no root claims are found ErrNoRootCommitForDID = errors.New("no rootclaims were in the snapshot") )
Functions ¶
Types ¶
type JWTClaimPGPersister ¶
type JWTClaimPGPersister struct {
// contains filtered or unexported fields
}
JWTClaimPGPersister is a postgres persister for JWT claims
func NewJWTClaimPGPersister ¶
func NewJWTClaimPGPersister(db *gorm.DB, didJWTService *didjwt.Service) *JWTClaimPGPersister
NewJWTClaimPGPersister returns a new JWTClaimPGPersister
func (*JWTClaimPGPersister) AddJWT ¶
func (p *JWTClaimPGPersister) AddJWT(tokenString string, senderDID *didlib.DID) (*jwt.Token, string, error)
AddJWT adds a new jwt claim to the db
func (*JWTClaimPGPersister) GetJWTByHash ¶
func (p *JWTClaimPGPersister) GetJWTByHash(hash string) (*jwt.Token, error)
GetJWTByHash returns a jwt from it's hash
func (*JWTClaimPGPersister) GetJWTByMultihash ¶
func (p *JWTClaimPGPersister) GetJWTByMultihash(mHash string) (*jwt.Token, error)
GetJWTByMultihash returns a jwt from it's multihash
func (*JWTClaimPGPersister) GetJWTBySubjectsOrIssuers ¶
func (p *JWTClaimPGPersister) GetJWTBySubjectsOrIssuers(issuers []string, subjs []string) ([]*JWTClaimPostgres, error)
GetJWTBySubjectsOrIssuers takes a list of subjects and a list of issuers and returns all dids that match either
type JWTClaimPostgres ¶
type JWTClaimPostgres struct { JWT string `gorm:"not null"` Issuer string `gorm:"not null;index:jwtissuer"` Subject string Sender string `gorm:"not null;index:jwtsender"` Hash string `gorm:"primary_key"` Data string Type string IssuedAt int64 }
JWTClaimPostgres is a model for storing jwt type vcs
func TokenToJWTClaimPostgres ¶
func TokenToJWTClaimPostgres(token *jwt.Token) (*JWTClaimPostgres, error)
TokenToJWTClaimPostgres turns a jwt token into the db model
func (JWTClaimPostgres) TableName ¶
func (JWTClaimPostgres) TableName() string
TableName sets the name of the table in the db
type Node ¶
type Node struct { gorm.Model Prefix string NodeData string NodeKey string `gorm:"unique_index;not null;"` NodeType string DID string `gorm:"column:did"` ClaimType string ClaimVersion uint32 }
Node is node in the merkle tree stored in this table
func (*Node) ToDataBytes ¶
ToDataBytes returns just the data stored in the node as a byte slice
type NodePGPersister ¶
NodePGPersister is a persister for saving the nodes into postgress
func NewNodePGPersisterWithDB ¶
func NewNodePGPersisterWithDB(db *gorm.DB) *NodePGPersister
NewNodePGPersisterWithDB uses an existing gorm.DB struct to create a new GormPGPersister. This is useful if we want to reuse existing connections
func (*NodePGPersister) Batch ¶
func (c *NodePGPersister) Batch(cache *kvMap, prefix []byte) error
Batch updates many nodes at once from the cached kv values used to update all the middle nodes when a leaf is added or changed
func (*NodePGPersister) Get ¶
func (c *NodePGPersister) Get(key []byte) (*Node, error)
Get a node from the db
func (*NodePGPersister) GetAll ¶
func (c *NodePGPersister) GetAll() ([]db.KV, error)
GetAll returns all the nodes in all trees
func (*NodePGPersister) GetAllForPrefix ¶
GetAllForPrefix returns the nodes associated with a particular prefix tree
func (*NodePGPersister) GetLatestRootClaimInSnapshot ¶
func (c *NodePGPersister) GetLatestRootClaimInSnapshot(did *didlib.DID, tree *merkletree.MerkleTree) (*claimtypes.ClaimSetRootKeyDID, error)
GetLatestRootClaimInSnapshot returns the root claim in the snapshot with the highest version number
func (*NodePGPersister) GetLatestRootClaimNodes ¶
func (c *NodePGPersister) GetLatestRootClaimNodes(did *didlib.DID) (*[]Node, error)
GetLatestRootClaimNodes returns the rootclaims nodes for a did sorted by their version number
func (*NodePGPersister) GetNextRootClaimVersion ¶
func (c *NodePGPersister) GetNextRootClaimVersion(did *didlib.DID) (uint32, error)
GetNextRootClaimVersion gets the next root claim version for a did
func (*NodePGPersister) Info ¶
func (c *NodePGPersister) Info() string
Info returns basic info about the table
type PGStore ¶
type PGStore struct { NodePersister *NodePGPersister // contains filtered or unexported fields }
PGStore is an implementation of the iden3 storage interface that uses postgres as its backend
func NewPGStore ¶
func NewPGStore(nodePersister *NodePGPersister) *PGStore
NewPGStore returns a new postgress store
type PGTX ¶
type PGTX struct { *PGStore // contains filtered or unexported fields }
PGTX implements the iden3 transaction interface to use a postgress store
type RootCommit ¶
type RootCommit struct { gorm.Model Root string `gorm:"primary_key"` BlockNumber int64 Prefix string TransactionHash string ContractAddress string CommitterAddress string }
RootCommit stores information about a root saved to the contract
func (RootCommit) TableName ¶
func (RootCommit) TableName() string
TableName sets the table name for signed claims
type RootCommitsPGPersister ¶
type RootCommitsPGPersister struct {
// contains filtered or unexported fields
}
RootCommitsPGPersister persister model for root commits
func NewRootCommitsPGPersister ¶
func NewRootCommitsPGPersister(db *gorm.DB) *RootCommitsPGPersister
NewRootCommitsPGPersister returns a new RootCommitsPGPersister
func (*RootCommitsPGPersister) Get ¶
func (p *RootCommitsPGPersister) Get(rootHash string) (*RootCommit, error)
Get returns the information about a root commit given a root hash
func (*RootCommitsPGPersister) GetLatest ¶
func (p *RootCommitsPGPersister) GetLatest() (*RootCommit, error)
GetLatest returns the most recent root committed to the tree
func (*RootCommitsPGPersister) Save ¶
func (p *RootCommitsPGPersister) Save(root *RootCommit) error
Save saves a new root commit to the db
type SignedClaimPGPersister ¶
type SignedClaimPGPersister struct {
// contains filtered or unexported fields
}
SignedClaimPGPersister persister model for signed claims
func NewSignedClaimPGPersister ¶
func NewSignedClaimPGPersister(db *gorm.DB) *SignedClaimPGPersister
NewSignedClaimPGPersister returns a new SignedClaimPGPersister
func (*SignedClaimPGPersister) AddCredential ¶
func (p *SignedClaimPGPersister) AddCredential(claim claimtypes.Credential) (string, error)
AddCredential takes a credential and adds it to the db
func (*SignedClaimPGPersister) GetCredentialByHash ¶
func (p *SignedClaimPGPersister) GetCredentialByHash(hash string) (claimtypes.Credential, error)
GetCredentialByHash returns a credential from a hash taken from the associated merkle tree claim
func (*SignedClaimPGPersister) GetCredentialByMultihash ¶
func (p *SignedClaimPGPersister) GetCredentialByMultihash(mHash string) (claimtypes.Credential, error)
GetCredentialByMultihash returns a credential from a multihash
type SignedClaimPostgres ¶
type SignedClaimPostgres struct { IssuanceDate time.Time Type claimtypes.CredentialType CredentialSubject postgres.Jsonb `gorm:"not null"` Issuer string `gorm:"not null;index:issuer"` Proof postgres.Jsonb `gorm:"not null"` Hash string `gorm:"primary_key"` }
SignedClaimPostgres represents the schema for signed claims
func (*SignedClaimPostgres) FromContentCredential ¶
func (c *SignedClaimPostgres) FromContentCredential(cred *claimtypes.ContentCredential) error
FromContentCredential populates the db type from a model
func (*SignedClaimPostgres) FromLicenseCredential ¶
func (c *SignedClaimPostgres) FromLicenseCredential(cred *claimtypes.LicenseCredential) error
FromLicenseCredential populates a signed claim postgres model from a license claim
func (SignedClaimPostgres) TableName ¶
func (SignedClaimPostgres) TableName() string
TableName sets the table name for signed claims
func (*SignedClaimPostgres) ToCredential ¶
func (c *SignedClaimPostgres) ToCredential() (claimtypes.Credential, error)
ToCredential converts the db type to the model