token

package
v0.0.0-...-6c8c277 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotValidPublicAddr = &DIDTokenError{errors.New("Invalid public address format.")}
	ErrNotValidProof      = &DIDTokenError{errors.New("Signature mismatch between 'proof' and 'claim'. Please " +
		"generate a new token with an intended issuer.")}
	ErrExpired    = &DIDTokenError{errors.New("Given DID token has expired. Please generate a new one.")}
	ErrNbfExpired = &DIDTokenError{errors.New("Given DID token cannot be used at this time. Please " +
		"check the 'nbf' field and regenerate a new token with a suitable value.")}
)

Functions

This section is empty.

Types

type Claim

type Claim struct {
	Iat int64  `json:"iat"`
	Ext int64  `json:"ext"`
	Iss string `json:"iss"`
	Sub string `json:"sub"`
	Aud string `json:"aud"`
	Nbf int64  `json:"nbf"`
	Tid string `json:"tid"`
	Add string `json:"add,omitempty"`
}

func (*Claim) String

func (c *Claim) String() string

String returns string data of the claim in json format.

type DIDTokenError

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

func (*DIDTokenError) Error

func (e *DIDTokenError) Error() string

type Token

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

Token is representation of the DID token which contains proof (hash) and the serialized claim.

func NewToken

func NewToken(tk string) (*Token, error)

NewToken creates token decoder and validator.

func (*Token) GetClaim

func (t *Token) GetClaim() Claim

GetClaim returns the claim structure with all data.

func (*Token) GetIssuer

func (t *Token) GetIssuer() string

GetIssuer returns the claim issuer.

func (*Token) GetNbfGracePeriod

func (t *Token) GetNbfGracePeriod() int64

GetNbfGracePeriod returns nbf time with grace period.

func (*Token) GetProof

func (t *Token) GetProof() string

GetProof returns the hash of the Ethereum message with claim serialized in json.

func (*Token) GetPublicAddress

func (t *Token) GetPublicAddress() (string, error)

GetPublicAddress split issuer on parts and returns only public address.

func (*Token) Validate

func (t *Token) Validate() error

Validates DID token by recovering public key using signature data and the hash of the claim message.

Jump to

Keyboard shortcuts

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