siwe

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TODO: This static domain and URI should be configurable via an environment variable.
	// See: https://linear.app/arguslabs/issue/WORLD-995/make-domain-and-uri-configurable-for-siwe-authentication
	DefaultDomain = "example.com"
	DefaultURI    = "https://example.com/v2/account/authenticate/custom"

	// DefaultTimeout is the length of time between the issue time and the expiration time. If the current time
	// is not between the issue time and expiration time of a message, the signature will be rejected.
	DefaultTimeout   = 5 * time.Minute
	DefaultStatement = "Log in to Nakama using SIWE."
)

Variables

View Source
var (
	ErrMissingSignerAddress = errors.New("missing signer address")
	ErrMissingMessage       = errors.New("message field is required")
	ErrMissingSignature     = errors.New("signature field is required")
)

Functions

func ValidateSignature

func ValidateSignature(ctx context.Context, nk runtime.NakamaModule, signerAddress, message, signature string) error

ValidateSignature ensures the given message is valid and the given signature is actually a signature for the message.

Types

type GenerateResult

type GenerateResult struct {
	SIWEMessage string `json:"siwe_message"`
}

GenerateResult will be serialized to JSON and sent back to a client. The client must sign the message in the SIWEMessage field, and resubmit their authentication request.

func GenerateNewSIWEMessage

func GenerateNewSIWEMessage(signerAddress string) (*GenerateResult, error)

GenerateNewSIWEMessage generates an SIWE Message that can be signed and used to authenticate a user.

Jump to

Keyboard shortcuts

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