Documentation
¶
Index ¶
- Constants
- func Base64UrlDecode(s string) ([]byte, error)
- func Base64UrlEncode(s []byte) string
- func ValidateContractAccountToken(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, token *Token) (bool, string, error)
- func ValidateEOASignature(address string, message []byte, signatureHex string) (bool, error)
- func ValidateEOAToken(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, token *Token) (bool, string, error)
- type Claims
- type ETHWebToken
- func (w *ETHWebToken) ConfigJsonRpcProvider(ethereumJsonRpcURL string, optChainId ...int64) error
- func (w *ETHWebToken) ConfigValidators(validators ...ValidatorFunc) error
- func (w *ETHWebToken) DecodeToken(tokenString string) (bool, *Token, error)
- func (w *ETHWebToken) EncodeToken(token *Token) (string, error)
- func (w *ETHWebToken) ValidateToken(token *Token) (bool, error)
- func (w *ETHWebToken) ValidateTokenClaims(token *Token) (bool, error)
- func (w *ETHWebToken) ValidateTokenSignature(token *Token) bool
- func (w *ETHWebToken) Validators() []ValidatorFunc
- type Token
- type ValidatorFunc
Constants ¶
const ( EWTVersion = "1" EWTPrefix = "eth" )
const (
// IsValidSignatureBytes32 is the EIP-1271 magic value we test
IsValidSignatureBytes32MagicValue = "0x1626ba7e"
)
Variables ¶
This section is empty.
Functions ¶
func Base64UrlDecode ¶
Base64 url-variant decoding with padding stripped. Note, this is the same encoding format as JWT.
func Base64UrlEncode ¶
Base64 url-variant encoding with padding stripped. Note, this is the same encoding format as JWT.
func ValidateContractAccountToken ¶
func ValidateContractAccountToken(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, token *Token) (bool, string, error)
ValidateContractAccountToken verifies the account proof of the provided ewt, testing if the token has been signed with a smart-contract based account by calling the EIP-1271 method of the remote contract. This method will return success/failure, the account address as a string, and any errors. The wallet contract must be deployed in order for this call to be successful. In order test an undeployed smart-wallet, you will have to implement your own custom validator method.
func ValidateEOASignature ¶
Validate the public key address of an Ethereum signed message
func ValidateEOAToken ¶
func ValidateEOAToken(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, token *Token) (bool, string, error)
ValidateEOAToken verifies the account proof of the provided ewt, testing if the token has been signed with an EOA (externally owned account) and will return success/failture, the account address as a string, and any errors.
Types ¶
type Claims ¶
type Claims struct {
App string `json:"app,omitempty"`
IssuedAt int64 `json:"iat,omitempty"`
ExpiresAt int64 `json:"exp,omitempty"`
Nonce uint64 `json:"n,omitempty"`
Type string `json:"typ,omitempty"`
Origin string `json:"ogn,omitempty"`
EWTVersion string `json:"v,omitempty"`
}
func (Claims) MessageDigest ¶
func (*Claims) SetExpiryIn ¶
func (*Claims) SetIssuedAtNow ¶
func (c *Claims) SetIssuedAtNow()
type ETHWebToken ¶
type ETHWebToken struct {
// contains filtered or unexported fields
}
func New ¶
func New(validators ...ValidatorFunc) (*ETHWebToken, error)
func (*ETHWebToken) ConfigJsonRpcProvider ¶
func (w *ETHWebToken) ConfigJsonRpcProvider(ethereumJsonRpcURL string, optChainId ...int64) error
func (*ETHWebToken) ConfigValidators ¶
func (w *ETHWebToken) ConfigValidators(validators ...ValidatorFunc) error
func (*ETHWebToken) DecodeToken ¶
func (w *ETHWebToken) DecodeToken(tokenString string) (bool, *Token, error)
DecodeToken will decode an EWT token string and return a Token object
func (*ETHWebToken) EncodeToken ¶
func (w *ETHWebToken) EncodeToken(token *Token) (string, error)
EncodeToken will encode a Token object and return the EWT token string
func (*ETHWebToken) ValidateToken ¶
func (w *ETHWebToken) ValidateToken(token *Token) (bool, error)
func (*ETHWebToken) ValidateTokenClaims ¶
func (w *ETHWebToken) ValidateTokenClaims(token *Token) (bool, error)
func (*ETHWebToken) ValidateTokenSignature ¶
func (w *ETHWebToken) ValidateTokenSignature(token *Token) bool
func (*ETHWebToken) Validators ¶
func (w *ETHWebToken) Validators() []ValidatorFunc