siwe

package
v0.0.0-...-c4f7e29 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SIWENoncePerIP  ratelimit.BucketName = "SIWENoncePerIP"
	SIWEVerifyPerIP ratelimit.BucketName = "SIWEVerifyPerIP"
)
View Source
const Alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

siwe-go library regex does not support underscore so we define a new one for this case https://github.com/spruceid/siwe-go/blob/fc1b0374f4ffff68e3455839655e680be7e0f862/regex.go#L17

Variables

View Source
var ErrNonceNotFound = InvalidNonce.NewWithCause("nonce is expired or invalid", apierrors.StringCause("NonceNotFound"))
View Source
var InvalidNetwork = apierrors.BadRequest.WithReason("InvalidNetwork")
View Source
var InvalidNonce = apierrors.Forbidden.WithReason("InvalidNonce")

Functions

This section is empty.

Types

type Logger

type Logger struct{ *log.Logger }

func NewLogger

func NewLogger(lf *log.Factory) Logger

type Nonce

type Nonce struct {
	Nonce    string    `json:"nonce"`
	ExpireAt time.Time `json:"expire_at"`
}

type NonceStore

type NonceStore interface {
	Create(nonce *Nonce) error
	Get(nonce *Nonce) (*Nonce, error)
	Delete(nonce *Nonce) error
}

type RateLimiter

type RateLimiter interface {
	Allow(spec ratelimit.BucketSpec) error
	Reserve(spec ratelimit.BucketSpec) *ratelimit.Reservation
	Cancel(r *ratelimit.Reservation)
}

type Service

type Service struct {
	RemoteIP             httputil.RemoteIP
	HTTPOrigin           httputil.HTTPOrigin
	Web3Config           *config.Web3Config
	AuthenticationConfig *config.AuthenticationConfig

	Clock       clock.Clock
	NonceStore  NonceStore
	RateLimiter RateLimiter
	Logger      Logger
}

func (*Service) CreateNewNonce

func (s *Service) CreateNewNonce() (*Nonce, error)

func (*Service) VerifyMessage

func (s *Service) VerifyMessage(msg string, signature string) (*model.SIWEWallet, *ecdsa.PublicKey, error)

type StoreRedis

type StoreRedis struct {
	Context context.Context
	Redis   *appredis.Handle
	AppID   config.AppID
	Clock   clock.Clock
}

func (*StoreRedis) Create

func (s *StoreRedis) Create(nonce *Nonce) error

func (*StoreRedis) Delete

func (s *StoreRedis) Delete(codeKey *Nonce) error

func (*StoreRedis) Get

func (s *StoreRedis) Get(nonce *Nonce) (*Nonce, error)

Jump to

Keyboard shortcuts

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