Documentation ¶
Overview ¶
Package eip4361
package for encoding, decoding, and verifying eip4361 messages
Index ¶
- Constants
- Variables
- func GenerateNonce() string
- func New() string
- func NewLen(length int) string
- func NewLenChars(length int, chars []byte) string
- type ExpiredMessage
- type InvalidMessage
- type InvalidSignature
- type Message
- func (m *Message) GetAddress() common.Address
- func (m *Message) GetChainID() int
- func (m *Message) GetDomain() string
- func (m *Message) GetExpirationTime() *string
- func (m *Message) GetIssuedAt() string
- func (m *Message) GetNonce() string
- func (m *Message) GetNotBefore() *string
- func (m *Message) GetRequestID() *string
- func (m *Message) GetResources() []url.URL
- func (m *Message) GetStatement() *string
- func (m *Message) GetStatementString() string
- func (m *Message) GetURI() url.URL
- func (m *Message) GetURIString() string
- func (m *Message) GetVersion() string
- func (m *Message) GobDecode(b []byte) error
- func (m *Message) GobEncode() ([]byte, error)
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) String() string
- func (m *Message) UnmarshalJSON(b []byte) error
- func (m *Message) ValidAt(when time.Time) (bool, error)
- func (m *Message) ValidNow() (bool, error)
- func (m *Message) Verify(signature string, domain *string, nonce *string, timestamp *time.Time) (*ecdsa.PublicKey, error)
- func (m *Message) VerifyEIP191(signature string) (*ecdsa.PublicKey, error)
Constants ¶
const ( // StdLen is a standard length of uniuri string to achieve ~95 bits of entropy. StdLen = 16 // UUIDLen is a length of uniuri string to achieve ~119 bits of entropy, closest // to what can be losslessly converted to UUIDv4 (122 bits). UUIDLen = 20 )
const ISO8601 = "2006-01-02T15:04:05.000Z" // time.RFC3339
ISO8601 time formatting that js uses
const MessageTemplateString = `` /* 545-byte string literal not displayed */
MessageTemplateString is the template string used to compile eip4361 messages
Variables ¶
var MessageTemplate = template.Must(template.New("EIP4361Message").Parse(MessageTemplateString))
MessageTemplate is the template used to compile eip4361 message
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
StdChars is a set of standard characters allowed in uniuri string.
Functions ¶
func GenerateNonce ¶
func GenerateNonce() string
func New ¶
func New() string
New returns a new random string of the standard length, consisting of standard characters.
func NewLen ¶
NewLen returns a new random string of the provided length, consisting of standard characters.
func NewLenChars ¶
NewLenChars returns a new random string of the provided length, consisting of the provided byte slice of allowed characters (maximum 256).
Types ¶
type ExpiredMessage ¶
type ExpiredMessage struct {
// contains filtered or unexported fields
}
ExpiredMessage is return when msg is expired
type InvalidMessage ¶
type InvalidMessage struct {
// contains filtered or unexported fields
}
InvalidMessage is return when msg is invalid
type InvalidSignature ¶
type InvalidSignature struct {
// contains filtered or unexported fields
}
InvalidSignature is return when sig is invalid
func (*InvalidSignature) Error ¶
func (m *InvalidSignature) Error() string
Error implements error.Error
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message a message that represents eip4361 message
func InitMessage ¶
func InitMessage(domain, address, uri, nonce string, options map[string]interface{}) (*Message, error)
InitMessage creates a Message object with the provided parameters
func ParseMessage ¶
ParseMessage returns a Message object by parsing an EIP-4361 formatted string
func (*Message) GetExpirationTime ¶
GetExpirationTime gets expiration time
func (*Message) GetNotBefore ¶
GetNotBefore gets not before
func (*Message) GetRequestID ¶
GetRequestID gets request id
func (*Message) GetResources ¶
GetResources gets resources
func (*Message) GetStatementString ¶
GetStatementString gets statement string
func (*Message) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Message) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
func (*Message) ValidAt ¶
ValidAt validates the time constraints of the message at a specific point in time.