diff --git a/libgm/pair_google.go b/libgm/pair_google.go index a51f2ad..121092a 100644 --- a/libgm/pair_google.go +++ b/libgm/pair_google.go @@ -94,13 +94,12 @@ func (c *Client) signInGaiaGetToken() (*gmproto.SignInGaiaResponse, error) { type PairingSession struct { UUID uuid.UUID Start time.Time - DestRegID uuid.UUID PairingKeyDSA *ecdsa.PrivateKey InitPayload []byte NextKey []byte } -func NewPairingSession(destRegID uuid.UUID) PairingSession { +func NewPairingSession() PairingSession { ec, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { panic(err) @@ -108,7 +107,6 @@ func NewPairingSession(destRegID uuid.UUID) PairingSession { return PairingSession{ UUID: uuid.New(), Start: time.Now(), - DestRegID: destRegID, PairingKeyDSA: ec, } } @@ -255,7 +253,7 @@ func (c *Client) DoGaiaPairing(emojiCallback func(string)) error { // TODO multiple devices? var destRegID string for _, dev := range sigResp.GetDeviceData().GetUnknownItems2() { - if dev.GetDestOrSourceUUID() != sigResp.GetMaybeBrowserUUID() { + if dev.GetUnknownInt4() == 1 { destRegID = dev.GetDestOrSourceUUID() break } @@ -269,7 +267,7 @@ func (c *Client) DoGaiaPairing(emojiCallback func(string)) error { } c.AuthData.DestRegID = destRegUUID go c.doLongPoll(false) - ps := NewPairingSession(destRegUUID) + ps := NewPairingSession() clientInit, clientFinish, err := ps.PreparePayloads() if err != nil { return fmt.Errorf("failed to prepare pairing payloads: %w", err) @@ -327,8 +325,7 @@ func (c *Client) sendGaiaPairingMessage(sess PairingSession, action gmproto.Acti CustomTTL: (300 * time.Second).Microseconds(), MessageType: gmproto.MessageType_GAIA_2, - DestRegistrationIDs: []string{sess.DestRegID.String()}, - NoPingOnTimeout: true, + NoPingOnTimeout: true, }) if err != nil { return nil, err @@ -347,7 +344,6 @@ func (c *Client) UnpairGaia() error { Data: &gmproto.RevokeGaiaPairingRequest{ PairingAttemptID: c.AuthData.PairingID.String(), }, - DestRegistrationIDs: []string{c.AuthData.DestRegID.String()}, - NoPingOnTimeout: true, + NoPingOnTimeout: true, }) } diff --git a/libgm/session_handler.go b/libgm/session_handler.go index d38721c..1d7fed0 100644 --- a/libgm/session_handler.go +++ b/libgm/session_handler.go @@ -176,8 +176,7 @@ type SendMessageParams struct { DontEncrypt bool MessageType gmproto.MessageType - DestRegistrationIDs []string - NoPingOnTimeout bool + NoPingOnTimeout bool } func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.Message, error) { @@ -192,9 +191,6 @@ func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.M if params.MessageType == 0 { params.MessageType = gmproto.MessageType_BUGLE_MESSAGE } - if params.DestRegistrationIDs == nil { - params.DestRegistrationIDs = make([]string, 0) - } message := &gmproto.OutgoingRPCMessage{ Mobile: s.client.AuthData.Mobile, @@ -211,7 +207,10 @@ func (s *SessionHandler) buildMessage(params SendMessageParams) (string, proto.M TachyonAuthToken: s.client.AuthData.TachyonAuthToken, ConfigVersion: util.ConfigMessage, }, - DestRegistrationIDs: params.DestRegistrationIDs, + DestRegistrationIDs: []string{}, + } + if s.client.AuthData != nil && s.client.AuthData.DestRegID != uuid.Nil { + message.DestRegistrationIDs = append(message.DestRegistrationIDs, s.client.AuthData.DestRegID.String()) } if params.CustomTTL != 0 { message.TTL = params.CustomTTL diff --git a/provisioning.go b/provisioning.go index 6165be2..d32b722 100644 --- a/provisioning.go +++ b/provisioning.go @@ -316,7 +316,8 @@ type ReqGoogleLoginStart struct { } type RespGoogleLoginStart struct { - Emoji string + Status string `json:"status"` + Emoji string `json:"emoji"` } func (prov *ProvisioningAPI) GoogleLoginStart(w http.ResponseWriter, r *http.Request) { @@ -346,7 +347,7 @@ func (prov *ProvisioningAPI) GoogleLoginStart(w http.ResponseWriter, r *http.Req }) return } - jsonResponse(w, http.StatusOK, &RespGoogleLoginStart{Emoji: emoji}) + jsonResponse(w, http.StatusOK, &RespGoogleLoginStart{Status: "emoji", Emoji: emoji}) } func (prov *ProvisioningAPI) GoogleLoginWait(w http.ResponseWriter, r *http.Request) {