utils

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EthereumMessagePrefix = "\x19Ethereum Signed Message:\n"

Variables

View Source
var (
	InvalidJWTFormatError    = errors.New("invalid JWT format")
	InvalidTokenIdError      = errors.New("invalid token id")
	JWTDomainMismatchError   = errors.New("invalid domain in JWT")
	JWTInvalidBeforeError    = errors.New("request time is JWT nbf")
	JWTExpiredError          = errors.New("jWT has expired")
	JWTInvalidIssuerError    = errors.New("invalid JWT issuer")
	JWTInvalidSignatureError = errors.New("invalid JWT signature")
)
View Source
var (
	PayloadDomainMismatchError    = errors.New("payload domain does not match the domain in the options")
	PayloadStatementMismatchError = errors.New("payload statement does not match the statement in the options")
	PayloadURIMismatchError       = errors.New("payload URI does not match the URI in the options")
	PayloadVersionMismatchError   = errors.New("payload version does not match the version in the options")
	PayloadChainIDMismatchError   = errors.New("payload chainID does not match the chainID in the options")
	PayloadNonceError             = errors.New("login request nonce is invalid")
	PayloadInvalidBeforeError     = errors.New("payload invalid_before is invalid")
	PayloadNotYetValidError       = errors.New("login request is not yet valid")
	PayloadExpirationTimeError    = errors.New("payload expiration_time is invalid")
	PayloadExpiredError           = errors.New("login request has expired")
	PayloadMissingResourcesError  = errors.New("login request is missing required resources")
	PayloadInvalidSignatureError  = errors.New("login request signature is invalid")
)

Functions

func AuthenticateJWT

func AuthenticateJWT(
	jwt string,
	options *thirdwebauth.AuthenticateOptions,
	clientOptions *thirdwebauth.ThirdwebAuthOptions,
) (*thirdwebauth.User, error)

Validate a JWT and extract the user's info

func BuildAndSignLoginPayload

func BuildAndSignLoginPayload(
	signVerifier thirdwebauth.SignVerifier,
	options *thirdwebauth.LoginOptions,
) (*thirdwebauth.LoginPayload, error)

func BuildJWT

Build JWT token based on the authentication payload

func CreateLoginMessage

func CreateLoginMessage(payload *thirdwebauth.LoginPayloadData) string

Create an EIP-4361 & CAIP-122 compliant message to sign based on the login payload

func GenerateJWT

func GenerateJWT(
	signVerifier thirdwebauth.SignVerifier,
	payload *thirdwebauth.LoginPayload,
	options *thirdwebauth.GenerateOptions,
	clientOptions *thirdwebauth.ThirdwebAuthOptions,
) (string, error)

Generate a new JWT uing a login payload

func HashMessage

func HashMessage(message []byte) common.Hash

func ParseJWT

Parse data from an encoded auth JWT

func RefreshJWT

func RefreshJWT(
	signVerifier thirdwebauth.SignVerifier,
	jwt string,
	options *thirdwebauth.RefreshOptions,
) (string, error)

Refresh an existing JWT

func SignLoginPayload

func SignLoginPayload(
	signVerifier thirdwebauth.SignVerifier,
	payload *thirdwebauth.LoginPayloadData,
) (*thirdwebauth.LoginPayload, error)

func VerifyLoginPayload

func VerifyLoginPayload(
	payload *thirdwebauth.LoginPayload,
	options *thirdwebauth.VerifyOptions,
	clientOptions *thirdwebauth.ThirdwebAuthOptions,
) (string, error)

func VerifySignature

func VerifySignature(
	message, signature, address string,
	clientID, secretKey string,
) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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