auth

package
v0.0.0-...-d85f73f Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceMethodAuthLogin            = "wtlogin.login"
	ServiceMethodAuthExchange         = "wtlogin.exchange"
	ServiceMethodAuthExchangeAccount  = "wtlogin.exchange_emp"
	ServiceMethodAuthUsernameToUin    = "wtlogin.name2uin"
	ServiceMethodAuthTransportAccount = "wtlogin.trans_emp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Call(
		serviceMethod string,
		c2s *codec.ClientToServerMessage,
		s2c *codec.ServerToClientMessage,
	) error
	GetNextSeq() uint32

	GetUserSignature(username string) *rpc.UserSignature
	SetUserSignature(
		ctx context.Context,
		username string,
		tlvs map[uint16]tlv.TLVCodec,
	)
	SetUserAuthSession(username string, session []byte)
	SetUserKSIDSession(username string, ksid []byte)

	SaveUserSignatures(file string) error
}

type Flow

type Flow struct {
	// contains filtered or unexported fields
}

func NewFlow

func NewFlow(opt *FlowOptions, h FlowHandler) *Flow

func (*Flow) Run

func (f *Flow) Run(ctx context.Context) error

type FlowHandler

type FlowHandler interface {
	CheckCaptcha(ctx context.Context, username string, code []byte) (*Response, error)
	CheckPassword(ctx context.Context, username, password string) (*Response, error)
	CheckPicture(ctx context.Context, username string, code, sign []byte) (*Response, error)
	CheckSMSCode(ctx context.Context, username string, code []byte) (*Response, error)
	SendSMSCode(ctx context.Context, username string) (*Response, error)
	SignIn(ctx context.Context, username, password string) (*Response, error)

	GetUserSignature(username string) *rpc.UserSignature
}

type FlowOptions

type FlowOptions struct {
	Username string
	Password string

	AuthAddr string
	CacheDir string
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(opt *HandlerOptions, client Client) *Handler

func (*Handler) AuthGetSessionTicketsWithQRSignature

func (h *Handler) AuthGetSessionTicketsWithQRSignature(
	ctx context.Context,
	req *getSessionTicketsWithQRSignatureRequest,
) (*Response, error)

func (*Handler) CheckCaptcha

func (h *Handler) CheckCaptcha(ctx context.Context, username string, code []byte) (*Response, error)

func (*Handler) CheckPassword

func (h *Handler) CheckPassword(ctx context.Context, username, password string) (*Response, error)

func (*Handler) CheckPicture

func (h *Handler) CheckPicture(ctx context.Context, username string, code, sign []byte) (*Response, error)

func (*Handler) CheckSMSCode

func (h *Handler) CheckSMSCode(ctx context.Context, username string, code []byte) (*Response, error)

func (*Handler) GetNextSeq

func (h *Handler) GetNextSeq() uint32

func (*Handler) GetUserSignature

func (h *Handler) GetUserSignature(username string) *rpc.UserSignature

func (*Handler) SendSMSCode

func (h *Handler) SendSMSCode(ctx context.Context, username string) (*Response, error)

func (*Handler) SignIn

func (h *Handler) SignIn(ctx context.Context, username, password string) (*Response, error)

type HandlerOptions

type HandlerOptions struct {
	BaseDir string
	Client  *config.ClientConfig
	Device  *config.DeviceConfig
}

type Request

type Request interface {
	GetSeq() uint32
	SetSeq(seq uint32)
	GetServiceMethod() string
	SetServiceMethod(service string)
	GetType() uint16
	SetType(typ uint16)
	GetUin() uint64
	SetUin(uin uint64)
	GetUsername() string
	SetUsername(username string)

	MustGetTLVs(ctx context.Context) map[uint16]tlv.TLVCodec
}

type Response

type Response struct {
	Code     uint8
	Uin      uint64
	Username string

	PictureSign  []byte
	PictureData  []byte
	CaptchaSign  string
	ErrorCode    uint32
	ErrorTitle   string
	ErrorMessage string
	Message      string
	SMSMobile    string

	AuthSession []byte
	T119        []byte
	T150        []byte
	T161        []byte
	T174        []byte
	T17B        []byte
	T401        [16]byte
	T402        []byte
	T403        []byte
	T546        []byte

	LoginExtraData []byte
}

func (*Response) SetTLVs

func (resp *Response) SetTLVs(
	ctx context.Context,
	tlvs map[uint16]tlv.TLVCodec,
) error

type SendSMSCodeRequest

type SendSMSCodeRequest struct {
	SMSAppID uint64

	SubSigMap    uint32
	SubAppIDList []uint64
	// contains filtered or unexported fields
}

func (*SendSMSCodeRequest) GetSeq

func (req *SendSMSCodeRequest) GetSeq() uint32

func (*SendSMSCodeRequest) GetServiceMethod

func (req *SendSMSCodeRequest) GetServiceMethod() string

func (*SendSMSCodeRequest) GetType

func (req *SendSMSCodeRequest) GetType() uint16

func (*SendSMSCodeRequest) GetUin

func (req *SendSMSCodeRequest) GetUin() uint64

func (*SendSMSCodeRequest) GetUsername

func (req *SendSMSCodeRequest) GetUsername() string

func (*SendSMSCodeRequest) MustGetTLVs

func (req *SendSMSCodeRequest) MustGetTLVs(
	ctx context.Context,
) map[uint16]tlv.TLVCodec

func (*SendSMSCodeRequest) SetSeq

func (req *SendSMSCodeRequest) SetSeq(seq uint32)

func (*SendSMSCodeRequest) SetServiceMethod

func (req *SendSMSCodeRequest) SetServiceMethod(service string)

func (*SendSMSCodeRequest) SetType

func (req *SendSMSCodeRequest) SetType(typ uint16)

func (*SendSMSCodeRequest) SetUin

func (req *SendSMSCodeRequest) SetUin(uin uint64)

func (*SendSMSCodeRequest) SetUsername

func (req *SendSMSCodeRequest) SetUsername(username string)

Jump to

Keyboard shortcuts

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