Documentation
¶
Index ¶
- Constants
- Variables
- func Init()
- func MarshalPersona(persona any) string
- func MarshalSignature(signature []byte) string
- type Proof
- type ProofChain
- func (pc *ProofChain) Apply() (err error)
- func (pc *ProofChain) Pubkey() *ecdsa.PublicKey
- func (pc *ProofChain) RestoreValidator() (v *validator.Base, err error)
- func (pc *ProofChain) SignatureBytes() (sig []byte)
- func (ProofChain) TableName() string
- func (pc *ProofChain) ToProofChainItem() ProofChainItem
- type ProofChainArweaveDocument
- type ProofChainItem
Constants ¶
const EXPIRED_IN = time.Hour * 24 * 3
EXPIRED_IN is the time after which a proof is considered expired and should perform revalidate.
Variables ¶
var ( DB *gorm.DB // Since this service is mostly run as a lambda, we don't need // to init an array here. When lambda scaled to a very large // number, servers in `read_only_hosts` will be used evenly. ReadOnlyDB *gorm.DB )
Functions ¶
func MarshalPersona ¶
MarshalPersona accepts *ecdsa.Pubkey | string type of pubkey, returns a string to be stored into DB.
func MarshalSignature ¶
MarshalSignature converts []byte signature into string.
Types ¶
type Proof ¶
type Proof struct { ID int64 `gorm:"primarykey"` CreatedAt time.Time LastCheckedAt time.Time IsValid bool InvalidReason string ProofChainID int64 `gorm:"index"` ProofChain ProofChain // Persona is public key of user persona (string, /0x[0-9a-f]{130}/) Persona string `gorm:"index;not null"` Platform types.Platform `gorm:"index;not null"` Identity string `gorm:"index;not null"` AltID string `gorm:"column:alt_id;index"` Location string `gorm:"not null"` }
Proof is final proof state of a user (persona).
func FindAllProofByPersona ¶
func (*Proof) IsOutdated ¶
IsOutdated returns true if proof is outdated and should do a revalidate.
func (*Proof) Revalidate ¶
Revalidate validates current proof, will update `IsValid` and `LastCheckedAt`. Must be used after `DB.Preload("ProofChain")`.
type ProofChain ¶
type ProofChain struct { ID int64 `gorm:"primarykey"` CreatedAt time.Time `gorm:"column:created_at"` Action types.Action `gorm:"index;not null"` Persona string `gorm:"index;not null"` Identity string `gorm:"index;not null"` AltID string `gorm:"column:alt_id;index"` Platform types.Platform `gorm:"index;not null"` Location string `gorm:"not null"` Signature string `gorm:"not null"` SignaturePayload string `gorm:"column:signature_payload"` Extra datatypes.JSON `gorm:"default:'{}'"` Uuid string `gorm:"index;column:uuid"` ArweaveID string `gorm:"column:arweave_id;not null;default:''"` PreviousID sql.NullInt64 `gorm:"index"` Previous *ProofChain }
ProofChain is a chain of a persona's proof modification log.
func ProofChainCreateFromValidator ¶
func ProofChainCreateFromValidator(validator *validator.Base) (pc *ProofChain, err error)
func ProofChainFindBySignature ¶
func ProofChainFindBySignature(signature string) (pc *ProofChain, err error)
func ProofChainFindLatest ¶
func ProofChainFindLatest(persona string) (pc *ProofChain, err error)
func (*ProofChain) Apply ¶
func (pc *ProofChain) Apply() (err error)
Apply applies current ProofChain modification to Proof model.
func (*ProofChain) Pubkey ¶
func (pc *ProofChain) Pubkey() *ecdsa.PublicKey
func (*ProofChain) RestoreValidator ¶
func (pc *ProofChain) RestoreValidator() (v *validator.Base, err error)
RestoreValidator rebuilds `validator.Base` from current `ProofChain` record.
func (*ProofChain) SignatureBytes ¶
func (pc *ProofChain) SignatureBytes() (sig []byte)
func (ProofChain) TableName ¶
func (ProofChain) TableName() string
func (*ProofChain) ToProofChainItem ¶
func (pc *ProofChain) ToProofChainItem() ProofChainItem
type ProofChainArweaveDocument ¶
type ProofChainArweaveDocument struct { Avatar string `json:"avatar"` Action types.Action `json:"action"` Platform types.Platform `json:"platform"` Identity string `json:"identity"` AltID string `json:"alt_id"` ProofLocation string `json:"proof_location"` CreatedAt string `json:"created_at"` Signature string `json:"signature"` SignaturePayload string `json:"signature_payload"` Uuid string `json:"uuid"` Extra datatypes.JSON `json:"extra"` PreviousUuid string `json:"previous_uuid"` PreviousArweaveID string `json:"previous_arweave_id"` }
Arweave data ID
type ProofChainItem ¶
type ProofChainItem struct { Action types.Action `json:"action"` Platform types.Platform `json:"platform"` Identity string `json:"identity"` AltID string `json:"alt_id"` ProofLocation string `json:"proof_location"` CreatedAt string `json:"created_at"` Signature string `json:"signature"` SignaturePayload string `json:"signature_payload"` Uuid string `json:"uuid"` Extra datatypes.JSON `json:"extra"` ArweaveID string `json:"arweave_id"` }
Output version of the proof chain