Documentation ¶
Index ¶
- Constants
- Variables
- func GetEmojiSVG(emoji string) string
- func SAPISIDHash(origin, sapisid string) string
- type AuthData
- type Client
- func (c *Client) Connect() error
- func (c *Client) CurrentSessionID() string
- func (c *Client) DeleteMessage(messageID string) (*gmproto.DeleteMessageResponse, error)
- func (c *Client) Disconnect()
- func (c *Client) DoGaiaPairing(ctx context.Context, emojiCallback func(string)) error
- func (c *Client) DownloadMedia(mediaID string, key []byte) ([]byte, error)
- func (c *Client) FetchConfig() (*gmproto.Config, error)
- func (c *Client) FetchMessages(conversationID string, count int64, cursor *gmproto.Cursor) (*gmproto.ListMessagesResponse, error)
- func (c *Client) FinalizeUploadMedia(upload *StartGoogleUpload) (*MediaUpload, error)
- func (c *Client) FinishGaiaPairing(ctx context.Context, ps *PairingSession) (string, error)
- func (c *Client) GenerateQRCodeData(pairingKey []byte) (string, error)
- func (c *Client) GetContactThumbnail(contactIDs ...string) (*gmproto.GetThumbnailResponse, error)
- func (c *Client) GetConversation(conversationID string) (*gmproto.Conversation, error)
- func (c *Client) GetConversationType(conversationID string) (*gmproto.GetConversationTypeResponse, error)
- func (c *Client) GetFullSizeImage(messageID, actionMessageID string) (*gmproto.GetFullSizeImageResponse, error)
- func (c *Client) GetOrCreateConversation(req *gmproto.GetOrCreateConversationRequest) (*gmproto.GetOrCreateConversationResponse, error)
- func (c *Client) GetParticipantThumbnail(participantIDs ...string) (*gmproto.GetThumbnailResponse, error)
- func (c *Client) GetWebEncryptionKey() (*gmproto.WebEncryptionKeyResponse, error)
- func (c *Client) HandleRPCMsg(rawMsg *gmproto.IncomingRPCMessage)
- func (c *Client) IsBugleDefault() (*gmproto.IsBugleDefaultResponse, error)
- func (c *Client) IsConnected() bool
- func (c *Client) IsLoggedIn() bool
- func (c *Client) ListContacts() (*gmproto.ListContactsResponse, error)
- func (c *Client) ListConversations(count int, folder gmproto.ListConversationsRequest_Folder) (*gmproto.ListConversationsResponse, error)
- func (c *Client) ListTopContacts() (*gmproto.ListTopContactsResponse, error)
- func (c *Client) MarkRead(conversationID, messageID string) error
- func (c *Client) NotifyDittoActivity() (<-chan *IncomingRPCMessage, error)
- func (c *Client) Reconnect() error
- func (c *Client) RefreshPhoneRelay() (string, error)
- func (c *Client) RegisterPhoneRelay() (*gmproto.RegisterPhoneRelayResponse, error)
- func (c *Client) SendMessage(payload *gmproto.SendMessageRequest) (*gmproto.SendMessageResponse, error)
- func (c *Client) SendReaction(payload *gmproto.SendReactionRequest) (*gmproto.SendReactionResponse, error)
- func (c *Client) SetActiveSession() error
- func (c *Client) SetEventHandler(eventHandler EventHandler)
- func (c *Client) SetProxy(proxy string) error
- func (c *Client) SetTyping(convID string) error
- func (c *Client) StartGaiaPairing(ctx context.Context) (string, *PairingSession, error)
- func (c *Client) StartLogin() (string, error)
- func (c *Client) StartUploadMedia(encryptedImageBytes []byte, mime string) (*StartGoogleUpload, error)
- func (c *Client) Unpair() (err error)
- func (c *Client) UnpairBugle() (*gmproto.RevokeRelayPairingResponse, error)
- func (c *Client) UnpairGaia() error
- func (c *Client) UpdateConversation(payload *gmproto.UpdateConversationRequest) (*gmproto.UpdateConversationResponse, error)
- func (c *Client) UploadMedia(data []byte, fileName, mime string) (*gmproto.MediaContent, error)
- type EventHandler
- type GaiaPairingState
- type IncomingRPCMessage
- type MediaType
- type MediaUpload
- type PairingSession
- type Proxy
- type SendMessageParams
- type SessionHandler
- type StartGoogleUpload
- type WrappedMessage
Constants ¶
View Source
const ContentTypePBLite = "application/json+protobuf"
View Source
const ContentTypeProtobuf = "application/x-protobuf"
View Source
const DefaultBugleDefaultCheckInterval = 2*time.Hour + 55*time.Minute
View Source
const GaiaInitTimeout = 20 * time.Second
View Source
const RefreshTachyonBuffer = 1 * time.Hour
Variables ¶
View Source
var ( ErrNoCookies = errors.New("gaia pairing requires cookies") ErrNoDevicesFound = errors.New("no devices found for gaia pairing") ErrIncorrectEmoji = errors.New("user chose incorrect emoji on phone") ErrPairingCancelled = errors.New("user cancelled pairing on phone") ErrPairingTimeout = errors.New("pairing timed out") ErrPairingInitTimeout = errors.New("client init timed out") ErrHadMultipleDevices = errors.New("had multiple primary-looking devices") )
View Source
var FormatToMediaType = map[gmproto.MediaFormats]MediaType{ gmproto.MediaFormats_CAL_TEXT_XVCALENDAR: MimeToMediaType["text/x-calendar"], gmproto.MediaFormats_CAL_APPLICATION_VCS: MimeToMediaType["text/x-calendar"], gmproto.MediaFormats_CAL_APPLICATION_ICS: MimeToMediaType["text/calendar"], }
View Source
var MimeToMediaType = map[string]MediaType{ "image/jpeg": {Extension: "jpeg", Type: gmproto.MediaFormats_IMAGE_JPEG}, "image/jpg": {Extension: "jpg", Type: gmproto.MediaFormats_IMAGE_JPG}, "image/png": {Extension: "png", Type: gmproto.MediaFormats_IMAGE_PNG}, "image/gif": {Extension: "gif", Type: gmproto.MediaFormats_IMAGE_GIF}, "image/wbmp": {Extension: "wbmp", Type: gmproto.MediaFormats_IMAGE_WBMP}, "image/bmp": {Extension: "bmp", Type: gmproto.MediaFormats_IMAGE_X_MS_BMP}, "image/x-ms-bmp": {Extension: "bmp", Type: gmproto.MediaFormats_IMAGE_X_MS_BMP}, "video/mp4": {Extension: "mp4", Type: gmproto.MediaFormats_VIDEO_MP4}, "video/3gpp2": {Extension: "3gpp2", Type: gmproto.MediaFormats_VIDEO_3G2}, "video/3gpp": {Extension: "3gpp", Type: gmproto.MediaFormats_VIDEO_3GPP}, "video/webm": {Extension: "webm", Type: gmproto.MediaFormats_VIDEO_WEBM}, "video/x-matroska": {Extension: "mkv", Type: gmproto.MediaFormats_VIDEO_MKV}, "audio/aac": {Extension: "aac", Type: gmproto.MediaFormats_AUDIO_AAC}, "audio/amr": {Extension: "amr", Type: gmproto.MediaFormats_AUDIO_AMR}, "audio/mp3": {Extension: "mp3", Type: gmproto.MediaFormats_AUDIO_MP3}, "audio/mpeg": {Extension: "mpeg", Type: gmproto.MediaFormats_AUDIO_MPEG}, "audio/mpg": {Extension: "mpg", Type: gmproto.MediaFormats_AUDIO_MPG}, "audio/mp4": {Extension: "mp4", Type: gmproto.MediaFormats_AUDIO_MP4}, "audio/mp4-latm": {Extension: "latm", Type: gmproto.MediaFormats_AUDIO_MP4_LATM}, "audio/3gpp": {Extension: "3gpp", Type: gmproto.MediaFormats_AUDIO_3GPP}, "audio/ogg": {Extension: "ogg", Type: gmproto.MediaFormats_AUDIO_OGG}, "text/vcard": {Extension: "vcard", Type: gmproto.MediaFormats_TEXT_VCARD}, "application/pdf": {Extension: "pdf", Type: gmproto.MediaFormats_APP_PDF}, "text/plain": {Extension: "txt", Type: gmproto.MediaFormats_APP_TXT}, "text/html": {Extension: "html", Type: gmproto.MediaFormats_APP_HTML}, "application/msword": {Extension: "doc", Type: gmproto.MediaFormats_APP_DOC}, "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {Extension: "docx", Type: gmproto.MediaFormats_APP_DOCX}, "application/vnd.openxmlformats-officedocument.presentationml.presentation": {Extension: "pptx", Type: gmproto.MediaFormats_APP_PPTX}, "application/vnd.ms-powerpoint": {Extension: "ppt", Type: gmproto.MediaFormats_APP_PPT}, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {Extension: "xlsx", Type: gmproto.MediaFormats_APP_XLSX}, "application/vnd.ms-excel": {Extension: "xls", Type: gmproto.MediaFormats_APP_XLS}, "application/vnd.android.package-archive": {Extension: "apk", Type: gmproto.MediaFormats_APP_APK}, "application/zip": {Extension: "zip", Type: gmproto.MediaFormats_APP_ZIP}, "application/java-archive": {Extension: "jar", Type: gmproto.MediaFormats_APP_JAR}, "text/x-calendar": {Extension: "vcs", Type: gmproto.MediaFormats_CAL_TEXT_VCALENDAR}, "text/calendar": {Extension: "ics", Type: gmproto.MediaFormats_CAL_TEXT_CALENDAR}, "image": {Type: gmproto.MediaFormats_IMAGE_UNSPECIFIED}, "video": {Type: gmproto.MediaFormats_VIDEO_UNSPECIFIED}, "audio": {Type: gmproto.MediaFormats_AUDIO_UNSPECIFIED}, "application": {Type: gmproto.MediaFormats_APP_UNSPECIFIED}, "text": {Type: gmproto.MediaFormats_APP_TXT}, }
Functions ¶
func GetEmojiSVG ¶
func SAPISIDHash ¶
Types ¶
type AuthData ¶
type AuthData struct { // Keys used to encrypt communication with the phone RequestCrypto *crypto.AESCTRHelper `json:"request_crypto,omitempty"` // Key used to sign requests to refresh the tachyon auth token from the server RefreshKey *crypto.JWK `json:"refresh_key,omitempty"` // Identity of the paired phone and browser Browser *gmproto.Device `json:"browser,omitempty"` Mobile *gmproto.Device `json:"mobile,omitempty"` // Key used to authenticate with the server TachyonAuthToken []byte `json:"tachyon_token,omitempty"` TachyonExpiry time.Time `json:"tachyon_expiry,omitempty"` TachyonTTL int64 `json:"tachyon_ttl,omitempty"` // Unknown encryption key, not used for anything WebEncryptionKey []byte `json:"web_encryption_key,omitempty"` SessionID uuid.UUID `json:"session_id,omitempty"` DestRegID uuid.UUID `json:"dest_reg_id,omitempty"` PairingID uuid.UUID `json:"pairing_id,omitempty"` Cookies map[string]string `json:"cookies,omitempty"` CookiesLock sync.RWMutex `json:"-"` }
func NewAuthData ¶
func NewAuthData() *AuthData
func (*AuthData) AddCookiesToRequest ¶
func (*AuthData) AuthNetwork ¶
func (*AuthData) HasCookies ¶
func (*AuthData) SetCookies ¶
func (*AuthData) UpdateCookiesFromResponse ¶
type Client ¶
type Client struct { Logger zerolog.Logger GaiaHackyDeviceSwitcher int PairCallback atomic.Pointer[func(data *gmproto.PairedData)] AuthData *AuthData // contains filtered or unexported fields }
func (*Client) CurrentSessionID ¶
func (*Client) DeleteMessage ¶
func (c *Client) DeleteMessage(messageID string) (*gmproto.DeleteMessageResponse, error)
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
func (*Client) DoGaiaPairing ¶
func (*Client) DownloadMedia ¶
func (*Client) FetchMessages ¶
func (*Client) FinalizeUploadMedia ¶
func (c *Client) FinalizeUploadMedia(upload *StartGoogleUpload) (*MediaUpload, error)
func (*Client) FinishGaiaPairing ¶
func (*Client) GenerateQRCodeData ¶
func (*Client) GetContactThumbnail ¶
func (c *Client) GetContactThumbnail(contactIDs ...string) (*gmproto.GetThumbnailResponse, error)
func (*Client) GetConversation ¶
func (c *Client) GetConversation(conversationID string) (*gmproto.Conversation, error)
func (*Client) GetConversationType ¶
func (c *Client) GetConversationType(conversationID string) (*gmproto.GetConversationTypeResponse, error)
func (*Client) GetFullSizeImage ¶
func (c *Client) GetFullSizeImage(messageID, actionMessageID string) (*gmproto.GetFullSizeImageResponse, error)
func (*Client) GetOrCreateConversation ¶
func (c *Client) GetOrCreateConversation(req *gmproto.GetOrCreateConversationRequest) (*gmproto.GetOrCreateConversationResponse, error)
func (*Client) GetParticipantThumbnail ¶
func (c *Client) GetParticipantThumbnail(participantIDs ...string) (*gmproto.GetThumbnailResponse, error)
func (*Client) GetWebEncryptionKey ¶
func (c *Client) GetWebEncryptionKey() (*gmproto.WebEncryptionKeyResponse, error)
func (*Client) HandleRPCMsg ¶
func (c *Client) HandleRPCMsg(rawMsg *gmproto.IncomingRPCMessage)
func (*Client) IsBugleDefault ¶
func (c *Client) IsBugleDefault() (*gmproto.IsBugleDefaultResponse, error)
func (*Client) IsConnected ¶
func (*Client) IsLoggedIn ¶
func (*Client) ListContacts ¶
func (c *Client) ListContacts() (*gmproto.ListContactsResponse, error)
func (*Client) ListConversations ¶
func (c *Client) ListConversations(count int, folder gmproto.ListConversationsRequest_Folder) (*gmproto.ListConversationsResponse, error)
func (*Client) ListTopContacts ¶
func (c *Client) ListTopContacts() (*gmproto.ListTopContactsResponse, error)
func (*Client) NotifyDittoActivity ¶
func (c *Client) NotifyDittoActivity() (<-chan *IncomingRPCMessage, error)
func (*Client) RefreshPhoneRelay ¶
func (*Client) RegisterPhoneRelay ¶
func (c *Client) RegisterPhoneRelay() (*gmproto.RegisterPhoneRelayResponse, error)
func (*Client) SendMessage ¶
func (c *Client) SendMessage(payload *gmproto.SendMessageRequest) (*gmproto.SendMessageResponse, error)
func (*Client) SendReaction ¶
func (c *Client) SendReaction(payload *gmproto.SendReactionRequest) (*gmproto.SendReactionResponse, error)
func (*Client) SetActiveSession ¶
func (*Client) SetEventHandler ¶
func (c *Client) SetEventHandler(eventHandler EventHandler)
func (*Client) StartGaiaPairing ¶
func (*Client) StartLogin ¶
func (*Client) StartUploadMedia ¶
func (c *Client) StartUploadMedia(encryptedImageBytes []byte, mime string) (*StartGoogleUpload, error)
func (*Client) UnpairBugle ¶
func (c *Client) UnpairBugle() (*gmproto.RevokeRelayPairingResponse, error)
func (*Client) UnpairGaia ¶
func (*Client) UpdateConversation ¶
func (c *Client) UpdateConversation(payload *gmproto.UpdateConversationRequest) (*gmproto.UpdateConversationResponse, error)
func (*Client) UploadMedia ¶
type EventHandler ¶
type EventHandler func(evt any)
type GaiaPairingState ¶
type GaiaPairingState struct {
*PairingSession
}
type IncomingRPCMessage ¶
type IncomingRPCMessage struct { *gmproto.IncomingRPCMessage IsOld bool Pair *gmproto.RPCPairData Gaia *gmproto.RPCGaiaData Message *gmproto.RPCMessageData DecryptedData []byte DecryptedMessage proto.Message }
type MediaUpload ¶
type PairingSession ¶
type PairingSession struct { UUID uuid.UUID Start time.Time PairingKeyDSA *ecdsa.PrivateKey DestRegDevice primaryDeviceID ServerInit *gmproto.GaiaPairingResponseContainer InitPayload []byte FinishPayload []byte NextKey []byte }
func NewPairingSession ¶
func NewPairingSession(destRegDevice primaryDeviceID) *PairingSession
func (*PairingSession) PreparePayloads ¶
func (ps *PairingSession) PreparePayloads() ([]byte, []byte, error)
func (*PairingSession) ProcessServerInit ¶
func (ps *PairingSession) ProcessServerInit(msg *gmproto.GaiaPairingResponseContainer) (string, error)
type SendMessageParams ¶
type SendMessageParams struct { Action gmproto.ActionType Data proto.Message RequestID string OmitTTL bool CustomTTL int64 DontEncrypt bool MessageType gmproto.MessageType }
type SessionHandler ¶
type SessionHandler struct {
// contains filtered or unexported fields
}
func (*SessionHandler) ResetSessionID ¶
func (s *SessionHandler) ResetSessionID()
type StartGoogleUpload ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.