auth

package
v0.0.0-...-0005af6 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FC_SIGNER_ADDRESS_USER_ID_SOURCE = "fc_signer_address"
	PRIVY_DID_USER_ID_SOURCE         = "privy_did"
)

Variables

This section is empty.

Functions

func CreateServerToken

func CreateServerToken(userId string) (tokenString string, err error)

func ParseKeyFunc

func ParseKeyFunc(verificationKey string) func(token *jwt.Token) (interface{}, error)

func ValidateFrameMessage

func ValidateFrameMessage(message FcFrameMessage) (bool, error)

*

  • ValidateFrameMessage validates a frame request message was signed by the claimed signer *
  • Unlike most frame/Farcaster validations, this one does not utilize
  • a Farcaster Hub node to validate the linkage of the signer to the Fid.
  • Thus...
  • - We do not need to make a Hub request or maintain a Hub
  • - We do not have validation of the claimed Fid *
  • @param message - The frame request message to validate
  • @return bool - True if the message was signed by the claimed signer
  • @return error - An error if the message was not signed by the claimed signer

Types

type Claims

type Claims struct {
	Expiration uint64 `json:"exp,omitempty"`
	Issuer     string `json:"iss,omitempty"`
	UserId     string `json:"sub,omitempty"`
}

Defining a Go type for JWTs issued by this server

func ValidateServerToken

func ValidateServerToken(jwtToken string, verificationKey string) (claims *Claims, err error)

func ValidateServerTokenDefault

func ValidateServerTokenDefault(jwtToken string) (claims *Claims, err error)

func (*Claims) Valid

func (c *Claims) Valid() error

This method will be used to check the token's claims later

type FcCastID

type FcCastID struct {
	FID  int
	Hash string
}

type FcFrameAction

type FcFrameAction struct {
	Url         string
	ButtonIndex int
	InputText   string
	CastID      FcCastID
}

type FcFrameMessage

type FcFrameMessage struct {
	Data            FcFrameMessageData
	Hash            string
	HashScheme      string
	Signature       string
	SignatureScheme string
	Signer          string
}

type FcFrameMessageData

type FcFrameMessageData struct {
	Type            string
	Fid             int
	Timestamp       time.Time
	Network         string
	FrameActionBody FcFrameAction
}

type PrivyClaims

type PrivyClaims struct {
	AppId      string `json:"aud,omitempty"`
	Expiration uint64 `json:"exp,omitempty"`
	Issuer     string `json:"iss,omitempty"`
	UserId     string `json:"sub,omitempty"`
}

Defining a Go type for Privy JWTs

func PrivyAppValidateToken

func PrivyAppValidateToken(jwtToken string) (privyClaims *PrivyClaims, err error)

func PrivyValidateToken

func PrivyValidateToken(jwtToken string, appId string, verificationKey string) (privyClaims *PrivyClaims, err error)

func (*PrivyClaims) Valid

func (c *PrivyClaims) Valid() error

This method will be used to check the token's claims later

func (*PrivyClaims) ValidateApp

func (c *PrivyClaims) ValidateApp(AppId string) error

Jump to

Keyboard shortcuts

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