From df3fdc26a01a20c3568b824f4f15f9b56a2f3db3 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 2 Mar 2019 13:04:28 +0100 Subject: Use whatsapp forks (#750) --- .../github.com/matterbridge/go-whatsapp/.gitignore | 2 + vendor/github.com/matterbridge/go-whatsapp/LICENSE | 21 + .../github.com/matterbridge/go-whatsapp/README.md | 104 + .../matterbridge/go-whatsapp/binary/decoder.go | 388 ++ .../matterbridge/go-whatsapp/binary/encoder.go | 351 ++ .../matterbridge/go-whatsapp/binary/node.go | 103 + .../go-whatsapp/binary/proto/def.pb.go | 3800 ++++++++++++++++++++ .../go-whatsapp/binary/proto/def.proto | 417 +++ .../matterbridge/go-whatsapp/binary/token/token.go | 78 + vendor/github.com/matterbridge/go-whatsapp/conn.go | 389 ++ .../github.com/matterbridge/go-whatsapp/contact.go | 234 ++ .../matterbridge/go-whatsapp/crypto/cbc/cbc.go | 101 + .../go-whatsapp/crypto/curve25519/curve.go | 44 + .../matterbridge/go-whatsapp/crypto/hkdf/hkdf.go | 52 + vendor/github.com/matterbridge/go-whatsapp/go.mod | 8 + vendor/github.com/matterbridge/go-whatsapp/go.sum | 7 + .../github.com/matterbridge/go-whatsapp/group.go | 65 + .../github.com/matterbridge/go-whatsapp/handler.go | 169 + .../github.com/matterbridge/go-whatsapp/media.go | 199 + .../github.com/matterbridge/go-whatsapp/message.go | 444 +++ .../github.com/matterbridge/go-whatsapp/session.go | 389 ++ .../github.com/matterbridge/go-whatsapp/store.go | 45 + .../matterbridge/mautrix-whatsapp/LICENSE | 661 ++++ .../mautrix-whatsapp/whatsapp-ext/chat.go | 147 + .../mautrix-whatsapp/whatsapp-ext/cmd.go | 59 + .../mautrix-whatsapp/whatsapp-ext/conn.go | 60 + .../mautrix-whatsapp/whatsapp-ext/jsonmessage.go | 102 + .../mautrix-whatsapp/whatsapp-ext/msginfo.go | 90 + .../mautrix-whatsapp/whatsapp-ext/presence.go | 67 + .../mautrix-whatsapp/whatsapp-ext/props.go | 68 + .../mautrix-whatsapp/whatsapp-ext/stream.go | 63 + .../mautrix-whatsapp/whatsapp-ext/whatsapp.go | 132 + 32 files changed, 8859 insertions(+) create mode 100644 vendor/github.com/matterbridge/go-whatsapp/.gitignore create mode 100644 vendor/github.com/matterbridge/go-whatsapp/LICENSE create mode 100644 vendor/github.com/matterbridge/go-whatsapp/README.md create mode 100644 vendor/github.com/matterbridge/go-whatsapp/binary/decoder.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/binary/encoder.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/binary/node.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.pb.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.proto create mode 100644 vendor/github.com/matterbridge/go-whatsapp/binary/token/token.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/conn.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/contact.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/crypto/cbc/cbc.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/crypto/curve25519/curve.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/crypto/hkdf/hkdf.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/go.mod create mode 100644 vendor/github.com/matterbridge/go-whatsapp/go.sum create mode 100644 vendor/github.com/matterbridge/go-whatsapp/group.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/handler.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/media.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/message.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/session.go create mode 100644 vendor/github.com/matterbridge/go-whatsapp/store.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/LICENSE create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/chat.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/cmd.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/conn.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/jsonmessage.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/msginfo.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/presence.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/props.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/stream.go create mode 100644 vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/whatsapp.go (limited to 'vendor/github.com/matterbridge') diff --git a/vendor/github.com/matterbridge/go-whatsapp/.gitignore b/vendor/github.com/matterbridge/go-whatsapp/.gitignore new file mode 100644 index 00000000..5c2e8752 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/.gitignore @@ -0,0 +1,2 @@ +.idea/ +docs/ diff --git a/vendor/github.com/matterbridge/go-whatsapp/LICENSE b/vendor/github.com/matterbridge/go-whatsapp/LICENSE new file mode 100644 index 00000000..b442934b --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/matterbridge/go-whatsapp/README.md b/vendor/github.com/matterbridge/go-whatsapp/README.md new file mode 100644 index 00000000..9a5216e7 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/README.md @@ -0,0 +1,104 @@ +# go-whatsapp +Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of the [sigalor/whatsapp-web-reveng](https://github.com/sigalor/whatsapp-web-reveng) project. The official WhatsApp Business API was released in August 2018. You can check it out [here](https://www.whatsapp.com/business/api). + +## Installation +```sh +go get github.com/rhymen/go-whatsapp +``` + +## Usage +### Creating a connection +```go +import ( + whatsapp "github.com/Rhymen/go-whatsapp" +) + +wac, err := whatsapp.NewConn(20 * time.Second) +``` +The duration passed to the NewConn function is used to timeout login requests. If you have a bad internet connection use a higher timeout value. This function only creates a websocket connection, it does not handle authentication. + +### Login +```go +qrChan := make(chan string) +go func() { + fmt.Printf("qr code: %v\n", <-qrChan) + //show qr code or save it somewhere to scan +} +sess, err := wac.Login(qrChan) +``` +The authentication process requires you to scan the qr code, that is send through the channel, with the device you are using whatsapp on. The session struct that is returned can be saved and used to restore the login without scanning the qr code again. The qr code has a ttl of 20 seconds and the login function throws a timeout err if the time has passed or any other request fails. + +### Restore +```go +newSess, err := wac.RestoreSession(sess) +``` +The restore function needs a valid session and returns the new session that was created. + +### Add message handlers +```go +type myHandler struct{} + +func (myHandler) HandleError(err error) { + fmt.Fprintf(os.Stderr, "%v", err) +} + +func (myHandler) HandleTextMessage(message whatsapp.TextMessage) { + fmt.Println(message) +} + +func (myHandler) HandleImageMessage(message whatsapp.ImageMessage) { + fmt.Println(message) +} + +func (myHandler) HandleVideoMessage(message whatsapp.VideoMessage) { + fmt.Println(message) +} + +func (myHandler) HandleJsonMessage(message string) { + fmt.Println(message) +} + +wac.AddHandler(myHandler{}) +``` +The message handlers are all optional, you don't need to implement anything but the error handler to implement the interface. The ImageMessage and VideoMessage provide a Download function to get the media data. + +### Sending text messages +```go +text := whatsapp.TextMessage{ + Info: whatsapp.MessageInfo{ + RemoteJid: "0123456789@s.whatsapp.net", + }, + Text: "Hello Whatsapp", +} + +err := wac.Send(text) +``` +The message will be send over the websocket. The attributes seen above are the required ones. All other relevant attributes (id, timestamp, fromMe, status) are set if they are missing in the struct. For the time being we only support text messages, but other types are planned for the near future. + +## Legal +This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by WhatsApp or any of its +affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk. + +## License + +The MIT License (MIT) + +Copyright (c) 2018 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/matterbridge/go-whatsapp/binary/decoder.go b/vendor/github.com/matterbridge/go-whatsapp/binary/decoder.go new file mode 100644 index 00000000..2ca828d0 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/binary/decoder.go @@ -0,0 +1,388 @@ +package binary + +import ( + "fmt" + "github.com/matterbridge/go-whatsapp/binary/token" + "io" + "strconv" +) + +type binaryDecoder struct { + data []byte + index int +} + +func NewDecoder(data []byte) *binaryDecoder { + return &binaryDecoder{data, 0} +} + +func (r *binaryDecoder) checkEOS(length int) error { + if r.index+length > len(r.data) { + return io.EOF + } + + return nil +} + +func (r *binaryDecoder) readByte() (byte, error) { + if err := r.checkEOS(1); err != nil { + return 0, err + } + + b := r.data[r.index] + r.index++ + + return b, nil +} + +func (r *binaryDecoder) readIntN(n int, littleEndian bool) (int, error) { + if err := r.checkEOS(n); err != nil { + return 0, err + } + + var ret int + + for i := 0; i < n; i++ { + var curShift int + if littleEndian { + curShift = i + } else { + curShift = n - i - 1 + } + ret |= int(r.data[r.index+i]) << uint(curShift*8) + } + + r.index += n + return ret, nil +} + +func (r *binaryDecoder) readInt8(littleEndian bool) (int, error) { + return r.readIntN(1, littleEndian) +} + +func (r *binaryDecoder) readInt16(littleEndian bool) (int, error) { + return r.readIntN(2, littleEndian) +} + +func (r *binaryDecoder) readInt20() (int, error) { + if err := r.checkEOS(3); err != nil { + return 0, err + } + + ret := ((int(r.data[r.index]) & 15) << 16) + (int(r.data[r.index+1]) << 8) + int(r.data[r.index+2]) + r.index += 3 + return ret, nil +} + +func (r *binaryDecoder) readInt32(littleEndian bool) (int, error) { + return r.readIntN(4, littleEndian) +} + +func (r *binaryDecoder) readInt64(littleEndian bool) (int, error) { + return r.readIntN(8, littleEndian) +} + +func (r *binaryDecoder) readPacked8(tag int) (string, error) { + startByte, err := r.readByte() + if err != nil { + return "", err + } + + ret := "" + + for i := 0; i < int(startByte&127); i++ { + currByte, err := r.readByte() + if err != nil { + return "", err + } + + lower, err := unpackByte(tag, currByte&0xF0>>4) + if err != nil { + return "", err + } + + upper, err := unpackByte(tag, currByte&0x0F) + if err != nil { + return "", err + } + + ret += lower + upper + } + + if startByte>>7 != 0 { + ret = ret[:len(ret)-1] + } + return ret, nil +} + +func unpackByte(tag int, value byte) (string, error) { + switch tag { + case token.NIBBLE_8: + return unpackNibble(value) + case token.HEX_8: + return unpackHex(value) + default: + return "", fmt.Errorf("unpackByte with unknown tag %d", tag) + } +} + +func unpackNibble(value byte) (string, error) { + switch { + case value < 0 || value > 15: + return "", fmt.Errorf("unpackNibble with value %d", value) + case value == 10: + return "-", nil + case value == 11: + return ".", nil + case value == 15: + return "\x00", nil + default: + return strconv.Itoa(int(value)), nil + } +} + +func unpackHex(value byte) (string, error) { + switch { + case value < 0 || value > 15: + return "", fmt.Errorf("unpackHex with value %d", value) + case value < 10: + return strconv.Itoa(int(value)), nil + default: + return string('A' + value - 10), nil + } +} + +func (r *binaryDecoder) readListSize(tag int) (int, error) { + switch tag { + case token.LIST_EMPTY: + return 0, nil + case token.LIST_8: + return r.readInt8(false) + case token.LIST_16: + return r.readInt16(false) + default: + return 0, fmt.Errorf("readListSize with unknown tag %d at position %d", tag, r.index) + } +} + +func (r *binaryDecoder) readString(tag int) (string, error) { + switch { + case tag >= 3 && tag <= len(token.SingleByteTokens): + tok, err := token.GetSingleToken(tag) + if err != nil { + return "", err + } + + if tok == "s.whatsapp.net" { + tok = "c.us" + } + + return tok, nil + case tag == token.DICTIONARY_0 || tag == token.DICTIONARY_1 || tag == token.DICTIONARY_2 || tag == token.DICTIONARY_3: + i, err := r.readInt8(false) + if err != nil { + return "", err + } + + return token.GetDoubleToken(tag-token.DICTIONARY_0, i) + case tag == token.LIST_EMPTY: + return "", nil + case tag == token.BINARY_8: + length, err := r.readInt8(false) + if err != nil { + return "", err + } + + return r.readStringFromChars(length) + case tag == token.BINARY_20: + length, err := r.readInt20() + if err != nil { + return "", err + } + + return r.readStringFromChars(length) + case tag == token.BINARY_32: + length, err := r.readInt32(false) + if err != nil { + return "", err + } + + return r.readStringFromChars(length) + case tag == token.JID_PAIR: + b, err := r.readByte() + if err != nil { + return "", err + } + i, err := r.readString(int(b)) + if err != nil { + return "", err + } + + b, err = r.readByte() + if err != nil { + return "", err + } + j, err := r.readString(int(b)) + if err != nil { + return "", err + } + + if i == "" || j == "" { + return "", fmt.Errorf("invalid jid pair: %s - %s", i, j) + } + + return i + "@" + j, nil + case tag == token.NIBBLE_8 || tag == token.HEX_8: + return r.readPacked8(tag) + default: + return "", fmt.Errorf("invalid string with tag %d", tag) + } +} + +func (r *binaryDecoder) readStringFromChars(length int) (string, error) { + if err := r.checkEOS(length); err != nil { + return "", err + } + + ret := r.data[r.index : r.index+length] + r.index += length + + return string(ret), nil +} + +func (r *binaryDecoder) readAttributes(n int) (map[string]string, error) { + if n == 0 { + return nil, nil + } + + ret := make(map[string]string) + for i := 0; i < n; i++ { + idx, err := r.readInt8(false) + if err != nil { + return nil, err + } + + index, err := r.readString(idx) + if err != nil { + return nil, err + } + + idx, err = r.readInt8(false) + if err != nil { + return nil, err + } + + ret[index], err = r.readString(idx) + if err != nil { + return nil, err + } + } + + return ret, nil +} + +func (r *binaryDecoder) readList(tag int) ([]Node, error) { + size, err := r.readListSize(tag) + if err != nil { + return nil, err + } + + ret := make([]Node, size) + for i := 0; i < size; i++ { + n, err := r.ReadNode() + + if err != nil { + return nil, err + } + + ret[i] = *n + } + + return ret, nil +} + +func (r *binaryDecoder) ReadNode() (*Node, error) { + ret := &Node{} + + size, err := r.readInt8(false) + if err != nil { + return nil, err + } + listSize, err := r.readListSize(size) + if err != nil { + return nil, err + } + + descrTag, err := r.readInt8(false) + if descrTag == token.STREAM_END { + return nil, fmt.Errorf("unexpected stream end") + } + ret.Description, err = r.readString(descrTag) + if err != nil { + return nil, err + } + if listSize == 0 || ret.Description == "" { + return nil, fmt.Errorf("invalid Node") + } + + ret.Attributes, err = r.readAttributes((listSize - 1) >> 1) + if err != nil { + return nil, err + } + + if listSize%2 == 1 { + return ret, nil + } + + tag, err := r.readInt8(false) + if err != nil { + return nil, err + } + + switch tag { + case token.LIST_EMPTY, token.LIST_8, token.LIST_16: + ret.Content, err = r.readList(tag) + case token.BINARY_8: + size, err = r.readInt8(false) + if err != nil { + return nil, err + } + + ret.Content, err = r.readBytes(size) + case token.BINARY_20: + size, err = r.readInt20() + if err != nil { + return nil, err + } + + ret.Content, err = r.readBytes(size) + case token.BINARY_32: + size, err = r.readInt32(false) + if err != nil { + return nil, err + } + + ret.Content, err = r.readBytes(size) + default: + ret.Content, err = r.readString(tag) + } + + if err != nil { + return nil, err + } + return ret, nil +} + +func (r *binaryDecoder) readBytes(n int) ([]byte, error) { + ret := make([]byte, n) + var err error + + for i := range ret { + ret[i], err = r.readByte() + if err != nil { + return nil, err + } + } + + return ret, nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/binary/encoder.go b/vendor/github.com/matterbridge/go-whatsapp/binary/encoder.go new file mode 100644 index 00000000..a8ff1c75 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/binary/encoder.go @@ -0,0 +1,351 @@ +package binary + +import ( + "fmt" + "github.com/matterbridge/go-whatsapp/binary/token" + "math" + "strconv" + "strings" +) + +type binaryEncoder struct { + data []byte +} + +func NewEncoder() *binaryEncoder { + return &binaryEncoder{make([]byte, 0)} +} + +func (w *binaryEncoder) GetData() []byte { + return w.data +} + +func (w *binaryEncoder) pushByte(b byte) { + w.data = append(w.data, b) +} + +func (w *binaryEncoder) pushBytes(bytes []byte) { + w.data = append(w.data, bytes...) +} + +func (w *binaryEncoder) pushIntN(value, n int, littleEndian bool) { + for i := 0; i < n; i++ { + var curShift int + if littleEndian { + curShift = i + } else { + curShift = n - i - 1 + } + w.pushByte(byte((value >> uint(curShift*8)) & 0xFF)) + } +} + +func (w *binaryEncoder) pushInt20(value int) { + w.pushBytes([]byte{byte((value >> 16) & 0x0F), byte((value >> 8) & 0xFF), byte(value & 0xFF)}) +} + +func (w *binaryEncoder) pushInt8(value int) { + w.pushIntN(value, 1, false) +} + +func (w *binaryEncoder) pushInt16(value int) { + w.pushIntN(value, 2, false) +} + +func (w *binaryEncoder) pushInt32(value int) { + w.pushIntN(value, 4, false) +} + +func (w *binaryEncoder) pushInt64(value int) { + w.pushIntN(value, 8, false) +} + +func (w *binaryEncoder) pushString(value string) { + w.pushBytes([]byte(value)) +} + +func (w *binaryEncoder) writeByteLength(length int) error { + if length > math.MaxInt32 { + return fmt.Errorf("length is too large: %d", length) + } else if length >= (1 << 20) { + w.pushByte(token.BINARY_32) + w.pushInt32(length) + } else if length >= 256 { + w.pushByte(token.BINARY_20) + w.pushInt20(length) + } else { + w.pushByte(token.BINARY_8) + w.pushInt8(length) + } + + return nil +} + +func (w *binaryEncoder) WriteNode(n Node) error { + numAttributes := 0 + if n.Attributes != nil { + numAttributes = len(n.Attributes) + } + + hasContent := 0 + if n.Content != nil { + hasContent = 1 + } + + w.writeListStart(2*numAttributes + 1 + hasContent) + if err := w.writeString(n.Description, false); err != nil { + return err + } + + if err := w.writeAttributes(n.Attributes); err != nil { + return err + } + + if err := w.writeChildren(n.Content); err != nil { + return err + } + + return nil +} + +func (w *binaryEncoder) writeString(tok string, i bool) error { + if !i && tok == "c.us" { + if err := w.writeToken(token.IndexOfSingleToken("s.whatsapp.net")); err != nil { + return err + } + return nil + } + + tokenIndex := token.IndexOfSingleToken(tok) + if tokenIndex == -1 { + jidSepIndex := strings.Index(tok, "@") + if jidSepIndex < 1 { + w.writeStringRaw(tok) + } else { + w.writeJid(tok[:jidSepIndex], tok[jidSepIndex+1:]) + } + } else { + if tokenIndex < token.SINGLE_BYTE_MAX { + if err := w.writeToken(tokenIndex); err != nil { + return err + } + } else { + singleByteOverflow := tokenIndex - token.SINGLE_BYTE_MAX + dictionaryIndex := singleByteOverflow >> 8 + if dictionaryIndex < 0 || dictionaryIndex > 3 { + return fmt.Errorf("double byte dictionary token out of range: %v", tok) + } + if err := w.writeToken(token.DICTIONARY_0 + dictionaryIndex); err != nil { + return err + } + if err := w.writeToken(singleByteOverflow % 256); err != nil { + return err + } + } + } + + return nil +} + +func (w *binaryEncoder) writeStringRaw(value string) error { + if err := w.writeByteLength(len(value)); err != nil { + return err + } + + w.pushString(value) + + return nil +} + +func (w *binaryEncoder) writeJid(jidLeft, jidRight string) error { + w.pushByte(token.JID_PAIR) + + if jidLeft != "" { + if err := w.writePackedBytes(jidLeft); err != nil { + return err + } + } else { + if err := w.writeToken(token.LIST_EMPTY); err != nil { + return err + } + } + + if err := w.writeString(jidRight, false); err != nil { + return err + } + + return nil +} + +func (w *binaryEncoder) writeToken(tok int) error { + if tok < len(token.SingleByteTokens) { + w.pushByte(byte(tok)) + } else if tok <= 500 { + return fmt.Errorf("invalid token: %d", tok) + } + + return nil +} + +func (w *binaryEncoder) writeAttributes(attributes map[string]string) error { + if attributes == nil { + return nil + } + + for key, val := range attributes { + if val == "" { + continue + } + + if err := w.writeString(key, false); err != nil { + return err + } + + if err := w.writeString(val, false); err != nil { + return err + } + } + + return nil +} + +func (w *binaryEncoder) writeChildren(children interface{}) error { + if children == nil { + return nil + } + + switch childs := children.(type) { + case string: + if err := w.writeString(childs, true); err != nil { + return err + } + case []byte: + if err := w.writeByteLength(len(childs)); err != nil { + return err + } + + w.pushBytes(childs) + case []Node: + w.writeListStart(len(childs)) + for _, n := range childs { + if err := w.WriteNode(n); err != nil { + return err + } + } + default: + return fmt.Errorf("cannot write child of type: %T", children) + } + + return nil +} + +func (w *binaryEncoder) writeListStart(listSize int) { + if listSize == 0 { + w.pushByte(byte(token.LIST_EMPTY)) + } else if listSize < 256 { + w.pushByte(byte(token.LIST_8)) + w.pushInt8(listSize) + } else { + w.pushByte(byte(token.LIST_16)) + w.pushInt16(listSize) + } +} + +func (w *binaryEncoder) writePackedBytes(value string) error { + if err := w.writePackedBytesImpl(value, token.NIBBLE_8); err != nil { + if err := w.writePackedBytesImpl(value, token.HEX_8); err != nil { + return err + } + } + + return nil +} + +func (w *binaryEncoder) writePackedBytesImpl(value string, dataType int) error { + numBytes := len(value) + if numBytes > token.PACKED_MAX { + return fmt.Errorf("too many bytes to pack: %d", numBytes) + } + + w.pushByte(byte(dataType)) + + x := 0 + if numBytes%2 != 0 { + x = 128 + } + w.pushByte(byte(x | int(math.Ceil(float64(numBytes)/2.0)))) + for i, l := 0, numBytes/2; i < l; i++ { + b, err := w.packBytePair(dataType, value[2*i:2*i+1], value[2*i+1:2*i+2]) + if err != nil { + return err + } + + w.pushByte(byte(b)) + } + + if (numBytes % 2) != 0 { + b, err := w.packBytePair(dataType, value[numBytes-1:], "\x00") + if err != nil { + return err + } + + w.pushByte(byte(b)) + } + + return nil +} + +func (w *binaryEncoder) packBytePair(packType int, part1, part2 string) (int, error) { + if packType == token.NIBBLE_8 { + n1, err := packNibble(part1) + if err != nil { + return 0, err + } + + n2, err := packNibble(part2) + if err != nil { + return 0, err + } + + return (n1 << 4) | n2, nil + } else if packType == token.HEX_8 { + n1, err := packHex(part1) + if err != nil { + return 0, err + } + + n2, err := packHex(part2) + if err != nil { + return 0, err + } + + return (n1 << 4) | n2, nil + } else { + return 0, fmt.Errorf("invalid pack type (%d) for byte pair: %s / %s", packType, part1, part2) + } +} + +func packNibble(value string) (int, error) { + if value >= "0" && value <= "9" { + return strconv.Atoi(value) + } else if value == "-" { + return 10, nil + } else if value == "." { + return 11, nil + } else if value == "\x00" { + return 15, nil + } + + return 0, fmt.Errorf("invalid string to pack as nibble: %v", value) +} + +func packHex(value string) (int, error) { + if (value >= "0" && value <= "9") || (value >= "A" && value <= "F") || (value >= "a" && value <= "f") { + d, err := strconv.ParseInt(value, 16, 0) + return int(d), err + } else if value == "\x00" { + return 15, nil + } + + return 0, fmt.Errorf("invalid string to pack as hex: %v", value) +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/binary/node.go b/vendor/github.com/matterbridge/go-whatsapp/binary/node.go new file mode 100644 index 00000000..0e55656e --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/binary/node.go @@ -0,0 +1,103 @@ +package binary + +import ( + "fmt" + pb "github.com/matterbridge/go-whatsapp/binary/proto" + "github.com/golang/protobuf/proto" +) + +type Node struct { + Description string + Attributes map[string]string + Content interface{} +} + +func Marshal(n Node) ([]byte, error) { + if n.Attributes != nil && n.Content != nil { + a, err := marshalMessageArray(n.Content.([]interface{})) + if err != nil { + return nil, err + } + n.Content = a + } + + w := NewEncoder() + if err := w.WriteNode(n); err != nil { + return nil, err + } + + return w.GetData(), nil +} + +func marshalMessageArray(messages []interface{}) ([]Node, error) { + ret := make([]Node, len(messages)) + + for i, m := range messages { + if wmi, ok := m.(*pb.WebMessageInfo); ok { + b, err := marshalWebMessageInfo(wmi) + if err != nil { + return nil, nil + } + ret[i] = Node{"message", nil, b} + } else { + ret[i], ok = m.(Node) + if !ok { + return nil, fmt.Errorf("invalid Node") + } + } + } + + return ret, nil +} + +func marshalWebMessageInfo(p *pb.WebMessageInfo) ([]byte, error) { + b, err := proto.Marshal(p) + if err != nil { + return nil, err + } + return b, nil +} + +func Unmarshal(data []byte) (*Node, error) { + r := NewDecoder(data) + n, err := r.ReadNode() + if err != nil { + return nil, err + } + + if n != nil && n.Attributes != nil && n.Content != nil { + n.Content, err = unmarshalMessageArray(n.Content.([]Node)) + if err != nil { + return nil, err + } + } + + return n, nil +} + +func unmarshalMessageArray(messages []Node) ([]interface{}, error) { + ret := make([]interface{}, len(messages)) + + for i, msg := range messages { + if msg.Description == "message" { + info, err := unmarshalWebMessageInfo(msg.Content.([]byte)) + if err != nil { + return nil, err + } + ret[i] = info + } else { + ret[i] = msg + } + } + + return ret, nil +} + +func unmarshalWebMessageInfo(msg []byte) (*pb.WebMessageInfo, error) { + message := &pb.WebMessageInfo{} + err := proto.Unmarshal(msg, message) + if err != nil { + return nil, err + } + return message, nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.pb.go b/vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.pb.go new file mode 100644 index 00000000..71d9923f --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.pb.go @@ -0,0 +1,3800 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: def.proto + +package proto + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type ExtendedTextMessage_FONTTYPE int32 + +const ( + ExtendedTextMessage_SANS_SERIF ExtendedTextMessage_FONTTYPE = 0 + ExtendedTextMessage_SERIF ExtendedTextMessage_FONTTYPE = 1 + ExtendedTextMessage_NORICAN_REGULAR ExtendedTextMessage_FONTTYPE = 2 + ExtendedTextMessage_BRYNDAN_WRITE ExtendedTextMessage_FONTTYPE = 3 + ExtendedTextMessage_BEBASNEUE_REGULAR ExtendedTextMessage_FONTTYPE = 4 + ExtendedTextMessage_OSWALD_HEAVY ExtendedTextMessage_FONTTYPE = 5 +) + +var ExtendedTextMessage_FONTTYPE_name = map[int32]string{ + 0: "SANS_SERIF", + 1: "SERIF", + 2: "NORICAN_REGULAR", + 3: "BRYNDAN_WRITE", + 4: "BEBASNEUE_REGULAR", + 5: "OSWALD_HEAVY", +} +var ExtendedTextMessage_FONTTYPE_value = map[string]int32{ + "SANS_SERIF": 0, + "SERIF": 1, + "NORICAN_REGULAR": 2, + "BRYNDAN_WRITE": 3, + "BEBASNEUE_REGULAR": 4, + "OSWALD_HEAVY": 5, +} + +func (x ExtendedTextMessage_FONTTYPE) Enum() *ExtendedTextMessage_FONTTYPE { + p := new(ExtendedTextMessage_FONTTYPE) + *p = x + return p +} +func (x ExtendedTextMessage_FONTTYPE) String() string { + return proto.EnumName(ExtendedTextMessage_FONTTYPE_name, int32(x)) +} +func (x *ExtendedTextMessage_FONTTYPE) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ExtendedTextMessage_FONTTYPE_value, data, "ExtendedTextMessage_FONTTYPE") + if err != nil { + return err + } + *x = ExtendedTextMessage_FONTTYPE(value) + return nil +} +func (ExtendedTextMessage_FONTTYPE) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{7, 0} +} + +type VideoMessage_ATTRIBUTION int32 + +const ( + VideoMessage_NONE VideoMessage_ATTRIBUTION = 0 + VideoMessage_GIPHY VideoMessage_ATTRIBUTION = 1 + VideoMessage_TENOR VideoMessage_ATTRIBUTION = 2 +) + +var VideoMessage_ATTRIBUTION_name = map[int32]string{ + 0: "NONE", + 1: "GIPHY", + 2: "TENOR", +} +var VideoMessage_ATTRIBUTION_value = map[string]int32{ + "NONE": 0, + "GIPHY": 1, + "TENOR": 2, +} + +func (x VideoMessage_ATTRIBUTION) Enum() *VideoMessage_ATTRIBUTION { + p := new(VideoMessage_ATTRIBUTION) + *p = x + return p +} +func (x VideoMessage_ATTRIBUTION) String() string { + return proto.EnumName(VideoMessage_ATTRIBUTION_name, int32(x)) +} +func (x *VideoMessage_ATTRIBUTION) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(VideoMessage_ATTRIBUTION_value, data, "VideoMessage_ATTRIBUTION") + if err != nil { + return err + } + *x = VideoMessage_ATTRIBUTION(value) + return nil +} +func (VideoMessage_ATTRIBUTION) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{10, 0} +} + +type ProtocolMessage_TYPE int32 + +const ( + ProtocolMessage_REVOKE ProtocolMessage_TYPE = 0 +) + +var ProtocolMessage_TYPE_name = map[int32]string{ + 0: "REVOKE", +} +var ProtocolMessage_TYPE_value = map[string]int32{ + "REVOKE": 0, +} + +func (x ProtocolMessage_TYPE) Enum() *ProtocolMessage_TYPE { + p := new(ProtocolMessage_TYPE) + *p = x + return p +} +func (x ProtocolMessage_TYPE) String() string { + return proto.EnumName(ProtocolMessage_TYPE_name, int32(x)) +} +func (x *ProtocolMessage_TYPE) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ProtocolMessage_TYPE_value, data, "ProtocolMessage_TYPE") + if err != nil { + return err + } + *x = ProtocolMessage_TYPE(value) + return nil +} +func (ProtocolMessage_TYPE) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{13, 0} +} + +type HSMDateTimeComponent_DAYOFWEEKTYPE int32 + +const ( + HSMDateTimeComponent_MONDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 1 + HSMDateTimeComponent_TUESDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 2 + HSMDateTimeComponent_WEDNESDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 3 + HSMDateTimeComponent_THURSDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 4 + HSMDateTimeComponent_FRIDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 5 + HSMDateTimeComponent_SATURDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 6 + HSMDateTimeComponent_SUNDAY HSMDateTimeComponent_DAYOFWEEKTYPE = 7 +) + +var HSMDateTimeComponent_DAYOFWEEKTYPE_name = map[int32]string{ + 1: "MONDAY", + 2: "TUESDAY", + 3: "WEDNESDAY", + 4: "THURSDAY", + 5: "FRIDAY", + 6: "SATURDAY", + 7: "SUNDAY", +} +var HSMDateTimeComponent_DAYOFWEEKTYPE_value = map[string]int32{ + "MONDAY": 1, + "TUESDAY": 2, + "WEDNESDAY": 3, + "THURSDAY": 4, + "FRIDAY": 5, + "SATURDAY": 6, + "SUNDAY": 7, +} + +func (x HSMDateTimeComponent_DAYOFWEEKTYPE) Enum() *HSMDateTimeComponent_DAYOFWEEKTYPE { + p := new(HSMDateTimeComponent_DAYOFWEEKTYPE) + *p = x + return p +} +func (x HSMDateTimeComponent_DAYOFWEEKTYPE) String() string { + return proto.EnumName(HSMDateTimeComponent_DAYOFWEEKTYPE_name, int32(x)) +} +func (x *HSMDateTimeComponent_DAYOFWEEKTYPE) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(HSMDateTimeComponent_DAYOFWEEKTYPE_value, data, "HSMDateTimeComponent_DAYOFWEEKTYPE") + if err != nil { + return err + } + *x = HSMDateTimeComponent_DAYOFWEEKTYPE(value) + return nil +} +func (HSMDateTimeComponent_DAYOFWEEKTYPE) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{16, 0} +} + +type HSMDateTimeComponent_CALENDARTYPE int32 + +const ( + HSMDateTimeComponent_GREGORIAN HSMDateTimeComponent_CALENDARTYPE = 1 + HSMDateTimeComponent_SOLAR_HIJRI HSMDateTimeComponent_CALENDARTYPE = 2 +) + +var HSMDateTimeComponent_CALENDARTYPE_name = map[int32]string{ + 1: "GREGORIAN", + 2: "SOLAR_HIJRI", +} +var HSMDateTimeComponent_CALENDARTYPE_value = map[string]int32{ + "GREGORIAN": 1, + "SOLAR_HIJRI": 2, +} + +func (x HSMDateTimeComponent_CALENDARTYPE) Enum() *HSMDateTimeComponent_CALENDARTYPE { + p := new(HSMDateTimeComponent_CALENDARTYPE) + *p = x + return p +} +func (x HSMDateTimeComponent_CALENDARTYPE) String() string { + return proto.EnumName(HSMDateTimeComponent_CALENDARTYPE_name, int32(x)) +} +func (x *HSMDateTimeComponent_CALENDARTYPE) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(HSMDateTimeComponent_CALENDARTYPE_value, data, "HSMDateTimeComponent_CALENDARTYPE") + if err != nil { + return err + } + *x = HSMDateTimeComponent_CALENDARTYPE(value) + return nil +} +func (HSMDateTimeComponent_CALENDARTYPE) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{16, 1} +} + +type WebMessageInfo_STATUS int32 + +const ( + WebMessageInfo_ERROR WebMessageInfo_STATUS = 0 + WebMessageInfo_PENDING WebMessageInfo_STATUS = 1 + WebMessageInfo_SERVER_ACK WebMessageInfo_STATUS = 2 + WebMessageInfo_DELIVERY_ACK WebMessageInfo_STATUS = 3 + WebMessageInfo_READ WebMessageInfo_STATUS = 4 + WebMessageInfo_PLAYED WebMessageInfo_STATUS = 5 +) + +var WebMessageInfo_STATUS_name = map[int32]string{ + 0: "ERROR", + 1: "PENDING", + 2: "SERVER_ACK", + 3: "DELIVERY_ACK", + 4: "READ", + 5: "PLAYED", +} +var WebMessageInfo_STATUS_value = map[string]int32{ + "ERROR": 0, + "PENDING": 1, + "SERVER_ACK": 2, + "DELIVERY_ACK": 3, + "READ": 4, + "PLAYED": 5, +} + +func (x WebMessageInfo_STATUS) Enum() *WebMessageInfo_STATUS { + p := new(WebMessageInfo_STATUS) + *p = x + return p +} +func (x WebMessageInfo_STATUS) String() string { + return proto.EnumName(WebMessageInfo_STATUS_name, int32(x)) +} +func (x *WebMessageInfo_STATUS) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(WebMessageInfo_STATUS_value, data, "WebMessageInfo_STATUS") + if err != nil { + return err + } + *x = WebMessageInfo_STATUS(value) + return nil +} +func (WebMessageInfo_STATUS) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{30, 0} +} + +type WebMessageInfo_STUBTYPE int32 + +const ( + WebMessageInfo_UNKNOWN WebMessageInfo_STUBTYPE = 0 + WebMessageInfo_REVOKE WebMessageInfo_STUBTYPE = 1 + WebMessageInfo_CIPHERTEXT WebMessageInfo_STUBTYPE = 2 + WebMessageInfo_FUTUREPROOF WebMessageInfo_STUBTYPE = 3 + WebMessageInfo_NON_VERIFIED_TRANSITION WebMessageInfo_STUBTYPE = 4 + WebMessageInfo_UNVERIFIED_TRANSITION WebMessageInfo_STUBTYPE = 5 + WebMessageInfo_VERIFIED_TRANSITION WebMessageInfo_STUBTYPE = 6 + WebMessageInfo_VERIFIED_LOW_UNKNOWN WebMessageInfo_STUBTYPE = 7 + WebMessageInfo_VERIFIED_HIGH WebMessageInfo_STUBTYPE = 8 + WebMessageInfo_VERIFIED_INITIAL_UNKNOWN WebMessageInfo_STUBTYPE = 9 + WebMessageInfo_VERIFIED_INITIAL_LOW WebMessageInfo_STUBTYPE = 10 + WebMessageInfo_VERIFIED_INITIAL_HIGH WebMessageInfo_STUBTYPE = 11 + WebMessageInfo_VERIFIED_TRANSITION_ANY_TO_NONE WebMessageInfo_STUBTYPE = 12 + WebMessageInfo_VERIFIED_TRANSITION_ANY_TO_HIGH WebMessageInfo_STUBTYPE = 13 + WebMessageInfo_VERIFIED_TRANSITION_HIGH_TO_LOW WebMessageInfo_STUBTYPE = 14 + WebMessageInfo_VERIFIED_TRANSITION_HIGH_TO_UNKNOWN WebMessageInfo_STUBTYPE = 15 + WebMessageInfo_VERIFIED_TRANSITION_UNKNOWN_TO_LOW WebMessageInfo_STUBTYPE = 16 + WebMessageInfo_VERIFIED_TRANSITION_LOW_TO_UNKNOWN WebMessageInfo_STUBTYPE = 17 + WebMessageInfo_VERIFIED_TRANSITION_NONE_TO_LOW WebMessageInfo_STUBTYPE = 18 + WebMessageInfo_VERIFIED_TRANSITION_NONE_TO_UNKNOWN WebMessageInfo_STUBTYPE = 19 + WebMessageInfo_GROUP_CREATE WebMessageInfo_STUBTYPE = 20 + WebMessageInfo_GROUP_CHANGE_SUBJECT WebMessageInfo_STUBTYPE = 21 + WebMessageInfo_GROUP_CHANGE_ICON WebMessageInfo_STUBTYPE = 22 + WebMessageInfo_GROUP_CHANGE_INVITE_LINK WebMessageInfo_STUBTYPE = 23 + WebMessageInfo_GROUP_CHANGE_DESCRIPTION WebMessageInfo_STUBTYPE = 24 + WebMessageInfo_GROUP_CHANGE_RESTRICT WebMessageInfo_STUBTYPE = 25 + WebMessageInfo_GROUP_CHANGE_ANNOUNCE WebMessageInfo_STUBTYPE = 26 + WebMessageInfo_GROUP_PARTICIPANT_ADD WebMessageInfo_STUBTYPE = 27 + WebMessageInfo_GROUP_PARTICIPANT_REMOVE WebMessageInfo_STUBTYPE = 28 + WebMessageInfo_GROUP_PARTICIPANT_PROMOTE WebMessageInfo_STUBTYPE = 29 + WebMessageInfo_GROUP_PARTICIPANT_DEMOTE WebMessageInfo_STUBTYPE = 30 + WebMessageInfo_GROUP_PARTICIPANT_INVITE WebMessageInfo_STUBTYPE = 31 + WebMessageInfo_GROUP_PARTICIPANT_LEAVE WebMessageInfo_STUBTYPE = 32 + WebMessageInfo_GROUP_PARTICIPANT_CHANGE_NUMBER WebMessageInfo_STUBTYPE = 33 + WebMessageInfo_BROADCAST_CREATE WebMessageInfo_STUBTYPE = 34 + WebMessageInfo_BROADCAST_ADD WebMessageInfo_STUBTYPE = 35 + WebMessageInfo_BROADCAST_REMOVE WebMessageInfo_STUBTYPE = 36 + WebMessageInfo_GENERIC_NOTIFICATION WebMessageInfo_STUBTYPE = 37 + WebMessageInfo_E2E_IDENTITY_CHANGED WebMessageInfo_STUBTYPE = 38 + WebMessageInfo_E2E_ENCRYPTED WebMessageInfo_STUBTYPE = 39 + WebMessageInfo_CALL_MISSED_VOICE WebMessageInfo_STUBTYPE = 40 + WebMessageInfo_CALL_MISSED_VIDEO WebMessageInfo_STUBTYPE = 41 + WebMessageInfo_INDIVIDUAL_CHANGE_NUMBER WebMessageInfo_STUBTYPE = 42 + WebMessageInfo_GROUP_DELETE WebMessageInfo_STUBTYPE = 43 +) + +var WebMessageInfo_STUBTYPE_name = map[int32]string{ + 0: "UNKNOWN", + 1: "REVOKE", + 2: "CIPHERTEXT", + 3: "FUTUREPROOF", + 4: "NON_VERIFIED_TRANSITION", + 5: "UNVERIFIED_TRANSITION", + 6: "VERIFIED_TRANSITION", + 7: "VERIFIED_LOW_UNKNOWN", + 8: "VERIFIED_HIGH", + 9: "VERIFIED_INITIAL_UNKNOWN", + 10: "VERIFIED_INITIAL_LOW", + 11: "VERIFIED_INITIAL_HIGH", + 12: "VERIFIED_TRANSITION_ANY_TO_NONE", + 13: "VERIFIED_TRANSITION_ANY_TO_HIGH", + 14: "VERIFIED_TRANSITION_HIGH_TO_LOW", + 15: "VERIFIED_TRANSITION_HIGH_TO_UNKNOWN", + 16: "VERIFIED_TRANSITION_UNKNOWN_TO_LOW", + 17: "VERIFIED_TRANSITION_LOW_TO_UNKNOWN", + 18: "VERIFIED_TRANSITION_NONE_TO_LOW", + 19: "VERIFIED_TRANSITION_NONE_TO_UNKNOWN", + 20: "GROUP_CREATE", + 21: "GROUP_CHANGE_SUBJECT", + 22: "GROUP_CHANGE_ICON", + 23: "GROUP_CHANGE_INVITE_LINK", + 24: "GROUP_CHANGE_DESCRIPTION", + 25: "GROUP_CHANGE_RESTRICT", + 26: "GROUP_CHANGE_ANNOUNCE", + 27: "GROUP_PARTICIPANT_ADD", + 28: "GROUP_PARTICIPANT_REMOVE", + 29: "GROUP_PARTICIPANT_PROMOTE", + 30: "GROUP_PARTICIPANT_DEMOTE", + 31: "GROUP_PARTICIPANT_INVITE", + 32: "GROUP_PARTICIPANT_LEAVE", + 33: "GROUP_PARTICIPANT_CHANGE_NUMBER", + 34: "BROADCAST_CREATE", + 35: "BROADCAST_ADD", + 36: "BROADCAST_REMOVE", + 37: "GENERIC_NOTIFICATION", + 38: "E2E_IDENTITY_CHANGED", + 39: "E2E_ENCRYPTED", + 40: "CALL_MISSED_VOICE", + 41: "CALL_MISSED_VIDEO", + 42: "INDIVIDUAL_CHANGE_NUMBER", + 43: "GROUP_DELETE", +} +var WebMessageInfo_STUBTYPE_value = map[string]int32{ + "UNKNOWN": 0, + "REVOKE": 1, + "CIPHERTEXT": 2, + "FUTUREPROOF": 3, + "NON_VERIFIED_TRANSITION": 4, + "UNVERIFIED_TRANSITION": 5, + "VERIFIED_TRANSITION": 6, + "VERIFIED_LOW_UNKNOWN": 7, + "VERIFIED_HIGH": 8, + "VERIFIED_INITIAL_UNKNOWN": 9, + "VERIFIED_INITIAL_LOW": 10, + "VERIFIED_INITIAL_HIGH": 11, + "VERIFIED_TRANSITION_ANY_TO_NONE": 12, + "VERIFIED_TRANSITION_ANY_TO_HIGH": 13, + "VERIFIED_TRANSITION_HIGH_TO_LOW": 14, + "VERIFIED_TRANSITION_HIGH_TO_UNKNOWN": 15, + "VERIFIED_TRANSITION_UNKNOWN_TO_LOW": 16, + "VERIFIED_TRANSITION_LOW_TO_UNKNOWN": 17, + "VERIFIED_TRANSITION_NONE_TO_LOW": 18, + "VERIFIED_TRANSITION_NONE_TO_UNKNOWN": 19, + "GROUP_CREATE": 20, + "GROUP_CHANGE_SUBJECT": 21, + "GROUP_CHANGE_ICON": 22, + "GROUP_CHANGE_INVITE_LINK": 23, + "GROUP_CHANGE_DESCRIPTION": 24, + "GROUP_CHANGE_RESTRICT": 25, + "GROUP_CHANGE_ANNOUNCE": 26, + "GROUP_PARTICIPANT_ADD": 27, + "GROUP_PARTICIPANT_REMOVE": 28, + "GROUP_PARTICIPANT_PROMOTE": 29, + "GROUP_PARTICIPANT_DEMOTE": 30, + "GROUP_PARTICIPANT_INVITE": 31, + "GROUP_PARTICIPANT_LEAVE": 32, + "GROUP_PARTICIPANT_CHANGE_NUMBER": 33, + "BROADCAST_CREATE": 34, + "BROADCAST_ADD": 35, + "BROADCAST_REMOVE": 36, + "GENERIC_NOTIFICATION": 37, + "E2E_IDENTITY_CHANGED": 38, + "E2E_ENCRYPTED": 39, + "CALL_MISSED_VOICE": 40, + "CALL_MISSED_VIDEO": 41, + "INDIVIDUAL_CHANGE_NUMBER": 42, + "GROUP_DELETE": 43, +} + +func (x WebMessageInfo_STUBTYPE) Enum() *WebMessageInfo_STUBTYPE { + p := new(WebMessageInfo_STUBTYPE) + *p = x + return p +} +func (x WebMessageInfo_STUBTYPE) String() string { + return proto.EnumName(WebMessageInfo_STUBTYPE_name, int32(x)) +} +func (x *WebMessageInfo_STUBTYPE) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(WebMessageInfo_STUBTYPE_value, data, "WebMessageInfo_STUBTYPE") + if err != nil { + return err + } + *x = WebMessageInfo_STUBTYPE(value) + return nil +} +func (WebMessageInfo_STUBTYPE) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{30, 1} +} + +type WebFeatures_FLAG int32 + +const ( + WebFeatures_NOT_IMPLEMENTED WebFeatures_FLAG = 0 + WebFeatures_IMPLEMENTED WebFeatures_FLAG = 1 + WebFeatures_OPTIONAL WebFeatures_FLAG = 2 +) + +var WebFeatures_FLAG_name = map[int32]string{ + 0: "NOT_IMPLEMENTED", + 1: "IMPLEMENTED", + 2: "OPTIONAL", +} +var WebFeatures_FLAG_value = map[string]int32{ + "NOT_IMPLEMENTED": 0, + "IMPLEMENTED": 1, + "OPTIONAL": 2, +} + +func (x WebFeatures_FLAG) Enum() *WebFeatures_FLAG { + p := new(WebFeatures_FLAG) + *p = x + return p +} +func (x WebFeatures_FLAG) String() string { + return proto.EnumName(WebFeatures_FLAG_name, int32(x)) +} +func (x *WebFeatures_FLAG) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(WebFeatures_FLAG_value, data, "WebFeatures_FLAG") + if err != nil { + return err + } + *x = WebFeatures_FLAG(value) + return nil +} +func (WebFeatures_FLAG) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{34, 0} +} + +type FingerprintData struct { + PublicKey *string `protobuf:"bytes,1,opt,name=publicKey" json:"publicKey,omitempty"` + Identifier *string `protobuf:"bytes,2,opt,name=identifier" json:"identifier,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FingerprintData) Reset() { *m = FingerprintData{} } +func (m *FingerprintData) String() string { return proto.CompactTextString(m) } +func (*FingerprintData) ProtoMessage() {} +func (*FingerprintData) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{0} +} +func (m *FingerprintData) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FingerprintData.Unmarshal(m, b) +} +func (m *FingerprintData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FingerprintData.Marshal(b, m, deterministic) +} +func (dst *FingerprintData) XXX_Merge(src proto.Message) { + xxx_messageInfo_FingerprintData.Merge(dst, src) +} +func (m *FingerprintData) XXX_Size() int { + return xxx_messageInfo_FingerprintData.Size(m) +} +func (m *FingerprintData) XXX_DiscardUnknown() { + xxx_messageInfo_FingerprintData.DiscardUnknown(m) +} + +var xxx_messageInfo_FingerprintData proto.InternalMessageInfo + +func (m *FingerprintData) GetPublicKey() string { + if m != nil && m.PublicKey != nil { + return *m.PublicKey + } + return "" +} + +func (m *FingerprintData) GetIdentifier() string { + if m != nil && m.Identifier != nil { + return *m.Identifier + } + return "" +} + +type CombinedFingerprint struct { + Version *uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"` + LocalFingerprint *FingerprintData `protobuf:"bytes,2,opt,name=localFingerprint" json:"localFingerprint,omitempty"` + RemoteFingerprint *FingerprintData `protobuf:"bytes,3,opt,name=remoteFingerprint" json:"remoteFingerprint,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CombinedFingerprint) Reset() { *m = CombinedFingerprint{} } +func (m *CombinedFingerprint) String() string { return proto.CompactTextString(m) } +func (*CombinedFingerprint) ProtoMessage() {} +func (*CombinedFingerprint) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{1} +} +func (m *CombinedFingerprint) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CombinedFingerprint.Unmarshal(m, b) +} +func (m *CombinedFingerprint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CombinedFingerprint.Marshal(b, m, deterministic) +} +func (dst *CombinedFingerprint) XXX_Merge(src proto.Message) { + xxx_messageInfo_CombinedFingerprint.Merge(dst, src) +} +func (m *CombinedFingerprint) XXX_Size() int { + return xxx_messageInfo_CombinedFingerprint.Size(m) +} +func (m *CombinedFingerprint) XXX_DiscardUnknown() { + xxx_messageInfo_CombinedFingerprint.DiscardUnknown(m) +} + +var xxx_messageInfo_CombinedFingerprint proto.InternalMessageInfo + +func (m *CombinedFingerprint) GetVersion() uint32 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +func (m *CombinedFingerprint) GetLocalFingerprint() *FingerprintData { + if m != nil { + return m.LocalFingerprint + } + return nil +} + +func (m *CombinedFingerprint) GetRemoteFingerprint() *FingerprintData { + if m != nil { + return m.RemoteFingerprint + } + return nil +} + +type MessageKey struct { + RemoteJid *string `protobuf:"bytes,1,opt,name=remoteJid" json:"remoteJid,omitempty"` + FromMe *bool `protobuf:"varint,2,opt,name=fromMe" json:"fromMe,omitempty"` + Id *string `protobuf:"bytes,3,opt,name=id" json:"id,omitempty"` + Participant *string `protobuf:"bytes,4,opt,name=participant" json:"participant,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *MessageKey) Reset() { *m = MessageKey{} } +func (m *MessageKey) String() string { return proto.CompactTextString(m) } +func (*MessageKey) ProtoMessage() {} +func (*MessageKey) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{2} +} +func (m *MessageKey) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_MessageKey.Unmarshal(m, b) +} +func (m *MessageKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_MessageKey.Marshal(b, m, deterministic) +} +func (dst *MessageKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_MessageKey.Merge(dst, src) +} +func (m *MessageKey) XXX_Size() int { + return xxx_messageInfo_MessageKey.Size(m) +} +func (m *MessageKey) XXX_DiscardUnknown() { + xxx_messageInfo_MessageKey.DiscardUnknown(m) +} + +var xxx_messageInfo_MessageKey proto.InternalMessageInfo + +func (m *MessageKey) GetRemoteJid() string { + if m != nil && m.RemoteJid != nil { + return *m.RemoteJid + } + return "" +} + +func (m *MessageKey) GetFromMe() bool { + if m != nil && m.FromMe != nil { + return *m.FromMe + } + return false +} + +func (m *MessageKey) GetId() string { + if m != nil && m.Id != nil { + return *m.Id + } + return "" +} + +func (m *MessageKey) GetParticipant() string { + if m != nil && m.Participant != nil { + return *m.Participant + } + return "" +} + +type SenderKeyDistributionMessage struct { + GroupId *string `protobuf:"bytes,1,opt,name=groupId" json:"groupId,omitempty"` + AxolotlSenderKeyDistributionMessage []byte `protobuf:"bytes,2,opt,name=axolotlSenderKeyDistributionMessage" json:"axolotlSenderKeyDistributionMessage,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SenderKeyDistributionMessage) Reset() { *m = SenderKeyDistributionMessage{} } +func (m *SenderKeyDistributionMessage) String() string { return proto.CompactTextString(m) } +func (*SenderKeyDistributionMessage) ProtoMessage() {} +func (*SenderKeyDistributionMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{3} +} +func (m *SenderKeyDistributionMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SenderKeyDistributionMessage.Unmarshal(m, b) +} +func (m *SenderKeyDistributionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SenderKeyDistributionMessage.Marshal(b, m, deterministic) +} +func (dst *SenderKeyDistributionMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_SenderKeyDistributionMessage.Merge(dst, src) +} +func (m *SenderKeyDistributionMessage) XXX_Size() int { + return xxx_messageInfo_SenderKeyDistributionMessage.Size(m) +} +func (m *SenderKeyDistributionMessage) XXX_DiscardUnknown() { + xxx_messageInfo_SenderKeyDistributionMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_SenderKeyDistributionMessage proto.InternalMessageInfo + +func (m *SenderKeyDistributionMessage) GetGroupId() string { + if m != nil && m.GroupId != nil { + return *m.GroupId + } + return "" +} + +func (m *SenderKeyDistributionMessage) GetAxolotlSenderKeyDistributionMessage() []byte { + if m != nil { + return m.AxolotlSenderKeyDistributionMessage + } + return nil +} + +type ImageMessage struct { + Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` + Mimetype *string `protobuf:"bytes,2,opt,name=mimetype" json:"mimetype,omitempty"` + Caption *string `protobuf:"bytes,3,opt,name=caption" json:"caption,omitempty"` + FileSha256 []byte `protobuf:"bytes,4,opt,name=fileSha256" json:"fileSha256,omitempty"` + FileLength *uint64 `protobuf:"varint,5,opt,name=fileLength" json:"fileLength,omitempty"` + Height *uint32 `protobuf:"varint,6,opt,name=height" json:"height,omitempty"` + Width *uint32 `protobuf:"varint,7,opt,name=width" json:"width,omitempty"` + MediaKey []byte `protobuf:"bytes,8,opt,name=mediaKey" json:"mediaKey,omitempty"` + FileEncSha256 []byte `protobuf:"bytes,9,opt,name=fileEncSha256" json:"fileEncSha256,omitempty"` + InteractiveAnnotations []*InteractiveAnnotation `protobuf:"bytes,10,rep,name=interactiveAnnotations" json:"interactiveAnnotations,omitempty"` + DirectPath *string `protobuf:"bytes,11,opt,name=directPath" json:"directPath,omitempty"` + JpegThumbnail []byte `protobuf:"bytes,16,opt,name=jpegThumbnail" json:"jpegThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + FirstScanSidecar []byte `protobuf:"bytes,18,opt,name=firstScanSidecar" json:"firstScanSidecar,omitempty"` + FirstScanLength *uint32 `protobuf:"varint,19,opt,name=firstScanLength" json:"firstScanLength,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ImageMessage) Reset() { *m = ImageMessage{} } +func (m *ImageMessage) String() string { return proto.CompactTextString(m) } +func (*ImageMessage) ProtoMessage() {} +func (*ImageMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{4} +} +func (m *ImageMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ImageMessage.Unmarshal(m, b) +} +func (m *ImageMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ImageMessage.Marshal(b, m, deterministic) +} +func (dst *ImageMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ImageMessage.Merge(dst, src) +} +func (m *ImageMessage) XXX_Size() int { + return xxx_messageInfo_ImageMessage.Size(m) +} +func (m *ImageMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ImageMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ImageMessage proto.InternalMessageInfo + +func (m *ImageMessage) GetUrl() string { + if m != nil && m.Url != nil { + return *m.Url + } + return "" +} + +func (m *ImageMessage) GetMimetype() string { + if m != nil && m.Mimetype != nil { + return *m.Mimetype + } + return "" +} + +func (m *ImageMessage) GetCaption() string { + if m != nil && m.Caption != nil { + return *m.Caption + } + return "" +} + +func (m *ImageMessage) GetFileSha256() []byte { + if m != nil { + return m.FileSha256 + } + return nil +} + +func (m *ImageMessage) GetFileLength() uint64 { + if m != nil && m.FileLength != nil { + return *m.FileLength + } + return 0 +} + +func (m *ImageMessage) GetHeight() uint32 { + if m != nil && m.Height != nil { + return *m.Height + } + return 0 +} + +func (m *ImageMessage) GetWidth() uint32 { + if m != nil && m.Width != nil { + return *m.Width + } + return 0 +} + +func (m *ImageMessage) GetMediaKey() []byte { + if m != nil { + return m.MediaKey + } + return nil +} + +func (m *ImageMessage) GetFileEncSha256() []byte { + if m != nil { + return m.FileEncSha256 + } + return nil +} + +func (m *ImageMessage) GetInteractiveAnnotations() []*InteractiveAnnotation { + if m != nil { + return m.InteractiveAnnotations + } + return nil +} + +func (m *ImageMessage) GetDirectPath() string { + if m != nil && m.DirectPath != nil { + return *m.DirectPath + } + return "" +} + +func (m *ImageMessage) GetJpegThumbnail() []byte { + if m != nil { + return m.JpegThumbnail + } + return nil +} + +func (m *ImageMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +func (m *ImageMessage) GetFirstScanSidecar() []byte { + if m != nil { + return m.FirstScanSidecar + } + return nil +} + +func (m *ImageMessage) GetFirstScanLength() uint32 { + if m != nil && m.FirstScanLength != nil { + return *m.FirstScanLength + } + return 0 +} + +type ContactMessage struct { + DisplayName *string `protobuf:"bytes,1,opt,name=displayName" json:"displayName,omitempty"` + Vcard *string `protobuf:"bytes,16,opt,name=vcard" json:"vcard,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ContactMessage) Reset() { *m = ContactMessage{} } +func (m *ContactMessage) String() string { return proto.CompactTextString(m) } +func (*ContactMessage) ProtoMessage() {} +func (*ContactMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{5} +} +func (m *ContactMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ContactMessage.Unmarshal(m, b) +} +func (m *ContactMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ContactMessage.Marshal(b, m, deterministic) +} +func (dst *ContactMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContactMessage.Merge(dst, src) +} +func (m *ContactMessage) XXX_Size() int { + return xxx_messageInfo_ContactMessage.Size(m) +} +func (m *ContactMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ContactMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ContactMessage proto.InternalMessageInfo + +func (m *ContactMessage) GetDisplayName() string { + if m != nil && m.DisplayName != nil { + return *m.DisplayName + } + return "" +} + +func (m *ContactMessage) GetVcard() string { + if m != nil && m.Vcard != nil { + return *m.Vcard + } + return "" +} + +func (m *ContactMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type LocationMessage struct { + DegreesLatitude *float64 `protobuf:"fixed64,1,opt,name=degreesLatitude" json:"degreesLatitude,omitempty"` + DegreesLongitude *float64 `protobuf:"fixed64,2,opt,name=degreesLongitude" json:"degreesLongitude,omitempty"` + Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + Address *string `protobuf:"bytes,4,opt,name=address" json:"address,omitempty"` + Url *string `protobuf:"bytes,5,opt,name=url" json:"url,omitempty"` + JpegThumbnail []byte `protobuf:"bytes,16,opt,name=jpegThumbnail" json:"jpegThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LocationMessage) Reset() { *m = LocationMessage{} } +func (m *LocationMessage) String() string { return proto.CompactTextString(m) } +func (*LocationMessage) ProtoMessage() {} +func (*LocationMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{6} +} +func (m *LocationMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LocationMessage.Unmarshal(m, b) +} +func (m *LocationMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LocationMessage.Marshal(b, m, deterministic) +} +func (dst *LocationMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_LocationMessage.Merge(dst, src) +} +func (m *LocationMessage) XXX_Size() int { + return xxx_messageInfo_LocationMessage.Size(m) +} +func (m *LocationMessage) XXX_DiscardUnknown() { + xxx_messageInfo_LocationMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_LocationMessage proto.InternalMessageInfo + +func (m *LocationMessage) GetDegreesLatitude() float64 { + if m != nil && m.DegreesLatitude != nil { + return *m.DegreesLatitude + } + return 0 +} + +func (m *LocationMessage) GetDegreesLongitude() float64 { + if m != nil && m.DegreesLongitude != nil { + return *m.DegreesLongitude + } + return 0 +} + +func (m *LocationMessage) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *LocationMessage) GetAddress() string { + if m != nil && m.Address != nil { + return *m.Address + } + return "" +} + +func (m *LocationMessage) GetUrl() string { + if m != nil && m.Url != nil { + return *m.Url + } + return "" +} + +func (m *LocationMessage) GetJpegThumbnail() []byte { + if m != nil { + return m.JpegThumbnail + } + return nil +} + +func (m *LocationMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type ExtendedTextMessage struct { + Text *string `protobuf:"bytes,1,opt,name=text" json:"text,omitempty"` + MatchedText *string `protobuf:"bytes,2,opt,name=matchedText" json:"matchedText,omitempty"` + CanonicalUrl *string `protobuf:"bytes,4,opt,name=canonicalUrl" json:"canonicalUrl,omitempty"` + Description *string `protobuf:"bytes,5,opt,name=description" json:"description,omitempty"` + Title *string `protobuf:"bytes,6,opt,name=title" json:"title,omitempty"` + TextArgb *uint32 `protobuf:"fixed32,7,opt,name=textArgb" json:"textArgb,omitempty"` + BackgroundArgb *uint32 `protobuf:"fixed32,8,opt,name=backgroundArgb" json:"backgroundArgb,omitempty"` + Font *ExtendedTextMessage_FONTTYPE `protobuf:"varint,9,opt,name=font,enum=proto.ExtendedTextMessage_FONTTYPE" json:"font,omitempty"` + JpegThumbnail []byte `protobuf:"bytes,16,opt,name=jpegThumbnail" json:"jpegThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ExtendedTextMessage) Reset() { *m = ExtendedTextMessage{} } +func (m *ExtendedTextMessage) String() string { return proto.CompactTextString(m) } +func (*ExtendedTextMessage) ProtoMessage() {} +func (*ExtendedTextMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{7} +} +func (m *ExtendedTextMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ExtendedTextMessage.Unmarshal(m, b) +} +func (m *ExtendedTextMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ExtendedTextMessage.Marshal(b, m, deterministic) +} +func (dst *ExtendedTextMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExtendedTextMessage.Merge(dst, src) +} +func (m *ExtendedTextMessage) XXX_Size() int { + return xxx_messageInfo_ExtendedTextMessage.Size(m) +} +func (m *ExtendedTextMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ExtendedTextMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ExtendedTextMessage proto.InternalMessageInfo + +func (m *ExtendedTextMessage) GetText() string { + if m != nil && m.Text != nil { + return *m.Text + } + return "" +} + +func (m *ExtendedTextMessage) GetMatchedText() string { + if m != nil && m.MatchedText != nil { + return *m.MatchedText + } + return "" +} + +func (m *ExtendedTextMessage) GetCanonicalUrl() string { + if m != nil && m.CanonicalUrl != nil { + return *m.CanonicalUrl + } + return "" +} + +func (m *ExtendedTextMessage) GetDescription() string { + if m != nil && m.Description != nil { + return *m.Description + } + return "" +} + +func (m *ExtendedTextMessage) GetTitle() string { + if m != nil && m.Title != nil { + return *m.Title + } + return "" +} + +func (m *ExtendedTextMessage) GetTextArgb() uint32 { + if m != nil && m.TextArgb != nil { + return *m.TextArgb + } + return 0 +} + +func (m *ExtendedTextMessage) GetBackgroundArgb() uint32 { + if m != nil && m.BackgroundArgb != nil { + return *m.BackgroundArgb + } + return 0 +} + +func (m *ExtendedTextMessage) GetFont() ExtendedTextMessage_FONTTYPE { + if m != nil && m.Font != nil { + return *m.Font + } + return ExtendedTextMessage_SANS_SERIF +} + +func (m *ExtendedTextMessage) GetJpegThumbnail() []byte { + if m != nil { + return m.JpegThumbnail + } + return nil +} + +func (m *ExtendedTextMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type DocumentMessage struct { + Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` + Mimetype *string `protobuf:"bytes,2,opt,name=mimetype" json:"mimetype,omitempty"` + Title *string `protobuf:"bytes,3,opt,name=title" json:"title,omitempty"` + FileSha256 []byte `protobuf:"bytes,4,opt,name=fileSha256" json:"fileSha256,omitempty"` + FileLength *uint64 `protobuf:"varint,5,opt,name=fileLength" json:"fileLength,omitempty"` + PageCount *uint32 `protobuf:"varint,6,opt,name=pageCount" json:"pageCount,omitempty"` + MediaKey []byte `protobuf:"bytes,7,opt,name=mediaKey" json:"mediaKey,omitempty"` + FileName *string `protobuf:"bytes,8,opt,name=fileName" json:"fileName,omitempty"` + FileEncSha256 []byte `protobuf:"bytes,9,opt,name=fileEncSha256" json:"fileEncSha256,omitempty"` + DirectPath *string `protobuf:"bytes,10,opt,name=directPath" json:"directPath,omitempty"` + JpegThumbnail []byte `protobuf:"bytes,16,opt,name=jpegThumbnail" json:"jpegThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DocumentMessage) Reset() { *m = DocumentMessage{} } +func (m *DocumentMessage) String() string { return proto.CompactTextString(m) } +func (*DocumentMessage) ProtoMessage() {} +func (*DocumentMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{8} +} +func (m *DocumentMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DocumentMessage.Unmarshal(m, b) +} +func (m *DocumentMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DocumentMessage.Marshal(b, m, deterministic) +} +func (dst *DocumentMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_DocumentMessage.Merge(dst, src) +} +func (m *DocumentMessage) XXX_Size() int { + return xxx_messageInfo_DocumentMessage.Size(m) +} +func (m *DocumentMessage) XXX_DiscardUnknown() { + xxx_messageInfo_DocumentMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_DocumentMessage proto.InternalMessageInfo + +func (m *DocumentMessage) GetUrl() string { + if m != nil && m.Url != nil { + return *m.Url + } + return "" +} + +func (m *DocumentMessage) GetMimetype() string { + if m != nil && m.Mimetype != nil { + return *m.Mimetype + } + return "" +} + +func (m *DocumentMessage) GetTitle() string { + if m != nil && m.Title != nil { + return *m.Title + } + return "" +} + +func (m *DocumentMessage) GetFileSha256() []byte { + if m != nil { + return m.FileSha256 + } + return nil +} + +func (m *DocumentMessage) GetFileLength() uint64 { + if m != nil && m.FileLength != nil { + return *m.FileLength + } + return 0 +} + +func (m *DocumentMessage) GetPageCount() uint32 { + if m != nil && m.PageCount != nil { + return *m.PageCount + } + return 0 +} + +func (m *DocumentMessage) GetMediaKey() []byte { + if m != nil { + return m.MediaKey + } + return nil +} + +func (m *DocumentMessage) GetFileName() string { + if m != nil && m.FileName != nil { + return *m.FileName + } + return "" +} + +func (m *DocumentMessage) GetFileEncSha256() []byte { + if m != nil { + return m.FileEncSha256 + } + return nil +} + +func (m *DocumentMessage) GetDirectPath() string { + if m != nil && m.DirectPath != nil { + return *m.DirectPath + } + return "" +} + +func (m *DocumentMessage) GetJpegThumbnail() []byte { + if m != nil { + return m.JpegThumbnail + } + return nil +} + +func (m *DocumentMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type AudioMessage struct { + Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` + Mimetype *string `protobuf:"bytes,2,opt,name=mimetype" json:"mimetype,omitempty"` + FileSha256 []byte `protobuf:"bytes,3,opt,name=fileSha256" json:"fileSha256,omitempty"` + FileLength *uint64 `protobuf:"varint,4,opt,name=fileLength" json:"fileLength,omitempty"` + Seconds *uint32 `protobuf:"varint,5,opt,name=seconds" json:"seconds,omitempty"` + Ptt *bool `protobuf:"varint,6,opt,name=ptt" json:"ptt,omitempty"` + MediaKey []byte `protobuf:"bytes,7,opt,name=mediaKey" json:"mediaKey,omitempty"` + FileEncSha256 []byte `protobuf:"bytes,8,opt,name=fileEncSha256" json:"fileEncSha256,omitempty"` + DirectPath *string `protobuf:"bytes,9,opt,name=directPath" json:"directPath,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + StreamingSidecar []byte `protobuf:"bytes,18,opt,name=streamingSidecar" json:"streamingSidecar,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AudioMessage) Reset() { *m = AudioMessage{} } +func (m *AudioMessage) String() string { return proto.CompactTextString(m) } +func (*AudioMessage) ProtoMessage() {} +func (*AudioMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{9} +} +func (m *AudioMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AudioMessage.Unmarshal(m, b) +} +func (m *AudioMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AudioMessage.Marshal(b, m, deterministic) +} +func (dst *AudioMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_AudioMessage.Merge(dst, src) +} +func (m *AudioMessage) XXX_Size() int { + return xxx_messageInfo_AudioMessage.Size(m) +} +func (m *AudioMessage) XXX_DiscardUnknown() { + xxx_messageInfo_AudioMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_AudioMessage proto.InternalMessageInfo + +func (m *AudioMessage) GetUrl() string { + if m != nil && m.Url != nil { + return *m.Url + } + return "" +} + +func (m *AudioMessage) GetMimetype() string { + if m != nil && m.Mimetype != nil { + return *m.Mimetype + } + return "" +} + +func (m *AudioMessage) GetFileSha256() []byte { + if m != nil { + return m.FileSha256 + } + return nil +} + +func (m *AudioMessage) GetFileLength() uint64 { + if m != nil && m.FileLength != nil { + return *m.FileLength + } + return 0 +} + +func (m *AudioMessage) GetSeconds() uint32 { + if m != nil && m.Seconds != nil { + return *m.Seconds + } + return 0 +} + +func (m *AudioMessage) GetPtt() bool { + if m != nil && m.Ptt != nil { + return *m.Ptt + } + return false +} + +func (m *AudioMessage) GetMediaKey() []byte { + if m != nil { + return m.MediaKey + } + return nil +} + +func (m *AudioMessage) GetFileEncSha256() []byte { + if m != nil { + return m.FileEncSha256 + } + return nil +} + +func (m *AudioMessage) GetDirectPath() string { + if m != nil && m.DirectPath != nil { + return *m.DirectPath + } + return "" +} + +func (m *AudioMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +func (m *AudioMessage) GetStreamingSidecar() []byte { + if m != nil { + return m.StreamingSidecar + } + return nil +} + +type VideoMessage struct { + Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` + Mimetype *string `protobuf:"bytes,2,opt,name=mimetype" json:"mimetype,omitempty"` + FileSha256 []byte `protobuf:"bytes,3,opt,name=fileSha256" json:"fileSha256,omitempty"` + FileLength *uint64 `protobuf:"varint,4,opt,name=fileLength" json:"fileLength,omitempty"` + Seconds *uint32 `protobuf:"varint,5,opt,name=seconds" json:"seconds,omitempty"` + MediaKey []byte `protobuf:"bytes,6,opt,name=mediaKey" json:"mediaKey,omitempty"` + Caption *string `protobuf:"bytes,7,opt,name=caption" json:"caption,omitempty"` + GifPlayback *bool `protobuf:"varint,8,opt,name=gifPlayback" json:"gifPlayback,omitempty"` + Height *uint32 `protobuf:"varint,9,opt,name=height" json:"height,omitempty"` + Width *uint32 `protobuf:"varint,10,opt,name=width" json:"width,omitempty"` + FileEncSha256 []byte `protobuf:"bytes,11,opt,name=fileEncSha256" json:"fileEncSha256,omitempty"` + InteractiveAnnotations []*InteractiveAnnotation `protobuf:"bytes,12,rep,name=interactiveAnnotations" json:"interactiveAnnotations,omitempty"` + DirectPath *string `protobuf:"bytes,13,opt,name=directPath" json:"directPath,omitempty"` + JpegThumbnail []byte `protobuf:"bytes,16,opt,name=jpegThumbnail" json:"jpegThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + StreamingSidecar []byte `protobuf:"bytes,18,opt,name=streamingSidecar" json:"streamingSidecar,omitempty"` + GifAttribution *VideoMessage_ATTRIBUTION `protobuf:"varint,19,opt,name=gifAttribution,enum=proto.VideoMessage_ATTRIBUTION" json:"gifAttribution,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *VideoMessage) Reset() { *m = VideoMessage{} } +func (m *VideoMessage) String() string { return proto.CompactTextString(m) } +func (*VideoMessage) ProtoMessage() {} +func (*VideoMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{10} +} +func (m *VideoMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_VideoMessage.Unmarshal(m, b) +} +func (m *VideoMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_VideoMessage.Marshal(b, m, deterministic) +} +func (dst *VideoMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_VideoMessage.Merge(dst, src) +} +func (m *VideoMessage) XXX_Size() int { + return xxx_messageInfo_VideoMessage.Size(m) +} +func (m *VideoMessage) XXX_DiscardUnknown() { + xxx_messageInfo_VideoMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_VideoMessage proto.InternalMessageInfo + +func (m *VideoMessage) GetUrl() string { + if m != nil && m.Url != nil { + return *m.Url + } + return "" +} + +func (m *VideoMessage) GetMimetype() string { + if m != nil && m.Mimetype != nil { + return *m.Mimetype + } + return "" +} + +func (m *VideoMessage) GetFileSha256() []byte { + if m != nil { + return m.FileSha256 + } + return nil +} + +func (m *VideoMessage) GetFileLength() uint64 { + if m != nil && m.FileLength != nil { + return *m.FileLength + } + return 0 +} + +func (m *VideoMessage) GetSeconds() uint32 { + if m != nil && m.Seconds != nil { + return *m.Seconds + } + return 0 +} + +func (m *VideoMessage) GetMediaKey() []byte { + if m != nil { + return m.MediaKey + } + return nil +} + +func (m *VideoMessage) GetCaption() string { + if m != nil && m.Caption != nil { + return *m.Caption + } + return "" +} + +func (m *VideoMessage) GetGifPlayback() bool { + if m != nil && m.GifPlayback != nil { + return *m.GifPlayback + } + return false +} + +func (m *VideoMessage) GetHeight() uint32 { + if m != nil && m.Height != nil { + return *m.Height + } + return 0 +} + +func (m *VideoMessage) GetWidth() uint32 { + if m != nil && m.Width != nil { + return *m.Width + } + return 0 +} + +func (m *VideoMessage) GetFileEncSha256() []byte { + if m != nil { + return m.FileEncSha256 + } + return nil +} + +func (m *VideoMessage) GetInteractiveAnnotations() []*InteractiveAnnotation { + if m != nil { + return m.InteractiveAnnotations + } + return nil +} + +func (m *VideoMessage) GetDirectPath() string { + if m != nil && m.DirectPath != nil { + return *m.DirectPath + } + return "" +} + +func (m *VideoMessage) GetJpegThumbnail() []byte { + if m != nil { + return m.JpegThumbnail + } + return nil +} + +func (m *VideoMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +func (m *VideoMessage) GetStreamingSidecar() []byte { + if m != nil { + return m.StreamingSidecar + } + return nil +} + +func (m *VideoMessage) GetGifAttribution() VideoMessage_ATTRIBUTION { + if m != nil && m.GifAttribution != nil { + return *m.GifAttribution + } + return VideoMessage_NONE +} + +type Call struct { + CallKey []byte `protobuf:"bytes,1,opt,name=callKey" json:"callKey,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Call) Reset() { *m = Call{} } +func (m *Call) String() string { return proto.CompactTextString(m) } +func (*Call) ProtoMessage() {} +func (*Call) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{11} +} +func (m *Call) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Call.Unmarshal(m, b) +} +func (m *Call) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Call.Marshal(b, m, deterministic) +} +func (dst *Call) XXX_Merge(src proto.Message) { + xxx_messageInfo_Call.Merge(dst, src) +} +func (m *Call) XXX_Size() int { + return xxx_messageInfo_Call.Size(m) +} +func (m *Call) XXX_DiscardUnknown() { + xxx_messageInfo_Call.DiscardUnknown(m) +} + +var xxx_messageInfo_Call proto.InternalMessageInfo + +func (m *Call) GetCallKey() []byte { + if m != nil { + return m.CallKey + } + return nil +} + +type Chat struct { + DisplayName *string `protobuf:"bytes,1,opt,name=displayName" json:"displayName,omitempty"` + Id *string `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Chat) Reset() { *m = Chat{} } +func (m *Chat) String() string { return proto.CompactTextString(m) } +func (*Chat) ProtoMessage() {} +func (*Chat) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{12} +} +func (m *Chat) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Chat.Unmarshal(m, b) +} +func (m *Chat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Chat.Marshal(b, m, deterministic) +} +func (dst *Chat) XXX_Merge(src proto.Message) { + xxx_messageInfo_Chat.Merge(dst, src) +} +func (m *Chat) XXX_Size() int { + return xxx_messageInfo_Chat.Size(m) +} +func (m *Chat) XXX_DiscardUnknown() { + xxx_messageInfo_Chat.DiscardUnknown(m) +} + +var xxx_messageInfo_Chat proto.InternalMessageInfo + +func (m *Chat) GetDisplayName() string { + if m != nil && m.DisplayName != nil { + return *m.DisplayName + } + return "" +} + +func (m *Chat) GetId() string { + if m != nil && m.Id != nil { + return *m.Id + } + return "" +} + +type ProtocolMessage struct { + Key *MessageKey `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Type *ProtocolMessage_TYPE `protobuf:"varint,2,opt,name=type,enum=proto.ProtocolMessage_TYPE" json:"type,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProtocolMessage) Reset() { *m = ProtocolMessage{} } +func (m *ProtocolMessage) String() string { return proto.CompactTextString(m) } +func (*ProtocolMessage) ProtoMessage() {} +func (*ProtocolMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{13} +} +func (m *ProtocolMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ProtocolMessage.Unmarshal(m, b) +} +func (m *ProtocolMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ProtocolMessage.Marshal(b, m, deterministic) +} +func (dst *ProtocolMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProtocolMessage.Merge(dst, src) +} +func (m *ProtocolMessage) XXX_Size() int { + return xxx_messageInfo_ProtocolMessage.Size(m) +} +func (m *ProtocolMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ProtocolMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ProtocolMessage proto.InternalMessageInfo + +func (m *ProtocolMessage) GetKey() *MessageKey { + if m != nil { + return m.Key + } + return nil +} + +func (m *ProtocolMessage) GetType() ProtocolMessage_TYPE { + if m != nil && m.Type != nil { + return *m.Type + } + return ProtocolMessage_REVOKE +} + +type ContactsArrayMessage struct { + DisplayName *string `protobuf:"bytes,1,opt,name=displayName" json:"displayName,omitempty"` + Contacts []*ContactMessage `protobuf:"bytes,2,rep,name=contacts" json:"contacts,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ContactsArrayMessage) Reset() { *m = ContactsArrayMessage{} } +func (m *ContactsArrayMessage) String() string { return proto.CompactTextString(m) } +func (*ContactsArrayMessage) ProtoMessage() {} +func (*ContactsArrayMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{14} +} +func (m *ContactsArrayMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ContactsArrayMessage.Unmarshal(m, b) +} +func (m *ContactsArrayMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ContactsArrayMessage.Marshal(b, m, deterministic) +} +func (dst *ContactsArrayMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContactsArrayMessage.Merge(dst, src) +} +func (m *ContactsArrayMessage) XXX_Size() int { + return xxx_messageInfo_ContactsArrayMessage.Size(m) +} +func (m *ContactsArrayMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ContactsArrayMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ContactsArrayMessage proto.InternalMessageInfo + +func (m *ContactsArrayMessage) GetDisplayName() string { + if m != nil && m.DisplayName != nil { + return *m.DisplayName + } + return "" +} + +func (m *ContactsArrayMessage) GetContacts() []*ContactMessage { + if m != nil { + return m.Contacts + } + return nil +} + +func (m *ContactsArrayMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type HSMCurrency struct { + CurrencyCode *string `protobuf:"bytes,1,opt,name=currencyCode" json:"currencyCode,omitempty"` + Amount1000 *int64 `protobuf:"varint,2,opt,name=amount1000" json:"amount1000,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HSMCurrency) Reset() { *m = HSMCurrency{} } +func (m *HSMCurrency) String() string { return proto.CompactTextString(m) } +func (*HSMCurrency) ProtoMessage() {} +func (*HSMCurrency) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{15} +} +func (m *HSMCurrency) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HSMCurrency.Unmarshal(m, b) +} +func (m *HSMCurrency) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HSMCurrency.Marshal(b, m, deterministic) +} +func (dst *HSMCurrency) XXX_Merge(src proto.Message) { + xxx_messageInfo_HSMCurrency.Merge(dst, src) +} +func (m *HSMCurrency) XXX_Size() int { + return xxx_messageInfo_HSMCurrency.Size(m) +} +func (m *HSMCurrency) XXX_DiscardUnknown() { + xxx_messageInfo_HSMCurrency.DiscardUnknown(m) +} + +var xxx_messageInfo_HSMCurrency proto.InternalMessageInfo + +func (m *HSMCurrency) GetCurrencyCode() string { + if m != nil && m.CurrencyCode != nil { + return *m.CurrencyCode + } + return "" +} + +func (m *HSMCurrency) GetAmount1000() int64 { + if m != nil && m.Amount1000 != nil { + return *m.Amount1000 + } + return 0 +} + +type HSMDateTimeComponent struct { + DayOfWeek *HSMDateTimeComponent_DAYOFWEEKTYPE `protobuf:"varint,1,opt,name=dayOfWeek,enum=proto.HSMDateTimeComponent_DAYOFWEEKTYPE" json:"dayOfWeek,omitempty"` + Year *uint32 `protobuf:"varint,2,opt,name=year" json:"year,omitempty"` + Month *uint32 `protobuf:"varint,3,opt,name=month" json:"month,omitempty"` + DayOfMonth *uint32 `protobuf:"varint,4,opt,name=dayOfMonth" json:"dayOfMonth,omitempty"` + Hour *uint32 `protobuf:"varint,5,opt,name=hour" json:"hour,omitempty"` + Minute *uint32 `protobuf:"varint,6,opt,name=minute" json:"minute,omitempty"` + Calendar *HSMDateTimeComponent_CALENDARTYPE `protobuf:"varint,7,opt,name=calendar,enum=proto.HSMDateTimeComponent_CALENDARTYPE" json:"calendar,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HSMDateTimeComponent) Reset() { *m = HSMDateTimeComponent{} } +func (m *HSMDateTimeComponent) String() string { return proto.CompactTextString(m) } +func (*HSMDateTimeComponent) ProtoMessage() {} +func (*HSMDateTimeComponent) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{16} +} +func (m *HSMDateTimeComponent) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HSMDateTimeComponent.Unmarshal(m, b) +} +func (m *HSMDateTimeComponent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HSMDateTimeComponent.Marshal(b, m, deterministic) +} +func (dst *HSMDateTimeComponent) XXX_Merge(src proto.Message) { + xxx_messageInfo_HSMDateTimeComponent.Merge(dst, src) +} +func (m *HSMDateTimeComponent) XXX_Size() int { + return xxx_messageInfo_HSMDateTimeComponent.Size(m) +} +func (m *HSMDateTimeComponent) XXX_DiscardUnknown() { + xxx_messageInfo_HSMDateTimeComponent.DiscardUnknown(m) +} + +var xxx_messageInfo_HSMDateTimeComponent proto.InternalMessageInfo + +func (m *HSMDateTimeComponent) GetDayOfWeek() HSMDateTimeComponent_DAYOFWEEKTYPE { + if m != nil && m.DayOfWeek != nil { + return *m.DayOfWeek + } + return HSMDateTimeComponent_MONDAY +} + +func (m *HSMDateTimeComponent) GetYear() uint32 { + if m != nil && m.Year != nil { + return *m.Year + } + return 0 +} + +func (m *HSMDateTimeComponent) GetMonth() uint32 { + if m != nil && m.Month != nil { + return *m.Month + } + return 0 +} + +func (m *HSMDateTimeComponent) GetDayOfMonth() uint32 { + if m != nil && m.DayOfMonth != nil { + return *m.DayOfMonth + } + return 0 +} + +func (m *HSMDateTimeComponent) GetHour() uint32 { + if m != nil && m.Hour != nil { + return *m.Hour + } + return 0 +} + +func (m *HSMDateTimeComponent) GetMinute() uint32 { + if m != nil && m.Minute != nil { + return *m.Minute + } + return 0 +} + +func (m *HSMDateTimeComponent) GetCalendar() HSMDateTimeComponent_CALENDARTYPE { + if m != nil && m.Calendar != nil { + return *m.Calendar + } + return HSMDateTimeComponent_GREGORIAN +} + +type HSMDateTimeUnixEpoch struct { + Timestamp *int64 `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HSMDateTimeUnixEpoch) Reset() { *m = HSMDateTimeUnixEpoch{} } +func (m *HSMDateTimeUnixEpoch) String() string { return proto.CompactTextString(m) } +func (*HSMDateTimeUnixEpoch) ProtoMessage() {} +func (*HSMDateTimeUnixEpoch) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{17} +} +func (m *HSMDateTimeUnixEpoch) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HSMDateTimeUnixEpoch.Unmarshal(m, b) +} +func (m *HSMDateTimeUnixEpoch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HSMDateTimeUnixEpoch.Marshal(b, m, deterministic) +} +func (dst *HSMDateTimeUnixEpoch) XXX_Merge(src proto.Message) { + xxx_messageInfo_HSMDateTimeUnixEpoch.Merge(dst, src) +} +func (m *HSMDateTimeUnixEpoch) XXX_Size() int { + return xxx_messageInfo_HSMDateTimeUnixEpoch.Size(m) +} +func (m *HSMDateTimeUnixEpoch) XXX_DiscardUnknown() { + xxx_messageInfo_HSMDateTimeUnixEpoch.DiscardUnknown(m) +} + +var xxx_messageInfo_HSMDateTimeUnixEpoch proto.InternalMessageInfo + +func (m *HSMDateTimeUnixEpoch) GetTimestamp() int64 { + if m != nil && m.Timestamp != nil { + return *m.Timestamp + } + return 0 +} + +type HSMDateTime struct { + // Types that are valid to be assigned to DatetimeOneof: + // *HSMDateTime_Component + // *HSMDateTime_UnixEpoch + DatetimeOneof isHSMDateTime_DatetimeOneof `protobuf_oneof:"datetimeOneof"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HSMDateTime) Reset() { *m = HSMDateTime{} } +func (m *HSMDateTime) String() string { return proto.CompactTextString(m) } +func (*HSMDateTime) ProtoMessage() {} +func (*HSMDateTime) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{18} +} +func (m *HSMDateTime) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HSMDateTime.Unmarshal(m, b) +} +func (m *HSMDateTime) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HSMDateTime.Marshal(b, m, deterministic) +} +func (dst *HSMDateTime) XXX_Merge(src proto.Message) { + xxx_messageInfo_HSMDateTime.Merge(dst, src) +} +func (m *HSMDateTime) XXX_Size() int { + return xxx_messageInfo_HSMDateTime.Size(m) +} +func (m *HSMDateTime) XXX_DiscardUnknown() { + xxx_messageInfo_HSMDateTime.DiscardUnknown(m) +} + +var xxx_messageInfo_HSMDateTime proto.InternalMessageInfo + +type isHSMDateTime_DatetimeOneof interface { + isHSMDateTime_DatetimeOneof() +} + +type HSMDateTime_Component struct { + Component *HSMDateTimeComponent `protobuf:"bytes,1,opt,name=component,oneof"` +} +type HSMDateTime_UnixEpoch struct { + UnixEpoch *HSMDateTimeUnixEpoch `protobuf:"bytes,2,opt,name=unixEpoch,oneof"` +} + +func (*HSMDateTime_Component) isHSMDateTime_DatetimeOneof() {} +func (*HSMDateTime_UnixEpoch) isHSMDateTime_DatetimeOneof() {} + +func (m *HSMDateTime) GetDatetimeOneof() isHSMDateTime_DatetimeOneof { + if m != nil { + return m.DatetimeOneof + } + return nil +} + +func (m *HSMDateTime) GetComponent() *HSMDateTimeComponent { + if x, ok := m.GetDatetimeOneof().(*HSMDateTime_Component); ok { + return x.Component + } + return nil +} + +func (m *HSMDateTime) GetUnixEpoch() *HSMDateTimeUnixEpoch { + if x, ok := m.GetDatetimeOneof().(*HSMDateTime_UnixEpoch); ok { + return x.UnixEpoch + } + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*HSMDateTime) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _HSMDateTime_OneofMarshaler, _HSMDateTime_OneofUnmarshaler, _HSMDateTime_OneofSizer, []interface{}{ + (*HSMDateTime_Component)(nil), + (*HSMDateTime_UnixEpoch)(nil), + } +} + +func _HSMDateTime_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*HSMDateTime) + // datetimeOneof + switch x := m.DatetimeOneof.(type) { + case *HSMDateTime_Component: + b.EncodeVarint(1<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Component); err != nil { + return err + } + case *HSMDateTime_UnixEpoch: + b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.UnixEpoch); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("HSMDateTime.DatetimeOneof has unexpected type %T", x) + } + return nil +} + +func _HSMDateTime_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*HSMDateTime) + switch tag { + case 1: // datetimeOneof.component + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(HSMDateTimeComponent) + err := b.DecodeMessage(msg) + m.DatetimeOneof = &HSMDateTime_Component{msg} + return true, err + case 2: // datetimeOneof.unixEpoch + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(HSMDateTimeUnixEpoch) + err := b.DecodeMessage(msg) + m.DatetimeOneof = &HSMDateTime_UnixEpoch{msg} + return true, err + default: + return false, nil + } +} + +func _HSMDateTime_OneofSizer(msg proto.Message) (n int) { + m := msg.(*HSMDateTime) + // datetimeOneof + switch x := m.DatetimeOneof.(type) { + case *HSMDateTime_Component: + s := proto.Size(x.Component) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case *HSMDateTime_UnixEpoch: + s := proto.Size(x.UnixEpoch) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type HSMLocalizableParameter struct { + Default *string `protobuf:"bytes,1,opt,name=default" json:"default,omitempty"` + // Types that are valid to be assigned to ParamOneof: + // *HSMLocalizableParameter_Currency + // *HSMLocalizableParameter_DateTime + ParamOneof isHSMLocalizableParameter_ParamOneof `protobuf_oneof:"paramOneof"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HSMLocalizableParameter) Reset() { *m = HSMLocalizableParameter{} } +func (m *HSMLocalizableParameter) String() string { return proto.CompactTextString(m) } +func (*HSMLocalizableParameter) ProtoMessage() {} +func (*HSMLocalizableParameter) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{19} +} +func (m *HSMLocalizableParameter) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HSMLocalizableParameter.Unmarshal(m, b) +} +func (m *HSMLocalizableParameter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HSMLocalizableParameter.Marshal(b, m, deterministic) +} +func (dst *HSMLocalizableParameter) XXX_Merge(src proto.Message) { + xxx_messageInfo_HSMLocalizableParameter.Merge(dst, src) +} +func (m *HSMLocalizableParameter) XXX_Size() int { + return xxx_messageInfo_HSMLocalizableParameter.Size(m) +} +func (m *HSMLocalizableParameter) XXX_DiscardUnknown() { + xxx_messageInfo_HSMLocalizableParameter.DiscardUnknown(m) +} + +var xxx_messageInfo_HSMLocalizableParameter proto.InternalMessageInfo + +type isHSMLocalizableParameter_ParamOneof interface { + isHSMLocalizableParameter_ParamOneof() +} + +type HSMLocalizableParameter_Currency struct { + Currency *HSMCurrency `protobuf:"bytes,2,opt,name=currency,oneof"` +} +type HSMLocalizableParameter_DateTime struct { + DateTime *HSMDateTime `protobuf:"bytes,3,opt,name=dateTime,oneof"` +} + +func (*HSMLocalizableParameter_Currency) isHSMLocalizableParameter_ParamOneof() {} +func (*HSMLocalizableParameter_DateTime) isHSMLocalizableParameter_ParamOneof() {} + +func (m *HSMLocalizableParameter) GetParamOneof() isHSMLocalizableParameter_ParamOneof { + if m != nil { + return m.ParamOneof + } + return nil +} + +func (m *HSMLocalizableParameter) GetDefault() string { + if m != nil && m.Default != nil { + return *m.Default + } + return "" +} + +func (m *HSMLocalizableParameter) GetCurrency() *HSMCurrency { + if x, ok := m.GetParamOneof().(*HSMLocalizableParameter_Currency); ok { + return x.Currency + } + return nil +} + +func (m *HSMLocalizableParameter) GetDateTime() *HSMDateTime { + if x, ok := m.GetParamOneof().(*HSMLocalizableParameter_DateTime); ok { + return x.DateTime + } + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*HSMLocalizableParameter) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _HSMLocalizableParameter_OneofMarshaler, _HSMLocalizableParameter_OneofUnmarshaler, _HSMLocalizableParameter_OneofSizer, []interface{}{ + (*HSMLocalizableParameter_Currency)(nil), + (*HSMLocalizableParameter_DateTime)(nil), + } +} + +func _HSMLocalizableParameter_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*HSMLocalizableParameter) + // paramOneof + switch x := m.ParamOneof.(type) { + case *HSMLocalizableParameter_Currency: + b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Currency); err != nil { + return err + } + case *HSMLocalizableParameter_DateTime: + b.EncodeVarint(3<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.DateTime); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("HSMLocalizableParameter.ParamOneof has unexpected type %T", x) + } + return nil +} + +func _HSMLocalizableParameter_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*HSMLocalizableParameter) + switch tag { + case 2: // paramOneof.currency + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(HSMCurrency) + err := b.DecodeMessage(msg) + m.ParamOneof = &HSMLocalizableParameter_Currency{msg} + return true, err + case 3: // paramOneof.dateTime + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(HSMDateTime) + err := b.DecodeMessage(msg) + m.ParamOneof = &HSMLocalizableParameter_DateTime{msg} + return true, err + default: + return false, nil + } +} + +func _HSMLocalizableParameter_OneofSizer(msg proto.Message) (n int) { + m := msg.(*HSMLocalizableParameter) + // paramOneof + switch x := m.ParamOneof.(type) { + case *HSMLocalizableParameter_Currency: + s := proto.Size(x.Currency) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case *HSMLocalizableParameter_DateTime: + s := proto.Size(x.DateTime) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type HighlyStructuredMessage struct { + Namespace *string `protobuf:"bytes,1,opt,name=namespace" json:"namespace,omitempty"` + ElementName *string `protobuf:"bytes,2,opt,name=elementName" json:"elementName,omitempty"` + Params []string `protobuf:"bytes,3,rep,name=params" json:"params,omitempty"` + FallbackLg *string `protobuf:"bytes,4,opt,name=fallbackLg" json:"fallbackLg,omitempty"` + FallbackLc *string `protobuf:"bytes,5,opt,name=fallbackLc" json:"fallbackLc,omitempty"` + LocalizableParams []*HSMLocalizableParameter `protobuf:"bytes,6,rep,name=localizableParams" json:"localizableParams,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HighlyStructuredMessage) Reset() { *m = HighlyStructuredMessage{} } +func (m *HighlyStructuredMessage) String() string { return proto.CompactTextString(m) } +func (*HighlyStructuredMessage) ProtoMessage() {} +func (*HighlyStructuredMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{20} +} +func (m *HighlyStructuredMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HighlyStructuredMessage.Unmarshal(m, b) +} +func (m *HighlyStructuredMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HighlyStructuredMessage.Marshal(b, m, deterministic) +} +func (dst *HighlyStructuredMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_HighlyStructuredMessage.Merge(dst, src) +} +func (m *HighlyStructuredMessage) XXX_Size() int { + return xxx_messageInfo_HighlyStructuredMessage.Size(m) +} +func (m *HighlyStructuredMessage) XXX_DiscardUnknown() { + xxx_messageInfo_HighlyStructuredMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_HighlyStructuredMessage proto.InternalMessageInfo + +func (m *HighlyStructuredMessage) GetNamespace() string { + if m != nil && m.Namespace != nil { + return *m.Namespace + } + return "" +} + +func (m *HighlyStructuredMessage) GetElementName() string { + if m != nil && m.ElementName != nil { + return *m.ElementName + } + return "" +} + +func (m *HighlyStructuredMessage) GetParams() []string { + if m != nil { + return m.Params + } + return nil +} + +func (m *HighlyStructuredMessage) GetFallbackLg() string { + if m != nil && m.FallbackLg != nil { + return *m.FallbackLg + } + return "" +} + +func (m *HighlyStructuredMessage) GetFallbackLc() string { + if m != nil && m.FallbackLc != nil { + return *m.FallbackLc + } + return "" +} + +func (m *HighlyStructuredMessage) GetLocalizableParams() []*HSMLocalizableParameter { + if m != nil { + return m.LocalizableParams + } + return nil +} + +type SendPaymentMessage struct { + NoteMessage *Message `protobuf:"bytes,2,opt,name=noteMessage" json:"noteMessage,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SendPaymentMessage) Reset() { *m = SendPaymentMessage{} } +func (m *SendPaymentMessage) String() string { return proto.CompactTextString(m) } +func (*SendPaymentMessage) ProtoMessage() {} +func (*SendPaymentMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{21} +} +func (m *SendPaymentMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SendPaymentMessage.Unmarshal(m, b) +} +func (m *SendPaymentMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SendPaymentMessage.Marshal(b, m, deterministic) +} +func (dst *SendPaymentMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_SendPaymentMessage.Merge(dst, src) +} +func (m *SendPaymentMessage) XXX_Size() int { + return xxx_messageInfo_SendPaymentMessage.Size(m) +} +func (m *SendPaymentMessage) XXX_DiscardUnknown() { + xxx_messageInfo_SendPaymentMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_SendPaymentMessage proto.InternalMessageInfo + +func (m *SendPaymentMessage) GetNoteMessage() *Message { + if m != nil { + return m.NoteMessage + } + return nil +} + +type RequestPaymentMessage struct { + CurrencyCodeIso4217 *string `protobuf:"bytes,1,opt,name=currencyCodeIso4217" json:"currencyCodeIso4217,omitempty"` + Amount1000 *uint64 `protobuf:"varint,2,opt,name=amount1000" json:"amount1000,omitempty"` + RequestFrom *string `protobuf:"bytes,3,opt,name=requestFrom" json:"requestFrom,omitempty"` + NoteMessage *Message `protobuf:"bytes,4,opt,name=noteMessage" json:"noteMessage,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RequestPaymentMessage) Reset() { *m = RequestPaymentMessage{} } +func (m *RequestPaymentMessage) String() string { return proto.CompactTextString(m) } +func (*RequestPaymentMessage) ProtoMessage() {} +func (*RequestPaymentMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{22} +} +func (m *RequestPaymentMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RequestPaymentMessage.Unmarshal(m, b) +} +func (m *RequestPaymentMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RequestPaymentMessage.Marshal(b, m, deterministic) +} +func (dst *RequestPaymentMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_RequestPaymentMessage.Merge(dst, src) +} +func (m *RequestPaymentMessage) XXX_Size() int { + return xxx_messageInfo_RequestPaymentMessage.Size(m) +} +func (m *RequestPaymentMessage) XXX_DiscardUnknown() { + xxx_messageInfo_RequestPaymentMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_RequestPaymentMessage proto.InternalMessageInfo + +func (m *RequestPaymentMessage) GetCurrencyCodeIso4217() string { + if m != nil && m.CurrencyCodeIso4217 != nil { + return *m.CurrencyCodeIso4217 + } + return "" +} + +func (m *RequestPaymentMessage) GetAmount1000() uint64 { + if m != nil && m.Amount1000 != nil { + return *m.Amount1000 + } + return 0 +} + +func (m *RequestPaymentMessage) GetRequestFrom() string { + if m != nil && m.RequestFrom != nil { + return *m.RequestFrom + } + return "" +} + +func (m *RequestPaymentMessage) GetNoteMessage() *Message { + if m != nil { + return m.NoteMessage + } + return nil +} + +type LiveLocationMessage struct { + DegreesLatitude *float64 `protobuf:"fixed64,1,opt,name=degreesLatitude" json:"degreesLatitude,omitempty"` + DegreesLongitude *float64 `protobuf:"fixed64,2,opt,name=degreesLongitude" json:"degreesLongitude,omitempty"` + AccuracyInMeters *uint32 `protobuf:"varint,3,opt,name=accuracyInMeters" json:"accuracyInMeters,omitempty"` + SpeedInMps *float32 `protobuf:"fixed32,4,opt,name=speedInMps" json:"speedInMps,omitempty"` + DegreesClockwiseFromMagneticNorth *uint32 `protobuf:"varint,5,opt,name=degreesClockwiseFromMagneticNorth" json:"degreesClockwiseFromMagneticNorth,omitempty"` + Caption *string `protobuf:"bytes,6,opt,name=caption" json:"caption,omitempty"` + SequenceNumber *int64 `protobuf:"varint,7,opt,name=sequenceNumber" json:"sequenceNumber,omitempty"` + JpegThumbnail []byte `protobuf:"bytes,16,opt,name=jpegThumbnail" json:"jpegThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *LiveLocationMessage) Reset() { *m = LiveLocationMessage{} } +func (m *LiveLocationMessage) String() string { return proto.CompactTextString(m) } +func (*LiveLocationMessage) ProtoMessage() {} +func (*LiveLocationMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{23} +} +func (m *LiveLocationMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_LiveLocationMessage.Unmarshal(m, b) +} +func (m *LiveLocationMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_LiveLocationMessage.Marshal(b, m, deterministic) +} +func (dst *LiveLocationMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiveLocationMessage.Merge(dst, src) +} +func (m *LiveLocationMessage) XXX_Size() int { + return xxx_messageInfo_LiveLocationMessage.Size(m) +} +func (m *LiveLocationMessage) XXX_DiscardUnknown() { + xxx_messageInfo_LiveLocationMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_LiveLocationMessage proto.InternalMessageInfo + +func (m *LiveLocationMessage) GetDegreesLatitude() float64 { + if m != nil && m.DegreesLatitude != nil { + return *m.DegreesLatitude + } + return 0 +} + +func (m *LiveLocationMessage) GetDegreesLongitude() float64 { + if m != nil && m.DegreesLongitude != nil { + return *m.DegreesLongitude + } + return 0 +} + +func (m *LiveLocationMessage) GetAccuracyInMeters() uint32 { + if m != nil && m.AccuracyInMeters != nil { + return *m.AccuracyInMeters + } + return 0 +} + +func (m *LiveLocationMessage) GetSpeedInMps() float32 { + if m != nil && m.SpeedInMps != nil { + return *m.SpeedInMps + } + return 0 +} + +func (m *LiveLocationMessage) GetDegreesClockwiseFromMagneticNorth() uint32 { + if m != nil && m.DegreesClockwiseFromMagneticNorth != nil { + return *m.DegreesClockwiseFromMagneticNorth + } + return 0 +} + +func (m *LiveLocationMessage) GetCaption() string { + if m != nil && m.Caption != nil { + return *m.Caption + } + return "" +} + +func (m *LiveLocationMessage) GetSequenceNumber() int64 { + if m != nil && m.SequenceNumber != nil { + return *m.SequenceNumber + } + return 0 +} + +func (m *LiveLocationMessage) GetJpegThumbnail() []byte { + if m != nil { + return m.JpegThumbnail + } + return nil +} + +func (m *LiveLocationMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type StickerMessage struct { + Url *string `protobuf:"bytes,1,opt,name=url" json:"url,omitempty"` + FileSha256 []byte `protobuf:"bytes,2,opt,name=fileSha256" json:"fileSha256,omitempty"` + FileEncSha256 []byte `protobuf:"bytes,3,opt,name=fileEncSha256" json:"fileEncSha256,omitempty"` + MediaKey []byte `protobuf:"bytes,4,opt,name=mediaKey" json:"mediaKey,omitempty"` + Mimetype *string `protobuf:"bytes,5,opt,name=mimetype" json:"mimetype,omitempty"` + Height *uint32 `protobuf:"varint,6,opt,name=height" json:"height,omitempty"` + Width *uint32 `protobuf:"varint,7,opt,name=width" json:"width,omitempty"` + DirectPath *string `protobuf:"bytes,8,opt,name=directPath" json:"directPath,omitempty"` + FileLength *uint64 `protobuf:"varint,9,opt,name=fileLength" json:"fileLength,omitempty"` + PngThumbnail []byte `protobuf:"bytes,16,opt,name=pngThumbnail" json:"pngThumbnail,omitempty"` + ContextInfo *ContextInfo `protobuf:"bytes,17,opt,name=contextInfo" json:"contextInfo,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StickerMessage) Reset() { *m = StickerMessage{} } +func (m *StickerMessage) String() string { return proto.CompactTextString(m) } +func (*StickerMessage) ProtoMessage() {} +func (*StickerMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{24} +} +func (m *StickerMessage) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_StickerMessage.Unmarshal(m, b) +} +func (m *StickerMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_StickerMessage.Marshal(b, m, deterministic) +} +func (dst *StickerMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_StickerMessage.Merge(dst, src) +} +func (m *StickerMessage) XXX_Size() int { + return xxx_messageInfo_StickerMessage.Size(m) +} +func (m *StickerMessage) XXX_DiscardUnknown() { + xxx_messageInfo_StickerMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_StickerMessage proto.InternalMessageInfo + +func (m *StickerMessage) GetUrl() string { + if m != nil && m.Url != nil { + return *m.Url + } + return "" +} + +func (m *StickerMessage) GetFileSha256() []byte { + if m != nil { + return m.FileSha256 + } + return nil +} + +func (m *StickerMessage) GetFileEncSha256() []byte { + if m != nil { + return m.FileEncSha256 + } + return nil +} + +func (m *StickerMessage) GetMediaKey() []byte { + if m != nil { + return m.MediaKey + } + return nil +} + +func (m *StickerMessage) GetMimetype() string { + if m != nil && m.Mimetype != nil { + return *m.Mimetype + } + return "" +} + +func (m *StickerMessage) GetHeight() uint32 { + if m != nil && m.Height != nil { + return *m.Height + } + return 0 +} + +func (m *StickerMessage) GetWidth() uint32 { + if m != nil && m.Width != nil { + return *m.Width + } + return 0 +} + +func (m *StickerMessage) GetDirectPath() string { + if m != nil && m.DirectPath != nil { + return *m.DirectPath + } + return "" +} + +func (m *StickerMessage) GetFileLength() uint64 { + if m != nil && m.FileLength != nil { + return *m.FileLength + } + return 0 +} + +func (m *StickerMessage) GetPngThumbnail() []byte { + if m != nil { + return m.PngThumbnail + } + return nil +} + +func (m *StickerMessage) GetContextInfo() *ContextInfo { + if m != nil { + return m.ContextInfo + } + return nil +} + +type Message struct { + Conversation *string `protobuf:"bytes,1,opt,name=conversation" json:"conversation,omitempty"` + SenderKeyDistributionMessage *SenderKeyDistributionMessage `protobuf:"bytes,2,opt,name=senderKeyDistributionMessage" json:"senderKeyDistributionMessage,omitempty"` + ImageMessage *ImageMessage `protobuf:"bytes,3,opt,name=imageMessage" json:"imageMessage,omitempty"` + ContactMessage *ContactMessage `protobuf:"bytes,4,opt,name=contactMessage" json:"contactMessage,omitempty"` + LocationMessage *LocationMessage `protobuf:"bytes,5,opt,name=locationMessage" json:"locationMessage,omitempty"` + ExtendedTextMessage *ExtendedTextMessage `protobuf:"bytes,6,opt,name=extendedTextMessage" json:"extendedTextMessage,omitempty"` + DocumentMessage *DocumentMessage `protobuf:"bytes,7,opt,name=documentMessage" json:"documentMessage,omitempty"` + AudioMessage *AudioMessage `protobuf:"bytes,8,opt,name=audioMessage" json:"audioMessage,omitempty"` + VideoMessage *VideoMessage `protobuf:"bytes,9,opt,name=videoMessage" json:"videoMessage,omitempty"` + Call *Call `protobuf:"bytes,10,opt,name=call" json:"call,omitempty"` + Chat *Chat `protobuf:"bytes,11,opt,name=chat" json:"chat,omitempty"` + ProtocolMessage *ProtocolMessage `protobuf:"bytes,12,opt,name=protocolMessage" json:"protocolMessage,omitempty"` + ContactsArrayMessage *ContactsArrayMessage `protobuf:"bytes,13,opt,name=contactsArrayMessage" json:"contactsArrayMessage,omitempty"` + HighlyStructuredMessage *HighlyStructuredMessage `protobuf:"bytes,14,opt,name=highlyStructuredMessage" json:"highlyStructuredMessage,omitempty"` + FastRatchetKeySenderKeyDistributionMessage *SenderKeyDistributionMessage `protobuf:"bytes,15,opt,name=fastRatchetKeySenderKeyDistributionMessage" json:"fastRatchetKeySenderKeyDistributionMessage,omitempty"` + SendPaymentMessage *SendPaymentMessage `protobuf:"bytes,16,opt,name=sendPaymentMessage" json:"sendPaymentMessage,omitempty"` + RequestPaymentMessage *RequestPaymentMessage `protobuf:"bytes,17,opt,name=requestPaymentMessage" json:"requestPaymentMessage,omitempty"` + LiveLocationMessage *LiveLocationMessage `protobuf:"bytes,18,opt,name=liveLocationMessage" json:"liveLocationMessage,omitempty"` + StickerMessage *StickerMessage `protobuf:"bytes,20,opt,name=stickerMessage" json:"stickerMessage,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Message) Reset() { *m = Message{} } +func (m *Message) String() string { return proto.CompactTextString(m) } +func (*Message) ProtoMessage() {} +func (*Message) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{25} +} +func (m *Message) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Message.Unmarshal(m, b) +} +func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Message.Marshal(b, m, deterministic) +} +func (dst *Message) XXX_Merge(src proto.Message) { + xxx_messageInfo_Message.Merge(dst, src) +} +func (m *Message) XXX_Size() int { + return xxx_messageInfo_Message.Size(m) +} +func (m *Message) XXX_DiscardUnknown() { + xxx_messageInfo_Message.DiscardUnknown(m) +} + +var xxx_messageInfo_Message proto.InternalMessageInfo + +func (m *Message) GetConversation() string { + if m != nil && m.Conversation != nil { + return *m.Conversation + } + return "" +} + +func (m *Message) GetSenderKeyDistributionMessage() *SenderKeyDistributionMessage { + if m != nil { + return m.SenderKeyDistributionMessage + } + return nil +} + +func (m *Message) GetImageMessage() *ImageMessage { + if m != nil { + return m.ImageMessage + } + return nil +} + +func (m *Message) GetContactMessage() *ContactMessage { + if m != nil { + return m.ContactMessage + } + return nil +} + +func (m *Message) GetLocationMessage() *LocationMessage { + if m != nil { + return m.LocationMessage + } + return nil +} + +func (m *Message) GetExtendedTextMessage() *ExtendedTextMessage { + if m != nil { + return m.ExtendedTextMessage + } + return nil +} + +func (m *Message) GetDocumentMessage() *DocumentMessage { + if m != nil { + return m.DocumentMessage + } + return nil +} + +func (m *Message) GetAudioMessage() *AudioMessage { + if m != nil { + return m.AudioMessage + } + return nil +} + +func (m *Message) GetVideoMessage() *VideoMessage { + if m != nil { + return m.VideoMessage + } + return nil +} + +func (m *Message) GetCall() *Call { + if m != nil { + return m.Call + } + return nil +} + +func (m *Message) GetChat() *Chat { + if m != nil { + return m.Chat + } + return nil +} + +func (m *Message) GetProtocolMessage() *ProtocolMessage { + if m != nil { + return m.ProtocolMessage + } + return nil +} + +func (m *Message) GetContactsArrayMessage() *ContactsArrayMessage { + if m != nil { + return m.ContactsArrayMessage + } + return nil +} + +func (m *Message) GetHighlyStructuredMessage() *HighlyStructuredMessage { + if m != nil { + return m.HighlyStructuredMessage + } + return nil +} + +func (m *Message) GetFastRatchetKeySenderKeyDistributionMessage() *SenderKeyDistributionMessage { + if m != nil { + return m.FastRatchetKeySenderKeyDistributionMessage + } + return nil +} + +func (m *Message) GetSendPaymentMessage() *SendPaymentMessage { + if m != nil { + return m.SendPaymentMessage + } + return nil +} + +func (m *Message) GetRequestPaymentMessage() *RequestPaymentMessage { + if m != nil { + return m.RequestPaymentMessage + } + return nil +} + +func (m *Message) GetLiveLocationMessage() *LiveLocationMessage { + if m != nil { + return m.LiveLocationMessage + } + return nil +} + +func (m *Message) GetStickerMessage() *StickerMessage { + if m != nil { + return m.StickerMessage + } + return nil +} + +type ContextInfo struct { + StanzaId *string `protobuf:"bytes,1,opt,name=stanzaId" json:"stanzaId,omitempty"` + Participant *string `protobuf:"bytes,2,opt,name=participant" json:"participant,omitempty"` + QuotedMessage []*Message `protobuf:"bytes,3,rep,name=quotedMessage" json:"quotedMessage,omitempty"` + RemoteJid *string `protobuf:"bytes,4,opt,name=remoteJid" json:"remoteJid,omitempty"` + MentionedJid []string `protobuf:"bytes,15,rep,name=mentionedJid" json:"mentionedJid,omitempty"` + ConversionSource *string `protobuf:"bytes,18,opt,name=conversionSource" json:"conversionSource,omitempty"` + ConversionData []byte `protobuf:"bytes,19,opt,name=conversionData" json:"conversionData,omitempty"` + ConversionDelaySeconds *uint32 `protobuf:"varint,20,opt,name=conversionDelaySeconds" json:"conversionDelaySeconds,omitempty"` + IsForwarded *bool `protobuf:"varint,22,opt,name=isForwarded" json:"isForwarded,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ContextInfo) Reset() { *m = ContextInfo{} } +func (m *ContextInfo) String() string { return proto.CompactTextString(m) } +func (*ContextInfo) ProtoMessage() {} +func (*ContextInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{26} +} +func (m *ContextInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ContextInfo.Unmarshal(m, b) +} +func (m *ContextInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ContextInfo.Marshal(b, m, deterministic) +} +func (dst *ContextInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContextInfo.Merge(dst, src) +} +func (m *ContextInfo) XXX_Size() int { + return xxx_messageInfo_ContextInfo.Size(m) +} +func (m *ContextInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ContextInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ContextInfo proto.InternalMessageInfo + +func (m *ContextInfo) GetStanzaId() string { + if m != nil && m.StanzaId != nil { + return *m.StanzaId + } + return "" +} + +func (m *ContextInfo) GetParticipant() string { + if m != nil && m.Participant != nil { + return *m.Participant + } + return "" +} + +func (m *ContextInfo) GetQuotedMessage() []*Message { + if m != nil { + return m.QuotedMessage + } + return nil +} + +func (m *ContextInfo) GetRemoteJid() string { + if m != nil && m.RemoteJid != nil { + return *m.RemoteJid + } + return "" +} + +func (m *ContextInfo) GetMentionedJid() []string { + if m != nil { + return m.MentionedJid + } + return nil +} + +func (m *ContextInfo) GetConversionSource() string { + if m != nil && m.ConversionSource != nil { + return *m.ConversionSource + } + return "" +} + +func (m *ContextInfo) GetConversionData() []byte { + if m != nil { + return m.ConversionData + } + return nil +} + +func (m *ContextInfo) GetConversionDelaySeconds() uint32 { + if m != nil && m.ConversionDelaySeconds != nil { + return *m.ConversionDelaySeconds + } + return 0 +} + +func (m *ContextInfo) GetIsForwarded() bool { + if m != nil && m.IsForwarded != nil { + return *m.IsForwarded + } + return false +} + +type InteractiveAnnotation struct { + PolygonVertices []*Point `protobuf:"bytes,1,rep,name=polygonVertices" json:"polygonVertices,omitempty"` + // Types that are valid to be assigned to Action: + // *InteractiveAnnotation_Location + Action isInteractiveAnnotation_Action `protobuf_oneof:"action"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *InteractiveAnnotation) Reset() { *m = InteractiveAnnotation{} } +func (m *InteractiveAnnotation) String() string { return proto.CompactTextString(m) } +func (*InteractiveAnnotation) ProtoMessage() {} +func (*InteractiveAnnotation) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{27} +} +func (m *InteractiveAnnotation) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_InteractiveAnnotation.Unmarshal(m, b) +} +func (m *InteractiveAnnotation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_InteractiveAnnotation.Marshal(b, m, deterministic) +} +func (dst *InteractiveAnnotation) XXX_Merge(src proto.Message) { + xxx_messageInfo_InteractiveAnnotation.Merge(dst, src) +} +func (m *InteractiveAnnotation) XXX_Size() int { + return xxx_messageInfo_InteractiveAnnotation.Size(m) +} +func (m *InteractiveAnnotation) XXX_DiscardUnknown() { + xxx_messageInfo_InteractiveAnnotation.DiscardUnknown(m) +} + +var xxx_messageInfo_InteractiveAnnotation proto.InternalMessageInfo + +type isInteractiveAnnotation_Action interface { + isInteractiveAnnotation_Action() +} + +type InteractiveAnnotation_Location struct { + Location *Location `protobuf:"bytes,2,opt,name=location,oneof"` +} + +func (*InteractiveAnnotation_Location) isInteractiveAnnotation_Action() {} + +func (m *InteractiveAnnotation) GetAction() isInteractiveAnnotation_Action { + if m != nil { + return m.Action + } + return nil +} + +func (m *InteractiveAnnotation) GetPolygonVertices() []*Point { + if m != nil { + return m.PolygonVertices + } + return nil +} + +func (m *InteractiveAnnotation) GetLocation() *Location { + if x, ok := m.GetAction().(*InteractiveAnnotation_Location); ok { + return x.Location + } + return nil +} + +// XXX_OneofFuncs is for the internal use of the proto package. +func (*InteractiveAnnotation) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { + return _InteractiveAnnotation_OneofMarshaler, _InteractiveAnnotation_OneofUnmarshaler, _InteractiveAnnotation_OneofSizer, []interface{}{ + (*InteractiveAnnotation_Location)(nil), + } +} + +func _InteractiveAnnotation_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { + m := msg.(*InteractiveAnnotation) + // action + switch x := m.Action.(type) { + case *InteractiveAnnotation_Location: + b.EncodeVarint(2<<3 | proto.WireBytes) + if err := b.EncodeMessage(x.Location); err != nil { + return err + } + case nil: + default: + return fmt.Errorf("InteractiveAnnotation.Action has unexpected type %T", x) + } + return nil +} + +func _InteractiveAnnotation_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { + m := msg.(*InteractiveAnnotation) + switch tag { + case 2: // action.location + if wire != proto.WireBytes { + return true, proto.ErrInternalBadWireType + } + msg := new(Location) + err := b.DecodeMessage(msg) + m.Action = &InteractiveAnnotation_Location{msg} + return true, err + default: + return false, nil + } +} + +func _InteractiveAnnotation_OneofSizer(msg proto.Message) (n int) { + m := msg.(*InteractiveAnnotation) + // action + switch x := m.Action.(type) { + case *InteractiveAnnotation_Location: + s := proto.Size(x.Location) + n += 1 // tag and wire + n += proto.SizeVarint(uint64(s)) + n += s + case nil: + default: + panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) + } + return n +} + +type Point struct { + X *float64 `protobuf:"fixed64,3,opt,name=x" json:"x,omitempty"` + Y *float64 `protobuf:"fixed64,4,opt,name=y" json:"y,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Point) Reset() { *m = Point{} } +func (m *Point) String() string { return proto.CompactTextString(m) } +func (*Point) ProtoMessage() {} +func (*Point) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{28} +} +func (m *Point) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Point.Unmarshal(m, b) +} +func (m *Point) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Point.Marshal(b, m, deterministic) +} +func (dst *Point) XXX_Merge(src proto.Message) { + xxx_messageInfo_Point.Merge(dst, src) +} +func (m *Point) XXX_Size() int { + return xxx_messageInfo_Point.Size(m) +} +func (m *Point) XXX_DiscardUnknown() { + xxx_messageInfo_Point.DiscardUnknown(m) +} + +var xxx_messageInfo_Point proto.InternalMessageInfo + +func (m *Point) GetX() float64 { + if m != nil && m.X != nil { + return *m.X + } + return 0 +} + +func (m *Point) GetY() float64 { + if m != nil && m.Y != nil { + return *m.Y + } + return 0 +} + +type Location struct { + DegreesLatitude *float64 `protobuf:"fixed64,1,opt,name=degreesLatitude" json:"degreesLatitude,omitempty"` + DegreesLongitude *float64 `protobuf:"fixed64,2,opt,name=degreesLongitude" json:"degreesLongitude,omitempty"` + Name *string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Location) Reset() { *m = Location{} } +func (m *Location) String() string { return proto.CompactTextString(m) } +func (*Location) ProtoMessage() {} +func (*Location) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{29} +} +func (m *Location) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Location.Unmarshal(m, b) +} +func (m *Location) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Location.Marshal(b, m, deterministic) +} +func (dst *Location) XXX_Merge(src proto.Message) { + xxx_messageInfo_Location.Merge(dst, src) +} +func (m *Location) XXX_Size() int { + return xxx_messageInfo_Location.Size(m) +} +func (m *Location) XXX_DiscardUnknown() { + xxx_messageInfo_Location.DiscardUnknown(m) +} + +var xxx_messageInfo_Location proto.InternalMessageInfo + +func (m *Location) GetDegreesLatitude() float64 { + if m != nil && m.DegreesLatitude != nil { + return *m.DegreesLatitude + } + return 0 +} + +func (m *Location) GetDegreesLongitude() float64 { + if m != nil && m.DegreesLongitude != nil { + return *m.DegreesLongitude + } + return 0 +} + +func (m *Location) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +type WebMessageInfo struct { + Key *MessageKey `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Message *Message `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` + MessageTimestamp *uint64 `protobuf:"varint,3,opt,name=messageTimestamp" json:"messageTimestamp,omitempty"` + Status *WebMessageInfo_STATUS `protobuf:"varint,4,opt,name=status,enum=proto.WebMessageInfo_STATUS,def=1" json:"status,omitempty"` + Participant *string `protobuf:"bytes,5,opt,name=participant" json:"participant,omitempty"` + Ignore *bool `protobuf:"varint,16,opt,name=ignore" json:"ignore,omitempty"` + Starred *bool `protobuf:"varint,17,opt,name=starred" json:"starred,omitempty"` + Broadcast *bool `protobuf:"varint,18,opt,name=broadcast" json:"broadcast,omitempty"` + PushName *string `protobuf:"bytes,19,opt,name=pushName" json:"pushName,omitempty"` + MediaCiphertextSha256 []byte `protobuf:"bytes,20,opt,name=mediaCiphertextSha256" json:"mediaCiphertextSha256,omitempty"` + Multicast *bool `protobuf:"varint,21,opt,name=multicast" json:"multicast,omitempty"` + UrlText *bool `protobuf:"varint,22,opt,name=urlText" json:"urlText,omitempty"` + UrlNumber *bool `protobuf:"varint,23,opt,name=urlNumber" json:"urlNumber,omitempty"` + MessageStubType *WebMessageInfo_STUBTYPE `protobuf:"varint,24,opt,name=messageStubType,enum=proto.WebMessageInfo_STUBTYPE" json:"messageStubType,omitempty"` + ClearMedia *bool `protobuf:"varint,25,opt,name=clearMedia" json:"clearMedia,omitempty"` + MessageStubParameters []string `protobuf:"bytes,26,rep,name=messageStubParameters" json:"messageStubParameters,omitempty"` + Duration *uint32 `protobuf:"varint,27,opt,name=duration" json:"duration,omitempty"` + Labels []string `protobuf:"bytes,28,rep,name=labels" json:"labels,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WebMessageInfo) Reset() { *m = WebMessageInfo{} } +func (m *WebMessageInfo) String() string { return proto.CompactTextString(m) } +func (*WebMessageInfo) ProtoMessage() {} +func (*WebMessageInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{30} +} +func (m *WebMessageInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WebMessageInfo.Unmarshal(m, b) +} +func (m *WebMessageInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WebMessageInfo.Marshal(b, m, deterministic) +} +func (dst *WebMessageInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_WebMessageInfo.Merge(dst, src) +} +func (m *WebMessageInfo) XXX_Size() int { + return xxx_messageInfo_WebMessageInfo.Size(m) +} +func (m *WebMessageInfo) XXX_DiscardUnknown() { + xxx_messageInfo_WebMessageInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_WebMessageInfo proto.InternalMessageInfo + +const Default_WebMessageInfo_Status WebMessageInfo_STATUS = WebMessageInfo_PENDING + +func (m *WebMessageInfo) GetKey() *MessageKey { + if m != nil { + return m.Key + } + return nil +} + +func (m *WebMessageInfo) GetMessage() *Message { + if m != nil { + return m.Message + } + return nil +} + +func (m *WebMessageInfo) GetMessageTimestamp() uint64 { + if m != nil && m.MessageTimestamp != nil { + return *m.MessageTimestamp + } + return 0 +} + +func (m *WebMessageInfo) GetStatus() WebMessageInfo_STATUS { + if m != nil && m.Status != nil { + return *m.Status + } + return Default_WebMessageInfo_Status +} + +func (m *WebMessageInfo) GetParticipant() string { + if m != nil && m.Participant != nil { + return *m.Participant + } + return "" +} + +func (m *WebMessageInfo) GetIgnore() bool { + if m != nil && m.Ignore != nil { + return *m.Ignore + } + return false +} + +func (m *WebMessageInfo) GetStarred() bool { + if m != nil && m.Starred != nil { + return *m.Starred + } + return false +} + +func (m *WebMessageInfo) GetBroadcast() bool { + if m != nil && m.Broadcast != nil { + return *m.Broadcast + } + return false +} + +func (m *WebMessageInfo) GetPushName() string { + if m != nil && m.PushName != nil { + return *m.PushName + } + return "" +} + +func (m *WebMessageInfo) GetMediaCiphertextSha256() []byte { + if m != nil { + return m.MediaCiphertextSha256 + } + return nil +} + +func (m *WebMessageInfo) GetMulticast() bool { + if m != nil && m.Multicast != nil { + return *m.Multicast + } + return false +} + +func (m *WebMessageInfo) GetUrlText() bool { + if m != nil && m.UrlText != nil { + return *m.UrlText + } + return false +} + +func (m *WebMessageInfo) GetUrlNumber() bool { + if m != nil && m.UrlNumber != nil { + return *m.UrlNumber + } + return false +} + +func (m *WebMessageInfo) GetMessageStubType() WebMessageInfo_STUBTYPE { + if m != nil && m.MessageStubType != nil { + return *m.MessageStubType + } + return WebMessageInfo_UNKNOWN +} + +func (m *WebMessageInfo) GetClearMedia() bool { + if m != nil && m.ClearMedia != nil { + return *m.ClearMedia + } + return false +} + +func (m *WebMessageInfo) GetMessageStubParameters() []string { + if m != nil { + return m.MessageStubParameters + } + return nil +} + +func (m *WebMessageInfo) GetDuration() uint32 { + if m != nil && m.Duration != nil { + return *m.Duration + } + return 0 +} + +func (m *WebMessageInfo) GetLabels() []string { + if m != nil { + return m.Labels + } + return nil +} + +type WebNotificationsInfo struct { + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` + UnreadChats *uint32 `protobuf:"varint,3,opt,name=unreadChats" json:"unreadChats,omitempty"` + NotifyMessageCount *uint32 `protobuf:"varint,4,opt,name=notifyMessageCount" json:"notifyMessageCount,omitempty"` + NotifyMessages []*Message `protobuf:"bytes,5,rep,name=notifyMessages" json:"notifyMessages,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WebNotificationsInfo) Reset() { *m = WebNotificationsInfo{} } +func (m *WebNotificationsInfo) String() string { return proto.CompactTextString(m) } +func (*WebNotificationsInfo) ProtoMessage() {} +func (*WebNotificationsInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{31} +} +func (m *WebNotificationsInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WebNotificationsInfo.Unmarshal(m, b) +} +func (m *WebNotificationsInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WebNotificationsInfo.Marshal(b, m, deterministic) +} +func (dst *WebNotificationsInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_WebNotificationsInfo.Merge(dst, src) +} +func (m *WebNotificationsInfo) XXX_Size() int { + return xxx_messageInfo_WebNotificationsInfo.Size(m) +} +func (m *WebNotificationsInfo) XXX_DiscardUnknown() { + xxx_messageInfo_WebNotificationsInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_WebNotificationsInfo proto.InternalMessageInfo + +func (m *WebNotificationsInfo) GetTimestamp() uint64 { + if m != nil && m.Timestamp != nil { + return *m.Timestamp + } + return 0 +} + +func (m *WebNotificationsInfo) GetUnreadChats() uint32 { + if m != nil && m.UnreadChats != nil { + return *m.UnreadChats + } + return 0 +} + +func (m *WebNotificationsInfo) GetNotifyMessageCount() uint32 { + if m != nil && m.NotifyMessageCount != nil { + return *m.NotifyMessageCount + } + return 0 +} + +func (m *WebNotificationsInfo) GetNotifyMessages() []*Message { + if m != nil { + return m.NotifyMessages + } + return nil +} + +type NotificationMessageInfo struct { + Key *MessageKey `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Message *Message `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` + MessageTimestamp *uint64 `protobuf:"varint,3,opt,name=messageTimestamp" json:"messageTimestamp,omitempty"` + Participant *string `protobuf:"bytes,4,opt,name=participant" json:"participant,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NotificationMessageInfo) Reset() { *m = NotificationMessageInfo{} } +func (m *NotificationMessageInfo) String() string { return proto.CompactTextString(m) } +func (*NotificationMessageInfo) ProtoMessage() {} +func (*NotificationMessageInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{32} +} +func (m *NotificationMessageInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_NotificationMessageInfo.Unmarshal(m, b) +} +func (m *NotificationMessageInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_NotificationMessageInfo.Marshal(b, m, deterministic) +} +func (dst *NotificationMessageInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_NotificationMessageInfo.Merge(dst, src) +} +func (m *NotificationMessageInfo) XXX_Size() int { + return xxx_messageInfo_NotificationMessageInfo.Size(m) +} +func (m *NotificationMessageInfo) XXX_DiscardUnknown() { + xxx_messageInfo_NotificationMessageInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_NotificationMessageInfo proto.InternalMessageInfo + +func (m *NotificationMessageInfo) GetKey() *MessageKey { + if m != nil { + return m.Key + } + return nil +} + +func (m *NotificationMessageInfo) GetMessage() *Message { + if m != nil { + return m.Message + } + return nil +} + +func (m *NotificationMessageInfo) GetMessageTimestamp() uint64 { + if m != nil && m.MessageTimestamp != nil { + return *m.MessageTimestamp + } + return 0 +} + +func (m *NotificationMessageInfo) GetParticipant() string { + if m != nil && m.Participant != nil { + return *m.Participant + } + return "" +} + +type TabletNotificationsInfo struct { + Timestamp *uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` + UnreadChats *uint32 `protobuf:"varint,3,opt,name=unreadChats" json:"unreadChats,omitempty"` + NotifyMessageCount *uint32 `protobuf:"varint,4,opt,name=notifyMessageCount" json:"notifyMessageCount,omitempty"` + NotifyMessage []*Message `protobuf:"bytes,5,rep,name=notifyMessage" json:"notifyMessage,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TabletNotificationsInfo) Reset() { *m = TabletNotificationsInfo{} } +func (m *TabletNotificationsInfo) String() string { return proto.CompactTextString(m) } +func (*TabletNotificationsInfo) ProtoMessage() {} +func (*TabletNotificationsInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{33} +} +func (m *TabletNotificationsInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TabletNotificationsInfo.Unmarshal(m, b) +} +func (m *TabletNotificationsInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TabletNotificationsInfo.Marshal(b, m, deterministic) +} +func (dst *TabletNotificationsInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_TabletNotificationsInfo.Merge(dst, src) +} +func (m *TabletNotificationsInfo) XXX_Size() int { + return xxx_messageInfo_TabletNotificationsInfo.Size(m) +} +func (m *TabletNotificationsInfo) XXX_DiscardUnknown() { + xxx_messageInfo_TabletNotificationsInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_TabletNotificationsInfo proto.InternalMessageInfo + +func (m *TabletNotificationsInfo) GetTimestamp() uint64 { + if m != nil && m.Timestamp != nil { + return *m.Timestamp + } + return 0 +} + +func (m *TabletNotificationsInfo) GetUnreadChats() uint32 { + if m != nil && m.UnreadChats != nil { + return *m.UnreadChats + } + return 0 +} + +func (m *TabletNotificationsInfo) GetNotifyMessageCount() uint32 { + if m != nil && m.NotifyMessageCount != nil { + return *m.NotifyMessageCount + } + return 0 +} + +func (m *TabletNotificationsInfo) GetNotifyMessage() []*Message { + if m != nil { + return m.NotifyMessage + } + return nil +} + +type WebFeatures struct { + LabelsDisplay *WebFeatures_FLAG `protobuf:"varint,1,opt,name=labelsDisplay,enum=proto.WebFeatures_FLAG" json:"labelsDisplay,omitempty"` + VoipIndividualOutgoing *WebFeatures_FLAG `protobuf:"varint,2,opt,name=voipIndividualOutgoing,enum=proto.WebFeatures_FLAG" json:"voipIndividualOutgoing,omitempty"` + GroupsV3 *WebFeatures_FLAG `protobuf:"varint,3,opt,name=groupsV3,enum=proto.WebFeatures_FLAG" json:"groupsV3,omitempty"` + GroupsV3Create *WebFeatures_FLAG `protobuf:"varint,4,opt,name=groupsV3Create,enum=proto.WebFeatures_FLAG" json:"groupsV3Create,omitempty"` + ChangeNumberV2 *WebFeatures_FLAG `protobuf:"varint,5,opt,name=changeNumberV2,enum=proto.WebFeatures_FLAG" json:"changeNumberV2,omitempty"` + QueryStatusV3Thumbnail *WebFeatures_FLAG `protobuf:"varint,6,opt,name=queryStatusV3Thumbnail,enum=proto.WebFeatures_FLAG" json:"queryStatusV3Thumbnail,omitempty"` + LiveLocations *WebFeatures_FLAG `protobuf:"varint,7,opt,name=liveLocations,enum=proto.WebFeatures_FLAG" json:"liveLocations,omitempty"` + QueryVname *WebFeatures_FLAG `protobuf:"varint,8,opt,name=queryVname,enum=proto.WebFeatures_FLAG" json:"queryVname,omitempty"` + VoipIndividualIncoming *WebFeatures_FLAG `protobuf:"varint,9,opt,name=voipIndividualIncoming,enum=proto.WebFeatures_FLAG" json:"voipIndividualIncoming,omitempty"` + QuickRepliesQuery *WebFeatures_FLAG `protobuf:"varint,10,opt,name=quickRepliesQuery,enum=proto.WebFeatures_FLAG" json:"quickRepliesQuery,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *WebFeatures) Reset() { *m = WebFeatures{} } +func (m *WebFeatures) String() string { return proto.CompactTextString(m) } +func (*WebFeatures) ProtoMessage() {} +func (*WebFeatures) Descriptor() ([]byte, []int) { + return fileDescriptor_def_131d1935231ace52, []int{34} +} +func (m *WebFeatures) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_WebFeatures.Unmarshal(m, b) +} +func (m *WebFeatures) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_WebFeatures.Marshal(b, m, deterministic) +} +func (dst *WebFeatures) XXX_Merge(src proto.Message) { + xxx_messageInfo_WebFeatures.Merge(dst, src) +} +func (m *WebFeatures) XXX_Size() int { + return xxx_messageInfo_WebFeatures.Size(m) +} +func (m *WebFeatures) XXX_DiscardUnknown() { + xxx_messageInfo_WebFeatures.DiscardUnknown(m) +} + +var xxx_messageInfo_WebFeatures proto.InternalMessageInfo + +func (m *WebFeatures) GetLabelsDisplay() WebFeatures_FLAG { + if m != nil && m.LabelsDisplay != nil { + return *m.LabelsDisplay + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetVoipIndividualOutgoing() WebFeatures_FLAG { + if m != nil && m.VoipIndividualOutgoing != nil { + return *m.VoipIndividualOutgoing + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetGroupsV3() WebFeatures_FLAG { + if m != nil && m.GroupsV3 != nil { + return *m.GroupsV3 + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetGroupsV3Create() WebFeatures_FLAG { + if m != nil && m.GroupsV3Create != nil { + return *m.GroupsV3Create + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetChangeNumberV2() WebFeatures_FLAG { + if m != nil && m.ChangeNumberV2 != nil { + return *m.ChangeNumberV2 + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetQueryStatusV3Thumbnail() WebFeatures_FLAG { + if m != nil && m.QueryStatusV3Thumbnail != nil { + return *m.QueryStatusV3Thumbnail + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetLiveLocations() WebFeatures_FLAG { + if m != nil && m.LiveLocations != nil { + return *m.LiveLocations + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetQueryVname() WebFeatures_FLAG { + if m != nil && m.QueryVname != nil { + return *m.QueryVname + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetVoipIndividualIncoming() WebFeatures_FLAG { + if m != nil && m.VoipIndividualIncoming != nil { + return *m.VoipIndividualIncoming + } + return WebFeatures_NOT_IMPLEMENTED +} + +func (m *WebFeatures) GetQuickRepliesQuery() WebFeatures_FLAG { + if m != nil && m.QuickRepliesQuery != nil { + return *m.QuickRepliesQuery + } + return WebFeatures_NOT_IMPLEMENTED +} + +func init() { + proto.RegisterType((*FingerprintData)(nil), "proto.FingerprintData") + proto.RegisterType((*CombinedFingerprint)(nil), "proto.CombinedFingerprint") + proto.RegisterType((*MessageKey)(nil), "proto.MessageKey") + proto.RegisterType((*SenderKeyDistributionMessage)(nil), "proto.SenderKeyDistributionMessage") + proto.RegisterType((*ImageMessage)(nil), "proto.ImageMessage") + proto.RegisterType((*ContactMessage)(nil), "proto.ContactMessage") + proto.RegisterType((*LocationMessage)(nil), "proto.LocationMessage") + proto.RegisterType((*ExtendedTextMessage)(nil), "proto.ExtendedTextMessage") + proto.RegisterType((*DocumentMessage)(nil), "proto.DocumentMessage") + proto.RegisterType((*AudioMessage)(nil), "proto.AudioMessage") + proto.RegisterType((*VideoMessage)(nil), "proto.VideoMessage") + proto.RegisterType((*Call)(nil), "proto.Call") + proto.RegisterType((*Chat)(nil), "proto.Chat") + proto.RegisterType((*ProtocolMessage)(nil), "proto.ProtocolMessage") + proto.RegisterType((*ContactsArrayMessage)(nil), "proto.ContactsArrayMessage") + proto.RegisterType((*HSMCurrency)(nil), "proto.HSMCurrency") + proto.RegisterType((*HSMDateTimeComponent)(nil), "proto.HSMDateTimeComponent") + proto.RegisterType((*HSMDateTimeUnixEpoch)(nil), "proto.HSMDateTimeUnixEpoch") + proto.RegisterType((*HSMDateTime)(nil), "proto.HSMDateTime") + proto.RegisterType((*HSMLocalizableParameter)(nil), "proto.HSMLocalizableParameter") + proto.RegisterType((*HighlyStructuredMessage)(nil), "proto.HighlyStructuredMessage") + proto.RegisterType((*SendPaymentMessage)(nil), "proto.SendPaymentMessage") + proto.RegisterType((*RequestPaymentMessage)(nil), "proto.RequestPaymentMessage") + proto.RegisterType((*LiveLocationMessage)(nil), "proto.LiveLocationMessage") + proto.RegisterType((*StickerMessage)(nil), "proto.StickerMessage") + proto.RegisterType((*Message)(nil), "proto.Message") + proto.RegisterType((*ContextInfo)(nil), "proto.ContextInfo") + proto.RegisterType((*InteractiveAnnotation)(nil), "proto.InteractiveAnnotation") + proto.RegisterType((*Point)(nil), "proto.Point") + proto.RegisterType((*Location)(nil), "proto.Location") + proto.RegisterType((*WebMessageInfo)(nil), "proto.WebMessageInfo") + proto.RegisterType((*WebNotificationsInfo)(nil), "proto.WebNotificationsInfo") + proto.RegisterType((*NotificationMessageInfo)(nil), "proto.NotificationMessageInfo") + proto.RegisterType((*TabletNotificationsInfo)(nil), "proto.TabletNotificationsInfo") + proto.RegisterType((*WebFeatures)(nil), "proto.WebFeatures") + proto.RegisterEnum("proto.ExtendedTextMessage_FONTTYPE", ExtendedTextMessage_FONTTYPE_name, ExtendedTextMessage_FONTTYPE_value) + proto.RegisterEnum("proto.VideoMessage_ATTRIBUTION", VideoMessage_ATTRIBUTION_name, VideoMessage_ATTRIBUTION_value) + proto.RegisterEnum("proto.ProtocolMessage_TYPE", ProtocolMessage_TYPE_name, ProtocolMessage_TYPE_value) + proto.RegisterEnum("proto.HSMDateTimeComponent_DAYOFWEEKTYPE", HSMDateTimeComponent_DAYOFWEEKTYPE_name, HSMDateTimeComponent_DAYOFWEEKTYPE_value) + proto.RegisterEnum("proto.HSMDateTimeComponent_CALENDARTYPE", HSMDateTimeComponent_CALENDARTYPE_name, HSMDateTimeComponent_CALENDARTYPE_value) + proto.RegisterEnum("proto.WebMessageInfo_STATUS", WebMessageInfo_STATUS_name, WebMessageInfo_STATUS_value) + proto.RegisterEnum("proto.WebMessageInfo_STUBTYPE", WebMessageInfo_STUBTYPE_name, WebMessageInfo_STUBTYPE_value) + proto.RegisterEnum("proto.WebFeatures_FLAG", WebFeatures_FLAG_name, WebFeatures_FLAG_value) +} + +func init() { proto.RegisterFile("def.proto", fileDescriptor_def_131d1935231ace52) } + +var fileDescriptor_def_131d1935231ace52 = []byte{ + // 3724 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x3a, 0x4d, 0x6f, 0xe3, 0x48, + 0x76, 0xad, 0x0f, 0xdb, 0xd2, 0x93, 0x2c, 0xd1, 0x65, 0xbb, 0xad, 0xe9, 0xf6, 0xce, 0x78, 0xd9, + 0x9b,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8e, 0x74, 0x3d, 0x5a, 0xd0, 0x10, 0x2f, 0xd1, 0xa3, + 0x16, 0x6c, 0x05, 0x74, 0xe4, 0x33, 0x9a, 0x16, 0x52, 0x78, 0x50, 0xc8, 0x32, 0x83, 0xcc, 0x00, + 0x2e, 0x68, 0x18, 0x92, 0x01, 0xe5, 0x27, 0xdd, 0x87, 0x72, 0x44, 0xf2, 0xd2, 0xb1, 0x13, 0x3b, + 0xcc, 0x00, 0xe8, 0x31, 0xac, 0xdf, 0x06, 0xfe, 0xe8, 0x82, 0x0a, 0x5d, 0x4b, 0x38, 0x5e, 0xa1, + 0x1a, 0xe4, 0x1d, 0x5b, 0x6c, 0x5d, 0xc6, 0x79, 0xc7, 0x46, 0x07, 0x50, 0x19, 0x93, 0x80, 0x39, + 0x96, 0x33, 0x26, 0x1e, 0x6b, 0x14, 0x05, 0x22, 0x0d, 0x92, 0xff, 0x2c, 0x07, 0xfb, 0x5d, 0xea, + 0xd9, 0x34, 0x78, 0x45, 0xa7, 0x2d, 0x27, 0x64, 0x81, 0x73, 0x33, 0x61, 0x8e, 0xef, 0xc5, 0xba, + 0x70, 0xd3, 0x0d, 0x02, 0x7f, 0x32, 0xd6, 0x12, 0x35, 0x92, 0x25, 0xea, 0xc0, 0x33, 0xf2, 0xc6, + 0x77, 0x7d, 0xe6, 0x3e, 0x24, 0x40, 0x68, 0x58, 0xc5, 0xef, 0x42, 0x2a, 0xff, 0x4d, 0x11, 0xaa, + 0xda, 0x88, 0x0c, 0x68, 0xb2, 0xb9, 0x04, 0x85, 0x49, 0xe0, 0xc6, 0x1b, 0xf3, 0x9f, 0xe8, 0x09, + 0x94, 0x46, 0xce, 0x88, 0xb2, 0xe9, 0x98, 0xc6, 0xfe, 0x9f, 0xad, 0xb9, 0xaa, 0x16, 0x19, 0x73, + 0x81, 0xb1, 0x09, 0x92, 0x25, 0xbf, 0x37, 0xb7, 0x8e, 0x4b, 0xbb, 0x43, 0x72, 0xfc, 0xbb, 0x5f, + 0x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x18, 0x71, 0x51, 0x67, 0xe3, 0x99, 0xfc, 0x03, + 0xe3, 0x99, 0x43, 0xd8, 0x18, 0x3d, 0xd8, 0x12, 0x24, 0x68, 0xae, 0x61, 0xfc, 0xd3, 0x9c, 0x35, + 0xb0, 0x05, 0x51, 0xbd, 0x2c, 0xc1, 0xd1, 0xd7, 0xb0, 0x1e, 0x32, 0xc2, 0x26, 0x51, 0x71, 0x5b, + 0x9b, 0x65, 0x81, 0xac, 0x86, 0x47, 0x5d, 0x53, 0x31, 0x7b, 0xdd, 0x5f, 0x6c, 0x74, 0x54, 0xbd, + 0xa5, 0xe9, 0x67, 0x38, 0x66, 0x5a, 0x0c, 0xa3, 0xb5, 0xe5, 0x30, 0x7a, 0x0c, 0xeb, 0xce, 0xc0, + 0xf3, 0x83, 0x28, 0x69, 0x95, 0x70, 0xbc, 0x12, 0xd3, 0x53, 0x46, 0x82, 0x80, 0xda, 0x22, 0xff, + 0x94, 0x70, 0xb2, 0xe4, 0x21, 0x74, 0x13, 0xf8, 0xc4, 0xb6, 0x48, 0xc8, 0xc4, 0xcd, 0x2f, 0xe1, + 0x39, 0x80, 0x07, 0xf5, 0x78, 0x12, 0x0e, 0x45, 0xe3, 0xb7, 0x1d, 0x05, 0x75, 0xb2, 0x46, 0x2f, + 0x60, 0x57, 0x94, 0x89, 0x4d, 0x67, 0x3c, 0xa4, 0x01, 0xcf, 0x03, 0x71, 0x91, 0xb9, 0x23, 0xa2, + 0x62, 0x35, 0x92, 0xef, 0x37, 0x9a, 0xb8, 0xcc, 0x11, 0xfb, 0xed, 0x46, 0xfb, 0xcd, 0x00, 0x5c, + 0xcf, 0x49, 0xe0, 0x8a, 0xcf, 0x65, 0xd1, 0xf5, 0x4f, 0x96, 0x9c, 0x6f, 0x12, 0xb8, 0x71, 0x39, + 0xbe, 0x17, 0xf1, 0xcd, 0x00, 0xe8, 0x1c, 0xea, 0xb1, 0xb1, 0xbb, 0x6c, 0x72, 0x63, 0xf2, 0x6a, + 0x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, 0x90, 0x7f, 0x01, 0x45, 0x8e, + 0x8a, 0xfe, 0xa7, 0xc9, 0xec, 0x6b, 0x17, 0x9d, 0xb6, 0x7a, 0xa1, 0xea, 0x3c, 0xdd, 0x3e, 0xe2, + 0x75, 0x59, 0x1a, 0x90, 0x43, 0x55, 0x28, 0x19, 0xe2, 0x75, 0x54, 0xda, 0x52, 0xfe, 0xbf, 0x03, + 0x00, 0x00, 0xff, 0xff, 0x11, 0x17, 0x9b, 0xf6, 0x8b, 0x2c, 0x00, 0x00, +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.proto b/vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.proto new file mode 100644 index 00000000..a885973d --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/binary/proto/def.proto @@ -0,0 +1,417 @@ +syntax = "proto2"; +package proto; + +message FingerprintData { + optional string publicKey = 1; + optional string identifier = 2; +} + +message CombinedFingerprint { + optional uint32 version = 1; + optional FingerprintData localFingerprint = 2; + optional FingerprintData remoteFingerprint = 3; +} + +message MessageKey { + optional string remoteJid = 1; + optional bool fromMe = 2; + optional string id = 3; + optional string participant = 4; +} + +message SenderKeyDistributionMessage { + optional string groupId = 1; + optional bytes axolotlSenderKeyDistributionMessage = 2; +} + +message ImageMessage { + optional string url = 1; + optional string mimetype = 2; + optional string caption = 3; + optional bytes fileSha256 = 4; + optional uint64 fileLength = 5; + optional uint32 height = 6; + optional uint32 width = 7; + optional bytes mediaKey = 8; + optional bytes fileEncSha256 = 9; + repeated InteractiveAnnotation interactiveAnnotations = 10; + optional string directPath = 11; + optional bytes jpegThumbnail = 16; + optional ContextInfo contextInfo = 17; + optional bytes firstScanSidecar = 18; + optional uint32 firstScanLength = 19; +} + +message ContactMessage { + optional string displayName = 1; + optional string vcard = 16; + optional ContextInfo contextInfo = 17; +} + +message LocationMessage { + optional double degreesLatitude = 1; + optional double degreesLongitude = 2; + optional string name = 3; + optional string address = 4; + optional string url = 5; + optional bytes jpegThumbnail = 16; + optional ContextInfo contextInfo = 17; +} + +message ExtendedTextMessage { + optional string text = 1; + optional string matchedText = 2; + optional string canonicalUrl = 4; + optional string description = 5; + optional string title = 6; + optional fixed32 textArgb = 7; + optional fixed32 backgroundArgb = 8; + enum FONTTYPE { + SANS_SERIF = 0; + SERIF = 1; + NORICAN_REGULAR = 2; + BRYNDAN_WRITE = 3; + BEBASNEUE_REGULAR = 4; + OSWALD_HEAVY = 5; + } + optional FONTTYPE font = 9; + optional bytes jpegThumbnail = 16; + optional ContextInfo contextInfo = 17; +} + +message DocumentMessage { + optional string url = 1; + optional string mimetype = 2; + optional string title = 3; + optional bytes fileSha256 = 4; + optional uint64 fileLength = 5; + optional uint32 pageCount = 6; + optional bytes mediaKey = 7; + optional string fileName = 8; + optional bytes fileEncSha256 = 9; + optional string directPath = 10; + optional bytes jpegThumbnail = 16; + optional ContextInfo contextInfo = 17; +} + +message AudioMessage { + optional string url = 1; + optional string mimetype = 2; + optional bytes fileSha256 = 3; + optional uint64 fileLength = 4; + optional uint32 seconds = 5; + optional bool ptt = 6; + optional bytes mediaKey = 7; + optional bytes fileEncSha256 = 8; + optional string directPath = 9; + optional ContextInfo contextInfo = 17; + optional bytes streamingSidecar = 18; +} + +message VideoMessage { + optional string url = 1; + optional string mimetype = 2; + optional bytes fileSha256 = 3; + optional uint64 fileLength = 4; + optional uint32 seconds = 5; + optional bytes mediaKey = 6; + optional string caption = 7; + optional bool gifPlayback = 8; + optional uint32 height = 9; + optional uint32 width = 10; + optional bytes fileEncSha256 = 11; + repeated InteractiveAnnotation interactiveAnnotations = 12; + optional string directPath = 13; + optional bytes jpegThumbnail = 16; + optional ContextInfo contextInfo = 17; + optional bytes streamingSidecar = 18; + enum ATTRIBUTION { + NONE = 0; + GIPHY = 1; + TENOR = 2; + } + optional ATTRIBUTION gifAttribution = 19; +} + +message Call { + optional bytes callKey = 1; +} + +message Chat { + optional string displayName = 1; + optional string id = 2; +} + +message ProtocolMessage { + optional MessageKey key = 1; + enum TYPE { + REVOKE = 0; + } + optional TYPE type = 2; +} + +message ContactsArrayMessage { + optional string displayName = 1; + repeated ContactMessage contacts = 2; + optional ContextInfo contextInfo = 17; +} + +message HSMCurrency { + optional string currencyCode = 1; + optional int64 amount1000 = 2; +} + +message HSMDateTimeComponent { + enum DAYOFWEEKTYPE { + MONDAY = 1; + TUESDAY = 2; + WEDNESDAY = 3; + THURSDAY = 4; + FRIDAY = 5; + SATURDAY = 6; + SUNDAY = 7; + } + optional DAYOFWEEKTYPE dayOfWeek = 1; + optional uint32 year = 2; + optional uint32 month = 3; + optional uint32 dayOfMonth = 4; + optional uint32 hour = 5; + optional uint32 minute = 6; + enum CALENDARTYPE { + GREGORIAN = 1; + SOLAR_HIJRI = 2; + } + optional CALENDARTYPE calendar = 7; +} + +message HSMDateTimeUnixEpoch { + optional int64 timestamp = 1; +} + +message HSMDateTime { + oneof datetimeOneof { + HSMDateTimeComponent component = 1; + HSMDateTimeUnixEpoch unixEpoch = 2; + } +} + +message HSMLocalizableParameter { + optional string default = 1; + oneof paramOneof { + HSMCurrency currency = 2; + HSMDateTime dateTime = 3; + } +} + +message HighlyStructuredMessage { + optional string namespace = 1; + optional string elementName = 2; + repeated string params = 3; + optional string fallbackLg = 4; + optional string fallbackLc = 5; + repeated HSMLocalizableParameter localizableParams = 6; +} + +message SendPaymentMessage { + optional Message noteMessage = 2; +} + +message RequestPaymentMessage { + optional string currencyCodeIso4217 = 1; + optional uint64 amount1000 = 2; + optional string requestFrom = 3; + optional Message noteMessage = 4; +} + +message LiveLocationMessage { + optional double degreesLatitude = 1; + optional double degreesLongitude = 2; + optional uint32 accuracyInMeters = 3; + optional float speedInMps = 4; + optional uint32 degreesClockwiseFromMagneticNorth = 5; + optional string caption = 6; + optional int64 sequenceNumber = 7; + optional bytes jpegThumbnail = 16; + optional ContextInfo contextInfo = 17; +} + +message StickerMessage { + optional string url = 1; + optional bytes fileSha256 = 2; + optional bytes fileEncSha256 = 3; + optional bytes mediaKey = 4; + optional string mimetype = 5; + optional uint32 height = 6; + optional uint32 width = 7; + optional string directPath = 8; + optional uint64 fileLength = 9; + optional bytes pngThumbnail = 16; + optional ContextInfo contextInfo = 17; +} + +message Message { + optional string conversation = 1; + optional SenderKeyDistributionMessage senderKeyDistributionMessage = 2; + optional ImageMessage imageMessage = 3; + optional ContactMessage contactMessage = 4; + optional LocationMessage locationMessage = 5; + optional ExtendedTextMessage extendedTextMessage = 6; + optional DocumentMessage documentMessage = 7; + optional AudioMessage audioMessage = 8; + optional VideoMessage videoMessage = 9; + optional Call call = 10; + optional Chat chat = 11; + optional ProtocolMessage protocolMessage = 12; + optional ContactsArrayMessage contactsArrayMessage = 13; + optional HighlyStructuredMessage highlyStructuredMessage = 14; + optional SenderKeyDistributionMessage fastRatchetKeySenderKeyDistributionMessage = 15; + optional SendPaymentMessage sendPaymentMessage = 16; + optional RequestPaymentMessage requestPaymentMessage = 17; + optional LiveLocationMessage liveLocationMessage = 18; + optional StickerMessage stickerMessage = 20; +} + +message ContextInfo { + optional string stanzaId = 1; + optional string participant = 2; + repeated Message quotedMessage = 3; + optional string remoteJid = 4; + repeated string mentionedJid = 15; + optional string conversionSource = 18; + optional bytes conversionData = 19; + optional uint32 conversionDelaySeconds = 20; + optional bool isForwarded = 22; + reserved 16, 17; +} + +message InteractiveAnnotation { + repeated Point polygonVertices = 1; + oneof action { + Location location = 2; + } +} + +message Point { + optional double x = 3; + optional double y = 4; +} + +message Location { + optional double degreesLatitude = 1; + optional double degreesLongitude = 2; + optional string name = 3; +} + +message WebMessageInfo { + required MessageKey key = 1; + optional Message message = 2; + optional uint64 messageTimestamp = 3; + enum STATUS { + ERROR = 0; + PENDING = 1; + SERVER_ACK = 2; + DELIVERY_ACK = 3; + READ = 4; + PLAYED = 5; + } + optional STATUS status = 4 [default=PENDING]; + optional string participant = 5; + optional bool ignore = 16; + optional bool starred = 17; + optional bool broadcast = 18; + optional string pushName = 19; + optional bytes mediaCiphertextSha256 = 20; + optional bool multicast = 21; + optional bool urlText = 22; + optional bool urlNumber = 23; + enum STUBTYPE { + UNKNOWN = 0; + REVOKE = 1; + CIPHERTEXT = 2; + FUTUREPROOF = 3; + NON_VERIFIED_TRANSITION = 4; + UNVERIFIED_TRANSITION = 5; + VERIFIED_TRANSITION = 6; + VERIFIED_LOW_UNKNOWN = 7; + VERIFIED_HIGH = 8; + VERIFIED_INITIAL_UNKNOWN = 9; + VERIFIED_INITIAL_LOW = 10; + VERIFIED_INITIAL_HIGH = 11; + VERIFIED_TRANSITION_ANY_TO_NONE = 12; + VERIFIED_TRANSITION_ANY_TO_HIGH = 13; + VERIFIED_TRANSITION_HIGH_TO_LOW = 14; + VERIFIED_TRANSITION_HIGH_TO_UNKNOWN = 15; + VERIFIED_TRANSITION_UNKNOWN_TO_LOW = 16; + VERIFIED_TRANSITION_LOW_TO_UNKNOWN = 17; + VERIFIED_TRANSITION_NONE_TO_LOW = 18; + VERIFIED_TRANSITION_NONE_TO_UNKNOWN = 19; + GROUP_CREATE = 20; + GROUP_CHANGE_SUBJECT = 21; + GROUP_CHANGE_ICON = 22; + GROUP_CHANGE_INVITE_LINK = 23; + GROUP_CHANGE_DESCRIPTION = 24; + GROUP_CHANGE_RESTRICT = 25; + GROUP_CHANGE_ANNOUNCE = 26; + GROUP_PARTICIPANT_ADD = 27; + GROUP_PARTICIPANT_REMOVE = 28; + GROUP_PARTICIPANT_PROMOTE = 29; + GROUP_PARTICIPANT_DEMOTE = 30; + GROUP_PARTICIPANT_INVITE = 31; + GROUP_PARTICIPANT_LEAVE = 32; + GROUP_PARTICIPANT_CHANGE_NUMBER = 33; + BROADCAST_CREATE = 34; + BROADCAST_ADD = 35; + BROADCAST_REMOVE = 36; + GENERIC_NOTIFICATION = 37; + E2E_IDENTITY_CHANGED = 38; + E2E_ENCRYPTED = 39; + CALL_MISSED_VOICE = 40; + CALL_MISSED_VIDEO = 41; + INDIVIDUAL_CHANGE_NUMBER = 42; + GROUP_DELETE = 43; + } + optional STUBTYPE messageStubType = 24; + optional bool clearMedia = 25; + repeated string messageStubParameters = 26; + optional uint32 duration = 27; + repeated string labels = 28; +} + +message WebNotificationsInfo { + optional uint64 timestamp = 2; + optional uint32 unreadChats = 3; + optional uint32 notifyMessageCount = 4; + repeated Message notifyMessages = 5; +} + +message NotificationMessageInfo { + optional MessageKey key = 1; + optional Message message = 2; + optional uint64 messageTimestamp = 3; + optional string participant = 4; +} + +message TabletNotificationsInfo { + optional uint64 timestamp = 2; + optional uint32 unreadChats = 3; + optional uint32 notifyMessageCount = 4; + repeated Message notifyMessage = 5; +} + +message WebFeatures { + enum FLAG { + NOT_IMPLEMENTED = 0; + IMPLEMENTED = 1; + OPTIONAL = 2; + } + optional FLAG labelsDisplay = 1; + optional FLAG voipIndividualOutgoing = 2; + optional FLAG groupsV3 = 3; + optional FLAG groupsV3Create = 4; + optional FLAG changeNumberV2 = 5; + optional FLAG queryStatusV3Thumbnail = 6; + optional FLAG liveLocations = 7; + optional FLAG queryVname = 8; + optional FLAG voipIndividualIncoming = 9; + optional FLAG quickRepliesQuery = 10; +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/binary/token/token.go b/vendor/github.com/matterbridge/go-whatsapp/binary/token/token.go new file mode 100644 index 00000000..070a6896 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/binary/token/token.go @@ -0,0 +1,78 @@ +package token + +import "fmt" + +var SingleByteTokens = [...]string{"", "", "", "200", "400", "404", "500", "501", "502", "action", "add", + "after", "archive", "author", "available", "battery", "before", "body", + "broadcast", "chat", "clear", "code", "composing", "contacts", "count", + "create", "debug", "delete", "demote", "duplicate", "encoding", "error", + "false", "filehash", "from", "g.us", "group", "groups_v2", "height", "id", + "image", "in", "index", "invis", "item", "jid", "kind", "last", "leave", + "live", "log", "media", "message", "mimetype", "missing", "modify", "name", + "notification", "notify", "out", "owner", "participant", "paused", + "picture", "played", "presence", "preview", "promote", "query", "raw", + "read", "receipt", "received", "recipient", "recording", "relay", + "remove", "response", "resume", "retry", "s.whatsapp.net", "seconds", + "set", "size", "status", "subject", "subscribe", "t", "text", "to", "true", + "type", "unarchive", "unavailable", "url", "user", "value", "web", "width", + "mute", "read_only", "admin", "creator", "short", "update", "powersave", + "checksum", "epoch", "block", "previous", "409", "replaced", "reason", + "spam", "modify_tag", "message_info", "delivery", "emoji", "title", + "description", "canonical-url", "matched-text", "star", "unstar", + "media_key", "filename", "identity", "unread", "page", "page_count", + "search", "media_message", "security", "call_log", "profile", "ciphertext", + "invite", "gif", "vcard", "frequent", "privacy", "blacklist", "whitelist", + "verify", "location", "document", "elapsed", "revoke_invite", "expiration", + "unsubscribe", "disable", "vname", "old_jid", "new_jid", "announcement", + "locked", "prop", "label", "color", "call", "offer", "call-id"} + +var doubleByteTokens = [...]string{} + +func GetSingleToken(i int) (string, error) { + if i < 3 || i >= len(SingleByteTokens) { + return "", fmt.Errorf("index out of single byte token bounds %d", i) + } + + return SingleByteTokens[i], nil +} + +func GetDoubleToken(index1 int, index2 int) (string, error) { + n := 256*index1 + index2 + if n < 0 || n >= len(doubleByteTokens) { + return "", fmt.Errorf("index out of double byte token bounds %d", n) + } + + return doubleByteTokens[n], nil +} + +func IndexOfSingleToken(token string) int { + for i, t := range SingleByteTokens { + if t == token { + return i + } + } + + return -1 +} + +const ( + LIST_EMPTY = 0 + STREAM_END = 2 + DICTIONARY_0 = 236 + DICTIONARY_1 = 237 + DICTIONARY_2 = 238 + DICTIONARY_3 = 239 + LIST_8 = 248 + LIST_16 = 249 + JID_PAIR = 250 + HEX_8 = 251 + BINARY_8 = 252 + BINARY_20 = 253 + BINARY_32 = 254 + NIBBLE_8 = 255 +) + +const ( + PACKED_MAX = 254 + SINGLE_BYTE_MAX = 256 +) diff --git a/vendor/github.com/matterbridge/go-whatsapp/conn.go b/vendor/github.com/matterbridge/go-whatsapp/conn.go new file mode 100644 index 00000000..caae5dbb --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/conn.go @@ -0,0 +1,389 @@ +//Package whatsapp provides a developer API to interact with the WhatsAppWeb-Servers. +package whatsapp + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/json" + "fmt" + "math/rand" + "net/http" + "os" + "strconv" + "strings" + "sync" + "time" + + "github.com/gorilla/websocket" + "github.com/matterbridge/go-whatsapp/binary" + "github.com/matterbridge/go-whatsapp/crypto/cbc" +) + +type metric byte + +const ( + debugLog metric = iota + 1 + queryResume + queryReceipt + queryMedia + queryChat + queryContacts + queryMessages + presence + presenceSubscribe + group + read + chat + received + pic + status + message + queryActions + block + queryGroup + queryPreview + queryEmoji + queryMessageInfo + spam + querySearch + queryIdentity + queryUrl + profile + contact + queryVcard + queryStatus + queryStatusUpdate + privacyStatus + queryLiveLocations + liveLocation + queryVname + queryLabels + call + queryCall + queryQuickReplies +) + +type flag byte + +const ( + ignore flag = 1 << (7 - iota) + ackRequest + available + notAvailable + expires + skipOffline +) + +/* +Conn is created by NewConn. Interacting with the initialized Conn is the main way of interacting with our package. +It holds all necessary information to make the package work internally. +*/ +type Conn struct { + wsConn *websocket.Conn + wsConnOK bool + wsConnMutex sync.RWMutex + session *Session + listener map[string]chan string + listenerMutex sync.RWMutex + writeChan chan wsMsg + handler []Handler + msgCount int + msgTimeout time.Duration + Info *Info + Store *Store + ServerLastSeen time.Time + + longClientName string + shortClientName string +} + +type wsMsg struct { + messageType int + data []byte +} + +/* +Creates a new connection with a given timeout. The websocket connection to the WhatsAppWeb servers get´s established. +The goroutine for handling incoming messages is started +*/ +func NewConn(timeout time.Duration) (*Conn, error) { + wac := &Conn{ + wsConn: nil, // will be set in connect() + wsConnMutex: sync.RWMutex{}, + listener: make(map[string]chan string), + listenerMutex: sync.RWMutex{}, + writeChan: make(chan wsMsg), + handler: make([]Handler, 0), + msgCount: 0, + msgTimeout: timeout, + Store: newStore(), + + longClientName: "github.com/rhymen/go-whatsapp", + shortClientName: "go-whatsapp", + } + + if err := wac.connect(); err != nil { + return nil, err + } + + go wac.readPump() + go wac.writePump() + go wac.keepAlive(20000, 60000) + + return wac, nil +} + +func (wac *Conn) isConnected() bool { + wac.wsConnMutex.RLock() + defer wac.wsConnMutex.RUnlock() + if wac.wsConn == nil { + return false + } + if wac.wsConnOK { + return true + } + + // just send a keepalive to test the connection + wac.sendKeepAlive() + + // this method is expected to be called by loops. So we can just return false + return false +} + +// connect should be guarded with wsConnMutex +func (wac *Conn) connect() error { + dialer := &websocket.Dialer{ + ReadBufferSize: 25 * 1024 * 1024, + WriteBufferSize: 10 * 1024 * 1024, + HandshakeTimeout: wac.msgTimeout, + } + + headers := http.Header{"Origin": []string{"https://web.whatsapp.com"}} + wsConn, _, err := dialer.Dial("wss://web.whatsapp.com/ws", headers) + if err != nil { + return fmt.Errorf("couldn't dial whatsapp web websocket: %v", err) + } + + wsConn.SetCloseHandler(func(code int, text string) error { + fmt.Fprintf(os.Stderr, "websocket connection closed(%d, %s)\n", code, text) + + // from default CloseHandler + message := websocket.FormatCloseMessage(code, "") + wsConn.WriteControl(websocket.CloseMessage, message, time.Now().Add(time.Second)) + + // our close handling + if websocket.IsUnexpectedCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway) { + fmt.Println("Trigger reconnect") + go wac.reconnect() + } + return nil + }) + + wac.wsConn = wsConn + wac.wsConnOK = true + return nil +} + +// reconnect should be run as go routine +func (wac *Conn) reconnect() { + wac.wsConnMutex.Lock() + wac.wsConn.Close() + wac.wsConn = nil + wac.wsConnOK = false + wac.wsConnMutex.Unlock() + + // wait up to 60 seconds and then reconnect. As writePump should send immediately, it might + // reconnect as well. So we check its existance before reconnecting + for !wac.isConnected() { + time.Sleep(time.Duration(rand.Intn(60)) * time.Second) + + wac.wsConnMutex.Lock() + if wac.wsConn == nil { + if err := wac.connect(); err != nil { + fmt.Fprintf(os.Stderr, "could not reconnect to websocket: %v\n", err) + } + } + wac.wsConnMutex.Unlock() + } +} + +func (wac *Conn) write(data []interface{}) (<-chan string, error) { + d, err := json.Marshal(data) + if err != nil { + return nil, err + } + + ts := time.Now().Unix() + messageTag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) + msg := fmt.Sprintf("%s,%s", messageTag, d) + + ch := make(chan string, 1) + + wac.listenerMutex.Lock() + wac.listener[messageTag] = ch + wac.listenerMutex.Unlock() + + wac.writeChan <- wsMsg{websocket.TextMessage, []byte(msg)} + + wac.msgCount++ + return ch, nil +} + +func (wac *Conn) writeBinary(node binary.Node, metric metric, flag flag, tag string) (<-chan string, error) { + if len(tag) < 2 { + return nil, fmt.Errorf("no tag specified or to short") + } + b, err := binary.Marshal(node) + if err != nil { + return nil, err + } + + cipher, err := cbc.Encrypt(wac.session.EncKey, nil, b) + if err != nil { + return nil, err + } + + h := hmac.New(sha256.New, wac.session.MacKey) + h.Write(cipher) + hash := h.Sum(nil) + + data := []byte(tag + ",") + data = append(data, byte(metric), byte(flag)) + data = append(data, hash[:32]...) + data = append(data, cipher...) + + ch := make(chan string, 1) + + wac.listenerMutex.Lock() + wac.listener[tag] = ch + wac.listenerMutex.Unlock() + + msg := wsMsg{websocket.BinaryMessage, data} + wac.writeChan <- msg + + wac.msgCount++ + return ch, nil +} + +func (wac *Conn) readPump() { + defer wac.wsConn.Close() + + for { + msgType, msg, err := wac.wsConn.ReadMessage() + if err != nil { + wac.wsConnOK = false + if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) { + wac.handle(fmt.Errorf("unexpected websocket close: %v", err)) + } + // sleep for a second and retry reading the next message + time.Sleep(time.Second) + continue + } + wac.wsConnOK = true + + data := strings.SplitN(string(msg), ",", 2) + + //Kepp-Alive Timestmap + if data[0][0] == '!' { + msecs, err := strconv.ParseInt(data[0][1:], 10, 64) + if err != nil { + fmt.Fprintf(os.Stderr, "Error converting time string to uint: %v\n", err) + continue + } + wac.ServerLastSeen = time.Unix(msecs/1000, (msecs%1000)*int64(time.Millisecond)) + continue + } + + wac.listenerMutex.RLock() + listener, hasListener := wac.listener[data[0]] + wac.listenerMutex.RUnlock() + + if len(data[1]) == 0 { + continue + } else if hasListener { + listener <- data[1] + + wac.listenerMutex.Lock() + delete(wac.listener, data[0]) + wac.listenerMutex.Unlock() + } else if msgType == 2 && wac.session != nil && wac.session.EncKey != nil { + message, err := wac.decryptBinaryMessage([]byte(data[1])) + if err != nil { + wac.handle(fmt.Errorf("error decoding binary: %v", err)) + continue + } + + wac.dispatch(message) + } else { + wac.handle(string(data[1])) + } + + } +} + +func (wac *Conn) writePump() { + for msg := range wac.writeChan { + for !wac.isConnected() { + // reconnect to send the message ASAP + wac.wsConnMutex.Lock() + if wac.wsConn == nil { + if err := wac.connect(); err != nil { + fmt.Fprintf(os.Stderr, "could not reconnect to websocket: %v\n", err) + } + } + wac.wsConnMutex.Unlock() + if !wac.isConnected() { + // reconnecting failed. Sleep for a while and try again afterwards + time.Sleep(time.Duration(rand.Intn(5)) * time.Second) + } + } + if err := wac.wsConn.WriteMessage(msg.messageType, msg.data); err != nil { + fmt.Fprintf(os.Stderr, "error writing to socket: %v\n", err) + wac.wsConnOK = false + // add message to channel again to no loose it + go func() { + wac.writeChan <- msg + }() + } + } +} + +func (wac *Conn) sendKeepAlive() { + // whatever issues might be there allow sending this message + wac.wsConnOK = true + wac.writeChan <- wsMsg{ + messageType: websocket.TextMessage, + data: []byte("?,,"), + } +} + +func (wac *Conn) keepAlive(minIntervalMs int, maxIntervalMs int) { + for { + wac.sendKeepAlive() + interval := rand.Intn(maxIntervalMs-minIntervalMs) + minIntervalMs + <-time.After(time.Duration(interval) * time.Millisecond) + } +} + +func (wac *Conn) decryptBinaryMessage(msg []byte) (*binary.Node, error) { + //message validation + h2 := hmac.New(sha256.New, wac.session.MacKey) + h2.Write([]byte(msg[32:])) + if !hmac.Equal(h2.Sum(nil), msg[:32]) { + return nil, fmt.Errorf("message received with invalid hmac") + } + + // message decrypt + d, err := cbc.Decrypt(wac.session.EncKey, nil, msg[32:]) + if err != nil { + return nil, fmt.Errorf("error decrypting message with AES: %v", err) + } + + // message unmarshal + message, err := binary.Unmarshal(d) + if err != nil { + return nil, fmt.Errorf("error decoding binary: %v", err) + } + + return message, nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/contact.go b/vendor/github.com/matterbridge/go-whatsapp/contact.go new file mode 100644 index 00000000..5073608e --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/contact.go @@ -0,0 +1,234 @@ +package whatsapp + +import ( + "fmt" + "github.com/matterbridge/go-whatsapp/binary" + "strconv" + "time" +) + +type Presence string + +const ( + PresenceAvailable = "available" + PresenceUnavailable = "unavailable" + PresenceComposing = "composing" + PresenceRecording = "recording" + PresencePaused = "paused" +) + +//TODO: filename? WhatsApp uses Store.Contacts for these functions +//TODO: functions probably shouldn't return a string, maybe build a struct / return json +//TODO: check for further queries +func (wac *Conn) GetProfilePicThumb(jid string) (<-chan string, error) { + data := []interface{}{"query", "ProfilePicThumb", jid} + return wac.write(data) +} + +func (wac *Conn) GetStatus(jid string) (<-chan string, error) { + data := []interface{}{"query", "Status", jid} + return wac.write(data) +} + +func (wac *Conn) SubscribePresence(jid string) (<-chan string, error) { + data := []interface{}{"action", "presence", "subscribe", jid} + return wac.write(data) +} + +func (wac *Conn) Search(search string, count, page int) (*binary.Node, error) { + return wac.query("search", "", "", "", "", search, count, page) +} + +func (wac *Conn) LoadMessages(jid, messageId string, count int) (*binary.Node, error) { + return wac.query("message", jid, "", "before", "true", "", count, 0) +} + +func (wac *Conn) LoadMessagesBefore(jid, messageId string, count int) (*binary.Node, error) { + return wac.query("message", jid, messageId, "before", "true", "", count, 0) +} + +func (wac *Conn) LoadMessagesAfter(jid, messageId string, count int) (*binary.Node, error) { + return wac.query("message", jid, messageId, "after", "true", "", count, 0) +} + +func (wac *Conn) Presence(jid string, presence Presence) (<-chan string, error) { + ts := time.Now().Unix() + tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) + + content := binary.Node{ + Description: "presence", + Attributes: map[string]string{ + "type": string(presence), + }, + } + switch presence { + case PresenceComposing: + fallthrough + case PresenceRecording: + fallthrough + case PresencePaused: + content.Attributes["to"] = jid + } + + n := binary.Node{ + Description: "action", + Attributes: map[string]string{ + "type": "set", + "epoch": strconv.Itoa(wac.msgCount), + }, + Content: []interface{}{content}, + } + + return wac.writeBinary(n, group, ignore, tag) +} + +func (wac *Conn) Exist(jid string) (<-chan string, error) { + data := []interface{}{"query", "exist", jid} + return wac.write(data) +} + +func (wac *Conn) Emoji() (*binary.Node, error) { + return wac.query("emoji", "", "", "", "", "", 0, 0) +} + +func (wac *Conn) Contacts() (*binary.Node, error) { + return wac.query("contacts", "", "", "", "", "", 0, 0) +} + +func (wac *Conn) Chats() (*binary.Node, error) { + return wac.query("chat", "", "", "", "", "", 0, 0) +} + +func (wac *Conn) Read(jid, id string) (<-chan string, error) { + ts := time.Now().Unix() + tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) + + n := binary.Node{ + Description: "action", + Attributes: map[string]string{ + "type": "set", + "epoch": strconv.Itoa(wac.msgCount), + }, + Content: []interface{}{binary.Node{ + Description: "read", + Attributes: map[string]string{ + "count": "1", + "index": id, + "jid": jid, + "owner": "false", + }, + }}, + } + + return wac.writeBinary(n, group, ignore, tag) +} + +func (wac *Conn) query(t, jid, messageId, kind, owner, search string, count, page int) (*binary.Node, error) { + ts := time.Now().Unix() + tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) + + n := binary.Node{ + Description: "query", + Attributes: map[string]string{ + "type": t, + "epoch": strconv.Itoa(wac.msgCount), + }, + } + + if jid != "" { + n.Attributes["jid"] = jid + } + + if messageId != "" { + n.Attributes["index"] = messageId + } + + if kind != "" { + n.Attributes["kind"] = kind + } + + if owner != "" { + n.Attributes["owner"] = owner + } + + if search != "" { + n.Attributes["search"] = search + } + + if count != 0 { + n.Attributes["count"] = strconv.Itoa(count) + } + + if page != 0 { + n.Attributes["page"] = strconv.Itoa(page) + } + + ch, err := wac.writeBinary(n, group, ignore, tag) + if err != nil { + return nil, err + } + + msg, err := wac.decryptBinaryMessage([]byte(<-ch)) + if err != nil { + return nil, err + } + + //TODO: use parseProtoMessage + return msg, nil +} + +func (wac *Conn) setGroup(t, jid, subject string, participants []string) (<-chan string, error) { + ts := time.Now().Unix() + tag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) + + //TODO: get proto or improve encoder to handle []interface{} + + p := buildParticipantNodes(participants) + + g := binary.Node{ + Description: "group", + Attributes: map[string]string{ + "author": wac.session.Wid, + "id": tag, + "type": t, + }, + Content: p, + } + + if jid != "" { + g.Attributes["jid"] = jid + } + + if subject != "" { + g.Attributes["subject"] = subject + } + + n := binary.Node{ + Description: "action", + Attributes: map[string]string{ + "type": "set", + "epoch": strconv.Itoa(wac.msgCount), + }, + Content: []interface{}{g}, + } + + return wac.writeBinary(n, group, ignore, tag) +} + +func buildParticipantNodes(participants []string) []binary.Node { + l := len(participants) + if participants == nil || l == 0 { + return nil + } + + p := make([]binary.Node, len(participants)) + for i, participant := range participants { + p[i] = binary.Node{ + Description: "participant", + Attributes: map[string]string{ + "jid": participant, + }, + } + } + return p +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/crypto/cbc/cbc.go b/vendor/github.com/matterbridge/go-whatsapp/crypto/cbc/cbc.go new file mode 100644 index 00000000..cc5427c3 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/crypto/cbc/cbc.go @@ -0,0 +1,101 @@ +/* +CBC describes a block cipher mode. In cryptography, a block cipher mode of operation is an algorithm that uses a +block cipher to provide an information service such as confidentiality or authenticity. A block cipher by itself +is only suitable for the secure cryptographic transformation (encryption or decryption) of one fixed-length group of +bits called a block. A mode of operation describes how to repeatedly apply a cipher's single-block operation to +securely transform amounts of data larger than a block. + +This package simplifies the usage of AES-256-CBC. +*/ +package cbc + +/* +Some code is provided by the GitHub user locked (github.com/locked): +https://gist.github.com/locked/b066aa1ddeb2b28e855e +Thanks! +*/ +import ( + "bytes" + "crypto/aes" + "crypto/cipher" + "crypto/rand" + "fmt" + "io" +) + +/* +Decrypt is a function that decrypts a given cipher text with a provided key and initialization vector(iv). +*/ +func Decrypt(key, iv, ciphertext []byte) ([]byte, error) { + block, err := aes.NewCipher(key) + + if err != nil { + return nil, err + } + + if len(ciphertext) < aes.BlockSize { + return nil, fmt.Errorf("ciphertext is shorter then block size: %d / %d", len(ciphertext), aes.BlockSize) + } + + if iv == nil { + iv = ciphertext[:aes.BlockSize] + ciphertext = ciphertext[aes.BlockSize:] + } + + cbc := cipher.NewCBCDecrypter(block, iv) + cbc.CryptBlocks(ciphertext, ciphertext) + + return unpad(ciphertext) +} + +/* +Encrypt is a function that encrypts plaintext with a given key and an optional initialization vector(iv). +*/ +func Encrypt(key, iv, plaintext []byte) ([]byte, error) { + plaintext = pad(plaintext, aes.BlockSize) + + if len(plaintext)%aes.BlockSize != 0 { + return nil, fmt.Errorf("plaintext is not a multiple of the block size: %d / %d", len(plaintext), aes.BlockSize) + } + + block, err := aes.NewCipher(key) + if err != nil { + return nil, err + } + + var ciphertext []byte + if iv == nil { + ciphertext = make([]byte, aes.BlockSize+len(plaintext)) + iv := ciphertext[:aes.BlockSize] + if _, err := io.ReadFull(rand.Reader, iv); err != nil { + return nil, err + } + + cbc := cipher.NewCBCEncrypter(block, iv) + cbc.CryptBlocks(ciphertext[aes.BlockSize:], plaintext) + } else { + ciphertext = make([]byte, len(plaintext)) + + cbc := cipher.NewCBCEncrypter(block, iv) + cbc.CryptBlocks(ciphertext, plaintext) + } + + return ciphertext, nil +} + +func pad(ciphertext []byte, blockSize int) []byte { + padding := blockSize - len(ciphertext)%blockSize + padtext := bytes.Repeat([]byte{byte(padding)}, padding) + return append(ciphertext, padtext...) +} + +func unpad(src []byte) ([]byte, error) { + length := len(src) + padLen := int(src[length-1]) + + if padLen > length { + return nil, fmt.Errorf("padding is greater then the length: %d / %d", padLen, length) + } + + return src[:(length - padLen)], nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/crypto/curve25519/curve.go b/vendor/github.com/matterbridge/go-whatsapp/crypto/curve25519/curve.go new file mode 100644 index 00000000..5ddf9c9a --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/crypto/curve25519/curve.go @@ -0,0 +1,44 @@ +/* +In cryptography, Curve25519 is an elliptic curve offering 128 bits of security and designed for use with the elliptic +curve Diffie–Hellman (ECDH) key agreement scheme. It is one of the fastest ECC curves and is not covered by any known +patents. The reference implementation is public domain software. The original Curve25519 paper defined it +as a Diffie–Hellman (DH) function. +*/ +package curve25519 + +import ( + "crypto/rand" + "golang.org/x/crypto/curve25519" + "io" +) + +/* +GenerateKey generates a public private key pair using Curve25519. +*/ +func GenerateKey() (privateKey *[32]byte, publicKey *[32]byte, err error) { + var pub, priv [32]byte + + _, err = io.ReadFull(rand.Reader, priv[:]) + if err != nil { + return nil, nil, err + } + + priv[0] &= 248 + priv[31] &= 127 + priv[31] |= 64 + + curve25519.ScalarBaseMult(&pub, &priv) + + return &priv, &pub, nil +} + +/* +GenerateSharedSecret generates the shared secret with a given public private key pair. +*/ +func GenerateSharedSecret(priv, pub [32]byte) []byte { + var secret [32]byte + + curve25519.ScalarMult(&secret, &priv, &pub) + + return secret[:] +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/crypto/hkdf/hkdf.go b/vendor/github.com/matterbridge/go-whatsapp/crypto/hkdf/hkdf.go new file mode 100644 index 00000000..e0be0587 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/crypto/hkdf/hkdf.go @@ -0,0 +1,52 @@ +/* +HKDF is a simple key derivation function (KDF) based on +a hash-based message authentication code (HMAC). It was initially proposed by its authors as a building block in +various protocols and applications, as well as to discourage the proliferation of multiple KDF mechanisms. +The main approach HKDF follows is the "extract-then-expand" paradigm, where the KDF logically consists of two modules: +the first stage takes the input keying material and "extracts" from it a fixed-length pseudorandom key, and then the +second stage "expands" this key into several additional pseudorandom keys (the output of the KDF). +*/ +package hkdf + +import ( + "crypto/hmac" + "crypto/sha256" + "fmt" + "golang.org/x/crypto/hkdf" + "io" +) + +/* +Expand expands a given key with the HKDF algorithm. +*/ +func Expand(key []byte, length int, info string) ([]byte, error) { + if info == "" { + keyBlock := hmac.New(sha256.New, key) + var out, last []byte + + var blockIndex byte = 1 + for i := 0; len(out) < length; i++ { + keyBlock.Reset() + //keyBlock.Write(append(append(last, []byte(info)...), blockIndex)) + keyBlock.Write(last) + keyBlock.Write([]byte(info)) + keyBlock.Write([]byte{blockIndex}) + last = keyBlock.Sum(nil) + blockIndex += 1 + out = append(out, last...) + } + return out[:length], nil + } else { + h := hkdf.New(sha256.New, key, nil, []byte(info)) + out := make([]byte, length) + n, err := io.ReadAtLeast(h, out, length) + if err != nil { + return nil, err + } + if n != length { + return nil, fmt.Errorf("new key to short") + } + + return out[:length], nil + } +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/go.mod b/vendor/github.com/matterbridge/go-whatsapp/go.mod new file mode 100644 index 00000000..2c2afb6d --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/go.mod @@ -0,0 +1,8 @@ +module github.com/matterbridge/go-whatsapp + +require ( + github.com/golang/protobuf v1.2.0 + github.com/gorilla/websocket v1.4.0 + golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613 + golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect +) diff --git a/vendor/github.com/matterbridge/go-whatsapp/go.sum b/vendor/github.com/matterbridge/go-whatsapp/go.sum new file mode 100644 index 00000000..e4fd3944 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/go.sum @@ -0,0 +1,7 @@ +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613 h1:MQ/ZZiDsUapFFiMS+vzwXkCTeEKaum+Do5rINYJDmxc= +golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/vendor/github.com/matterbridge/go-whatsapp/group.go b/vendor/github.com/matterbridge/go-whatsapp/group.go new file mode 100644 index 00000000..432ba457 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/group.go @@ -0,0 +1,65 @@ +package whatsapp + +import ( + "encoding/json" + "fmt" + "time" +) + +func (wac *Conn) GetGroupMetaData(jid string) (<-chan string, error) { + data := []interface{}{"query", "GroupMetadata", jid} + return wac.write(data) +} + +func (wac *Conn) CreateGroup(subject string, participants []string) (<-chan string, error) { + return wac.setGroup("create", "", subject, participants) +} + +func (wac *Conn) UpdateGroupSubject(subject string, jid string) (<-chan string, error) { + return wac.setGroup("subject", jid, subject, nil) +} + +func (wac *Conn) SetAdmin(jid string, participants []string) (<-chan string, error) { + return wac.setGroup("promote", jid, "", participants) +} + +func (wac *Conn) RemoveAdmin(jid string, participants []string) (<-chan string, error) { + return wac.setGroup("demote", jid, "", participants) +} + +func (wac *Conn) AddMember(jid string, participants []string) (<-chan string, error) { + return wac.setGroup("add", jid, "", participants) +} + +func (wac *Conn) RemoveMember(jid string, participants []string) (<-chan string, error) { + return wac.setGroup("remove", jid, "", participants) +} + +func (wac *Conn) LeaveGroup(jid string) (<-chan string, error) { + return wac.setGroup("leave", jid, "", nil) +} + +func (wac *Conn) GroupInviteLink(jid string) (string, error) { + request := []interface{}{"query", "inviteCode", jid} + ch, err := wac.write(request) + if err != nil { + return "", err + } + + var response map[string]interface{} + + select { + case r := <-ch: + if err := json.Unmarshal([]byte(r), &response); err != nil { + return "", fmt.Errorf("error decoding response message: %v\n", err) + } + case <-time.After(wac.msgTimeout): + return "", fmt.Errorf("request timed out") + } + + if int(response["status"].(float64)) != 200 { + return "", fmt.Errorf("request responded with %d", response["status"]) + } + + return response["code"].(string), nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/handler.go b/vendor/github.com/matterbridge/go-whatsapp/handler.go new file mode 100644 index 00000000..330356f0 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/handler.go @@ -0,0 +1,169 @@ +package whatsapp + +import ( + "fmt" + "github.com/matterbridge/go-whatsapp/binary" + "github.com/matterbridge/go-whatsapp/binary/proto" + "os" +) + +/* +The Handler interface is the minimal interface that needs to be implemented +to be accepted as a valid handler for our dispatching system. +The minimal handler is used to dispatch error messages. These errors occur on unexpected behavior by the websocket +connection or if we are unable to handle or interpret an incoming message. Error produced by user actions are not +dispatched through this handler. They are returned as an error on the specific function call. +*/ +type Handler interface { + HandleError(err error) +} + +/* +The TextMessageHandler interface needs to be implemented to receive text messages dispatched by the dispatcher. +*/ +type TextMessageHandler interface { + Handler + HandleTextMessage(message TextMessage) +} + +/* +The ImageMessageHandler interface needs to be implemented to receive image messages dispatched by the dispatcher. +*/ +type ImageMessageHandler interface { + Handler + HandleImageMessage(message ImageMessage) +} + +/* +The VideoMessageHandler interface needs to be implemented to receive video messages dispatched by the dispatcher. +*/ +type VideoMessageHandler interface { + Handler + HandleVideoMessage(message VideoMessage) +} + +/* +The AudioMessageHandler interface needs to be implemented to receive audio messages dispatched by the dispatcher. +*/ +type AudioMessageHandler interface { + Handler + HandleAudioMessage(message AudioMessage) +} + +/* +The DocumentMessageHandler interface needs to be implemented to receive document messages dispatched by the dispatcher. +*/ +type DocumentMessageHandler interface { + Handler + HandleDocumentMessage(message DocumentMessage) +} + +/* +The JsonMessageHandler interface needs to be implemented to receive json messages dispatched by the dispatcher. +These json messages contain status updates of every kind sent by WhatsAppWeb servers. WhatsAppWeb uses these messages +to built a Store, which is used to save these "secondary" information. These messages may contain +presence (available, last see) information, or just the battery status of your phone. +*/ +type JsonMessageHandler interface { + Handler + HandleJsonMessage(message string) +} + +/** +The RawMessageHandler interface needs to be implemented to receive raw messages dispatched by the dispatcher. +Raw messages are the raw protobuf structs instead of the easy-to-use structs in TextMessageHandler, ImageMessageHandler, etc.. +*/ +type RawMessageHandler interface { + Handler + HandleRawMessage(message *proto.WebMessageInfo) +} + +/* +AddHandler adds an handler to the list of handler that receive dispatched messages. +The provided handler must at least implement the Handler interface. Additionally implemented +handlers(TextMessageHandler, ImageMessageHandler) are optional. At runtime it is checked if they are implemented +and they are called if so and needed. +*/ +func (wac *Conn) AddHandler(handler Handler) { + wac.handler = append(wac.handler, handler) +} + +func (wac *Conn) handle(message interface{}) { + switch m := message.(type) { + case error: + for _, h := range wac.handler { + go h.HandleError(m) + } + case string: + for _, h := range wac.handler { + if x, ok := h.(JsonMessageHandler); ok { + go x.HandleJsonMessage(m) + } + } + case TextMessage: + for _, h := range wac.handler { + if x, ok := h.(TextMessageHandler); ok { + go x.HandleTextMessage(m) + } + } + case ImageMessage: + for _, h := range wac.handler { + if x, ok := h.(ImageMessageHandler); ok { + go x.HandleImageMessage(m) + } + } + case VideoMessage: + for _, h := range wac.handler { + if x, ok := h.(VideoMessageHandler); ok { + go x.HandleVideoMessage(m) + } + } + case AudioMessage: + for _, h := range wac.handler { + if x, ok := h.(AudioMessageHandler); ok { + go x.HandleAudioMessage(m) + } + } + case DocumentMessage: + for _, h := range wac.handler { + if x, ok := h.(DocumentMessageHandler); ok { + go x.HandleDocumentMessage(m) + } + } + case *proto.WebMessageInfo: + for _, h := range wac.handler { + if x, ok := h.(RawMessageHandler); ok { + go x.HandleRawMessage(m) + } + } + } + +} + +func (wac *Conn) dispatch(msg interface{}) { + if msg == nil { + return + } + + switch message := msg.(type) { + case *binary.Node: + if message.Description == "action" { + if con, ok := message.Content.([]interface{}); ok { + for a := range con { + if v, ok := con[a].(*proto.WebMessageInfo); ok { + wac.handle(v) + wac.handle(parseProtoMessage(v)) + } + } + } + } else if message.Description == "response" && message.Attributes["type"] == "contacts" { + wac.updateContacts(message.Content) + } + case error: + wac.handle(message) + case string: + wac.handle(message) + default: + fmt.Fprintf(os.Stderr, "unknown type in dipatcher chan: %T", msg) + } +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/media.go b/vendor/github.com/matterbridge/go-whatsapp/media.go new file mode 100644 index 00000000..9fcc08e2 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/media.go @@ -0,0 +1,199 @@ +package whatsapp + +import ( + "bytes" + "crypto/hmac" + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "fmt" + "github.com/matterbridge/go-whatsapp/crypto/cbc" + "github.com/matterbridge/go-whatsapp/crypto/hkdf" + "io" + "io/ioutil" + "mime/multipart" + "net/http" + "os" + "strings" + "time" +) + +func Download(url string, mediaKey []byte, appInfo MediaType, fileLength int) ([]byte, error) { + if url == "" { + return nil, fmt.Errorf("no url present") + } + file, mac, err := downloadMedia(url) + if err != nil { + return nil, err + } + iv, cipherKey, macKey, _, err := getMediaKeys(mediaKey, appInfo) + if err != nil { + return nil, err + } + if err = validateMedia(iv, file, macKey, mac); err != nil { + return nil, err + } + data, err := cbc.Decrypt(cipherKey, iv, file) + if err != nil { + return nil, err + } + if len(data) != fileLength { + return nil, fmt.Errorf("file length does not match") + } + return data, nil +} + +func validateMedia(iv []byte, file []byte, macKey []byte, mac []byte) error { + h := hmac.New(sha256.New, macKey) + n, err := h.Write(append(iv, file...)) + if err != nil { + return err + } + if n < 10 { + return fmt.Errorf("hash to short") + } + if !hmac.Equal(h.Sum(nil)[:10], mac) { + return fmt.Errorf("invalid media hmac") + } + return nil +} + +func getMediaKeys(mediaKey []byte, appInfo MediaType) (iv, cipherKey, macKey, refKey []byte, err error) { + mediaKeyExpanded, err := hkdf.Expand(mediaKey, 112, string(appInfo)) + if err != nil { + return nil, nil, nil, nil, err + } + return mediaKeyExpanded[:16], mediaKeyExpanded[16:48], mediaKeyExpanded[48:80], mediaKeyExpanded[80:], nil +} + +func downloadMedia(url string) (file []byte, mac []byte, err error) { + resp, err := http.Get(url) + if err != nil { + return nil, nil, err + } + if resp.StatusCode != 200 { + return nil, nil, fmt.Errorf("download failed") + } + defer resp.Body.Close() + if resp.ContentLength <= 10 { + return nil, nil, fmt.Errorf("file to short") + } + data, err := ioutil.ReadAll(resp.Body) + n := len(data) + if err != nil { + return nil, nil, err + } + return data[:n-10], data[n-10 : n], nil +} + +func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (url string, mediaKey []byte, fileEncSha256 []byte, fileSha256 []byte, fileLength uint64, err error) { + data, err := ioutil.ReadAll(reader) + if err != nil { + return "", nil, nil, nil, 0, err + } + + mediaKey = make([]byte, 32) + rand.Read(mediaKey) + + iv, cipherKey, macKey, _, err := getMediaKeys(mediaKey, appInfo) + if err != nil { + return "", nil, nil, nil, 0, err + } + + enc, err := cbc.Encrypt(cipherKey, iv, data) + if err != nil { + return "", nil, nil, nil, 0, err + } + + fileLength = uint64(len(data)) + + h := hmac.New(sha256.New, macKey) + h.Write(append(iv, enc...)) + mac := h.Sum(nil)[:10] + + sha := sha256.New() + sha.Write(data) + fileSha256 = sha.Sum(nil) + + sha.Reset() + sha.Write(append(enc, mac...)) + fileEncSha256 = sha.Sum(nil) + + var filetype string + switch appInfo { + case MediaImage: + filetype = "image" + case MediaAudio: + filetype = "audio" + case MediaDocument: + filetype = "document" + case MediaVideo: + filetype = "video" + } + + uploadReq := []interface{}{"action", "encr_upload", filetype, base64.StdEncoding.EncodeToString(fileEncSha256)} + ch, err := wac.write(uploadReq) + if err != nil { + return "", nil, nil, nil, 0, err + } + + var resp map[string]interface{} + select { + case r := <-ch: + if err = json.Unmarshal([]byte(r), &resp); err != nil { + return "", nil, nil, nil, 0, fmt.Errorf("error decoding upload response: %v\n", err) + } + case <-time.After(wac.msgTimeout): + return "", nil, nil, nil, 0, fmt.Errorf("restore session init timed out") + } + + if int(resp["status"].(float64)) != 200 { + return "", nil, nil, nil, 0, fmt.Errorf("upload responsed with %d", resp["status"]) + } + + var b bytes.Buffer + w := multipart.NewWriter(&b) + hashWriter, err := w.CreateFormField("hash") + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + } + io.Copy(hashWriter, strings.NewReader(base64.StdEncoding.EncodeToString(fileEncSha256))) + + fileWriter, err := w.CreateFormFile("file", "blob") + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + } + io.Copy(fileWriter, bytes.NewReader(append(enc, mac...))) + err = w.Close() + if err != nil { + fmt.Fprintf(os.Stderr, "%v\n", err) + } + + req, err := http.NewRequest("POST", resp["url"].(string), &b) + if err != nil { + return "", nil, nil, nil, 0, err + } + + req.Header.Set("Content-Type", w.FormDataContentType()) + req.Header.Set("Origin", "https://web.whatsapp.com") + req.Header.Set("Referer", "https://web.whatsapp.com/") + + req.URL.Query().Set("f", "j") + + client := &http.Client{} + // Submit the request + res, err := client.Do(req) + if err != nil { + return "", nil, nil, nil, 0, err + } + + if res.StatusCode != http.StatusOK { + return "", nil, nil, nil, 0, fmt.Errorf("upload failed with status code %d", res.StatusCode) + } + + var jsonRes map[string]string + json.NewDecoder(res.Body).Decode(&jsonRes) + + return jsonRes["url"], mediaKey, fileEncSha256, fileSha256, fileLength, nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/message.go b/vendor/github.com/matterbridge/go-whatsapp/message.go new file mode 100644 index 00000000..7e099b9d --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/message.go @@ -0,0 +1,444 @@ +package whatsapp + +import ( + "encoding/hex" + "encoding/json" + "fmt" + "github.com/matterbridge/go-whatsapp/binary" + "github.com/matterbridge/go-whatsapp/binary/proto" + "io" + "math/rand" + "strconv" + "strings" + "time" +) + +type MediaType string + +const ( + MediaImage MediaType = "WhatsApp Image Keys" + MediaVideo MediaType = "WhatsApp Video Keys" + MediaAudio MediaType = "WhatsApp Audio Keys" + MediaDocument MediaType = "WhatsApp Document Keys" +) + +func (wac *Conn) Send(msg interface{}) error { + var err error + var ch <-chan string + + switch m := msg.(type) { + case *proto.WebMessageInfo: + ch, err = wac.sendProto(m) + case TextMessage: + ch, err = wac.sendProto(getTextProto(m)) + case ImageMessage: + m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaImage) + if err != nil { + return fmt.Errorf("image upload failed: %v", err) + } + ch, err = wac.sendProto(getImageProto(m)) + case VideoMessage: + m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaVideo) + if err != nil { + return fmt.Errorf("video upload failed: %v", err) + } + ch, err = wac.sendProto(getVideoProto(m)) + case DocumentMessage: + m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaDocument) + if err != nil { + return fmt.Errorf("document upload failed: %v", err) + } + ch, err = wac.sendProto(getDocumentProto(m)) + case AudioMessage: + m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaAudio) + if err != nil { + return fmt.Errorf("audio upload failed: %v", err) + } + ch, err = wac.sendProto(getAudioProto(m)) + default: + return fmt.Errorf("cannot match type %T, use message types declared in the package", msg) + } + + if err != nil { + return fmt.Errorf("could not send proto: %v", err) + } + + select { + case response := <-ch: + var resp map[string]interface{} + if err = json.Unmarshal([]byte(response), &resp); err != nil { + return fmt.Errorf("error decoding sending response: %v\n", err) + } + if int(resp["status"].(float64)) != 200 { + return fmt.Errorf("message sending responded with %d", resp["status"]) + } + case <-time.After(wac.msgTimeout): + return fmt.Errorf("sending message timed out") + } + + return nil +} + +func (wac *Conn) sendProto(p *proto.WebMessageInfo) (<-chan string, error) { + n := binary.Node{ + Description: "action", + Attributes: map[string]string{ + "type": "relay", + "epoch": strconv.Itoa(wac.msgCount), + }, + Content: []interface{}{p}, + } + return wac.writeBinary(n, message, ignore, p.Key.GetId()) +} + +func init() { + rand.Seed(time.Now().UTC().UnixNano()) +} + +/* +MessageInfo contains general message information. It is part of every of every message type. +*/ +type MessageInfo struct { + Id string + RemoteJid string + SenderJid string + FromMe bool + Timestamp uint64 + PushName string + Status MessageStatus + QuotedMessageID string + + Source *proto.WebMessageInfo +} + +type MessageStatus int + +const ( + Error MessageStatus = 0 + Pending = 1 + ServerAck = 2 + DeliveryAck = 3 + Read = 4 + Played = 5 +) + +func getMessageInfo(msg *proto.WebMessageInfo) MessageInfo { + return MessageInfo{ + Id: msg.GetKey().GetId(), + RemoteJid: msg.GetKey().GetRemoteJid(), + SenderJid: msg.GetKey().GetParticipant(), + FromMe: msg.GetKey().GetFromMe(), + Timestamp: msg.GetMessageTimestamp(), + Status: MessageStatus(msg.GetStatus()), + PushName: msg.GetPushName(), + Source: msg, + } +} + +func getInfoProto(info *MessageInfo) *proto.WebMessageInfo { + if info.Id == "" || len(info.Id) < 2 { + b := make([]byte, 10) + rand.Read(b) + info.Id = strings.ToUpper(hex.EncodeToString(b)) + } + if info.Timestamp == 0 { + info.Timestamp = uint64(time.Now().Unix()) + } + info.FromMe = true + + status := proto.WebMessageInfo_STATUS(info.Status) + + return &proto.WebMessageInfo{ + Key: &proto.MessageKey{ + FromMe: &info.FromMe, + RemoteJid: &info.RemoteJid, + Id: &info.Id, + }, + MessageTimestamp: &info.Timestamp, + Status: &status, + } +} + +/* +TextMessage represents a text message. +*/ +type TextMessage struct { + Info MessageInfo + Text string +} + +func getTextMessage(msg *proto.WebMessageInfo) TextMessage { + text := TextMessage{Info: getMessageInfo(msg)} + if m := msg.GetMessage().GetExtendedTextMessage(); m != nil { + text.Text = m.GetText() + text.Info.QuotedMessageID = m.GetContextInfo().GetStanzaId() + } else { + text.Text = msg.GetMessage().GetConversation() + } + return text +} + +func getTextProto(msg TextMessage) *proto.WebMessageInfo { + p := getInfoProto(&msg.Info) + p.Message = &proto.Message{ + Conversation: &msg.Text, + } + return p +} + +/* +ImageMessage represents a image message. Unexported fields are needed for media up/downloading and media validation. +Provide a io.Reader as Content for message sending. +*/ +type ImageMessage struct { + Info MessageInfo + Caption string + Thumbnail []byte + Type string + Content io.Reader + url string + mediaKey []byte + fileEncSha256 []byte + fileSha256 []byte + fileLength uint64 +} + +func getImageMessage(msg *proto.WebMessageInfo) ImageMessage { + image := msg.GetMessage().GetImageMessage() + return ImageMessage{ + Info: getMessageInfo(msg), + Caption: image.GetCaption(), + Thumbnail: image.GetJpegThumbnail(), + url: image.GetUrl(), + mediaKey: image.GetMediaKey(), + Type: image.GetMimetype(), + fileEncSha256: image.GetFileEncSha256(), + fileSha256: image.GetFileSha256(), + fileLength: image.GetFileLength(), + } +} + +func getImageProto(msg ImageMessage) *proto.WebMessageInfo { + p := getInfoProto(&msg.Info) + p.Message = &proto.Message{ + ImageMessage: &proto.ImageMessage{ + Caption: &msg.Caption, + JpegThumbnail: msg.Thumbnail, + Url: &msg.url, + MediaKey: msg.mediaKey, + Mimetype: &msg.Type, + FileEncSha256: msg.fileEncSha256, + FileSha256: msg.fileSha256, + FileLength: &msg.fileLength, + }, + } + return p +} + +/* +Download is the function to retrieve media data. The media gets downloaded, validated and returned. +*/ +func (m *ImageMessage) Download() ([]byte, error) { + return Download(m.url, m.mediaKey, MediaImage, int(m.fileLength)) +} + +/* +VideoMessage represents a video message. Unexported fields are needed for media up/downloading and media validation. +Provide a io.Reader as Content for message sending. +*/ +type VideoMessage struct { + Info MessageInfo + Caption string + Thumbnail []byte + Length uint32 + Type string + Content io.Reader + url string + mediaKey []byte + fileEncSha256 []byte + fileSha256 []byte + fileLength uint64 +} + +func getVideoMessage(msg *proto.WebMessageInfo) VideoMessage { + vid := msg.GetMessage().GetVideoMessage() + return VideoMessage{ + Info: getMessageInfo(msg), + Caption: vid.GetCaption(), + Thumbnail: vid.GetJpegThumbnail(), + url: vid.GetUrl(), + mediaKey: vid.GetMediaKey(), + Length: vid.GetSeconds(), + Type: vid.GetMimetype(), + fileEncSha256: vid.GetFileEncSha256(), + fileSha256: vid.GetFileSha256(), + fileLength: vid.GetFileLength(), + } +} + +func getVideoProto(msg VideoMessage) *proto.WebMessageInfo { + p := getInfoProto(&msg.Info) + p.Message = &proto.Message{ + VideoMessage: &proto.VideoMessage{ + Caption: &msg.Caption, + JpegThumbnail: msg.Thumbnail, + Url: &msg.url, + MediaKey: msg.mediaKey, + Seconds: &msg.Length, + FileEncSha256: msg.fileEncSha256, + FileSha256: msg.fileSha256, + FileLength: &msg.fileLength, + Mimetype: &msg.Type, + }, + } + return p +} + +/* +Download is the function to retrieve media data. The media gets downloaded, validated and returned. +*/ +func (m *VideoMessage) Download() ([]byte, error) { + return Download(m.url, m.mediaKey, MediaVideo, int(m.fileLength)) +} + +/* +AudioMessage represents a audio message. Unexported fields are needed for media up/downloading and media validation. +Provide a io.Reader as Content for message sending. +*/ +type AudioMessage struct { + Info MessageInfo + Length uint32 + Type string + Content io.Reader + url string + mediaKey []byte + fileEncSha256 []byte + fileSha256 []byte + fileLength uint64 +} + +func getAudioMessage(msg *proto.WebMessageInfo) AudioMessage { + aud := msg.GetMessage().GetAudioMessage() + return AudioMessage{ + Info: getMessageInfo(msg), + url: aud.GetUrl(), + mediaKey: aud.GetMediaKey(), + Length: aud.GetSeconds(), + Type: aud.GetMimetype(), + fileEncSha256: aud.GetFileEncSha256(), + fileSha256: aud.GetFileSha256(), + fileLength: aud.GetFileLength(), + } +} + +func getAudioProto(msg AudioMessage) *proto.WebMessageInfo { + p := getInfoProto(&msg.Info) + p.Message = &proto.Message{ + AudioMessage: &proto.AudioMessage{ + Url: &msg.url, + MediaKey: msg.mediaKey, + Seconds: &msg.Length, + FileEncSha256: msg.fileEncSha256, + FileSha256: msg.fileSha256, + FileLength: &msg.fileLength, + Mimetype: &msg.Type, + }, + } + return p +} + +/* +Download is the function to retrieve media data. The media gets downloaded, validated and returned. +*/ +func (m *AudioMessage) Download() ([]byte, error) { + return Download(m.url, m.mediaKey, MediaAudio, int(m.fileLength)) +} + +/* +DocumentMessage represents a document message. Unexported fields are needed for media up/downloading and media +validation. Provide a io.Reader as Content for message sending. +*/ +type DocumentMessage struct { + Info MessageInfo + Title string + PageCount uint32 + Type string + FileName string + Thumbnail []byte + Content io.Reader + url string + mediaKey []byte + fileEncSha256 []byte + fileSha256 []byte + fileLength uint64 +} + +func getDocumentMessage(msg *proto.WebMessageInfo) DocumentMessage { + doc := msg.GetMessage().GetDocumentMessage() + return DocumentMessage{ + Info: getMessageInfo(msg), + Title: doc.GetTitle(), + PageCount: doc.GetPageCount(), + Type: doc.GetMimetype(), + FileName: doc.GetFileName(), + Thumbnail: doc.GetJpegThumbnail(), + url: doc.GetUrl(), + mediaKey: doc.GetMediaKey(), + fileEncSha256: doc.GetFileEncSha256(), + fileSha256: doc.GetFileSha256(), + fileLength: doc.GetFileLength(), + } +} + +func getDocumentProto(msg DocumentMessage) *proto.WebMessageInfo { + p := getInfoProto(&msg.Info) + p.Message = &proto.Message{ + DocumentMessage: &proto.DocumentMessage{ + JpegThumbnail: msg.Thumbnail, + Url: &msg.url, + MediaKey: msg.mediaKey, + FileEncSha256: msg.fileEncSha256, + FileSha256: msg.fileSha256, + FileLength: &msg.fileLength, + PageCount: &msg.PageCount, + Title: &msg.Title, + Mimetype: &msg.Type, + }, + } + return p +} + +/* +Download is the function to retrieve media data. The media gets downloaded, validated and returned. +*/ +func (m *DocumentMessage) Download() ([]byte, error) { + return Download(m.url, m.mediaKey, MediaDocument, int(m.fileLength)) +} + +func parseProtoMessage(msg *proto.WebMessageInfo) interface{} { + switch { + + case msg.GetMessage().GetAudioMessage() != nil: + return getAudioMessage(msg) + + case msg.GetMessage().GetImageMessage() != nil: + return getImageMessage(msg) + + case msg.GetMessage().GetVideoMessage() != nil: + return getVideoMessage(msg) + + case msg.GetMessage().GetDocumentMessage() != nil: + return getDocumentMessage(msg) + + case msg.GetMessage().GetConversation() != "": + return getTextMessage(msg) + + case msg.GetMessage().GetExtendedTextMessage() != nil: + return getTextMessage(msg) + + default: + //cannot match message + } + + return nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/session.go b/vendor/github.com/matterbridge/go-whatsapp/session.go new file mode 100644 index 00000000..2dd8d582 --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/session.go @@ -0,0 +1,389 @@ +package whatsapp + +import ( + "crypto/hmac" + "crypto/rand" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "fmt" + "time" + + "github.com/matterbridge/go-whatsapp/crypto/cbc" + "github.com/matterbridge/go-whatsapp/crypto/curve25519" + "github.com/matterbridge/go-whatsapp/crypto/hkdf" +) + +/* +Session contains session individual information. To be able to resume the connection without scanning the qr code +every time you should save the Session returned by Login and use RestoreSession the next time you want to login. +Every successful created connection returns a new Session. The Session(ClientToken, ServerToken) is altered after +every re-login and should be saved every time. +*/ +type Session struct { + ClientId string + ClientToken string + ServerToken string + EncKey []byte + MacKey []byte + Wid string +} + +type Info struct { + Battery int + Platform string + Connected bool + Pushname string + Wid string + Lc string + Phone *PhoneInfo + Plugged bool + Tos int + Lg string + Is24h bool +} + +type PhoneInfo struct { + Mcc string + Mnc string + OsVersion string + DeviceManufacturer string + DeviceModel string + OsBuildNumber string + WaVersion string +} + +func newInfoFromReq(info map[string]interface{}) *Info { + phoneInfo := info["phone"].(map[string]interface{}) + + ret := &Info{ + Battery: int(info["battery"].(float64)), + Platform: info["platform"].(string), + Connected: info["connected"].(bool), + Pushname: info["pushname"].(string), + Wid: info["wid"].(string), + Lc: info["lc"].(string), + Phone: &PhoneInfo{ + phoneInfo["mcc"].(string), + phoneInfo["mnc"].(string), + phoneInfo["os_version"].(string), + phoneInfo["device_manufacturer"].(string), + phoneInfo["device_model"].(string), + phoneInfo["os_build_number"].(string), + phoneInfo["wa_version"].(string), + }, + Plugged: info["plugged"].(bool), + Lg: info["lg"].(string), + Tos: int(info["tos"].(float64)), + } + + if is24h, ok := info["is24h"]; ok { + ret.Is24h = is24h.(bool) + } + + return ret +} + +/* +SetClientName sets the long and short client names that are sent to WhatsApp when logging in and displayed in the +WhatsApp Web device list. As the values are only sent when logging in, changing them after logging in is not possible. +*/ +func (wac *Conn) SetClientName(long, short string) error { + if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) { + return fmt.Errorf("cannot change client name after logging in") + } + wac.longClientName, wac.shortClientName = long, short + return nil +} + +/* +Login is the function that creates a new whatsapp session and logs you in. If you do not want to scan the qr code +every time, you should save the returned session and use RestoreSession the next time. Login takes a writable channel +as an parameter. This channel is used to push the data represented by the qr code back to the user. The received data +should be displayed as an qr code in a way you prefer. To print a qr code to console you can use: +github.com/Baozisoftware/qrcode-terminal-go Example login procedure: + wac, err := whatsapp.NewConn(5 * time.Second) + if err != nil { + panic(err) + } + + qr := make(chan string) + go func() { + terminal := qrcodeTerminal.New() + terminal.Get(<-qr).Print() + }() + + session, err := wac.Login(qr) + if err != nil { + fmt.Fprintf(os.Stderr, "error during login: %v\n", err) + } + fmt.Printf("login successful, session: %v\n", session) +*/ +func (wac *Conn) Login(qrChan chan<- string) (Session, error) { + session := Session{} + + if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) { + return session, fmt.Errorf("already logged in") + } + + clientId := make([]byte, 16) + _, err := rand.Read(clientId) + if err != nil { + return session, fmt.Errorf("error creating random ClientId: %v", err) + } + + session.ClientId = base64.StdEncoding.EncodeToString(clientId) + //oldVersion=8691 + login := []interface{}{"admin", "init", []int{0, 3, 225}, []string{wac.longClientName, wac.shortClientName}, session.ClientId, true} + loginChan, err := wac.write(login) + if err != nil { + return session, fmt.Errorf("error writing login: %v\n", err) + } + + var r string + select { + case r = <-loginChan: + case <-time.After(wac.msgTimeout): + return session, fmt.Errorf("login connection timed out") + } + + var resp map[string]interface{} + if err = json.Unmarshal([]byte(r), &resp); err != nil { + return session, fmt.Errorf("error decoding login resp: %v\n", err) + } + + ref := resp["ref"].(string) + + priv, pub, err := curve25519.GenerateKey() + if err != nil { + return session, fmt.Errorf("error generating keys: %v\n", err) + } + + //listener for Login response + messageTag := "s1" + wac.listener[messageTag] = make(chan string, 1) + + qrChan <- fmt.Sprintf("%v,%v,%v", ref, base64.StdEncoding.EncodeToString(pub[:]), session.ClientId) + + var resp2 []interface{} + select { + case r1 := <-wac.listener[messageTag]: + if err := json.Unmarshal([]byte(r1), &resp2); err != nil { + return session, fmt.Errorf("error decoding qr code resp: %v", err) + } + case <-time.After(time.Duration(resp["ttl"].(float64)) * time.Millisecond): + return session, fmt.Errorf("qr code scan timed out") + } + + info := resp2[1].(map[string]interface{}) + + wac.Info = newInfoFromReq(info) + + session.ClientToken = info["clientToken"].(string) + session.ServerToken = info["serverToken"].(string) + session.Wid = info["wid"].(string) + s := info["secret"].(string) + decodedSecret, err := base64.StdEncoding.DecodeString(s) + if err != nil { + return session, fmt.Errorf("error decoding secret: %v", err) + } + + var pubKey [32]byte + copy(pubKey[:], decodedSecret[:32]) + + sharedSecret := curve25519.GenerateSharedSecret(*priv, pubKey) + + hash := sha256.New + + nullKey := make([]byte, 32) + h := hmac.New(hash, nullKey) + h.Write(sharedSecret) + + sharedSecretExtended, err := hkdf.Expand(h.Sum(nil), 80, "") + if err != nil { + return session, fmt.Errorf("hkdf error: %v", err) + } + + //login validation + checkSecret := make([]byte, 112) + copy(checkSecret[:32], decodedSecret[:32]) + copy(checkSecret[32:], decodedSecret[64:]) + h2 := hmac.New(hash, sharedSecretExtended[32:64]) + h2.Write(checkSecret) + if !hmac.Equal(h2.Sum(nil), decodedSecret[32:64]) { + return session, fmt.Errorf("abort login") + } + + keysEncrypted := make([]byte, 96) + copy(keysEncrypted[:16], sharedSecretExtended[64:]) + copy(keysEncrypted[16:], decodedSecret[64:]) + + keyDecrypted, err := cbc.Decrypt(sharedSecretExtended[:32], nil, keysEncrypted) + if err != nil { + return session, fmt.Errorf("error decryptAes: %v", err) + } + + session.EncKey = keyDecrypted[:32] + session.MacKey = keyDecrypted[32:64] + wac.session = &session + + return session, nil +} + +/* +RestoreSession is the function that restores a given session. It will try to reestablish the connection to the +WhatsAppWeb servers with the provided session. If it succeeds it will return a new session. This new session has to be +saved because the Client and Server-Token will change after every login. Logging in with old tokens is possible, but not +suggested. If so, a challenge has to be resolved which is just another possible point of failure. +*/ +func (wac *Conn) RestoreSession(session Session) (Session, error) { + if wac.session != nil && (wac.session.EncKey != nil || wac.session.MacKey != nil) { + return Session{}, fmt.Errorf("already logged in") + } + + wac.session = &session + + //listener for Conn or challenge; s1 is not allowed to drop + wac.listener["s1"] = make(chan string, 1) + + //admin init + init := []interface{}{"admin", "init", []int{0, 3, 225}, []string{wac.longClientName, wac.shortClientName}, session.ClientId, true} + initChan, err := wac.write(init) + if err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error writing admin init: %v\n", err) + } + + //admin login with takeover + login := []interface{}{"admin", "login", session.ClientToken, session.ServerToken, session.ClientId, "takeover"} + loginChan, err := wac.write(login) + if err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error writing admin login: %v\n", err) + } + + select { + case r := <-initChan: + var resp map[string]interface{} + if err = json.Unmarshal([]byte(r), &resp); err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error decoding login connResp: %v\n", err) + } + + if int(resp["status"].(float64)) != 200 { + wac.session = nil + return Session{}, fmt.Errorf("init responded with %d", resp["status"]) + } + case <-time.After(wac.msgTimeout): + wac.session = nil + return Session{}, fmt.Errorf("restore session init timed out") + } + + //wait for s1 + var connResp []interface{} + select { + case r1 := <-wac.listener["s1"]: + if err := json.Unmarshal([]byte(r1), &connResp); err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error decoding s1 message: %v\n", err) + } + case <-time.After(wac.msgTimeout): + wac.session = nil + return Session{}, fmt.Errorf("restore session connection timed out") + } + + //check if challenge is present + if len(connResp) == 2 && connResp[0] == "Cmd" && connResp[1].(map[string]interface{})["type"] == "challenge" { + wac.listener["s2"] = make(chan string, 1) + + if err := wac.resolveChallenge(connResp[1].(map[string]interface{})["challenge"].(string)); err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error resolving challenge: %v\n", err) + } + + select { + case r := <-wac.listener["s2"]: + if err := json.Unmarshal([]byte(r), &connResp); err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error decoding s2 message: %v\n", err) + } + case <-time.After(wac.msgTimeout): + wac.session = nil + return Session{}, fmt.Errorf("restore session challenge timed out") + } + } + + //check for login 200 --> login success + select { + case r := <-loginChan: + var resp map[string]interface{} + if err = json.Unmarshal([]byte(r), &resp); err != nil { + wac.session = nil + return Session{}, fmt.Errorf("error decoding login connResp: %v\n", err) + } + + if int(resp["status"].(float64)) != 200 { + wac.session = nil + return Session{}, fmt.Errorf("admin login responded with %d", resp["status"]) + } + case <-time.After(wac.msgTimeout): + wac.session = nil + return Session{}, fmt.Errorf("restore session login timed out") + } + + info := connResp[1].(map[string]interface{}) + + wac.Info = newInfoFromReq(info) + + //set new tokens + session.ClientToken = info["clientToken"].(string) + session.ServerToken = info["serverToken"].(string) + session.Wid = info["wid"].(string) + + return *wac.session, nil +} + +func (wac *Conn) resolveChallenge(challenge string) error { + decoded, err := base64.StdEncoding.DecodeString(challenge) + if err != nil { + return err + } + + h2 := hmac.New(sha256.New, wac.session.MacKey) + h2.Write([]byte(decoded)) + + ch := []interface{}{"admin", "challenge", base64.StdEncoding.EncodeToString(h2.Sum(nil)), wac.session.ServerToken, wac.session.ClientId} + challengeChan, err := wac.write(ch) + if err != nil { + return fmt.Errorf("error writing challenge: %v\n", err) + } + + select { + case r := <-challengeChan: + var resp map[string]interface{} + if err := json.Unmarshal([]byte(r), &resp); err != nil { + return fmt.Errorf("error decoding login resp: %v\n", err) + } + if int(resp["status"].(float64)) != 200 { + return fmt.Errorf("challenge responded with %d\n", resp["status"]) + } + case <-time.After(wac.msgTimeout): + return fmt.Errorf("connection timed out") + } + + return nil +} + +/* +Logout is the function to logout from a WhatsApp session. Logging out means invalidating the current session. +The session can not be resumed and will disappear on your phone in the WhatsAppWeb client list. +*/ +func (wac *Conn) Logout() error { + login := []interface{}{"admin", "Conn", "disconnect"} + _, err := wac.write(login) + if err != nil { + return fmt.Errorf("error writing logout: %v\n", err) + } + + return nil +} diff --git a/vendor/github.com/matterbridge/go-whatsapp/store.go b/vendor/github.com/matterbridge/go-whatsapp/store.go new file mode 100644 index 00000000..70b89efd --- /dev/null +++ b/vendor/github.com/matterbridge/go-whatsapp/store.go @@ -0,0 +1,45 @@ +package whatsapp + +import ( + "github.com/matterbridge/go-whatsapp/binary" + "strings" +) + +type Store struct { + Contacts map[string]Contact +} + +type Contact struct { + Jid string + Notify string + Name string + Short string +} + +func newStore() *Store { + return &Store{ + make(map[string]Contact), + } +} + +func (wac *Conn) updateContacts(contacts interface{}) { + c, ok := contacts.([]interface{}) + if !ok { + return + } + + for _, contact := range c { + contactNode, ok := contact.(binary.Node) + if !ok { + continue + } + + jid := strings.Replace(contactNode.Attributes["jid"], "@c.us", "@s.whatsapp.net", 1) + wac.Store.Contacts[jid] = Contact{ + jid, + contactNode.Attributes["notify"], + contactNode.Attributes["name"], + contactNode.Attributes["short"], + } + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/LICENSE b/vendor/github.com/matterbridge/mautrix-whatsapp/LICENSE new file mode 100644 index 00000000..be3f7b28 --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/chat.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/chat.go new file mode 100644 index 00000000..b1a08823 --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/chat.go @@ -0,0 +1,147 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + "strings" + + "github.com/matterbridge/go-whatsapp" +) + +type ChatUpdateCommand string + +const ( + ChatUpdateCommandAction ChatUpdateCommand = "action" +) + +type ChatUpdate struct { + JID string `json:"id"` + Command ChatUpdateCommand `json:"cmd"` + Data ChatUpdateData `json:"data"` +} + +type ChatActionType string + +const ( + ChatActionNameChange ChatActionType = "subject" + ChatActionAddTopic ChatActionType = "desc_add" + ChatActionRemoveTopic ChatActionType = "desc_remove" + ChatActionRestrict ChatActionType = "restrict" + ChatActionAnnounce ChatActionType = "announce" + ChatActionPromote ChatActionType = "promote" + ChatActionDemote ChatActionType = "demote" +) + +type ChatUpdateData struct { + Action ChatActionType + SenderJID string + + NameChange struct { + Name string `json:"subject"` + SetAt int64 `json:"s_t"` + SetBy string `json:"s_o"` + } + + AddTopic struct { + Topic string `json:"desc"` + ID string `json:"descId"` + SetAt int64 `json:"descTime"` + } + + RemoveTopic struct { + ID string `json:"descId"` + } + + Restrict bool + + Announce bool + + PermissionChange struct { + JIDs []string `json:"participants"` + } +} + +func (cud *ChatUpdateData) UnmarshalJSON(data []byte) error { + var arr []json.RawMessage + err := json.Unmarshal(data, &arr) + if err != nil { + return err + } else if len(arr) < 3 { + return nil + } + + err = json.Unmarshal(arr[0], &cud.Action) + if err != nil { + return err + } + + err = json.Unmarshal(arr[1], &cud.SenderJID) + if err != nil { + return err + } + cud.SenderJID = strings.Replace(cud.SenderJID, OldUserSuffix, NewUserSuffix, 1) + + var unmarshalTo interface{} + switch cud.Action { + case ChatActionNameChange: + unmarshalTo = &cud.NameChange + case ChatActionAddTopic: + unmarshalTo = &cud.AddTopic + case ChatActionRemoveTopic: + unmarshalTo = &cud.RemoveTopic + case ChatActionRestrict: + unmarshalTo = &cud.Restrict + case ChatActionAnnounce: + unmarshalTo = &cud.Announce + case ChatActionPromote, ChatActionDemote: + unmarshalTo = &cud.PermissionChange + default: + return nil + } + err = json.Unmarshal(arr[2], unmarshalTo) + if err != nil { + return err + } + cud.NameChange.SetBy = strings.Replace(cud.NameChange.SetBy, OldUserSuffix, NewUserSuffix, 1) + for index, jid := range cud.PermissionChange.JIDs { + cud.PermissionChange.JIDs[index] = strings.Replace(jid, OldUserSuffix, NewUserSuffix, 1) + } + return nil +} + +type ChatUpdateHandler interface { + whatsapp.Handler + HandleChatUpdate(ChatUpdate) +} + +func (ext *ExtendedConn) handleMessageChatUpdate(message []byte) { + var event ChatUpdate + err := json.Unmarshal(message, &event) + if err != nil { + ext.jsonParseError(err) + return + } + event.JID = strings.Replace(event.JID, OldUserSuffix, NewUserSuffix, 1) + for _, handler := range ext.handlers { + chatUpdateHandler, ok := handler.(ChatUpdateHandler) + if !ok { + continue + } + go chatUpdateHandler.HandleChatUpdate(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/cmd.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/cmd.go new file mode 100644 index 00000000..69dbe60c --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/cmd.go @@ -0,0 +1,59 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + "strings" + + "github.com/matterbridge/go-whatsapp" +) + +type CommandType string + +const ( + CommandPicture CommandType = "picture" +) + +type Command struct { + Type CommandType `json:"type"` + JID string `json:"jid"` + + *ProfilePicInfo +} + +type CommandHandler interface { + whatsapp.Handler + HandleCommand(Command) +} + +func (ext *ExtendedConn) handleMessageCommand(message []byte) { + var event Command + err := json.Unmarshal(message, &event) + if err != nil { + ext.jsonParseError(err) + return + } + event.JID = strings.Replace(event.JID, OldUserSuffix, NewUserSuffix, 1) + for _, handler := range ext.handlers { + commandHandler, ok := handler.(CommandHandler) + if !ok { + continue + } + go commandHandler.HandleCommand(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/conn.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/conn.go new file mode 100644 index 00000000..5084cb5a --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/conn.go @@ -0,0 +1,60 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + + "github.com/matterbridge/go-whatsapp" +) + +type ConnInfo struct { + ProtocolVersion []int `json:"protoVersion"` + BinaryVersion int `json:"binVersion"` + Phone struct { + WhatsAppVersion string `json:"wa_version"` + MCC string `json:"mcc"` + MNC string `json:"mnc"` + OSVersion string `json:"os_version"` + DeviceManufacturer string `json:"device_manufacturer"` + DeviceModel string `json:"device_model"` + OSBuildNumber string `json:"os_build_number"` + } `json:"phone"` + Features map[string]interface{} `json:"features"` + PushName string `json:"pushname"` +} + +type ConnInfoHandler interface { + whatsapp.Handler + HandleConnInfo(ConnInfo) +} + +func (ext *ExtendedConn) handleMessageConn(message []byte) { + var event ConnInfo + err := json.Unmarshal(message, &event) + if err != nil { + ext.jsonParseError(err) + return + } + for _, handler := range ext.handlers { + connInfoHandler, ok := handler.(ConnInfoHandler) + if !ok { + continue + } + connInfoHandler.HandleConnInfo(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/jsonmessage.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/jsonmessage.go new file mode 100644 index 00000000..0b5a791c --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/jsonmessage.go @@ -0,0 +1,102 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + + "github.com/matterbridge/go-whatsapp" +) + +type JSONMessage []json.RawMessage + +type JSONMessageType string + +const ( + MessageMsgInfo JSONMessageType = "MsgInfo" + MessageMsg JSONMessageType = "Msg" + MessagePresence JSONMessageType = "Presence" + MessageStream JSONMessageType = "Stream" + MessageConn JSONMessageType = "Conn" + MessageProps JSONMessageType = "Props" + MessageCmd JSONMessageType = "Cmd" + MessageChat JSONMessageType = "Chat" +) + +func (ext *ExtendedConn) AddHandler(handler whatsapp.Handler) { + ext.Conn.AddHandler(handler) + ext.handlers = append(ext.handlers, handler) +} + +func (ext *ExtendedConn) HandleError(error) {} + +type UnhandledJSONMessageHandler interface { + whatsapp.Handler + HandleUnhandledJSONMessage(string) +} + +type JSONParseErrorHandler interface { + whatsapp.Handler + HandleJSONParseError(error) +} + +func (ext *ExtendedConn) jsonParseError(err error) { + for _, handler := range ext.handlers { + errorHandler, ok := handler.(JSONParseErrorHandler) + if !ok { + continue + } + errorHandler.HandleJSONParseError(err) + } +} + +func (ext *ExtendedConn) HandleJsonMessage(message string) { + msg := JSONMessage{} + err := json.Unmarshal([]byte(message), &msg) + if err != nil || len(msg) < 2 { + ext.jsonParseError(err) + return + } + + var msgType JSONMessageType + json.Unmarshal(msg[0], &msgType) + + switch msgType { + case MessagePresence: + ext.handleMessagePresence(msg[1]) + case MessageStream: + ext.handleMessageStream(msg[1:]) + case MessageConn: + ext.handleMessageConn(msg[1]) + case MessageProps: + ext.handleMessageProps(msg[1]) + case MessageMsgInfo, MessageMsg: + ext.handleMessageMsgInfo(msgType, msg[1]) + case MessageCmd: + ext.handleMessageCommand(msg[1]) + case MessageChat: + ext.handleMessageChatUpdate(msg[1]) + default: + for _, handler := range ext.handlers { + ujmHandler, ok := handler.(UnhandledJSONMessageHandler) + if !ok { + continue + } + ujmHandler.HandleUnhandledJSONMessage(message) + } + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/msginfo.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/msginfo.go new file mode 100644 index 00000000..e929ec90 --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/msginfo.go @@ -0,0 +1,90 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + "strings" + + "github.com/matterbridge/go-whatsapp" +) + +type MsgInfoCommand string + +const ( + MsgInfoCommandAck MsgInfoCommand = "ack" + MsgInfoCommandAcks MsgInfoCommand = "acks" +) + +type Acknowledgement int + +const ( + AckMessageSent Acknowledgement = 1 + AckMessageDelivered Acknowledgement = 2 + AckMessageRead Acknowledgement = 3 +) + +type JSONStringOrArray []string + +func (jsoa *JSONStringOrArray) UnmarshalJSON(data []byte) error { + var str string + if json.Unmarshal(data, &str) == nil { + *jsoa = []string{str} + return nil + } + var strs []string + json.Unmarshal(data, &strs) + *jsoa = strs + return nil +} + +type MsgInfo struct { + Command MsgInfoCommand `json:"cmd"` + IDs JSONStringOrArray `json:"id"` + Acknowledgement Acknowledgement `json:"ack"` + MessageFromJID string `json:"from"` + SenderJID string `json:"participant"` + ToJID string `json:"to"` + Timestamp int64 `json:"t"` +} + +type MsgInfoHandler interface { + whatsapp.Handler + HandleMsgInfo(MsgInfo) +} + +func (ext *ExtendedConn) handleMessageMsgInfo(msgType JSONMessageType, message []byte) { + var event MsgInfo + err := json.Unmarshal(message, &event) + if err != nil { + ext.jsonParseError(err) + return + } + event.MessageFromJID = strings.Replace(event.MessageFromJID, OldUserSuffix, NewUserSuffix, 1) + event.SenderJID = strings.Replace(event.SenderJID, OldUserSuffix, NewUserSuffix, 1) + event.ToJID = strings.Replace(event.ToJID, OldUserSuffix, NewUserSuffix, 1) + if msgType == MessageMsg { + event.SenderJID = event.ToJID + } + for _, handler := range ext.handlers { + msgInfoHandler, ok := handler.(MsgInfoHandler) + if !ok { + continue + } + go msgInfoHandler.HandleMsgInfo(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/presence.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/presence.go new file mode 100644 index 00000000..d70a753a --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/presence.go @@ -0,0 +1,67 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + "strings" + + "github.com/matterbridge/go-whatsapp" +) + +type PresenceType string + +const ( + PresenceUnavailable PresenceType = "unavailable" + PresenceAvailable PresenceType = "available" + PresenceComposing PresenceType = "composing" +) + +type Presence struct { + JID string `json:"id"` + SenderJID string `json:"participant"` + Status PresenceType `json:"type"` + Timestamp int64 `json:"t"` + Deny bool `json:"deny"` +} + +type PresenceHandler interface { + whatsapp.Handler + HandlePresence(Presence) +} + +func (ext *ExtendedConn) handleMessagePresence(message []byte) { + var event Presence + err := json.Unmarshal(message, &event) + if err != nil { + ext.jsonParseError(err) + return + } + event.JID = strings.Replace(event.JID, OldUserSuffix, NewUserSuffix, 1) + if len(event.SenderJID) == 0 { + event.SenderJID = event.JID + } else { + event.SenderJID = strings.Replace(event.SenderJID, OldUserSuffix, NewUserSuffix, 1) + } + for _, handler := range ext.handlers { + presenceHandler, ok := handler.(PresenceHandler) + if !ok { + continue + } + go presenceHandler.HandlePresence(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/props.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/props.go new file mode 100644 index 00000000..dcfdef9e --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/props.go @@ -0,0 +1,68 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + + "github.com/matterbridge/go-whatsapp" +) + +type ProtocolProps struct { + WebPresence bool `json:"webPresence"` + NotificationQuery bool `json:"notificationQuery"` + FacebookCrashLog bool `json:"fbCrashlog"` + Bucket string `json:"bucket"` + GIFSearch string `json:"gifSearch"` + Spam bool `json:"SPAM"` + SetBlock bool `json:"SET_BLOCK"` + MessageInfo bool `json:"MESSAGE_INFO"` + MaxFileSize int `json:"maxFileSize"` + Media int `json:"media"` + GroupNameLength int `json:"maxSubject"` + GroupDescriptionLength int `json:"groupDescLength"` + MaxParticipants int `json:"maxParticipants"` + VideoMaxEdge int `json:"videoMaxEdge"` + ImageMaxEdge int `json:"imageMaxEdge"` + ImageMaxKilobytes int `json:"imageMaxKBytes"` + Edit int `json:"edit"` + FwdUIStartTimestamp int `json:"fwdUiStartTs"` + GroupsV3 int `json:"groupsV3"` + RestrictGroups int `json:"restrictGroups"` + AnnounceGroups int `json:"announceGroups"` +} + +type ProtocolPropsHandler interface { + whatsapp.Handler + HandleProtocolProps(ProtocolProps) +} + +func (ext *ExtendedConn) handleMessageProps(message []byte) { + var event ProtocolProps + err := json.Unmarshal(message, &event) + if err != nil { + ext.jsonParseError(err) + return + } + for _, handler := range ext.handlers { + protocolPropsHandler, ok := handler.(ProtocolPropsHandler) + if !ok { + continue + } + go protocolPropsHandler.HandleProtocolProps(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/stream.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/stream.go new file mode 100644 index 00000000..f2b222d5 --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/stream.go @@ -0,0 +1,63 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + + "github.com/matterbridge/go-whatsapp" +) + +type StreamType string + +const ( + StreamUpdate = "update" + StreamSleep = "asleep" +) + +type StreamEvent struct { + Type StreamType + Boolean bool + Version string +} + +type StreamEventHandler interface { + whatsapp.Handler + HandleStreamEvent(StreamEvent) +} + +func (ext *ExtendedConn) handleMessageStream(message []json.RawMessage) { + var event StreamEvent + err := json.Unmarshal(message[0], &event.Type) + if err != nil { + ext.jsonParseError(err) + return + } + + if event.Type == StreamUpdate && len(message) > 4 { + json.Unmarshal(message[1], event.Boolean) + json.Unmarshal(message[2], event.Version) + } + + for _, handler := range ext.handlers { + streamHandler, ok := handler.(StreamEventHandler) + if !ok { + continue + } + go streamHandler.HandleStreamEvent(event) + } +} diff --git a/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/whatsapp.go b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/whatsapp.go new file mode 100644 index 00000000..bd28a06d --- /dev/null +++ b/vendor/github.com/matterbridge/mautrix-whatsapp/whatsapp-ext/whatsapp.go @@ -0,0 +1,132 @@ +// mautrix-whatsapp - A Matrix-WhatsApp puppeting bridge. +// Copyright (C) 2019 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package whatsappExt + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "strings" + + "github.com/matterbridge/go-whatsapp" +) + +const ( + OldUserSuffix = "@c.us" + NewUserSuffix = "@s.whatsapp.net" +) + +type ExtendedConn struct { + *whatsapp.Conn + + handlers []whatsapp.Handler +} + +func ExtendConn(conn *whatsapp.Conn) *ExtendedConn { + ext := &ExtendedConn{ + Conn: conn, + } + ext.Conn.AddHandler(ext) + return ext +} + +type GroupInfo struct { + JID string `json:"jid"` + OwnerJID string `json:"owner"` + + Name string `json:"subject"` + NameSetTime int64 `json:"subjectTime"` + NameSetBy string `json:"subjectOwner"` + + Topic string `json:"desc"` + TopicID string `json:"descId"` + TopicSetAt int64 `json:"descTime"` + TopicSetBy string `json:"descOwner"` + + GroupCreated int64 `json:"creation"` + + Status int16 `json:"status"` + + Participants []struct { + JID string `json:"id"` + IsAdmin bool `json:"isAdmin"` + IsSuperAdmin bool `json:"isSuperAdmin"` + } `json:"participants"` +} + +func (ext *ExtendedConn) GetGroupMetaData(jid string) (*GroupInfo, error) { + data, err := ext.Conn.GetGroupMetaData(jid) + if err != nil { + return nil, fmt.Errorf("failed to get group metadata: %v", err) + } + content := <-data + + info := &GroupInfo{} + err = json.Unmarshal([]byte(content), info) + if err != nil { + return info, fmt.Errorf("failed to unmarshal group metadata: %v", err) + } + + for index, participant := range info.Participants { + info.Participants[index].JID = strings.Replace(participant.JID, OldUserSuffix, NewUserSuffix, 1) + } + info.NameSetBy = strings.Replace(info.NameSetBy, OldUserSuffix, NewUserSuffix, 1) + info.TopicSetBy = strings.Replace(info.TopicSetBy, OldUserSuffix, NewUserSuffix, 1) + + return info, nil +} + +type ProfilePicInfo struct { + URL string `json:"eurl"` + Tag string `json:"tag"` + + Status int16 `json:"status"` +} + +func (ppi *ProfilePicInfo) Download() (io.ReadCloser, error) { + resp, err := http.Get(ppi.URL) + if err != nil { + return nil, err + } + return resp.Body, nil +} + +func (ppi *ProfilePicInfo) DownloadBytes() ([]byte, error) { + body, err := ppi.Download() + if err != nil { + return nil, err + } + defer body.Close() + data, err := ioutil.ReadAll(body) + return data, err +} + +func (ext *ExtendedConn) GetProfilePicThumb(jid string) (*ProfilePicInfo, error) { + data, err := ext.Conn.GetProfilePicThumb(jid) + if err != nil { + return nil, fmt.Errorf("failed to get avatar: %v", err) + } + content := <-data + info := &ProfilePicInfo{} + err = json.Unmarshal([]byte(content), info) + if err != nil { + return info, fmt.Errorf("failed to unmarshal avatar info: %v", err) + } + return info, nil +} -- cgit v1.2.3