messagix

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: AGPL-3.0 Imports: 53 Imported by: 0

Documentation

Index

Constants

View Source
const BrowserName = "Chrome"
View Source
const ChromeVersion = "129"
View Source
const ChromeVersionFull = ChromeVersion + ".0.6668.101"
View Source
const DPR = "1"
View Source
const MaxHTTPRetries = 5
View Source
const OSName = "Linux"
View Source
const OSVersion = "6.8.0"
View Source
const SecCHFullVersionList = `"Chromium";v="` + ChromeVersionFull + `", "Google Chrome";v="` + ChromeVersionFull + `", "Not-A.Brand";v="99.0.0.0"`
View Source
const SecCHMobile = "?0"
View Source
const SecCHModel = `""`
View Source
const SecCHPlatform = `"` + OSName + `"`
View Source
const SecCHPlatformVersion = `"` + OSVersion + `"`
View Source
const SecCHPrefersColorScheme = "light"
View Source
const SecCHUserAgent = `"Chromium";v="` + ChromeVersion + `", "Google Chrome";v="` + ChromeVersion + `", "Not-A.Brand";v="99"`
View Source
const UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/" + ChromeVersion + ".0.0.0 Safari/537.36"

Variables

View Source
var (
	ErrTokenInvalidated   = errors.New("access token is no longer valid")
	ErrChallengeRequired  = errors.New("challenge required")
	ErrConsentRequired    = errors.New("consent required")
	ErrAccountSuspended   = errors.New("account suspended")
	ErrRequestFailed      = errors.New("failed to send request")
	ErrResponseReadFailed = errors.New("failed to read response body")
	ErrMaxRetriesReached  = errors.New("maximum retries reached")
	ErrTooManyRedirects   = errors.New("too many redirects")
)
View Source
var (
	ErrSocketClosed      = errors.New("messagix-socket: socket is closed")
	ErrSocketAlreadyOpen = errors.New("messagix-socket: socket is already open")
	ErrNotAuthenticated  = errors.New("messagix-socket: client has not been authenticated successfully yet")
)
View Source
var DisableTLSVerification = false
View Source
var ErrChannelNotFound = fmt.Errorf("channel not found for packet")
View Source
var ErrConnectionClosed = fmt.Errorf("connection closed")
View Source
var ErrDial = errors.New("failed to dial socket")
View Source
var ErrInReadLoop = errors.New("error in read loop")
View Source
var ErrSendConnect = errors.New("failed to send connect packet")
View Source
var ErrTimeout = fmt.Errorf("timeout waiting for response")

Functions

This section is empty.

Types

type AckEvent

type AckEvent interface {
	GetPacketId() uint16
}

type AppSettingsPublish

type AppSettingsPublish struct {
	LsFdid        string `json:"ls_fdid"`
	SchemaVersion string `json:"ls_sv"`
}

type AttributeMap

type AttributeMap map[string]string

type BBox

type BBox struct {
	Require []*ModuleEntry `json:"require"`
	Define  []*ModuleEntry `json:"define"`
}

type BBoxContainer

type BBoxContainer struct {
	BBox *BBox `json:"__bbox,omitempty"`
}

type BigPipe

type BigPipe struct {
	JSMods *BBox `json:"jsmods,omitempty"`
}

type ChannelType

type ChannelType int
const (
	RequestChannel ChannelType = iota
	PacketChannel
)

type Client

type Client struct {
	Instagram *InstagramMethods
	Facebook  *FacebookMethods
	Logger    zerolog.Logger
	Platform  types.Platform

	SyncManager *SyncManager

	GetNewProxy func(reason string) (string, error)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cookies *cookies.Cookies, logger zerolog.Logger) *Client

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Disconnect

func (c *Client) Disconnect()

func (*Client) EnableSendingMessages

func (c *Client) EnableSendingMessages()

func (*Client) ExecuteTasks

func (c *Client) ExecuteTasks(tasks ...socket.Task) (*table.LSTable, error)

func (*Client) GetCurrentAccount

func (c *Client) GetCurrentAccount() (types.UserInfo, error)

func (*Client) GetTaskId

func (c *Client) GetTaskId() int

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) LoadMessagesPage

func (c *Client) LoadMessagesPage() (types.UserInfo, *table.LSTable, error)

func (*Client) MakeRequest

func (c *Client) MakeRequest(url string, method string, headers http.Header, payload []byte, contentType types.ContentType) (*http.Response, []byte, error)

func (*Client) NewHttpQuery

func (c *Client) NewHttpQuery() *HttpQuery

func (*Client) NewMercuryMediaPayload

func (c *Client) NewMercuryMediaPayload(media *MercuryUploadMedia) ([]byte, string, error)

returns payloadBytes, multipart content-type header

func (*Client) NewPublishRequest

func (c *Client) NewPublishRequest(topic Topic, jsonData string, packetByte byte, packetId uint16) ([]byte, uint16, error)

func (*Client) NewSubscribeRequest

func (c *Client) NewSubscribeRequest(topic Topic, qos packets.QoS) ([]byte, uint16, error)

func (*Client) NewSyncManager

func (c *Client) NewSyncManager() *SyncManager

func (*Client) NewTaskManager

func (c *Client) NewTaskManager() *TaskManager

func (*Client) PrepareE2EEClient

func (c *Client) PrepareE2EEClient() *whatsmeow.Client

func (*Client) RegisterE2EE

func (c *Client) RegisterE2EE(ctx context.Context, fbid int64) error

func (*Client) SaveSession

func (c *Client) SaveSession(path string) error

func (*Client) SendMercuryUploadRequest

func (c *Client) SendMercuryUploadRequest(ctx context.Context, threadID int64, media *MercuryUploadMedia) (*types.MercuryUploadResponse, error)

func (*Client) SetDevice

func (c *Client) SetDevice(dev *store.Device)

func (*Client) SetEventHandler

func (c *Client) SetEventHandler(handler EventHandler)

func (*Client) SetProxy

func (c *Client) SetProxy(proxyAddr string) error

func (*Client) UpdateProxy

func (c *Client) UpdateProxy(reason string) bool

func (*Client) WaitUntilCanSendMessages

func (c *Client) WaitUntilCanSendMessages(timeout time.Duration) error

type Configs

type Configs struct {
	LsdToken     string
	CometReq     string
	VersionId    int64
	Jazoest      string
	WebSessionId string
	Bitmap       *crypto.Bitmap
	CsrBitmap    *crypto.Bitmap
	// contains filtered or unexported fields
}

func (*Configs) LoadBitmaps

func (c *Configs) LoadBitmaps() (*crypto.Bitmap, *crypto.Bitmap)

(bitmap, csrBitmap)

func (*Configs) ParseFormInputs

func (c *Configs) ParseFormInputs(inputs []InputTag, reflectedMs reflect.Value)

func (*Configs) SetupConfigs

func (c *Configs) SetupConfigs(ls *table.LSTable) (*table.LSTable, error)

type Connect

type Connect struct {
	AccountId          string               `json:"u"`            // account id
	SessionId          int64                `json:"s"`            // randomly generated sessionid
	ClientCapabilities int                  `json:"cp"`           // mqttconfig clientCapabilities (3)
	Capabilities       int                  `json:"ecp"`          // mqttconfig capabilities (10)
	ChatOn             bool                 `json:"chat_on"`      // mqttconfig chatVisibility (true) - not 100% sure
	Fg                 bool                 `json:"fg"`           // idk what this is
	Cid                string               `json:"d"`            // cid from html content
	ConnectionType     string               `json:"ct"`           // connection type? facebook=websocket , insta=cookie_auth
	MqttSid            string               `json:"mqtt_sid"`     // ""
	AppId              int64                `json:"aid"`          // mqttconfig appID (219994525426954)
	SubscribedTopics   []string             `json:"st"`           // mqttconfig subscribedTopics ([])
	PostMessage        []ConnectPostMessage `json:"pm"`           // only seen empty array
	Dc                 string               `json:"dc"`           // only seem empty string
	NoAutoFg           bool                 `json:"no_auto_fg"`   // only seen true
	Gas                any                  `json:"gas"`          // only seen null
	Pack               []any                `json:"pack"`         // only seen empty arr
	HostNameOverride   string               `json:"php_override"` // mqttconfig hostNameOverride
	P                  any                  `json:"p"`            // only seen null
	UserAgent          string               `json:"a"`            // user agent
	Aids               any                  `json:"aids"`         // only seen null
}

type ConnectPayload

type ConnectPayload struct {
	ProtocolName  string `lengthType:"uint16"`
	ProtocolLevel uint8
	ConnectFlags  uint8
	KeepAliveTime uint16
	ClientId      string `lengthType:"uint16"`
	JSONData      string `lengthType:"uint16"`
}

func (*ConnectPayload) Write

func (cp *ConnectPayload) Write() ([]byte, error)

type ConnectPostMessage

type ConnectPostMessage struct {
	IsBase64Publish bool        `json:"isBase64Publish"`
	MessageID       int64       `json:"messageId"`
	Payload         string      `json:"payload"`
	QoS             packets.QoS `json:"qos"`
	Topic           string      `json:"topic"`
}

type ConnectionCode

type ConnectionCode uint8
const (
	CONNECTION_ACCEPTED ConnectionCode = iota
	CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION
	CONNECTION_REFUSED_IDENTIFIER_REJECTED
	CONNECTION_REFUSED_SERVER_UNAVAILABLE
	CONNECTION_REFUSED_BAD_USERNAME_OR_PASSWORD
	CONNECTION_REFUSED_UNAUTHORIZED
)

func (ConnectionCode) Error

func (c ConnectionCode) Error() string

func (ConnectionCode) IsEnum

func (c ConnectionCode) IsEnum()

type EventHandler

type EventHandler func(evt interface{})

type Event_PermanentError

type Event_PermanentError struct{ Err error }

type Event_PingResp

type Event_PingResp struct{}

func (*Event_PingResp) Finish

func (e *Event_PingResp) Finish() ResponseData

func (*Event_PingResp) SetIdentifier

func (pr *Event_PingResp) SetIdentifier(identifier uint16)

type Event_PublishACK

type Event_PublishACK struct {
	PacketId uint16
}

Event_PublishACK is never emitted, it only handles the acknowledgement after a PUBLISH packet has been sent.

func (*Event_PublishACK) Finish

func (pb *Event_PublishACK) Finish() ResponseData

func (*Event_PublishACK) GetPacketId

func (pb *Event_PublishACK) GetPacketId() uint16

func (*Event_PublishACK) SetIdentifier

func (pb *Event_PublishACK) SetIdentifier(identifier uint16)

type Event_PublishResponse

type Event_PublishResponse struct {
	Topic             string              `lengthType:"uint16" endian:"big"`
	Data              PublishResponseData `jsonString:"1"`
	Table             *table.LSTable
	MessageIdentifier uint16
}

Event_PublishResponse is emitted if the packetId/requestId from the websocket is 0 or nil

It will also be used for handling the responses after calling a function like GetContacts through the requestId

func (*Event_PublishResponse) Finish

func (pb *Event_PublishResponse) Finish() ResponseData

func (*Event_PublishResponse) SetIdentifier

func (pb *Event_PublishResponse) SetIdentifier(identifier uint16)

type Event_Ready

type Event_Ready struct {
	IsNewSession   bool
	ConnectionCode ConnectionCode
	// contains filtered or unexported fields
}

Event_Ready represents the CONNACK packet's response.

The library provides the raw parsed data, so handle connection codes as needed for your application.

func (*Event_Ready) Finish

func (e *Event_Ready) Finish() ResponseData

func (*Event_Ready) SetIdentifier

func (pb *Event_Ready) SetIdentifier(identifier uint16)

type Event_Reconnected

type Event_Reconnected struct{}

type Event_SocketError

type Event_SocketError struct {
	Err                error
	ConnectionAttempts int
}

type Event_SubscribeACK

type Event_SubscribeACK struct {
	PacketId uint16
	QoSLevel uint8 // 0, 1, 2, 128
}

Event_SubscribeACK is never emitted, it only handles the acknowledgement after a SUBSCRIBE packet has been sent.

func (*Event_SubscribeACK) Finish

func (pb *Event_SubscribeACK) Finish() ResponseData

func (*Event_SubscribeACK) GetPacketId

func (pb *Event_SubscribeACK) GetPacketId() uint16

func (*Event_SubscribeACK) SetIdentifier

func (pb *Event_SubscribeACK) SetIdentifier(identifier uint16)

type FacebookMethods

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

func (*FacebookMethods) Login

func (fb *FacebookMethods) Login(identifier, password string) (*cookies.Cookies, error)

func (*FacebookMethods) RegisterPushNotifications

func (fb *FacebookMethods) RegisterPushNotifications(endpoint string, keys PushKeys) error

type FormTag

type FormTag struct {
	Attributes AttributeMap
	Inputs     []InputTag
}

type HttpQuery

type HttpQuery struct {
	AcceptOnlyEssential  string `url:"accept_only_essential,omitempty"`
	Av                   string `url:"av,omitempty"`          // not required
	User                 string `url:"__user,omitempty"`      // not required
	A                    string `url:"__a,omitempty"`         // 1 or 0 wether to include "suggestion_keys" or not in the response - no idea what this is
	Req                  string `url:"__req,omitempty"`       // not required
	Hs                   string `url:"__hs,omitempty"`        // not required
	Dpr                  string `url:"dpr,omitempty"`         // not required
	Ccg                  string `url:"__ccg,omitempty"`       // not required
	Rev                  string `url:"__rev,omitempty"`       // not required
	S                    string `url:"__s,omitempty"`         // not required
	Hsi                  string `url:"__hsi,omitempty"`       // not required
	Dyn                  string `url:"__dyn,omitempty"`       // not required
	Csr                  string `url:"__csr"`                 // not required
	CometReq             string `url:"__comet_req,omitempty"` // not required but idk what this is
	FbDtsg               string `url:"fb_dtsg,omitempty"`
	Jazoest              string `url:"jazoest,omitempty"`                  // not required
	Lsd                  string `url:"lsd,omitempty"`                      // required
	SpinR                string `url:"__spin_r,omitempty"`                 // not required
	SpinB                string `url:"__spin_b,omitempty"`                 // not required
	SpinT                string `url:"__spin_t,omitempty"`                 // not required
	Jssesw               string `url:"__jssesw,omitempty"`                 // not required
	FbAPICallerClass     string `url:"fb_api_caller_class,omitempty"`      // not required
	FbAPIReqFriendlyName string `url:"fb_api_req_friendly_name,omitempty"` // not required
	Variables            string `url:"variables,omitempty"`
	ServerTimestamps     string `url:"server_timestamps,omitempty"` // "true" or "false"
	DocID                string `url:"doc_id,omitempty"`
	D                    string `url:"__d,omitempty"`               // for insta
	AppID                string `url:"app_id,omitempty"`            // not required
	PushEndpoint         string `url:"push_endpoint,omitempty"`     // not required
	SubscriptionKeys     string `url:"subscription_keys,omitempty"` // not required
	DeviceToken          string `url:"device_token,omitempty"`      // not required
	DeviceType           string `url:"device_type,omitempty"`       // not required
	Mid                  string `url:"mid,omitempty"`               // not required
	Aaid                 string `url:"__aaid,omitempty"`
}

type ICDCFetchResponse

type ICDCFetchResponse struct {
	DeviceIdentities []string `json:"device_identities"`
	ICDCSeq          int      `json:"icdc_seq"`
	Status           int      `json:"status"`
}

func (*ICDCFetchResponse) DeviceIdentityBytes

func (ifr *ICDCFetchResponse) DeviceIdentityBytes() (deviceIdentityBytes [][32]byte, err error)

type ICDCRegisterResponse

type ICDCRegisterResponse struct {
	ICDCSuccess bool   `json:"icdc_success"` // not always present?
	Product     string `json:"product"`      // msgr
	Status      int    `json:"status"`       // 200
	Type        string `json:"type"`         // "new"
	WADeviceID  int    `json:"wa_device_id"`
}

type InputTag

type InputTag struct {
	Attributes AttributeMap
}

type InstagramMethods

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

specific methods for insta api, not socket related

func (*InstagramMethods) ExtractFBID

func (ig *InstagramMethods) ExtractFBID(currentUser types.UserInfo, tbl *table.LSTable) (int64, error)

func (*InstagramMethods) FetchHighlights

func (ig *InstagramMethods) FetchHighlights(highlightIds []string) (*responses.ReelInfoResponse, error)

NOTE:

Hightlight IDs are different, they come in the format: "highlight:17913397615055292"

func (*InstagramMethods) FetchMedia

func (ig *InstagramMethods) FetchMedia(mediaID, mediaShortcode string) (*responses.FetchMediaResponse, error)

func (*InstagramMethods) FetchProfile

func (ig *InstagramMethods) FetchProfile(username string) (*responses.ProfileInfoResponse, error)

func (*InstagramMethods) FetchReel

func (ig *InstagramMethods) FetchReel(reelIds []string, mediaID string) (*responses.ReelInfoResponse, error)

func (*InstagramMethods) Login

func (ig *InstagramMethods) Login(identifier, password string) (*cookies.Cookies, error)

func (*InstagramMethods) RegisterPushNotifications

func (ig *InstagramMethods) RegisterPushNotifications(endpoint string, keys PushKeys) error

type LinkTag

type LinkTag struct {
	Attributes AttributeMap
}

type MercuryUploadMedia

type MercuryUploadMedia struct {
	Filename  string
	MimeType  string
	MediaData []byte

	IsVoiceClip  bool
	WaveformData *WaveformData
}

type ModuleEntry

type ModuleEntry struct {
	Name string
	Data []json.RawMessage
}

func (*ModuleEntry) UnmarshalJSON

func (me *ModuleEntry) UnmarshalJSON(data []byte) error

type ModuleParser

type ModuleParser struct {
	FormTags    []FormTag
	LoginInputs []InputTag
	JSDatr      string

	LS *table.LSTable
	// contains filtered or unexported fields
}

func (*ModuleParser) HandleBootloaderPayload

func (m *ModuleParser) HandleBootloaderPayload(payload json.RawMessage, bootloaderConfig *types.BootLoaderConfig) error

func (*ModuleParser) HandleRawJSON

func (m *ModuleParser) HandleRawJSON(data []byte, id string) error

func (*ModuleParser) Load

func (m *ModuleParser) Load(page string) error

func (*ModuleParser) SSJSHandle

func (m *ModuleParser) SSJSHandle(data json.RawMessage) error

func (*ModuleParser) SetClientInstance

func (m *ModuleParser) SetClientInstance(cli *Client)

type NodeProcessor

type NodeProcessor func(*html.Node) interface{}

type Payload

type Payload interface {
	Write() ([]byte, error)
}

type PublishPayload

type PublishPayload struct {
	Topic    Topic `lengthType:"uint16"`
	PacketId uint16
	JSONData string `lengthType:""`
}

func (*PublishPayload) Write

func (pb *PublishPayload) Write() ([]byte, error)

type PublishResponseData

type PublishResponseData struct {
	RequestID int64    `json:"request_id,omitempty"`
	Payload   string   `json:"payload,omitempty"`
	Sp        []string `json:"sp,omitempty"` // dependencies
	Target    int      `json:"target,omitempty"`
}

type PushKeys added in v0.4.1

type PushKeys struct {
	P256DH []byte `json:"p256dh"`
	Auth   []byte `json:"auth"`
}

type RPSCBBox

type RPSCBBox struct {
	Complete bool            `json:"complete"`
	Result   json.RawMessage `json:"result"`
}

type RPSCBBoxContainer

type RPSCBBoxContainer struct {
	BBox *RPSCBBox `json:"__bbox"`
}

type RelayPrefetchedStreamCache

type RelayPrefetchedStreamCache struct {
	PreloadID string
	BBox      *RPSCBBoxContainer
}

func (*RelayPrefetchedStreamCache) UnmarshalJSON

func (rpsc *RelayPrefetchedStreamCache) UnmarshalJSON(data []byte) error

type Request

type Request struct {
	PacketByte      uint8
	RemainingLength uint32 `vlq:"true"`
}

func (*Request) Write

func (r *Request) Write(payload Payload) ([]byte, error)

type Response

type Response struct {
	PacketByte      uint8
	RemainingLength uint32 `vlq:"true"`
	ResponseData    ResponseData
}

func (*Response) PacketType

func (r *Response) PacketType() uint8

func (*Response) QOS

func (r *Response) QOS() packets.QoS

func (*Response) Read

func (r *Response) Read(data []byte) error

type ResponseData

type ResponseData interface {
	Finish() ResponseData
	SetIdentifier(identifier uint16)
}

type ResponseHandler

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

func (*ResponseHandler) CancelAllRequests

func (p *ResponseHandler) CancelAllRequests()

type ScriptTag

type ScriptTag struct {
	Attributes AttributeMap
	Content    string
}

type Socket

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

func (*Socket) BuildBrokerUrl

func (s *Socket) BuildBrokerUrl() string

func (*Socket) CanConnect

func (s *Socket) CanConnect() error

func (*Socket) Connect

func (s *Socket) Connect() error

func (*Socket) Disconnect

func (s *Socket) Disconnect()

func (*Socket) SafePacketId

func (s *Socket) SafePacketId() uint16

type SocketLSRequestPayload

type SocketLSRequestPayload struct {
	AppId     string `json:"app_id"`
	Payload   string `json:"payload"`
	RequestId int    `json:"request_id"`
	Type      int    `json:"type"`
}

type SubscribePayload

type SubscribePayload struct {
	PacketId uint16
	Topic    Topic `lengthType:"uint16"`
	QoSLevel packets.QoS
}

func (*SubscribePayload) Write

func (sb *SubscribePayload) Write() ([]byte, error)

type SyncManager

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

func (*SyncManager) EnsureSyncedSocket

func (sm *SyncManager) EnsureSyncedSocket(databases []int64) error

func (*SyncManager) GetCursor

func (sm *SyncManager) GetCursor(db int64) string

func (*SyncManager) SyncDataGraphQL

func (sm *SyncManager) SyncDataGraphQL(dbs []int64) (*table.LSTable, error)

func (*SyncManager) SyncSocketData

func (sm *SyncManager) SyncSocketData(databaseId int64, db *socket.QueryMetadata) (*table.LSTable, error)

func (*SyncManager) SyncTransactions

func (sm *SyncManager) SyncTransactions(transactions []*table.LSExecuteFirstBlockForSyncTransaction) error

func (*SyncManager) UpdateDatabaseSyncParams

func (sm *SyncManager) UpdateDatabaseSyncParams(dbs []*socket.QueryMetadata) error

type TaskManager

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

func (*TaskManager) AddNewTask

func (tm *TaskManager) AddNewTask(task socket.Task)

func (*TaskManager) FinalizePayload

func (tm *TaskManager) FinalizePayload() ([]byte, error)

func (*TaskManager) GetTaskId

func (tm *TaskManager) GetTaskId() int64

type Topic

type Topic string
const (
	UNKNOWN_TOPIC       Topic = "unknown"
	LS_APP_SETTINGS     Topic = "/ls_app_settings"
	LS_FOREGROUND_STATE Topic = "/ls_foreground_state"
	LS_REQ              Topic = "/ls_req"
	LS_RESP             Topic = "/ls_resp"
)

type WaveformData

type WaveformData struct {
	Amplitudes        []float64 `json:"amplitudes"`
	SamplingFrequency int       `json:"sampling_frequency"`
}

Directories

Path Synopsis
data

Jump to

Keyboard shortcuts

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