Documentation ¶
Index ¶
- Constants
- func Base64UrlDecode(s string) ([]byte, error)
- func Base64UrlEncode(s []byte) string
- func ValidateContractAccountProof(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, proof *Proof) (bool, string, error)
- func ValidateEOAProof(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, proof *Proof) (bool, string, error)
- func ValidateEOASignature(address string, message []byte, signatureHex string) (bool, error)
- type Claims
- func (c Claims) Map() map[string]interface{}
- func (c Claims) Message() ([]byte, error)
- func (c Claims) MessageDigest() ([]byte, error)
- func (c *Claims) SetExpiryIn(tm time.Duration)
- func (c *Claims) SetIssuedAtNow()
- func (c Claims) TypedData() (*ethcoder.TypedData, error)
- func (c Claims) Valid() error
- type ETHAuth
- func (w *ETHAuth) ConfigJsonRpcProvider(ethereumJsonRpcURL string, optChainId ...int64) error
- func (w *ETHAuth) ConfigValidators(validators ...ValidatorFunc) error
- func (w *ETHAuth) DecodeProof(proofString string) (bool, *Proof, error)
- func (w *ETHAuth) EncodeProof(proof *Proof) (string, error)
- func (w *ETHAuth) ValidateProof(proof *Proof) (bool, error)
- func (w *ETHAuth) ValidateProofClaims(proof *Proof) (bool, error)
- func (w *ETHAuth) ValidateProofSignature(proof *Proof) bool
- func (w *ETHAuth) Validators() []ValidatorFunc
- type Proof
- type ValidatorFunc
Constants ¶
const ( ETHAuthVersion = "1" ETHAuthPrefix = "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 ValidateContractAccountProof ¶
func ValidateContractAccountProof(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, proof *Proof) (bool, string, error)
ValidateContractAccountProof verifies the account proof, testing if the proof claims have 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 ValidateEOAProof ¶
func ValidateEOAProof(ctx context.Context, provider *ethrpc.Provider, chainID *big.Int, proof *Proof) (bool, string, error)
ValidateEOAProof verifies the account proof, testing if the proof claims have 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"` ETHAuthVersion string `json:"v,omitempty"` }
func (Claims) MessageDigest ¶
func (*Claims) SetExpiryIn ¶
func (*Claims) SetIssuedAtNow ¶
func (c *Claims) SetIssuedAtNow()
type ETHAuth ¶
type ETHAuth struct {
// contains filtered or unexported fields
}
func New ¶
func New(validators ...ValidatorFunc) (*ETHAuth, error)
func (*ETHAuth) ConfigJsonRpcProvider ¶
func (*ETHAuth) ConfigValidators ¶
func (w *ETHAuth) ConfigValidators(validators ...ValidatorFunc) error
func (*ETHAuth) DecodeProof ¶
DecodeProof will decode an ETHAuth proof string, validate it, and return a Proof object
func (*ETHAuth) EncodeProof ¶
EncodeProof will encode a Proof object, validate it and return the ETHAuth proof string
func (*ETHAuth) ValidateProofClaims ¶
func (*ETHAuth) ValidateProofSignature ¶
func (*ETHAuth) Validators ¶
func (w *ETHAuth) Validators() []ValidatorFunc
type Proof ¶
type Proof struct { // "eth" prefix Prefix string // Account addres (in hex) Address string // Claims object, aka, the message key of an EIP712 signature Claims Claims // Signature of the message by the account address above (in hex) Signature string // Extra bytes in hex format used for signature validation // ie. useful for counterfactual smart wallets Extra string }