2023-06-30 11:05:33 +00:00
|
|
|
package libgm
|
2023-06-30 09:54:08 +00:00
|
|
|
|
|
|
|
import (
|
2023-06-30 10:48:52 +00:00
|
|
|
"encoding/base64"
|
|
|
|
|
2023-07-15 13:25:54 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
2023-06-30 09:54:08 +00:00
|
|
|
"go.mau.fi/mautrix-gmessages/libgm/binary"
|
|
|
|
"go.mau.fi/mautrix-gmessages/libgm/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (p *Pairer) GenerateQRCodeData() (string, error) {
|
2023-07-15 13:25:54 +00:00
|
|
|
urlData := &binary.URLData{
|
2023-07-09 11:16:52 +00:00
|
|
|
PairingKey: p.pairingKey,
|
|
|
|
AESKey: p.client.authData.Cryptor.AESKey,
|
|
|
|
HMACKey: p.client.authData.Cryptor.HMACKey,
|
2023-06-30 09:54:08 +00:00
|
|
|
}
|
2023-07-15 13:25:54 +00:00
|
|
|
encodedURLData, err := proto.Marshal(urlData)
|
2023-06-30 09:54:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
2023-07-15 13:25:54 +00:00
|
|
|
cData := base64.StdEncoding.EncodeToString(encodedURLData)
|
2023-06-30 13:31:35 +00:00
|
|
|
return util.QRCodeURLBase + cData, nil
|
2023-06-30 09:54:08 +00:00
|
|
|
}
|