auth

package
v0.0.0-...-7c21c3e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader                = "Authorization"
	XAuthorizationHeader               = "X-Authorization"
	ContentType                        = "application/x-www-form-urlencoded"
	Auth0Url                           = "https://auth0.openai.com"
	LoginPasswordUrl                   = Auth0Url + "/u/login/password?state="
	ParseUserInfoErrorMessage          = "Failed to parse user login info."
	GetAuthorizedUrlErrorMessage       = "Failed to get authorized url."
	GetStateErrorMessage               = "Failed to get state."
	EmailInvalidErrorMessage           = "Email is not valid."
	EmailOrPasswordInvalidErrorMessage = "Email or password is not correct."
	GetAccessTokenErrorMessage         = "Failed to get access token."
	GetArkoseTokenErrorMessage         = "Failed to get arkose token."
)

Variables

View Source
var UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"

Functions

func NewHttpClient

func NewHttpClient(proxyUrl string) tls_client.HttpClient

Types

type AccountCookies

type AccountCookies map[string][]*http.Cookie

type AccountInfo

type AccountInfo struct {
	Account struct {
		AccountId   string `json:"account_id"`
		PlanType    string `json:"plan_type"`
		Deactivated bool   `json:"is_deactivated"`
	} `json:"account"`
}

type Error

type Error struct {
	Location   string
	StatusCode int
	Details    string
}

func NewError

func NewError(location string, statusCode int, details string) *Error

type Result

type Result struct {
	AccessToken string `json:"access_token"`
	PUID        string `json:"puid"`
	TeamUserID  string `json:"team_uid,omitempty"`
}

type UserID

type UserID struct {
	Accounts map[string]AccountInfo `json:"accounts"`
}

type UserLogin

type UserLogin struct {
	Username string
	Password string

	Result Result
	// contains filtered or unexported fields
}

func NewAuthenticator

func NewAuthenticator(emailAddress, password, proxy string) *UserLogin

func (*UserLogin) Begin

func (userLogin *UserLogin) Begin() *Error

func (*UserLogin) CheckPassword

func (userLogin *UserLogin) CheckPassword(state string, username string, password string) (string, int, error)

func (*UserLogin) CheckUsername

func (userLogin *UserLogin) CheckUsername(authorizedUrl string, username string) (string, string, int, error)

func (*UserLogin) GetAccessToken

func (userLogin *UserLogin) GetAccessToken() string

func (*UserLogin) GetAccessTokenInternal

func (userLogin *UserLogin) GetAccessTokenInternal(code string) (string, int, error)

func (*UserLogin) GetAuthResult

func (userLogin *UserLogin) GetAuthResult() Result

func (*UserLogin) GetAuthorizedUrl

func (userLogin *UserLogin) GetAuthorizedUrl(csrfToken string) (string, int, error)

func (*UserLogin) GetPUID

func (userLogin *UserLogin) GetPUID() (string, *Error)

func (*UserLogin) GetState

func (userLogin *UserLogin) GetState(authorizedUrl string) (int, error)

func (*UserLogin) GetTeamUserID

func (userLogin *UserLogin) GetTeamUserID() (string, *Error)

func (*UserLogin) GetToken

func (userLogin *UserLogin) GetToken() (int, string, string)

func (*UserLogin) RefreshIOSToken

func (userLogin *UserLogin) RefreshIOSToken(refreshToken string) (string, *Error)

func (*UserLogin) RenewWithCookies

func (userLogin *UserLogin) RenewWithCookies() *Error

func (*UserLogin) ResetCookies

func (userLogin *UserLogin) ResetCookies()

func (*UserLogin) SaveCookies

func (userLogin *UserLogin) SaveCookies() *Error

Jump to

Keyboard shortcuts

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