auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	API_ENDPOINT = "https://discord.com/api/v10"
)

Variables

View Source
var LoginExpired = fmt.Errorf("session expired")

Functions

func CleanString

func CleanString(data []byte) string

func GenerateSauerKey

func GenerateSauerKey(seed string) (public string, private string)

func GenerateSeed

func GenerateSeed() (string, error)

Types

type Challenge

type Challenge struct {
	// Discord Id
	Id           string
	Question     string
	Answer       uintptr
	AnswerString string
}

func GenerateChallenge

func GenerateChallenge(id string, publicKey string) (*Challenge, error)

func (*Challenge) Check

func (c *Challenge) Check(answer string) bool

func (*Challenge) Destroy

func (c *Challenge) Destroy()

type DiscordService

type DiscordService struct {
	State *state.StateService
	// contains filtered or unexported fields
}

func NewDiscordService

func NewDiscordService(config config.DiscordSettings, state *state.StateService, db *gorm.DB) *DiscordService

func (*DiscordService) AuthenticateCode

func (d *DiscordService) AuthenticateCode(ctx context.Context, code string) (*state.User, error)

func (*DiscordService) AuthenticateId

func (d *DiscordService) AuthenticateId(ctx context.Context, id string) (*state.User, error)

func (*DiscordService) FetchAccessToken

func (d *DiscordService) FetchAccessToken(code string) (*TokenResponse, error)

func (*DiscordService) GetUser

func (d *DiscordService) GetUser(token string) (*DiscordUser, error)

func (*DiscordService) RefreshAccessToken

func (d *DiscordService) RefreshAccessToken(refreshToken string) (*TokenResponse, error)

type DiscordUser

type DiscordUser struct {
	Id            string
	Username      string
	Discriminator string
	Avatar        string
}

func (*DiscordUser) Reference

func (u *DiscordUser) Reference() string

type KeyPair

type KeyPair struct {
	Public  string
	Private string
}

func GenerateAuthKey

func GenerateAuthKey() (*KeyPair, error)

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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