Fix some things

This commit is contained in:
Tulir Asokan 2024-02-23 19:26:49 +02:00
parent 49a3fd983f
commit f99201f8e6
3 changed files with 13 additions and 17 deletions

View file

@ -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,7 +325,6 @@ 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,
})
if err != nil {
@ -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,
})
}

View file

@ -176,7 +176,6 @@ type SendMessageParams struct {
DontEncrypt bool
MessageType gmproto.MessageType
DestRegistrationIDs []string
NoPingOnTimeout bool
}
@ -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

View file

@ -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) {