auth

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader                = "Authorization"
	XAuthorizationHeader               = "X-Authorization"
	ContentType                        = "application/x-www-form-urlencoded"
	UserAgent                          = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
	Auth0Url                           = "https://auth0.openai.com"
	LoginUsernameUrl                   = Auth0Url + "/u/login/identifier?state="
	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

This section is empty.

Functions

func NewCloudFlare403ErrorMessage

func NewCloudFlare403ErrorMessage(url string) string

构造返回url的CloudFlare 403错误

func NewHttpClient

func NewHttpClient(proxyUrl string) tls_client.HttpClient

Types

type AccountCookies

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

type Error

type Error struct {
	Location   string
	StatusCode int
	Details    string
}

func NewError

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

type Option

type Option func(*UserLogin)

func WithAuth0OpenaiCookies

func WithAuth0OpenaiCookies(auth0OpenAiCookies map[string]string) Option

func WithAuthOpenaiCookies

func WithAuthOpenaiCookies(authOpenAiCookies map[string]string) Option

func WithChatGPTCookies added in v0.0.3

func WithChatGPTCookies(chatGPTCookies map[string]string) Option

func WithProxy

func WithProxy(proxyUrl string) Option

func WithUserAgent

func WithUserAgent(userAgent string) Option

type Result

type Result struct {
	AuthCookies []*http.Cookie `json:"auth_cookies"`
	AccessToken string         `json:"access_token"`
	PUID        string         `json:"puid"`
	TeamUserID  string         `json:"team_uid,omitempty"`
}

type UserID

type UserID struct {
	AccountOrdering []string `json:"account_ordering"`
}

type UserLogin

type UserLogin struct {
	Username        string
	Password        string
	CapsolverApiKey string

	Result Result
	// contains filtered or unexported fields
}

func NewAuthenticator

func NewAuthenticator(emailAddress, password, capsolverApiKey string, opts ...Option) *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) FirstLoginSubmitAccountInfo added in v0.0.3

func (userLogin *UserLogin) FirstLoginSubmitAccountInfo(email, accessToken, arkoseToken string) error

注册后首次登录第十一步,提交信息到create_account接口

func (*UserLogin) FirstRegLogin added in v0.0.3

func (userLogin *UserLogin) FirstRegLogin(chatGPTAuthorizedPage, deviceId string) error

注册并 Verfiy Email之后, 首次登录调用这个方法

chatGPTAuthorizedPage 为点击 Login 之后的 形如 auth.openai.com/authorize?client_id=xxx 的页面,可以为空

func (*UserLogin) GetAccessToken

func (userLogin *UserLogin) GetAccessToken() string

func (*UserLogin) GetAuthCookies

func (userLogin *UserLogin) GetAuthCookies() (int, string, []*http.Cookie)

func (*UserLogin) GetAuthResult

func (userLogin *UserLogin) GetAuthResult() Result

func (*UserLogin) GetAuthorizedUrl

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

func (*UserLogin) GetFirstLoginArkosePayload added in v0.0.3

func (userLogin *UserLogin) GetFirstLoginArkosePayload(accessToken string) (string, error)

注册后首次登录第九步

func (*UserLogin) GetFirstLoginCbCode added in v0.0.3

func (userLogin *UserLogin) GetFirstLoginCbCode(deviceId, state, codeChallenge string) (string, error)

注册后首次登录第七步

func (*UserLogin) GetFirstLoginInitArkoseTokenFromCapsolver added in v0.0.3

func (userLogin *UserLogin) GetFirstLoginInitArkoseTokenFromCapsolver(arkoseDataBlob string) (string, error)

注册后首次登录第十步(选项2.从capsolver获取), 获取初始化 Arkose

func (*UserLogin) GetFirstLoginInitArkoseTokenFromFuncaptcha added in v0.0.3

func (userLogin *UserLogin) GetFirstLoginInitArkoseTokenFromFuncaptcha(arkoseDataBlob string) (string, error)

注册后首次登录第十步(选项3.使用自己的har+funcapcha生成), 获取初始化 Arkose

func (*UserLogin) GetFirstLoginInitArkoseTokenFromRemoteUrl added in v0.0.3

func (userLogin *UserLogin) GetFirstLoginInitArkoseTokenFromRemoteUrl(arkoseDataBlob string) (string, error)

注册后首次登录第十步(选项1.从远程的单独url获取), 获取初始化 Arkose

func (*UserLogin) GetFirstLoginToken added in v0.0.3

func (userLogin *UserLogin) GetFirstLoginToken(code, codeVerifier string) (string, 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) 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