Documentation
¶
Overview ¶
Package gm is Agent GM's entire dependency on Google Messages.
Index ¶
- Constants
- Variables
- func AccountAddressFromPairing(rawSourceID string) (string, error)
- func CanonicalEmoji(t EmojiType, raw string) *string
- func DecryptLegacyWebPush(private, auth, body []byte, encryption, cryptoKey string) ([]byte, error)
- func DecryptWebPush(private, auth, body []byte) ([]byte, error)
- func DeviceIdentity() string
- func DeviceOSName(version string) string
- func GenerateTmpID() string
- func IgnoredStatuses() (dmOnly []int32, always []int32)
- func IsFatalListenError(err error) bool
- func IsOutgoingLadderState(s DeliveryState) bool
- func IsSystemEventStatus(raw int32) bool
- func MappedStatusValues() []int32
- func MissingRequiredCookies(cookies map[string]string) []string
- func PlausibleAccountAddress(s string) bool
- func RawEmojiType(t EmojiType) (int32, bool)
- func SetDeviceIdentity(version string)
- func ShouldIgnoreStatus(raw int32, isDM bool) bool
- func SupportedMIME(mime string) bool
- func SupportedMIMETypes() []string
- func TransitionAllowed(from, to DeliveryState) bool
- type AlertType
- type Attachment
- type Backend
- type Code
- type ConfigInfo
- type ConfigVersion
- type Contact
- type Conversation
- type ConversationChange
- type ConversationType
- type Cursor
- type DeliveryState
- type Direction
- type DroppedEventCounter
- type EmojiType
- type Error
- type Event
- type EventAccountChange
- type EventAuthTokenRefreshed
- type EventClientReady
- type EventConversation
- type EventGaiaLoggedOut
- type EventHackySetActiveMayFail
- type EventListenFatalError
- type EventListenRecovered
- type EventListenTemporaryError
- type EventMessage
- type EventNoDataReceived
- type EventPairSuccessful
- type EventPhoneNotResponding
- type EventPhoneRespondingAgain
- type EventPingFailed
- type EventRevokePairData
- type EventSettings
- type EventTyping
- type EventUnknown
- type EventUserAlert
- type Folder
- type HTTPError
- type LibGM
- func (b *LibGM) AccountAddress() string
- func (b *LibGM) BackgroundRequest(ctx context.Context, request func(context.Context) error) error
- func (b *LibGM) CompiledConfigVersion() ConfigVersion
- func (b *LibGM) Connect(ctx context.Context) error
- func (b *LibGM) ContactAvatars(ctx context.Context, ids []string) (map[string][]byte, error)
- func (b *LibGM) DeleteConversation(ctx context.Context, convID, phone string) error
- func (b *LibGM) DeleteMessage(ctx context.Context, msgID string) error
- func (b *LibGM) Disconnect()
- func (b *LibGM) Download(ctx context.Context, mediaID string, key []byte) ([]byte, error)
- func (b *LibGM) DownloadAvatar(ctx context.Context, url string) ([]byte, error)
- func (b *LibGM) DroppedEvents() uint64
- func (b *LibGM) EnablePush(endpointBase string, saved []byte, save, saveAuth func([]byte) error) error
- func (b *LibGM) Events() <-chan Event
- func (b *LibGM) FetchConfig(ctx context.Context) (ConfigInfo, error)
- func (b *LibGM) GetConversation(ctx context.Context, convID string) (*Conversation, error)
- func (b *LibGM) GetConversationType(ctx context.Context, convID string) (ConversationType, error)
- func (b *LibGM) HandlePush(w http.ResponseWriter, r *http.Request, token string)
- func (b *LibGM) IsConnected() bool
- func (b *LibGM) IsDefaultSMSApp(ctx context.Context) (bool, error)
- func (b *LibGM) IsLoggedIn() bool
- func (b *LibGM) ListContacts(ctx context.Context) ([]Contact, error)
- func (b *LibGM) ListConversations(ctx context.Context, folder Folder, count int) ([]Conversation, error)
- func (b *LibGM) ListMessages(ctx context.Context, convID string, count int, cursor *Cursor) ([]Message, *Cursor, error)
- func (b *LibGM) ListTopContacts(ctx context.Context) ([]Contact, error)
- func (b *LibGM) LoadSession(data []byte) error
- func (b *LibGM) MarkRead(ctx context.Context, convID, msgID string) error
- func (b *LibGM) MarshalSession() ([]byte, error)
- func (b *LibGM) PollBackgroundOnce() error
- func (b *LibGM) React(ctx context.Context, msgID string, emoji string, action ReactionAction) error
- func (b *LibGM) RefreshGoogleCookies(ctx context.Context, cookies map[string]string) error
- func (b *LibGM) RegisterWebPush(ctx context.Context, endpoint string, public, auth []byte) error
- func (b *LibGM) RequestFullSizeImage(ctx context.Context, msgID, actionMsgID string) error
- func (b *LibGM) ResolveConversation(ctx context.Context, numbers []string, groupName string) (ResolveResult, error)
- func (b *LibGM) SaveSession(save func([]byte) error) error
- func (b *LibGM) SendMedia(ctx context.Context, req SendMediaRequest) (SendResult, error)
- func (b *LibGM) SendText(ctx context.Context, req SendTextRequest) (SendResult, error)
- func (b *LibGM) SessionDirty() bool
- func (b *LibGM) SessionID() string
- func (b *LibGM) SetPushLogger(log zerolog.Logger)
- func (b *LibGM) SetPushPairingMode()
- func (b *LibGM) SetTyping(ctx context.Context, convID string) error
- func (b *LibGM) Shred()
- func (b *LibGM) StartGooglePairing(ctx context.Context, cookies map[string]string, deviceIndex int, ...) (PairedDevice, error)
- func (b *LibGM) UnknownEvents() uint64
- func (b *LibGM) UpdateConversation(ctx context.Context, convID string, ch ConversationChange) error
- func (b *LibGM) Upload(ctx context.Context, data []byte, filename, mime string) (MediaRef, error)
- func (b *LibGM) WithSession(ctx context.Context, request func(context.Context) error) error
- type MediaRef
- type Message
- type MessageKind
- type PairedDevice
- type Participant
- type PushSubscription
- type Reaction
- type ReactionAction
- type RequestError
- type ResolveResult
- type ResolveStatus
- type SendMediaRequest
- type SendMode
- type SendResult
- type SendStatus
- type SendTextRequest
- type SessionPersister
Constants ¶
const ( SystemEventStatusMin int32 = 200 SystemEventStatusMax int32 = 279 )
SystemEventStatusMin and SystemEventStatusMax bound the in-thread system event band. Values 200-279 are stored with kind='system' and carry delivery_state='received' for schema uniformity (spec section 4.4).
const AlertTypeCount = 28
AlertTypeCount is the number of values gmproto.AlertType declares at the pin. The fixture-validation job asserts it is still 28.
const DeviceName = "Agent GM"
DeviceName is what a paired device is called, before the version.
const EventBufferSize = 1024
EventBufferSize is the capacity of the channel Events() returns. The libgm callback must not block -- libgm calls it synchronously from the long-poll loop -- so the adapter does a non-blocking send onto a channel of this capacity and increments dropped_events on overflow (spec section 2.3).
const GaiaCaptureURL = "https://accounts.google.com/AccountChooser?continue=https://messages.google.com/web/config"
GaiaCaptureURL is upstream's own capture URL (connector/login.go:229).
const MessageDeletedStatus int32 = 300
MessageDeletedStatus is MESSAGE_DELETED, which sits outside every other range (spec section 3.7).
const PinnedUpstreamCommit = "be48a58"
PinnedUpstreamCommit is the mautrix-gmessages commit Agent GM is built against. It is a fact recorded in three places that must agree: go.mod, this constant, and spec section 3.6. The CI job `pin-consistency` fails if any one of them is edited alone.
Bumping the pin is a deliberate slice with its own live gate (spec 3.6), never a drive-by commit.
const PinnedUpstreamCommitFull = "be48a58b733825f6dfd6bb630af5f236d3bc9ae8"
PinnedUpstreamCommitFull is the same commit in full. Git cannot fetch a commit by abbreviation, so the fixture-validation job needs all forty characters; pin-consistency asserts it still begins with PinnedUpstreamCommit.
const PinnedUpstreamModule = "go.mau.fi/mautrix-gmessages"
PinnedUpstreamModule is the Go module path of the pinned dependency.
const ReasonNotSignedIn = "not_signed_in"
ReasonNotSignedIn is the details.reason that accompanies unsupported_capability when an account's credentials are dead. It is an account-level condition and is deliberately not `not_paired`, which means the server holds no accounts at all (spec sections 3.5, 7.8).
Variables ¶
var ( // ErrPhoneNotResponding mirrors libgm.ErrPhoneNotResponding // (session_handler.go:20-32). The server already accepted the request. ErrPhoneNotResponding = errors.New("phone did not respond to request") // ErrConnectionClosed mirrors libgm.ErrConnectionClosed. ErrConnectionClosed = errors.New("client disconnected before response was received") // ErrInvalidCredentials mirrors events.ErrInvalidCredentials (tachyon 16). ErrInvalidCredentials = errors.New("invalid authentication credentials") // ErrRequestedEntityNotFound mirrors events.ErrRequestedEntityNotFound // (tachyon 5). ErrRequestedEntityNotFound = errors.New("requested entity was not found") // ErrCallerNoPermission mirrors events.ErrCallerNoPermission (tachyon 7). ErrCallerNoPermission = errors.New("the caller does not have permission") // ErrNoCookies mirrors libgm.ErrNoCookies. ErrNoCookies = errors.New("gaia pairing requires cookies") // ErrNoDevicesFound mirrors libgm.ErrNoDevicesFound. ErrNoDevicesFound = errors.New("no devices found for gaia pairing") // ErrIncorrectEmoji mirrors libgm.ErrIncorrectEmoji. ErrIncorrectEmoji = errors.New("user chose incorrect emoji on phone") // ErrPairingCancelled mirrors libgm.ErrPairingCancelled. ErrPairingCancelled = errors.New("user cancelled pairing on phone") // ErrPairingTimeout mirrors libgm.ErrPairingTimeout. ErrPairingTimeout = errors.New("pairing timed out") // ErrPairingInitTimeout mirrors libgm.ErrPairingInitTimeout. ErrPairingInitTimeout = errors.New("client init timed out") // ErrHadMultipleDevices mirrors libgm.ErrHadMultipleDevices. It is only // ever wrapped inside ErrPairingInitTimeout and never has a code of its // own: Google never reports "multiple devices" as an error, the library // picks one (spec sections 3.2, 3.5). ErrHadMultipleDevices = errors.New("had multiple primary-looking devices") // ErrWrongAccount is Agent GM's own: a cookie refresh that signs in as a // different Google account is refused, changing nothing. This is stricter // than upstream on purpose (spec section 3.2). ErrWrongAccount = errors.New("cookies belong to a different Google account") // ErrNoAccountAddress is Agent GM's own: StartGaiaPairing produced an // empty or implausible AuthData.Mobile.SourceID, so no account can be // created (spec section 3.2). ErrNoAccountAddress = errors.New("pairing produced no Google account address") )
Sentinel errors the fake raises and the adapter classifies. They mirror the library's own sentinels one for one so that a table test can enumerate spec section 3.5 without a phone.
var GaiaCookieDomains = map[string]string{
"OSID": "messages.google.com",
"SID": ".google.com",
"HSID": ".google.com",
"SSID": ".google.com",
"APISID": ".google.com",
"SAPISID": ".google.com",
"__Secure-1PSIDTS": ".google.com",
}
GaiaCookieDomains gives each cookie the host it is scoped to. OSID is host-scoped to messages.google.com, so a capture that reads only .google.com silently returns an unusable set -- the most common way the gaia flow fails (spec section 3.2).
var GaiaHTTPOnlyCookies = []string{"SID", "HSID", "SSID", "OSID", "__Secure-1PSIDTS"}
GaiaHTTPOnlyCookies names the five of the seven that are httpOnly, so document.cookie and any injected-JS approach cannot reach them. This is why spec section 11.4 reads the browser's own cookie store over CDP.
var GaiaOptionalCookies = []string{"__Secure-1PSIDTS"}
GaiaOptionalCookies is the one cookie that is read but not required.
var GaiaRequiredCookies = []string{"SID", "HSID", "OSID", "SSID", "APISID", "SAPISID"}
GaiaRequiredCookies is the exact required set (connector/login.go:200-210). SAPISID alone is not sufficient; its separate job is computing the SAPISIDHASH Authorization header.
var SendRetryBackoff = []time.Duration{3 * time.Second, 8 * time.Second, 20 * time.Second}
SendRetryBackoff is connector.sendRetryBackoff at the pin.
Functions ¶
func AccountAddressFromPairing ¶
AccountAddressFromPairing normalises and validates the address a pairing produced. It is the single place the refusal lives, so a test can reach it without a real libgm.Client.
An empty or implausible address is refused BEFORE anything is created: acct_ is UUIDv5(ns, "account", address), so AccountID("") is a perfectly valid UUID and two different degenerate pairings would derive the same acct_ ID and adopt each other's conversations and messages (spec 3.2, 4.1). Agent GM never falls back to a generated ID.
func CanonicalEmoji ¶
CanonicalEmoji is the value every surface uses and every react_ ID is derived from (spec section 4.1). For one of the eleven it is EmojiType.Unicode(); for CUSTOM it is the caller's own unicode after NFC normalisation; for a type with no unicode of its own it is nil.
func DecryptLegacyWebPush ¶ added in v1.2.0
DecryptLegacyWebPush supports the aesgcm draft format still emitted by Google Messages. Its salt and ECDH key are in HTTP headers, and padding is a two-byte length prefix rather than the RFC 8291 trailing delimiter.
func DecryptWebPush ¶ added in v1.2.0
DecryptWebPush validates one RFC 8291 aes128gcm record. Web Push requires a single record, unlike general RFC 8188 HTTP content encoding.
func DeviceIdentity ¶
func DeviceIdentity() string
DeviceIdentity reports what the phone will be told, for `GET /v1/health` and for the tests that assert the pairing request really carries it.
func DeviceOSName ¶
DeviceOSName renders the paired-devices entry for a build version: "Agent GM 1.0" for `1.0.0`, `1.0.3` or `1.0.0-slice2`.
Only major.minor, because the string is frozen at pairing time and never updated afterwards (see SetDeviceIdentity). A patch number or a prerelease tag on a label that outlives the build it names would be a claim about a running version that stopped being true at the next deploy; major.minor is the coarsest thing still worth telling the owner apart. A version this cannot read at all degrades to the bare name rather than to a label with a blank or a `%!s` in it, because the owner reads this on their phone and cannot be shown a rendering bug.
func GenerateTmpID ¶
func GenerateTmpID() string
GenerateTmpID mints the transaction ID for one send attempt.
It is a bare UUID, not Agent GM's op_-prefixed operation ID (D22). Upstream generates it with util.GenerateTmpID() (util/func.go:9-12), whose comment is "Matches what the native app does", and the phone echoes the value back on the remote message. Sending a non-UUID transaction ID would diverge from every other client of this protocol for no benefit.
func IgnoredStatuses ¶
IgnoredStatuses returns the two ignore sets, for the fixture-validation job.
func IsFatalListenError ¶
IsFatalListenError implements the matching rule of spec section 3.4: the library makes an HTTP 401 or 403 on the listen request fatal, and renders both as "http %d while polling". Matching on the string sends a 403 into the retry branch, where it loops forever on dead credentials, so the match is on the error value.
func IsOutgoingLadderState ¶
func IsOutgoingLadderState(s DeliveryState) bool
IsOutgoingLadderState reports whether a state participates in the outgoing transition ladder of spec section 4.4.
func IsSystemEventStatus ¶
IsSystemEventStatus reports whether a raw status is an in-thread system event (spec section 3.7: values 200-279).
func MappedStatusValues ¶
func MappedStatusValues() []int32
MappedStatusValues returns every raw status the mapping names, excluding the 200-279 band. Tests use it to assert the mapping and the pinned proto enumerate the same set.
func MissingRequiredCookies ¶
MissingRequiredCookies names the required cookies a capture did not produce, so the caller can say which ones and which domain each comes from.
func PlausibleAccountAddress ¶
PlausibleAccountAddress reports whether a value is a syntactically plausible Google account address.
func RawEmojiType ¶
RawEmojiType converts back to the proto value.
func SetDeviceIdentity ¶
func SetDeviceIdentity(version string)
SetDeviceIdentity names this build in the phone's paired-devices list. It is called before any pairing can start.
**It changes nothing about an account that is already paired.** The name is sent once, inside the pairing request, and Google keeps what it was told; there is no later message that renames a device. An account paired before this existed goes on saying `libgm` until the owner re-pairs it, and `docs/pairing.md` says so, because an owner who reads a release note and then looks at their phone would otherwise think it had not worked.
Once, because `util.BrowserDetailsMessage` is a package-level pointer shared by every client in the process, and a second caller with a different version would race the first. The value does not vary within a build.
func ShouldIgnoreStatus ¶
ShouldIgnoreStatus is spec section 5.3 step 1: the ingest path drops these and counts them. The set is carried over verbatim from upstream, and the fixture-validation job asserts the two still agree.
func SupportedMIME ¶
SupportedMIME reports whether Google Messages will carry this content type, using upstream's own table and upstream's own fallback.
`libgm.UploadMedia` looks a MIME type up in `MimeToMediaType` and, on a miss, retries with the part before the slash -- so `image/heif` is accepted as `image` even though the table names no such row (`pkg/libgm/media.go` at the pin). Agent GM validates at **reservation** time with exactly that rule, so a reservation that would be accepted here and refused at send time -- or the reverse -- is impossible. An unsupported type is `media_unsupported_type` (415) and reserves nothing (spec section 10.2).
This function exists because nothing above `internal/gm` may import `libgm` (spec section 2.3): the media layer asks Agent GM's own vocabulary, and the answer still comes from upstream's table rather than from a copy of it that could drift at the next pin bump.
func SupportedMIMETypes ¶
func SupportedMIMETypes() []string
SupportedMIMETypes returns every MIME string upstream's table names, sorted by nothing in particular. It is here so a test can walk the real table rather than a handful of samples, and so `media_unsupported_type`'s message can say how many types are supported without hard-coding a number that would go stale at the next pin bump.
func TransitionAllowed ¶
func TransitionAllowed(from, to DeliveryState) bool
TransitionAllowed reports whether an outgoing message may move from `from` to `to`, per the transition table of spec section 4.4:
sending -> sent -> delivered -> read sending|sent -> failed sending -> canceled any -> deleted unknown -> any
A forward skip is accepted; a backward move is refused.
Types ¶
type AlertType ¶
type AlertType int32
AlertType is gmproto.AlertType, which has 28 values (0-27) at this pin.
const ( AlertUnknown AlertType = 0 AlertBrowserInactive AlertType = 1 AlertBrowserActive AlertType = 2 AlertMobileDataConnection AlertType = 3 AlertMobileWifiConnection AlertType = 4 AlertMobileBatteryLow AlertType = 5 AlertMobileBatteryRestored AlertType = 6 AlertBrowserInactiveFromTimeout AlertType = 7 AlertBrowserInactiveFromInactivity AlertType = 8 AlertRCSConnection AlertType = 9 AlertObserverRegistered AlertType = 10 AlertMobileDatabaseSyncing AlertType = 11 AlertMobileDatabaseSyncComplete AlertType = 12 AlertMobileDatabaseSyncStarted AlertType = 13 )
func (AlertType) MarksSessionIdle ¶
MarksSessionIdle reports whether an alert means this session went idle.
func (AlertType) PausesBackfill ¶
PausesBackfill reports whether an alert means the phone is resyncing its own database, so this account's backfill must be deferred.
func (AlertType) TriggersResync ¶
TriggersResync reports whether an alert means "our session changed, resync". Only BROWSER_ACTIVE does; it does not mean another device took over (spec section 3.4).
type Attachment ¶
type Attachment struct {
PartIndex int
ActionMessageID string
MediaID string
ThumbnailMediaID string
DecryptionKey []byte
Filename string
MimeType string
MediaFormat string
SizeBytes int64
Width int64
Height int64
}
Attachment is one media part of a message.
type Backend ¶
type Backend interface {
// lifecycle
Connect(ctx context.Context) error
Disconnect()
IsConnected() bool
IsLoggedIn() bool
SessionID() string // libgm CurrentSessionID; drives the resync check
// health -- everything GET /v1/health reports about Google
FetchConfig(ctx context.Context) (ConfigInfo, error)
CompiledConfigVersion() ConfigVersion
IsDefaultSMSApp(ctx context.Context) (bool, error)
// pairing
StartGooglePairing(ctx context.Context, cookies map[string]string, deviceIndex int, emoji func(string)) (PairedDevice, error)
RefreshGoogleCookies(ctx context.Context, cookies map[string]string) error
// reads
ListConversations(ctx context.Context, folder Folder, count int) ([]Conversation, error)
GetConversation(ctx context.Context, convID string) (*Conversation, error)
GetConversationType(ctx context.Context, convID string) (ConversationType, error)
ListMessages(ctx context.Context, convID string, count int, cursor *Cursor) ([]Message, *Cursor, error)
ListContacts(ctx context.Context) ([]Contact, error)
ListTopContacts(ctx context.Context) ([]Contact, error)
ContactAvatars(ctx context.Context, ids []string) (map[string][]byte, error)
DownloadAvatar(ctx context.Context, url string) ([]byte, error)
// writes
ResolveConversation(ctx context.Context, numbers []string, groupName string) (ResolveResult, error)
SendText(ctx context.Context, req SendTextRequest) (SendResult, error)
SendMedia(ctx context.Context, req SendMediaRequest) (SendResult, error)
React(ctx context.Context, msgID string, emoji string, action ReactionAction) error
DeleteMessage(ctx context.Context, msgID string) error
MarkRead(ctx context.Context, convID, msgID string) error
SetTyping(ctx context.Context, convID string) error
UpdateConversation(ctx context.Context, convID string, ch ConversationChange) error
DeleteConversation(ctx context.Context, convID, phone string) error
// media
Upload(ctx context.Context, data []byte, filename, mime string) (MediaRef, error)
Download(ctx context.Context, mediaID string, key []byte) ([]byte, error)
RequestFullSizeImage(ctx context.Context, msgID, actionMsgID string) error
// events
Events() <-chan Event
}
Backend is the whole of Agent GM's dependency on Google Messages (spec section 2.3). There are exactly two implementations and only ever two: the libgm adapter in this package, and the fake in internal/gm/fake. A second production implementation is forbidden by non-goal N3 -- this interface exists for testability, not for extensibility (D10).
One instance is one account.
type Code ¶
type Code string
Code is an Agent GM error code from spec section 7.2. The gm package produces the code and the HTTP status the REST layer will later render, so the mapping of spec section 3.5 is testable with no REST surface at all (spec section 16, Slice 1 acceptance test 5).
const ( CodePhoneNotResponding Code = "phone_not_responding" CodeDisconnected Code = "disconnected" CodeUnsupportedCapability Code = "unsupported_capability" CodeGooglePermissionDenied Code = "google_permission_denied" CodeGoogleError Code = "google_error" CodeGoogleHTTPError Code = "google_http_error" CodeGoogleUndocumentedState Code = "google_undocumented_status" CodeNotDefaultSMSApp Code = "not_default_sms_app" CodePairingNoCookies Code = "pairing_no_cookies" CodePairingNoDevices Code = "pairing_no_devices" CodePairingWrongEmoji Code = "pairing_wrong_emoji" CodePairingCancelled Code = "pairing_cancelled" CodePairingTimeout Code = "pairing_timeout" CodePairingInitTimeout Code = "pairing_init_timeout" CodePairingNoAccount Code = "pairing_no_account" CodePairingWrongAccount Code = "pairing_wrong_account" CodeInternalError Code = "internal_error" )
type ConfigInfo ¶
type ConfigInfo struct {
Live ConfigVersion
// DeviceEmail is Config.DeviceInfo.Email. Upstream compares it against
// AuthData.Mobile.SourceID to decide whether a re-authentication is the
// same account (connector/login.go:267-270).
DeviceEmail string
// SessionID is Config.DeviceInfo.DeviceID, which FetchConfig parses into
// AuthData.SessionID (client.go:389).
DeviceID string
}
ConfigInfo is what a live FetchConfig round trip tells us.
type ConfigVersion ¶
type ConfigVersion struct {
Year int32 `json:"year"`
Month int32 `json:"month"`
Day int32 `json:"day"`
V1 int32 `json:"v1"`
V2 int32 `json:"v2"`
}
ConfigVersion is Google Messages for web's client version, as carried by util.ConfigMessage (compiled in) and by the live Config document.
func CompiledConfigVersion ¶
func CompiledConfigVersion() ConfigVersion
CompiledConfigVersion is exposed as a package function too, because GET /v1/health carries the compiled value once at the top level, without an account (spec section 3.7).
func (ConfigVersion) SameDate ¶
func (c ConfigVersion) SameDate(other ConfigVersion) bool
SameDate reports whether two versions agree in year, month and day. Spec section 3.7: the config_version_stale detection rule is the date diff alone.
func (ConfigVersion) String ¶
func (c ConfigVersion) String() string
type Contact ¶
type Contact struct {
SourceID string
ContactID string
DisplayName string
PhoneE164 string
FormattedNumber string
IsTop bool
}
Contact is somebody in the phone's contact list.
type Conversation ¶
type Conversation struct {
SourceID string
Name string
IsGroup bool
Type ConversationType
SendModeRaw SendMode
Folder Folder
Unread bool
Pinned bool
ReadOnly bool
// Deleted is Google's own delete-for-me: ConversationStatus DELETED or
// TRASH_FOLDER. It is the only delete Agent GM has (non-goal N6).
Deleted bool
DefaultOutgoingID string
LatestMessageID string
LastActivity time.Time
GroupAvatarURL string
// SIMPayload is opaque: it is carried back verbatim on sends and typing
// notifications and is never interpreted.
SIMPayload []byte
Participants []Participant
}
Conversation is one Google Messages thread.
func ConvertConversation ¶
func ConvertConversation(c *gmproto.Conversation) Conversation
ConvertConversation turns a gmproto.Conversation into Agent GM's own. Conversation.LatestMessage is deliberately dropped: it is large and duplicative, and upstream itself clones and nils it before logging (connector/startchat.go:227-230). It goes through the message ingest path or nowhere (spec section 3.7).
func (Conversation) ForceRCSEligible ¶
func (c Conversation) ForceRCSEligible() bool
ForceRCSEligible is spec section 4.6: true exactly when the conversation is RCS and its send mode is SEND_MODE_AUTO.
type ConversationChange ¶
ConversationChange carries the optional folder, pinned and unread fields of PATCH /v1/conversations/{id} (spec section 2.3).
type ConversationType ¶
type ConversationType string
ConversationType is the derived public value of spec section 4.6: sms_mms for ConversationType_SMS(1), rcs for RCS(2), unknown for 0.
const ( ConversationTypeUnknown ConversationType = "unknown" ConversationTypeSMSMMS ConversationType = "sms_mms" ConversationTypeRCS ConversationType = "rcs" )
type Cursor ¶
Cursor is gmproto.Cursor: {lastItemID, lastItemTimestamp}. The timestamp is Google's own microseconds and is carried back verbatim.
type DeliveryState ¶
type DeliveryState string
DeliveryState is Agent GM's own closed vocabulary for what Google said about a message (spec section 4.4). The mapping below covers every value declared in MessageStatusType at the pin. A value the mapping does not name fails the table test in section 13.2 rather than falling silently to unknown.
const ( DeliveryStateSending DeliveryState = "sending" DeliveryStateSent DeliveryState = "sent" DeliveryStateDelivered DeliveryState = "delivered" DeliveryStateRead DeliveryState = "read" DeliveryStateFailed DeliveryState = "failed" DeliveryStateCanceled DeliveryState = "canceled" DeliveryStateDeleted DeliveryState = "deleted" DeliveryStateReceived DeliveryState = "received" DeliveryStateDownloading DeliveryState = "downloading" DeliveryStateDownloadFailed DeliveryState = "download_failed" DeliveryStateUnknown DeliveryState = "unknown" )
func DeliveryStateFor ¶
func DeliveryStateFor(raw int32) (DeliveryState, bool)
DeliveryStateFor maps a raw MessageStatusType onto Agent GM's vocabulary. The second return value is false when the value is not mapped -- which for a value declared at the pin is a bug the section 13.2 table test catches, and for a value added upstream after the pin means `unknown`.
type DroppedEventCounter ¶
DroppedEventCounter is implemented by backends that can report how many events overflowed the channel, for GET /v1/health.
type EmojiType ¶
type EmojiType string
EmojiType is Google's closed 14-value reaction enum (spec section 3.7, gmproto/conversations.proto:70-85). Reactions are not free-form emoji: anything outside the eleven canonical values becomes CUSTOM and may not render on the recipient's phone.
const ( EmojiTypeUnspecified EmojiType = "unspecified" EmojiTypeLike EmojiType = "like" EmojiTypeLove EmojiType = "love" EmojiTypeLaugh EmojiType = "laugh" EmojiTypeSurprised EmojiType = "surprised" EmojiTypeSad EmojiType = "sad" EmojiTypeAngry EmojiType = "angry" EmojiTypeDislike EmojiType = "dislike" EmojiTypeCustom EmojiType = "custom" EmojiTypeQuestioning EmojiType = "questioning" EmojiTypeCryingFace EmojiType = "crying_face" EmojiTypePoutingFace EmojiType = "pouting_face" EmojiTypeRedHeart EmojiType = "red_heart" EmojiTypeEmotify EmojiType = "emotify" )
func CanonicaliseEmojiInput ¶
CanonicaliseEmojiInput takes whatever a caller sent and returns the type and the canonical emoji Agent GM will use. Every inbound emoji goes through here before a react_ ID is derived or a path segment is matched.
func EmojiTypeForRaw ¶
EmojiTypeForRaw converts a raw proto value. An unrecognised value is reported as CUSTOM, which is what upstream's UnicodeToEmojiType default arm does for an unrecognised emoji.
func EmojiTypeForUnicode ¶
EmojiTypeForUnicode mirrors gmproto.UnicodeToEmojiType: anything that is not one of the eleven canonical code points is CUSTOM. The input is NFC normalised first so that the two spellings of a heart cannot produce two different reactions (spec section 3.7 consequence 1).
type Error ¶
type Error struct {
Code Code
// HTTPStatus is the status spec section 7.2 assigns to Code.
HTTPStatus int
Message string
// Reason populates details.reason. It is set only for
// unsupported_capability.
Reason string
// SignsOutAccount is true when this error means the account's credentials
// are dead and its state must become signed_out (spec section 4.7).
SignsOutAccount bool
// Retryable marks an error the caller may reasonably retry.
Retryable bool
// KeepsOperationPending is true only for phone_not_responding: the server
// accepted the request and the phone may still act on it, so the
// operation stays pending and must never be reported as failed (D5).
KeepsOperationPending bool
// Details carries the extra fields spec section 3.5 names, such as
// multiple_devices on pairing_init_timeout, or the numeric type and
// message on google_error. details.google_type and details.status are
// the ONLY raw Google integers permitted here: every other raw Google
// value is admin-only (spec sections 4.1, 7.2).
Details map[string]any
// GoogleStatusRaw is the numeric Google status behind this error, or 0.
// It is written to operations.google_status_raw and served only on
// GET /v1/admin/diagnostics -- never in a public error envelope, which
// is why it is a field of its own and not an entry in Details.
GoogleStatusRaw int32
// Err is the underlying library error.
Err error
}
Error is the gm layer's classified error.
func Classify ¶
Classify maps a library error onto the Agent GM code and status that spec section 7.2 will render. Every row of spec section 3.5 is covered; the table test in errors_test.go enumerates the list rather than sampling it.
func NotDefaultSMSApp ¶
func NotDefaultSMSApp() *Error
NotDefaultSMSApp is FAILURE_4, which is not retried: upstream renders it as the user-facing string "Google Messages is not your default SMS app" (connector/errors.go:41-42).
It carries no details: the raw Google status is admin-only (spec sections 4.1, 6.5), and `details.google_type` and `details.status` are the only raw Google integers permitted on a public surface (spec section 7.2). The value is recorded on the operation row as google_status_raw and served on GET /v1/admin/diagnostics, which is where a reviewer reads it.
func ResolveCreateRCSTwice ¶
func ResolveCreateRCSTwice() *Error
ResolveCreateRCSTwice is a second CREATE_RCS from GetOrCreateConversation. The adapter has already done the one documented thing about the first (retry once with CreateRCSGroup=true, exactly as upstream does), so a second is a refusal Agent GM reports rather than a hint it acts on (spec section 3.7).
func SendFailure ¶
func SendFailure(status SendStatus) *Error
SendFailure classifies a non-SUCCESS SendMessageResponse status.
The raw status travels on the Error's GoogleStatusRaw field, not in Details: it is written to operations.google_status_raw and served only on GET /v1/admin/diagnostics. What reaches the public envelope is details.google_type, which section 7.2 names as one of exactly two raw Google integers a caller may see.
func UndocumentedResolveStatus ¶
func UndocumentedResolveStatus(status ResolveStatus) *Error
UndocumentedResolveStatus builds the google_undocumented_status error for a GetOrCreateConversation status the proto has no name for. Agent GM reports the bare integer and claims nothing about what it means (spec section 3.7).
func WithConfigVersionContext ¶
func WithConfigVersionContext(e *Error, compiled, live ConfigVersion) *Error
WithConfigVersionContext adds the compiled and live ConfigVersions to an error as CONTEXT, without changing what the error IS.
The version difference is useful when a conversation-creating call fails and useless as a diagnosis on its own: Google ships a new ConfigVersion on its own schedule, so a mismatch is the normal resting state between pin bumps (D32). Replacing the real status with `config_version_stale` -- which this code used to do -- told an operator to bump the pin for a failure that had nothing to do with the pin, and threw away the status that did.
type Event ¶
type Event any
Event is one thing that happened on one account's stream. Every event below is one account's event, on one account's client; there is one handler per account and no event from one account ever changes another's state (spec section 3.4).
type EventAccountChange ¶
EventAccountChange means the phone's active Google account changed. IsFake=true means it was synthesised at startup from EncryptedData2, not a real change (event_handler.go:105-118).
type EventAuthTokenRefreshed ¶
type EventAuthTokenRefreshed struct{}
EventAuthTokenRefreshed means the tachyon token rotated; persist AuthData.
type EventClientReady ¶
type EventClientReady struct {
SessionID string
Conversations []Conversation
}
EventClientReady means the long poll is established, with the initial conversation list.
type EventConversation ¶
type EventConversation struct {
Conversation Conversation
}
EventConversation carries one conversation upsert.
type EventGaiaLoggedOut ¶
type EventGaiaLoggedOut struct{}
EventGaiaLoggedOut means the Google cookies are dead: set this account signed_out and offer a cookie refresh. It deletes nothing.
type EventHackySetActiveMayFail ¶
type EventHackySetActiveMayFail struct{}
EventHackySetActiveMayFail means the skip count was non-zero at connect; re-issue SetActiveSession after a delay.
type EventListenFatalError ¶
EventListenFatalError means the poll cannot continue. CredentialsDead is the result of the matching rule in spec section 3.4 -- an HTTP 401 or 403, or ErrInvalidCredentials -- computed once at this boundary so that no consumer is tempted to match on the error string.
type EventListenRecovered ¶
type EventListenRecovered struct{}
EventListenRecovered means the poll is back.
type EventListenTemporaryError ¶
type EventListenTemporaryError struct{ Err error }
EventListenTemporaryError means the poll dropped and will retry.
type EventMessage ¶
EventMessage carries one message from the live stream. IsOld means it was replayed from the server's backlog after a reconnect.
type EventNoDataReceived ¶
type EventNoDataReceived struct{}
EventNoDataReceived means nothing arrived for dataReceiveCheckInterval (default 2h55m). It triggers a reconciliation sweep.
type EventPairSuccessful ¶
type EventPairSuccessful struct {
PhoneID string
}
EventPairSuccessful means pairing completed. events.PairSuccessful.QRData is always nil on the gaia path -- DoGaiaPairing constructs the event with PhoneID and nothing else (pair_google.go:310) -- so the field is not carried here at all and cannot be dereferenced.
type EventPhoneNotResponding ¶
type EventPhoneNotResponding struct{}
EventPhoneNotResponding is emitted on the first unanswered ping, or after alertTimeoutCount (default 4) missed pings in a row. It is not a single fixed threshold (spec section 3.4).
type EventPhoneRespondingAgain ¶
type EventPhoneRespondingAgain struct{}
EventPhoneRespondingAgain means the phone came back.
type EventPingFailed ¶
EventPingFailed means a ditto ping failed. EntityNotFound means the phone no longer knows this pairing. Upstream deliberately ignores the first failure, so ErrorCount matters.
type EventRevokePairData ¶
type EventRevokePairData struct{}
EventRevokePairData means the phone revoked this pairing: set this account signed_out. It deletes nothing (spec section 4.7).
type EventSettings ¶
EventSettings carries the phone's settings: SIM list, RCS enablement and the default-SMS-app flag.
type EventTyping ¶
EventTyping is ephemeral: it is surfaced as peer_typing_until and never persisted.
type EventUnknown ¶
type EventUnknown struct {
TypeName string
}
EventUnknown is anything the catalogue above does not name. It is logged at debug and dropped, and it increments the account's unknown_events counter.
type EventUserAlert ¶
type EventUserAlert struct {
Alert AlertType
}
EventUserAlert carries one gmproto.UserAlertEvent.
type Folder ¶
type Folder int32
Folder mirrors gmproto.ListConversationsRequest_Folder: UNKNOWN=0, INBOX=1, ARCHIVE=2, SPAM_BLOCKED=5 (spec section 3.1).
type HTTPError ¶
HTTPError is the gm-level rendering of events.HTTPError: a transport-level failure carrying the action and the status code.
type LibGM ¶
type LibGM struct {
// contains filtered or unexported fields
}
LibGM is the real Google Messages backend: one instance is one account.
It is the only place in Agent GM that imports libgm or gmproto (spec section 2.3).
func New ¶
New builds a backend for a brand-new pairing.
Agent GM always passes pk == nil to libgm.NewClient: there is no web push (spec section 3.1). PairCallback is deliberately left nil -- it fires only from the withdrawn QR flow's completePairing and is unreachable on the gaia path, where DoGaiaPairing emits PairSuccessful directly.
func NewFromSession ¶
NewFromSession rebuilds a backend from a persisted session, which is libgm.AuthData marshalled to JSON (spec section 3.3).
func (*LibGM) AccountAddress ¶
func (*LibGM) BackgroundRequest ¶ added in v1.2.0
BackgroundRequest executes a diagnostic batch with a bounded passive listener.
func (*LibGM) CompiledConfigVersion ¶
func (b *LibGM) CompiledConfigVersion() ConfigVersion
CompiledConfigVersion is util.ConfigMessage, a property of this binary.
func (*LibGM) Connect ¶
Connect refreshes the tachyon token synchronously so bad credentials surface immediately, then starts long polling. It is the only connect path Agent GM uses; ConnectBackground is deliberately not called.
func (*LibGM) ContactAvatars ¶
func (*LibGM) DeleteConversation ¶
func (*LibGM) DeleteMessage ¶
func (*LibGM) Disconnect ¶
func (b *LibGM) Disconnect()
func (*LibGM) DownloadAvatar ¶
func (*LibGM) DroppedEvents ¶
func (*LibGM) EnablePush ¶ added in v1.2.0
func (b *LibGM) EnablePush(endpointBase string, saved []byte, save, saveAuth func([]byte) error) error
EnablePush configures push before Connect. It never connects on its own.
func (*LibGM) FetchConfig ¶
func (b *LibGM) FetchConfig(ctx context.Context) (ConfigInfo, error)
func (*LibGM) GetConversation ¶
func (*LibGM) GetConversationType ¶
func (*LibGM) HandlePush ¶ added in v1.2.0
HandlePush verifies encryption before durably accepting a wake. The random capability is never logged. It does not forward any decrypted payload.
func (*LibGM) IsConnected ¶
IsConnected is advisory only: upstream notes it is imprecise during reconnects (spec section 3.1).
func (*LibGM) IsLoggedIn ¶
IsLoggedIn is the authoritative "are we paired" check.
func (*LibGM) ListConversations ¶
func (*LibGM) ListMessages ¶
func (*LibGM) ListTopContacts ¶
func (*LibGM) LoadSession ¶
func (*LibGM) MarshalSession ¶
func (*LibGM) PollBackgroundOnce ¶ added in v1.2.0
PollBackgroundOnce is an experimental diagnostic, not the server lifecycle. Call only on an otherwise idle client. Upstream drains pending events and closes after a short idle period, without running postConnect (which claims the active session). The local library patch disables its recovery pinger; physical notification behavior must still be checked on the phone. Events must be consumed and the refreshed session saved by the caller after it returns.
Upstream does not accept a context for this operation. Run the diagnostic in a separate process when a hard deadline is needed.
func (*LibGM) RefreshGoogleCookies ¶
RefreshGoogleCookies re-authenticates an existing pairing with fresh cookies, exactly as connector/login.go:246-289 does: it is accepted only when the tachyon token and the pairing ID are both present, the account is verified the same by comparing Config.DeviceInfo.Email against AuthData.Mobile.SourceID, and on any failure the previous cookies are restored so a failed refresh changes nothing.
A refresh against a different Google account is refused with pairing_wrong_account. That is stricter than upstream on purpose: upstream falls through to a fresh pairing, which here would silently create a second account (spec section 3.2, declared deviation).
func (*LibGM) RegisterWebPush ¶ added in v1.2.0
RegisterWebPush registers an externally reachable encrypted push endpoint.
func (*LibGM) RequestFullSizeImage ¶
func (*LibGM) ResolveConversation ¶
func (*LibGM) SaveSession ¶ added in v1.2.0
SaveSession keeps the snapshot and its disk write in the same passive-client critical section, so a timer cannot overwrite a newer batch's credentials.
func (*LibGM) SendMedia ¶
func (b *LibGM) SendMedia(ctx context.Context, req SendMediaRequest) (SendResult, error)
func (*LibGM) SendText ¶
func (b *LibGM) SendText(ctx context.Context, req SendTextRequest) (SendResult, error)
func (*LibGM) SessionDirty ¶
SessionDirty compares the in-memory AuthData against what was last marshalled. Cookies mutate in place via UpdateCookiesFromResponse with no event (client.go:73-81), so the 5-minute timer of spec section 3.3 is the only thing that captures a rotation, and this is how it decides.
func (*LibGM) SetPushLogger ¶ added in v1.3.0
func (*LibGM) SetPushPairingMode ¶ added in v1.2.0
func (b *LibGM) SetPushPairingMode()
SetPushPairingMode prevents the upstream post-pair active reconnect. The supervisor configures the account's durable push endpoint after pairing.
func (*LibGM) Shred ¶
func (b *LibGM) Shred()
Shred zeroes the in-memory AuthData so the Google account cookies are gone from the process as well as from disk (spec section 4.7).
func (*LibGM) StartGooglePairing ¶
func (b *LibGM) StartGooglePairing(ctx context.Context, cookies map[string]string, deviceIndex int, emoji func(string)) (PairedDevice, error)
StartGooglePairing runs the gaia flow start to finish through DoGaiaPairing, which is the call Agent GM uses (spec section 3.1). Agent GM does not reconnect on its own afterwards: DoGaiaPairing reconnects in its own goroutine on success (pair_google.go:311-318).
func (*LibGM) UnknownEvents ¶
func (*LibGM) UpdateConversation ¶
type MediaRef ¶
type MediaRef struct {
MediaID string
Format string
Name string
SizeBytes int64
DecryptionKey []byte
MimeType string
}
MediaRef is the result of an upload: gmproto.MediaContent, in Agent GM's vocabulary. SizeBytes is the plaintext size.
type Message ¶
type Message struct {
SourceID string
ConversationID string
ParticipantID string
Text string
Subject string
// Timestamp is already converted from Google's microseconds. The
// conversion happens once, at this boundary (spec section 3.7).
Timestamp time.Time
TmpID string
StatusRaw int32
Kind MessageKind
DeliveryState DeliveryState
ReplyToMessageID string
IsOld bool
Attachments []Attachment
Reactions []Reaction
}
Message is one message in a conversation.
func ConvertMessage ¶
ConvertMessage turns a gmproto.Message into Agent GM's own. Text parts are joined with a newline in part order, exactly as the content hash of spec section 5.3 expects.
type MessageKind ¶
type MessageKind string
MessageKind separates ordinary messages from Google's own in-thread system events (MessageStatusType 200-279). "tombstone" is Matrix vocabulary and does not appear on any surface (spec section 1.3 N6).
const ( MessageKindMessage MessageKind = "message" MessageKindSystem MessageKind = "system" )
func KindForStatus ¶
func KindForStatus(raw int32) MessageKind
KindForStatus classifies a raw MessageStatusType into a message kind.
type PairedDevice ¶
type PairedDevice struct {
// PhoneID is FinishGaiaPairing's "<mobile sourceID>/<destRegDevice int>".
PhoneID string
// AccountAddress is AuthData.Mobile.SourceID, lowercased: the Google
// account address, and the only stable account identifier at this pin
// (spec section 3.2, D28).
AccountAddress string
// DestRegUUID and DeviceLastSeen record which phone was chosen, so
// "which phone did we pair?" is answerable afterwards (spec section 3.2).
DestRegUUID string
DeviceLastSeen time.Time
DeviceCount int
DeviceIndex int
}
PairedDevice is what a completed gaia pairing produced.
type Participant ¶
type Participant struct {
SourceID string
ContactID string
DisplayName string
FirstName string
PhoneE164 string
FormattedNumber string
IdentifierType string
IsMe bool
IsVisible bool
}
Participant is one person in a conversation.
type PushSubscription ¶ added in v1.2.0
type PushSubscription struct {
Private []byte `json:"private"`
Auth []byte `json:"auth"`
Token string `json:"token"`
Generation uint64 `json:"generation"`
Delivered uint64 `json:"delivered"`
LastReceivedMS int64 `json:"last_received_ms,omitempty"`
LastCompletedMS int64 `json:"last_completed_ms,omitempty"`
}
PushSubscription is stored in an encrypted sidecar next to AuthData. Generation/Delivered make acknowledged HTTP wakes survive a process crash.
type Reaction ¶
Reaction is one reaction entry on a message. Emoji is nil when the EmojiType has no unicode of its own (EMOTIFY, and any unrecognised type): spec section 3.7 requires {"emoji": null, "type": ...} rather than the upstream behaviour of silently skipping it.
type ReactionAction ¶
type ReactionAction int32
ReactionAction mirrors gmproto.SendReactionRequest_Action.
const ( ReactionActionUnspecified ReactionAction = 0 ReactionActionAdd ReactionAction = 1 ReactionActionRemove ReactionAction = 2 ReactionActionSwitch ReactionAction = 3 )
type RequestError ¶
RequestError is the gm-level rendering of events.RequestError: any non-OK tachyon response that is not one of the three sentinels.
func (RequestError) Error ¶
func (r RequestError) Error() string
type ResolveResult ¶
type ResolveResult struct {
Conversation *Conversation
Status ResolveStatus
}
ResolveResult carries the conversation and the raw status, so core can distinguish SUCCESS, CREATE_RCS and an unnamed value without reaching past the Backend interface (spec section 2.3).
type ResolveStatus ¶
type ResolveStatus int32
ResolveStatus mirrors gmproto.GetOrCreateConversationResponse_Status, which declares exactly UNKNOWN=0, SUCCESS=1, CREATE_RCS=3 at this pin. Any other value is unnamed and Agent GM never invents a name for one.
const ( ResolveStatusUnknown ResolveStatus = 0 ResolveStatusSuccess ResolveStatus = 1 ResolveStatusCreateRCS ResolveStatus = 3 )
type SendMediaRequest ¶
type SendMediaRequest struct {
ConversationID string
ParticipantID string
Media MediaRef
Caption string
TmpID string
ReplyToMessageID string
ForceRCS bool
SIMPayload []byte
}
SendMediaRequest is a media send. The caption, when present, is appended as a second MessageInfo entry carrying MessageContent, exactly as upstream does.
type SendMode ¶
type SendMode string
SendMode is gmproto.ConversationSendMode. It is internal and is never served on a public surface (spec section 4.6); it exists so that capabilities.force_rcs can be derived.
type SendResult ¶
type SendResult struct {
Status SendStatus
// GoogleAccountSwitch is non-empty when the phone switched Google
// accounts underneath us (spec section 3.7).
GoogleAccountSwitch string
}
SendResult is the phone's own answer to a send.
type SendStatus ¶
type SendStatus int32
SendStatus mirrors gmproto.SendMessageResponse_Status.
const ( SendStatusUnknown SendStatus = 0 SendStatusSuccess SendStatus = 1 SendStatusFailure2 SendStatus = 2 SendStatusFailure3 SendStatus = 3 SendStatusFailure4 SendStatus = 4 )
func (SendStatus) IsTransient ¶
func (s SendStatus) IsTransient() bool
IsTransient mirrors connector.isTransientSendFailure: only FAILURE_2 and FAILURE_3 are retried, on SendRetryBackoff.
func (SendStatus) String ¶
func (s SendStatus) String() string
type SendTextRequest ¶
type SendTextRequest struct {
ConversationID string
ParticipantID string
Text string
// TmpID is a bare UUID minted per send attempt (D22). It is set on all
// three of SendMessageRequest.TmpID, MessagePayload.TmpID and
// MessagePayload.TmpID2.
TmpID string
ReplyToMessageID string
ForceRCS bool
SIMPayload []byte
}
SendTextRequest is one text send attempt.
type SessionPersister ¶
type SessionPersister interface {
// MarshalSession returns the current session bytes.
MarshalSession() ([]byte, error)
// LoadSession replaces the in-memory session.
LoadSession(data []byte) error
// SessionDirty reports whether the in-memory session differs from what
// was last marshalled. Cookies mutate in place with no event, so the
// 5-minute persistence timer of spec section 3.3 needs this.
SessionDirty() bool
// AccountAddress is AuthData.Mobile.SourceID, lowercased.
AccountAddress() string
// Shred zeroes the in-memory session, so the Google account cookies are
// gone from the process (spec section 4.7).
Shred()
}
SessionPersister is the part of a Backend that Agent GM stores. The session is libgm.AuthData marshalled to JSON (spec section 3.3); the adapter exposes it as opaque bytes so that nothing above internal/gm has to know the shape.