thirdwebauth

package module
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: 3 Imported by: 0

README

thirdweb-auth-go

ThirdWeb Auth SDK written in Go.

Documentation

Index

Constants

View Source
const (
	AuthTokenCookiePrefix   = "thirdweb_auth_token"
	AuthActiveAccountCookie = "thirdweb_auth_active_account"
)
View Source
const (
	DefaultLoginPayloadDuration = 10 * time.Minute
	DefaultTokenDuration        = 24 * time.Hour
	DefaultRefreshInterval      = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveBody

type ActiveBody struct {
	Address string `json:"address" validate:"required"`
}

type AuthenticateOptions

type AuthenticateOptions struct {
	Domain          string             `json:"domain,omitempty"`
	ValidateTokenId func(string) error `json:"-"`
}

type AuthenticationPayload

type AuthenticationPayload struct {
	Payload   *AuthenticationPayloadData `json:"payload"   validate:"required"`
	Signature string                     `json:"signature" validate:"required"`
}

type AuthenticationPayloadData

type AuthenticationPayloadData struct {
	ISS string      `json:"iss" validate:"required"`
	SUB string      `json:"sub" validate:"required"`
	AUD string      `json:"aud" validate:"required"`
	EXP int64       `json:"exp" validate:"required"`
	NBF int64       `json:"nbf" validate:"required"`
	IAT int64       `json:"iat" validate:"required"`
	JTI string      `json:"jti" validate:"required"`
	CTX interface{} `json:"ctx"`
}

type AuthenticationPayloadDataInput

type AuthenticationPayloadDataInput struct {
	ISS string      `json:"iss" validate:"required"`
	SUB string      `json:"sub" validate:"required"`
	AUD string      `json:"aud" validate:"required"`
	EXP time.Time   `json:"exp" validate:"required"`
	NBF time.Time   `json:"nbf" validate:"required"`
	IAT time.Time   `json:"iat" validate:"required"`
	JTI string      `json:"jti" validate:"required"`
	CTX interface{} `json:"ctx"`
}

func DefaultAuthenticationPayloadDataInput

func DefaultAuthenticationPayloadDataInput() *AuthenticationPayloadDataInput

func (*AuthenticationPayloadDataInput) ToData

type GenerateOptions

type GenerateOptions struct {
	Domain         string                   `json:"domain,omitempty"`
	TokenId        string                   `json:"tokenId,omitempty"`
	ExpirationTime time.Time                `json:"expirationTime"`
	InvalidBefore  time.Time                `json:"invalidBefore,omitempty"`
	Session        func(string) interface{} `json:"session,omitempty"`
	VerifyOptions  VerifyOptions            `json:"verifyOptions,omitempty"`
}

func DefaultGenerateOptions

func DefaultGenerateOptions() *GenerateOptions

type LoginOptions

type LoginOptions struct {
	Domain         string    `json:"domain,omitempty"`
	Address        string    `json:"address,omitempty"`
	Statement      string    `json:"statement,omitempty"`
	URI            string    `json:"uri,omitempty"`
	Version        string    `json:"version,omitempty"`
	ChainID        string    `json:"chainId,omitempty"`
	Nonce          string    `json:"nonce,omitempty"`
	ExpirationTime time.Time `json:"expirationTime,omitempty"`
	InvalidBefore  time.Time `json:"invalidBefore,omitempty"`
	Resources      []string  `json:"resources,omitempty"`
}

func DefaultLoginOptions

func DefaultLoginOptions() *LoginOptions

type LoginPayload

type LoginPayload struct {
	Payload   *LoginPayloadData `json:"payload"   validate:"required"`
	Signature string            `json:"signature" validate:"required"`
}

type LoginPayloadBody

type LoginPayloadBody struct {
	Payload LoginPayload `json:"payload" validate:"required"`
}

type LoginPayloadData

type LoginPayloadData struct {
	Type           string   `json:"type"                      validate:"required"`
	Domain         string   `json:"domain"                    validate:"required"`
	Address        string   `json:"address"                   validate:"required"`
	Statement      string   `json:"statement"                 validate:"required"`
	URI            string   `json:"uri,omitempty"`
	Version        string   `json:"version"                   validate:"required"`
	ChainID        string   `json:"chain_id,omitempty"`
	Nonce          string   `json:"nonce"                     validate:"required"`
	IssuedAt       string   `json:"issued_at"                 validate:"required"`
	ExpirationTime string   `json:"expiration_time,omitempty"`
	InvalidBefore  string   `json:"invalid_before"            validate:"required"`
	Resources      []string `json:"resources,omitempty"`
}

func DefaultLoginPayloadData

func DefaultLoginPayloadData() *LoginPayloadData

type PayloadBody

type PayloadBody struct {
	Address string `json:"address"           validate:"required"`
	ChainID string `json:"chainId,omitempty"`
}

type RefreshOptions

type RefreshOptions struct {
	ExpirationTime time.Time `json:"expirationTime"`
}

func DefaultRefreshOptions

func DefaultRefreshOptions() *RefreshOptions

type SignVerifier

type SignVerifier interface {
	Signer
	Verifier
}

type Signer

type Signer interface {
	SignMessage(message string) (string, error)
}

type ThirdwebAuthConfig

type ThirdwebAuthConfig struct {
	Domain              string
	Verifier            SignVerifier
	AuthOptions         ThirdwebAuthConfigAuthOptions
	CookieOptions       ThirdwebAuthConfigCookieOptions
	Callbacks           ThirdwebAuthConfigCallbacks
	ThirdwebAuthOptions ThirdwebAuthOptions
}

type ThirdwebAuthConfigAuthOptions

type ThirdwebAuthConfigAuthOptions struct {
	Statement            string             `json:"statement,omitempty"`
	URI                  string             `json:"uri,omitempty"`
	Version              string             `json:"version,omitempty"`
	ChainID              string             `json:"chainId,omitempty"`
	Resources            []string           `json:"resources,omitempty"`
	ValidateNonce        func(string) error `json:"-"`
	ValidateTokenId      func(string) error `json:"-"`
	LoginPayloadDuration time.Duration      `json:"loginPayloadDuration,omitempty"`
	TokenDuration        time.Duration      `json:"tokenDuration,omitempty"`
	RefreshInterval      time.Duration      `json:"refreshInterval,omitempty"`
}

type ThirdwebAuthConfigCallbacks

type ThirdwebAuthConfigCallbacks struct {
	OnLogin  func(*http.Request, string) interface{}
	OnToken  func(*http.Request, string) interface{}
	OnUser   func(*http.Request, *User) interface{}
	OnLogout func(*http.Request, *User)
}

type ThirdwebAuthConfigCookieOptions

type ThirdwebAuthConfigCookieOptions struct {
	Domain   *string        `json:"domain,omitempty"`
	Path     *string        `json:"path,omitempty"`
	SameSite *http.SameSite `json:"sameSite,omitempty"`
	Secure   *bool          `json:"secure,omitempty"`
}

type ThirdwebAuthOptions

type ThirdwebAuthOptions struct {
	JwtISS       string
	ClientID     string
	ClientSecret string
}

func NewThirdwebAuthOptions

func NewThirdwebAuthOptions() *ThirdwebAuthOptions

func (*ThirdwebAuthOptions) WithClientID

func (o *ThirdwebAuthOptions) WithClientID(clientID string) *ThirdwebAuthOptions

func (*ThirdwebAuthOptions) WithClientSecret

func (o *ThirdwebAuthOptions) WithClientSecret(clientSecret string) *ThirdwebAuthOptions

func (*ThirdwebAuthOptions) WithJwtISS

func (o *ThirdwebAuthOptions) WithJwtISS(jwtISS string) *ThirdwebAuthOptions

type ThirdwebAuthUser

type ThirdwebAuthUser struct {
	Address string      `json:"address"           validate:"required"`
	Session interface{} `json:"session,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

type User

type User struct {
	Address string      `json:"address"           validate:"required"`
	Session interface{} `json:"session,omitempty"`
}

type Verifier

type Verifier interface {
	VerifySignature(message, signature string) (bool, error)
}

type VerifyOptions

type VerifyOptions struct {
	Domain        string             `json:"domain,omitempty"`
	Statement     string             `json:"statement,omitempty"`
	URI           string             `json:"uri,omitempty"`
	Version       string             `json:"version,omitempty"`
	ChainID       string             `json:"chainId,omitempty"`
	Resources     []string           `json:"resources,omitempty"`
	ValidateNonce func(string) error `json:"-"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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